diff --git a/.agents/skills/webspeak-plugin-development/SKILL.md b/.agents/skills/webspeak-plugin-development/SKILL.md
index 982a988..9db0f05 100644
--- a/.agents/skills/webspeak-plugin-development/SKILL.md
+++ b/.agents/skills/webspeak-plugin-development/SKILL.md
@@ -1,20 +1,32 @@
---
name: webspeak-plugin-development
-description: Develop, review, package, and validate portable WebSpeak functional .wplugin plugins through the public API. Use for server or instance plugins and GitHub plugin distribution, not .wskin appearance packages or their internal components.
+description: Build, review and package WebSpeak API v2 functional applications with standard browser code and optional Node services, including GitHub distribution. Use for .wplugin applications rather than .wskin skins or their presentation components.
---
-# WebSpeak Plugin Development
+# WebSpeak Application Development
-Build a functional package without editing WebSpeak runtime, SDK, skins, or administration code. A missing host capability needs a separate API change authorized by the user; do not invent methods or reach into Vue instances.
+Read the current [application runtime guide](../../../docs/PLUGIN_DEVELOPMENT.md). In a standalone checkout, use `https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/dev/docs/PLUGIN_DEVELOPMENT.md`. Confirm API v2 support on the target instance; stable v0.2.9 has none. API v1 and its shared-room examples are removed.
-Read the current [plugin development guide](../../../docs/PLUGIN_DEVELOPMENT.md) before implementing. In a standalone checkout, use the guide at `https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak/blob/dev/docs/PLUGIN_DEVELOPMENT.md`. Confirm that the target instance supports API v1; released v0.2.9 does not.
+Develop an independent application, not a list of host business RPC calls. Use ordinary HTML/CSS/JavaScript, browser APIs and optional Node services with author-defined routes, dependencies and state. The host provides authenticated context, configuration, package/lifecycle management and a separate origin. It supplies no room API or feature permission list. Keep application business logic in its package; a host defect or missing general runtime primitive is a separate host change.
-Choose the scope that matches the user's intent: `server` uses actual TS target + channel rooms; `instance` shares a room across connected users of one gateway. Neither synchronizes separate gateways or TS native clients. Public plugin config is not secret storage. Do not repurpose TS administration credentials.
+Start with `docs/templates/plugin-app/` or the distribution repository's `template/`. Put frontend output under `client/` with relative assets and optional `.mjs/.cjs` activation code under `server/`. Include audited dependencies or bundle them; the host does not run package installers. Native dependencies must match target OS and Node ABI. Build with `node scripts/build-plugin.mjs SOURCE_DIR OUTPUT.wplugin`, or the standalone distribution builder, then import the actual output.
-Keep UI/behavior in `.wplugin` JSON: validated manifest, HTML, script, complete light and dark styles. Use only `window.webspeak.ready` and the documented `room` API. Never assume a particular skin DOM or CSS selector. Use an independent panel, responsive layout, translated labels, and accessible controls. Media autoplay needs participant action when blocked.
+Use `webspeak.ready`, `getContext()`, `onContextChange()` and `signal` for generic context; implement functionality through native browser/Node code. Scope provides admission and a grouping key, not synchronization. Server logic must enforce scope and business access. Prefer host-verified `req.webspeak` over browser-supplied identities or channels. Temporary runtime URLs are credentials: do not persist, broadcast or log them. Backend private configuration is encrypted at rest and omitted from admin reads; public configuration is user-visible.
-Represent collaboration as small JSON state. Use revision CAS, recover conflicts from a fresh snapshot, reject old room IDs/versions, and derive playback progress from gateway time rather than sending frames or high-frequency ticks. Clean timers, subscriptions and media on pagehide. The example is `docs/examples/watch-together/` in the host repo and `examples/watch-together/` in the distribution repo.
+Treat applications as trusted code. Node services have the WebSpeak OS account's privileges; process separation and heap limits are not a hostile-code sandbox. Frontends use a separate origin with standard browser capabilities. Browser permission, secure-context, user-gesture, CORS and network requirements apply. The shared application origin does not isolate mutually hostile plugins. Explain these boundaries accurately and review dependencies rather than inventing host feature permissions.
-Build with `node --import tsx scripts/build-plugin.mjs SOURCE_DIR OUTPUT.wplugin` in a host checkout (the provided template reads manifest.json, panel.html, player.js, light.css and dark.css), or use the standalone distribution repo builder. Validate the actual resulting package through host import. For GitHub distribution provide real package SHA-256 and a fixed commit/tag, then add the repository to the catalog. Publishing or deploying requires the user's task authorization; do not infer it from this skill.
+Provide responsive light/dark styles and suitable language handling using context. Keep UI in the application panel without relying on skin DOM. Clean timers, subscriptions, media and sockets on exit/revocation. Persist backend state in `dataDir`, never extracted code directories. Implement concurrency and atomic writes appropriate to the application.
-Verify two independent participants: load/play/pause/seek, late join, concurrent writes, target/channel isolation, disconnect, close, administrator disable/update and re-open. Check both themes and narrow layout. Distinguish mocked gateway tests from a real browser playback test and real TS connectivity. Only claim capabilities the evidence demonstrates. Keep private credentials and diagnostic recordings outside published artifacts.
+Verify import, trust, enable, update, failure/restart, custom routes, persistence and revocation. Collaborative apps need two real browser participants and late-join/concurrent-change/channel-boundary/disconnect tests. Distinguish mocked HTTP, actual processes, browser interactions and independent networks. Claim only demonstrated capabilities. Keep credentials and diagnostics out of artifacts.
+
+For distribution use schema v2 catalog entries, matching manifest, raw-package SHA-256 and fixed refs. Publishing and deployment follow the user's task authorization; this skill does not itself authorize either.
+
+## Floating host workspace
+
+The host owns a skin-independent draggable launcher, application library and non-modal app window. Do not add launch controls to a particular skin or inspect its DOM. Apps render their responsive light/dark UI inside the supplied iframe; the host supplies dragging, minimize/maximize/restore and close controls. The host window uses the standard `color-scheme` for its light/dark fallback without inheriting skin component styles. Do not duplicate host window chrome or block the workspace with a page-wide modal backdrop.
+
+Minimizing or switching to the library retains the same iframe and app session. Transfers and playback must survive those actions. Closing the window, replacing the active app or host context revocation ends that session; only one frontend app is currently hosted at a time. Do not equate a hidden iframe with app exit. Verify resize, narrow screens, theme changes, minimize/resume without reload and close/revocation cleanup. Keep the user-facing window focused on functionality and actionable status; omit repeated runtime/permission disclaimers. Administrator trust and security review remain part of enablement.
+
+## Instance authorization
+
+The public host asks once per browser origin for third-party skins and functional applications together. No decision or refusal allows only Day, Night and ILLUSIA; KAAK also requires consent. The last item in the skin menu reopens this setting. Revocation must close/revoke the active frontend application while preserving independently enabled backend services. Do not add per-app copies of the same host authorization prompt, bypass the host gate or confuse this user decision with administrator package trust or browser-native permission prompts.
diff --git a/.agents/skills/webspeak-skin-development/SKILL.md b/.agents/skills/webspeak-skin-development/SKILL.md
index d1ed6bd..6543342 100644
--- a/.agents/skills/webspeak-skin-development/SKILL.md
+++ b/.agents/skills/webspeak-skin-development/SKILL.md
@@ -29,3 +29,7 @@ Develop the skin as a portable `.wskin` package. A skin task should not require
- `docs/SKIN_DEVELOPMENT.md` — the single current reference for skin formats, runtime APIs, permissions, data, actions, CSS hooks, security, and QA.
- `docs/examples/ILLUSIA-VOICE.md` and `docs/examples/OPEN-VOICE-SURFACE.md` — full skin and surface examples.
+
+## Instance authorization
+
+Current development builds replace per-skin consent dialogs with one origin-scoped user decision covering third-party skins and functional apps. Without consent only the fixed official Day, Night and ILLUSIA skins are available; bundled KAAK also requires consent. The host skin switcher owns the final authorization item. Packages must not duplicate or bypass it. Revocation must cancel pending activation, remove third-party CSS/components and stop workers. Continue enforcing manifest permissions, credential redaction, trusted action validation and package digests internally; one-time consent does not extend the public API. See the current guide for release compatibility.
diff --git a/Dockerfile b/Dockerfile
index d49112f..38a2639 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -37,7 +37,7 @@ COPY --from=build --chown=node:node /app/scripts/docker-healthcheck.mjs ./script
USER node
VOLUME ["/data"]
-EXPOSE 3040/tcp 3041/tcp 39087/udp 40000-40099/udp
+EXPOSE 3040/tcp 3041/tcp 3042/tcp 39087/udp 40000-40099/udp
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD ["node", "scripts/docker-healthcheck.mjs"]
diff --git a/README.md b/README.md
index d846c58..85c4ff5 100644
--- a/README.md
+++ b/README.md
@@ -91,9 +91,9 @@ Data persists in the `webspeak-data` volume. The Compose file uses host networki
| 类型 · Type | 入口 · Resources |
| --- | --- |
| 皮肤包 · Skin packages | [皮肤索引 · Catalog](https://github.com/Huddle-Up-Forge/webspeak-skins) · [Discord Voice](https://github.com/Huddle-Up-Forge/webspeak-skin-discord-voice) |
-| 功能插件 · Functional plugins **(dev)** | [分发仓库与一起观看示例 · Catalog & Watch Together](https://github.com/Huddle-Up-Forge/webspeak-plugin) · [开发指南 · Guide](./docs/PLUGIN_DEVELOPMENT.md) · [Agent Skill](./.agents/skills/webspeak-plugin-development/SKILL.md) |
+| 功能插件 · Functional plugins **(dev)** | [应用目录与开发起点 · Catalog & application starter](https://github.com/Huddle-Up-Forge/webspeak-plugin) · [开发指南 · Guide](./docs/PLUGIN_DEVELOPMENT.md) · [Agent Skill](./.agents/skills/webspeak-plugin-development/SKILL.md) |
-皮肤包负责界面、布局及其附属小组件;功能插件在独立面板中提供协作能力。功能插件需要当前 `dev` 运行时,尚未包含在 v0.2.9 中。
+皮肤包负责界面、布局及其附属小组件;功能插件使用标准浏览器环境和可选 Node 后端,自行实现业务功能。功能插件需要当前 `dev` 运行时,尚未包含在 v0.2.9 中。
Skins own appearance, layout and attached widgets. Functional plugins provide collaboration in an independent panel and currently require the `dev` runtime; they are not included in v0.2.9.
diff --git a/docs/PLUGIN_DEVELOPMENT.md b/docs/PLUGIN_DEVELOPMENT.md
index ee5f248..7eb8255 100644
--- a/docs/PLUGIN_DEVELOPMENT.md
+++ b/docs/PLUGIN_DEVELOPMENT.md
@@ -1,158 +1,152 @@
-# WebSpeak 功能插件开发 / Functional plugin development
+# WebSpeak 功能应用开发 / Functional application development
-本文描述 dev 分支的功能插件 API v1。实例需要包含插件商店;正式版 v0.2.9 尚无此接口。功能包 `.wplugin` 与外观包 `.wskin`、皮肤内部组件及其 API 独立。
+当前 `dev` 使用应用运行时 **API v2**。正式版 v0.2.9 不包含该能力。`.wplugin` 与 `.wskin` 完全独立;旧 API v1、共享房间协议及其两个示例已移除,不兼容旧包。
-## 使用与作用域
+插件是作者自己的应用:标准 HTML/CSS/JavaScript 前端,加上可选的 Node 后端。可以使用框架、浏览器原生 API、自己的 HTTP/WebSocket 协议、网络客户端和数据模型。宿主不提供按音乐、文件、视频等功能划分的业务 API,也不提供 `room.read/write` 或下载权限表。浏览器原有的安全上下文、用户手势、权限许可、跨域及网络可达性要求仍然适用。
-管理员进入 `/admin/plugins`,从 [GitHub 分发仓库](https://github.com/Huddle-Up-Forge/webspeak-plugin) 安装或导入本地 `.wplugin`。检查作者、许可证和权限后,选择作用域、保存公开配置并启用。安装、更新后默认禁用,不能静默获取新权限。管理写操作受管理员会话、同源和 CSRF 保护,并记录审计。
+## 管理与部署
-用户连接语音工作台后,通过独立的“插件功能”入口打开隔离面板,不依赖皮肤的挂载位置。关闭面板或返回列表会退出插件房间、销毁 iframe 并停止媒体;插件不修改原生工作台 DOM。
+管理员在 `/admin/plugins` 从 GitHub 安装或导入包,审核代码和依赖,配置作用域,勾选信任后启用。每次安装、更新均撤销信任并禁用,需要重新审核。审核是人工准入流程,校验包哈希不等于审核代码。写操作继续使用管理员认证、同源检查、CSRF 和审计。
-| 类型 | 配置和房间边界 |
+**信任边界:** 前端运行在独立源,和工作台 DOM 分离,使用真实浏览器环境。Node 后端运行于独立子进程,拥有 WebSpeak 服务账户的操作系统权限,能够访问该账户可访问的网络和文件。独立进程、目录和 JS 堆上限用于生命周期与故障控制,不是恶意代码安全沙箱。仅安装审核且信任的应用。
+
+运行时默认监听 `0.0.0.0:3042`:
+
+| 环境变量 | 用途 |
| --- | --- |
-| `server` 服务器插件 | 配置允许的 TS `host:port`,用户按实际 TS 目标及频道进入各自房间 |
-| `instance` WebSpeak 实例插件 | 同一网关的已连接用户共享一个插件房间,跨 TS 服务器和频道 |
+| `WEBSPEAK_PLUGIN_PORT` | 应用端口,默认 3042 |
+| `WEBSPEAK_PLUGIN_HOST` | 监听地址,默认 0.0.0.0 |
+| `WEBSPEAK_PLUGIN_PUBLIC_ORIGIN` | 初始公开源,例如 `https://apps.example.com` |
-服务器绑定使用网关解析后的实际连接地址,不接受插件或浏览器自报的目标。使用 SRV、Nickname 或别名时,在实例连接列表核对实际目标。配置支持 `host:port`、`host#port`、`[IPv6]:port`,保存时规范化。服务器插件未配置目标时不能启用。切频道会退出旧服务器插件房间,实例插件保留房间。断线、重连、卸载、更新或管理员修改配置会关闭旧上下文,需重新打开。
+本地工作台为 `127.0.0.1` 时自动使用 `localhost:3042`,反向亦然,以保持源分离。公网部署必须给应用配置独立 HTTPS 源,在管理页“应用运行时”保存;该设置优先于环境变量。代理应将该源的全部路径转发至应用端口,支持 WebSocket 升级和 SSE 长连接,关闭 SSE 缓冲。不要让代理记录 `/apps/…` 中的访问凭证,也不要与主站共用域 Cookie。
-“所有人”指打开插件的 WebSpeak 浏览器参与者,TS 原生客户端不会运行网页插件。不同 WebSpeak 网关目前不共享插件房间。使用浏览器直连中继网关时,插件目录和房间属于实际连接的语音网关,需要在那里安装配置;只使用 UDP 加速不会改变房间归属。
+```caddyfile
+apps.example.com {
+ reverse_proxy 127.0.0.1:3042
+}
+```
-## 包格式
+容器需映射应用端口,或让代理接入相同容器网络。端口/监听地址改变需重启;公开源可在后台更新,会撤销已有应用会话。主站直接使用 TLS 时,运行端口使用相同证书;TLS 在代理终止时,上游使用 HTTP。监听失败会保留主站和语音服务,后台显示不可用,修复后需重启。配置为主站自身源时拒绝打开应用。
-`.wplugin` 是 UTF-8 JSON,最多 512 KiB,不是 ZIP;不包含服务端可执行文件、原生模块或任意路径。
+## 作用域与身份
+
+`server`:管理员配置允许的实际 TS `host:port`,用户按真实 TS 目标和频道获得作用域标识。`instance`:当前语音网关的已连接用户获得同一实例标识。作用域负责宿主准入和提供上下文,**不会替作者创建共享房间或自动同步数据**。应用后端应按 `request.webspeak.scope.key` 分组,并自行实现业务授权和同步。
+
+TS 目标由实际语音连接解析,插件不能自报身份或频道。目标支持 `host:port`、`host#port`、`[IPv6]:port`,保存时规范化;SRV/Nickname 场景应核对实际目标。服务器范围切换频道后需重开;实例范围的频道变更通过上下文更新。断开、重连、更新、禁用、重启、配置修改或卸载会撤销旧凭证并关闭连接。服务端可以在没有打开面板时执行后台任务,直到禁用或停止。
+
+入口属于实际语音网关;浏览器直连另一中继网关时,在那个网关安装配置。原生 TS 客户端不会执行网页应用,不同网关不会自动共享状态。作者可自行实现跨实例服务。
+
+## 包格式与构建
+
+复制 [通用起点](templates/plugin-app/manifest.json),修改 ID、元数据和业务代码。它只展示上下文及自定义计数路由,不是商店预装插件。
+
+```text
+my-app/
+ manifest.json
+ client/index.html
+ client/main.js
+ client/style.css
+ server/main.mjs # 可选
+ server/node_modules/ # 可选,已审核的运行依赖
+```
```json
{
- "manifest": {
- "apiVersion": 1, "id": "community.example", "name": "Example",
- "version": "1.0.0", "author": "Author", "license": "MIT",
- "description": "Collaborative panel",
- "scopes": ["server", "instance"],
- "permissions": ["room.read", "room.write"]
- },
- "html": "",
- "script": "(async () => { const context = await webspeak.ready; })();",
- "styles": {
- "light": "body { background: #fff; color: #16332e; }",
- "dark": "body { background: #20242b; color: #edf5f2; }"
- }
+ "apiVersion": 2,
+ "id": "community.my-app",
+ "name": "My application",
+ "version": "1.0.0",
+ "author": "Author",
+ "license": "MIT",
+ "description": "An independently implemented application",
+ "scopes": ["server", "instance"],
+ "client": { "entry": "client/index.html" },
+ "server": { "entry": "server/main.mjs" }
}
```
-两个基础样式都必须提供。宿主根据当前皮肤文字明暗推断基础配色,发送 `context.theme`,一次只启用一个样式表。iframe 不继承皮肤 CSS,无需适配每款皮肤的组件位置。语言为 `zh/en/de/ru/ja`,建议五种文案和英文回退。每段 HTML、脚本或样式最多 256 KiB,总包仍受 512 KiB 限制。ID 为小写字母、数字、点和连字符,最长 80 字符。
-
-完整示例源文件在 [watch-together](examples/watch-together/manifest.json):`manifest.json`、`panel.html`、`player.js`、`light.css`、`dark.css`。
+纯前端应用删除 `server` 声明。前端框架产物放入 `client/`,静态引用使用相对路径,不能假设根路径为 `/`。后端入口支持 `.mjs/.cjs`,依赖放在 `server/` 内或打包为自包含文件。宿主不会执行 `npm install`、安装脚本或原生编译;原生依赖需匹配目标 Node ABI/操作系统,不一定跨平台。运行环境为宿主 Node,当前项目要求 Node 22 或更高。
```sh
-node --import tsx scripts/build-plugin.mjs docs/examples/watch-together docs/examples/watch-together.wplugin
-node --import tsx --test src/plugins/plugins.test.ts
+node scripts/build-plugin.mjs docs/templates/plugin-app /tmp/application.wplugin
```
-构建器读取上述五个文件。其他工具链只需生成同格式 JSON。独立插件仓库不需要 WebSpeak 源码即可生成包;宿主导入时也会校验。
+构建器是独立 Node 脚本,可复制到插件仓库,无需导入 WebSpeak 源码。`.wplugin` 是 UTF-8 JSON:`{manifest,files}`;`files` 是路径到 `{encoding:"utf8"|"base64",data:string}` 的映射。支持普通 `client/`、`server/` 文件;禁止越界路径、符号链接、Windows 设备名、大小写冲突及文件/目录别名。入口必须是 UTF-8。封装上限 48 MiB、解码内容 32 MiB、单文件 16 MiB、4096 个文件,安装上限 50 个。宿主导入时完整校验。
-## 公共浏览器 API
+## 浏览器上下文
-脚本开始前,宿主提供只读 `window.webspeak`,不需要导入内部 Vue 组件。
+宿主在入口 HTML 注入外部脚本,在应用模块运行前提供:
-```ts
-type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
-interface Snapshot {
- roomId: string;
- revision: number;
- state: JsonValue; // 空房间初始为 null
- serverTime: number; // 网关 Unix 毫秒时间
- participants: { id: string; nickname: string }[];
-}
-interface Context {
- self: { id: string; nickname: string }; // 临时会话 ID,不是 TS 私钥或 UID
- config: JsonValue; // 管理员提供的公开配置
- scope: "server" | "instance";
- snapshot: Snapshot;
- theme: "light" | "dark";
- language: "zh" | "en" | "de" | "ru" | "ja";
-}
-interface WebSpeakPluginAPI {
- apiVersion: 1;
- ready: Promise;
- room: {
- snapshot(): Promise;
- update(expectedRevision: number, state: JsonValue): Promise;
- subscribe(listener: (snapshot: Snapshot) => void): () => void;
+```js
+const context = await window.webspeak.ready;
+const unsubscribe = webspeak.onContextChange(next => render(next));
+const latest = webspeak.getContext();
+const response = await fetch(context.serverUrl + '/my-route', {
+ method: 'POST', body: JSON.stringify({anything: 'defined by the application'}),
+ signal: webspeak.signal
+});
+const socket = new WebSocket(context.socketUrl + '/my-socket');
+```
+
+| 上下文字段 | 内容 |
+| --- | --- |
+| `apiVersion` | 2 |
+| `plugin` | manifest |
+| `self` | 当前公开 `id/nickname/uid?` |
+| `connection` | 真实 `target/channelId` 和当前频道公开 `members`(`id/nickname/uid?`) |
+| `scope` | `{type:"server"|"instance",key:string}`;分组标识不能直接当文件路径 |
+| `config` | 管理员公开 JSON,所有参与者可读 |
+| `theme/language` | `light/dark` 和 `zh/en/de/ru/ja`,同步到 `` 与 `lang` |
+| `appId` | 本次打开的公开标识,不是长期身份或认证凭据 |
+| `serverUrl/socketUrl` | 此会话的后端 HTTP/WS 根;纯前端为 `null` |
+| `contextUrl` | 此会话最新上下文地址 |
+
+运行时 URL 含临时凭证,不应持久化、广播或记录。`webspeak.signal` 在撤销或退出时中止,仍需清理自己的定时器、网络、媒体和订阅。应用应提供两种基础配色及适合的语言回退。
+
+用原生 `fetch`、`WebSocket`、`RTCPeerConnection`、文件选择/下载、IndexedDB、Canvas 等编写功能。独立源存储遵循原生规则;同一运行源的应用共享该源存储,请按插件 ID 命名,不能把此设计当作互不信任插件间的隔离。服务端持久化使用 `dataDir`。
+
+关闭面板会销毁 iframe 并取消未完成的打开操作。宿主每秒检查会话有效性,撤销后终止 HTTP、SSE、WS 和旧页面。控制平面只传上下文与生命周期;业务数据使用独立应用服务,不经过语音 WebSocket。
+
+## 可选 Node 后端
+
+```js
+export default async function activate({ dataDir, config, publicConfig, events, signal, log }) {
+ return {
+ handle(req, res) {
+ // req.webspeak is verified by the host; req.url is your own route.
+ res.setHeader('content-type', 'application/json');
+ res.end(JSON.stringify({participant: req.webspeak.self.id}));
+ },
+ upgrade(req, socket, head) { /* your WebSocket protocol */ },
+ async stop() { /* flush data and release resources */ }
};
}
```
-`room.read` 允许读房间和订阅状态;`room.write` 允许替换共享状态,必须同时声明读权限。不需要共享数据的独立功能面板可声明空权限数组:仍可打开并获得公开配置,但上下文仅含空快照,不能读写或订阅其他参与者。当前所有已加入且拥有写权限的参与者都能操作,没有隐含主持人角色或 TS 管理权限。API 不提供 TS Query、宿主 DOM、系统文件、管理员凭据或任意宿主方法。需要新能力时另行提议接口,不能访问内部实现绕过。
+也可直接返回 `(req,res)=>…`。这是 Node 原生请求/响应,可适配 Express、WS 等库。`req.webspeak` 含 `apiVersion/appId/self/connection/scope`,不含临时 URL 或管理凭据;服务端 `connection` 只有目标和频道。代理剥离主站 Cookie、Authorization 和伪造的 `x-webspeak-*` 头;应用自行认证可使用自定义头或自己的外部服务。后端不会收到主站管理员/Query 密钥,除非管理员主动在插件配置中提供。
-更新使用比较并交换:读取 N 后提交 N,成功返回 N+1;冲突返回 `PLUGIN_REVISION_CONFLICT`。重新读取,让用户重试或基于新状态重算,不能盲目覆盖。
+`dataDir` 为本插件持久目录,更新/重启/卸载保留。代码提取目录会清理,不可持久化。包文件没有可执行位;额外子程序需作者自行处理权限和平台。Node 网络、文件、子程序和第三方服务同样属于审核范围。
-```js
-const api = window.webspeak;
-const context = await api.ready;
-let snapshot = context.snapshot;
-const unsubscribe = api.room.subscribe(next => {
- if (next.roomId !== snapshot.roomId || next.revision < snapshot.revision) return;
- snapshot = next;
- render(next.state);
-});
-async function update(next) {
- try { snapshot = await api.room.update(snapshot.revision, next); }
- catch (error) {
- if (error.message === "PLUGIN_REVISION_CONFLICT") snapshot = await api.room.snapshot();
- else throw error;
- }
-}
-addEventListener("pagehide", unsubscribe, { once: true });
-```
+`config` 是后端私密 JSON,`publicConfig` 是公开 JSON。私密配置在管理页仅显示是否已保存,支持保留/替换/删除,用实例主密钥加密存储;启用的 Node 代码获得明文。它不是针对恶意插件的秘密保险箱。不要把私密配置写入响应或日志。
-共享状态上限 16 KiB、16 层嵌套、4096 个节点,只接受 JSON,不接受非有限数、原型键或二进制媒体。公开配置上限 8 KiB。每会话每秒最多 20 个插件请求,每个房间每秒最多 10 次共享写入,关闭操作不受频率限制。最多 8 个已打开插件(当前面板一次打开一个);每网关最多 800 个非空房间、50 个已安装插件。读取快照不触发广播。不要通过高频写状态传视频帧。服务端只保存通用状态与成员,不执行插件代码。
+`events` 为 Node `EventEmitter`:`participantJoined/contextChanged` 提供服务端公开上下文,`participantLeft` 为 `{appId,selfId,scopeKey}`。加入指打开应用面板,不是全体 TS 成员。`signal` 在停止时中止;`log(level,message)` 提供限流日志,宿主当前以 debug 级别记录。
-最后一位参与者离开立即销毁房间,重启也会丢失临时房间。安装和配置持久化于数据目录 `plugins/*.json`,原子替换;实例备份应包含此目录。需要持久业务数据或外部适配器时,应定义额外能力协议。
+每个后端一个进程,默认最多 8 个;启动超时 10 秒、停止宽限 2 秒、JS 堆上限 256 MiB(不是总 RSS 限额)。失败显示错误、撤销会话,可手动重启,无无限重试。每个语音连接最多 8 个打开会话,全局 800 个,每会话最多 32 条代理连接及 4 条上下文 SSE。普通 HTTP 空闲超时 120 秒,无上下文 SSE 且 90 秒无活动的会话回收。作者负责消息大小、业务授权、并发、存储一致性和依赖资源用量。
-主要错误:`PLUGIN_NOT_CONNECTED`、`PLUGIN_NOT_ALLOWED`、`PLUGIN_DISABLED`、`PLUGIN_NOT_OPEN`、`PLUGIN_PERMISSION_DENIED`、`PLUGIN_REVISION_CONFLICT`、`PLUGIN_RATE_LIMITED`、`PLUGIN_TOO_LARGE`、`PLUGIN_TIMEOUT`。配置或包变化会关闭旧上下文并提示重新打开。
+## 分发与验证
-为避免可选插件消息挤占语音连接的内存,出站队列超过 512 KiB 时跳过插件消息。恢复连接质量后可请求快照或重新打开插件;请求无响应会超时,不代表共享写入一定没有执行。
+[分发仓库](https://github.com/Huddle-Up-Forge/webspeak-plugin) 目录为 `{"schemaVersion":2,"plugins":[{"id":"community.my-app","repository":"https://github.com/OWNER/REPO","metadataPath":"plugin.json"}]}`。插件仓库 `plugin.json` 包含同一 `manifest` 和 `package:{ref,path,sha256}`。`ref` 使用固定提交/不可变标签,`path` 指向已提交包,SHA-256 为包原始字节哈希。宿主限制 GitHub 内容来源、核验哈希与 manifest;目录或安装修订改变会拒绝覆盖,需重新加载。空目录不默认安装插件。
-## 同步观影示例
+验证实际构建包的导入、审核、启用、自定义 HTTP/WS、依赖加载、持久化和关闭/断线/禁用/更新撤销;检查明暗、语言、窄屏。协作另测两位真实参与者及并发/离开/重连。区分模拟身份、真实 TS、浏览器交互与跨网络证据。宿主回归:`npm run verify`。
-状态为 `{ url, position, playing, updatedAt }`。加载、播放、暂停、跳转共享;音量、全屏与播放许可仅影响自己。使用快照 `serverTime` 估算网关时钟,推算播放 elapsed time,定时校正漂移,大偏移跳转、小偏移暂调速。后来加入读取同一快照追上进度,不依赖过去的操作事件。
+## 悬浮应用窗口 / Floating application workspace
-视频由每个浏览器直接从 URL 加载,不经过 WebSpeak 中转。支持浏览器可解码的 MP4/WebM 等直链,不支持播放网页、DRM、登录后 URL 或嵌入式平台播放器。HTTPS 实例一般需要 HTTPS 视频。自动播放受浏览器策略限制,可能需要点击“允许播放”。源端带宽、网络和缓冲会影响误差,不承诺逐帧同步。
+功能插件入口由宿主的独立悬浮层提供,不属于默认主题或任何皮肤插槽。入口可拖动,避免遮挡工作台控件。应用库和应用内容使用非模态窗口:打开后仍可操作工作台;标题栏可拖动,支持最小化、最大化、还原和关闭,小屏幕自动限制在可视区域内。宿主窗口优先读取标准 `color-scheme` 来选择日间/夜间配色,不继承皮肤组件样式。
-## 隔离与清理
+最小化、切换到应用库、再返回当前应用均保留同一个 iframe 与会话,传输、播放等任务不会因收起窗口而重置。关闭窗口、切换至另一个应用或语音会话撤销时,宿主结束当前应用会话。当前同时承载一个前端应用;不要把窗口最小化当成退出事件。
-使用 opaque-origin `sandbox="allow-scripts"` iframe,不授予 `allow-same-origin`、顶部导航、弹窗、表单、麦克风或摄像头。宿主 RPC 校验 `event.source`、随机通道和面板生命周期;插件不能选择另一个 ID 或房间。CSP 禁止 fetch/WebSocket、外部脚本、嵌套 iframe,仅允许直接媒体及 HTTPS 图片。媒体源仍会收到浏览器请求,配置、共享状态和视频 URL 都不能包含管理员密钥。
+应用只负责 iframe 内部内容,使用自身响应式日间/夜间样式和上下文中的主题、语言。不读取或改写皮肤 DOM,不绘制覆盖宿主的全屏遮罩,不自行重复宿主的标题栏、最小化和关闭按钮。需要自有导航时可在内容区实现。应用界面优先显示功能与实际状态,不重复运行环境、权限或免责说明;管理员启用时的信任与权限信息保留在管理流程中。
-隔离不是恶意代码审核、CPU/内存配额的替代品。管理员应审查来源。插件在 `pagehide` 清理计时器、订阅和媒体;宿主关闭时销毁 iframe,后端移除房间成员,迟到响应不能重开已关闭面板。
+## 实例级用户授权
-## GitHub 分发协议
-
-根仓库 `main/index.json`:
-
-```json
-{
- "schemaVersion": 1,
- "plugins": [{
- "id": "community.example",
- "repository": "https://github.com/OWNER/REPOSITORY",
- "metadataPath": "plugin.json"
- }]
-}
-```
-
-`metadataPath` 默认 `plugin.json`,也支持子目录。同一个仓库可以分发多个插件。对应仓库默认分支的元数据:
-
-```json
-{
- "manifest": { "apiVersion": 1, "id": "community.example", "name": "Example", "version": "1.0.0", "author": "Author", "license": "MIT", "description": "Example", "scopes": ["server"], "permissions": ["room.read", "room.write"] },
- "package": { "ref": "IMMUTABLE_COMMIT_OR_TAG", "path": "example.wplugin", "sha256": "64_lowercase_hex_digits" }
-}
-```
-
-使用真实 SHA-256,推荐固定提交或发布标签;不要上传占位值。只访问 `raw.githubusercontent.com`,拒绝重定向、非法地址/路径、超时和超限数据。安装时重读目录和元数据,核对管理员看到的 revision,再下载校验摘要及清单;installedRevision 也作并发保护。失败保留旧包。摘要是内容一致性校验,不是作者签名或安全认证。
-
-## English quick start
-
-Functional plugins are portable UTF-8 `.wplugin` JSON bundles, independent of skins. Install under `/admin/plugins`, review permissions, select `server` (target + channel) or `instance` (one room across connected users of this gateway), and explicitly enable. Open the common Plugins panel after joining voice. Native TS clients and separate WebSpeak gateways do not share this runtime.
-
-Await `window.webspeak.ready`, subscribe with `webspeak.room.subscribe`, and write with revision-checked `room.update`. The API types, limits and distribution schemas above are normative. Both light/dark styles are required. The [Watch Together example](examples/watch-together/player.js) implements clock-based progress, late joining, conflict recovery, autoplay handling and cleanup without host-specific player code. Build using the command above and import into an isolated development instance. Develop plugins without modifying WebSpeak runtime files; propose missing capabilities separately.
+首次访问时,宿主统一征求第三方皮肤与功能应用的使用授权;决定按浏览器源保存,不迁移旧的逐皮肤授权。拒绝或未选择时,只显示日间、夜间、ILLUSIA 三款官方皮肤,KAAK 和功能应用入口均隐藏。皮肤菜单最后的“授权”可随时更改。撤回会关闭 iframe 并撤销当前打开操作/应用会话,不停止管理员启用的全实例后台服务。应用不得以入口以外的方式绕过宿主授权,也无需重复询问同一份宿主上下文授权;相机、麦克风等浏览器原生许可仍由浏览器处理。
diff --git a/docs/README.de.md b/docs/README.de.md
index 2207fa2..24d84e6 100644
--- a/docs/README.de.md
+++ b/docs/README.de.md
@@ -304,7 +304,7 @@ Skins gestalten Aussehen, Layout und zugehörige Widgets. Administratoren instal
### Funktionale Plugins `.wplugin` (dev)
-Funktionale Plugins laufen getrennt von Skins in einem eigenen Panel. Administratoren wählen Server-Geltungsbereich (gleiches TS-Ziel und gleicher Kanal) oder Instanz-Geltungsbereich (ein Sprach-Gateway). Watch Together zeigt synchrones Abspielen, Pausieren, Springen und spätes Beitreten. Erforderlich ist die aktuelle dev-Laufzeit; v0.2.9 enthält diese Funktion nicht.
+Funktionale Plugins sind unabhängige Anwendungen mit Browserfunktionen und optionalen Node-Backends, eigenen Routen, Daten und Zusammenarbeit. Administratoren prüfen Code und Abhängigkeiten vor der Aktivierung; Updates erfordern erneutes Vertrauen. Anwendungen unterstützen TS-Server- oder Instanz-Bereiche und eine separate Origin. API v2 benötigt die aktuelle dev-Version und ist nicht in v0.2.9 enthalten.
[Entwicklungsleitfaden](./PLUGIN_DEVELOPMENT.md) · [Agent Skill](../.agents/skills/webspeak-plugin-development/SKILL.md) · [Verteilungskatalog & Beispiel](https://github.com/Huddle-Up-Forge/webspeak-plugin)
diff --git a/docs/README.en.md b/docs/README.en.md
index 38dd4fe..7ff88d7 100644
--- a/docs/README.en.md
+++ b/docs/README.en.md
@@ -304,7 +304,7 @@ Skins own appearance, layout and their attached widgets. Administrators install,
### Functional plugins `.wplugin` (dev)
-Functional plugins run in an independent panel, separately from skins. Administrators choose server scope (the same TS target and channel) or instance scope (one voice gateway). The Watch Together example demonstrates synchronized play, pause, seek and late joining. This requires the current dev runtime and is not included in v0.2.9.
+Functional plugins are independent applications using standard browser capabilities and optional Node backends with their own routes, state and collaboration. Administrators review code and dependencies before enabling; updates require renewed trust. Applications support TS server or instance scope and run on a separate origin. API v2 requires current dev and is not included in v0.2.9.
[Development guide](./PLUGIN_DEVELOPMENT.md) · [Agent Skill](../.agents/skills/webspeak-plugin-development/SKILL.md) · [Distribution catalog & example](https://github.com/Huddle-Up-Forge/webspeak-plugin)
diff --git a/docs/README.ja.md b/docs/README.ja.md
index 16fb1a3..19b6fee 100644
--- a/docs/README.ja.md
+++ b/docs/README.ja.md
@@ -240,7 +240,7 @@ relay.example.com {
### 機能プラグイン `.wplugin`(dev)
-機能プラグインはスキンと分離した専用パネルで動作します。管理者はサーバー単位(同じ TS 接続先とチャンネル)かインスタンス単位(1 つの音声ゲートウェイ)を選択できます。Watch Together は再生、一時停止、シーク、途中参加の同期例です。現在の dev ランタイムが必要で、v0.2.9 には含まれません。
+機能プラグインは標準ブラウザー機能と任意の Node バックエンドを使う独立アプリです。ルート、状態、共同作業は作者が実装します。管理者はコードと依存関係を審査して有効化し、更新後は再び信頼を確認します。TS サーバーまたはインスタンス範囲に対応し、別オリジンで動作します。API v2 は現在の dev が必要で、v0.2.9 には含まれません。
[開発ガイド](./PLUGIN_DEVELOPMENT.md) · [Agent Skill](../.agents/skills/webspeak-plugin-development/SKILL.md) · [配布一覧とサンプル](https://github.com/Huddle-Up-Forge/webspeak-plugin)
diff --git a/docs/README.ru.md b/docs/README.ru.md
index 88b692e..b569afd 100644
--- a/docs/README.ru.md
+++ b/docs/README.ru.md
@@ -240,7 +240,7 @@ relay.example.com {
### Функциональные плагины `.wplugin` (dev)
-Функциональные плагины работают в отдельной панели независимо от скинов. Администратор выбирает область сервера (одна цель TS и канал) или экземпляра (один голосовой шлюз). Watch Together демонстрирует синхронные воспроизведение, паузу, перемотку и позднее подключение. Нужна текущая среда dev; в v0.2.9 функции нет.
+Функциональные плагины — самостоятельные приложения с API браузера, необязательными сервисами Node, своими маршрутами, данными и совместной работой. Администратор проверяет код и зависимости перед включением; обновления требуют повторного доверия. Приложения работают на отдельном источнике в области TS-сервера или экземпляра. API v2 требует текущую dev-версию и не входит в v0.2.9.
[Руководство](./PLUGIN_DEVELOPMENT.md) · [Agent Skill](../.agents/skills/webspeak-plugin-development/SKILL.md) · [Каталог распространения и пример](https://github.com/Huddle-Up-Forge/webspeak-plugin)
diff --git a/docs/README.zh-CN.md b/docs/README.zh-CN.md
index 5afab9f..d280690 100644
--- a/docs/README.zh-CN.md
+++ b/docs/README.zh-CN.md
@@ -308,7 +308,7 @@ relay.example.com {
### 功能插件 `.wplugin`(dev)
-功能插件在独立面板中运行,与皮肤包分开。管理员可配置服务器作用域(同一 TS 目标与频道)或实例作用域(同一语音网关);“一起观看”示例验证播放、暂停、跳转和中途加入的同步。需要当前 dev 运行时,不属于 v0.2.9。
+功能插件是独立应用,使用标准浏览器能力和可选 Node 后端,自行实现路由、状态与协作。管理员审核代码和依赖后启用;更新须重新信任。支持 TS 服务器或实例范围,运行于独立源。当前 dev 使用 API v2,不属于 v0.2.9。
[开发指南](./PLUGIN_DEVELOPMENT.md) · [Agent Skill](../.agents/skills/webspeak-plugin-development/SKILL.md) · [分发索引与示例](https://github.com/Huddle-Up-Forge/webspeak-plugin)
diff --git a/docs/SKIN_DEVELOPMENT.md b/docs/SKIN_DEVELOPMENT.md
index 00336f4..16153d0 100644
--- a/docs/SKIN_DEVELOPMENT.md
+++ b/docs/SKIN_DEVELOPMENT.md
@@ -522,3 +522,11 @@ CSS 被限定在 `.ws-skin-root` 内,管理员页面不会继承皮肤。删
自绘成员列表时,`session.members` 可读取 `screenSharing` 与 `screenShareStreamId`;这两个成员字段和 `screenShare.streams` 一样要求 `voice.screenShare.read`。用 `member.screenSharing` 显示共享标记,再将 `member.screenShareStreamId` 绑定到 `voice.joinScreenShare`(还需 `voice.screenShare.control`)即可让用户观看。未声明/未获共享读取权限的皮肤不会收到这两个字段;整页替换皮肤仍须在自己的成员列表中绘制标记或观看入口。
\n
+
+## 实例级用户授权(当前开发版)
+
+用户首次访问公开页面时,由宿主统一询问是否允许当前实例的第三方皮肤和功能插件使用已公开的频道/成员/聊天等上下文;不包含连接凭据。不再逐个皮肤弹窗确认。选择按浏览器源(协议、域名、端口)保存,旧版本的逐包授权记录不会自动替代这次选择。管理员对应用的审核与信任仍单独保留。
+
+未作选择或拒绝时,仅可使用固定三款官方皮肤:`builtin.light`、`builtin.dark`、`community.illusia-voice`;KAAK 即使随包分发也不在免授权名单中,其他第三方皮肤及功能插件入口隐藏。缓存、直接激活、进行中的加载也必须经过同一授权检查,不能仅过滤菜单。皮肤菜单末尾的“授权”可以随时修改选择。撤回时立即退回内置皮肤、停止第三方皮肤组件/worker,并关闭与撤销当前功能应用会话;服务端由管理员启用的后台应用不因此停机。
+
+清单权限、数据投影、宿主动作校验和 Wasm 文件摘要校验继续保留,统一授权不是扩大皮肤 API 的理由。作者不应再自行增加重复授权弹窗。原文中的逐包授权记录与 SHA-256 绑定描述指内部校验记录,其创建必须在实例授权允许之后(或固定官方皮肤之内)。
diff --git a/docs/examples/watch-together.wplugin b/docs/examples/watch-together.wplugin
deleted file mode 100644
index 6ae5365..0000000
--- a/docs/examples/watch-together.wplugin
+++ /dev/null
@@ -1 +0,0 @@
-{"manifest":{"apiVersion":1,"id":"community.watch-together","name":"Watch Together / 一起观看","version":"1.0.0","author":"Huddle-Up-Forge","license":"AGPL-3.0-only","description":"A shared video player with synchronized playback, pause and seeking. / 同步播放、暂停与跳转的视频播放器。","scopes":["server","instance"],"permissions":["room.read","room.write"]},"html":"\n
Watch Together
\n \n \n \n \n \n \n \n\n","script":"/* Uses only the public plugin API. Nothing here imports WebSpeak internals. */\n(async () => {\n const api = window.webspeak, context = await api.ready;\n const $ = id => document.getElementById(id), video = $('video');\n const language = context.language, zh = language === 'zh';\n const texts = {\n zh: ['一起观看','所有参与者共享播放、暂停和进度;音量仅影响自己。','视频直链','载入视频','允许播放','请使用浏览器支持的 MP4 / WebM 视频直链。不会把视频经过 WebSpeak 服务器转发。','浏览器阻止自动播放,请点击“允许播放”。','视频无法加载,请检查地址、格式与 HTTPS。','有人同时操作,已获取最新进度,请重试。'],\n en: ['Watch Together','Playback, pause and seeking are shared; volume is local.','Direct video URL','Load video','Enable playback','Use a browser-compatible MP4 / WebM URL. Video is fetched directly, never relayed by WebSpeak.','Autoplay was blocked. Click Enable playback.','Video could not load. Check URL, format and HTTPS.','Another participant changed playback. Refreshed; please try again.'],\n de: ['Gemeinsam ansehen','Wiedergabe, Pause und Position sind gemeinsam; Lautstärke ist lokal.','Direkte Video-URL','Video laden','Wiedergabe erlauben','Browserkompatible MP4-/WebM-URL verwenden. Video wird direkt geladen.','Autoplay blockiert. Wiedergabe erlauben anklicken.','Video nicht ladbar. URL, Format und HTTPS prüfen.','Gleichzeitige Änderung. Aktualisiert; erneut versuchen.'],\n ru: ['Смотреть вместе','Воспроизведение, пауза и позиция общие; громкость локальная.','Прямая ссылка на видео','Загрузить видео','Разрешить воспроизведение','Используйте прямую ссылку MP4 / WebM. Видео загружается напрямую.','Автовоспроизведение заблокировано. Нажмите Разрешить воспроизведение.','Не удалось загрузить видео. Проверьте адрес, формат и HTTPS.','Другой участник изменил состояние. Обновлено; повторите.'],\n ja: ['一緒に見る','再生・停止・位置を共有します。音量は自分の端末のみです。','動画の直接 URL','動画を読み込む','再生を許可','ブラウザー対応の MP4 / WebM URL を使用します。動画は直接取得されます。','自動再生がブロックされました。「再生を許可」を押してください。','動画を読み込めません。URL・形式・HTTPS を確認してください。','他の参加者が操作しました。最新状態で再試行してください。'],\n };\n const t = texts[language] || texts.en;\n ['title','lead','url-label','load','unlock','note'].forEach((id,i) => $(id).textContent=t[i]);\n $('play').ariaLabel=zh?'同步播放':'Play for everyone'; $('pause').ariaLabel=zh?'同步暂停':'Pause for everyone';\n $('fullscreen').ariaLabel=zh?'全屏':'Fullscreen';\n let snapshot=context.snapshot, offset=snapshot.serverTime-Date.now(), source='', busy=false, seeking=false, playingAttempt=false;\n video.volume=.7;\n function validState(value) {\n if(!value || typeof value.url!=='string' || value.url.length>2048 || typeof value.playing!=='boolean' || !Number.isFinite(value.position) || value.position<0 || value.position>604800 || !Number.isFinite(value.updatedAt)) return null;\n try {const u=new URL(value.url);if(!['http:','https:'].includes(u.protocol)||u.username||u.password)return null;}catch{return null;}\n return value;\n }\n function targetPosition(state) {return Math.max(0,Math.min(604800,state.position+(state.playing?Math.max(0,(Date.now()+offset-state.updatedAt)/1000):0)));}\n function status(message='') {$('status').textContent=message;}\n async function apply() {\n const state=validState(snapshot.state); if(!state)return;\n if(source!==state.url){source=state.url;video.src=source;$('url').value=source;video.load();}\n const desired=targetPosition(state);\n if(Number.isFinite(video.duration)&&video.duration>0&&desired>=video.duration){video.pause();video.playbackRate=1;return;}\n if(video.readyState>=1 && !seeking){const diff=desired-video.currentTime;\n if(Math.abs(diff)>(state.playing?.7:.04))video.currentTime=Math.min(desired,Number.isFinite(video.duration)?video.duration:desired);\n video.playbackRate=state.playing&&Math.abs(diff)>.15&&Math.abs(diff)<=.7?(diff>0?1.03:.97):1;\n }\n if(state.playing&&video.paused&&!playingAttempt){playingAttempt=true;try{await video.play();status();}catch{status(t[6]);}finally{playingAttempt=false;}}\n else if(!state.playing&&!video.paused)video.pause();\n }\n function receive(next) {if(next.roomId!==snapshot.roomId || next.revision{if($('url').checkValidity())void update({url:$('url').value.trim(),position:0,playing:false});else $('url').reportValidity();};\n $('load').addEventListener('click',load);\n $('source').addEventListener('submit',event=>event.preventDefault());\n $('url').addEventListener('keydown',event=>{if(event.key==='Enter'){event.preventDefault();load();}});\n $('play').addEventListener('click',()=>{void video.play().catch(()=>status(t[6]));void update({playing:true});});\n $('pause').addEventListener('click',()=>void update({playing:false,position:video.currentTime}));\n $('unlock').addEventListener('click',()=>{void video.play().then(()=>{if(!snapshot.state?.playing)video.pause();status();}).catch(()=>status(t[6]));});\n $('fullscreen').addEventListener('click',()=>void video.requestFullscreen?.().catch(()=>undefined));\n $('volume').addEventListener('input',()=>video.volume=Number($('volume').value));\n $('seek').addEventListener('input',()=>{seeking=true;});\n $('seek').addEventListener('change',()=>{seeking=false;void update({position:Number($('seek').value)});});\n video.addEventListener('loadedmetadata',()=>void apply()); video.addEventListener('error',()=>status(t[7]));\n video.addEventListener('ended',()=>{video.playbackRate=1;});\n const time=value=>`${Math.floor(value/60)}:${Math.floor(value%60).toString().padStart(2,'0')}`;\n const timer=setInterval(()=>{void apply();const duration=Number.isFinite(video.duration)?video.duration:0;$('seek').max=String(duration||1);if(!seeking)$('seek').value=String(video.currentTime);$('time').textContent=`${time(video.currentTime)} / ${time(duration)}`;},1000);\n const unsubscribe=api.room.subscribe(receive);receive(snapshot);\n addEventListener('pagehide',()=>{clearInterval(timer);unsubscribe();video.pause();video.removeAttribute('src');video.load();},{once:true});\n})();\n","styles":{"light":"body{background:#f2f7f6;color:#183c38}main{max-width:850px;margin:auto}header{display:flex;gap:16px;align-items:center;justify-content:space-between}h1{font-size:22px;margin:0}p{line-height:1.5}form{display:flex;gap:10px;margin:16px 0;align-items:end}label{display:grid;gap:6px;flex:1;min-width:0}input[type=url]{width:100%;padding:10px;border:1px solid #83aaa4;border-radius:8px;background:#fff;color:#183c38;font:inherit}button{padding:10px 15px;border:1px solid #739e96;border-radius:8px;background:#e0f1eb;color:#174d41;font:inherit;cursor:pointer}button:disabled{opacity:.5}video{display:block;width:100%;max-height:50vh;min-height:180px;background:#101719;border-radius:12px}.controls{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:12px 0}.volume{display:flex;align-items:center;max-width:150px}.volume input{min-width:0;width:100%}.seek{display:grid;grid-template-columns:100px 1fr;align-items:center}.seek input{width:100%}.note,#members{font-size:13px;opacity:.75}#status{min-height:1.5em;color:#a33c24}input[type=range]{accent-color:#168575}@media(max-width:500px){form{flex-wrap:wrap}form label{flex-basis:100%}.seek{grid-template-columns:1fr}}\n","dark":"body{background:#20242b;color:#e9eeee}main{max-width:850px;margin:auto}header{display:flex;gap:16px;align-items:center;justify-content:space-between}h1{font-size:22px;margin:0}p{line-height:1.5}form{display:flex;gap:10px;margin:16px 0;align-items:end}label{display:grid;gap:6px;flex:1;min-width:0}input[type=url]{width:100%;padding:10px;border:1px solid #58676b;border-radius:8px;background:#303840;color:#e9eeee;font:inherit}button{padding:10px 15px;border:1px solid #588579;border-radius:8px;background:#254c43;color:#dcfff4;font:inherit;cursor:pointer}button:disabled{opacity:.5}video{display:block;width:100%;max-height:50vh;min-height:180px;background:#080c0e;border-radius:12px}.controls{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:12px 0}.volume{display:flex;align-items:center;max-width:150px}.volume input{min-width:0;width:100%}.seek{display:grid;grid-template-columns:100px 1fr;align-items:center}.seek input{width:100%}.note,#members{font-size:13px;opacity:.75}#status{min-height:1.5em;color:#ffaf91}input[type=range]{accent-color:#7cdbc2}@media(max-width:500px){form{flex-wrap:wrap}form label{flex-basis:100%}.seek{grid-template-columns:1fr}}\n"}}
\ No newline at end of file
diff --git a/docs/examples/watch-together/dark.css b/docs/examples/watch-together/dark.css
deleted file mode 100644
index 871b04a..0000000
--- a/docs/examples/watch-together/dark.css
+++ /dev/null
@@ -1 +0,0 @@
-body{background:#20242b;color:#e9eeee}main{max-width:850px;margin:auto}header{display:flex;gap:16px;align-items:center;justify-content:space-between}h1{font-size:22px;margin:0}p{line-height:1.5}form{display:flex;gap:10px;margin:16px 0;align-items:end}label{display:grid;gap:6px;flex:1;min-width:0}input[type=url]{width:100%;padding:10px;border:1px solid #58676b;border-radius:8px;background:#303840;color:#e9eeee;font:inherit}button{padding:10px 15px;border:1px solid #588579;border-radius:8px;background:#254c43;color:#dcfff4;font:inherit;cursor:pointer}button:disabled{opacity:.5}video{display:block;width:100%;max-height:50vh;min-height:180px;background:#080c0e;border-radius:12px}.controls{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:12px 0}.volume{display:flex;align-items:center;max-width:150px}.volume input{min-width:0;width:100%}.seek{display:grid;grid-template-columns:100px 1fr;align-items:center}.seek input{width:100%}.note,#members{font-size:13px;opacity:.75}#status{min-height:1.5em;color:#ffaf91}input[type=range]{accent-color:#7cdbc2}@media(max-width:500px){form{flex-wrap:wrap}form label{flex-basis:100%}.seek{grid-template-columns:1fr}}
diff --git a/docs/examples/watch-together/light.css b/docs/examples/watch-together/light.css
deleted file mode 100644
index 25685aa..0000000
--- a/docs/examples/watch-together/light.css
+++ /dev/null
@@ -1 +0,0 @@
-body{background:#f2f7f6;color:#183c38}main{max-width:850px;margin:auto}header{display:flex;gap:16px;align-items:center;justify-content:space-between}h1{font-size:22px;margin:0}p{line-height:1.5}form{display:flex;gap:10px;margin:16px 0;align-items:end}label{display:grid;gap:6px;flex:1;min-width:0}input[type=url]{width:100%;padding:10px;border:1px solid #83aaa4;border-radius:8px;background:#fff;color:#183c38;font:inherit}button{padding:10px 15px;border:1px solid #739e96;border-radius:8px;background:#e0f1eb;color:#174d41;font:inherit;cursor:pointer}button:disabled{opacity:.5}video{display:block;width:100%;max-height:50vh;min-height:180px;background:#101719;border-radius:12px}.controls{display:flex;flex-wrap:wrap;gap:8px;align-items:center;margin:12px 0}.volume{display:flex;align-items:center;max-width:150px}.volume input{min-width:0;width:100%}.seek{display:grid;grid-template-columns:100px 1fr;align-items:center}.seek input{width:100%}.note,#members{font-size:13px;opacity:.75}#status{min-height:1.5em;color:#a33c24}input[type=range]{accent-color:#168575}@media(max-width:500px){form{flex-wrap:wrap}form label{flex-basis:100%}.seek{grid-template-columns:1fr}}
diff --git a/docs/examples/watch-together/manifest.json b/docs/examples/watch-together/manifest.json
deleted file mode 100644
index dc9580c..0000000
--- a/docs/examples/watch-together/manifest.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "apiVersion": 1,
- "id": "community.watch-together",
- "name": "Watch Together / 一起观看",
- "version": "1.0.0",
- "author": "Huddle-Up-Forge",
- "license": "AGPL-3.0-only",
- "description": "A shared video player with synchronized playback, pause and seeking. / 同步播放、暂停与跳转的视频播放器。",
- "scopes": ["server", "instance"],
- "permissions": ["room.read", "room.write"]
-}
diff --git a/docs/examples/watch-together/panel.html b/docs/examples/watch-together/panel.html
deleted file mode 100644
index 7f18578..0000000
--- a/docs/examples/watch-together/panel.html
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
Watch Together
-
-
-
-
-
-
-
-
diff --git a/docs/examples/watch-together/player.js b/docs/examples/watch-together/player.js
deleted file mode 100644
index 0f39305..0000000
--- a/docs/examples/watch-together/player.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Uses only the public plugin API. Nothing here imports WebSpeak internals. */
-(async () => {
- const api = window.webspeak, context = await api.ready;
- const $ = id => document.getElementById(id), video = $('video');
- const language = context.language, zh = language === 'zh';
- const texts = {
- zh: ['一起观看','所有参与者共享播放、暂停和进度;音量仅影响自己。','视频直链','载入视频','允许播放','请使用浏览器支持的 MP4 / WebM 视频直链。不会把视频经过 WebSpeak 服务器转发。','浏览器阻止自动播放,请点击“允许播放”。','视频无法加载,请检查地址、格式与 HTTPS。','有人同时操作,已获取最新进度,请重试。'],
- en: ['Watch Together','Playback, pause and seeking are shared; volume is local.','Direct video URL','Load video','Enable playback','Use a browser-compatible MP4 / WebM URL. Video is fetched directly, never relayed by WebSpeak.','Autoplay was blocked. Click Enable playback.','Video could not load. Check URL, format and HTTPS.','Another participant changed playback. Refreshed; please try again.'],
- de: ['Gemeinsam ansehen','Wiedergabe, Pause und Position sind gemeinsam; Lautstärke ist lokal.','Direkte Video-URL','Video laden','Wiedergabe erlauben','Browserkompatible MP4-/WebM-URL verwenden. Video wird direkt geladen.','Autoplay blockiert. Wiedergabe erlauben anklicken.','Video nicht ladbar. URL, Format und HTTPS prüfen.','Gleichzeitige Änderung. Aktualisiert; erneut versuchen.'],
- ru: ['Смотреть вместе','Воспроизведение, пауза и позиция общие; громкость локальная.','Прямая ссылка на видео','Загрузить видео','Разрешить воспроизведение','Используйте прямую ссылку MP4 / WebM. Видео загружается напрямую.','Автовоспроизведение заблокировано. Нажмите Разрешить воспроизведение.','Не удалось загрузить видео. Проверьте адрес, формат и HTTPS.','Другой участник изменил состояние. Обновлено; повторите.'],
- ja: ['一緒に見る','再生・停止・位置を共有します。音量は自分の端末のみです。','動画の直接 URL','動画を読み込む','再生を許可','ブラウザー対応の MP4 / WebM URL を使用します。動画は直接取得されます。','自動再生がブロックされました。「再生を許可」を押してください。','動画を読み込めません。URL・形式・HTTPS を確認してください。','他の参加者が操作しました。最新状態で再試行してください。'],
- };
- const t = texts[language] || texts.en;
- ['title','lead','url-label','load','unlock','note'].forEach((id,i) => $(id).textContent=t[i]);
- $('play').ariaLabel=zh?'同步播放':'Play for everyone'; $('pause').ariaLabel=zh?'同步暂停':'Pause for everyone';
- $('fullscreen').ariaLabel=zh?'全屏':'Fullscreen';
- let snapshot=context.snapshot, offset=snapshot.serverTime-Date.now(), source='', busy=false, seeking=false, playingAttempt=false;
- video.volume=.7;
- function validState(value) {
- if(!value || typeof value.url!=='string' || value.url.length>2048 || typeof value.playing!=='boolean' || !Number.isFinite(value.position) || value.position<0 || value.position>604800 || !Number.isFinite(value.updatedAt)) return null;
- try {const u=new URL(value.url);if(!['http:','https:'].includes(u.protocol)||u.username||u.password)return null;}catch{return null;}
- return value;
- }
- function targetPosition(state) {return Math.max(0,Math.min(604800,state.position+(state.playing?Math.max(0,(Date.now()+offset-state.updatedAt)/1000):0)));}
- function status(message='') {$('status').textContent=message;}
- async function apply() {
- const state=validState(snapshot.state); if(!state)return;
- if(source!==state.url){source=state.url;video.src=source;$('url').value=source;video.load();}
- const desired=targetPosition(state);
- if(Number.isFinite(video.duration)&&video.duration>0&&desired>=video.duration){video.pause();video.playbackRate=1;return;}
- if(video.readyState>=1 && !seeking){const diff=desired-video.currentTime;
- if(Math.abs(diff)>(state.playing?.7:.04))video.currentTime=Math.min(desired,Number.isFinite(video.duration)?video.duration:desired);
- video.playbackRate=state.playing&&Math.abs(diff)>.15&&Math.abs(diff)<=.7?(diff>0?1.03:.97):1;
- }
- if(state.playing&&video.paused&&!playingAttempt){playingAttempt=true;try{await video.play();status();}catch{status(t[6]);}finally{playingAttempt=false;}}
- else if(!state.playing&&!video.paused)video.pause();
- }
- function receive(next) {if(next.roomId!==snapshot.roomId || next.revision{if($('url').checkValidity())void update({url:$('url').value.trim(),position:0,playing:false});else $('url').reportValidity();};
- $('load').addEventListener('click',load);
- $('source').addEventListener('submit',event=>event.preventDefault());
- $('url').addEventListener('keydown',event=>{if(event.key==='Enter'){event.preventDefault();load();}});
- $('play').addEventListener('click',()=>{void video.play().catch(()=>status(t[6]));void update({playing:true});});
- $('pause').addEventListener('click',()=>void update({playing:false,position:video.currentTime}));
- $('unlock').addEventListener('click',()=>{void video.play().then(()=>{if(!snapshot.state?.playing)video.pause();status();}).catch(()=>status(t[6]));});
- $('fullscreen').addEventListener('click',()=>void video.requestFullscreen?.().catch(()=>undefined));
- $('volume').addEventListener('input',()=>video.volume=Number($('volume').value));
- $('seek').addEventListener('input',()=>{seeking=true;});
- $('seek').addEventListener('change',()=>{seeking=false;void update({position:Number($('seek').value)});});
- video.addEventListener('loadedmetadata',()=>void apply()); video.addEventListener('error',()=>status(t[7]));
- video.addEventListener('ended',()=>{video.playbackRate=1;});
- const time=value=>`${Math.floor(value/60)}:${Math.floor(value%60).toString().padStart(2,'0')}`;
- const timer=setInterval(()=>{void apply();const duration=Number.isFinite(video.duration)?video.duration:0;$('seek').max=String(duration||1);if(!seeking)$('seek').value=String(video.currentTime);$('time').textContent=`${time(video.currentTime)} / ${time(duration)}`;},1000);
- const unsubscribe=api.room.subscribe(receive);receive(snapshot);
- addEventListener('pagehide',()=>{clearInterval(timer);unsubscribe();video.pause();video.removeAttribute('src');video.load();},{once:true});
-})();
diff --git a/docs/templates/plugin-app/client/index.html b/docs/templates/plugin-app/client/index.html
new file mode 100644
index 0000000..3d6f290
--- /dev/null
+++ b/docs/templates/plugin-app/client/index.html
@@ -0,0 +1,3 @@
+
+Application starter
+WEBSPEAK · APPLICATION RUNTIME 2