@undefineds.co/xpod 0.4.11 → 0.4.13

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 (429) hide show
  1. package/config/components-ignore.json +5 -1
  2. package/config/notifications.json +68 -0
  3. package/config/xpod.base.json +9 -11
  4. package/dist/acceptance/QleverSemanticConformance.js +7 -0
  5. package/dist/ai/service/AiCredentialSecret.d.ts +30 -0
  6. package/dist/ai/service/AiCredentialSecret.js +120 -0
  7. package/dist/ai/service/CredentialReaderImpl.d.ts +18 -0
  8. package/dist/ai/service/CredentialReaderImpl.js +81 -5
  9. package/dist/ai/service/CredentialReaderImpl.jsonld +42 -2
  10. package/dist/ai/service/EmbeddingModelPolicy.d.ts +79 -0
  11. package/dist/ai/service/EmbeddingModelPolicy.js +134 -0
  12. package/dist/ai/service/EmbeddingProviderError.js +6 -0
  13. package/dist/ai/service/EmbeddingServiceImpl.d.ts +13 -1
  14. package/dist/ai/service/EmbeddingServiceImpl.js +18 -5
  15. package/dist/ai/service/EmbeddingServiceImpl.jsonld +35 -0
  16. package/dist/ai/service/index.d.ts +2 -0
  17. package/dist/ai/service/index.js +2 -0
  18. package/dist/api/ai-gateway/connect/index.d.ts +20 -2
  19. package/dist/api/ai-gateway/connect/index.js +162 -16
  20. package/dist/api/ai-gateway/credentials/AiCredentialSecretDecoder.d.ts +12 -0
  21. package/dist/api/ai-gateway/credentials/AiCredentialSecretDecoder.js +30 -0
  22. package/dist/api/ai-gateway/errors.d.ts +1 -1
  23. package/dist/api/ai-gateway/models/GatewayEmbeddingModelCatalog.d.ts +11 -0
  24. package/dist/api/ai-gateway/models/GatewayEmbeddingModelCatalog.js +31 -0
  25. package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +7 -3
  26. package/dist/api/ai-gateway/models/ProviderCustomModelsService.d.ts +18 -0
  27. package/dist/api/ai-gateway/models/ProviderCustomModelsService.js +23 -0
  28. package/dist/api/ai-gateway/models/ProviderModelDiscoveryAdapters.d.ts +3 -1
  29. package/dist/api/ai-gateway/models/ProviderModelDiscoveryAdapters.js +2 -45
  30. package/dist/api/ai-gateway/models/ProviderModelSelectionService.d.ts +10 -0
  31. package/dist/api/ai-gateway/models/ProviderModelSelectionService.js +57 -20
  32. package/dist/api/ai-gateway/models/ProviderModelType.d.ts +28 -0
  33. package/dist/api/ai-gateway/models/ProviderModelType.js +34 -0
  34. package/dist/api/ai-gateway/models/ProviderModelsAdapter.d.ts +10 -0
  35. package/dist/api/ai-gateway/models/ProviderModelsAdapter.js +3 -4
  36. package/dist/api/ai-gateway/models/index.d.ts +1 -0
  37. package/dist/api/ai-gateway/models/index.js +3 -1
  38. package/dist/api/ai-gateway/providers/CustomRuntimeAdapter.d.ts +7 -0
  39. package/dist/api/ai-gateway/providers/CustomRuntimeAdapter.js +9 -2
  40. package/dist/api/ai-gateway/providers/ModelsDevCatalog.d.ts +7 -1
  41. package/dist/api/ai-gateway/providers/ModelsDevCatalog.js +4 -10
  42. package/dist/api/ai-gateway/providers/OfferingAuthorization.d.ts +6 -1
  43. package/dist/api/ai-gateway/providers/OfferingAuthorization.js +0 -3
  44. package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +107 -0
  45. package/dist/api/ai-gateway/providers/ProviderRegistry.js +246 -23
  46. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +5 -0
  47. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +5 -1
  48. package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.d.ts +12 -4
  49. package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.js +11 -11
  50. package/dist/api/ai-gateway/routing/ModelRouter.d.ts +14 -0
  51. package/dist/api/ai-gateway/routing/ModelRouter.js +43 -4
  52. package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.d.ts +9 -1
  53. package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.js +3 -27
  54. package/dist/api/chatkit/pod-store.d.ts +31 -0
  55. package/dist/api/chatkit/pod-store.js +132 -8
  56. package/dist/api/container/common.js +24 -4
  57. package/dist/api/container/routes.js +17 -2
  58. package/dist/api/container/types.d.ts +3 -1
  59. package/dist/api/handlers/AdminHandler.d.ts +13 -0
  60. package/dist/api/handlers/AdminHandler.js +47 -18
  61. package/dist/api/handlers/AiConfigHandler.d.ts +6 -0
  62. package/dist/api/handlers/AiConfigHandler.js +28 -0
  63. package/dist/api/handlers/AiGatewayManagementHandler.js +36 -0
  64. package/dist/api/runs/RdfRunContextRetriever.d.ts +14 -0
  65. package/dist/api/runs/RdfRunContextRetriever.js +41 -5
  66. package/dist/api/runtime.js +2 -1
  67. package/dist/api/service/AiClientConfigurationService.d.ts +1 -1
  68. package/dist/api/service/AiClientConfigurationService.js +1 -1
  69. package/dist/cli/commands/secret.d.ts +1 -0
  70. package/dist/cli/commands/secret.js +25 -7
  71. package/dist/components/components.jsonld +3 -1
  72. package/dist/components/context.jsonld +53 -1
  73. package/dist/http/SubgraphSparqlHttpHandler.d.ts +59 -2
  74. package/dist/http/SubgraphSparqlHttpHandler.js +145 -13
  75. package/dist/http/SubgraphSparqlHttpHandler.jsonld +37 -0
  76. package/dist/identity/drizzle/EdgeNodeRepository.d.ts +0 -12
  77. package/dist/identity/drizzle/EdgeNodeRepository.js +5 -13
  78. package/dist/index.d.ts +2 -1
  79. package/dist/index.js +7 -3
  80. package/dist/logging/log-file.d.ts +17 -0
  81. package/dist/logging/log-file.js +69 -0
  82. package/dist/main.js +2 -1
  83. package/dist/notifications/NotificationChannelSweeper.d.ts +50 -0
  84. package/dist/notifications/NotificationChannelSweeper.js +131 -0
  85. package/dist/notifications/NotificationChannelSweeper.jsonld +136 -0
  86. package/dist/notifications/ReclaimingWebSocket2023Storer.d.ts +25 -0
  87. package/dist/notifications/ReclaimingWebSocket2023Storer.js +56 -0
  88. package/dist/notifications/ReclaimingWebSocket2023Storer.jsonld +77 -0
  89. package/dist/notifications/index.d.ts +2 -0
  90. package/dist/notifications/index.js +2 -0
  91. package/dist/runtime/Proxy.d.ts +37 -0
  92. package/dist/runtime/Proxy.js +88 -16
  93. package/dist/runtime/bootstrap.js +2 -1
  94. package/dist/runtime/upgrade/BunNativeUpgradeRelay.d.ts +116 -0
  95. package/dist/runtime/upgrade/BunNativeUpgradeRelay.js +423 -0
  96. package/dist/runtime/upgrade/UpgradeHandshake.d.ts +63 -0
  97. package/dist/runtime/upgrade/UpgradeHandshake.js +199 -0
  98. package/dist/runtime/upgrade/WebSocketFrames.d.ts +67 -0
  99. package/dist/runtime/upgrade/WebSocketFrames.js +224 -0
  100. package/dist/storage/rdf/PostgresRdfEngine.js +10 -4
  101. package/dist/storage/rdf/RdfAccessScope.js +15 -1
  102. package/dist/storage/rdf/RdfEngineRdfJsSource.js +10 -2
  103. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.d.ts +1 -1
  104. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +9 -2
  105. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.d.ts +12 -3
  106. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.js +27 -10
  107. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +7 -0
  108. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +15 -13
  109. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.d.ts +1 -1
  110. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.js +1 -1
  111. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsList.js +10 -6
  112. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.d.ts +15 -0
  113. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.js +29 -3
  114. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMainHeader.js +18 -3
  115. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +17 -2
  116. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +94 -22
  117. package/node_modules/@undefineds.co/ai-connections/dist/AiCopyButton.d.ts +35 -0
  118. package/node_modules/@undefineds.co/ai-connections/dist/AiCopyButton.js +45 -0
  119. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.d.ts +1 -1
  120. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +71 -11
  121. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.d.ts +1 -1
  122. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.js +9 -7
  123. package/node_modules/@undefineds.co/ai-connections/dist/AiCustomProviderDialog.d.ts +1 -1
  124. package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.d.ts +23 -0
  125. package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.js +24 -0
  126. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeyRow.d.ts +1 -1
  127. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +14 -5
  128. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +35 -38
  129. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.d.ts +21 -0
  130. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.js +51 -0
  131. package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.d.ts +15 -0
  132. package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.js +16 -0
  133. package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.d.ts +175 -0
  134. package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.js +133 -0
  135. package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.d.ts +1 -1
  136. package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.js +2 -2
  137. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.d.ts +1 -1
  138. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +13 -64
  139. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.d.ts +21 -0
  140. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.js +12 -0
  141. package/node_modules/@undefineds.co/ai-connections/dist/AiQuotaCard.d.ts +1 -1
  142. package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.d.ts +15 -0
  143. package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.js +12 -0
  144. package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.d.ts +1 -1
  145. package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.js +2 -1
  146. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.d.ts +39 -6
  147. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.js +57 -11
  148. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.d.ts +46 -0
  149. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +231 -0
  150. package/node_modules/@undefineds.co/ai-connections/dist/collections.d.ts +119 -0
  151. package/node_modules/@undefineds.co/ai-connections/dist/collections.js +173 -0
  152. package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +71 -5
  153. package/node_modules/@undefineds.co/ai-connections/dist/controller.js +288 -18
  154. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.d.ts +6 -1
  155. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.js +8 -3
  156. package/node_modules/@undefineds.co/ai-connections/dist/display-wording.d.ts +20 -0
  157. package/node_modules/@undefineds.co/ai-connections/dist/display-wording.js +73 -0
  158. package/node_modules/@undefineds.co/ai-connections/dist/error-wording.d.ts +24 -0
  159. package/node_modules/@undefineds.co/ai-connections/dist/error-wording.js +253 -0
  160. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.d.ts +14 -0
  161. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.js +20 -0
  162. package/node_modules/@undefineds.co/ai-connections/dist/index.d.ts +8 -1
  163. package/node_modules/@undefineds.co/ai-connections/dist/index.js +8 -1
  164. package/node_modules/@undefineds.co/ai-connections/dist/manifest.js +1 -1
  165. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.d.ts +15 -1
  166. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.js +17 -0
  167. package/node_modules/@undefineds.co/ai-connections/dist/offering-label.d.ts +1 -1
  168. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.d.ts +6 -1
  169. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.js +5 -0
  170. package/node_modules/@undefineds.co/ai-connections/dist/service-access.js +2 -27
  171. package/node_modules/@undefineds.co/ai-connections/dist/useAiConnectDialog.d.ts +1 -1
  172. package/node_modules/@undefineds.co/ai-connections/package.json +2 -24
  173. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/ai-connections-client.d.ts +12 -3
  174. package/node_modules/@undefineds.co/ai-connections-core/dist/ai-connections-client.js +21 -0
  175. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/normalize.d.ts +17 -7
  176. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/normalize.js +48 -216
  177. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/request.js +3 -3
  178. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/types.d.ts +31 -2
  179. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/base-adapter.d.ts +1 -3
  180. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/base-adapter.js +3 -7
  181. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/index.cjs +9 -7
  182. package/node_modules/@undefineds.co/ai-connections-core/dist/credential-storage.d.ts +59 -0
  183. package/node_modules/@undefineds.co/ai-connections-core/dist/credential-storage.js +131 -0
  184. package/node_modules/@undefineds.co/ai-connections-core/dist/endpoint-urls.d.ts +15 -0
  185. package/node_modules/@undefineds.co/ai-connections-core/dist/endpoint-urls.js +20 -0
  186. package/node_modules/@undefineds.co/ai-connections-core/dist/index.d.ts +9 -0
  187. package/node_modules/@undefineds.co/ai-connections-core/dist/index.js +9 -0
  188. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/provider-catalog.cjs +68 -24
  189. package/node_modules/@undefineds.co/ai-connections-core/dist/provider-catalog.d.ts +84 -0
  190. package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/provider-catalog.js +121 -22
  191. package/node_modules/@undefineds.co/ai-connections-core/package.json +61 -0
  192. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +1 -1
  193. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +2 -0
  194. package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +150 -0
  195. package/node_modules/@undefineds.co/extension-sdk/package.json +2 -1
  196. package/node_modules/@undefineds.co/models/README.md +1 -1
  197. package/node_modules/@undefineds.co/models/dist/ai-config/index.d.ts +3 -3
  198. package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.d.ts +5 -0
  199. package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.js +9 -0
  200. package/node_modules/@undefineds.co/models/dist/ai-runtime.repository.d.ts +1 -1
  201. package/node_modules/@undefineds.co/models/dist/approval.repository.d.ts +2 -2
  202. package/node_modules/@undefineds.co/models/dist/audit.presentation.d.ts +2 -2
  203. package/node_modules/@undefineds.co/models/dist/capture.repository.d.ts +1 -1
  204. package/node_modules/@undefineds.co/models/dist/chat-project.repository.d.ts +1 -1
  205. package/node_modules/@undefineds.co/models/dist/chat.repository.d.ts +2 -2
  206. package/node_modules/@undefineds.co/models/dist/control-request.repository.d.ts +2 -2
  207. package/node_modules/@undefineds.co/models/dist/conversation-share.repository.d.ts +1 -1
  208. package/node_modules/@undefineds.co/models/dist/credential.schema.d.ts +12 -0
  209. package/node_modules/@undefineds.co/models/dist/credential.schema.js +15 -1
  210. package/node_modules/@undefineds.co/models/dist/discovery/index.d.ts +2 -2
  211. package/node_modules/@undefineds.co/models/dist/discovery/providers.json +248 -7
  212. package/node_modules/@undefineds.co/models/dist/discovery/types.d.ts +31 -0
  213. package/node_modules/@undefineds.co/models/dist/extension/index.d.ts +1 -1
  214. package/node_modules/@undefineds.co/models/dist/favorite/index.d.ts +2 -2
  215. package/node_modules/@undefineds.co/models/dist/fixtures/contracts-chat-contact.d.ts +5 -5
  216. package/node_modules/@undefineds.co/models/dist/import/index.d.ts +1 -1
  217. package/node_modules/@undefineds.co/models/dist/index.d.ts +73 -73
  218. package/node_modules/@undefineds.co/models/dist/index.js +1 -1
  219. package/node_modules/@undefineds.co/models/dist/input-request.repository.d.ts +2 -2
  220. package/node_modules/@undefineds.co/models/dist/knowledge/index.d.ts +1 -1
  221. package/node_modules/@undefineds.co/models/dist/message.repository.d.ts +1 -1
  222. package/node_modules/@undefineds.co/models/dist/namespaces.js +5 -0
  223. package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.d.ts +4815 -26
  224. package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.js +482 -132
  225. package/node_modules/@undefineds.co/models/dist/schema.d.ts +4 -0
  226. package/node_modules/@undefineds.co/models/dist/session/index.d.ts +1 -1
  227. package/node_modules/@undefineds.co/models/dist/settings/index.d.ts +1 -1
  228. package/node_modules/@undefineds.co/models/dist/sidecar/persistence-mapping.d.ts +5 -5
  229. package/node_modules/@undefineds.co/models/dist/thread.repository.d.ts +2 -2
  230. package/node_modules/@undefineds.co/models/dist/types/message-block.d.ts +1 -1
  231. package/node_modules/@undefineds.co/models/dist/vocab/_namespaces.d.ts +1 -1
  232. package/node_modules/@undefineds.co/models/dist/vocab/index.d.ts +10 -10
  233. package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.d.ts +1 -0
  234. package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.js +1 -0
  235. package/node_modules/@undefineds.co/models/package.json +4 -2
  236. package/node_modules/@undefineds.co/pod-collections/README.md +71 -0
  237. package/node_modules/@undefineds.co/pod-collections/dist/diff.d.ts +85 -0
  238. package/node_modules/@undefineds.co/pod-collections/dist/diff.js +166 -0
  239. package/node_modules/@undefineds.co/pod-collections/dist/feed.d.ts +17 -0
  240. package/node_modules/@undefineds.co/pod-collections/dist/feed.js +27 -0
  241. package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +1042 -0
  242. package/node_modules/@undefineds.co/pod-collections/dist/index.d.ts +37 -0
  243. package/node_modules/@undefineds.co/pod-collections/dist/index.js +89 -0
  244. package/node_modules/@undefineds.co/pod-collections/dist/layout.d.ts +75 -0
  245. package/node_modules/@undefineds.co/pod-collections/dist/layout.js +173 -0
  246. package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +78 -0
  247. package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +287 -0
  248. package/node_modules/@undefineds.co/pod-collections/dist/mutations.d.ts +83 -0
  249. package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +273 -0
  250. package/node_modules/@undefineds.co/pod-collections/dist/react.d.ts +21 -0
  251. package/node_modules/@undefineds.co/pod-collections/dist/react.js +22 -0
  252. package/node_modules/@undefineds.co/pod-collections/dist/read.d.ts +65 -0
  253. package/node_modules/@undefineds.co/pod-collections/dist/read.js +31 -0
  254. package/node_modules/@undefineds.co/pod-collections/dist/sync.d.ts +66 -0
  255. package/node_modules/@undefineds.co/pod-collections/dist/sync.js +260 -0
  256. package/node_modules/@undefineds.co/pod-collections/dist/types.d.ts +155 -0
  257. package/node_modules/@undefineds.co/pod-collections/dist/types.js +9 -0
  258. package/node_modules/@undefineds.co/pod-collections/package.json +42 -0
  259. package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +4 -2
  260. package/node_modules/@undefineds.co/shared-ui/dist/index.js +4 -2
  261. package/node_modules/@undefineds.co/shared-ui/dist/login/LoginModal.d.ts +4 -1
  262. package/node_modules/@undefineds.co/shared-ui/dist/login/LoginModal.js +12 -6
  263. package/node_modules/@undefineds.co/shared-ui/dist/login/LoginView.d.ts +1 -1
  264. package/node_modules/@undefineds.co/shared-ui/dist/login/host-types.d.ts +7 -1
  265. package/node_modules/@undefineds.co/shared-ui/dist/login/login-branding.d.ts +6 -0
  266. package/node_modules/@undefineds.co/shared-ui/dist/login/login-branding.js +18 -0
  267. package/node_modules/@undefineds.co/shared-ui/dist/user-facing-errors.d.ts +14 -2
  268. package/node_modules/@undefineds.co/shared-ui/dist/user-facing-errors.js +26 -17
  269. package/node_modules/@undefineds.co/solid-sdk/dist/login-store.d.ts +3 -3
  270. package/node_modules/@undefineds.co/solid-sdk/dist/login-store.js +3 -3
  271. package/package.json +17 -7
  272. package/static/app/assets/main.css +1 -1
  273. package/static/auth-callback/assets/AiConfigContext-DlFyEWy9.js +1 -0
  274. package/static/auth-callback/assets/AiConfigPage-CkYk-SFW.js +1 -0
  275. package/static/auth-callback/assets/DocumentProcessingPanel-CqIr3JqN.js +1 -0
  276. package/static/auth-callback/assets/IndexLifecyclePanel-C1GKV3Vx.js +1 -0
  277. package/static/auth-callback/assets/{IndexSubjectPanel-BbUqop4b.js → IndexSubjectPanel-ro9lC6XW.js} +1 -1
  278. package/static/auth-callback/assets/ModelAssignmentsPanel-DxNdyKRJ.js +1 -0
  279. package/static/auth-callback/assets/ModelsPage-BVtWSPBU.js +11 -0
  280. package/static/auth-callback/assets/{NetworkPage-Vp2PrMxs.js → NetworkPage-cEvxRMAl.js} +2 -2
  281. package/static/auth-callback/assets/{PaneListHeader-DY7baSFl.js → PaneListHeader-ByKw8ada.js} +1 -1
  282. package/static/auth-callback/assets/SearchIndexingPanel-CulBKcYT.js +1 -0
  283. package/static/auth-callback/assets/{StatusSubjectPanel-ArIS-TxT.js → StatusSubjectPanel-VOcfrt8o.js} +1 -1
  284. package/static/{settings/assets/StatusWorkspace-CoMFRXoV.js → auth-callback/assets/StatusWorkspace-Jsz6hAdE.js} +1 -1
  285. package/static/auth-callback/assets/{SystemSettingsPage-BDvT1NUz.js → SystemSettingsPage-BFNvGAle.js} +1 -1
  286. package/static/{dashboard/assets/SystemSettingsSubjectPanel-WaE8mTQi.js → auth-callback/assets/SystemSettingsSubjectPanel-DFRdrSfK.js} +5 -5
  287. package/static/auth-callback/assets/XpodAiConnectionsPodStore-C6KpvHVg.js +3 -0
  288. package/static/auth-callback/assets/{activity-D1Dsfa_0.js → activity-DnTlb9iM.js} +1 -1
  289. package/static/auth-callback/assets/ai-connections-C6yaE6WQ.js +1 -0
  290. package/static/auth-callback/assets/auth-callback-Cx9D_1qj.css +1 -0
  291. package/static/auth-callback/assets/{auth-callback-Cmf4hXVZ.js → auth-callback-D2UkK5Xj.js} +6 -6
  292. package/static/auth-callback/assets/{badge-CZsHq3Ih.js → badge-D7IJuuTM.js} +1 -1
  293. package/static/auth-callback/assets/collection-runtime-wT1n4GS2.js +1 -0
  294. package/static/auth-callback/assets/dialog-DickLu5z.js +1 -0
  295. package/static/auth-callback/assets/{download-DU9ntlHw.js → download-kn8WnRu3.js} +1 -1
  296. package/static/auth-callback/assets/{external-link-BfzaaZDx.js → external-link-B6B8jfSn.js} +1 -1
  297. package/static/auth-callback/assets/index-Cu0EguPo.js +4 -0
  298. package/static/auth-callback/assets/index-DHF97YLP.js +41 -0
  299. package/static/auth-callback/assets/index-Dz83EEHD.js +1 -0
  300. package/static/auth-callback/assets/{index-browser-BNFqqC74.js → index-browser-CSghinyi.js} +1 -1
  301. package/static/auth-callback/assets/{key-round-BwP3DBWo.js → key-round-ChkOx3E1.js} +1 -1
  302. package/static/auth-callback/assets/layout-DB3pMyTl.js +1 -0
  303. package/static/auth-callback/assets/pod-collections-host-KnnGFZHL.js +8 -0
  304. package/static/auth-callback/assets/{rotate-ccw-VMwnmyab.js → rotate-ccw-B3hE-nyd.js} +1 -1
  305. package/static/auth-callback/assets/{skeleton-CoD55rBT.js → skeleton-kEqR7tpI.js} +1 -1
  306. package/static/auth-callback/assets/{waypoints-DRo_1Ca7.js → waypoints-D6Jo-SZa.js} +1 -1
  307. package/static/auth-callback/assets/{workspace-layout--mcXl3My.js → workspace-layout-BHwT_cHd.js} +1 -1
  308. package/static/auth-callback/auth-callback.html +2 -2
  309. package/static/dashboard/assets/AiConfigContext-BfC3v-x2.js +1 -0
  310. package/static/dashboard/assets/AiConfigPage-QNS3u7Ff.js +1 -0
  311. package/static/dashboard/assets/DocumentProcessingPanel-Dr4XLeT4.js +1 -0
  312. package/static/dashboard/assets/IndexLifecyclePanel-KtM_gpeO.js +1 -0
  313. package/static/dashboard/assets/{IndexSubjectPanel-B2cXwl8X.js → IndexSubjectPanel-DLaiKdLc.js} +1 -1
  314. package/static/dashboard/assets/ModelAssignmentsPanel-Bk7TvQRq.js +1 -0
  315. package/static/dashboard/assets/ModelsPage-Cci3vlos.js +11 -0
  316. package/static/dashboard/assets/{NetworkPage-DV2V0qWO.js → NetworkPage-Ot4G2dX5.js} +2 -2
  317. package/static/dashboard/assets/{PaneListHeader-D0c1yCFH.js → PaneListHeader-qHME_s08.js} +1 -1
  318. package/static/dashboard/assets/SearchIndexingPanel-HZPKj8H9.js +1 -0
  319. package/static/dashboard/assets/{StatusSubjectPanel-oPSECj7i.js → StatusSubjectPanel-ij7IpI8d.js} +1 -1
  320. package/static/dashboard/assets/{StatusWorkspace-PdovQPKa.js → StatusWorkspace-Cp02JcaN.js} +1 -1
  321. package/static/dashboard/assets/{SystemSettingsPage-CtNDklkx.js → SystemSettingsPage-BSeuvb8X.js} +1 -1
  322. package/static/{settings/assets/SystemSettingsSubjectPanel-DExjDo_v.js → dashboard/assets/SystemSettingsSubjectPanel-CP4_luGS.js} +5 -5
  323. package/static/dashboard/assets/XpodAiConnectionsPodStore-urO6zaHL.js +18 -0
  324. package/static/dashboard/assets/{activity-B9ylSoyr.js → activity-DxjgQNvr.js} +1 -1
  325. package/static/dashboard/assets/ai-connections-CXp5gd1J.js +1 -0
  326. package/static/dashboard/assets/{badge-BNbFbpIb.js → badge-53qCrRbl.js} +1 -1
  327. package/static/dashboard/assets/collection-runtime-BPAmHG46.js +1 -0
  328. package/static/dashboard/assets/{dashboard-CD-FFVRD.js → dashboard-BcT2ByXw.js} +4 -4
  329. package/static/dashboard/assets/dashboard-Cx9D_1qj.css +1 -0
  330. package/static/dashboard/assets/dialog-B28YtNhS.js +1 -0
  331. package/static/dashboard/assets/{download-nOP38LtW.js → download-DkLNceJ4.js} +1 -1
  332. package/static/dashboard/assets/{external-link-Bh2ewN9E.js → external-link-D3TXnlo3.js} +1 -1
  333. package/static/dashboard/assets/index-CFIenkeK.js +41 -0
  334. package/static/dashboard/assets/index-CIiBu9mr.js +1 -0
  335. package/static/dashboard/assets/index-Gp3cLolR.js +4 -0
  336. package/static/dashboard/assets/{key-round-bGmguBLv.js → key-round-B5ccp6nx.js} +1 -1
  337. package/static/dashboard/assets/layout-DB3pMyTl.js +1 -0
  338. package/static/dashboard/assets/pod-collections-host-KnnGFZHL.js +8 -0
  339. package/static/dashboard/assets/{rotate-ccw-D2x__ODW.js → rotate-ccw-DUpfkNnk.js} +1 -1
  340. package/static/dashboard/assets/{skeleton-VOqft8WS.js → skeleton-BRe19fO0.js} +1 -1
  341. package/static/dashboard/assets/{waypoints-fgRqm4oH.js → waypoints-BKDMxEvu.js} +1 -1
  342. package/static/dashboard/assets/{workspace-layout-DV4dgeHX.js → workspace-layout-ZTF7C16h.js} +1 -1
  343. package/static/dashboard/dashboard.html +2 -2
  344. package/static/settings/assets/AiConfigContext-DsyWgu2i.js +1 -0
  345. package/static/settings/assets/AiConfigPage-CSCBckKo.js +1 -0
  346. package/static/settings/assets/DocumentProcessingPanel-w9yQDbBe.js +1 -0
  347. package/static/settings/assets/IndexLifecyclePanel-CUUXI8mP.js +1 -0
  348. package/static/settings/assets/{IndexSubjectPanel-BgbI9c-a.js → IndexSubjectPanel-BypAU5TJ.js} +1 -1
  349. package/static/settings/assets/ModelAssignmentsPanel-BetgXw1G.js +1 -0
  350. package/static/settings/assets/ModelsPage-DZpTlTZ3.js +11 -0
  351. package/static/settings/assets/{NetworkPage-C8OA9Mtp.js → NetworkPage-BVkasFGM.js} +2 -2
  352. package/static/settings/assets/{PaneListHeader-COvlPJWj.js → PaneListHeader-BGOqGec4.js} +1 -1
  353. package/static/settings/assets/SearchIndexingPanel-DYAbpZ_9.js +1 -0
  354. package/static/settings/assets/{StatusSubjectPanel-BuLml7qn.js → StatusSubjectPanel-CFgzeQ8Q.js} +1 -1
  355. package/static/settings/assets/StatusWorkspace-4Z6g4Jvv.js +1 -0
  356. package/static/settings/assets/{SystemSettingsPage-DlzmaWV-.js → SystemSettingsPage-C1tlrgvI.js} +1 -1
  357. package/static/{auth-callback/assets/SystemSettingsSubjectPanel-CDqRuC4t.js → settings/assets/SystemSettingsSubjectPanel-CcURI-1L.js} +5 -5
  358. package/static/settings/assets/XpodAiConnectionsPodStore-owBQc5nY.js +3 -0
  359. package/static/settings/assets/{activity-TLerXgMs.js → activity-CtBc9cNy.js} +1 -1
  360. package/static/settings/assets/ai-connections-C6yaE6WQ.js +1 -0
  361. package/static/settings/assets/{badge-Bcs8iWrH.js → badge--r-FDIhU.js} +1 -1
  362. package/static/settings/assets/collection-runtime-CnhPmwAM.js +1 -0
  363. package/static/settings/assets/dialog-B7ZRsjN7.js +1 -0
  364. package/static/settings/assets/{download-Ct3QmHPt.js → download-DgQ1F8QR.js} +1 -1
  365. package/static/settings/assets/{external-link-C8KiHbss.js → external-link-Bz7NckNO.js} +1 -1
  366. package/static/settings/assets/index-BdXwm8nh.js +4 -0
  367. package/static/settings/assets/index-CkGda_Pg.js +41 -0
  368. package/static/settings/assets/index-Vv-8Vslg.js +1 -0
  369. package/static/settings/assets/{index-browser-CazX1pc2.js → index-browser-Dq7omlpY.js} +1 -1
  370. package/static/settings/assets/{key-round-B19YD1GA.js → key-round-CvuhloKV.js} +1 -1
  371. package/static/settings/assets/layout-DB3pMyTl.js +1 -0
  372. package/static/settings/assets/pod-collections-host-KnnGFZHL.js +8 -0
  373. package/static/settings/assets/{rotate-ccw-AQm2kMgU.js → rotate-ccw-DgFKDaz7.js} +1 -1
  374. package/static/settings/assets/{settings-C-VBtt9r.js → settings-BvqY7K96.js} +5 -5
  375. package/static/settings/assets/settings-Cx9D_1qj.css +1 -0
  376. package/static/settings/assets/{skeleton-DyZ1OBYf.js → skeleton-D3OeFDF6.js} +1 -1
  377. package/static/settings/assets/{waypoints-CC3wq-SU.js → waypoints-C4WbspTb.js} +1 -1
  378. package/static/settings/assets/{workspace-layout-BxXNKgf9.js → workspace-layout-B9H1Tqrk.js} +1 -1
  379. package/static/settings/settings.html +2 -2
  380. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.js +0 -13
  381. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.d.ts +0 -9
  382. package/static/auth-callback/assets/AiConfigContext-DqWRSm7n.js +0 -1
  383. package/static/auth-callback/assets/AiConfigPage-C5YYyvzl.js +0 -1
  384. package/static/auth-callback/assets/DocumentProcessingPanel-DZCiacBz.js +0 -1
  385. package/static/auth-callback/assets/IndexLifecyclePanel-CCLeOljB.js +0 -1
  386. package/static/auth-callback/assets/ModelAssignmentsPanel-jUUTDKuh.js +0 -1
  387. package/static/auth-callback/assets/ModelsPage-B08zdtff.js +0 -10
  388. package/static/auth-callback/assets/SearchIndexingPanel-D4YRg1-8.js +0 -1
  389. package/static/auth-callback/assets/StatusWorkspace-Cp5LQ9Yx.js +0 -1
  390. package/static/auth-callback/assets/ai-connections-CHNTKemd.js +0 -1
  391. package/static/auth-callback/assets/auth-callback-DWMMiFjh.css +0 -1
  392. package/static/auth-callback/assets/index-DSNnLUbU.js +0 -4
  393. package/static/auth-callback/assets/index-FHhHoKgp.js +0 -41
  394. package/static/dashboard/assets/AiConfigContext-BpPDKSzI.js +0 -1
  395. package/static/dashboard/assets/AiConfigPage-wsqEZDIX.js +0 -1
  396. package/static/dashboard/assets/DocumentProcessingPanel-CDSy3juc.js +0 -1
  397. package/static/dashboard/assets/IndexLifecyclePanel-CVd6vQCX.js +0 -1
  398. package/static/dashboard/assets/ModelAssignmentsPanel-BeBZhnQd.js +0 -1
  399. package/static/dashboard/assets/ModelsPage-B6McSCJw.js +0 -25
  400. package/static/dashboard/assets/SearchIndexingPanel-CGs0OZ12.js +0 -1
  401. package/static/dashboard/assets/ai-connections-CHNTKemd.js +0 -1
  402. package/static/dashboard/assets/dashboard-DWMMiFjh.css +0 -1
  403. package/static/dashboard/assets/index-PgS-Bt7X.js +0 -41
  404. package/static/dashboard/assets/index-QN2QgEwr.js +0 -4
  405. package/static/settings/assets/AiConfigContext-zKQYdfai.js +0 -1
  406. package/static/settings/assets/AiConfigPage-Bs1EE3Ei.js +0 -1
  407. package/static/settings/assets/DocumentProcessingPanel-CSFfdOXS.js +0 -1
  408. package/static/settings/assets/IndexLifecyclePanel-BR9Su49B.js +0 -1
  409. package/static/settings/assets/ModelAssignmentsPanel-C0BE7nbk.js +0 -1
  410. package/static/settings/assets/ModelsPage-CU-YQ8_7.js +0 -10
  411. package/static/settings/assets/SearchIndexingPanel-Bdd46mIV.js +0 -1
  412. package/static/settings/assets/ai-connections-CHNTKemd.js +0 -1
  413. package/static/settings/assets/index-1Q2cRjZd.js +0 -41
  414. package/static/settings/assets/index-DBO_Vq0P.js +0 -4
  415. package/static/settings/assets/settings-DWMMiFjh.css +0 -1
  416. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/request.d.ts +0 -0
  417. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client/types.js +0 -0
  418. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/codex.d.ts +0 -0
  419. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/codex.js +0 -0
  420. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/index.d.ts +0 -0
  421. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/index.js +0 -0
  422. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/json-env-adapter.d.ts +0 -0
  423. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/json-env-adapter.js +0 -0
  424. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/pi.d.ts +0 -0
  425. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/pi.js +0 -0
  426. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/transaction.d.ts +0 -0
  427. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/transaction.js +0 -0
  428. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/types.d.ts +0 -0
  429. /package/node_modules/@undefineds.co/{ai-connections → ai-connections-core}/dist/client-config/types.js +0 -0
