@undefineds.co/models 0.1.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 (254) hide show
  1. package/README.md +578 -0
  2. package/dist/_drizzle-solid/columns.d.ts +37 -0
  3. package/dist/_drizzle-solid/columns.js +1 -0
  4. package/dist/_drizzle-solid/pod-table.d.ts +3 -0
  5. package/dist/_drizzle-solid/pod-table.js +1 -0
  6. package/dist/_drizzle-solid/types.d.ts +40 -0
  7. package/dist/_drizzle-solid/types.js +1 -0
  8. package/dist/agent.providers.d.ts +13 -0
  9. package/dist/agent.providers.js +69 -0
  10. package/dist/agent.repository.d.ts +85 -0
  11. package/dist/agent.repository.js +7 -0
  12. package/dist/agent.schema.d.ts +1 -0
  13. package/dist/agent.schema.js +1 -0
  14. package/dist/ai-config/index.d.ts +61 -0
  15. package/dist/ai-config/index.js +294 -0
  16. package/dist/ai-config.d.ts +1 -0
  17. package/dist/ai-config.js +1 -0
  18. package/dist/ai-model.schema.d.ts +1 -0
  19. package/dist/ai-model.schema.js +1 -0
  20. package/dist/ai-provider.schema.d.ts +1 -0
  21. package/dist/ai-provider.schema.js +1 -0
  22. package/dist/approval.schema.d.ts +1 -0
  23. package/dist/approval.schema.js +1 -0
  24. package/dist/audit.schema.d.ts +1 -0
  25. package/dist/audit.schema.js +1 -0
  26. package/dist/chat.repository.d.ts +61 -0
  27. package/dist/chat.repository.js +8 -0
  28. package/dist/chat.schema.d.ts +1 -0
  29. package/dist/chat.schema.js +1 -0
  30. package/dist/chat.utils.d.ts +3 -0
  31. package/dist/chat.utils.js +30 -0
  32. package/dist/contact.repository.d.ts +85 -0
  33. package/dist/contact.repository.js +8 -0
  34. package/dist/contact.schema.d.ts +1 -0
  35. package/dist/contact.schema.js +1 -0
  36. package/dist/core/agent-provider.schema.d.ts +1 -0
  37. package/dist/core/agent-provider.schema.js +1 -0
  38. package/dist/core/agent-status.schema.d.ts +12 -0
  39. package/dist/core/agent-status.schema.js +18 -0
  40. package/dist/core/agent.schema.d.ts +72 -0
  41. package/dist/core/agent.schema.js +38 -0
  42. package/dist/core/ai-config.schema.d.ts +11 -0
  43. package/dist/core/ai-config.schema.js +18 -0
  44. package/dist/core/ai-model.schema.d.ts +15 -0
  45. package/dist/core/ai-model.schema.js +21 -0
  46. package/dist/core/ai-provider.schema.d.ts +16 -0
  47. package/dist/core/ai-provider.schema.js +28 -0
  48. package/dist/core/approval.schema.d.ts +21 -0
  49. package/dist/core/approval.schema.js +33 -0
  50. package/dist/core/audit.schema.d.ts +17 -0
  51. package/dist/core/audit.schema.js +29 -0
  52. package/dist/core/chat.schema.d.ts +36 -0
  53. package/dist/core/chat.schema.js +45 -0
  54. package/dist/core/contact.schema.d.ts +47 -0
  55. package/dist/core/contact.schema.js +59 -0
  56. package/dist/core/credential.schema.d.ts +56 -0
  57. package/dist/core/credential.schema.js +40 -0
  58. package/dist/core/extension/extension.schema.d.ts +4 -0
  59. package/dist/core/extension/extension.schema.js +11 -0
  60. package/dist/core/extension/index.d.ts +1 -0
  61. package/dist/core/extension/index.js +1 -0
  62. package/dist/core/extension.d.ts +1 -0
  63. package/dist/core/extension.js +1 -0
  64. package/dist/core/favorite/favorite.schema.d.ts +24 -0
  65. package/dist/core/favorite/favorite.schema.js +34 -0
  66. package/dist/core/favorite/index.d.ts +1 -0
  67. package/dist/core/favorite/index.js +1 -0
  68. package/dist/core/file/file.schema.d.ts +39 -0
  69. package/dist/core/file/file.schema.js +51 -0
  70. package/dist/core/file/index.d.ts +1 -0
  71. package/dist/core/file/index.js +1 -0
  72. package/dist/core/file.d.ts +1 -0
  73. package/dist/core/file.js +1 -0
  74. package/dist/core/grant.schema.d.ts +16 -0
  75. package/dist/core/grant.schema.js +29 -0
  76. package/dist/core/import/import-job.schema.d.ts +5 -0
  77. package/dist/core/import/import-job.schema.js +5 -0
  78. package/dist/core/import/index.d.ts +1 -0
  79. package/dist/core/import/index.js +1 -0
  80. package/dist/core/import.d.ts +1 -0
  81. package/dist/core/import.js +1 -0
  82. package/dist/core/inbox-notification.schema.d.ts +9 -0
  83. package/dist/core/inbox-notification.schema.js +16 -0
  84. package/dist/core/index.d.ts +31 -0
  85. package/dist/core/index.js +32 -0
  86. package/dist/core/knowledge/index.d.ts +1 -0
  87. package/dist/core/knowledge/index.js +1 -0
  88. package/dist/core/knowledge/knowledge-folder.schema.d.ts +7 -0
  89. package/dist/core/knowledge/knowledge-folder.schema.js +6 -0
  90. package/dist/core/knowledge.d.ts +1 -0
  91. package/dist/core/knowledge.js +1 -0
  92. package/dist/core/message.schema.d.ts +33 -0
  93. package/dist/core/message.schema.js +49 -0
  94. package/dist/core/namespaces.d.ts +176 -0
  95. package/dist/core/namespaces.js +289 -0
  96. package/dist/core/profile.d.ts +16 -0
  97. package/dist/core/profile.js +19 -0
  98. package/dist/core/schema.d.ts +304 -0
  99. package/dist/core/schema.js +46 -0
  100. package/dist/core/session/index.d.ts +1 -0
  101. package/dist/core/session/index.js +1 -0
  102. package/dist/core/session/session.schema.d.ts +6 -0
  103. package/dist/core/session/session.schema.js +6 -0
  104. package/dist/core/session.d.ts +1 -0
  105. package/dist/core/session.js +1 -0
  106. package/dist/core/settings/index.d.ts +1 -0
  107. package/dist/core/settings/index.js +1 -0
  108. package/dist/core/settings/settings.schema.d.ts +49 -0
  109. package/dist/core/settings/settings.schema.js +63 -0
  110. package/dist/core/settings.d.ts +1 -0
  111. package/dist/core/settings.js +1 -0
  112. package/dist/core/thread.schema.d.ts +28 -0
  113. package/dist/core/thread.schema.js +36 -0
  114. package/dist/core/types/collaboration-blocks.d.ts +52 -0
  115. package/dist/core/types/collaboration-blocks.js +7 -0
  116. package/dist/core/types/message-block.d.ts +270 -0
  117. package/dist/core/types/message-block.js +125 -0
  118. package/dist/core/vector-store.schema.d.ts +25 -0
  119. package/dist/core/vector-store.schema.js +35 -0
  120. package/dist/core/vocab/_namespaces.d.ts +1 -0
  121. package/dist/core/vocab/_namespaces.js +3 -0
  122. package/dist/core/vocab/chat.vocab.d.ts +16 -0
  123. package/dist/core/vocab/chat.vocab.js +22 -0
  124. package/dist/core/vocab/contact.vocab.d.ts +21 -0
  125. package/dist/core/vocab/contact.vocab.js +22 -0
  126. package/dist/core/vocab/index.d.ts +6 -0
  127. package/dist/core/vocab/index.js +6 -0
  128. package/dist/core/vocab/message.vocab.d.ts +20 -0
  129. package/dist/core/vocab/message.vocab.js +24 -0
  130. package/dist/core/vocab/sidecar.vocab.d.ts +46 -0
  131. package/dist/core/vocab/sidecar.vocab.js +47 -0
  132. package/dist/core/vocab/thread.vocab.d.ts +11 -0
  133. package/dist/core/vocab/thread.vocab.js +14 -0
  134. package/dist/core/vocab/workspace.vocab.d.ts +12 -0
  135. package/dist/core/vocab/workspace.vocab.js +13 -0
  136. package/dist/core/vocab.d.ts +1 -0
  137. package/dist/core/vocab.js +1 -0
  138. package/dist/core/workspace.schema.d.ts +35 -0
  139. package/dist/core/workspace.schema.js +106 -0
  140. package/dist/core.d.ts +1 -0
  141. package/dist/core.js +1 -0
  142. package/dist/credential.schema.d.ts +1 -0
  143. package/dist/credential.schema.js +1 -0
  144. package/dist/discovery/index.d.ts +31 -0
  145. package/dist/discovery/index.js +147 -0
  146. package/dist/discovery/models.json +2623 -0
  147. package/dist/discovery/providers.json +156 -0
  148. package/dist/discovery/types.d.ts +103 -0
  149. package/dist/discovery/types.js +12 -0
  150. package/dist/discovery/vercel.d.ts +25 -0
  151. package/dist/discovery/vercel.js +95 -0
  152. package/dist/discovery.d.ts +1 -0
  153. package/dist/discovery.js +1 -0
  154. package/dist/extension/extension.schema.d.ts +1 -0
  155. package/dist/extension/extension.schema.js +1 -0
  156. package/dist/extension/index.d.ts +1 -0
  157. package/dist/extension/index.js +1 -0
  158. package/dist/extension.d.ts +1 -0
  159. package/dist/extension.js +1 -0
  160. package/dist/favorite/favorite.schema.d.ts +1 -0
  161. package/dist/favorite/favorite.schema.js +1 -0
  162. package/dist/favorite/index.d.ts +2 -0
  163. package/dist/favorite/index.js +7 -0
  164. package/dist/favorite/starred-sync.d.ts +66 -0
  165. package/dist/favorite/starred-sync.js +156 -0
  166. package/dist/favorite.d.ts +1 -0
  167. package/dist/favorite.js +1 -0
  168. package/dist/file/file.schema.d.ts +1 -0
  169. package/dist/file/file.schema.js +1 -0
  170. package/dist/file/index.d.ts +1 -0
  171. package/dist/file/index.js +1 -0
  172. package/dist/file.d.ts +1 -0
  173. package/dist/file.js +1 -0
  174. package/dist/fixtures/contracts-chat-contact.d.ts +13 -0
  175. package/dist/fixtures/contracts-chat-contact.js +76 -0
  176. package/dist/grant.schema.d.ts +1 -0
  177. package/dist/grant.schema.js +1 -0
  178. package/dist/import/import-job.schema.d.ts +5 -0
  179. package/dist/import/import-job.schema.js +5 -0
  180. package/dist/import/index.d.ts +1 -0
  181. package/dist/import/index.js +1 -0
  182. package/dist/import.d.ts +1 -0
  183. package/dist/import.js +1 -0
  184. package/dist/inbox-notification.schema.d.ts +1 -0
  185. package/dist/inbox-notification.schema.js +1 -0
  186. package/dist/index.d.ts +41 -0
  187. package/dist/index.js +83 -0
  188. package/dist/knowledge/index.d.ts +1 -0
  189. package/dist/knowledge/index.js +1 -0
  190. package/dist/knowledge/knowledge-folder.schema.d.ts +1 -0
  191. package/dist/knowledge/knowledge-folder.schema.js +1 -0
  192. package/dist/knowledge.d.ts +1 -0
  193. package/dist/knowledge.js +1 -0
  194. package/dist/message.repository.d.ts +81 -0
  195. package/dist/message.repository.js +8 -0
  196. package/dist/message.schema.d.ts +1 -0
  197. package/dist/message.schema.js +1 -0
  198. package/dist/namespaces.d.ts +1 -0
  199. package/dist/namespaces.js +1 -0
  200. package/dist/profile.d.ts +1 -0
  201. package/dist/profile.js +1 -0
  202. package/dist/repository.d.ts +59 -0
  203. package/dist/repository.js +186 -0
  204. package/dist/schema.d.ts +1 -0
  205. package/dist/schema.js +1 -0
  206. package/dist/session/index.d.ts +1 -0
  207. package/dist/session/index.js +1 -0
  208. package/dist/session/session.schema.d.ts +1 -0
  209. package/dist/session/session.schema.js +1 -0
  210. package/dist/session.d.ts +1 -0
  211. package/dist/session.js +1 -0
  212. package/dist/settings/index.d.ts +1 -0
  213. package/dist/settings/index.js +1 -0
  214. package/dist/settings/settings.schema.d.ts +1 -0
  215. package/dist/settings/settings.schema.js +1 -0
  216. package/dist/settings.d.ts +1 -0
  217. package/dist/settings.js +1 -0
  218. package/dist/sidecar/index.d.ts +2 -0
  219. package/dist/sidecar/index.js +2 -0
  220. package/dist/sidecar/persistence-mapping.d.ts +51 -0
  221. package/dist/sidecar/persistence-mapping.js +44 -0
  222. package/dist/sidecar/sidecar-events.d.ts +632 -0
  223. package/dist/sidecar/sidecar-events.js +133 -0
  224. package/dist/thread.repository.d.ts +41 -0
  225. package/dist/thread.repository.js +8 -0
  226. package/dist/thread.schema.d.ts +1 -0
  227. package/dist/thread.schema.js +1 -0
  228. package/dist/types/collaboration-blocks.d.ts +52 -0
  229. package/dist/types/collaboration-blocks.js +7 -0
  230. package/dist/types/message-block.d.ts +270 -0
  231. package/dist/types/message-block.js +125 -0
  232. package/dist/vocab/_namespaces.d.ts +1 -0
  233. package/dist/vocab/_namespaces.js +3 -0
  234. package/dist/vocab/chat.vocab.d.ts +16 -0
  235. package/dist/vocab/chat.vocab.js +22 -0
  236. package/dist/vocab/contact.vocab.d.ts +21 -0
  237. package/dist/vocab/contact.vocab.js +22 -0
  238. package/dist/vocab/index.d.ts +6 -0
  239. package/dist/vocab/index.js +6 -0
  240. package/dist/vocab/message.vocab.d.ts +20 -0
  241. package/dist/vocab/message.vocab.js +24 -0
  242. package/dist/vocab/sidecar.vocab.d.ts +46 -0
  243. package/dist/vocab/sidecar.vocab.js +47 -0
  244. package/dist/vocab/thread.vocab.d.ts +11 -0
  245. package/dist/vocab/thread.vocab.js +14 -0
  246. package/dist/vocab/workspace.vocab.d.ts +12 -0
  247. package/dist/vocab/workspace.vocab.js +13 -0
  248. package/dist/vocab.d.ts +1 -0
  249. package/dist/vocab.js +1 -0
  250. package/dist/workspace.repository.d.ts +45 -0
  251. package/dist/workspace.repository.js +8 -0
  252. package/dist/workspace.schema.d.ts +1 -0
  253. package/dist/workspace.schema.js +1 -0
  254. package/package.json +68 -0
