@allbluecn/shared 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/package.json +117 -0
  2. package/src/constants/perf.ts +21 -0
  3. package/src/i18n/client.ts +32 -0
  4. package/src/i18n/config.ts +104 -0
  5. package/src/i18n/detect.ts +43 -0
  6. package/src/i18n/locales/en/agents.json +134 -0
  7. package/src/i18n/locales/en/apps.json +6 -0
  8. package/src/i18n/locales/en/auth.json +88 -0
  9. package/src/i18n/locales/en/billing.json +78 -0
  10. package/src/i18n/locales/en/chat.json +194 -0
  11. package/src/i18n/locales/en/common.json +203 -0
  12. package/src/i18n/locales/en/dashboard.json +38 -0
  13. package/src/i18n/locales/en/design.json +70 -0
  14. package/src/i18n/locales/en/desktop.json +35 -0
  15. package/src/i18n/locales/en/display.json +37 -0
  16. package/src/i18n/locales/en/editor.json +304 -0
  17. package/src/i18n/locales/en/enterprise.json +1 -0
  18. package/src/i18n/locales/en/invite.json +11 -0
  19. package/src/i18n/locales/en/knowledge.json +451 -0
  20. package/src/i18n/locales/en/mindmap.json +28 -0
  21. package/src/i18n/locales/en/prd.json +43 -0
  22. package/src/i18n/locales/en/projects.json +133 -0
  23. package/src/i18n/locales/en/settings.json +375 -0
  24. package/src/i18n/locales/en/share.json +20 -0
  25. package/src/i18n/locales/en/story.json +785 -0
  26. package/src/i18n/locales/en/tags.json +42 -0
  27. package/src/i18n/locales/en/workspace.json +90 -0
  28. package/src/i18n/locales/zh/agents.json +134 -0
  29. package/src/i18n/locales/zh/apps.json +6 -0
  30. package/src/i18n/locales/zh/auth.json +88 -0
  31. package/src/i18n/locales/zh/billing.json +78 -0
  32. package/src/i18n/locales/zh/chat.json +194 -0
  33. package/src/i18n/locales/zh/common.json +203 -0
  34. package/src/i18n/locales/zh/dashboard.json +38 -0
  35. package/src/i18n/locales/zh/design.json +70 -0
  36. package/src/i18n/locales/zh/desktop.json +35 -0
  37. package/src/i18n/locales/zh/display.json +37 -0
  38. package/src/i18n/locales/zh/editor.json +304 -0
  39. package/src/i18n/locales/zh/enterprise.json +1 -0
  40. package/src/i18n/locales/zh/invite.json +11 -0
  41. package/src/i18n/locales/zh/knowledge.json +451 -0
  42. package/src/i18n/locales/zh/mindmap.json +28 -0
  43. package/src/i18n/locales/zh/prd.json +43 -0
  44. package/src/i18n/locales/zh/projects.json +133 -0
  45. package/src/i18n/locales/zh/settings.json +375 -0
  46. package/src/i18n/locales/zh/share.json +20 -0
  47. package/src/i18n/locales/zh/story.json +785 -0
  48. package/src/i18n/locales/zh/tags.json +42 -0
  49. package/src/i18n/locales/zh/workspace.json +90 -0
  50. package/src/i18n/server.ts +18 -0
  51. package/src/i18n/types.ts +5 -0
  52. package/src/index.ts +90 -0
  53. package/src/infrastructure/ai/adapter.ts +59 -0
  54. package/src/infrastructure/ai/cli-detector.ts +64 -0
  55. package/src/infrastructure/ip-location.ts +76 -0
  56. package/src/infrastructure/references/engine.ts +104 -0
  57. package/src/infrastructure/ua-parser.ts +107 -0
  58. package/src/interfaces/ai.ts +38 -0
  59. package/src/interfaces/avatar.ts +22 -0
  60. package/src/interfaces/module.ts +60 -0
  61. package/src/interfaces/references.ts +44 -0
  62. package/src/interfaces/transport.ts +26 -0
  63. package/src/lib/annotation-template.ts +33 -0
  64. package/src/lib/comment-utils.ts +47 -0
  65. package/src/lib/datetime.ts +115 -0
  66. package/src/lib/desktop-detect.ts +27 -0
  67. package/src/lib/outline-utils.ts +57 -0
  68. package/src/lib/pacer.ts +96 -0
  69. package/src/lib/prd/stack-layout.ts +53 -0
  70. package/src/lib/prd-tree-utils.ts +94 -0
  71. package/src/lib/prototype-registry.ts +24 -0
  72. package/src/lib/query-client-seam.ts +14 -0
  73. package/src/lib/share-events.ts +78 -0
  74. package/src/lib/sidebar-utils.ts +21 -0
  75. package/src/lib/stores/prd-canvas-store.ts +69 -0
  76. package/src/lib/tag-colors.ts +35 -0
  77. package/src/lib/time-format.ts +50 -0
  78. package/src/modules/ai-providers/constants.ts +79 -0
  79. package/src/modules/ai-providers/index.ts +21 -0
  80. package/src/modules/ai-providers/seed-data.ts +222 -0
  81. package/src/modules/ai-providers/types.ts +95 -0
  82. package/src/modules/billing/feature-registry.ts +63 -0
  83. package/src/modules/billing/plan-features-schema.ts +11 -0
  84. package/src/modules/billing/resource-registry.ts +80 -0
  85. package/src/modules/definitions/plugin.module.ts +38 -0
  86. package/src/modules/definitions/prd.module.ts +45 -0
  87. package/src/modules/definitions/prototype.module.ts +38 -0
  88. package/src/modules/dependencies/index.ts +186 -0
  89. package/src/modules/register-defaults.ts +27 -0
  90. package/src/modules/registry.ts +53 -0
  91. package/src/server-seam.ts +51 -0
  92. package/src/types/outline.ts +26 -0
  93. package/src/types/prd.ts +90 -0
  94. package/src/types/prototype.ts +12 -0
  95. package/src/virtual.d.ts +4 -0