@@ -0,0 +1,131 @@
1
+ import { aiProviderResource } from '@undefineds.co/models';
2
+ import { AI_CONNECTIONS_PROVIDERS } from './client/types.js';
3
+ /**
4
+ * Storage-shape rules for AI credential rows: the secret envelope, the provider
5
+ * relation a credential declares, and the provider resource key.
6
+ *
7
+ * They live in the capability package, not in the Pod adapter that happens to
8
+ * use them: `@undefineds.co/ai-connections` owns what a credential row looks
9
+ * like, and `ui/src/extensions/XpodAiConnectionsPodStore.ts` is one adapter over
10
+ * it. Keeping one copy is what lets the collection layer write the same rows the
11
+ * adapter reads - a second copy would drift on the first format change.
12
+ */
13
+ /** Base64 of the UTF-8 JSON, so the envelope stays a single string literal. */
14
+ function encodeBase64Json(value) {
15
+ const bytes = new TextEncoder().encode(JSON.stringify(value));
16
+ let binary = '';
17
+ for (const byte of bytes)
18
+ binary += String.fromCharCode(byte);
19
+ return btoa(binary);
20
+ }
21
+ function decodeBase64Json(value) {
22
+ const binary = atob(value);
23
+ const bytes = Uint8Array.from(binary, (character) => character.charCodeAt(0));
24
+ return JSON.parse(new TextDecoder().decode(bytes));
25
+ }
26
+ /**
27
+ * The `encryptedSecret` payload for a credential row.
28
+ *
29
+ * `PLAINTEXT` means "not encrypted at rest yet", not "no envelope": the read
30
+ * side verifies the envelope's owner (`webId`), provider and credential IRI
31
+ * before handing the secret to a provider request, so a row copied between
32
+ * credentials (or between accounts) never yields a usable secret.
33
+ */
34
+ export function credentialSecretEnvelope(input) {
35
+ return JSON.stringify({
36
+ algorithm: 'PLAINTEXT',
37
+ encoding: 'base64',
38
+ ciphertext: encodeBase64Json(input.secret),
39
+ webId: input.webId,
40
+ credentialIri: input.credentialIri,
41
+ provider: input.provider,
42
+ });
43
+ }
44
+ /** `undefined` unless the envelope belongs to this account, provider and credential. */
45
+ export function decodeCredentialSecret(input) {
46
+ if (typeof input.envelope !== 'string' || !input.envelope.trim())
47
+ return undefined;
48
+ try {
49
+ const envelope = JSON.parse(input.envelope);
50
+ if (envelope.algorithm !== 'PLAINTEXT'
51
+ || envelope.webId !== input.webId
52
+ || envelope.provider !== input.provider
53
+ || envelope.credentialIri !== input.credentialIri) {
54
+ return undefined;
55
+ }
56
+ const secret = envelope.encoding === 'base64'
57
+ ? decodeBase64Json(String(envelope.ciphertext))
58
+ : JSON.parse(String(envelope.ciphertext));
59
+ return typeof secret === 'object' && secret !== null && !Array.isArray(secret)
60
+ ? secret
61
+ : undefined;
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ }
67
+ /**
68
+ * The provider relation a catalog credential declares (`provider`):
69
+ * `providers/openai.ttl` in resource terms, `openai.ttl` as the stored value.
70
+ *
71
+ * A custom instance owns its own provider document, so there the relation is
72
+ * derived from the credential's own id.
73
+ */
74
+ export function credentialProviderRelation(provider) {
75
+ return aiProviderResource.buildId({ id: provider });
76
+ }
77
+ export function customCredentialProviderRelation(credentialId) {
78
+ return aiProviderResource.buildId({ id: `custom-instance-${encodeURIComponent(credentialId)}.ttl#this` });
79
+ }
80
+ /**
81
+ * The row key of a new credential: the `{id}` slot of the descriptor's
82
+ * `resourceIdPattern`, which is the credential's identity (never a display
83
+ * name).
84
+ *
85
+ * Two writers create credential rows - `XpodAiConnectionsPodStore` for a plain
86
+ * page, and the collection layer when a live collection creates the row
87
+ * optimistically - and a row key that differed between them would produce two
88
+ * credentials where the user asked for one, so the shape is declared once here.
89
+ */
90
+ export function credentialRowKeyFor(provider, authMode) {
91
+ const suffix = crypto.randomUUID();
92
+ return authMode === 'local' ? `${provider}-local-${suffix}` : `${provider}-${suffix}`;
93
+ }
94
+ /**
95
+ * The provider a credential row key declares, for rows whose `provider` relation
96
+ * is missing: a credential is keyed `<provider>-<uuid>` (see
97
+ * {@link credentialRowKeyFor}), and a custom instance is keyed `custom-…`.
98
+ *
99
+ * A key reaches us in either of two shapes - the bare `resourceIdPattern` slot
100
+ * (`openai-<uuid>`) or a full resource id (`custom-instance-abc.ttl#this`). The
101
+ * provider lives in the document segment in both, never in the fragment, so the
102
+ * fragment must not be the part that gets inspected.
103
+ */
104
+ export function providerOfCredentialKey(key) {
105
+ const document = (key.split('#', 1)[0] ?? key).split('/').filter(Boolean).at(-1) ?? '';
106
+ const name = document.endsWith('.ttl') ? document.slice(0, -'.ttl'.length) : document;
107
+ if (!name)
108
+ return undefined;
109
+ if (name.startsWith('custom-') || name === 'custom')
110
+ return 'custom';
111
+ return AI_CONNECTIONS_PROVIDERS.find((provider) => name === provider || name.startsWith(`${provider}-`));
112
+ }
113
+ /** `providers/openai.ttl#this` → `openai.ttl#this` (document-relative reference). */
114
+ export function providerResourceReference(value) {
115
+ if (!value)
116
+ return undefined;
117
+ const withoutFragment = value.split('#', 1)[0] ?? value;
118
+ const fileName = withoutFragment.split('/').filter(Boolean).at(-1) ?? withoutFragment;
119
+ if (!fileName)
120
+ return undefined;
121
+ const document = fileName.endsWith('.ttl') ? fileName : `${fileName}.ttl`;
122
+ const fragmentIndex = value.indexOf('#');
123
+ return fragmentIndex < 0 ? document : `${document}${value.slice(fragmentIndex)}`;
124
+ }
125
+ /** `providers/openai.ttl#this` → `openai` (the document name minus `.ttl`). */
126
+ export function providerResourceKey(value) {
127
+ const reference = providerResourceReference(value);
128
+ if (!reference)
129
+ return undefined;
130
+ return (reference.split('#', 1)[0] ?? reference).replace(/\.ttl$/u, '');
131
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The endpoint shape rules every consumer shares: the coding-client adapters
3
+ * (`client-config/base-adapter.ts`) and the UI both point clients at the same
4
+ * Xpod base URL, so the `/v1` rule lives here once and nowhere else.
5
+ *
6
+ * This module must stay dependency-free: it is bundled into the Web applet and
7
+ * imported by the Node-side configuration service.
8
+ */
9
+ /** OpenAI-compatible base: the client appends `/chat/completions` or `/responses` itself. */
10
+ export declare function normalizeV1Endpoint(endpoint: string): string;
11
+ /**
12
+ * Anthropic base: `ANTHROPIC_BASE_URL` is the host; the client appends
13
+ * `/v1/messages`, so a trailing `/v1` has to come off rather than stay on.
14
+ */
15
+ export declare function normalizeMessagesEndpoint(endpoint: string): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The endpoint shape rules every consumer shares: the coding-client adapters
3
+ * (`client-config/base-adapter.ts`) and the UI both point clients at the same
4
+ * Xpod base URL, so the `/v1` rule lives here once and nowhere else.
5
+ *
6
+ * This module must stay dependency-free: it is bundled into the Web applet and
7
+ * imported by the Node-side configuration service.
8
+ */
9
+ /** OpenAI-compatible base: the client appends `/chat/completions` or `/responses` itself. */
10
+ export function normalizeV1Endpoint(endpoint) {
11
+ const normalized = endpoint.trim().replace(/\/+$/, '');
12
+ return normalized.endsWith('/v1') ? normalized : `${normalized}/v1`;
13
+ }
14
+ /**
15
+ * Anthropic base: `ANTHROPIC_BASE_URL` is the host; the client appends
16
+ * `/v1/messages`, so a trailing `/v1` has to come off rather than stay on.
17
+ */
18
+ export function normalizeMessagesEndpoint(endpoint) {
19
+ return endpoint.trim().replace(/\/+$/, '').replace(/\/v1$/, '');
20
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Root entry of the shared core.
3
+ *
4
+ * The client protocol is what most consumers want, and it is the same surface
5
+ * `@undefineds.co/ai-connections-core/client` publishes. The catalog and the
6
+ * client-configuration adapters stay on their own subpaths because they are
7
+ * larger and only some consumers need them.
8
+ */
9
+ export * from './ai-connections-client';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Root entry of the shared core.
3
+ *
4
+ * The client protocol is what most consumers want, and it is the same surface
5
+ * `@undefineds.co/ai-connections-core/client` publishes. The catalog and the
6
+ * client-configuration adapters stay on their own subpaths because they are
7
+ * larger and only some consumers need them.
8
+ */
9
+ export * from './ai-connections-client.js';
@@ -39,19 +39,49 @@ var __export = (target, all) => {
39
39
  // src/provider-catalog.ts
40
40
  var exports_provider_catalog = {};
41
41
  __export(exports_provider_catalog, {
42
+ storedOfferingIdFor: () => storedOfferingIdFor,
42
43
  providerOfferings: () => providerOfferings,
43
- providerName: () => providerName,
44
44
  offeringBaseUrl: () => offeringBaseUrl,
45
45
  defaultOfferingFor: () => defaultOfferingFor,
46
46
  customCompatibilityValue: () => customCompatibilityValue,
47
+ credentialOfferingMetadata: () => credentialOfferingMetadata,
47
48
  PROVIDER_OFFERINGS: () => PROVIDER_OFFERINGS,
48
49
  DEFAULT_PROVIDER_OFFERINGS: () => DEFAULT_PROVIDER_OFFERINGS,
49
- CUSTOM_DEFAULT_OFFERINGS: () => CUSTOM_DEFAULT_OFFERINGS
50
+ CUSTOM_DEFAULT_OFFERINGS: () => CUSTOM_DEFAULT_OFFERINGS,
51
+ BROWSER_LOGIN_METHOD: () => BROWSER_LOGIN_METHOD,
52
+ API_KEY_METHOD: () => API_KEY_METHOD,
53
+ AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS: () => AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS
50
54
  });
51
55
  module.exports = __toCommonJS(exports_provider_catalog);
56
+
57
+ // src/client/types.ts
58
+ var AI_CONNECTIONS_PROVIDERS = [
59
+ "openai",
60
+ "anthropic",
61
+ "kimi",
62
+ "bailian",
63
+ "deepseek",
64
+ "zhipu",
65
+ "ollama",
66
+ "custom"
67
+ ];
68
+
69
+ // src/provider-catalog.ts
52
70
  var DEFAULT_PROVIDER_OFFERINGS = [
53
71
  { id: "api-platform", label: "API Platform", kind: "api-platform", lifecycle: "active", authModes: ["apiKey"] }
54
72
  ];
73
+ var API_KEY_METHOD = {
74
+ id: "api-key",
75
+ authMode: "apiKey",
76
+ lifecycle: "active"
77
+ };
78
+ var BROWSER_LOGIN_METHOD = {
79
+ id: "browser-login",
80
+ authMode: "apiKey",
81
+ connectMode: "browserAssistedApiKey",
82
+ lifecycle: "active"
83
+ };
84
+ var API_KEY_METHODS = [API_KEY_METHOD, BROWSER_LOGIN_METHOD];
55
85
  var CUSTOM_DEFAULT_OFFERINGS = [
56
86
  {
57
87
  id: "openai-compatible",
@@ -119,6 +149,7 @@ var PROVIDER_OFFERINGS = {
119
149
  kind: "api-platform",
120
150
  lifecycle: "active",
121
151
  authModes: ["apiKey"],
152
+ authorizationMethods: API_KEY_METHODS,
122
153
  productLabel: "OpenAI",
123
154
  runtimeProviderIds: ["openai"],
124
155
  credentialPrefixHints: ["sk-"],
@@ -158,6 +189,7 @@ var PROVIDER_OFFERINGS = {
158
189
  kind: "api-platform",
159
190
  lifecycle: "active",
160
191
  authModes: ["apiKey"],
192
+ authorizationMethods: API_KEY_METHODS,
161
193
  productLabel: "Anthropic",
162
194
  runtimeProviderIds: ["anthropic"],
163
195
  credentialPrefixHints: ["sk-ant-"],
@@ -255,6 +287,7 @@ var PROVIDER_OFFERINGS = {
255
287
  kind: "api-platform",
256
288
  lifecycle: "active",
257
289
  authModes: ["apiKey"],
290
+ authorizationMethods: API_KEY_METHODS,
258
291
  productLabel: "智谱 AI",
259
292
  runtimeProviderIds: ["zhipu"],
260
293
  credentialPrefixHints: ["id."],
@@ -272,6 +305,7 @@ var PROVIDER_OFFERINGS = {
272
305
  kind: "token-plan",
273
306
  lifecycle: "active",
274
307
  authModes: ["apiKey"],
308
+ authorizationMethods: API_KEY_METHODS,
275
309
  productLabel: "智谱 AI",
276
310
  runtimeProviderIds: ["zhipu"],
277
311
  credentialPrefixHints: ["id."],
@@ -292,6 +326,7 @@ function kimiOffering(input) {
292
326
  kind: input.kind,
293
327
  lifecycle: "active",
294
328
  authModes: input.authModes,
329
+ authorizationMethods: API_KEY_METHODS,
295
330
  productLabel: input.productLabel,
296
331
  runtimeProviderIds: input.runtimeProviderIds,
297
332
  credentialPrefixHints: input.credentialPrefixHints,
@@ -312,6 +347,7 @@ function bailianOffering(input) {
312
347
  productLabel: "Alibaba Bailian",
313
348
  kind: input.kind,
314
349
  authModes: ["apiKey"],
350
+ authorizationMethods: API_KEY_METHODS,
315
351
  runtimeProviderIds: input.runtimeProviderIds,
316
352
  credentialPrefixHints: input.credentialPrefixHints,
317
353
  consoleUrl: input.consoleUrl,
@@ -342,39 +378,28 @@ function providerOfferings(provider, openAiSubscriptionImportAvailable = false)
342
378
  lifecycle: "active",
343
379
  authModes: Array.from(new Set([...offering.authModes ?? [], "local"])),
344
380
  authorizationMethods: [
345
- { id: "device-code", authMode: "deviceCode", connectMode: "deviceCodeOAuth", label: "设备码登录", lifecycle: "active" },
346
- { id: "local-session-import", authMode: "local", label: "已有登录态", lifecycle: "active" }
381
+ { id: "device-code", authMode: "deviceCode", connectMode: "deviceCodeOAuth", lifecycle: "active" },
382
+ { id: "local-session-import", authMode: "local", lifecycle: "active" }
347
383
  ]
348
384
  };
349
385
  }
350
386
  return { ...offering };
351
387
  });
352
388
  }
389
+ var AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS = AI_CONNECTIONS_PROVIDERS.flatMap((provider) => [
390
+ provider,
391
+ ...builtinOfferings(provider).map((offering) => `${provider}-${offering.id}`)
392
+ ]);
393
+ function builtinOfferings(provider) {
394
+ if (provider === "custom")
395
+ return CUSTOM_DEFAULT_OFFERINGS;
396
+ return PROVIDER_OFFERINGS[provider] ?? DEFAULT_PROVIDER_OFFERINGS;
397
+ }
353
398
  function customCompatibilityValue(value, offeringId) {
354
399
  if (value === "anthropic" || offeringId === "anthropic-compatible")
355
400
  return "anthropic";
356
401
  return "openai";
357
402
  }
358
- function providerName(provider) {
359
- switch (provider) {
360
- case "openai":
361
- return "OpenAI";
362
- case "anthropic":
363
- return "Anthropic";
364
- case "kimi":
365
- return "Kimi";
366
- case "bailian":
367
- return "百炼";
368
- case "deepseek":
369
- return "DeepSeek";
370
- case "zhipu":
371
- return "智谱 AI";
372
- case "ollama":
373
- return "Ollama";
374
- case "custom":
375
- return "Custom";
376
- }
377
- }
378
403
  function defaultOfferingFor(provider, authMode) {
379
404
  if (provider === "openai" && (authMode === "local" || authMode === "oauth" || authMode === "deviceCode")) {
380
405
  return "official-subscription";
@@ -397,3 +422,22 @@ function offeringBaseUrl(provider, offeringId) {
397
422
  const discoveryProtocol = offering.modelDiscovery?.endpointProtocol;
398
423
  return offering.endpoints?.find((endpoint) => endpoint.protocol === discoveryProtocol)?.baseUrl ?? offering.endpoints?.[0]?.baseUrl;
399
424
  }
425
+ function storedOfferingIdFor(provider, offeringId) {
426
+ const normalized = offeringId.trim().toLowerCase();
427
+ if (provider === "bailian") {
428
+ if (normalized === "token-plan-personal")
429
+ return "token-plan";
430
+ if (normalized === "coding-plan-pro")
431
+ return "coding-plan";
432
+ }
433
+ return normalized;
434
+ }
435
+ function credentialOfferingMetadata(input) {
436
+ return {
437
+ offeringId: input.offeringId,
438
+ priority: input.priority ?? 100,
439
+ enabled: input.enabled ?? true,
440
+ health: input.health ?? "unknown",
441
+ ...input.baseUrl ? { baseUrl: input.baseUrl } : {}
442
+ };
443
+ }
@@ -0,0 +1,84 @@
1
+ import type { AiConnectionsProvider, AiProviderAuthorizationMethod, AiProviderCredentialSummary, AiProviderOffering } from './ai-connections-client';
2
+ export declare const DEFAULT_PROVIDER_OFFERINGS: AiProviderOffering[];
3
+ /**
4
+ * How an offering accepts a key: typed into Xpod's own form (this entry) or
5
+ * minted in the provider's console (the browser-assisted entry below). An
6
+ * offering that declares its actions declares this one too - the catalog names
7
+ * the action by id and the server only decides whether the entry is usable in a
8
+ * given deployment. The wording a user reads is the applet's
9
+ * (`display-wording.ts`), so the same action cannot be named three ways.
10
+ */
11
+ export declare const API_KEY_METHOD: AiProviderAuthorizationMethod;
12
+ /**
13
+ * The connect entry that opens the provider's own console so the user signs in
14
+ * there and mints a key. Which ways in exist is offering data, so the entry is
15
+ * declared on the offerings that accept a key (`authModes` keeps the mechanical
16
+ * truth, `apiKey`) instead of on a provider-level label, and it points at the
17
+ * `consoleUrl` the offering already carries.
18
+ *
19
+ * Providers without one say something real by not declaring it: DeepSeek has no
20
+ * account console to sign into, Ollama is a local service, and `custom` is
21
+ * configured inside Xpod rather than at a provider.
22
+ *
23
+ * The id names the action the way its siblings do (browser-login / device-code /
24
+ * local-session-import); the wording follows from the id in the applet, and the
25
+ * legacy 「登录」 was retired because it named the provider rather than the
26
+ * action - which is what let a provider-level string claim a capability no
27
+ * offering declared.
28
+ */
29
+ export declare const BROWSER_LOGIN_METHOD: AiProviderAuthorizationMethod;
30
+ export declare const CUSTOM_DEFAULT_OFFERINGS: AiProviderOffering[];
31
+ export declare const PROVIDER_OFFERINGS: Partial<Record<AiConnectionsProvider, AiProviderOffering[]>>;
32
+ export declare function providerOfferings(provider: AiConnectionsProvider, openAiSubscriptionImportAvailable?: boolean): AiProviderOffering[];
33
+ /**
34
+ * Provider documents the AI Connection service is granted access to: the
35
+ * provider container document plus one document per built-in offering, named
36
+ * `<provider>-<offeringId>` by the Pod layout.
37
+ *
38
+ * This is the single program-side authority for that list. The Gateway's
39
+ * service-access descriptor and this package's descriptor validator both read
40
+ * it, so the granted surface and the validator cannot drift from the catalogue
41
+ * or from each other. Adding an offering to the catalogue adds its document
42
+ * here, which is exactly the program capability the service is allowed to
43
+ * reach.
44
+ */
45
+ export declare const AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS: readonly string[];
46
+ export declare function customCompatibilityValue(value: unknown, offeringId?: string): 'openai' | 'anthropic';
47
+ export declare function defaultOfferingFor(provider: AiConnectionsProvider, authMode: AiProviderCredentialSummary['authMode']): string;
48
+ export declare function offeringBaseUrl(provider: AiConnectionsProvider, offeringId?: string): string | undefined;
49
+ /**
50
+ * The offering id a credential records.
51
+ *
52
+ * An offering id is catalog content, so this stores the catalog's own id
53
+ * (`token-plan`, `coding-plan`, `pay-as-you-go`, …) lower-cased. The bootstrap
54
+ * naming turned two Bailian ids into document-name variants; those are folded
55
+ * back so the attribute never carries a storage-layout artefact.
56
+ *
57
+ * It lives in the capability package rather than in the Pod adapter that first
58
+ * needed it: the adapter, the collection runtime and the read emulation in tests
59
+ * all have to agree on this column, and a second copy would drift on the first
60
+ * catalog change (AGENTS.md: 目录内容跟能力走, 不得保留第二份副本).
61
+ */
62
+ export declare function storedOfferingIdFor(provider: AiConnectionsProvider, offeringId: string): string;
63
+ /**
64
+ * The offering-derived part of a credential row's `metadata`.
65
+ *
66
+ * MIGRATION WINDOW: the offering is written both as the credential's
67
+ * `udfs:offeringId` attribute and inside the `metadata` JSON.
68
+ * `@undefineds.co/models` releases before the one that declares `offeringId`
69
+ * persist neither (drizzle-solid drops values whose key is not a declared
70
+ * column), so a bundle built against such a release would lose it. Drop the
71
+ * `metadata` copy once every consumer is built against the declaring release and
72
+ * no reader needs the fallback in `credentialOfferingIdFromRow`.
73
+ *
74
+ * Shared for the same reason as {@link storedOfferingIdFor}: a credential's row
75
+ * has exactly one shape, and the collection would read its own confirmation as a
76
+ * change if the writer and the projection disagreed on it.
77
+ */
78
+ export declare function credentialOfferingMetadata(input: {
79
+ offeringId: string;
80
+ baseUrl?: string;
81
+ priority?: number;
82
+ enabled?: boolean;
83
+ health?: string;
84
+ }): Record<string, unknown>;
@@ -1,9 +1,48 @@
1
+ import { AI_CONNECTIONS_PROVIDERS } from './client/types.js';
1
2
  // Built-in provider and offering catalog. This is the single place that names a
2
3
  // provider or an offering; display layers project from it instead of keeping a
3
4
  // second copy, which is how the same offering used to appear under two names.
4
5
  export const DEFAULT_PROVIDER_OFFERINGS = [
5
6
  { id: 'api-platform', label: 'API Platform', kind: 'api-platform', lifecycle: 'active', authModes: ['apiKey'] },
6
7
  ];
8
+ /**
9
+ * How an offering accepts a key: typed into Xpod's own form (this entry) or
10
+ * minted in the provider's console (the browser-assisted entry below). An
11
+ * offering that declares its actions declares this one too - the catalog names
12
+ * the action by id and the server only decides whether the entry is usable in a
13
+ * given deployment. The wording a user reads is the applet's
14
+ * (`display-wording.ts`), so the same action cannot be named three ways.
15
+ */
16
+ export const API_KEY_METHOD = {
17
+ id: 'api-key',
18
+ authMode: 'apiKey',
19
+ lifecycle: 'active',
20
+ };
21
+ /**
22
+ * The connect entry that opens the provider's own console so the user signs in
23
+ * there and mints a key. Which ways in exist is offering data, so the entry is
24
+ * declared on the offerings that accept a key (`authModes` keeps the mechanical
25
+ * truth, `apiKey`) instead of on a provider-level label, and it points at the
26
+ * `consoleUrl` the offering already carries.
27
+ *
28
+ * Providers without one say something real by not declaring it: DeepSeek has no
29
+ * account console to sign into, Ollama is a local service, and `custom` is
30
+ * configured inside Xpod rather than at a provider.
31
+ *
32
+ * The id names the action the way its siblings do (browser-login / device-code /
33
+ * local-session-import); the wording follows from the id in the applet, and the
34
+ * legacy 「登录」 was retired because it named the provider rather than the
35
+ * action - which is what let a provider-level string claim a capability no
36
+ * offering declared.
37
+ */
38
+ export const BROWSER_LOGIN_METHOD = {
39
+ id: 'browser-login',
40
+ authMode: 'apiKey',
41
+ connectMode: 'browserAssistedApiKey',
42
+ lifecycle: 'active',
43
+ };
44
+ /** Both ways a key arrives, for an offering whose provider has a console. */
45
+ const API_KEY_METHODS = [API_KEY_METHOD, BROWSER_LOGIN_METHOD];
7
46
  export const CUSTOM_DEFAULT_OFFERINGS = [
8
47
  {
9
48
  id: 'openai-compatible',
@@ -79,6 +118,7 @@ export const PROVIDER_OFFERINGS = {
79
118
  kind: 'api-platform',
80
119
  lifecycle: 'active',
81
120
  authModes: ['apiKey'],
121
+ authorizationMethods: API_KEY_METHODS,
82
122
  productLabel: 'OpenAI',
83
123
  runtimeProviderIds: ['openai'],
84
124
  credentialPrefixHints: ['sk-'],
@@ -118,6 +158,7 @@ export const PROVIDER_OFFERINGS = {
118
158
  kind: 'api-platform',
119
159
  lifecycle: 'active',
120
160
  authModes: ['apiKey'],
161
+ authorizationMethods: API_KEY_METHODS,
121
162
  productLabel: 'Anthropic',
122
163
  runtimeProviderIds: ['anthropic'],
123
164
  credentialPrefixHints: ['sk-ant-'],
@@ -217,6 +258,7 @@ export const PROVIDER_OFFERINGS = {
217
258
  kind: 'api-platform',
218
259
  lifecycle: 'active',
219
260
  authModes: ['apiKey'],
261
+ authorizationMethods: API_KEY_METHODS,
220
262
  productLabel: '智谱 AI',
221
263
  runtimeProviderIds: ['zhipu'],
222
264
  credentialPrefixHints: ['id.'],
@@ -234,6 +276,7 @@ export const PROVIDER_OFFERINGS = {
234
276
  kind: 'token-plan',
235
277
  lifecycle: 'active',
236
278
  authModes: ['apiKey'],
279
+ authorizationMethods: API_KEY_METHODS,
237
280
  productLabel: '智谱 AI',
238
281
  runtimeProviderIds: ['zhipu'],
239
282
  credentialPrefixHints: ['id.'],
@@ -254,6 +297,7 @@ function kimiOffering(input) {
254
297
  kind: input.kind,
255
298
  lifecycle: 'active',
256
299
  authModes: input.authModes,
300
+ authorizationMethods: API_KEY_METHODS,
257
301
  productLabel: input.productLabel,
258
302
  runtimeProviderIds: input.runtimeProviderIds,
259
303
  credentialPrefixHints: input.credentialPrefixHints,
@@ -274,6 +318,7 @@ function bailianOffering(input) {
274
318
  productLabel: 'Alibaba Bailian',
275
319
  kind: input.kind,
276
320
  authModes: ['apiKey'],
321
+ authorizationMethods: API_KEY_METHODS,
277
322
  runtimeProviderIds: input.runtimeProviderIds,
278
323
  credentialPrefixHints: input.credentialPrefixHints,
279
324
  consoleUrl: input.consoleUrl,
@@ -306,39 +351,46 @@ export function providerOfferings(provider, openAiSubscriptionImportAvailable =
306
351
  lifecycle: 'active',
307
352
  authModes: Array.from(new Set([...(offering.authModes ?? []), 'local'])),
308
353
  authorizationMethods: [
309
- { id: 'device-code', authMode: 'deviceCode', connectMode: 'deviceCodeOAuth', label: '设备码登录', lifecycle: 'active' },
310
- { id: 'local-session-import', authMode: 'local', label: '已有登录态', lifecycle: 'active' },
354
+ { id: 'device-code', authMode: 'deviceCode', connectMode: 'deviceCodeOAuth', lifecycle: 'active' },
355
+ { id: 'local-session-import', authMode: 'local', lifecycle: 'active' },
311
356
  ],
312
357
  };
313
358
  }
314
359
  return { ...offering };
315
360
  });
316
361
  }
362
+ /**
363
+ * Provider documents the AI Connection service is granted access to: the
364
+ * provider container document plus one document per built-in offering, named
365
+ * `<provider>-<offeringId>` by the Pod layout.
366
+ *
367
+ * This is the single program-side authority for that list. The Gateway's
368
+ * service-access descriptor and this package's descriptor validator both read
369
+ * it, so the granted surface and the validator cannot drift from the catalogue
370
+ * or from each other. Adding an offering to the catalogue adds its document
371
+ * here, which is exactly the program capability the service is allowed to
372
+ * reach.
373
+ */
374
+ export const AI_CONNECTIONS_PROVIDER_DOCUMENT_IDS = AI_CONNECTIONS_PROVIDERS.flatMap((provider) => [
375
+ provider,
376
+ ...builtinOfferings(provider).map((offering) => `${provider}-${offering.id}`),
377
+ ]);
378
+ /**
379
+ * Built-in offerings of one provider as the catalogue declares them. `custom`
380
+ * keeps its placeholder offerings in their own table because its endpoints are
381
+ * intentionally invalid; every other provider declares its own list above.
382
+ * This mirrors the Gateway's `ProviderRegistry.offeringsForProduct`.
383
+ */
384
+ function builtinOfferings(provider) {
385
+ if (provider === 'custom')
386
+ return CUSTOM_DEFAULT_OFFERINGS;
387
+ return PROVIDER_OFFERINGS[provider] ?? DEFAULT_PROVIDER_OFFERINGS;
388
+ }
317
389
  export function customCompatibilityValue(value, offeringId) {
318
390
  if (value === 'anthropic' || offeringId === 'anthropic-compatible')
319
391
  return 'anthropic';
320
392
  return 'openai';
321
393
  }
322
- export function providerName(provider) {
323
- switch (provider) {
324
- case 'openai':
325
- return 'OpenAI';
326
- case 'anthropic':
327
- return 'Anthropic';
328
- case 'kimi':
329
- return 'Kimi';
330
- case 'bailian':
331
- return '百炼';
332
- case 'deepseek':
333
- return 'DeepSeek';
334
- case 'zhipu':
335
- return '智谱 AI';
336
- case 'ollama':
337
- return 'Ollama';
338
- case 'custom':
339
- return 'Custom';
340
- }
341
- }
342
394
  export function defaultOfferingFor(provider, authMode) {
343
395
  if (provider === 'openai' && (authMode === 'local' || authMode === 'oauth' || authMode === 'deviceCode')) {
344
396
  return 'official-subscription';
@@ -362,3 +414,50 @@ export function offeringBaseUrl(provider, offeringId) {
362
414
  return offering.endpoints?.find((endpoint) => endpoint.protocol === discoveryProtocol)?.baseUrl
363
415
  ?? offering.endpoints?.[0]?.baseUrl;
364
416
  }
417
+ /**
418
+ * The offering id a credential records.
419
+ *
420
+ * An offering id is catalog content, so this stores the catalog's own id
421
+ * (`token-plan`, `coding-plan`, `pay-as-you-go`, …) lower-cased. The bootstrap
422
+ * naming turned two Bailian ids into document-name variants; those are folded
423
+ * back so the attribute never carries a storage-layout artefact.
424
+ *
425
+ * It lives in the capability package rather than in the Pod adapter that first
426
+ * needed it: the adapter, the collection runtime and the read emulation in tests
427
+ * all have to agree on this column, and a second copy would drift on the first
428
+ * catalog change (AGENTS.md: 目录内容跟能力走, 不得保留第二份副本).
429
+ */
430
+ export function storedOfferingIdFor(provider, offeringId) {
431
+ const normalized = offeringId.trim().toLowerCase();
432
+ if (provider === 'bailian') {
433
+ if (normalized === 'token-plan-personal')
434
+ return 'token-plan';
435
+ if (normalized === 'coding-plan-pro')
436
+ return 'coding-plan';
437
+ }
438
+ return normalized;
439
+ }
440
+ /**
441
+ * The offering-derived part of a credential row's `metadata`.
442
+ *
443
+ * MIGRATION WINDOW: the offering is written both as the credential's
444
+ * `udfs:offeringId` attribute and inside the `metadata` JSON.
445
+ * `@undefineds.co/models` releases before the one that declares `offeringId`
446
+ * persist neither (drizzle-solid drops values whose key is not a declared
447
+ * column), so a bundle built against such a release would lose it. Drop the
448
+ * `metadata` copy once every consumer is built against the declaring release and
449
+ * no reader needs the fallback in `credentialOfferingIdFromRow`.
450
+ *
451
+ * Shared for the same reason as {@link storedOfferingIdFor}: a credential's row
452
+ * has exactly one shape, and the collection would read its own confirmation as a
453
+ * change if the writer and the projection disagreed on it.
454
+ */
455
+ export function credentialOfferingMetadata(input) {
456
+ return {
457
+ offeringId: input.offeringId,
458
+ priority: input.priority ?? 100,
459
+ enabled: input.enabled ?? true,
460
+ health: input.health ?? 'unknown',
461
+ ...(input.baseUrl ? { baseUrl: input.baseUrl } : {}),
462
+ };
463
+ }