Repository navigation
feat(app): add the js plugin runtime and file install - #183
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M1 PR 9a:插件的 JS 執行環境、宿主 API v1 與從檔案安裝(ADR 0014;父任務
09-28-m1-skeleton-tracer的擁有者決定 6、7)。做了什麼
flutter_js0.8.7(釘死)的 QuickJS。每個插件跑在自己的背景 isolate:plugin_worker.dart)只放 QuickJS、prelude 與crypto,是唯一 importflutter_js的檔案。plugin_runtime.dart)負責 spawn、轉送訊息與看門狗。宿主 API(http、storage、credentials、log)在主 isolate 執行,網域與插件 id 的檢查只在這一邊。NetworkError,插件照常。unresponsive,停用到 App 重啟。.js檔,開頭的/* ==FMP Plugin== {json} ==/FMP Plugin== */是 manifest。App 不執行腳本就能先驗證 manifest;載入後再檢查腳本的匯出是否和宣告的能力一致。SourcePlugin:只有search與resolveStream,用 v1 DTO,進出兩個方向都驗證。插件邊界上所有錯誤都轉成AppError。另附給插件作者用的types/fmp-plugin.d.ts。PluginInstaller寫進installed_plugins並註冊到插件清單。dev 的開發入口是--fmp-dev-plugin=<路徑>或環境變數FMP_DEV_PLUGIN;prod 一律不讀,有測試守著。fmp-test,回傳合成資料、不發網路請求,串流指向自己產生的tone.wav。flutter test直接載入flutter_js內附的.so,在 Linux runner 上跑真的 QuickJS。驗證
dart format、dart analyze --fatal-infos、flutter analyze:零問題。flutter test:449 個通過,runtime 測試連跑兩次都穩定。fmp-test 1.0.0;不帶參數重開後,插件從資料庫重新載入。expiresAt超出範圍;register互相覆蓋;retryAfterSeconds溢位;量測數字(debug 模式):
詳見
.trellis/tasks/archive/2026-09/09-30-js-runtime/research/notes.md。Review 指南
app/lib/plugins/runtime/:worker_protocol.dart是訊息格式;plugin_runtime.dart是看門狗與呼叫的生命週期;plugin_host.dart是安全邊界。source_dto.dart的驗證,和manifest/plugin_file.dart的解析。app/AGENTS.md:Isolate.kill停不掉卡在 QuickJS 原生碼裡的執行緒,它會佔著一個核心直到 App 結束;implement.md的後續。