@@ -0,0 +1,222 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ // packages/shared/src/modules/ai-providers/seed-data.ts
19
+ import type { AiProviderMeta } from './types'
20
+
21
+ /** 10 个最受欢迎 AI 服务商的种子数据,admin 可在其基础上增删改 */
22
+ export const SEED_AI_PROVIDERS: AiProviderMeta[] = [
23
+ {
24
+ providerId: 'openai',
25
+ displayName: 'OpenAI',
26
+ brandName: 'OpenAI',
27
+ description: 'GPT 系列模型,业界领先的通用对话与推理能力',
28
+ category: 'recommended',
29
+ iconSlug: 'openai',
30
+ brandColor: '#10A37F',
31
+ badge: '推荐',
32
+ adapterKind: 'openai',
33
+ defaultBaseUrl: 'https://api.openai.com/v1',
34
+ keyUrl: 'https://platform.openai.com/api-keys',
35
+ docsUrl: 'https://platform.openai.com/docs',
36
+ keyPlaceholder: 'sk-...',
37
+ models: [
38
+ { id: 'gpt-4o', displayName: 'GPT-4o', contextWindow: 128000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
39
+ { id: 'gpt-4o-mini', displayName: 'GPT-4o mini', contextWindow: 128000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
40
+ { id: 'o1', displayName: 'o1', contextWindow: 200000, capabilities: ['text', 'reasoning'] },
41
+ { id: 'o1-mini', displayName: 'o1-mini', contextWindow: 128000, capabilities: ['text', 'reasoning'] },
42
+ { id: 'o3-mini', displayName: 'o3-mini', contextWindow: 200000, capabilities: ['text', 'reasoning', 'tools'], defaultEnabled: true },
43
+ ],
44
+ },
45
+ {
46
+ providerId: 'anthropic',
47
+ displayName: 'Anthropic',
48
+ brandName: 'Claude',
49
+ description: 'Claude 系列模型,擅长长文本理解与代码生成',
50
+ category: 'recommended',
51
+ iconSlug: 'anthropic',
52
+ brandColor: '#D97757',
53
+ badge: '推荐',
54
+ adapterKind: 'anthropic',
55
+ defaultBaseUrl: 'https://api.anthropic.com',
56
+ keyUrl: 'https://console.anthropic.com/settings/keys',
57
+ docsUrl: 'https://docs.anthropic.com',
58
+ keyPlaceholder: 'sk-ant-...',
59
+ models: [
60
+ { id: 'claude-sonnet-4-5', displayName: 'Claude Sonnet 4.5', contextWindow: 200000, capabilities: ['text', 'vision', 'tools', 'reasoning'], defaultEnabled: true },
61
+ { id: 'claude-opus-4-1', displayName: 'Claude Opus 4.1', contextWindow: 200000, capabilities: ['text', 'vision', 'tools', 'reasoning'] },
62
+ { id: 'claude-haiku-4-5', displayName: 'Claude Haiku 4.5', contextWindow: 200000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
63
+ ],
64
+ },
65
+ {
66
+ providerId: 'gemini',
67
+ displayName: 'Google Gemini',
68
+ brandName: 'Gemini',
69
+ description: 'Google 推出的多模态大模型,支持文本、图像、视频',
70
+ category: 'recommended',
71
+ iconSlug: 'googlegemini',
72
+ brandColor: '#4285F4',
73
+ badge: '推荐',
74
+ adapterKind: 'gemini',
75
+ defaultBaseUrl: 'https://generativelanguage.googleapis.com',
76
+ keyUrl: 'https://aistudio.google.com/apikey',
77
+ docsUrl: 'https://ai.google.dev/gemini-api/docs',
78
+ keyPlaceholder: 'AIza...',
79
+ models: [
80
+ { id: 'gemini-2.5-pro', displayName: 'Gemini 2.5 Pro', contextWindow: 2000000, capabilities: ['text', 'vision', 'tools', 'reasoning'], defaultEnabled: true },
81
+ { id: 'gemini-2.5-flash', displayName: 'Gemini 2.5 Flash', contextWindow: 1000000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
82
+ ],
83
+ },
84
+ {
85
+ providerId: 'deepseek',
86
+ displayName: 'DeepSeek',
87
+ brandName: 'DeepSeek',
88
+ description: '国产开源模型,性价比极高,支持推理模式',
89
+ category: 'popular',
90
+ iconSlug: 'deepseek',
91
+ brandColor: '#4D6BFE',
92
+ badge: '热门',
93
+ adapterKind: 'openai-compatible',
94
+ defaultBaseUrl: 'https://api.deepseek.com/v1',
95
+ keyUrl: 'https://platform.deepseek.com/api_keys',
96
+ docsUrl: 'https://api-docs.deepseek.com',
97
+ keyPlaceholder: 'sk-...',
98
+ models: [
99
+ { id: 'deepseek-chat', displayName: 'DeepSeek Chat (V3)', contextWindow: 64000, capabilities: ['text', 'tools'], defaultEnabled: true },
100
+ { id: 'deepseek-reasoner', displayName: 'DeepSeek Reasoner (R1)', contextWindow: 64000, capabilities: ['text', 'reasoning'], defaultEnabled: true },
101
+ ],
102
+ },
103
+ {
104
+ providerId: 'groq',
105
+ displayName: 'Groq',
106
+ brandName: 'Groq',
107
+ description: '基于 LPU 的极速推理引擎,延迟低至毫秒级',
108
+ category: 'popular',
109
+ iconSlug: 'groq',
110
+ brandColor: '#F55036',
111
+ badge: '热门',
112
+ adapterKind: 'groq',
113
+ defaultBaseUrl: 'https://api.groq.com/openai/v1',
114
+ keyUrl: 'https://console.groq.com/keys',
115
+ docsUrl: 'https://console.groq.com/docs',
116
+ keyPlaceholder: 'gsk_...',
117
+ models: [
118
+ { id: 'llama-3.3-70b-versatile', displayName: 'Llama 3.3 70B', contextWindow: 128000, capabilities: ['text', 'tools'], defaultEnabled: true },
119
+ { id: 'llama-3.1-8b-instant', displayName: 'Llama 3.1 8B Instant', contextWindow: 128000, capabilities: ['text'] },
120
+ ],
121
+ },
122
+ {
123
+ providerId: 'xai',
124
+ displayName: 'xAI',
125
+ brandName: 'Grok',
126
+ description: 'Elon Musk 的 xAI 推出的 Grok 系列模型',
127
+ category: 'popular',
128
+ iconSlug: 'x',
129
+ brandColor: '#000000',
130
+ badge: '热门',
131
+ adapterKind: 'grok',
132
+ defaultBaseUrl: 'https://api.x.ai',
133
+ keyUrl: 'https://x.ai/api',
134
+ docsUrl: 'https://docs.x.ai',
135
+ keyPlaceholder: 'xai-...',
136
+ models: [
137
+ { id: 'grok-4', displayName: 'Grok 4', contextWindow: 256000, capabilities: ['text', 'vision', 'tools', 'reasoning'], defaultEnabled: true },
138
+ { id: 'grok-3', displayName: 'Grok 3', contextWindow: 131072, capabilities: ['text', 'tools'] },
139
+ ],
140
+ },
141
+ {
142
+ providerId: 'openrouter',
143
+ displayName: 'OpenRouter',
144
+ brandName: 'OpenRouter',
145
+ description: '聚合 200+ 模型的统一路由,一个 Key 访问所有厂商',
146
+ category: 'recommended',
147
+ iconSlug: 'openrouter',
148
+ brandColor: '#6467F2',
149
+ badge: '推荐',
150
+ adapterKind: 'openrouter',
151
+ defaultBaseUrl: 'https://openrouter.ai/api/v1',
152
+ keyUrl: 'https://openrouter.ai/keys',
153
+ docsUrl: 'https://openrouter.ai/docs',
154
+ keyPlaceholder: 'sk-or-...',
155
+ models: [
156
+ { id: 'openai/gpt-4o-mini', displayName: 'GPT-4o mini', contextWindow: 128000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
157
+ { id: 'openai/gpt-4o', displayName: 'GPT-4o', contextWindow: 128000, capabilities: ['text', 'vision', 'tools'] },
158
+ { id: 'anthropic/claude-sonnet-4.5', displayName: 'Claude Sonnet 4.5', contextWindow: 200000, capabilities: ['text', 'vision', 'tools', 'reasoning'], defaultEnabled: true },
159
+ { id: 'google/gemini-2.5-flash', displayName: 'Gemini 2.5 Flash', contextWindow: 1000000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
160
+ { id: 'deepseek/deepseek-chat', displayName: 'DeepSeek V3', contextWindow: 64000, capabilities: ['text', 'tools'] },
161
+ ],
162
+ },
163
+ {
164
+ providerId: 'mistral',
165
+ displayName: 'Mistral AI',
166
+ brandName: 'Mistral',
167
+ description: '欧洲开源大模型,擅长多语言与代码',
168
+ category: 'popular',
169
+ iconSlug: 'mistralai',
170
+ brandColor: '#FF7000',
171
+ badge: '热门',
172
+ adapterKind: 'openai-compatible',
173
+ defaultBaseUrl: 'https://api.mistral.ai/v1',
174
+ keyUrl: 'https://console.mistral.ai/api-keys',
175
+ docsUrl: 'https://docs.mistral.ai',
176
+ keyPlaceholder: '...',
177
+ models: [
178
+ { id: 'mistral-large-latest', displayName: 'Mistral Large', contextWindow: 128000, capabilities: ['text', 'vision', 'tools'], defaultEnabled: true },
179
+ { id: 'mistral-small-latest', displayName: 'Mistral Small', contextWindow: 32000, capabilities: ['text', 'tools'], defaultEnabled: true },
180
+ ],
181
+ },
182
+ {
183
+ providerId: 'moonshot',
184
+ displayName: 'Moonshot AI',
185
+ brandName: 'Kimi',
186
+ description: '月之暗面 Kimi,国产长文本之王',
187
+ category: 'popular',
188
+ iconSlug: 'moonshot',
189
+ brandColor: '#16161A',
190
+ badge: '热门',
191
+ adapterKind: 'openai-compatible',
192
+ defaultBaseUrl: 'https://api.moonshot.cn/v1',
193
+ keyUrl: 'https://platform.moonshot.cn/console/api-keys',
194
+ docsUrl: 'https://platform.moonshot.cn/docs',
195
+ keyPlaceholder: 'sk-...',
196
+ models: [
197
+ { id: 'moonshot-v1-128k', displayName: 'Moonshot v1 128K', contextWindow: 128000, capabilities: ['text', 'tools'], defaultEnabled: true },
198
+ { id: 'kimi-k2-0905-preview', displayName: 'Kimi K2', contextWindow: 128000, capabilities: ['text', 'tools'], defaultEnabled: true },
199
+ ],
200
+ },
201
+ {
202
+ providerId: 'ollama',
203
+ displayName: 'Ollama',
204
+ brandName: 'Ollama',
205
+ description: '本地部署开源模型,零成本零延迟(需先本地安装 Ollama)',
206
+ category: 'local',
207
+ iconSlug: 'ollama',
208
+ brandColor: '#FFFFFF',
209
+ badge: '本地',
210
+ adapterKind: 'ollama',
211
+ defaultBaseUrl: 'http://localhost:11434',
212
+ keyUrl: 'https://ollama.com/download',
213
+ docsUrl: 'https://ollama.com/library',
214
+ keyPlaceholder: '本地部署无需 API Key',
215
+ isLocal: true,
216
+ models: [
217
+ { id: 'llama3.3', displayName: 'Llama 3.3', contextWindow: 128000, capabilities: ['text', 'tools'], defaultEnabled: true },
218
+ { id: 'qwen2.5', displayName: 'Qwen 2.5', contextWindow: 128000, capabilities: ['text'], defaultEnabled: true },
219
+ { id: 'deepseek-r1', displayName: 'DeepSeek R1', contextWindow: 128000, capabilities: ['text', 'reasoning'] },
220
+ ],
221
+ },
222
+ ]
@@ -0,0 +1,95 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ // packages/shared/src/modules/ai-providers/types.ts
19
+ export type AdapterKind =
20
+ | 'openai'
21
+ | 'anthropic'
22
+ | 'gemini'
23
+ | 'groq'
24
+ | 'grok'
25
+ | 'openrouter'
26
+ | 'ollama'
27
+ | 'openai-compatible'
28
+
29
+ export type ProviderCategory = 'recommended' | 'popular' | 'local'
30
+
31
+ export type ModelCapability = 'text' | 'vision' | 'tools' | 'reasoning' | 'audio'
32
+
33
+ export interface AiModelMeta {
34
+ /** 模型 ID(传给 adapter 的 model 字符串) */
35
+ id: string
36
+ /** 显示名 */
37
+ displayName: string
38
+ /** 上下文窗口(tokens) */
39
+ contextWindow?: number
40
+ /** 能力标签 */
41
+ capabilities?: ModelCapability[]
42
+ /** 是否默认勾选 */
43
+ defaultEnabled?: boolean
44
+ /** 模型图标 slug(后台配置,@lobehub/icons PascalCase 导出名),未配置时 fallback 到服务商图标 */
45
+ iconSlug?: string
46
+ /** 发布日期 YYYY-MM-DD */
47
+ releaseDate?: string
48
+ /** 输入价格($/百万 tokens) */
49
+ inputPrice?: number
50
+ /** 输出价格($/百万 tokens) */
51
+ outputPrice?: number
52
+ /** 自定义标签(如「旗舰」「快速」),区别于 capabilities 能力标签 */
53
+ tags?: string[]
54
+ }
55
+
56
+ /** 服务商完整元数据(admin 表单 + DB 行 + 前端展示共用) */
57
+ export interface AiProviderMeta {
58
+ /** 业务标识("openai" "anthropic" 等),与数据库 providerId 字段对应 */
59
+ providerId: string
60
+ displayName: string
61
+ brandName: string
62
+ description: string
63
+ category: ProviderCategory
64
+ iconSlug: string
65
+ brandColor: string
66
+ /** 卡片角标文案(如「推荐」「热门」「NEW」),admin 可配,留空则不显示 */
67
+ badge?: string
68
+ adapterKind: AdapterKind
69
+ defaultBaseUrl?: string
70
+ keyUrl?: string
71
+ docsUrl?: string
72
+ keyPlaceholder?: string
73
+ isLocal?: boolean
74
+ models: AiModelMeta[]
75
+ }
76
+
77
+ /** admin 表格行:DB 行 + 关联用户配置数 */
78
+ export interface AiProviderRow extends AiProviderMeta {
79
+ /** DB 主键 */
80
+ id: string
81
+ enabled: boolean
82
+ sortOrder: number
83
+ /** 已配置此服务商的用户数 */
84
+ configCount: number
85
+ createdAt: string
86
+ updatedAt: string
87
+ }
88
+
89
+ /** 卡片角标的预设颜色(按文案匹配),admin 也可自由输入文案 */
90
+ export const PROVIDER_BADGE_STYLES: Record<string, string> = {
91
+ 推荐: "bg-primary/10 text-primary border-primary/30",
92
+ 热门: "bg-orange-500/10 text-orange-600 dark:text-orange-400 border-orange-500/30",
93
+ NEW: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 border-emerald-500/30",
94
+ 本地: "bg-blue-500/10 text-blue-600 dark:text-blue-400 border-blue-500/30",
95
+ }
@@ -0,0 +1,63 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ export interface FeatureMeta {
19
+ /** oss = 开源免费;paid = 付费;enterprise = 企业版专属 */
20
+ tier: 'oss' | 'paid' | 'enterprise'
21
+ /** 该功能依赖的 proModule 服务名;null = 开源代码自带(仅权益门控) */
22
+ module:
23
+ | 'billing'
24
+ | 'hostedAi'
25
+ | 'sso'
26
+ | 'audit'
27
+ | 'permissions'
28
+ | 'license'
29
+ | 'versionHistory'
30
+ | 'automation'
31
+ | 'templates'
32
+ | 'analytics'
33
+ | 'globalSearch'
34
+ | 'compliance'
35
+ | null
36
+ }
37
+
38
+ export const FeatureRegistry = {
39
+ byokAi: { tier: 'oss' as const, module: null },
40
+ hostedAi: { tier: 'paid' as const, module: 'hostedAi' as const },
41
+ multiProvider: { tier: 'paid' as const, module: null },
42
+ largePageSize: { tier: 'paid' as const, module: null },
43
+ versionHistory: { tier: 'paid' as const, module: 'versionHistory' as const },
44
+ automation: { tier: 'paid' as const, module: 'automation' as const },
45
+ templates: { tier: 'paid' as const, module: 'templates' as const },
46
+ globalSearch: { tier: 'paid' as const, module: 'globalSearch' as const },
47
+ analytics: { tier: 'enterprise' as const, module: 'analytics' as const },
48
+ sso: { tier: 'enterprise' as const, module: 'sso' as const },
49
+ audit: { tier: 'enterprise' as const, module: 'audit' as const },
50
+ advancedPermissions: { tier: 'enterprise' as const, module: 'permissions' as const },
51
+ compliance: { tier: 'enterprise' as const, module: 'compliance' as const },
52
+ customAgents: { tier: 'paid' as const, module: null },
53
+ } as const satisfies Record<string, FeatureMeta>
54
+
55
+ export type FeatureKey = keyof typeof FeatureRegistry
56
+ export const FEATURE_KEYS = Object.keys(FeatureRegistry) as FeatureKey[]
57
+
58
+ /** OSS 部署(billing 模块缺失)的基础白名单——唯一允许「无订阅即放行」的集合 */
59
+ export const OSS_BASE_FEATURES: readonly FeatureKey[] = ['byokAi', 'customAgents']
60
+
61
+ export function isOssFeature(key: FeatureKey): boolean {
62
+ return FeatureRegistry[key].tier === 'oss'
63
+ }
@@ -0,0 +1,11 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+
3
+ import { z } from 'zod'
4
+ import { FEATURE_KEYS, type FeatureKey } from './feature-registry'
5
+
6
+ export const PlanFeaturesSchema = z.record(
7
+ z.enum(FEATURE_KEYS as [FeatureKey, ...FeatureKey[]]),
8
+ z.boolean(),
9
+ )
10
+
11
+ export type PlanFeatures = z.infer<typeof PlanFeaturesSchema>
@@ -0,0 +1,80 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ export interface ResourceMeta {
19
+ tier: 'paid' | 'enterprise'
20
+ unit: string
21
+ purchasable: boolean | 'custom'
22
+ step: number
23
+ /** 降购下限约束:seats 不允许降到当前活跃成员数以下 */
24
+ floor?: 'activeMembers'
25
+ }
26
+
27
+ export const ResourceRegistry = {
28
+ seats: {
29
+ /** 成员席位池(billing 加购语义不变);访客池见 guestSeats */
30
+ tier: 'paid' as const,
31
+ unit: 'per-seat',
32
+ purchasable: true,
33
+ step: 1,
34
+ floor: 'activeMembers' as const,
35
+ },
36
+ guestSeats: {
37
+ tier: 'paid' as const,
38
+ unit: 'guest-seats',
39
+ purchasable: false,
40
+ step: 1,
41
+ },
42
+ aiQuotaMonthly: {
43
+ tier: 'paid' as const,
44
+ unit: 'requests/month',
45
+ purchasable: false,
46
+ step: 1,
47
+ },
48
+ agentQuota: {
49
+ tier: 'paid' as const,
50
+ unit: 'agents',
51
+ purchasable: false,
52
+ step: 1,
53
+ },
54
+ skillQuota: {
55
+ tier: 'paid' as const,
56
+ unit: 'skills',
57
+ purchasable: false,
58
+ step: 1,
59
+ },
60
+ workspaces: {
61
+ tier: 'paid' as const,
62
+ unit: 'workspaces',
63
+ purchasable: false,
64
+ step: 1,
65
+ },
66
+ } as const satisfies Record<string, ResourceMeta>
67
+
68
+ export type ResourceKey = keyof typeof ResourceRegistry
69
+ export const RESOURCE_KEYS = Object.keys(ResourceRegistry) as ResourceKey[]
70
+
71
+ export interface ResourceSnapshot {
72
+ limit: number | 'unlimited'
73
+ usage: number
74
+ }
75
+
76
+ export type ResourceSnapshots = Record<ResourceKey, ResourceSnapshot>
77
+
78
+ export function isResourceDefined(key: string): key is ResourceKey {
79
+ return key in ResourceRegistry
80
+ }
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import type { AllBlueModule } from "../../interfaces/module"
19
+
20
+ export const pluginModule: AllBlueModule = {
21
+ id: "anyhub",
22
+ name: "应用市场",
23
+ icon: "blocks",
24
+ workspaceRoute: "/apps/anyhub",
25
+ entities: [
26
+ {
27
+ type: "anyhubApp",
28
+ table: "anyhub_apps",
29
+ searchFields: ["name", "displayName", "description"],
30
+ displayFields: ["displayName"],
31
+ },
32
+ ],
33
+ aiCommands: [],
34
+ referenceDisplay: (type, data) => ({
35
+ title: (data.displayName as string) || (data.name as string) || "Untitled App",
36
+ url: `/apps/anyhub`,
37
+ }),
38
+ }
@@ -0,0 +1,45 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import type { AllBlueModule } from "../../interfaces/module"
19
+
20
+ export const prdModule: AllBlueModule = {
21
+ id: "prd",
22
+ name: "PRD",
23
+ icon: "file-text",
24
+ workspaceRoute: "/prd",
25
+ entities: [
26
+ {
27
+ type: "prd_document",
28
+ table: "prd_documents",
29
+ searchFields: ["title", "description"],
30
+ displayFields: ["title", "status"],
31
+ },
32
+ {
33
+ type: "prd_page",
34
+ table: "prd_pages",
35
+ searchFields: ["title", "content"],
36
+ displayFields: ["title"],
37
+ },
38
+ ],
39
+ aiCommands: [],
40
+ referenceDisplay: (type, data) => ({
41
+ title: (data.title as string) || "Untitled PRD",
42
+ status: data.status as string,
43
+ url: `/prd/${data.id}`,
44
+ }),
45
+ }
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: AGPL-3.0-or-later
2
+ // AllBlue - 理想之海
3
+ // Copyright (C) 2026 AllBlue Contributors
4
+ //
5
+ // This program is free software: you can redistribute it and/or modify
6
+ // it under the terms of the GNU Affero General Public License as published by
7
+ // the Free Software Foundation, either version 3 of the License, or
8
+ // (at your option) any later version.
9
+ //
10
+ // This program is distributed in the hope that it will be useful,
11
+ // but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ // GNU Affero General Public License for more details.
14
+ //
15
+ // You should have received a copy of the GNU Affero General Public License
16
+ // along with this program. If not, see <https://www.gnu.org/licenses/>.
17
+
18
+ import type { AllBlueModule } from "../../interfaces/module"
19
+
20
+ export const prototypeModule: AllBlueModule = {
21
+ id: "prototype",
22
+ name: "原型",
23
+ icon: "pen-tool",
24
+ workspaceRoute: "/plugin-anything",
25
+ entities: [
26
+ {
27
+ type: "prototype_component",
28
+ table: "plugin_installations",
29
+ searchFields: ["name", "description"],
30
+ displayFields: ["name"],
31
+ },
32
+ ],
33
+ aiCommands: [],
34
+ referenceDisplay: (type, data) => ({
35
+ title: (data.name as string) || "Untitled Prototype",
36
+ url: `/plugin-anything`,
37
+ }),
38
+ }