@@ -0,0 +1,156 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "updatedAt": "2026-03-16",
4
+ "providers": [
5
+ {
6
+ "slug": "openai",
7
+ "displayName": "OpenAI",
8
+ "baseUrl": "https://api.openai.com/v1",
9
+ "homepage": "https://platform.openai.com",
10
+ "logoUrl": "https://openai.com/favicon.ico",
11
+ "description": "OpenAI API - GPT-4, GPT-3.5 系列模型",
12
+ "supportedFeatures": ["chat", "embedding", "image", "audio", "vision", "function-calling"],
13
+ "authType": "bearer"
14
+ },
15
+ {
16
+ "slug": "anthropic",
17
+ "displayName": "Anthropic",
18
+ "baseUrl": "https://api.anthropic.com/v1",
19
+ "homepage": "https://www.anthropic.com",
20
+ "logoUrl": "https://www.anthropic.com/favicon.ico",
21
+ "description": "Anthropic Claude 系列模型",
22
+ "supportedFeatures": ["chat", "vision", "function-calling"],
23
+ "authType": "x-api-key"
24
+ },
25
+ {
26
+ "slug": "openrouter",
27
+ "displayName": "OpenRouter",
28
+ "baseUrl": "https://openrouter.ai/api/v1",
29
+ "homepage": "https://openrouter.ai",
30
+ "logoUrl": "https://openrouter.ai/favicon.ico",
31
+ "description": "统一接口访问多种 AI 模型",
32
+ "supportedFeatures": ["chat", "vision", "function-calling"],
33
+ "authType": "bearer"
34
+ },
35
+ {
36
+ "slug": "deepseek",
37
+ "displayName": "DeepSeek",
38
+ "baseUrl": "https://api.deepseek.com/v1",
39
+ "homepage": "https://www.deepseek.com",
40
+ "logoUrl": "https://www.deepseek.com/favicon.ico",
41
+ "description": "DeepSeek 深度求索 AI 模型",
42
+ "supportedFeatures": ["chat", "function-calling"],
43
+ "authType": "bearer"
44
+ },
45
+ {
46
+ "slug": "ollama",
47
+ "displayName": "Ollama",
48
+ "baseUrl": "http://localhost:11434/v1",
49
+ "homepage": "https://ollama.com",
50
+ "logoUrl": "https://ollama.com/public/ollama.png",
51
+ "description": "本地模型运行与管理",
52
+ "supportedFeatures": ["chat", "embedding", "vision"],
53
+ "authType": "none"
54
+ },
55
+ {
56
+ "slug": "google",
57
+ "displayName": "Google (Gemini)",
58
+ "baseUrl": "https://generativelanguage.googleapis.com/v1beta",
59
+ "homepage": "https://ai.google.dev",
60
+ "logoUrl": "https://ai.google.dev/favicon.ico",
61
+ "description": "Google Gemini 系列模型",
62
+ "supportedFeatures": ["chat", "vision", "embedding"],
63
+ "authType": "bearer"
64
+ },
65
+ {
66
+ "slug": "x-ai",
67
+ "displayName": "xAI (Grok)",
68
+ "baseUrl": "https://api.x.ai/v1",
69
+ "homepage": "https://x.ai",
70
+ "logoUrl": "https://x.ai/favicon.ico",
71
+ "description": "xAI Grok 模型",
72
+ "supportedFeatures": ["chat", "function-calling"],
73
+ "authType": "bearer"
74
+ },
75
+ {
76
+ "slug": "qwen",
77
+ "displayName": "通义千问",
78
+ "baseUrl": "https://dashscope.aliyuncs.com/api/v1",
79
+ "homepage": "https://qwen.ai",
80
+ "logoUrl": "https://qwen.ai/favicon.ico",
81
+ "description": "阿里云通义千问系列模型",
82
+ "supportedFeatures": ["chat", "vision", "function-calling"],
83
+ "authType": "bearer"
84
+ },
85
+ {
86
+ "slug": "moonshot",
87
+ "displayName": "Moonshot (Kimi)",
88
+ "baseUrl": "https://api.moonshot.cn/v1",
89
+ "homepage": "https://www.moonshot.cn",
90
+ "logoUrl": "https://www.moonshot.cn/favicon.ico",
91
+ "description": "月之暗面 Kimi 模型",
92
+ "supportedFeatures": ["chat", "function-calling"],
93
+ "authType": "bearer"
94
+ },
95
+ {
96
+ "slug": "minimax",
97
+ "displayName": "MiniMax",
98
+ "baseUrl": "https://api.minimax.chat/v1",
99
+ "homepage": "https://www.minimaxi.com",
100
+ "logoUrl": "https://www.minimaxi.com/favicon.ico",
101
+ "description": "MiniMax 大模型平台",
102
+ "supportedFeatures": ["chat", "vision", "function-calling"],
103
+ "authType": "bearer"
104
+ },
105
+ {
106
+ "slug": "mistral",
107
+ "displayName": "Mistral",
108
+ "baseUrl": "https://api.mistral.ai/v1",
109
+ "homepage": "https://mistral.ai",
110
+ "logoUrl": "https://mistral.ai/favicon.ico",
111
+ "description": "Mistral 模型平台",
112
+ "supportedFeatures": ["chat", "embedding", "function-calling"],
113
+ "authType": "bearer"
114
+ },
115
+ {
116
+ "slug": "groq",
117
+ "displayName": "Groq",
118
+ "baseUrl": "https://api.groq.com/openai/v1",
119
+ "homepage": "https://groq.com",
120
+ "logoUrl": "https://groq.com/favicon.ico",
121
+ "description": "Groq 高速推理平台",
122
+ "supportedFeatures": ["chat", "function-calling"],
123
+ "authType": "bearer"
124
+ },
125
+ {
126
+ "slug": "together",
127
+ "displayName": "Together AI",
128
+ "baseUrl": "https://api.together.xyz/v1",
129
+ "homepage": "https://together.ai",
130
+ "logoUrl": "https://together.ai/favicon.ico",
131
+ "description": "Together AI 开源模型平台",
132
+ "supportedFeatures": ["chat", "embedding", "image"],
133
+ "authType": "bearer"
134
+ },
135
+ {
136
+ "slug": "zhipu",
137
+ "displayName": "ZhiPu",
138
+ "baseUrl": "https://open.bigmodel.cn/api/paas/v4",
139
+ "homepage": "https://open.bigmodel.cn",
140
+ "logoUrl": "https://open.bigmodel.cn/favicon.ico",
141
+ "description": "智谱 GLM 模型平台",
142
+ "supportedFeatures": ["chat", "vision", "function-calling"],
143
+ "authType": "bearer"
144
+ },
145
+ {
146
+ "slug": "codebuddy",
147
+ "displayName": "CodeBuddy",
148
+ "baseUrl": "https://api.codebuddy.ai/v1",
149
+ "homepage": "https://codebuddy.ai",
150
+ "logoUrl": "https://codebuddy.ai/favicon.ico",
151
+ "description": "CodeBuddy 开发助手模型平台",
152
+ "supportedFeatures": ["chat", "function-calling"],
153
+ "authType": "bearer"
154
+ }
155
+ ]
156
+ }
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Discovery Service Types
3
+ *
4
+ * 可扩展的发现服务体系,用于提供:
5
+ * - Providers (AI 供应商)
6
+ * - Models (模型列表)
7
+ * - Tools (工具/插件)
8
+ * - Agents (预设 Agent 模板)
9
+ * - Prompts (提示词模板)
10
+ * - 未来更多...
11
+ */
12
+ export interface ProviderMetadata {
13
+ slug: string;
14
+ displayName: string;
15
+ baseUrl: string;
16
+ homepage: string;
17
+ logoUrl?: string;
18
+ description?: string;
19
+ supportedFeatures?: ProviderFeature[];
20
+ authType?: 'bearer' | 'x-api-key' | 'query-param' | 'none';
21
+ }
22
+ export type ProviderFeature = 'chat' | 'embedding' | 'image' | 'audio' | 'vision' | 'function-calling';
23
+ export interface ModelMetadata {
24
+ id: string;
25
+ provider: string;
26
+ displayName: string;
27
+ description?: string;
28
+ contextLength?: number;
29
+ maxOutputTokens?: number;
30
+ pricing?: ModelPricing;
31
+ capabilities?: ModelCapability[];
32
+ isDefault?: boolean;
33
+ }
34
+ export interface ModelPricing {
35
+ input: number;
36
+ output: number;
37
+ currency?: string;
38
+ }
39
+ export type ModelCapability = 'chat' | 'vision' | 'function-calling' | 'streaming' | 'json-mode';
40
+ export interface ToolMetadata {
41
+ id: string;
42
+ name: string;
43
+ displayName: string;
44
+ description: string;
45
+ category?: string;
46
+ schema: ToolSchema;
47
+ enabled?: boolean;
48
+ }
49
+ export interface ToolSchema {
50
+ type: 'function';
51
+ function: {
52
+ name: string;
53
+ description: string;
54
+ parameters: Record<string, unknown>;
55
+ };
56
+ }
57
+ export interface AgentTemplate {
58
+ id: string;
59
+ name: string;
60
+ displayName: string;
61
+ description: string;
62
+ icon?: string;
63
+ provider: string;
64
+ model: string;
65
+ systemPrompt: string;
66
+ tools?: string[];
67
+ tags?: string[];
68
+ }
69
+ export interface PromptTemplate {
70
+ id: string;
71
+ name: string;
72
+ displayName: string;
73
+ description: string;
74
+ category?: string;
75
+ content: string;
76
+ variables?: PromptVariable[];
77
+ tags?: string[];
78
+ }
79
+ export interface PromptVariable {
80
+ name: string;
81
+ description?: string;
82
+ defaultValue?: string;
83
+ required?: boolean;
84
+ }
85
+ export interface DiscoveryRegistry {
86
+ version: string;
87
+ updatedAt: string;
88
+ providers: ProviderMetadata[];
89
+ models: ModelMetadata[];
90
+ tools?: ToolMetadata[];
91
+ agents?: AgentTemplate[];
92
+ prompts?: PromptTemplate[];
93
+ }
94
+ export interface DiscoveryService {
95
+ getProviders(): Promise<ProviderMetadata[]>;
96
+ getProvider(slug: string): Promise<ProviderMetadata | undefined>;
97
+ getModels(provider?: string): Promise<ModelMetadata[]>;
98
+ getModel(provider: string, modelId: string): Promise<ModelMetadata | undefined>;
99
+ getDefaultModel(provider: string): Promise<ModelMetadata | undefined>;
100
+ getTools?(): Promise<ToolMetadata[]>;
101
+ getAgentTemplates?(): Promise<AgentTemplate[]>;
102
+ getPromptTemplates?(): Promise<PromptTemplate[]>;
103
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Discovery Service Types
3
+ *
4
+ * 可扩展的发现服务体系,用于提供:
5
+ * - Providers (AI 供应商)
6
+ * - Models (模型列表)
7
+ * - Tools (工具/插件)
8
+ * - Agents (预设 Agent 模板)
9
+ * - Prompts (提示词模板)
10
+ * - 未来更多...
11
+ */
12
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { DiscoveryRegistry, ModelMetadata } from './types.js';
2
+ export interface VercelModelPricing {
3
+ input?: string;
4
+ output?: string;
5
+ }
6
+ export interface VercelModelEntry {
7
+ id: string;
8
+ name?: string;
9
+ description?: string;
10
+ owned_by?: string;
11
+ context_window?: number;
12
+ max_tokens?: number;
13
+ type?: string;
14
+ tags?: string[];
15
+ pricing?: VercelModelPricing;
16
+ }
17
+ export interface VercelModelCatalogResponse {
18
+ object?: string;
19
+ data?: VercelModelEntry[];
20
+ }
21
+ export declare const VERCEL_OWNER_PROVIDER_MAP: Record<string, string>;
22
+ export declare function mapVercelOwnerToProviderId(owner?: string | null): string;
23
+ export declare function normalizeVercelModelEntry(entry: VercelModelEntry, defaultModelIds?: Readonly<Record<string, string>>): ModelMetadata | null;
24
+ export declare function mergeVercelModelsIntoDiscovery(currentModels: readonly ModelMetadata[], upstreamModels: readonly VercelModelEntry[], defaultModelIds?: Readonly<Record<string, string>>): ModelMetadata[];
25
+ export declare function updateDiscoveryModelRegistry(currentRegistry: DiscoveryRegistry, upstreamCatalog: VercelModelCatalogResponse, updatedAt: string, defaultModelIds?: Readonly<Record<string, string>>): DiscoveryRegistry;
@@ -0,0 +1,95 @@
1
+ export const VERCEL_OWNER_PROVIDER_MAP = {
2
+ alibaba: 'qwen',
3
+ anthropic: 'anthropic',
4
+ deepseek: 'deepseek',
5
+ google: 'google',
6
+ minimax: 'minimax',
7
+ mistral: 'mistral',
8
+ moonshotai: 'moonshot',
9
+ openai: 'openai',
10
+ togetherai: 'together',
11
+ xai: 'x-ai',
12
+ zai: 'zhipu',
13
+ };
14
+ const DEFAULT_SYNCED_MODEL_TYPES = new Set(['language']);
15
+ function toNumber(value) {
16
+ if (typeof value !== 'string')
17
+ return undefined;
18
+ const parsed = Number(value);
19
+ return Number.isFinite(parsed) ? parsed : undefined;
20
+ }
21
+ function normalizeCapabilities(entry) {
22
+ const capabilities = new Set();
23
+ const tags = new Set(entry.tags ?? []);
24
+ if (entry.type === 'language') {
25
+ capabilities.add('chat');
26
+ }
27
+ if (tags.has('vision') || tags.has('file-input')) {
28
+ capabilities.add('vision');
29
+ }
30
+ if (tags.has('tool-use')) {
31
+ capabilities.add('function-calling');
32
+ }
33
+ if (entry.type === 'language') {
34
+ capabilities.add('streaming');
35
+ }
36
+ return Array.from(capabilities);
37
+ }
38
+ function compareModels(left, right) {
39
+ if (left.provider !== right.provider) {
40
+ return left.provider.localeCompare(right.provider);
41
+ }
42
+ if (Boolean(left.isDefault) !== Boolean(right.isDefault)) {
43
+ return left.isDefault ? -1 : 1;
44
+ }
45
+ return left.id.localeCompare(right.id);
46
+ }
47
+ export function mapVercelOwnerToProviderId(owner) {
48
+ if (!owner)
49
+ return '';
50
+ return VERCEL_OWNER_PROVIDER_MAP[owner] ?? '';
51
+ }
52
+ export function normalizeVercelModelEntry(entry, defaultModelIds = {}) {
53
+ const provider = mapVercelOwnerToProviderId(entry.owned_by);
54
+ if (!provider)
55
+ return null;
56
+ if (!entry.id || !DEFAULT_SYNCED_MODEL_TYPES.has(String(entry.type ?? 'language'))) {
57
+ return null;
58
+ }
59
+ return {
60
+ id: entry.id,
61
+ provider,
62
+ displayName: entry.name || entry.id,
63
+ description: entry.description,
64
+ contextLength: typeof entry.context_window === 'number' ? entry.context_window : undefined,
65
+ maxOutputTokens: typeof entry.max_tokens === 'number' ? entry.max_tokens : undefined,
66
+ capabilities: normalizeCapabilities(entry),
67
+ pricing: {
68
+ input: toNumber(entry.pricing?.input) ?? 0,
69
+ output: toNumber(entry.pricing?.output) ?? 0,
70
+ },
71
+ isDefault: defaultModelIds[provider] === entry.id || undefined,
72
+ };
73
+ }
74
+ export function mergeVercelModelsIntoDiscovery(currentModels, upstreamModels, defaultModelIds = {}) {
75
+ const syncedProviderIds = new Set(upstreamModels
76
+ .map((entry) => mapVercelOwnerToProviderId(entry.owned_by))
77
+ .filter(Boolean));
78
+ const preservedModels = currentModels.filter((model) => !syncedProviderIds.has(model.provider));
79
+ const normalizedModels = upstreamModels
80
+ .map((entry) => normalizeVercelModelEntry(entry, defaultModelIds))
81
+ .filter((model) => Boolean(model));
82
+ const deduped = new Map();
83
+ for (const model of [...preservedModels, ...normalizedModels]) {
84
+ deduped.set(`${model.provider}:${model.id}`, model);
85
+ }
86
+ return Array.from(deduped.values()).sort(compareModels);
87
+ }
88
+ export function updateDiscoveryModelRegistry(currentRegistry, upstreamCatalog, updatedAt, defaultModelIds = {}) {
89
+ const upstreamModels = Array.isArray(upstreamCatalog.data) ? upstreamCatalog.data : [];
90
+ return {
91
+ ...currentRegistry,
92
+ updatedAt,
93
+ models: mergeVercelModelsIntoDiscovery(currentRegistry.models ?? [], upstreamModels, defaultModelIds),
94
+ };
95
+ }
@@ -0,0 +1 @@
1
+ export * from './discovery/index.js';
@@ -0,0 +1 @@
1
+ export * from './discovery/index.js';
@@ -0,0 +1 @@
1
+ export { extensionSchema } from '../core.js';
@@ -0,0 +1 @@
1
+ export { extensionSchema } from '../core.js';
@@ -0,0 +1 @@
1
+ export { extensionSchema } from "./extension.schema.js";
@@ -0,0 +1 @@
1
+ export { extensionSchema } from "./extension.schema.js";
@@ -0,0 +1 @@
1
+ export * from './extension/index.js';
@@ -0,0 +1 @@
1
+ export * from './extension/index.js';
@@ -0,0 +1 @@
1
+ export { favoriteTable, type FavoriteRow, type FavoriteInsert, type FavoriteUpdate, } from '../core.js';
@@ -0,0 +1 @@
1
+ export { favoriteTable, } from '../core.js';
@@ -0,0 +1,2 @@
1
+ export { favoriteTable, type FavoriteRow, type FavoriteInsert, type FavoriteUpdate } from "./favorite.schema.js";
2
+ export { createStarredSyncHook, registerDbForStarredSync, chatStarredSyncHook, threadStarredSyncHook, contactStarredSyncHook, chatSnapshotExtractor, threadSnapshotExtractor, contactSnapshotExtractor, type SnapshotExtractor, type StarredSyncConfig, type SourceModule, } from "./starred-sync.js";
@@ -0,0 +1,7 @@
1
+ export { favoriteTable } from "./favorite.schema.js";
2
+ // Starred Sync Hook
3
+ export { createStarredSyncHook, registerDbForStarredSync,
4
+ // Pre-configured hooks
5
+ chatStarredSyncHook, threadStarredSyncHook, contactStarredSyncHook,
6
+ // Extractors (for custom configuration)
7
+ chatSnapshotExtractor, threadSnapshotExtractor, contactSnapshotExtractor, } from "./starred-sync.js";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Starred Sync Hook
3
+ *
4
+ * 当实体的 starred 字段变更时,自动同步到 favoriteTable:
5
+ * - starred: true → 创建 Favorite 记录
6
+ * - starred: false → 删除 Favorite 记录
7
+ *
8
+ * 支持的实体类型:Chat, Thread, Contact
9
+ * favoriteType 使用 RDF type URI 标识
10
+ */
11
+ import type { TableHooks } from '@undefineds.co/drizzle-solid';
12
+ /** V2 来源模块类型 */
13
+ export type SourceModule = 'chat' | 'contacts' | 'files' | 'messages' | 'thread';
14
+ /** 快照数据提取器 */
15
+ export interface SnapshotExtractor<T = Record<string, unknown>> {
16
+ /** 获取收藏标题 */
17
+ getTitle: (record: T) => string;
18
+ /** 获取内容快照(可选) */
19
+ getContent?: (record: T) => string | undefined;
20
+ /** 获取作者快照(可选) */
21
+ getAuthor?: (record: T) => string | undefined;
22
+ /** V2: 获取检索文本(可选,默认用 title) */
23
+ getSearchText?: (record: T) => string | undefined;
24
+ /** V2: 获取快照元数据 JSON(可选) */
25
+ getSnapshotMeta?: (record: T) => string | undefined;
26
+ }
27
+ /** Starred Sync Hook 配置 */
28
+ export interface StarredSyncConfig<T = Record<string, unknown>> {
29
+ /** RDF type URI (e.g., MEETING.LongChat, SIOC.Thread, VCARD.Individual) */
30
+ rdfType: string;
31
+ /** V2: 来源模块标识 */
32
+ sourceModule: SourceModule;
33
+ /** 快照数据提取器 */
34
+ extractor: SnapshotExtractor<T>;
35
+ }
36
+ /**
37
+ * 创建 starred 同步 hook
38
+ *
39
+ * @example
40
+ * const chatTable = podTable('chats', columns, {
41
+ * hooks: createStarredSyncHook({
42
+ * rdfType: MEETING.LongChat,
43
+ * extractor: {
44
+ * getTitle: (r) => r.title as string,
45
+ * getContent: (r) => r.lastMessagePreview as string,
46
+ * }
47
+ * })
48
+ * })
49
+ */
50
+ export declare function createStarredSyncHook<T = Record<string, unknown>>(config: StarredSyncConfig<T>): TableHooks;
51
+ /**
52
+ * 注册 db 实例(应用层启动时调用)
53
+ */
54
+ export declare function registerDbForStarredSync(db: any): void;
55
+ /** Chat 快照提取器 */
56
+ export declare const chatSnapshotExtractor: SnapshotExtractor;
57
+ /** Thread 快照提取器 */
58
+ export declare const threadSnapshotExtractor: SnapshotExtractor;
59
+ /** Contact 快照提取器 */
60
+ export declare const contactSnapshotExtractor: SnapshotExtractor;
61
+ /** Chat starred sync hook */
62
+ export declare const chatStarredSyncHook: TableHooks;
63
+ /** Thread starred sync hook */
64
+ export declare const threadStarredSyncHook: TableHooks;
65
+ /** Contact starred sync hook */
66
+ export declare const contactStarredSyncHook: TableHooks;
@@ -0,0 +1,156 @@
1
+ import { favoriteTable } from './favorite.schema.js';
2
+ import { MEETING, SIOC } from '../namespaces.js';
3
+ import { VCARD } from '@inrupt/vocab-common-rdf';
4
+ // ============================================================================
5
+ // Core Sync Logic
6
+ // ============================================================================
7
+ /**
8
+ * 创建 Favorite 记录
9
+ */
10
+ async function createFavorite(_ctx, config, record) {
11
+ const { rdfType, sourceModule, extractor } = config;
12
+ const targetUri = record['@id'] || record.id;
13
+ const sourceId = record.id || targetUri;
14
+ if (!targetUri) {
15
+ console.warn('[StarredSync] Cannot create favorite: missing target URI');
16
+ return;
17
+ }
18
+ const title = extractor.getTitle(record);
19
+ const favoriteData = {
20
+ id: crypto.randomUUID(),
21
+ targetType: rdfType,
22
+ targetUri,
23
+ title,
24
+ snapshotContent: extractor.getContent?.(record),
25
+ snapshotAuthor: extractor.getAuthor?.(record),
26
+ // V2 fields
27
+ sourceModule,
28
+ sourceId,
29
+ searchText: extractor.getSearchText?.(record) ?? title,
30
+ snapshotMeta: extractor.getSnapshotMeta?.(record),
31
+ favoredAt: new Date(),
32
+ updatedAt: new Date(),
33
+ };
34
+ try {
35
+ const db = getDbInstance();
36
+ if (db) {
37
+ await db.insert(favoriteTable).values(favoriteData).execute();
38
+ console.log(`[StarredSync] Created favorite: ${rdfType} → ${targetUri}`);
39
+ }
40
+ else {
41
+ console.warn('[StarredSync] No db instance registered');
42
+ }
43
+ }
44
+ catch (error) {
45
+ console.error('[StarredSync] Failed to create favorite:', error);
46
+ }
47
+ }
48
+ /**
49
+ * 删除 Favorite 记录(通过 targetUri 查找)
50
+ */
51
+ async function deleteFavorite(_ctx, targetUri) {
52
+ if (!targetUri)
53
+ return;
54
+ try {
55
+ const db = getDbInstance();
56
+ if (db) {
57
+ await db.delete(favoriteTable)
58
+ .where({ targetUri })
59
+ .execute();
60
+ console.log(`[StarredSync] Deleted favorite: ${targetUri}`);
61
+ }
62
+ }
63
+ catch (error) {
64
+ console.error('[StarredSync] Failed to delete favorite:', error);
65
+ }
66
+ }
67
+ // ============================================================================
68
+ // Hook Factory
69
+ // ============================================================================
70
+ /**
71
+ * 创建 starred 同步 hook
72
+ *
73
+ * @example
74
+ * const chatTable = podTable('chats', columns, {
75
+ * hooks: createStarredSyncHook({
76
+ * rdfType: MEETING.LongChat,
77
+ * extractor: {
78
+ * getTitle: (r) => r.title as string,
79
+ * getContent: (r) => r.lastMessagePreview as string,
80
+ * }
81
+ * })
82
+ * })
83
+ */
84
+ export function createStarredSyncHook(config) {
85
+ return {
86
+ afterUpdate: async (ctx, record, changes) => {
87
+ // 只有当 starred 字段发生变化时才处理
88
+ if (!('starred' in changes))
89
+ return;
90
+ const starred = record.starred;
91
+ const targetUri = record['@id'] || record.id;
92
+ if (starred) {
93
+ // 标星 → 创建 Favorite
94
+ await createFavorite(ctx, config, record);
95
+ }
96
+ else {
97
+ // 取消标星 → 删除 Favorite
98
+ await deleteFavorite(ctx, targetUri);
99
+ }
100
+ },
101
+ };
102
+ }
103
+ // ============================================================================
104
+ // DB Instance Registry
105
+ // ============================================================================
106
+ let dbInstance = null;
107
+ /**
108
+ * 注册 db 实例(应用层启动时调用)
109
+ */
110
+ export function registerDbForStarredSync(db) {
111
+ dbInstance = db;
112
+ }
113
+ /**
114
+ * 获取 db 实例
115
+ */
116
+ function getDbInstance() {
117
+ return dbInstance;
118
+ }
119
+ // ============================================================================
120
+ // Pre-configured Extractors
121
+ // ============================================================================
122
+ /** Chat 快照提取器 */
123
+ export const chatSnapshotExtractor = {
124
+ getTitle: (r) => r.title || '未命名对话',
125
+ getContent: (r) => r.lastMessagePreview,
126
+ };
127
+ /** Thread 快照提取器 */
128
+ export const threadSnapshotExtractor = {
129
+ getTitle: (r) => r.title || '未命名话题',
130
+ };
131
+ /** Contact 快照提取器 */
132
+ export const contactSnapshotExtractor = {
133
+ getTitle: (r) => r.name || r.alias || '未命名联系人',
134
+ getContent: (r) => r.note,
135
+ };
136
+ // ============================================================================
137
+ // Pre-configured Hooks (using RDF type URIs)
138
+ // ============================================================================
139
+ /** Chat starred sync hook */
140
+ export const chatStarredSyncHook = createStarredSyncHook({
141
+ rdfType: MEETING.LongChat,
142
+ sourceModule: 'chat',
143
+ extractor: chatSnapshotExtractor,
144
+ });
145
+ /** Thread starred sync hook */
146
+ export const threadStarredSyncHook = createStarredSyncHook({
147
+ rdfType: SIOC.Thread,
148
+ sourceModule: 'thread',
149
+ extractor: threadSnapshotExtractor,
150
+ });
151
+ /** Contact starred sync hook */
152
+ export const contactStarredSyncHook = createStarredSyncHook({
153
+ rdfType: VCARD.Individual,
154
+ sourceModule: 'contacts',
155
+ extractor: contactSnapshotExtractor,
156
+ });
@@ -0,0 +1 @@
1
+ export * from './favorite/index.js';
@@ -0,0 +1 @@
1
+ export * from './favorite/index.js';
@@ -0,0 +1 @@
1
+ export { fileTable, type FileRow, type FileInsert, type FileUpdate, } from '../core.js';