document/content/docs/self-host/design/design_plugin.en.mdx
Previously, all FastGPT features lived within the Next.js framework, organized as a Monorepo. System plugins existed as a sub-repo under FastGPT/packages/plugin.
As the user base grew, this approach revealed several limitations:
We decided to extract system plugins into a separate repository:
Key goals of the split:
.pkg file for hot-swapping.For system tool structure, see How to Develop System Plugins.
ts-rest is a TypeScript RESTful API framework. After defining a contract, you can write handler logic, auto-generate OpenAPI specs, and export a typed client via createClient.
tRPC is a similar TypeScript RPC framework, but it uses a proprietary request format that makes integration with other tools inconvenient. ts-rest is essentially a thin wrapper around RESTful APIs and can directly generate OpenAPI specs.
We use zod for type validation. Zod provides runtime type checking along with advanced features like parameter transformation and object merging.
To prevent plugins from interfering with each other while improving concurrency, FastGPT-plugin uses Worker threads for plugin execution. Each tool runs in an independent Worker when called, providing:
Bundling each plugin into a single .pkg file is a key design decision. This allows plugins to be distributed and loaded directly via network mounting.