Z-CMS 内部で AI Plugin が動作する仕組み
Platform を特定 provider に lock-in せず AI を統合する
AI は controller 内の API call ではなく platform capability
モダン CMS には AI writer、summary、translation、SEO metadata、classification、moderation、semantic search、chatbot が求められます。各 plugin が provider を直接呼ぶと、API key が分散し、cost control と privacy が不透明になり、platform が provider に lock-in されます。
AI Gateway
標準 flow は AI Plugin → Z-CMS AI SDK → AI Gateway → Policy Engine → Provider Adapter → AI Provider です。Plugin は cms.ai だけを呼び、Gateway が provider、model、quota、policy、retry、fallback、cache、audit を管理します。
Provider abstraction
Z-CMS は generateText、generateObject、generateEmbedding の共通 interface を定義します。Adapter は OpenAI、Azure OpenAI、Anthropic、Gemini、Ollama、local model に接続できます。Administrator が provider を変更しても plugin business logic は変わりません。
AI Plugin
↓
Z-CMS AI SDK
↓
AI Gateway
↓
Policy Engine
↓
Provider Adapter
↓
AI ProviderTenant-level AI settings と secret management
各 tenant は provider、model、region、monthly budget、external transfer policy を設定できます。API key は secure secret store に保存し、plugin には credential を公開しません。
AI permission と purpose declaration
Plugin は ai:text:generate、ai:embedding:generate、ai:file:analyze を宣言します。Request は seo-description、translate-content、content-moderation などの purpose を指定し、Gateway が適切な model、token limit、prompt template、policy を選びます。
const result = await cms.ai.generateObject({
purpose: "seo-metadata",
input: article.content,
schema: seoMetadataSchema
});Prompt registry と structured output
すべての plugin が独自の system prompt を無制限に送る代わりに、Z-CMS は versioned prompt registry を提供できます。Structured output では plugin が JSON schema を指定し、Gateway が response を validate し、必要に応じて retry します。
Quota と cost control
Usage は tenant、plugin、user、purpose、provider、model ごとに追跡します。Warning threshold と hard limit を設定し、plugin は provider を直接呼べないため quota を bypass できません。
Data privacy と PII redaction
Content を Public、Internal、Confidential、Restricted に分類し、external AI を許可するか local model のみとするかを policy で決定します。Gateway は email、phone、customer ID、token などの PII を送信前に redact できます。
Human approval と async job
Risk の高い AI-generated content は自動 publish せず draft として editor review に回します。Translation や batch classification のような長い処理は background job で実行し、tenant context、plugin identity、permission scope を保持します。
Semantic search と RAG
Embedding API により semantic search を構築できます。RAG pipeline は document retrieval 後に tenant filter と permission filter を適用し、context を作成してから model を呼びます。AI assistant が user に許可されていない content を漏らしてはいけません。
Plugin isolation、fallback、audit
AI plugin も V8 Isolate 内で動作し、AI Capability Bridge のみを利用します。Fallback provider は privacy policy に従い、local-only tenant を public cloud に自動 fallback してはいけません。各 operation は audit metadata を記録します。
結論
AI plugin platform には provider abstraction、secure credential、tenant configuration、permission、quota、privacy、structured output、async job、semantic search、RAG、fallback、audit が必要です。Z-CMS AI SDK により developer は infrastructure ではなく feature に集中できます。
Key takeaways
- Security boundary は plugin の善意ではなく Core 側で enforce する必要があります。
- Lifecycle、permission、tenant context、observability は同じ platform contract の一部です。
- 優れた developer experience は、安全な runtime と supply chain の設計によって持続可能になります。
GitHub: https://github.com/zscontributor/z-cms
Website: https://z-cms.org