@undefineds.co/xpod 0.4.10 → 0.4.12

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 (402) 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/ai/service/AiCredentialSecret.d.ts +30 -0
  5. package/dist/ai/service/AiCredentialSecret.js +120 -0
  6. package/dist/ai/service/CredentialReaderImpl.d.ts +18 -0
  7. package/dist/ai/service/CredentialReaderImpl.js +81 -5
  8. package/dist/ai/service/CredentialReaderImpl.jsonld +42 -2
  9. package/dist/ai/service/EmbeddingModelPolicy.d.ts +79 -0
  10. package/dist/ai/service/EmbeddingModelPolicy.js +134 -0
  11. package/dist/ai/service/EmbeddingProviderError.js +6 -0
  12. package/dist/ai/service/EmbeddingServiceImpl.d.ts +13 -1
  13. package/dist/ai/service/EmbeddingServiceImpl.js +18 -5
  14. package/dist/ai/service/EmbeddingServiceImpl.jsonld +35 -0
  15. package/dist/ai/service/index.d.ts +2 -0
  16. package/dist/ai/service/index.js +2 -0
  17. package/dist/api/ai-gateway/connect/index.d.ts +20 -2
  18. package/dist/api/ai-gateway/connect/index.js +162 -16
  19. package/dist/api/ai-gateway/credentials/AiCredentialSecretDecoder.d.ts +12 -0
  20. package/dist/api/ai-gateway/credentials/AiCredentialSecretDecoder.js +30 -0
  21. package/dist/api/ai-gateway/errors.d.ts +1 -1
  22. package/dist/api/ai-gateway/models/GatewayEmbeddingModelCatalog.d.ts +11 -0
  23. package/dist/api/ai-gateway/models/GatewayEmbeddingModelCatalog.js +31 -0
  24. package/dist/api/ai-gateway/models/PodModelSelectionRepository.js +7 -3
  25. package/dist/api/ai-gateway/models/ProviderCustomModelsService.d.ts +18 -0
  26. package/dist/api/ai-gateway/models/ProviderCustomModelsService.js +23 -0
  27. package/dist/api/ai-gateway/models/ProviderModelDiscoveryAdapters.d.ts +3 -1
  28. package/dist/api/ai-gateway/models/ProviderModelDiscoveryAdapters.js +2 -45
  29. package/dist/api/ai-gateway/models/ProviderModelSelectionService.d.ts +10 -0
  30. package/dist/api/ai-gateway/models/ProviderModelSelectionService.js +57 -20
  31. package/dist/api/ai-gateway/models/ProviderModelType.d.ts +28 -0
  32. package/dist/api/ai-gateway/models/ProviderModelType.js +34 -0
  33. package/dist/api/ai-gateway/models/ProviderModelsAdapter.d.ts +10 -0
  34. package/dist/api/ai-gateway/models/ProviderModelsAdapter.js +3 -4
  35. package/dist/api/ai-gateway/models/index.d.ts +1 -0
  36. package/dist/api/ai-gateway/models/index.js +3 -1
  37. package/dist/api/ai-gateway/providers/CustomRuntimeAdapter.d.ts +7 -0
  38. package/dist/api/ai-gateway/providers/CustomRuntimeAdapter.js +9 -2
  39. package/dist/api/ai-gateway/providers/ModelsDevCatalog.d.ts +7 -1
  40. package/dist/api/ai-gateway/providers/ModelsDevCatalog.js +4 -10
  41. package/dist/api/ai-gateway/providers/ProviderRegistry.d.ts +107 -0
  42. package/dist/api/ai-gateway/providers/ProviderRegistry.js +244 -21
  43. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.d.ts +5 -0
  44. package/dist/api/ai-gateway/providers/ProviderRuntimeRegistry.js +5 -1
  45. package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.d.ts +12 -4
  46. package/dist/api/ai-gateway/quota/SubscriptionQuotaAdapters.js +11 -11
  47. package/dist/api/ai-gateway/routing/ModelRouter.d.ts +14 -0
  48. package/dist/api/ai-gateway/routing/ModelRouter.js +43 -4
  49. package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.d.ts +9 -1
  50. package/dist/api/ai-gateway/service-access/AiConnectionsServiceAccess.js +3 -27
  51. package/dist/api/auth/ClientCredentialsAuthenticator.d.ts +0 -1
  52. package/dist/api/auth/ClientCredentialsAuthenticator.js +0 -3
  53. package/dist/api/auth/index.d.ts +1 -0
  54. package/dist/api/auth/index.js +1 -1
  55. package/dist/api/chatkit/pod-store.d.ts +31 -0
  56. package/dist/api/chatkit/pod-store.js +132 -8
  57. package/dist/api/container/common.js +24 -4
  58. package/dist/api/container/routes.js +17 -2
  59. package/dist/api/container/types.d.ts +3 -1
  60. package/dist/api/handlers/AdminHandler.d.ts +13 -0
  61. package/dist/api/handlers/AdminHandler.js +47 -18
  62. package/dist/api/handlers/AiConfigHandler.d.ts +6 -0
  63. package/dist/api/handlers/AiConfigHandler.js +28 -0
  64. package/dist/api/handlers/AiGatewayManagementHandler.js +36 -0
  65. package/dist/api/runs/RdfRunContextRetriever.d.ts +14 -0
  66. package/dist/api/runs/RdfRunContextRetriever.js +41 -5
  67. package/dist/api/runtime.js +2 -1
  68. package/dist/cli/commands/secret.d.ts +1 -0
  69. package/dist/cli/commands/secret.js +25 -7
  70. package/dist/components/components.jsonld +3 -1
  71. package/dist/components/context.jsonld +53 -1
  72. package/dist/http/SubgraphSparqlHttpHandler.d.ts +59 -2
  73. package/dist/http/SubgraphSparqlHttpHandler.js +145 -13
  74. package/dist/http/SubgraphSparqlHttpHandler.jsonld +37 -0
  75. package/dist/identity/drizzle/AccountRoleRepository.d.ts +30 -2
  76. package/dist/identity/drizzle/AccountRoleRepository.js +163 -15
  77. package/dist/identity/drizzle/EdgeNodeRepository.d.ts +0 -12
  78. package/dist/identity/drizzle/EdgeNodeRepository.js +5 -13
  79. package/dist/identity/drizzle/PodLookupRepository.d.ts +58 -4
  80. package/dist/identity/drizzle/PodLookupRepository.js +248 -105
  81. package/dist/identity/drizzle/db.d.ts +19 -0
  82. package/dist/identity/drizzle/db.js +39 -4
  83. package/dist/index.d.ts +2 -1
  84. package/dist/index.js +7 -3
  85. package/dist/logging/log-file.d.ts +17 -0
  86. package/dist/logging/log-file.js +69 -0
  87. package/dist/main.js +2 -1
  88. package/dist/notifications/NotificationChannelSweeper.d.ts +50 -0
  89. package/dist/notifications/NotificationChannelSweeper.js +131 -0
  90. package/dist/notifications/NotificationChannelSweeper.jsonld +136 -0
  91. package/dist/notifications/ReclaimingWebSocket2023Storer.d.ts +25 -0
  92. package/dist/notifications/ReclaimingWebSocket2023Storer.js +56 -0
  93. package/dist/notifications/ReclaimingWebSocket2023Storer.jsonld +77 -0
  94. package/dist/notifications/index.d.ts +2 -0
  95. package/dist/notifications/index.js +2 -0
  96. package/dist/runtime/Proxy.d.ts +37 -0
  97. package/dist/runtime/Proxy.js +88 -16
  98. package/dist/runtime/bootstrap.js +2 -1
  99. package/dist/runtime/upgrade/BunNativeUpgradeRelay.d.ts +116 -0
  100. package/dist/runtime/upgrade/BunNativeUpgradeRelay.js +423 -0
  101. package/dist/runtime/upgrade/UpgradeHandshake.d.ts +63 -0
  102. package/dist/runtime/upgrade/UpgradeHandshake.js +199 -0
  103. package/dist/runtime/upgrade/WebSocketFrames.d.ts +67 -0
  104. package/dist/runtime/upgrade/WebSocketFrames.js +224 -0
  105. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +8 -1
  106. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.d.ts +11 -2
  107. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.js +27 -10
  108. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +7 -0
  109. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +13 -11
  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 +16 -1
  116. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +92 -20
  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.js +71 -11
  120. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.js +9 -7
  121. package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.d.ts +23 -0
  122. package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.js +24 -0
  123. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +13 -4
  124. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +35 -38
  125. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.d.ts +21 -0
  126. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.js +51 -0
  127. package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.d.ts +15 -0
  128. package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.js +16 -0
  129. package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.d.ts +175 -0
  130. package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.js +133 -0
  131. package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.js +2 -2
  132. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +13 -64
  133. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.d.ts +21 -0
  134. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.js +12 -0
  135. package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.d.ts +15 -0
  136. package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.js +12 -0
  137. package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.js +2 -1
  138. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.d.ts +7 -0
  139. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.js +6 -0
  140. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.d.ts +36 -5
  141. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.js +52 -9
  142. package/node_modules/@undefineds.co/ai-connections/dist/client/normalize.js +30 -3
  143. package/node_modules/@undefineds.co/ai-connections/dist/client/types.d.ts +21 -1
  144. package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.d.ts +1 -3
  145. package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.js +3 -7
  146. package/node_modules/@undefineds.co/ai-connections/dist/client-config/index.cjs +9 -7
  147. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.d.ts +46 -0
  148. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +231 -0
  149. package/node_modules/@undefineds.co/ai-connections/dist/collections.d.ts +119 -0
  150. package/node_modules/@undefineds.co/ai-connections/dist/collections.js +173 -0
  151. package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +71 -5
  152. package/node_modules/@undefineds.co/ai-connections/dist/controller.js +285 -16
  153. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.d.ts +5 -0
  154. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.js +8 -3
  155. package/node_modules/@undefineds.co/ai-connections/dist/credential-storage.d.ts +59 -0
  156. package/node_modules/@undefineds.co/ai-connections/dist/credential-storage.js +131 -0
  157. package/node_modules/@undefineds.co/ai-connections/dist/endpoint-urls.d.ts +15 -0
  158. package/node_modules/@undefineds.co/ai-connections/dist/endpoint-urls.js +20 -0
  159. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.d.ts +14 -0
  160. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.js +20 -0
  161. package/node_modules/@undefineds.co/ai-connections/dist/index.d.ts +8 -0
  162. package/node_modules/@undefineds.co/ai-connections/dist/index.js +8 -0
  163. package/node_modules/@undefineds.co/ai-connections/dist/manifest.js +1 -1
  164. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.d.ts +14 -0
  165. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.js +17 -0
  166. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.cjs +68 -1
  167. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.d.ts +75 -1
  168. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.js +119 -0
  169. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.d.ts +5 -0
  170. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.js +5 -0
  171. package/node_modules/@undefineds.co/ai-connections/dist/service-access.js +2 -27
  172. package/node_modules/@undefineds.co/ai-connections/package.json +1 -0
  173. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +1 -1
  174. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +2 -0
  175. package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +150 -0
  176. package/node_modules/@undefineds.co/extension-sdk/package.json +2 -1
  177. package/node_modules/@undefineds.co/models/README.md +1 -1
  178. package/node_modules/@undefineds.co/models/dist/ai-config/index.d.ts +3 -3
  179. package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.d.ts +5 -0
  180. package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.js +9 -0
  181. package/node_modules/@undefineds.co/models/dist/ai-runtime.repository.d.ts +1 -1
  182. package/node_modules/@undefineds.co/models/dist/approval.repository.d.ts +2 -2
  183. package/node_modules/@undefineds.co/models/dist/audit.presentation.d.ts +2 -2
  184. package/node_modules/@undefineds.co/models/dist/capture.repository.d.ts +1 -1
  185. package/node_modules/@undefineds.co/models/dist/chat-project.repository.d.ts +1 -1
  186. package/node_modules/@undefineds.co/models/dist/chat.repository.d.ts +2 -2
  187. package/node_modules/@undefineds.co/models/dist/control-request.repository.d.ts +2 -2
  188. package/node_modules/@undefineds.co/models/dist/conversation-share.repository.d.ts +1 -1
  189. package/node_modules/@undefineds.co/models/dist/credential.schema.d.ts +12 -0
  190. package/node_modules/@undefineds.co/models/dist/credential.schema.js +15 -1
  191. package/node_modules/@undefineds.co/models/dist/discovery/index.d.ts +2 -2
  192. package/node_modules/@undefineds.co/models/dist/discovery/providers.json +248 -7
  193. package/node_modules/@undefineds.co/models/dist/discovery/types.d.ts +31 -0
  194. package/node_modules/@undefineds.co/models/dist/extension/index.d.ts +1 -1
  195. package/node_modules/@undefineds.co/models/dist/favorite/index.d.ts +2 -2
  196. package/node_modules/@undefineds.co/models/dist/fixtures/contracts-chat-contact.d.ts +5 -5
  197. package/node_modules/@undefineds.co/models/dist/import/index.d.ts +1 -1
  198. package/node_modules/@undefineds.co/models/dist/index.d.ts +73 -73
  199. package/node_modules/@undefineds.co/models/dist/index.js +1 -1
  200. package/node_modules/@undefineds.co/models/dist/input-request.repository.d.ts +2 -2
  201. package/node_modules/@undefineds.co/models/dist/knowledge/index.d.ts +1 -1
  202. package/node_modules/@undefineds.co/models/dist/message.repository.d.ts +1 -1
  203. package/node_modules/@undefineds.co/models/dist/namespaces.js +5 -0
  204. package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.d.ts +4815 -26
  205. package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.js +482 -132
  206. package/node_modules/@undefineds.co/models/dist/schema.d.ts +4 -0
  207. package/node_modules/@undefineds.co/models/dist/session/index.d.ts +1 -1
  208. package/node_modules/@undefineds.co/models/dist/settings/index.d.ts +1 -1
  209. package/node_modules/@undefineds.co/models/dist/sidecar/persistence-mapping.d.ts +5 -5
  210. package/node_modules/@undefineds.co/models/dist/thread.repository.d.ts +2 -2
  211. package/node_modules/@undefineds.co/models/dist/types/message-block.d.ts +1 -1
  212. package/node_modules/@undefineds.co/models/dist/vocab/_namespaces.d.ts +1 -1
  213. package/node_modules/@undefineds.co/models/dist/vocab/index.d.ts +10 -10
  214. package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.d.ts +1 -0
  215. package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.js +1 -0
  216. package/node_modules/@undefineds.co/models/package.json +4 -2
  217. package/node_modules/@undefineds.co/pod-collections/README.md +71 -0
  218. package/node_modules/@undefineds.co/pod-collections/dist/diff.d.ts +85 -0
  219. package/node_modules/@undefineds.co/pod-collections/dist/diff.js +166 -0
  220. package/node_modules/@undefineds.co/pod-collections/dist/feed.d.ts +17 -0
  221. package/node_modules/@undefineds.co/pod-collections/dist/feed.js +27 -0
  222. package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +1042 -0
  223. package/node_modules/@undefineds.co/pod-collections/dist/index.d.ts +37 -0
  224. package/node_modules/@undefineds.co/pod-collections/dist/index.js +89 -0
  225. package/node_modules/@undefineds.co/pod-collections/dist/layout.d.ts +75 -0
  226. package/node_modules/@undefineds.co/pod-collections/dist/layout.js +173 -0
  227. package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +78 -0
  228. package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +287 -0
  229. package/node_modules/@undefineds.co/pod-collections/dist/mutations.d.ts +83 -0
  230. package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +273 -0
  231. package/node_modules/@undefineds.co/pod-collections/dist/react.d.ts +21 -0
  232. package/node_modules/@undefineds.co/pod-collections/dist/react.js +22 -0
  233. package/node_modules/@undefineds.co/pod-collections/dist/read.d.ts +65 -0
  234. package/node_modules/@undefineds.co/pod-collections/dist/read.js +31 -0
  235. package/node_modules/@undefineds.co/pod-collections/dist/sync.d.ts +66 -0
  236. package/node_modules/@undefineds.co/pod-collections/dist/sync.js +260 -0
  237. package/node_modules/@undefineds.co/pod-collections/dist/types.d.ts +155 -0
  238. package/node_modules/@undefineds.co/pod-collections/dist/types.js +9 -0
  239. package/node_modules/@undefineds.co/pod-collections/package.json +42 -0
  240. package/node_modules/@undefineds.co/shared-ui/dist/index.d.ts +0 -1
  241. package/node_modules/@undefineds.co/shared-ui/dist/index.js +0 -1
  242. package/package.json +15 -7
  243. package/static/app/assets/main.css +1 -1
  244. package/static/app/assets/main.js +12 -13
  245. package/static/auth-callback/assets/AiConfigContext-DnQs1ZpW.js +1 -0
  246. package/static/auth-callback/assets/AiConfigPage-DOtvlxH0.js +1 -0
  247. package/static/auth-callback/assets/DocumentProcessingPanel-BS2voQgL.js +1 -0
  248. package/static/auth-callback/assets/IndexLifecyclePanel-Cvt0cJtN.js +1 -0
  249. package/static/auth-callback/assets/{IndexSubjectPanel-C4YG0whI.js → IndexSubjectPanel-Dhf01GqF.js} +1 -1
  250. package/static/auth-callback/assets/ModelAssignmentsPanel-BJutWaAF.js +1 -0
  251. package/static/auth-callback/assets/ModelsPage-BRS0sje3.js +11 -0
  252. package/static/auth-callback/assets/{NetworkPage-Cbdn_P1e.js → NetworkPage-B3qBfANA.js} +2 -2
  253. package/static/auth-callback/assets/{PaneListHeader-jy70Q00L.js → PaneListHeader-QQeJGTp4.js} +1 -1
  254. package/static/auth-callback/assets/SearchIndexingPanel-MyNUSEwT.js +1 -0
  255. package/static/auth-callback/assets/{StatusSubjectPanel-hfjoB5aS.js → StatusSubjectPanel-DQkEVsFs.js} +1 -1
  256. package/static/{settings/assets/StatusWorkspace-CKD_Rzdr.js → auth-callback/assets/StatusWorkspace-Dkv63Uwk.js} +1 -1
  257. package/static/auth-callback/assets/SystemSettingsPage-TIsUfX5d.js +1 -0
  258. package/static/auth-callback/assets/SystemSettingsSubjectPanel-BJWEt2-7.js +33 -0
  259. package/static/auth-callback/assets/XpodAiConnectionsPodStore-BJiXm-PF.js +3 -0
  260. package/static/auth-callback/assets/{activity-BcsZZxxw.js → activity-5hNeNKnL.js} +1 -1
  261. package/static/auth-callback/assets/admin-C6qCRFiY.js +1 -0
  262. package/static/auth-callback/assets/ai-connections-CryuHGKW.js +1 -0
  263. package/static/auth-callback/assets/{auth-callback-atKg_oig.js → auth-callback-CAFZ3R0B.js} +80 -84
  264. package/static/auth-callback/assets/auth-callback-rk080mvG.css +1 -0
  265. package/static/auth-callback/assets/{badge-BWbRHThQ.js → badge-CAIPI0CB.js} +1 -1
  266. package/static/auth-callback/assets/collection-runtime-D9s7h9YA.js +1 -0
  267. package/static/auth-callback/assets/dialog-BjA109aX.js +1 -0
  268. package/static/auth-callback/assets/{download-BmvG1Vya.js → download-B3Up5W2G.js} +1 -1
  269. package/static/auth-callback/assets/{external-link-DZ34d3g3.js → external-link-BTXgSPzB.js} +1 -1
  270. package/static/auth-callback/assets/index-BppXlxcp.js +41 -0
  271. package/static/auth-callback/assets/index-CirW4CJf.js +1 -0
  272. package/static/auth-callback/assets/index-DlLYWOhw.js +4 -0
  273. package/static/auth-callback/assets/{index-browser-B9Z7GU-T.js → index-browser-DtU38ni3.js} +1 -1
  274. package/static/auth-callback/assets/{key-round-tjP76Se-.js → key-round-CQCOrZ7x.js} +1 -1
  275. package/static/auth-callback/assets/layout-DB3pMyTl.js +1 -0
  276. package/static/auth-callback/assets/pod-collections-host-KnnGFZHL.js +8 -0
  277. package/static/auth-callback/assets/{rotate-ccw-C_L5ZLx1.js → rotate-ccw-C1zM2KtS.js} +1 -1
  278. package/static/auth-callback/assets/settings-projection-CUkyprDQ.js +1 -0
  279. package/static/auth-callback/assets/{skeleton-C7tGDQIs.js → skeleton-Cqp7_M9-.js} +1 -1
  280. package/static/auth-callback/assets/{waypoints-VMNQlWdU.js → waypoints-Bj6gAUSQ.js} +1 -1
  281. package/static/auth-callback/assets/{workspace-layout-SAp6BtYK.js → workspace-layout-DK8mDzrY.js} +1 -1
  282. package/static/auth-callback/auth-callback.html +2 -2
  283. package/static/dashboard/assets/AiConfigContext-BsE7MqX8.js +1 -0
  284. package/static/dashboard/assets/AiConfigPage-DvM-lRXa.js +1 -0
  285. package/static/dashboard/assets/DocumentProcessingPanel-BPfdlfuf.js +1 -0
  286. package/static/dashboard/assets/IndexLifecyclePanel--m0AGxvh.js +1 -0
  287. package/static/dashboard/assets/{IndexSubjectPanel-DQFPP6-p.js → IndexSubjectPanel-Bb7m1k3d.js} +1 -1
  288. package/static/dashboard/assets/ModelAssignmentsPanel-BLi_zbMa.js +1 -0
  289. package/static/dashboard/assets/ModelsPage-CxdpgnfR.js +11 -0
  290. package/static/dashboard/assets/{NetworkPage-CHQ3YxIB.js → NetworkPage-BAIPw-D_.js} +2 -2
  291. package/static/dashboard/assets/{PaneListHeader-DsXemAdR.js → PaneListHeader-BBCMei0r.js} +1 -1
  292. package/static/dashboard/assets/SearchIndexingPanel-Ck4Y-xjR.js +1 -0
  293. package/static/dashboard/assets/{StatusSubjectPanel-D3PGEYT4.js → StatusSubjectPanel-D1KWfAXE.js} +1 -1
  294. package/static/dashboard/assets/{StatusWorkspace-BcpePYUW.js → StatusWorkspace-JbA5gzXx.js} +1 -1
  295. package/static/dashboard/assets/SystemSettingsPage-BbwQWsSR.js +1 -0
  296. package/static/dashboard/assets/SystemSettingsSubjectPanel-N117nMt5.js +33 -0
  297. package/static/dashboard/assets/XpodAiConnectionsPodStore-CdDOb4SV.js +18 -0
  298. package/static/dashboard/assets/{activity-j5zrznu-.js → activity-DX1I96o_.js} +1 -1
  299. package/static/dashboard/assets/admin-C6qCRFiY.js +1 -0
  300. package/static/dashboard/assets/ai-connections-DwCRqOQa.js +1 -0
  301. package/static/dashboard/assets/{badge-CzeBdG7h.js → badge-k2vhtDqH.js} +1 -1
  302. package/static/dashboard/assets/collection-runtime-BFQ8teQJ.js +1 -0
  303. package/static/dashboard/assets/{dashboard-D-xANHk1.js → dashboard-DWZ-fmCT.js} +105 -109
  304. package/static/dashboard/assets/dashboard-rk080mvG.css +1 -0
  305. package/static/dashboard/assets/dialog-1CCw-iHT.js +1 -0
  306. package/static/dashboard/assets/{download-IcNdEZWi.js → download-C6-SNY1q.js} +1 -1
  307. package/static/dashboard/assets/{external-link-DxBxK8Vu.js → external-link-BgPcZ_j2.js} +1 -1
  308. package/static/dashboard/assets/index-6LcIUIYO.js +1 -0
  309. package/static/dashboard/assets/index-D7A8U6Pt.js +41 -0
  310. package/static/dashboard/assets/index-UD6QOE7H.js +4 -0
  311. package/static/dashboard/assets/{key-round-D1K7warM.js → key-round-BOd7Jo0Q.js} +1 -1
  312. package/static/dashboard/assets/layout-DB3pMyTl.js +1 -0
  313. package/static/dashboard/assets/pod-collections-host-KnnGFZHL.js +8 -0
  314. package/static/dashboard/assets/{rotate-ccw-CcN1N6p9.js → rotate-ccw-CCgJqsvx.js} +1 -1
  315. package/static/dashboard/assets/settings-projection-CUkyprDQ.js +1 -0
  316. package/static/dashboard/assets/{skeleton-CKnmJMUH.js → skeleton-Bc7abAn5.js} +1 -1
  317. package/static/dashboard/assets/{waypoints-DuZPO_wu.js → waypoints-s-opmJxx.js} +1 -1
  318. package/static/dashboard/assets/{workspace-layout-BUj3wZ_m.js → workspace-layout-DqIQeTBV.js} +1 -1
  319. package/static/dashboard/dashboard.html +2 -2
  320. package/static/settings/assets/AiConfigContext-BB9KZySa.js +1 -0
  321. package/static/settings/assets/AiConfigPage-DGSXUkLs.js +1 -0
  322. package/static/settings/assets/DocumentProcessingPanel-Da2Re6Rg.js +1 -0
  323. package/static/settings/assets/IndexLifecyclePanel-BSZuIzgr.js +1 -0
  324. package/static/settings/assets/{IndexSubjectPanel-73sM16Ma.js → IndexSubjectPanel-CFd0ay-r.js} +1 -1
  325. package/static/settings/assets/ModelAssignmentsPanel-CSAryvWJ.js +1 -0
  326. package/static/settings/assets/ModelsPage-BQwCwLHU.js +11 -0
  327. package/static/settings/assets/{NetworkPage-i6j-M2RY.js → NetworkPage-BKymvsQc.js} +2 -2
  328. package/static/settings/assets/{PaneListHeader-DpqC0jd5.js → PaneListHeader-Bjh3hRdQ.js} +1 -1
  329. package/static/settings/assets/SearchIndexingPanel-MjKL5QLU.js +1 -0
  330. package/static/settings/assets/{StatusSubjectPanel-Dv4q3PGh.js → StatusSubjectPanel-Bvl6K4mx.js} +1 -1
  331. package/static/settings/assets/StatusWorkspace-B0NzrP--.js +1 -0
  332. package/static/settings/assets/SystemSettingsPage-D2z6Z4FE.js +1 -0
  333. package/static/settings/assets/SystemSettingsSubjectPanel-4sxma4X4.js +33 -0
  334. package/static/settings/assets/XpodAiConnectionsPodStore-BkNQ8fZx.js +3 -0
  335. package/static/settings/assets/{activity-DaFkk8f3.js → activity-CgJJGpjx.js} +1 -1
  336. package/static/settings/assets/admin-C6qCRFiY.js +1 -0
  337. package/static/settings/assets/ai-connections-CryuHGKW.js +1 -0
  338. package/static/settings/assets/{badge-d5SHdc-x.js → badge-C4NypVyT.js} +1 -1
  339. package/static/settings/assets/collection-runtime-CTLCDxAi.js +1 -0
  340. package/static/settings/assets/dialog-Csq0vWUi.js +1 -0
  341. package/static/settings/assets/{download-CpkwomDr.js → download-DaLJJ-Wp.js} +1 -1
  342. package/static/settings/assets/{external-link-_4YT42Mf.js → external-link--w_iW5Au.js} +1 -1
  343. package/static/settings/assets/index-B0mQa59b.js +4 -0
  344. package/static/settings/assets/index-BukHiu4y.js +1 -0
  345. package/static/settings/assets/index-COmVnZi2.js +41 -0
  346. package/static/settings/assets/{index-browser-B06xjBdZ.js → index-browser-BGpvHwD0.js} +1 -1
  347. package/static/settings/assets/{key-round-Dlqmp1Kq.js → key-round-Bk4YRjBu.js} +1 -1
  348. package/static/settings/assets/layout-DB3pMyTl.js +1 -0
  349. package/static/settings/assets/pod-collections-host-KnnGFZHL.js +8 -0
  350. package/static/settings/assets/{rotate-ccw-TAY65xWT.js → rotate-ccw-TCabbqsr.js} +1 -1
  351. package/static/settings/assets/{settings-ExBXGgbj.js → settings-CJWpdbNC.js} +105 -109
  352. package/static/settings/assets/settings-projection-CUkyprDQ.js +1 -0
  353. package/static/settings/assets/settings-rk080mvG.css +1 -0
  354. package/static/settings/assets/{skeleton-DKIWjNr9.js → skeleton-JDHYVe7t.js} +1 -1
  355. package/static/settings/assets/{waypoints-9erLIxyR.js → waypoints-DDvEl-MU.js} +1 -1
  356. package/static/settings/assets/{workspace-layout-CYXfYIa3.js → workspace-layout-DV5QU30U.js} +1 -1
  357. package/static/settings/settings.html +2 -2
  358. package/node_modules/@undefineds.co/shared-ui/dist/oidc-consent.d.ts +0 -54
  359. package/node_modules/@undefineds.co/shared-ui/dist/oidc-consent.js +0 -21
  360. package/static/auth-callback/assets/AiConfigContext-C81deMM9.js +0 -1
  361. package/static/auth-callback/assets/AiConfigPage-evWI8T56.js +0 -1
  362. package/static/auth-callback/assets/DocumentProcessingPanel-B9GrDEMe.js +0 -1
  363. package/static/auth-callback/assets/IndexLifecyclePanel-qCo8ABQZ.js +0 -1
  364. package/static/auth-callback/assets/ModelAssignmentsPanel-DG7Lxh3t.js +0 -1
  365. package/static/auth-callback/assets/ModelsPage-CgEuqE6p.js +0 -10
  366. package/static/auth-callback/assets/SearchIndexingPanel-ByU3u7kp.js +0 -1
  367. package/static/auth-callback/assets/StatusWorkspace-BZd617sV.js +0 -1
  368. package/static/auth-callback/assets/SystemSettingsPage-BirzWAQM.js +0 -1
  369. package/static/auth-callback/assets/SystemSettingsSubjectPanel-CmsVWNCx.js +0 -31
  370. package/static/auth-callback/assets/admin-BU4m6Ko2.js +0 -1
  371. package/static/auth-callback/assets/ai-connections-CHNTKemd.js +0 -1
  372. package/static/auth-callback/assets/auth-callback-C_7MUXJb.css +0 -1
  373. package/static/auth-callback/assets/index-BpV1hsqs.js +0 -4
  374. package/static/auth-callback/assets/index-D9oE6FXK.js +0 -41
  375. package/static/dashboard/assets/AiConfigContext-De-OtAWo.js +0 -1
  376. package/static/dashboard/assets/AiConfigPage-macP4Mop.js +0 -1
  377. package/static/dashboard/assets/DocumentProcessingPanel-C5ObvCCl.js +0 -1
  378. package/static/dashboard/assets/IndexLifecyclePanel-xVNa2l40.js +0 -1
  379. package/static/dashboard/assets/ModelAssignmentsPanel-DMOATFpQ.js +0 -1
  380. package/static/dashboard/assets/ModelsPage-91UbnETA.js +0 -25
  381. package/static/dashboard/assets/SearchIndexingPanel-Dh70PNFZ.js +0 -1
  382. package/static/dashboard/assets/SystemSettingsPage-BiN5GcKx.js +0 -1
  383. package/static/dashboard/assets/SystemSettingsSubjectPanel-B9QrSiFp.js +0 -31
  384. package/static/dashboard/assets/admin-BU4m6Ko2.js +0 -1
  385. package/static/dashboard/assets/ai-connections-CHNTKemd.js +0 -1
  386. package/static/dashboard/assets/dashboard-C_7MUXJb.css +0 -1
  387. package/static/dashboard/assets/index-FWZ-s52O.js +0 -41
  388. package/static/dashboard/assets/index-ZiQZ96oC.js +0 -4
  389. package/static/settings/assets/AiConfigContext-C0cQMPfG.js +0 -1
  390. package/static/settings/assets/AiConfigPage-CPhB4iFb.js +0 -1
  391. package/static/settings/assets/DocumentProcessingPanel-sYI7OpuH.js +0 -1
  392. package/static/settings/assets/IndexLifecyclePanel-yj8iyiT8.js +0 -1
  393. package/static/settings/assets/ModelAssignmentsPanel-BFIgUX5v.js +0 -1
  394. package/static/settings/assets/ModelsPage-BdppXl7E.js +0 -10
  395. package/static/settings/assets/SearchIndexingPanel-BlPnrkT3.js +0 -1
  396. package/static/settings/assets/SystemSettingsPage-CiOm2NzV.js +0 -1
  397. package/static/settings/assets/SystemSettingsSubjectPanel-Cd-GECon.js +0 -31
  398. package/static/settings/assets/admin-BU4m6Ko2.js +0 -1
  399. package/static/settings/assets/ai-connections-CHNTKemd.js +0 -1
  400. package/static/settings/assets/index-BFi9yn7_.js +0 -41
  401. package/static/settings/assets/index-BGgEhIUy.js +0 -4
  402. package/static/settings/assets/settings-C_7MUXJb.css +0 -1
@@ -1,2 +1,2 @@
1
- import{c as E,k as pe,r as d,t as B,j as e,C as N,a as w,b as k,d as C,e as S,B as y,n as se,R as xe,N as he,l as fe,m as be}from"./auth-callback-atKg_oig.js";import{P as ve}from"./PaneListHeader-jy70Q00L.js";import{N as re,W as je}from"./waypoints-VMNQlWdU.js";import{A as ie}from"./activity-BcsZZxxw.js";import{T as ge,u as ye}from"./workspace-layout-SAp6BtYK.js";import{E as Ne}from"./external-link-DZ34d3g3.js";import{B as L}from"./badge-BWbRHThQ.js";import{R as we}from"./rotate-ccw-C_L5ZLx1.js";import{D as ke}from"./download-BmvG1Vya.js";const Ce=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],Se=E("cable",Ce);const Pe=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],le=E("earth",Pe);const Re=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],De=E("lock-keyhole",Re);const Te=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Ae=E("radio",Te);const Ee=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],Le=E("route",Ee);const Ie=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Me=E("shield-check",Ie);const $e=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Oe=E("wifi",$e);async function Ue({fetchImpl:t}){return Q(t,X("/api/network/settings/status"),{method:"GET",credentials:"include",headers:{accept:"application/json"}})}async function qe({fetchImpl:t}){return Q(t,X("/api/network/settings/diagnose"),{method:"POST",credentials:"include",headers:{accept:"application/json"}})}async function He({fetchImpl:t}){await Q(t,X("/api/network/settings/certificate/renew"),{method:"POST",credentials:"include",headers:{accept:"application/json"}})}async function ze({podUrl:t,fetchImpl:a,patch:s}){return Q(a,Ve("/api/network/settings/configuration",t),{method:"PUT",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(s)})}function X(t){const a=typeof window>"u"?"http://localhost":window.location.origin;return new URL(t,a).toString()}function Ve(t,a){return a?new URL(t,a).toString():X(t)}async function Q(t,a,s){const r=await t(a,s);if(!r.ok)throw await r.arrayBuffer(),new Error("Network settings request failed. Please try again.");if(!r.headers.get("content-type")?.includes("application/json"))throw await r.arrayBuffer(),new Error("Network settings request failed. Please try again.");return await r.json()}const te=[{id:"overview",label:"Overview",path:"",icon:re},{id:"endpoints",label:"Endpoints",path:"endpoints",icon:Se},{id:"addresses",label:"Addresses",path:"addresses",icon:le},{id:"domain-dns",label:"Domain & DNS",path:"domain-dns",icon:Le},{id:"https",label:"HTTPS",path:"https",icon:De},{id:"tunnel-profiles",label:"Tunnel Profiles",path:"tunnel-profiles",icon:je},{id:"p2p",label:"P2P",path:"p2p",icon:Ae},{id:"diagnostics",label:"Diagnostics",path:"diagnostics",icon:ie}];function Be(t){const a=["Xpod Network Diagnostics",`Generated: ${t.generatedAt}`,`Canonical URL: ${t.endpoint??"Unavailable"}`],s=t.checks.flatMap(r=>["",`[${r.status.toUpperCase()}] ${r.label}`,...r.detail?[r.detail]:[]]);return[...a,...s].join(`
2
- `)}function jt(){const t=pe(),[a,s]=d.useState(),[r,n]=d.useState([]),[l,o]=d.useState(),[x,u]=d.useState(),[P,h]=d.useState(!1),[T,$]=d.useState(!1),[i,p]=d.useState(!1),[v,R]=d.useState(!1),[_,de]=d.useState(),O=d.useRef(0),U=d.useRef(0),q=d.useRef(0),H=d.useRef(void 0),z=d.useRef(!0),F=typeof window>"u"?void 0:window.location.origin,g=F?`local-host:${F}`:void 0,D=globalThis.fetch;d.useEffect(()=>(z.current=!0,()=>{z.current=!1,O.current+=1,U.current+=1,q.current+=1}),[]);const K=d.useCallback((c,m)=>z.current&&O.current===c&&H.current===m,[]),W=d.useCallback((c,m)=>z.current&&U.current===c&&H.current===m,[]),G=d.useCallback((c,m)=>z.current&&q.current===c&&H.current===m,[]),V=d.useCallback(async()=>{const c=g;if(!c)return;const m=O.current+1;O.current=m,h(!0),u(void 0);try{const A=await Ue({fetchImpl:D});K(m,c)&&s(A)}catch{K(m,c)&&u("网络设置请求失败,请重试。")}finally{K(m,c)&&h(!1)}},[D,g,K]);d.useEffect(()=>{let c=!1;return H.current=g,O.current+=1,U.current+=1,q.current+=1,queueMicrotask(()=>{c||H.current!==g||(s(void 0),n([]),o(void 0),u(void 0),h(!1),$(!1),p(!1),g&&V())}),()=>{c=!0}},[g,V]);const ce=d.useCallback(async()=>{const c=g;if(!c)return;const m=U.current+1;U.current=m,$(!0),u(void 0);try{const A=await qe({fetchImpl:D});W(m,c)&&(n(A.checks),o(new Date),B({description:"诊断完成"}))}catch{W(m,c)&&u("网络诊断失败,请重试。")}finally{W(m,c)&&$(!1)}},[D,g,W]),ue=d.useCallback(async()=>{const c=g;if(!c)return;const m=q.current+1;q.current=m,p(!0),u(void 0);try{await He({fetchImpl:D}),G(m,c)&&(B({variant:"success",description:"证书续签成功"}),await V())}catch{G(m,c)&&u("证书续签失败,请重试。")}finally{G(m,c)&&p(!1)}},[D,g,G,V]),J=d.useCallback(async c=>{if(F){R(!0),u(void 0);try{const m=await ze({fetchImpl:D,patch:c});s(A=>A&&{...A,configuration:m.configuration}),de(m.applyState),B({variant:"success",description:"Network configuration saved"})}catch{u("网络配置保存失败,请重试。")}finally{R(!1)}}},[D,F]),me=d.useMemo(()=>[{key:"local",title:"本机",values:a?.addresses.local??[]},{key:"lan",title:"局域网",values:a?.addresses.lan??[]},{key:"public",title:"公网",values:a?.addresses.public??[]}],[a]),ne=t.pathname.split("/").filter(Boolean).at(-1),b=te.some(c=>c.path===ne)?ne:"overview";return e.jsx(ge,{mode:"auto",listHeader:e.jsx(ve,{title:"Network"}),list:e.jsx(_e,{}),mainHeader:e.jsx(Fe,{title:te.find(c=>(c.path||"overview")===b)?.label??"Overview",loading:P,stale:P&&!!a,onRefresh:V}),main:e.jsxs("section",{className:"flex min-h-full flex-col gap-4 bg-background p-6",children:[x?e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:x}):null,(b==="overview"||b==="endpoints")&&e.jsx(Ze,{endpoint:a?.endpoint,loading:P&&!a}),b==="overview"&&e.jsx(Ke,{status:a}),(b==="overview"||b==="addresses")&&e.jsx(tt,{sections:me,loading:P&&!a,diagnostics:r,checkedAt:l}),b==="overview"&&e.jsx(lt,{status:a}),b==="domain-dns"&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{status:a}),e.jsx(Ge,{configuration:a?.configuration,saving:v,applyState:_,onSave:J})]}),b==="https"&&e.jsxs(e.Fragment,{children:[e.jsx(it,{status:a}),e.jsx(Je,{configuration:a?.configuration,saving:v,applyState:_,onSave:J})]}),b==="tunnel-profiles"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{title:"Observed tunnel",label:"Tunnel",capability:a?.tunnel}),e.jsx(Xe,{configuration:a?.configuration,saving:v,applyState:_,onSave:J})]}),b==="p2p"&&e.jsx(Ye,{configuration:a?.configuration,saving:v,applyState:_,onSave:J}),(b==="overview"||b==="diagnostics"||b==="https")&&e.jsx(ot,{status:a,endpoint:a?.endpoint,diagnostics:r,diagnosing:T,renewing:i,onDiagnose:ce,onRenewCertificate:ue})]}),className:"min-h-full"})}function _e(){const t=ye();return e.jsx("aside",{className:"h-full border-r border-border bg-muted/20 py-2",children:e.jsx("nav",{"aria-label":"Network sections","data-list-navigation":!0,children:te.map(a=>{const s=a.icon,r=`/network${a.path?`/${a.path}`:""}`;return e.jsxs(he,{to:r,onClick:()=>t.openMain(),onKeyDown:fe,className:({isActive:n})=>be(n,{compact:!1}),end:a.path==="",children:[e.jsx(s,{className:"h-4 w-4","aria-hidden":"true"}),a.label]},a.id)})})})}function Fe({title:t,loading:a,stale:s,onRefresh:r}){return e.jsxs("div",{className:"flex h-full min-w-0 items-center justify-between gap-4 px-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"text-sm font-semibold text-foreground",children:["Network · ",t]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground","aria-live":"polite",children:s?"Refreshing · showing previous snapshot":"接入点、DNS、TLS、隧道与连通性诊断"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:r,disabled:a,children:[e.jsx(xe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"刷新"]})})]})}function Ke({status:t}){const a=t?.addresses.public[0]??t?.addresses.lan[0]??t?.addresses.local[0]??t?.endpoint,s=t?!t.dns.supported||t.dns.status==="unsupported"?"Configure Domain & DNS, then recheck observed DNS.":!t.tls.supported||!["valid","active","ready"].includes(t.tls.status)?"Review HTTPS configuration and certificate renewal evidence.":"No connectivity action is currently required.":"Refresh network status.";return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:"Recommended access path"}),e.jsx(C,{children:"Chosen from observed public, LAN, then local reachability"})]}),e.jsxs(S,{className:"space-y-3 text-sm",children:[e.jsx("div",{className:"break-words font-medium",children:a??"Unavailable"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[e.jsxs(L,{variant:"outline",children:["Local ",t?.addresses.local.length?"available":"unavailable"]}),e.jsxs(L,{variant:"outline",children:["LAN ",t?.addresses.lan.length?"available":"unavailable"]}),e.jsxs(L,{variant:"outline",children:["Public ",t?.addresses.public.length?"available":"unavailable"]}),e.jsxs(L,{variant:"outline",children:["Tunnel ",t?.tunnel.status??"unknown"]})]}),e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-3",children:[e.jsx("div",{className:"font-medium",children:"Next action"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:s})]})]})]})}function We({title:t,label:a,capability:s,extra:r}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:t}),e.jsx(C,{children:"Observed runtime state"})]}),e.jsx(S,{children:e.jsx(M,{label:a,capability:s,extra:r})})]})}function Y({title:t}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:t}),e.jsx(C,{children:"Desired configuration"})]}),e.jsxs(S,{className:"text-sm text-muted-foreground",children:["This runtime does not report a configurable ",t," capability."]})]})}function Ge({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.domainDns),[o,x]=d.useState("");return d.useEffect(()=>{let u=!1;return queueMicrotask(()=>{u||l(t?.domainDns)}),()=>{u=!0}},[t]),n?e.jsxs(Z,{title:"Saved configuration",applyState:s,children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(j,{name:"domain",label:"Domain",value:n.domain,onChange:u=>l({...n,domain:u})}),e.jsx(j,{name:"provider",label:"DNS provider",value:n.provider,onChange:u=>l({...n,provider:u})}),e.jsx(oe,{name:"recordTtl",label:"Record TTL (seconds)",value:n.recordTtl,min:30,max:86400,onChange:u=>l({...n,recordTtl:u})}),e.jsx(j,{name:"dnsCredential",label:n.credentialConfigured?"Replace credential (configured)":"Credential",value:o,type:"password",onChange:x})]}),e.jsx(ae,{label:"Enable DDNS",checked:n.ddnsEnabled,onChange:u=>l({...n,ddnsEnabled:u})}),e.jsx(ee,{label:"Save DNS configuration",saving:a,onClick:()=>r({domainDns:{domain:n.domain,ddnsEnabled:n.ddnsEnabled,provider:n.provider,recordTtl:n.recordTtl,...o?{credential:o}:{}}})})]}):e.jsx(Y,{title:"Domain & DNS"})}function Je({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.https);return d.useEffect(()=>{let o=!1;return queueMicrotask(()=>{o||l(t?.https)}),()=>{o=!0}},[t]),n?e.jsxs(Z,{title:"Saved configuration",applyState:s,children:[e.jsx(ae,{label:"Enable HTTPS",checked:n.enabled,onChange:o=>l({...n,enabled:o})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(j,{name:"acmeEmail",label:"ACME email",value:n.acmeEmail,onChange:o=>l({...n,acmeEmail:o})}),e.jsx(j,{name:"acmeDomains",label:"Certificate domains",value:n.domains.join(", "),onChange:o=>l({...n,domains:o.split(",").map(x=>x.trim()).filter(Boolean)})}),e.jsx(j,{name:"certificatePath",label:"Certificate path",value:n.certificatePath??"",onChange:o=>l({...n,certificatePath:o})}),e.jsx(j,{name:"certificateKeyPath",label:"Private-key path",value:n.certificateKeyPath??"",onChange:o=>l({...n,certificateKeyPath:o})}),e.jsx(oe,{name:"renewBeforeDays",label:"Renew before (days)",value:n.renewBeforeDays,min:1,max:90,onChange:o=>l({...n,renewBeforeDays:o})})]}),e.jsx(ee,{label:"Save HTTPS configuration",saving:a,onClick:()=>r({https:n})})]}):e.jsx(Y,{title:"HTTPS"})}function Xe({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.tunnelProfiles.activeProfileId??""),[o,x]=d.useState(t?.tunnelProfiles.profiles??[]),[u,P]=d.useState({});if(d.useEffect(()=>{let i=!1;return queueMicrotask(()=>{i||(l(t?.tunnelProfiles.activeProfileId??""),x(t?.tunnelProfiles.profiles??[]),P({}))}),()=>{i=!0}},[t]),!t)return e.jsx(Y,{title:"Tunnel Profiles"});const h=(i,p)=>x(v=>v.map(R=>R.id===i?{...R,...p}:R)),T=()=>{const i=`tunnel-${Date.now()}`;x(p=>[...p,{id:i,provider:"ngrok",label:"New tunnel",credentialConfigured:!1,parameters:{}}])},$=i=>{x(p=>p.filter(v=>v.id!==i)),n===i&&l("")};return e.jsxs(Z,{title:"Saved tunnel profiles",applyState:s,children:[e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Active profile",e.jsxs("select",{value:n,onChange:i=>l(i.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 sm:max-w-sm",children:[e.jsx("option",{value:"",children:"None"}),o.map(i=>e.jsxs("option",{value:i.id,children:[i.label," · ",i.provider]},i.id))]})]}),e.jsx("div",{className:"space-y-3",children:o.map(i=>e.jsxs("div",{className:"space-y-3 rounded-md border border-border p-3 text-sm",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(j,{name:`tunnel-label-${i.id}`,label:"Label",value:i.label,onChange:p=>h(i.id,{label:p})}),e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Provider",e.jsxs("select",{value:i.provider,onChange:p=>h(i.id,{provider:p.target.value,parameters:{}}),className:"block h-10 w-full rounded-md border border-input bg-background px-3",children:[e.jsx("option",{value:"ngrok",children:"ngrok"}),e.jsx("option",{value:"cloudflare",children:"Cloudflare"}),e.jsx("option",{value:"frp",children:"frp"})]})]}),e.jsx(j,{name:`tunnel-url-${i.id}`,label:"Public endpoint",value:i.publicEndpoint??"",onChange:p=>h(i.id,{publicEndpoint:p})}),e.jsx(j,{name:`tunnel-credential-${i.id}`,label:i.credentialConfigured?"Replace credential (configured)":"Credential",type:"password",value:u[i.id]??"",onChange:p=>P(v=>({...v,[i.id]:p}))})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"cursor-pointer font-medium",children:"Provider-specific parameters"}),e.jsx("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:Qe(i.provider).map(({key:p,label:v})=>e.jsx(j,{name:`tunnel-${p}-${i.id}`,label:v,value:i.parameters?.[p]??"",onChange:R=>h(i.id,{parameters:{...i.parameters,[p]:R}})},p))})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n===i.id?"Active after restart":"Inactive"," · credential ",i.credentialConfigured?"configured":"missing"]}),e.jsx(y,{type:"button",size:"sm",variant:"ghost",onClick:()=>$(i.id),children:"Remove"})]})]},i.id))}),e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:T,children:"Add tunnel profile"}),e.jsx(ee,{label:"Save tunnel profiles",saving:a,onClick:()=>r({tunnelProfiles:{activeProfileId:n,profiles:o.map(i=>({id:i.id,provider:i.provider,label:i.label,publicEndpoint:i.publicEndpoint,parameters:i.parameters,...u[i.id]?{credential:u[i.id]}:{}}))}})})]})}function Qe(t){return t==="ngrok"?[{key:"region",label:"Region"},{key:"hostname",label:"Reserved hostname"}]:t==="cloudflare"?[{key:"tunnelId",label:"Tunnel ID"},{key:"hostname",label:"Hostname"}]:[{key:"serverHost",label:"Server host"},{key:"serverPort",label:"Server port"},{key:"remotePort",label:"Remote port"}]}function Ye({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.p2p);return d.useEffect(()=>{let o=!1;return queueMicrotask(()=>{o||l(t?.p2p)}),()=>{o=!0}},[t]),n?e.jsxs(Z,{title:"Saved P2P configuration",applyState:s,children:[e.jsx(ae,{label:"Enable P2P fallback",checked:n.enabled,onChange:o=>l({...n,enabled:o})}),e.jsx(j,{name:"signalService",label:"Signal service",value:n.signalService,onChange:o=>l({...n,signalService:o})}),e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Fallback policy",e.jsxs("select",{value:n.fallbackPolicy,onChange:o=>l({...n,fallbackPolicy:o.target.value}),className:"block h-10 w-full rounded-md border border-input bg-background px-3 sm:max-w-sm",children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"when-direct-unavailable",children:"When direct is unavailable"}),e.jsx("option",{value:"prefer-p2p",children:"Prefer P2P"})]})]}),e.jsx(ee,{label:"Save P2P configuration",saving:a,onClick:()=>r({p2p:n})})]}):e.jsx(Y,{title:"P2P"})}function Z({title:t,applyState:a,children:s}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:t}),e.jsx(C,{children:"Desired configuration · not presented as observed until verified"})]}),e.jsxs(S,{className:"space-y-4",children:[a==="restart-required"?e.jsx("div",{role:"status",className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-200",children:"Saved · restart required"}):null,s]})]})}function j({name:t,label:a,value:s,type:r="text",onChange:n}){return e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[a,e.jsx("input",{name:t,type:r,value:s,onChange:l=>n(l.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm"})]})}function oe({name:t,label:a,value:s,min:r,max:n,onChange:l}){return e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[a,e.jsx("input",{name:t,type:"number",value:s,min:r,max:n,onChange:o=>l(o.target.valueAsNumber),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm"})]})}function ae({label:t,checked:a,onChange:s}){return e.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-md border border-border p-3 text-sm font-medium",children:[t,e.jsx("input",{type:"checkbox",checked:a,onChange:r=>s(r.target.checked)})]})}function ee({label:t,saving:a,onClick:s}){return e.jsx("div",{className:"flex justify-end",children:e.jsx(y,{type:"button",onClick:s,disabled:a,children:a?"Saving…":t})})}function Ze({endpoint:t,loading:a}){const s=[{label:"Canonical URL",value:t},{label:"API endpoint",value:t?et(t,"/api/"):void 0}],r=async(n,l)=>{await window.navigator.clipboard.writeText(l),B({description:`${n} copied`})};return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(le,{className:"h-4 w-4","aria-hidden":"true"}),"接入点"]}),e.jsx(C,{children:a?"正在解析接入点":"Observed endpoints · Currently effective route is the canonical URL"})]}),e.jsx(S,{className:"space-y-3",children:s.map(({label:n,value:l})=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:n}),e.jsx("div",{className:"mt-1 break-words text-sm text-foreground",children:l||"Unavailable"})]}),l?e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx(y,{type:"button",size:"icon",variant:"ghost","aria-label":`Copy ${n}`,onClick:()=>{r(n,l)},children:e.jsx(se,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(y,{type:"button",size:"icon",variant:"ghost","aria-label":`Open ${n}`,onClick:()=>window.open(l,"_blank","noopener,noreferrer"),children:e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"})})]}):null]},n))})]})}function et(t,a){try{return new URL(a,t).toString()}catch{return t}}function tt({sections:t,loading:a,diagnostics:s,checkedAt:r}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(Oe,{className:"h-4 w-4","aria-hidden":"true"}),"网络地址"]}),e.jsx(C,{children:a?"正在刷新地址":"由运行时网络能力上报"})]}),e.jsx(S,{className:"space-y-4",children:t.map(n=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:n.title}),n.values.length>0?e.jsx("div",{className:"mt-1 space-y-1",children:n.values.map(l=>e.jsx(at,{scope:n.key,value:l,diagnostics:s,checkedAt:r},l))}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"未提供"})]},n.key))})]})}function at({scope:t,value:a,diagnostics:s,checkedAt:r}){const n=nt(a),l=s.find(o=>o.id==="endpoint");return e.jsxs("div",{className:"rounded-md border border-border p-3 text-sm",children:[e.jsx("div",{className:"break-words font-medium text-foreground",children:a}),e.jsxs("dl",{className:"mt-2 grid gap-x-4 gap-y-1 text-xs sm:grid-cols-2",children:[e.jsx(f,{label:"Interface",value:t==="local"?"Loopback":t==="lan"?"LAN interface (name not reported)":"Public route"}),e.jsx(f,{label:"IP version",value:n.ipVersion}),e.jsx(f,{label:"Port",value:n.port}),e.jsx(f,{label:"Reachability",value:l?st(l.status):"Not checked"}),e.jsx(f,{label:"Latency",value:l?.durationMs==null?"Not checked":`${l.durationMs} ms`}),e.jsx(f,{label:"Last checked",value:l?.checkedAt?I(l.checkedAt):r?r.toLocaleString():"Not checked"})]})]})}function f({label:t,value:a}){return e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:t}),e.jsx("dd",{className:"text-right text-foreground",children:a})]})}function nt(t){try{const a=new URL(t),s=a.hostname.replace(/^\[|\]$/g,"");return{ipVersion:s.includes(":")?"IPv6":/^\d{1,3}(?:\.\d{1,3}){3}$/.test(s)?"IPv4":"Resolved hostname",port:a.port||(a.protocol==="https:"?"443":a.protocol==="http:"?"80":"Not reported")}}catch{return{ipVersion:"Not reported",port:"Not reported"}}}function st(t){return t==="ok"?"Reachable":t==="warning"?"Warning":t==="error"?"Unreachable":"Unsupported"}function rt({status:t}){const a=t?.configuration?.domainDns,s=(t?.addresses.public??[]).map(r=>{try{return new URL(r).hostname}catch{return r}});return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:"Observed DNS"}),e.jsx(C,{children:"Observed state is kept separate from desired DNS policy."})]}),e.jsxs(S,{className:"space-y-3",children:[e.jsx(M,{label:"Runtime status",capability:t?.dns}),e.jsxs("dl",{className:"grid gap-2 text-sm sm:grid-cols-2",children:[e.jsx(f,{label:"Observed hostnames",value:s.join(", ")||"Not reported"}),e.jsx(f,{label:"Expected domain",value:a?.domain||"Not configured"}),e.jsx(f,{label:"Expected value",value:t?.addresses.public[0]||"Not reported"}),e.jsx(f,{label:"Provider",value:a?.provider||"Not configured"})]})]})]})}function it({status:t}){const a=t?.configuration?.https;return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:"Observed HTTPS"}),e.jsx(C,{children:"Certificate evidence reported by the active runtime."})]}),e.jsxs(S,{className:"space-y-3",children:[e.jsx(M,{label:"TLS",capability:t?.tls,extra:t?.tls.expiresAt?`Expires ${I(t.tls.expiresAt)}`:void 0}),e.jsxs("dl",{className:"grid gap-2 text-sm sm:grid-cols-2",children:[e.jsx(f,{label:"Certificate domains",value:t?.tls.domains?.join(", ")||a?.domains.join(", ")||"Not reported"}),e.jsx(f,{label:"Issuer",value:t?.tls.issuer||"Not reported by runtime"}),e.jsx(f,{label:"Validity",value:t?.tls.validFrom?`${I(t.tls.validFrom)} — ${t.tls.expiresAt?I(t.tls.expiresAt):"open"}`:t?.tls.status??"Not reported"}),e.jsx(f,{label:"Expiry",value:t?.tls.expiresAt?I(t.tls.expiresAt):"Not reported"}),e.jsx(f,{label:"Renewal status",value:t?.tls.renewalStatus||(t?.actions.renewCertificate?"Renewal available":"Renewal unavailable")}),e.jsx(f,{label:"Renewal policy",value:a?`${a.renewBeforeDays} days before expiry`:"Not configured"})]})]})]})}function lt({status:t}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(re,{className:"h-4 w-4","aria-hidden":"true"}),"网络能力"]}),e.jsx(C,{children:"服务端声明的网络支持"})]}),e.jsxs(S,{className:"grid gap-3 text-sm",children:[e.jsx(M,{label:"TLS",capability:t?.tls,extra:t?.tls.expiresAt?`到期时间 ${I(t.tls.expiresAt)}`:void 0}),e.jsx(M,{label:"DNS",capability:t?.dns}),e.jsx(M,{label:"Tunnel",capability:t?.tunnel})]})]})}function ot({status:t,endpoint:a,diagnostics:s,diagnosing:r,renewing:n,onDiagnose:l,onRenewCertificate:o}){const x=s.length>0?Be({generatedAt:new Date().toISOString(),endpoint:a,checks:s}):void 0,u=async()=>{x&&(await window.navigator.clipboard.writeText(x),B({description:"Diagnostic report copied"}))},P=()=>{if(!x)return;const h=URL.createObjectURL(new Blob([x],{type:"text/plain;charset=utf-8"})),T=document.createElement("a");T.href=h,T.download=`xpod-network-diagnostics-${new Date().toISOString().replace(/[:.]/g,"-")}.txt`,T.click(),URL.revokeObjectURL(h)};return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"}),"操作"]}),e.jsx(C,{children:"仅显示网络能力允许的操作"})]}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t?.actions.diagnose?e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:l,disabled:r,children:[e.jsx(Me,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"连通性诊断"]}):null,t?.actions.renewCertificate?e.jsxs(y,{type:"button",size:"sm",variant:"subtle",onClick:o,disabled:n,children:[e.jsx(we,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"续签证书"]}):null,e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:()=>{u()},disabled:!x,children:[e.jsx(se,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Copy diagnostics"]}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:P,disabled:!x,children:[e.jsx(ke,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Export diagnostics"]})]}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(h=>e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:h.label}),e.jsx(L,{variant:h.status==="ok"?"secondary":"outline",children:h.status})]}),h.detail?e.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:h.detail}):null]},h.id))}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"尚未运行过诊断。"})]})]})}function M({label:t,capability:a,extra:s}){const r=a?.supported===!0;return e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:r?t:`${t} 不支持`}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a?.status??"读取中"})]}),e.jsx(L,{variant:r?"secondary":"outline",children:r?"支持":"不支持"})]}),s?e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:s}):null]})}function I(t){if(!t)return"暂无记录";const a=new Date(t);return Number.isNaN(a.getTime())?"暂无记录":a.toLocaleString()}export{jt as default};
1
+ import{c as E,v as pe,r as d,Y as B,j as e,C as N,a as w,b as k,d as C,e as S,B as y,Z as se,R as xe,N as he,w as fe,x as be}from"./auth-callback-CAFZ3R0B.js";import{P as ve}from"./PaneListHeader-QQeJGTp4.js";import{N as re,W as je}from"./waypoints-Bj6gAUSQ.js";import{A as ie}from"./activity-5hNeNKnL.js";import{T as ge,u as ye}from"./workspace-layout-DK8mDzrY.js";import{E as Ne}from"./external-link-BTXgSPzB.js";import{B as L}from"./badge-CAIPI0CB.js";import{R as we}from"./rotate-ccw-C1zM2KtS.js";import{D as ke}from"./download-B3Up5W2G.js";const Ce=[["path",{d:"M17 19a1 1 0 0 1-1-1v-2a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2a1 1 0 0 1-1 1z",key:"trhst0"}],["path",{d:"M17 21v-2",key:"ds4u3f"}],["path",{d:"M19 14V6.5a1 1 0 0 0-7 0v11a1 1 0 0 1-7 0V10",key:"1mo9zo"}],["path",{d:"M21 21v-2",key:"eo0ou"}],["path",{d:"M3 5V3",key:"1k5hjh"}],["path",{d:"M4 10a2 2 0 0 1-2-2V6a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2z",key:"1dd30t"}],["path",{d:"M7 5V3",key:"1t1388"}]],Se=E("cable",Ce);const Pe=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],le=E("earth",Pe);const Re=[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]],De=E("lock-keyhole",Re);const Te=[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],Ae=E("radio",Te);const Ee=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],Le=E("route",Ee);const Ie=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Me=E("shield-check",Ie);const $e=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],Oe=E("wifi",$e);async function Ue({fetchImpl:t}){return Y(t,X("/api/network/settings/status"),{method:"GET",credentials:"include",headers:{accept:"application/json"}})}async function qe({fetchImpl:t}){return Y(t,X("/api/network/settings/diagnose"),{method:"POST",credentials:"include",headers:{accept:"application/json"}})}async function He({fetchImpl:t}){await Y(t,X("/api/network/settings/certificate/renew"),{method:"POST",credentials:"include",headers:{accept:"application/json"}})}async function ze({podUrl:t,fetchImpl:a,patch:s}){return Y(a,Ve("/api/network/settings/configuration",t),{method:"PUT",credentials:"include",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify(s)})}function X(t){const a=typeof window>"u"?"http://localhost":window.location.origin;return new URL(t,a).toString()}function Ve(t,a){return a?new URL(t,a).toString():X(t)}async function Y(t,a,s){const r=await t(a,s);if(!r.ok)throw await r.arrayBuffer(),new Error("Network settings request failed. Please try again.");if(!r.headers.get("content-type")?.includes("application/json"))throw await r.arrayBuffer(),new Error("Network settings request failed. Please try again.");return await r.json()}const te=[{id:"overview",label:"Overview",path:"",icon:re},{id:"endpoints",label:"Endpoints",path:"endpoints",icon:Se},{id:"addresses",label:"Addresses",path:"addresses",icon:le},{id:"domain-dns",label:"Domain & DNS",path:"domain-dns",icon:Le},{id:"https",label:"HTTPS",path:"https",icon:De},{id:"tunnel-profiles",label:"Tunnel Profiles",path:"tunnel-profiles",icon:je},{id:"p2p",label:"P2P",path:"p2p",icon:Ae},{id:"diagnostics",label:"Diagnostics",path:"diagnostics",icon:ie}];function Be(t){const a=["Xpod Network Diagnostics",`Generated: ${t.generatedAt}`,`Canonical URL: ${t.endpoint??"Unavailable"}`],s=t.checks.flatMap(r=>["",`[${r.status.toUpperCase()}] ${r.label}`,...r.detail?[r.detail]:[]]);return[...a,...s].join(`
2
+ `)}function jt(){const t=pe(),[a,s]=d.useState(),[r,n]=d.useState([]),[l,o]=d.useState(),[x,u]=d.useState(),[P,h]=d.useState(!1),[T,$]=d.useState(!1),[i,p]=d.useState(!1),[v,R]=d.useState(!1),[_,de]=d.useState(),O=d.useRef(0),U=d.useRef(0),q=d.useRef(0),H=d.useRef(void 0),z=d.useRef(!0),F=typeof window>"u"?void 0:window.location.origin,g=F?`local-host:${F}`:void 0,D=globalThis.fetch;d.useEffect(()=>(z.current=!0,()=>{z.current=!1,O.current+=1,U.current+=1,q.current+=1}),[]);const K=d.useCallback((c,m)=>z.current&&O.current===c&&H.current===m,[]),W=d.useCallback((c,m)=>z.current&&U.current===c&&H.current===m,[]),G=d.useCallback((c,m)=>z.current&&q.current===c&&H.current===m,[]),V=d.useCallback(async()=>{const c=g;if(!c)return;const m=O.current+1;O.current=m,h(!0),u(void 0);try{const A=await Ue({fetchImpl:D});K(m,c)&&s(A)}catch{K(m,c)&&u("网络设置请求失败,请重试。")}finally{K(m,c)&&h(!1)}},[D,g,K]);d.useEffect(()=>{let c=!1;return H.current=g,O.current+=1,U.current+=1,q.current+=1,queueMicrotask(()=>{c||H.current!==g||(s(void 0),n([]),o(void 0),u(void 0),h(!1),$(!1),p(!1),g&&V())}),()=>{c=!0}},[g,V]);const ce=d.useCallback(async()=>{const c=g;if(!c)return;const m=U.current+1;U.current=m,$(!0),u(void 0);try{const A=await qe({fetchImpl:D});W(m,c)&&(n(A.checks),o(new Date),B({description:"诊断完成"}))}catch{W(m,c)&&u("网络诊断失败,请重试。")}finally{W(m,c)&&$(!1)}},[D,g,W]),ue=d.useCallback(async()=>{const c=g;if(!c)return;const m=q.current+1;q.current=m,p(!0),u(void 0);try{await He({fetchImpl:D}),G(m,c)&&(B({variant:"success",description:"证书续签成功"}),await V())}catch{G(m,c)&&u("证书续签失败,请重试。")}finally{G(m,c)&&p(!1)}},[D,g,G,V]),J=d.useCallback(async c=>{if(F){R(!0),u(void 0);try{const m=await ze({fetchImpl:D,patch:c});s(A=>A&&{...A,configuration:m.configuration}),de(m.applyState),B({variant:"success",description:"Network configuration saved"})}catch{u("网络配置保存失败,请重试。")}finally{R(!1)}}},[D,F]),me=d.useMemo(()=>[{key:"local",title:"本机",values:a?.addresses.local??[]},{key:"lan",title:"局域网",values:a?.addresses.lan??[]},{key:"public",title:"公网",values:a?.addresses.public??[]}],[a]),ne=t.pathname.split("/").filter(Boolean).at(-1),b=te.some(c=>c.path===ne)?ne:"overview";return e.jsx(ge,{mode:"auto",listHeader:e.jsx(ve,{title:"Network"}),list:e.jsx(_e,{}),mainHeader:e.jsx(Fe,{title:te.find(c=>(c.path||"overview")===b)?.label??"Overview",loading:P,stale:P&&!!a,onRefresh:V}),main:e.jsxs("section",{className:"flex min-h-full flex-col gap-4 bg-background p-6",children:[x?e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 bg-destructive/10 px-4 py-3 text-sm text-destructive",children:x}):null,(b==="overview"||b==="endpoints")&&e.jsx(Qe,{endpoint:a?.endpoint,loading:P&&!a}),b==="overview"&&e.jsx(Ke,{status:a}),(b==="overview"||b==="addresses")&&e.jsx(tt,{sections:me,loading:P&&!a,diagnostics:r,checkedAt:l}),b==="overview"&&e.jsx(lt,{status:a}),b==="domain-dns"&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{status:a}),e.jsx(Ge,{configuration:a?.configuration,saving:v,applyState:_,onSave:J})]}),b==="https"&&e.jsxs(e.Fragment,{children:[e.jsx(it,{status:a}),e.jsx(Je,{configuration:a?.configuration,saving:v,applyState:_,onSave:J})]}),b==="tunnel-profiles"&&e.jsxs(e.Fragment,{children:[e.jsx(We,{title:"Observed tunnel",label:"Tunnel",capability:a?.tunnel}),e.jsx(Xe,{configuration:a?.configuration,saving:v,applyState:_,onSave:J})]}),b==="p2p"&&e.jsx(Ze,{configuration:a?.configuration,saving:v,applyState:_,onSave:J}),(b==="overview"||b==="diagnostics"||b==="https")&&e.jsx(ot,{status:a,endpoint:a?.endpoint,diagnostics:r,diagnosing:T,renewing:i,onDiagnose:ce,onRenewCertificate:ue})]}),className:"min-h-full"})}function _e(){const t=ye();return e.jsx("aside",{className:"h-full border-r border-border bg-muted/20 py-2",children:e.jsx("nav",{"aria-label":"Network sections","data-list-navigation":!0,children:te.map(a=>{const s=a.icon,r=`/network${a.path?`/${a.path}`:""}`;return e.jsxs(he,{to:r,onClick:()=>t.openMain(),onKeyDown:fe,className:({isActive:n})=>be(n,{compact:!1}),end:a.path==="",children:[e.jsx(s,{className:"h-4 w-4","aria-hidden":"true"}),a.label]},a.id)})})})}function Fe({title:t,loading:a,stale:s,onRefresh:r}){return e.jsxs("div",{className:"flex h-full min-w-0 items-center justify-between gap-4 px-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h1",{className:"text-sm font-semibold text-foreground",children:["Network · ",t]}),e.jsx("div",{className:"truncate text-xs text-muted-foreground","aria-live":"polite",children:s?"Refreshing · showing previous snapshot":"接入点、DNS、TLS、隧道与连通性诊断"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:r,disabled:a,children:[e.jsx(xe,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"刷新"]})})]})}function Ke({status:t}){const a=t?.addresses.public[0]??t?.addresses.lan[0]??t?.addresses.local[0]??t?.endpoint,s=t?!t.dns.supported||t.dns.status==="unsupported"?"Configure Domain & DNS, then recheck observed DNS.":!t.tls.supported||!["valid","active","ready"].includes(t.tls.status)?"Review HTTPS configuration and certificate renewal evidence.":"No connectivity action is currently required.":"Refresh network status.";return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:"Recommended access path"}),e.jsx(C,{children:"Chosen from observed public, LAN, then local reachability"})]}),e.jsxs(S,{className:"space-y-3 text-sm",children:[e.jsx("div",{className:"break-words font-medium",children:a??"Unavailable"}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-4",children:[e.jsxs(L,{variant:"outline",children:["Local ",t?.addresses.local.length?"available":"unavailable"]}),e.jsxs(L,{variant:"outline",children:["LAN ",t?.addresses.lan.length?"available":"unavailable"]}),e.jsxs(L,{variant:"outline",children:["Public ",t?.addresses.public.length?"available":"unavailable"]}),e.jsxs(L,{variant:"outline",children:["Tunnel ",t?.tunnel.status??"unknown"]})]}),e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-3",children:[e.jsx("div",{className:"font-medium",children:"Next action"}),e.jsx("div",{className:"mt-1 text-muted-foreground",children:s})]})]})]})}function We({title:t,label:a,capability:s,extra:r}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:t}),e.jsx(C,{children:"Observed runtime state"})]}),e.jsx(S,{children:e.jsx(M,{label:a,capability:s,extra:r})})]})}function Z({title:t}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:t}),e.jsx(C,{children:"Desired configuration"})]}),e.jsxs(S,{className:"text-sm text-muted-foreground",children:["This runtime does not report a configurable ",t," capability."]})]})}function Ge({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.domainDns),[o,x]=d.useState("");return d.useEffect(()=>{let u=!1;return queueMicrotask(()=>{u||l(t?.domainDns)}),()=>{u=!0}},[t]),n?e.jsxs(Q,{title:"Saved configuration",applyState:s,children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(j,{name:"domain",label:"Domain",value:n.domain,onChange:u=>l({...n,domain:u})}),e.jsx(j,{name:"provider",label:"DNS provider",value:n.provider,onChange:u=>l({...n,provider:u})}),e.jsx(oe,{name:"recordTtl",label:"Record TTL (seconds)",value:n.recordTtl,min:30,max:86400,onChange:u=>l({...n,recordTtl:u})}),e.jsx(j,{name:"dnsCredential",label:n.credentialConfigured?"Replace credential (configured)":"Credential",value:o,type:"password",onChange:x})]}),e.jsx(ae,{label:"Enable DDNS",checked:n.ddnsEnabled,onChange:u=>l({...n,ddnsEnabled:u})}),e.jsx(ee,{label:"Save DNS configuration",saving:a,onClick:()=>r({domainDns:{domain:n.domain,ddnsEnabled:n.ddnsEnabled,provider:n.provider,recordTtl:n.recordTtl,...o?{credential:o}:{}}})})]}):e.jsx(Z,{title:"Domain & DNS"})}function Je({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.https);return d.useEffect(()=>{let o=!1;return queueMicrotask(()=>{o||l(t?.https)}),()=>{o=!0}},[t]),n?e.jsxs(Q,{title:"Saved configuration",applyState:s,children:[e.jsx(ae,{label:"Enable HTTPS",checked:n.enabled,onChange:o=>l({...n,enabled:o})}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsx(j,{name:"acmeEmail",label:"ACME email",value:n.acmeEmail,onChange:o=>l({...n,acmeEmail:o})}),e.jsx(j,{name:"acmeDomains",label:"Certificate domains",value:n.domains.join(", "),onChange:o=>l({...n,domains:o.split(",").map(x=>x.trim()).filter(Boolean)})}),e.jsx(j,{name:"certificatePath",label:"Certificate path",value:n.certificatePath??"",onChange:o=>l({...n,certificatePath:o})}),e.jsx(j,{name:"certificateKeyPath",label:"Private-key path",value:n.certificateKeyPath??"",onChange:o=>l({...n,certificateKeyPath:o})}),e.jsx(oe,{name:"renewBeforeDays",label:"Renew before (days)",value:n.renewBeforeDays,min:1,max:90,onChange:o=>l({...n,renewBeforeDays:o})})]}),e.jsx(ee,{label:"Save HTTPS configuration",saving:a,onClick:()=>r({https:n})})]}):e.jsx(Z,{title:"HTTPS"})}function Xe({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.tunnelProfiles.activeProfileId??""),[o,x]=d.useState(t?.tunnelProfiles.profiles??[]),[u,P]=d.useState({});if(d.useEffect(()=>{let i=!1;return queueMicrotask(()=>{i||(l(t?.tunnelProfiles.activeProfileId??""),x(t?.tunnelProfiles.profiles??[]),P({}))}),()=>{i=!0}},[t]),!t)return e.jsx(Z,{title:"Tunnel Profiles"});const h=(i,p)=>x(v=>v.map(R=>R.id===i?{...R,...p}:R)),T=()=>{const i=`tunnel-${Date.now()}`;x(p=>[...p,{id:i,provider:"ngrok",label:"New tunnel",credentialConfigured:!1,parameters:{}}])},$=i=>{x(p=>p.filter(v=>v.id!==i)),n===i&&l("")};return e.jsxs(Q,{title:"Saved tunnel profiles",applyState:s,children:[e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Active profile",e.jsxs("select",{value:n,onChange:i=>l(i.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 sm:max-w-sm",children:[e.jsx("option",{value:"",children:"None"}),o.map(i=>e.jsxs("option",{value:i.id,children:[i.label," · ",i.provider]},i.id))]})]}),e.jsx("div",{className:"space-y-3",children:o.map(i=>e.jsxs("div",{className:"space-y-3 rounded-md border border-border p-3 text-sm",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsx(j,{name:`tunnel-label-${i.id}`,label:"Label",value:i.label,onChange:p=>h(i.id,{label:p})}),e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Provider",e.jsxs("select",{value:i.provider,onChange:p=>h(i.id,{provider:p.target.value,parameters:{}}),className:"block h-10 w-full rounded-md border border-input bg-background px-3",children:[e.jsx("option",{value:"ngrok",children:"ngrok"}),e.jsx("option",{value:"cloudflare",children:"Cloudflare"}),e.jsx("option",{value:"frp",children:"frp"})]})]}),e.jsx(j,{name:`tunnel-url-${i.id}`,label:"Public endpoint",value:i.publicEndpoint??"",onChange:p=>h(i.id,{publicEndpoint:p})}),e.jsx(j,{name:`tunnel-credential-${i.id}`,label:i.credentialConfigured?"Replace credential (configured)":"Credential",type:"password",value:u[i.id]??"",onChange:p=>P(v=>({...v,[i.id]:p}))})]}),e.jsxs("details",{children:[e.jsx("summary",{className:"cursor-pointer font-medium",children:"Provider-specific parameters"}),e.jsx("div",{className:"mt-3 grid gap-3 sm:grid-cols-2",children:Ye(i.provider).map(({key:p,label:v})=>e.jsx(j,{name:`tunnel-${p}-${i.id}`,label:v,value:i.parameters?.[p]??"",onChange:R=>h(i.id,{parameters:{...i.parameters,[p]:R}})},p))})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n===i.id?"Active after restart":"Inactive"," · credential ",i.credentialConfigured?"configured":"missing"]}),e.jsx(y,{type:"button",size:"sm",variant:"ghost",onClick:()=>$(i.id),children:"Remove"})]})]},i.id))}),e.jsx(y,{type:"button",size:"sm",variant:"outline",onClick:T,children:"Add tunnel profile"}),e.jsx(ee,{label:"Save tunnel profiles",saving:a,onClick:()=>r({tunnelProfiles:{activeProfileId:n,profiles:o.map(i=>({id:i.id,provider:i.provider,label:i.label,publicEndpoint:i.publicEndpoint,parameters:i.parameters,...u[i.id]?{credential:u[i.id]}:{}}))}})})]})}function Ye(t){return t==="ngrok"?[{key:"region",label:"Region"},{key:"hostname",label:"Reserved hostname"}]:t==="cloudflare"?[{key:"tunnelId",label:"Tunnel ID"},{key:"hostname",label:"Hostname"}]:[{key:"serverHost",label:"Server host"},{key:"serverPort",label:"Server port"},{key:"remotePort",label:"Remote port"}]}function Ze({configuration:t,saving:a,applyState:s,onSave:r}){const[n,l]=d.useState(t?.p2p);return d.useEffect(()=>{let o=!1;return queueMicrotask(()=>{o||l(t?.p2p)}),()=>{o=!0}},[t]),n?e.jsxs(Q,{title:"Saved P2P configuration",applyState:s,children:[e.jsx(ae,{label:"Enable P2P fallback",checked:n.enabled,onChange:o=>l({...n,enabled:o})}),e.jsx(j,{name:"signalService",label:"Signal service",value:n.signalService,onChange:o=>l({...n,signalService:o})}),e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Fallback policy",e.jsxs("select",{value:n.fallbackPolicy,onChange:o=>l({...n,fallbackPolicy:o.target.value}),className:"block h-10 w-full rounded-md border border-input bg-background px-3 sm:max-w-sm",children:[e.jsx("option",{value:"never",children:"Never"}),e.jsx("option",{value:"when-direct-unavailable",children:"When direct is unavailable"}),e.jsx("option",{value:"prefer-p2p",children:"Prefer P2P"})]})]}),e.jsx(ee,{label:"Save P2P configuration",saving:a,onClick:()=>r({p2p:n})})]}):e.jsx(Z,{title:"P2P"})}function Q({title:t,applyState:a,children:s}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:t}),e.jsx(C,{children:"Desired configuration · not presented as observed until verified"})]}),e.jsxs(S,{className:"space-y-4",children:[a==="restart-required"?e.jsx("div",{role:"status",className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-200",children:"Saved · restart required"}):null,s]})]})}function j({name:t,label:a,value:s,type:r="text",onChange:n}){return e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[a,e.jsx("input",{name:t,type:r,value:s,onChange:l=>n(l.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm"})]})}function oe({name:t,label:a,value:s,min:r,max:n,onChange:l}){return e.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[a,e.jsx("input",{name:t,type:"number",value:s,min:r,max:n,onChange:o=>l(o.target.valueAsNumber),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm"})]})}function ae({label:t,checked:a,onChange:s}){return e.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-md border border-border p-3 text-sm font-medium",children:[t,e.jsx("input",{type:"checkbox",checked:a,onChange:r=>s(r.target.checked)})]})}function ee({label:t,saving:a,onClick:s}){return e.jsx("div",{className:"flex justify-end",children:e.jsx(y,{type:"button",onClick:s,disabled:a,children:a?"Saving…":t})})}function Qe({endpoint:t,loading:a}){const s=[{label:"Canonical URL",value:t},{label:"API endpoint",value:t?et(t,"/api/"):void 0}],r=async(n,l)=>{await window.navigator.clipboard.writeText(l),B({description:`${n} copied`})};return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(le,{className:"h-4 w-4","aria-hidden":"true"}),"接入点"]}),e.jsx(C,{children:a?"正在解析接入点":"Observed endpoints · Currently effective route is the canonical URL"})]}),e.jsx(S,{className:"space-y-3",children:s.map(({label:n,value:l})=>e.jsxs("div",{className:"flex items-start justify-between gap-3 rounded-md border border-border p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:n}),e.jsx("div",{className:"mt-1 break-words text-sm text-foreground",children:l||"Unavailable"})]}),l?e.jsxs("div",{className:"flex shrink-0 gap-1",children:[e.jsx(y,{type:"button",size:"icon",variant:"ghost","aria-label":`Copy ${n}`,onClick:()=>{r(n,l)},children:e.jsx(se,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsx(y,{type:"button",size:"icon",variant:"ghost","aria-label":`Open ${n}`,onClick:()=>window.open(l,"_blank","noopener,noreferrer"),children:e.jsx(Ne,{className:"h-4 w-4","aria-hidden":"true"})})]}):null]},n))})]})}function et(t,a){try{return new URL(a,t).toString()}catch{return t}}function tt({sections:t,loading:a,diagnostics:s,checkedAt:r}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(Oe,{className:"h-4 w-4","aria-hidden":"true"}),"网络地址"]}),e.jsx(C,{children:a?"正在刷新地址":"由运行时网络能力上报"})]}),e.jsx(S,{className:"space-y-4",children:t.map(n=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:n.title}),n.values.length>0?e.jsx("div",{className:"mt-1 space-y-1",children:n.values.map(l=>e.jsx(at,{scope:n.key,value:l,diagnostics:s,checkedAt:r},l))}):e.jsx("div",{className:"mt-1 text-sm text-muted-foreground",children:"未提供"})]},n.key))})]})}function at({scope:t,value:a,diagnostics:s,checkedAt:r}){const n=nt(a),l=s.find(o=>o.id==="endpoint");return e.jsxs("div",{className:"rounded-md border border-border p-3 text-sm",children:[e.jsx("div",{className:"break-words font-medium text-foreground",children:a}),e.jsxs("dl",{className:"mt-2 grid gap-x-4 gap-y-1 text-xs sm:grid-cols-2",children:[e.jsx(f,{label:"Interface",value:t==="local"?"Loopback":t==="lan"?"LAN interface (name not reported)":"Public route"}),e.jsx(f,{label:"IP version",value:n.ipVersion}),e.jsx(f,{label:"Port",value:n.port}),e.jsx(f,{label:"Reachability",value:l?st(l.status):"Not checked"}),e.jsx(f,{label:"Latency",value:l?.durationMs==null?"Not checked":`${l.durationMs} ms`}),e.jsx(f,{label:"Last checked",value:l?.checkedAt?I(l.checkedAt):r?r.toLocaleString():"Not checked"})]})]})}function f({label:t,value:a}){return e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-muted-foreground",children:t}),e.jsx("dd",{className:"text-right text-foreground",children:a})]})}function nt(t){try{const a=new URL(t),s=a.hostname.replace(/^\[|\]$/g,"");return{ipVersion:s.includes(":")?"IPv6":/^\d{1,3}(?:\.\d{1,3}){3}$/.test(s)?"IPv4":"Resolved hostname",port:a.port||(a.protocol==="https:"?"443":a.protocol==="http:"?"80":"Not reported")}}catch{return{ipVersion:"Not reported",port:"Not reported"}}}function st(t){return t==="ok"?"Reachable":t==="warning"?"Warning":t==="error"?"Unreachable":"Unsupported"}function rt({status:t}){const a=t?.configuration?.domainDns,s=(t?.addresses.public??[]).map(r=>{try{return new URL(r).hostname}catch{return r}});return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:"Observed DNS"}),e.jsx(C,{children:"Observed state is kept separate from desired DNS policy."})]}),e.jsxs(S,{className:"space-y-3",children:[e.jsx(M,{label:"Runtime status",capability:t?.dns}),e.jsxs("dl",{className:"grid gap-2 text-sm sm:grid-cols-2",children:[e.jsx(f,{label:"Observed hostnames",value:s.join(", ")||"Not reported"}),e.jsx(f,{label:"Expected domain",value:a?.domain||"Not configured"}),e.jsx(f,{label:"Expected value",value:t?.addresses.public[0]||"Not reported"}),e.jsx(f,{label:"Provider",value:a?.provider||"Not configured"})]})]})]})}function it({status:t}){const a=t?.configuration?.https;return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsx(k,{className:"text-base",children:"Observed HTTPS"}),e.jsx(C,{children:"Certificate evidence reported by the active runtime."})]}),e.jsxs(S,{className:"space-y-3",children:[e.jsx(M,{label:"TLS",capability:t?.tls,extra:t?.tls.expiresAt?`Expires ${I(t.tls.expiresAt)}`:void 0}),e.jsxs("dl",{className:"grid gap-2 text-sm sm:grid-cols-2",children:[e.jsx(f,{label:"Certificate domains",value:t?.tls.domains?.join(", ")||a?.domains.join(", ")||"Not reported"}),e.jsx(f,{label:"Issuer",value:t?.tls.issuer||"Not reported by runtime"}),e.jsx(f,{label:"Validity",value:t?.tls.validFrom?`${I(t.tls.validFrom)} — ${t.tls.expiresAt?I(t.tls.expiresAt):"open"}`:t?.tls.status??"Not reported"}),e.jsx(f,{label:"Expiry",value:t?.tls.expiresAt?I(t.tls.expiresAt):"Not reported"}),e.jsx(f,{label:"Renewal status",value:t?.tls.renewalStatus||(t?.actions.renewCertificate?"Renewal available":"Renewal unavailable")}),e.jsx(f,{label:"Renewal policy",value:a?`${a.renewBeforeDays} days before expiry`:"Not configured"})]})]})]})}function lt({status:t}){return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(re,{className:"h-4 w-4","aria-hidden":"true"}),"网络能力"]}),e.jsx(C,{children:"服务端声明的网络支持"})]}),e.jsxs(S,{className:"grid gap-3 text-sm",children:[e.jsx(M,{label:"TLS",capability:t?.tls,extra:t?.tls.expiresAt?`到期时间 ${I(t.tls.expiresAt)}`:void 0}),e.jsx(M,{label:"DNS",capability:t?.dns}),e.jsx(M,{label:"Tunnel",capability:t?.tunnel})]})]})}function ot({status:t,endpoint:a,diagnostics:s,diagnosing:r,renewing:n,onDiagnose:l,onRenewCertificate:o}){const x=s.length>0?Be({generatedAt:new Date().toISOString(),endpoint:a,checks:s}):void 0,u=async()=>{x&&(await window.navigator.clipboard.writeText(x),B({description:"Diagnostic report copied"}))},P=()=>{if(!x)return;const h=URL.createObjectURL(new Blob([x],{type:"text/plain;charset=utf-8"})),T=document.createElement("a");T.href=h,T.download=`xpod-network-diagnostics-${new Date().toISOString().replace(/[:.]/g,"-")}.txt`,T.click(),URL.revokeObjectURL(h)};return e.jsxs(N,{children:[e.jsxs(w,{children:[e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"}),"操作"]}),e.jsx(C,{children:"仅显示网络能力允许的操作"})]}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[t?.actions.diagnose?e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:l,disabled:r,children:[e.jsx(Me,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"连通性诊断"]}):null,t?.actions.renewCertificate?e.jsxs(y,{type:"button",size:"sm",variant:"subtle",onClick:o,disabled:n,children:[e.jsx(we,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"续签证书"]}):null,e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:()=>{u()},disabled:!x,children:[e.jsx(se,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Copy diagnostics"]}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",onClick:P,disabled:!x,children:[e.jsx(ke,{className:"mr-2 h-4 w-4","aria-hidden":"true"}),"Export diagnostics"]})]}),s.length>0?e.jsx("div",{className:"space-y-2",children:s.map(h=>e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:h.label}),e.jsx(L,{variant:h.status==="ok"?"secondary":"outline",children:h.status})]}),h.detail?e.jsx("div",{className:"mt-1 break-words text-xs text-muted-foreground",children:h.detail}):null]},h.id))}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"尚未运行过诊断。"})]})]})}function M({label:t,capability:a,extra:s}){const r=a?.supported===!0;return e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-foreground",children:r?t:`${t} 不支持`}),e.jsx("div",{className:"text-xs text-muted-foreground",children:a?.status??"读取中"})]}),e.jsx(L,{variant:r?"secondary":"outline",children:r?"支持":"不支持"})]}),s?e.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:s}):null]})}function I(t){if(!t)return"暂无记录";const a=new Date(t);return Number.isNaN(a.getTime())?"暂无记录":a.toLocaleString()}export{jt as default};
@@ -1 +1 @@
1
- import{j as t}from"./auth-callback-atKg_oig.js";function s({title:e}){return t.jsx("div",{className:"flex h-full items-center px-4 text-sm font-semibold text-foreground",children:e})}export{s as P};
1
+ import{j as t}from"./auth-callback-CAFZ3R0B.js";function s({title:e}){return t.jsx("div",{className:"flex h-full items-center px-4 text-sm font-semibold text-foreground",children:e})}export{s as P};
@@ -0,0 +1 @@
1
+ import{r as g,j as n}from"./auth-callback-CAFZ3R0B.js";import{i as p,A as f}from"./ModelAssignmentsPanel-BJutWaAF.js";import{u as k}from"./AiConfigContext-DnQs1ZpW.js";import"./dialog-BjA109aX.js";import"./index-BppXlxcp.js";import"./ai-connections-CryuHGKW.js";import"./XpodAiConnectionsPodStore-BJiXm-PF.js";import"./index-browser-DtU38ni3.js";function w(){const{config:r,capabilities:d,save:o,rebuild:c,saveAndRebuild:i,saving:l,rebuilding:s}=k(),[e,a]=g.useState(r?.searchIndexing);if(g.useEffect(()=>{let t=!1;return queueMicrotask(()=>{t||a(r?.searchIndexing)}),()=>{t=!0}},[r]),!e)return null;const u=async t=>{t.preventDefault(),await o({searchIndexing:e})},x=e.ftsEnabled&&e.vectorEnabled?"all":e.vectorEnabled?"vector":"fts",b=d?.rebuildTargets?.includes(x)===!0,m=p(e,r?.searchIndexing);return n.jsxs(f,{title:"Search & Indexing",description:"Choose which derived search indexes Xpod maintains for this Pod.",onSubmit:u,onRestore:()=>o({searchIndexing:{ftsEnabled:!0,vectorEnabled:!0,progressiveIndexingEnabled:!0,textBackend:"auto",vectorBackend:"auto"}}),saving:l||s,dirty:m,footerActions:n.jsx("button",{type:"button",disabled:!b||l||s,onClick:()=>m?i({searchIndexing:e},x):c(x),className:"h-9 rounded-md border border-input px-3 text-sm font-medium disabled:opacity-50",children:s?"Scheduling…":m&&b?"Save and schedule rebuild":b?"Schedule rebuild":"Rebuild unavailable on this runtime"}),children:[n.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[n.jsx(h,{title:"Full-text Search",enabled:e.ftsEnabled,onEnabled:t=>a({...e,ftsEnabled:t}),backend:e.textBackend,onBackend:t=>a({...e,textBackend:t}),backends:[["auto","Auto"],...(d?.textBackends??[]).map(t=>[t,t==="fts5"?"FTS5":"PostgreSQL FTS"])]}),n.jsx(h,{title:"Vector Search",enabled:e.vectorEnabled,onEnabled:t=>a({...e,vectorEnabled:t}),backend:e.vectorBackend,onBackend:t=>a({...e,vectorBackend:t}),backends:[["auto","Auto"],...(d?.vectorBackends??[]).map(t=>[t,t==="vec"?"VEC":"pgvector"])]})]}),n.jsxs("label",{className:"flex items-start justify-between gap-4 rounded-xl border border-border p-4",children:[n.jsxs("span",{children:[n.jsx("span",{className:"block text-sm font-medium",children:"Progressive indexing"}),n.jsx("span",{className:"block text-xs text-muted-foreground",children:"Expand coverage as content becomes relevant instead of embedding everything eagerly."})]}),n.jsx("input",{name:"progressiveIndexingEnabled",type:"checkbox",checked:e.progressiveIndexingEnabled,onChange:t=>a({...e,progressiveIndexingEnabled:t.target.checked}),className:"mt-1 h-4 w-4 rounded border-input"})]})]})}function h({title:r,enabled:d,onEnabled:o,backend:c,onBackend:i,backends:l}){const s=l.filter(([a])=>a!=="auto"),e=v(c);return n.jsxs("section",{className:"rounded-xl border border-border p-4",children:[n.jsxs("label",{className:"flex items-center justify-between gap-3 text-sm font-medium",children:[r,n.jsx("input",{type:"checkbox",checked:d,onChange:a=>o(a.target.checked),className:"h-4 w-4 rounded border-input"})]}),n.jsxs("label",{className:"mt-4 flex items-center justify-between gap-3 text-xs font-medium text-muted-foreground",children:["Choose backend manually",n.jsx("input",{type:"checkbox",checked:e,disabled:s.length===0,onChange:a=>i(a.target.checked?s[0]?.[0]??"auto":"auto"),className:"h-4 w-4 rounded border-input"})]}),e?n.jsxs("label",{className:"mt-3 block space-y-2 text-xs font-medium text-muted-foreground",children:["Backend",n.jsx("select",{value:c,onChange:a=>i(a.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 text-sm text-foreground",children:s.map(([a,u])=>n.jsx("option",{value:a,children:u},a))})]}):n.jsx("p",{className:"mt-3 text-xs text-muted-foreground",children:"Auto selects the runtime-supported backend."})]})}function v(r){return r!=="auto"}export{w as SearchIndexingPanel,v as isManualBackendSelection};
@@ -1 +1 @@
1
- import{c as L,r as o,j as e,B as N,R as T,C as l,a as u,b as h,d as f,e as m}from"./auth-callback-atKg_oig.js";import{f as D,a as M,t as _,r as O}from"./admin-BU4m6Ko2.js";import{E as q}from"./external-link-DZ34d3g3.js";const G=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],U=L("rotate-cw",G);function Q({serviceId:t,title:r}){const[s,d]=o.useState(),[g,R]=o.useState(),[j,k]=o.useState([]),[v,p]=o.useState(),[b,S]=o.useState(!0),[y,w]=o.useState(!1),[C,$]=o.useState(),c=o.useCallback(async a=>{S(!0);try{const[n,A]=await Promise.all([D({signal:a}),M({source:t,level:"error",limit:5})]);d(t==="gateway"?{name:"gateway",status:"running",pid:n.adminData?.pid,uptime:n.adminData?.uptime?n.adminData.uptime*1e3:void 0,restartCount:0}:n.servicesData?.find(E=>E.name===t)),R(n.configData??void 0),k(A),$(n.checkedAt),p(void 0)}catch(n){n instanceof DOMException&&n.name==="AbortError"||p("Service status could not be loaded. The previous snapshot is retained.")}finally{S(!1)}},[t]);o.useEffect(()=>{const a=new AbortController;let n=!0;return Promise.resolve().then(()=>{n&&c(a.signal)}),()=>{n=!1,a.abort()}},[c]);const x=o.useMemo(()=>X(t,g),[g,t]),P=async()=>{const a=t==="gateway"?"the whole Xpod runtime":`${r} only`;if(!window.confirm(`Restart ${a}? Active requests may be interrupted.`))return;w(!0);const n=t==="gateway"?await _():await O(t);w(!1),n?setTimeout(()=>{c()},750):p(`Restart request for ${r} was not accepted by this runtime.`)};return e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{"aria-live":"polite",className:"text-xs text-muted-foreground",children:b?"Refreshing service evidence…":C?`Checked ${C.toLocaleString()}`:"Not checked"}),e.jsxs(N,{type:"button",size:"sm",variant:"outline",onClick:()=>{c()},disabled:b,children:[e.jsx(T,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),v&&e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive",children:v}),e.jsxs(l,{children:[e.jsxs(u,{children:[e.jsx(h,{children:r}),e.jsx(f,{children:"Observed state, endpoint, health evidence, dependencies, and explicitly scoped lifecycle action."})]}),e.jsxs(m,{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(i,{label:"State",value:s?.status??"Unknown"}),e.jsx(i,{label:"PID",value:s?.pid?.toString()??"Not reported"}),e.jsx(i,{label:"Uptime",value:s?.uptime?z(s.uptime):"Not reported"}),e.jsx(i,{label:"Restart count",value:s?.restartCount?.toString()??"Not reported"}),e.jsx(i,{label:"Internal endpoint",value:x.endpoint}),e.jsx(i,{label:"Health check",value:x.healthCheck})]})]}),e.jsxs(l,{children:[e.jsx(u,{children:e.jsx(h,{children:"Dependencies"})}),e.jsx(m,{className:"grid gap-3 text-sm sm:grid-cols-2",children:x.dependencies.map(a=>e.jsx(i,{label:a,value:B(a,t,s)},a))})]}),e.jsxs(l,{children:[e.jsxs(u,{children:[e.jsx(h,{children:"Recent errors"}),e.jsxs(f,{children:["Latest supervisor errors scoped to ",r,"."]})]}),e.jsxs(m,{className:"space-y-2",children:[j.length?j.map(a=>e.jsxs("div",{className:"rounded-lg border border-border p-3 text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(a.timestamp).toLocaleString()}),e.jsx("div",{className:"mt-1 break-words",children:a.message})]},`${a.timestamp}-${a.message}`)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No recent errors reported."}),e.jsxs("a",{className:"inline-flex items-center text-sm font-medium text-primary hover:underline",href:`/status/logs?source=${t}`,children:[e.jsx(q,{className:"mr-1.5 h-4 w-4"}),"Open related logs"]})]})]}),e.jsxs(l,{children:[e.jsxs(u,{children:[e.jsx(h,{children:"Lifecycle"}),e.jsx(f,{children:t==="gateway"?"Gateway is the parent process, so this action restarts the whole Xpod runtime.":`This action restarts ${r} only; dependent requests may briefly fail.`})]}),e.jsx(m,{children:e.jsxs(N,{type:"button",variant:"destructive",onClick:()=>{P()},disabled:y,children:[e.jsx(U,{className:"mr-2 h-4 w-4"}),y?"Restarting…":t==="gateway"?"Restart Xpod runtime…":`Restart ${r}…`]})})]})]})}function X(t,r){const s=r?.env??{};return t==="gateway"?{endpoint:window.location.origin,healthCheck:"GET /service/status",dependencies:["Solid Server","API Server"]}:t==="css"?{endpoint:s.CSS_PORT?`http://127.0.0.1:${s.CSS_PORT}`:"Internal endpoint not reported",healthCheck:"TCP readiness + Solid root request",dependencies:["Authority storage","Identity service"]}:{endpoint:s.API_INTERNAL_URL||(s.API_PORT?`http://127.0.0.1:${s.API_PORT}`:"Internal endpoint not reported"),healthCheck:"GET /health",dependencies:["Solid Server","Configuration store"]}}function B(t,r,s){return s?s.status!=="running"?`${H(r)} is ${s.status}; dependency health is not implied`:`${t} required; direct probe evidence is not reported by this runtime`:"Not reported"}function H(t){return t==="gateway"?"Gateway":t==="css"?"Solid Server":"API Server"}function i({label:t,value:r}){return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 break-all font-medium",children:r})]})}function z(t){const r=Math.floor(t/1e3),s=Math.floor(r/3600),d=Math.floor(r%3600/60);return s?`${s}h ${d}m`:`${d}m ${r%60}s`}export{Q as ServiceStatusPanel};
1
+ import{c as L,r as o,j as e,B as N,R as T,C as l,a as u,b as h,d as f,e as m}from"./auth-callback-CAFZ3R0B.js";import{f as D,a as M,t as _,r as O}from"./admin-C6qCRFiY.js";import{E as q}from"./external-link-BTXgSPzB.js";const G=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],U=L("rotate-cw",G);function Q({serviceId:t,title:r}){const[s,d]=o.useState(),[g,R]=o.useState(),[j,k]=o.useState([]),[v,p]=o.useState(),[b,S]=o.useState(!0),[y,w]=o.useState(!1),[C,$]=o.useState(),c=o.useCallback(async a=>{S(!0);try{const[n,A]=await Promise.all([D({signal:a}),M({source:t,level:"error",limit:5})]);d(t==="gateway"?{name:"gateway",status:"running",pid:n.adminData?.pid,uptime:n.adminData?.uptime?n.adminData.uptime*1e3:void 0,restartCount:0}:n.servicesData?.find(E=>E.name===t)),R(n.configData??void 0),k(A),$(n.checkedAt),p(void 0)}catch(n){n instanceof DOMException&&n.name==="AbortError"||p("Service status could not be loaded. The previous snapshot is retained.")}finally{S(!1)}},[t]);o.useEffect(()=>{const a=new AbortController;let n=!0;return Promise.resolve().then(()=>{n&&c(a.signal)}),()=>{n=!1,a.abort()}},[c]);const x=o.useMemo(()=>X(t,g),[g,t]),P=async()=>{const a=t==="gateway"?"the whole Xpod runtime":`${r} only`;if(!window.confirm(`Restart ${a}? Active requests may be interrupted.`))return;w(!0);const n=t==="gateway"?await _():await O(t);w(!1),n?setTimeout(()=>{c()},750):p(`Restart request for ${r} was not accepted by this runtime.`)};return e.jsxs("div",{className:"space-y-4 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{"aria-live":"polite",className:"text-xs text-muted-foreground",children:b?"Refreshing service evidence…":C?`Checked ${C.toLocaleString()}`:"Not checked"}),e.jsxs(N,{type:"button",size:"sm",variant:"outline",onClick:()=>{c()},disabled:b,children:[e.jsx(T,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),v&&e.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive",children:v}),e.jsxs(l,{children:[e.jsxs(u,{children:[e.jsx(h,{children:r}),e.jsx(f,{children:"Observed state, endpoint, health evidence, dependencies, and explicitly scoped lifecycle action."})]}),e.jsxs(m,{className:"grid gap-3 text-sm sm:grid-cols-2 xl:grid-cols-3",children:[e.jsx(i,{label:"State",value:s?.status??"Unknown"}),e.jsx(i,{label:"PID",value:s?.pid?.toString()??"Not reported"}),e.jsx(i,{label:"Uptime",value:s?.uptime?z(s.uptime):"Not reported"}),e.jsx(i,{label:"Restart count",value:s?.restartCount?.toString()??"Not reported"}),e.jsx(i,{label:"Internal endpoint",value:x.endpoint}),e.jsx(i,{label:"Health check",value:x.healthCheck})]})]}),e.jsxs(l,{children:[e.jsx(u,{children:e.jsx(h,{children:"Dependencies"})}),e.jsx(m,{className:"grid gap-3 text-sm sm:grid-cols-2",children:x.dependencies.map(a=>e.jsx(i,{label:a,value:B(a,t,s)},a))})]}),e.jsxs(l,{children:[e.jsxs(u,{children:[e.jsx(h,{children:"Recent errors"}),e.jsxs(f,{children:["Latest supervisor errors scoped to ",r,"."]})]}),e.jsxs(m,{className:"space-y-2",children:[j.length?j.map(a=>e.jsxs("div",{className:"rounded-lg border border-border p-3 text-sm",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(a.timestamp).toLocaleString()}),e.jsx("div",{className:"mt-1 break-words",children:a.message})]},`${a.timestamp}-${a.message}`)):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No recent errors reported."}),e.jsxs("a",{className:"inline-flex items-center text-sm font-medium text-primary hover:underline",href:`/status/logs?source=${t}`,children:[e.jsx(q,{className:"mr-1.5 h-4 w-4"}),"Open related logs"]})]})]}),e.jsxs(l,{children:[e.jsxs(u,{children:[e.jsx(h,{children:"Lifecycle"}),e.jsx(f,{children:t==="gateway"?"Gateway is the parent process, so this action restarts the whole Xpod runtime.":`This action restarts ${r} only; dependent requests may briefly fail.`})]}),e.jsx(m,{children:e.jsxs(N,{type:"button",variant:"destructive",onClick:()=>{P()},disabled:y,children:[e.jsx(U,{className:"mr-2 h-4 w-4"}),y?"Restarting…":t==="gateway"?"Restart Xpod runtime…":`Restart ${r}…`]})})]})]})}function X(t,r){const s=r?.env??{};return t==="gateway"?{endpoint:window.location.origin,healthCheck:"GET /service/status",dependencies:["Solid Server","API Server"]}:t==="css"?{endpoint:s.CSS_PORT?`http://127.0.0.1:${s.CSS_PORT}`:"Internal endpoint not reported",healthCheck:"TCP readiness + Solid root request",dependencies:["Authority storage","Identity service"]}:{endpoint:s.API_INTERNAL_URL||(s.API_PORT?`http://127.0.0.1:${s.API_PORT}`:"Internal endpoint not reported"),healthCheck:"GET /health",dependencies:["Solid Server","Configuration store"]}}function B(t,r,s){return s?s.status!=="running"?`${H(r)} is ${s.status}; dependency health is not implied`:`${t} required; direct probe evidence is not reported by this runtime`:"Not reported"}function H(t){return t==="gateway"?"Gateway":t==="css"?"Solid Server":"API Server"}function i({label:t,value:r}){return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:t}),e.jsx("div",{className:"mt-1 break-all font-medium",children:r})]})}function z(t){const r=Math.floor(t/1e3),s=Math.floor(r/3600),d=Math.floor(r%3600/60);return s?`${s}h ${d}m`:`${d}m ${r%60}s`}export{Q as ServiceStatusPanel};
@@ -1 +1 @@
1
- import{c as r,D as l,S as x,G as h,k as y,j as a,O as v,N as p,l as m,m as k}from"./settings-ExBXGgbj.js";import{A as u}from"./activity-DaFkk8f3.js";import{W as f,N as w}from"./waypoints-9erLIxyR.js";import{P as g}from"./PaneListHeader-DpqC0jd5.js";import{T as N,u as j}from"./workspace-layout-CYXfYIa3.js";const b=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],S=r("boxes",b);const I=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],M=r("braces",I);const L=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],_=r("hard-drive",L);const z=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],d=r("scroll-text",z);const D=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],H=r("server",D);const O=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],V=r("timer",O);function s(i,t,e,n,o){return{id:i,label:t,path:e,href:`/status/${e}`,end:!0,group:n,icon:o}}const c=[s("overview","Overview","overview","Overview",u),s("gateway","Gateway","services/gateway","Services",f),s("solid-server","Solid Server","services/solid-server","Services",l),s("api-server","API Server","services/api-server","Services",H),s("logs","Logs","logs","Diagnostics",d),s("index-overview","Index Overview","index","Index",S),s("rdf","RDF","index/rdf","Index",M),s("fts","FTS","index/fts","Index",d),s("vector","Vector","index/vector","Index",x),s("retrieval-points","Retrieval Points","index/retrieval-points","Index",w),s("cache","Cache","index/cache","Index",_),s("slow-queries","Slow Queries","index/slow-queries","Index",V),s("benchmark","Benchmark","index/benchmark","Index",h)],q=["Overview","Services","Diagnostics","Index"];function C(){const i=y(),t=[...c].sort((e,n)=>n.path.length-e.path.length).find(e=>i.pathname.endsWith(e.path))??c[0];return a.jsx(N,{mode:"auto",listHeader:a.jsx(g,{title:"Status"}),list:a.jsx(A,{}),mainHeader:a.jsx("div",{className:"flex h-full items-center px-4",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-sm font-semibold",children:["Status · ",t.label]}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Observed state and operational evidence"})]})}),main:a.jsx("section",{className:"min-h-full bg-background",children:a.jsx(v,{})}),className:"min-h-full"})}function A(){const i=j();return a.jsx("aside",{"data-list-navigation":!0,className:"h-full overflow-y-auto border-r border-border bg-muted/20 py-2",children:q.map(t=>a.jsxs("section",{className:"mb-3",children:[a.jsx("h2",{className:"px-5 py-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),c.filter(e=>e.group===t).map(e=>{const n=e.icon;return a.jsxs(p,{to:e.path,end:e.end,onKeyDown:m,onClick:()=>i.openMain(),className:({isActive:o})=>k(o,{compact:!1}),children:[a.jsx(n,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.label]},e.id)})]},t))})}export{C as default};
1
+ import{c as r,D as l,T as x,U as h,v,j as a,O as y,N as p,w as m,x as k}from"./auth-callback-CAFZ3R0B.js";import{A as u}from"./activity-5hNeNKnL.js";import{W as f,N as w}from"./waypoints-Bj6gAUSQ.js";import{P as g}from"./PaneListHeader-QQeJGTp4.js";import{T as N,u as j}from"./workspace-layout-DK8mDzrY.js";const b=[["path",{d:"M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z",key:"lc1i9w"}],["path",{d:"m7 16.5-4.74-2.85",key:"1o9zyk"}],["path",{d:"m7 16.5 5-3",key:"va8pkn"}],["path",{d:"M7 16.5v5.17",key:"jnp8gn"}],["path",{d:"M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z",key:"8zsnat"}],["path",{d:"m17 16.5-5-3",key:"8arw3v"}],["path",{d:"m17 16.5 4.74-2.85",key:"8rfmw"}],["path",{d:"M17 16.5v5.17",key:"k6z78m"}],["path",{d:"M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z",key:"1xygjf"}],["path",{d:"M12 8 7.26 5.15",key:"1vbdud"}],["path",{d:"m12 8 4.74-2.85",key:"3rx089"}],["path",{d:"M12 13.5V8",key:"1io7kd"}]],I=r("boxes",b);const S=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],M=r("braces",S);const L=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],_=r("hard-drive",L);const z=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],d=r("scroll-text",z);const D=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],H=r("server",D);const O=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],V=r("timer",O);function s(i,t,e,n,o){return{id:i,label:t,path:e,href:`/status/${e}`,end:!0,group:n,icon:o}}const c=[s("overview","Overview","overview","Overview",u),s("gateway","Gateway","services/gateway","Services",f),s("solid-server","Solid Server","services/solid-server","Services",l),s("api-server","API Server","services/api-server","Services",H),s("logs","Logs","logs","Diagnostics",d),s("index-overview","Index Overview","index","Index",I),s("rdf","RDF","index/rdf","Index",M),s("fts","FTS","index/fts","Index",d),s("vector","Vector","index/vector","Index",x),s("retrieval-points","Retrieval Points","index/retrieval-points","Index",w),s("cache","Cache","index/cache","Index",_),s("slow-queries","Slow Queries","index/slow-queries","Index",V),s("benchmark","Benchmark","index/benchmark","Index",h)],q=["Overview","Services","Diagnostics","Index"];function C(){const i=v(),t=[...c].sort((e,n)=>n.path.length-e.path.length).find(e=>i.pathname.endsWith(e.path))??c[0];return a.jsx(N,{mode:"auto",listHeader:a.jsx(g,{title:"Status"}),list:a.jsx(A,{}),mainHeader:a.jsx("div",{className:"flex h-full items-center px-4",children:a.jsxs("div",{children:[a.jsxs("h1",{className:"text-sm font-semibold",children:["Status · ",t.label]}),a.jsx("div",{className:"text-xs text-muted-foreground",children:"Observed state and operational evidence"})]})}),main:a.jsx("section",{className:"min-h-full bg-background",children:a.jsx(y,{})}),className:"min-h-full"})}function A(){const i=j();return a.jsx("aside",{"data-list-navigation":!0,className:"h-full overflow-y-auto border-r border-border bg-muted/20 py-2",children:q.map(t=>a.jsxs("section",{className:"mb-3",children:[a.jsx("h2",{className:"px-5 py-1 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground",children:t}),c.filter(e=>e.group===t).map(e=>{const n=e.icon;return a.jsxs(p,{to:e.path,end:e.end,onKeyDown:m,onClick:()=>i.openMain(),className:({isActive:o})=>k(o,{compact:!1}),children:[a.jsx(n,{className:"h-4 w-4 shrink-0","aria-hidden":"true"}),e.label]},e.id)})]},t))})}export{C as default};
@@ -0,0 +1 @@
1
+ import{c as l,D as h,v as u,r as c,j as e,O as x,N as b,w as y,x as g}from"./auth-callback-CAFZ3R0B.js";import{K as f}from"./key-round-CQCOrZ7x.js";import{b as v,c as k}from"./admin-C6qCRFiY.js";import{p as j}from"./settings-projection-CUkyprDQ.js";import{P as N}from"./PaneListHeader-QQeJGTp4.js";import{T as S,u as w}from"./workspace-layout-DK8mDzrY.js";const M=[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]],P=l("box",M);const L=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],C=l("cloud",L);const A=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],_=l("server-cog",A);const D=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],H=l("wrench",D),I=[{scope:"account",label:"Account",description:"Your Pod and its session.",items:[{id:"pod",label:"Pod",path:"pod",description:"Current Pod identity and data boundary.",icon:P},{id:"identity-access",label:"Identity & Access",path:"identity-access",description:"Session, WebID, and account access.",icon:f}]},{scope:"node",label:"This node",description:"Shared by every Pod on this machine.",items:[{id:"storage",label:"Storage",path:"storage",description:"Authority storage backend and limits.",icon:h},{id:"runtime",label:"Runtime",path:"runtime",description:"Low-frequency runtime configuration.",icon:_},{id:"cloud",label:"Cloud",path:"cloud",description:"Cloud coordination settings when supported.",icon:C},{id:"advanced",label:"Advanced",path:"advanced",description:"Expert and compatibility controls.",icon:H}]}];function q(){const r=u(),[n,s]=c.useState(!1);c.useEffect(()=>{let t=!1;return Promise.all([v(),k()]).then(([d,p])=>{t||s(j({registered:d?.registered===!0,managed:d?.managed===!0,domainAllocated:p?.allocated===!0}).cloud)}),()=>{t=!0}},[]);const a=c.useMemo(()=>I.map(t=>({...t,items:t.items.filter(d=>d.id!=="cloud"||n)})).filter(t=>t.items.length>0),[n]),o=c.useMemo(()=>a.flatMap(t=>t.items),[a]),i=o.find(t=>r.pathname.endsWith(`/${t.path}`))??o[0],m=a.find(t=>t.items.includes(i))?.scope;return e.jsx(S,{mode:"auto",listHeader:e.jsx(N,{title:"Settings"}),list:e.jsx(z,{groups:a}),mainHeader:e.jsx("div",{className:"flex h-full items-center px-4",children:e.jsxs("div",{children:[e.jsxs("h1",{className:"text-sm font-semibold",children:["Settings · ",i.label]}),e.jsx("div",{className:"text-xs text-muted-foreground",children:i.description}),m==="node"?e.jsx("div",{className:"text-xs text-amber-700 dark:text-amber-300",children:"Applies to every Pod on this machine."}):null]})}),main:e.jsx("section",{className:"min-h-full bg-background",children:e.jsx(x,{})}),className:"min-h-full"})}function z({groups:r}){const n=w();return e.jsx("aside",{className:"h-full border-r border-border bg-muted/20 py-2",children:e.jsx("nav",{"aria-label":"Settings sections","data-list-navigation":!0,children:r.map(s=>e.jsxs("div",{children:[e.jsxs("div",{className:"px-4 pb-1 pt-3",children:[e.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:s.label}),e.jsx("div",{className:"text-xs leading-4 text-muted-foreground",children:s.description})]}),s.items.map(a=>{const o=a.icon;return e.jsxs(b,{to:a.path,"aria-label":a.label,onKeyDown:y,onClick:()=>n.openMain(),className:({isActive:i})=>g(i,{compact:!1}),children:[e.jsx(o,{className:"mt-0.5 h-4 w-4 shrink-0","aria-hidden":"true"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium",children:a.label}),e.jsx("span",{className:"block text-xs leading-4 text-muted-foreground",children:a.description})]})]},a.id)})]},s.scope))})})}export{q as default};
@@ -0,0 +1,33 @@
1
+ import{y as Z,z as ee,A as te,E as I,F as ie,G as T,H as ce,I as G,J as de,K as le,L as ue,M as he,u as pe,r as u,j as s,B as C,R as fe,C as ge,a as me,b as we,d as be,e as ve,Q as xe,S as ye}from"./auth-callback-CAFZ3R0B.js";import{d as Ae,e as Se,b as Ce,c as Ie,h as Ne,i as _e,t as je,u as Ee}from"./admin-C6qCRFiY.js";import{a as Re}from"./settings-projection-CUkyprDQ.js";import{f as Ue,a as H}from"./ai-connections-CryuHGKW.js";import{R as Pe}from"./rotate-ccw-C1zM2KtS.js";import{S as X}from"./skeleton-Cqp7_M9-.js";import{E as ke}from"./external-link-BTXgSPzB.js";class v extends Error{code;constructor(t,r){super(r),this.name="AccountStorageBindingsError",this.code=t}}async function Oe(e){const t=De(e.origin),r=e.controls?.account?.bindings;if(typeof r!="string"||r.trim()==="")throw new v("missing-control","Account storage bindings control is unavailable");const n=e.fetchImpl??fetch,a=Te(r,t),o=a.origin===t?a.href:await Z(a.href,n,e.trustedAccountIndex);if(!o)throw new v("cross-origin","Account storage bindings control is not hosted by this Xpod");const c=ee({Accept:"application/json",...e.headers});let i;try{i=await n(o,{headers:c,credentials:"include"})}catch(l){throw new v("request-failed",l instanceof Error?l.message:"Failed to load Account storage bindings")}if(i.status===401||i.status===403)throw new v("forbidden","Account storage bindings require an authenticated Account");if(!i.ok)throw new v("request-failed",`Account storage bindings request failed (${i.status})`);let d;try{d=await i.json()}catch{throw new v("invalid-response","Account storage bindings response is not valid JSON")}return Le(d,a.origin,We(a,e.trustedAccountIndex,t))}function Le(e,t,r=!1){if(!z(e)||!Array.isArray(e.bindings))throw new v("invalid-response","Account storage bindings response is malformed");const n=[],a=new Set;for(const o of e.bindings){if(!z(o)||typeof o.webId!="string"||typeof o.storageUrl!="string")throw new v("invalid-response","Account storage binding row is malformed");const c=Be(o.webId),i=Fe(o.storageUrl,r?void 0:t);if(!c||!i)throw new v("cross-origin","Account storage binding is outside the trusted storage scope");const d={webId:c,storageUrl:i,...typeof o.label=="string"?{label:o.label}:{}},l=`${d.webId}
2
+ ${d.storageUrl}`;a.has(l)||(a.add(l),n.push(d))}return n}function De(e){try{return new URL(e??(typeof window>"u"?"http://localhost":window.location.origin)).origin}catch{throw new v("cross-origin","Current Xpod origin is invalid")}}function Te(e,t){try{const r=new URL(e,t);if(!["http:","https:"].includes(r.protocol)||r.username||r.password||r.hash)throw new Error("unsafe control URL");return r}catch{throw new v("cross-origin","Account storage bindings control is not a valid URL")}}function Be(e){if(!te(e))try{const t=new URL(e);return!["http:","https:"].includes(t.protocol)||t.username||t.password?void 0:e}catch{return}}function Fe(e,t){try{const r=new URL(e.trim());return t!==void 0&&r.origin!==t||!["http:","https:"].includes(r.protocol)||r.username||r.password||r.search||r.hash?void 0:(r.pathname=r.pathname.endsWith("/")?r.pathname:`${r.pathname}/`,r.href)}catch{return}}function We(e,t,r){if(!t)return!1;try{const n=new URL(t,r);return n.pathname.startsWith("/.account/")&&e.origin===n.origin&&e.pathname.startsWith("/.account/")}catch{return!1}}function z(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}const q="co.undefineds.ai-connections",Me={providerCredentials:"settings/credentials.ttl",providerDefinitions:"settings/providers/__service_access__.ttl",gatewayAccessKeys:".data/ai/gateway/access-keys.ttl",quotaSnapshots:".data/ai/gateway/quota.ttl"},$e=new Set(Ue);function V(e,t){if(!U(e))throw new Error("invalid_descriptor");if(e.appletId!==q)throw new Error("invalid_applet_id");const r=e.service;if(!U(r)||typeof r.webId!="string"||typeof r.label!="string"||!Je(r.webId))throw new Error("invalid_service");if(!Array.isArray(e.resources)||e.resources.length===0)throw new Error("invalid_empty_resources");const n=Ve(t),a=new Set,o=e.resources.map(c=>Ge(c,n,a));return{appletId:q,service:{webId:r.webId,label:r.label},resources:o}}function Ge(e,t,r){if(!U(e)||typeof e.id!="string"||typeof e.url!="string"||e.mediaType!=="text/turtle"||!U(e.access))throw new Error("invalid_resource");const n=He(e.id,t);if(!n||r.has(e.id))throw new Error("invalid_resource");Xe(e.url);let a;try{a=new URL(e.url)}catch{throw new Error("invalid_resource")}if(!Ke(a,t))throw new Error("invalid_resource");if(a.href!==n)throw new Error("invalid_resource");return r.add(e.id),{id:e.id,url:a.href,mediaType:"text/turtle",access:qe(e.access)}}function He(e,t){const r=Me[e];if(r)return new URL(r,t).href;const n=e.startsWith("providerDocument:")?e.slice(17):void 0;if(n&&$e.has(n))return new URL(`settings/providers/${n}.ttl`,t).href}function Xe(e){if(/%(?![0-9a-fA-F]{2})/.test(e)||/%(?:2f|5c)/i.test(e)||e.includes("\\"))throw new Error("invalid_resource");const t=ze(e);if(K(t))throw new Error("invalid_resource");try{const r=decodeURIComponent(t);if(r.includes("\\")||K(r))throw new Error("invalid_resource")}catch{throw new Error("invalid_resource")}}function ze(e){const t=e.split("#",1)[0]??e;return(t.split("?",1)[0]??t).replace(/^[a-z][a-z0-9+.-]*:\/\/[^/\\?#]*/i,"")}function K(e){return e.split("/").some(t=>t==="."||t==="..")}function qe(e){if(Object.keys(e).some(r=>r!=="read"&&r!=="append"&&r!=="write")||e.read!==!0||e.append!==!0||e.write!==!0)throw new Error("invalid_resource");return{read:!0,append:!0,write:!0}}function Ve(e){const t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error("invalid_current_pod");return t.pathname.endsWith("/")||(t.pathname=`${t.pathname}/`),t}function Ke(e,t){return(e.protocol==="http:"||e.protocol==="https:")&&e.origin===t.origin&&e.pathname.startsWith(t.pathname)}function Je(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}function U(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}const Qe=3,Ye=63,Ze=/^[a-z0-9-]+$/;function B(e){return e.trim().toLowerCase()}function re(e){const t=B(e);if(!t)return I.usernameRequired;if(t.length<Qe||t.length>Ye)return I.usernameLength;if(!Ze.test(t))return I.usernameCharset;if(t.startsWith("-")||t.endsWith("-"))return I.usernameHyphen}const et="已有 Pod 的身份绑定尚未确认。请重试读取绑定或返回账号,不需要重新创建 Pod。",tt="暂时无法确认已有 Pod,请重试读取或返回账号。";class x extends Error{code;constructor(t){super(t==="binding-missing"?et:t==="inventory-unavailable"?tt:"账号已切换,请返回当前账号重新操作。"),this.name="FirstPodReadinessError",this.code=t}}function rt(e){const t=G(),r=de(t,{...e.headers}),n=new Headers(r).get("Authorization"),a=()=>{try{e.assertCurrentAccount?.()}catch{throw new x("account-changed")}if(G()!==t||n?.startsWith("CSS-Account-Token ")&&n!==(t?`CSS-Account-Token ${t}`:void 0))throw new x("account-changed")},o=e.fetchImpl??fetch;return{headers:r,assertCurrentAccount:a,fetch:async(i,d)=>{a();const l=await o(i,d);try{a()}catch(b){throw l.body?.cancel().catch(()=>{}),b}const g=async b=>{a();const y=await b();return a(),y},m=l.json.bind(l),w=l.text.bind(l);return l.json=()=>g(m),l.text=()=>g(w),l}}}async function nt(e,t,r,n){n.assertCurrentAccount();let a;try{const i=await e(T(t),{headers:{...n.headers,Accept:"application/json"},credentials:"include"});if(!i.ok)throw new x("inventory-unavailable");a=await i.json()}catch{throw n.assertCurrentAccount(),new x("inventory-unavailable")}if(n.assertCurrentAccount(),!D(a)||!D(a.pods))throw new x("inventory-unavailable");const o=Object.entries(a.pods);if(o.some(([i,d])=>!ae(i)||typeof d!="string"||!d))throw new x("inventory-unavailable");const c=le(r);if(o.some(([i])=>!c||ue(i,c.storageRoot)))throw new x("binding-missing")}function st(e){for(const t of e){if(!t)continue;const r=ut(t);if(!r)continue;const n=B(r).replace(/[^a-z0-9-]/gu,"-").replace(/-+/gu,"-").replace(/^-+|-+$/gu,"");if(n&&!re(n))return n}return""}async function at(e){const t=rt(e),r=t.fetch,n=B(e.username),a=re(n);if(a)throw new Error(a);const o=await ie(e.provisionCode),c=await Z(e.createPodUrl,r,e.trustedAccountIndex);if(!c)throw new Error("Pod creation control is not hosted by this Xpod");await nt(r,c,o,t);const i=await dt(r,n,o);t.assertCurrentAccount();const d=await r(T(c),{method:"POST",headers:{...t.headers,Accept:"application/json","Content-Type":"application/json"},credentials:"include",body:JSON.stringify(ce(n,i?.provisionCode??o,i?.provisionReceipt))});if(t.assertCurrentAccount(),!d.ok){const w=await ct(d);throw d.status===409||ne(w)?new Error(I.podNameTaken):new Error(w||"Failed to create Pod")}const l=await d.json().catch(P);t.assertCurrentAccount();const g=lt(l);if(!e.pickWebIdUrl)return g;const m=await ot({fetchImpl:r,headers:t.headers,maxAttempts:e.maxAttempts,pickWebIdUrl:e.pickWebIdUrl,pollIntervalMs:e.pollIntervalMs});return t.assertCurrentAccount(),m.length>0?m:g}async function ot(e){const t=e.fetchImpl??fetch,r=Math.max(1,e.maxAttempts??30),n=Math.max(0,e.pollIntervalMs??500);for(let a=0;a<r;a+=1){const o=await it(t,e.pickWebIdUrl,e.headers);if(o.length>0)return o;a<r-1&&n>0&&await new Promise(c=>setTimeout(c,n))}return[]}function P(e){if(e instanceof x)throw e}async function it(e,t,r){const n=await e(T(t),{headers:r,credentials:"include"}).catch(P);if(!n?.ok)return[];const a=await n.json().catch(P);if(!Array.isArray(a?.entries))return[];const o=new Set,c=[];for(const i of a.entries){if(!D(i)||typeof i.webId!="string"||typeof i.storageUrl!="string")continue;const d=se(i.webId,i.storageUrl);if(!d)continue;const l=`${d.webId}
3
+ ${d.storageUrl}`;o.has(l)||(o.add(l),c.push(d))}return c}async function ct(e){const t=await e.text?.().catch(P);if(t)try{const r=JSON.parse(t);return typeof r.message=="string"?r.message:typeof r.error=="string"?r.error:t}catch{return t}}function ne(e){return e?/already (?:is )?(?:a )?resource/iu.test(e)||/already taken/iu.test(e)||/already exists/iu.test(e):!1}async function dt(e,t,r){try{return await he(e,t,r)}catch(n){const a=n instanceof Error?n.message:String(n);throw ne(a)?new Error(I.podNameTaken):n}}function lt(e){if(typeof e?.podUrl!="string")return[];const t=ae(e.podUrl);if(!t)return[];const r=new Set;if(typeof e.webId=="string"&&e.webId.length>0&&r.add(e.webId),Array.isArray(e.webIds))for(const n of e.webIds)typeof n=="string"&&n.length>0&&r.add(n);return Array.from(r).map(n=>se(n,t)).filter(n=>!!n)}function ut(e){try{return new URL(e).pathname.split("/").filter(Boolean)[0]}catch{return e.includes("@")?e.split("@",1)[0]:e}}function se(e,t){if(!te(e))try{const r=new URL(e),n=new URL(t);return!["http:","https:"].includes(r.protocol)||!["http:","https:"].includes(n.protocol)?void 0:(n.pathname=n.pathname.endsWith("/")?n.pathname:`${n.pathname}/`,{webId:e,storageUrl:n.href})}catch{return}}function ae(e){try{const t=new URL(e);return!["http:","https:"].includes(t.protocol)||t.username||t.password||t.hash||t.search?void 0:(t.pathname=t.pathname.endsWith("/")?t.pathname:`${t.pathname}/`,t.href)}catch{return}}function D(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function ht(e,t){if(e)try{return new URL(new URL(e).pathname,t).toString()}catch{return}}const pt="http://www.w3.org/ns/solid/acp#",ft="http://www.w3.org/ns/auth/acl#";function J(e,{ownerWebId:t,serviceWebId:r},n=!0){const a=n?`
4
+ <#serviceAccess>
5
+ a acp:AccessControl;
6
+ acp:apply [
7
+ a acp:Policy;
8
+ acp:allow acl:Read, acl:Write;
9
+ acp:anyOf [
10
+ a acp:Matcher;
11
+ acp:agent <${r}>
12
+ ]
13
+ ].
14
+ `:"",o=n?"<#ownerAccess>, <#serviceAccess>":"<#ownerAccess>";return`@prefix acl: <${ft}>.
15
+ @prefix acp: <${pt}>.
16
+
17
+ <#managed>
18
+ a acp:AccessControlResource;
19
+ acp:resource <${e}>;
20
+ acp:accessControl ${o};
21
+ acp:memberAccessControl ${o}.
22
+
23
+ <#ownerAccess>
24
+ a acp:AccessControl;
25
+ acp:apply [
26
+ a acp:Policy;
27
+ acp:allow acl:Read, acl:Write, acl:Control;
28
+ acp:anyOf [
29
+ a acp:Matcher;
30
+ acp:agent <${t}>
31
+ ]
32
+ ].
33
+ ${a}`}function gt(e){const t=new URL(e);return t.pathname.endsWith("/")||(t.pathname=t.pathname.slice(0,t.pathname.lastIndexOf("/")+1)),t.toString()}function O(e){return new URL(".acr",e).toString()}function L(e){return[...new Set(e.resources.map(t=>gt(t.url)))]}async function Q(e,t,r){const n=await e(t,{method:"PUT",headers:{"content-type":"text/turtle"},body:r});if(!n.ok)throw await n.arrayBuffer().catch(()=>{}),new Error(`service_acr_write_failed:${n.status}`)}function R(e,t,r){return{status:t?"granted":"missing",resources:e.resources}}function Y(e){const t=()=>{if(!e.ownerWebId)throw new Error("service_acr_owner_missing");return e.ownerWebId};return{async ensureAgentAccess(r){const n=t();for(const a of L(r))await Q(e.authenticatedFetch,O(a),J(a,{ownerWebId:n,serviceWebId:r.service.webId}));return{status:"granted",resources:r.resources}},async inspectAgentAccess(r){try{for(const n of L(r)){const a=await e.authenticatedFetch(O(n),{headers:{accept:"text/turtle"}});if(!a.ok)return await a.arrayBuffer().catch(()=>{}),R(r,!1);const o=await a.text();if(!o.includes(`<${r.service.webId}>`)||!o.includes("acp:AccessControlResource"))return R(r,!1)}return R(r,!0)}catch{return R(r,!1)}},async revokeAgentAccess(r){const n=t();for(const a of L(r))await Q(e.authenticatedFetch,O(a),J(a,{ownerWebId:n,serviceWebId:r.service.webId},!1));return{status:"missing",resources:r.resources}}}}function Pt({kind:e}){const t=pe(),[r,n]=u.useState(null),[a,o]=u.useState(null),[c,i]=u.useState(null),[d,l]=u.useState(null),[g,m]=u.useState(!0),[w,b]=u.useState(""),[y,A]=u.useState(""),S=u.useCallback(async()=>{m(!0),b("");try{const[h,p,k,f]=await Promise.all([Ae(),Se(),Ce(),Ie()]);if(!h||!p)throw new Error("unavailable");n(h),o(p),i(k),l(await Ne(_e(p.env,f,h.env.CSS_BASE_URL??"")))}catch{b("Settings evidence could not be loaded.")}finally{m(!1)}},[]);u.useEffect(()=>{let h=!1;return queueMicrotask(()=>{h||S()}),()=>{h=!0}},[S]);const _=async h=>{if(b(""),!await Ee(h)){b("Configuration could not be saved.");return}o(p=>p&&{...p,env:{...p.env,...h}}),A("Saved · restart required")},E=St[e];return s.jsxs("div",{className:"space-y-4 p-6",children:[s.jsx("div",{className:"flex justify-end",children:s.jsxs(C,{type:"button",size:"sm",variant:"outline",onClick:S,disabled:g,children:[s.jsx(fe,{className:"mr-2 h-4 w-4"}),"Refresh"]})}),w?s.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive",children:w}):null,y?s.jsxs("div",{role:"status",className:"flex flex-wrap items-center justify-between gap-3 rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-800 dark:bg-amber-950/20 dark:text-amber-200",children:[s.jsx("span",{children:y}),s.jsxs(C,{type:"button",size:"sm",variant:"outline",onClick:()=>{je()},children:[s.jsx(Pe,{className:"mr-2 h-4 w-4"}),"Restart Xpod"]})]}):null,s.jsxs(ge,{children:[s.jsxs(me,{children:[s.jsx(we,{children:E}),s.jsx(be,{children:Ct[e]})]}),s.jsx(ve,{className:"space-y-4",children:g&&!a?s.jsx("div",{role:"status","aria-label":"Loading settings",className:"grid gap-3 sm:grid-cols-2","aria-live":"polite",children:[0,1,2,3].map(h=>s.jsxs("div",{className:"rounded-lg border border-border p-3","aria-hidden":"true",children:[s.jsx(X,{className:"h-3 w-24"}),s.jsx(X,{className:"mt-2 h-5 w-36"})]},h))}):s.jsx(wt,{kind:e,runtime:t,admin:r,configuration:a,provision:c,publicRoute:d,save:_})})]})]})}function mt({runtime:e,publicRoute:t}){const r=xe(),[n,a]=u.useState(null),[o,c]=u.useState(""),[i,d]=u.useState(""),[l,g]=u.useState(!1),[m,w]=u.useState(""),[b,y]=u.useState(""),A=r.controls,S=r.idpIndex,_=u.useCallback(async()=>{c("");try{a(await Oe({controls:A,origin:window.location.origin,trustedAccountIndex:S}))}catch{a(null),c("暂时无法读取存储绑定,请重试。")}},[A,S]);u.useEffect(()=>{let f=!1;return queueMicrotask(()=>{f||_()}),()=>{f=!0}},[_]);const E=u.useMemo(()=>st([e.webId,r.identity?.username,A?.account?.username]),[e.webId,r.identity?.username,A?.account?.username]),h=async f=>{f.preventDefault();const W=A?.account?.pod,M=(i.trim()||E||"").trim();if(!l){if(!W){w("当前部署没有公布创建存储空间的入口。");return}if(!M){w("无法从当前账号推断 Pod 名称,请手动填写。");return}g(!0),w(""),y("");try{await at({assertCurrentAccount:r.bindAccountCapability?.(),createPodUrl:W,headers:ee(),provisionCode:await ye(),trustedAccountIndex:S,username:M}),d(""),y("存储空间已创建。"),await _()}catch($){w($ instanceof Error?$.message:"无法创建存储空间,请重试。")}finally{g(!1)}}},p=ht(e.podUrl,window.location.origin),k=[{label:"Pod name",value:oe(e.podUrl)},{label:"Pod URL",value:p??"Not discovered"},{label:"Public route",value:At(t),detail:t?.detail??"Not checked by this runtime"},{label:"Session",value:e.state.status}];return s.jsxs(s.Fragment,{children:[s.jsx(N,{rows:k}),s.jsxs(C,{type:"button",variant:"outline",disabled:!p,onClick:()=>p&&window.open(p,"_blank","noopener,noreferrer"),children:[s.jsx(ke,{className:"mr-2 h-4 w-4"}),"Open Pod"]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium",children:"属于当前账号的存储空间"}),o?s.jsx("div",{role:"alert",className:"rounded-md border border-destructive/30 p-3 text-sm text-destructive",children:o}):null,n===null&&!o?s.jsx("div",{role:"status",className:"text-sm text-muted-foreground",children:"正在读取…"}):null,n?.length===0?s.jsx("div",{role:"status",className:"rounded-lg border border-border p-3 text-sm text-muted-foreground",children:"这个账号还没有任何存储空间。创建后即可用它授权应用访问。"}):null,n&&n.length>0?s.jsx("ul",{className:"space-y-2",children:n.map(f=>s.jsxs("li",{className:"rounded-lg border border-border p-3 text-sm",children:[s.jsx("div",{className:"break-all font-medium",children:f.storageUrl}),s.jsx("div",{className:"mt-1 break-all text-xs text-muted-foreground",children:f.webId})]},`${f.webId}|${f.storageUrl}`))}):null]}),s.jsxs("form",{onSubmit:h,className:"space-y-2 rounded-lg border border-border p-3",children:[s.jsx("label",{className:"block text-sm font-medium",htmlFor:"pod-management-name",children:"创建存储空间"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"创建是一次显式操作:不会因为登录或授权而自动发生。"}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx("input",{id:"pod-management-name",className:"h-10 min-w-48 flex-1 rounded-md border border-input bg-background px-3",value:i,placeholder:E||"my-pod",disabled:l,onChange:f=>d(f.currentTarget.value)}),s.jsx(C,{type:"submit",disabled:l,children:l?"正在创建…":"创建"})]}),m?s.jsx("div",{role:"alert",className:"text-sm text-destructive",children:m}):null,b?s.jsx("div",{role:"status",className:"text-sm text-muted-foreground",children:b}):null]})]})}function wt({kind:e,runtime:t,admin:r,configuration:n,provision:a,publicRoute:o,save:c}){const i=n?.env??{};return e==="pod"?s.jsx(mt,{runtime:t,publicRoute:o}):e==="identity-access"?s.jsx(bt,{runtime:t}):e==="storage"?s.jsxs(s.Fragment,{children:[s.jsx(N,{rows:Re(i,n?.secrets)}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Measured storage and bandwidth are intentionally shown in Status → Usage, not here. Storage migration is unavailable because this runtime does not report a migration capability."})]}):e==="runtime"?s.jsx(vt,{env:i,admin:r,save:c}):e==="cloud"?s.jsx(xt,{env:i,provision:a,save:c}):s.jsx(yt,{env:i,save:c})}function bt({runtime:e}){const[t,r]=u.useState("checking"),[n,a]=u.useState(!1),o=u.useCallback(async()=>{if(!e.webId||!e.podUrl||e.state.status!=="authenticated"){r("unavailable");return}r("checking");try{const d=H({webId:e.webId,podUrl:e.podUrl,authenticatedFetch:e.fetch}),l=V(await d.getServiceAccess(),e.podUrl),m=await Y({authenticatedFetch:e.fetch,ownerWebId:e.webId}).inspectAgentAccess(l);r(m.status==="granted"?"granted":"missing")}catch{r("error")}},[e.fetch,e.podUrl,e.state.status,e.webId]);u.useEffect(()=>{let d=!1;return queueMicrotask(()=>{d||o()}),()=>{d=!0}},[o]);const c=async()=>{if(!(!e.webId||!e.podUrl||!window.confirm("Revoke AI Gateway service access to Xpod settings resources? Provider credentials remain stored but the service can no longer use them."))){a(!0);try{const d=H({webId:e.webId,podUrl:e.podUrl,authenticatedFetch:e.fetch}),l=V(await d.getServiceAccess(),e.podUrl);await Y({authenticatedFetch:e.fetch,ownerWebId:e.webId}).revokeAgentAccess(l),r("missing")}catch{r("error")}finally{a(!1)}}},i=t==="granted"?"Granted":t==="missing"?"Not granted":t==="checking"?"Checking…":t==="unavailable"?"Unavailable while signed out":"Could not inspect";return s.jsxs(s.Fragment,{children:[s.jsx(N,{rows:[{label:"WebID",value:e.webId??"Signed out"},{label:"OIDC issuer",value:e.issuer??"Not reported"},{label:"Current account",value:e.webId?oe(e.webId):"Signed out"},{label:"Session",value:e.state.status},{label:"ACP / ACR",value:t==="error"?"Capability unavailable or permission denied":"Managed ACR capability available"},{label:"AI Gateway service access",value:i,detail:"Inspected from the managed ACRs for declared settings resources"}]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(C,{type:"button",variant:"outline",onClick:()=>{o()},disabled:t==="checking",children:"Recheck access"}),s.jsx(C,{type:"button",variant:"destructive",onClick:()=>{c()},disabled:t!=="granted"||n,children:n?"Revoking…":"Revoke service access"})]})]})}function vt({env:e,admin:t,save:r}){const n=e.CSS_BASE_URL??t?.env.CSS_BASE_URL??"",[a,o]=u.useState(n),[c,i]=u.useState(e.CSS_ROOT_FILE_PATH??"");return u.useEffect(()=>{let d=!1;return queueMicrotask(()=>{d||(o(n),i(e.CSS_ROOT_FILE_PATH??""))}),()=>{d=!0}},[e,n]),s.jsxs("div",{className:"space-y-4",children:[s.jsx(N,{rows:[{label:"Edition",value:t?.env.XPOD_EDITION??e.XPOD_EDITION??"local"},{label:"Configuration source",value:".env.local / runtime bootstrap"},{label:"Service startup",value:"Gateway supervises Solid Server and API Server"},{label:"Automatic restart",value:"Enabled for managed child services"}]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(j,{label:"Base URL",value:a,onChange:o}),s.jsx(j,{label:"Data directory",value:c,onChange:i})]}),s.jsx(F,{onClick:()=>r({CSS_BASE_URL:a,CSS_ROOT_FILE_PATH:c})})]})}function xt({env:e,provision:t,save:r}){const[n,a]=u.useState(e.XPOD_CLOUD_API_ENDPOINT??""),[o,c]=u.useState(e.XPOD_NODE_ID??""),[i,d]=u.useState(e.XPOD_SP_DOMAIN??"");return u.useEffect(()=>{let l=!1;return queueMicrotask(()=>{l||(a(e.XPOD_CLOUD_API_ENDPOINT??""),c(e.XPOD_NODE_ID??""),d(e.XPOD_SP_DOMAIN??""))}),()=>{l=!0}},[e]),s.jsxs("div",{className:"space-y-4",children:[s.jsx(N,{rows:[{label:"Node registration",value:t?.registered?"Registered":"Not registered",detail:t?.nodeId??"Node ID not reported"},{label:"Cluster coordination",value:t?.cloudUrl??"Not configured",detail:t?.managed?"This node is cluster-managed":"Not cluster-managed"},{label:"Service-provider domain",value:t?.serviceProviderDomain??"Not allocated"}]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsx(j,{label:"Cloud endpoint",value:n,onChange:a}),s.jsx(j,{label:"Node ID",value:o,onChange:c}),s.jsx(j,{label:"Service-provider domain",value:i,onChange:d})]}),s.jsx(F,{onClick:()=>r({XPOD_CLOUD_API_ENDPOINT:n,XPOD_NODE_ID:o,XPOD_SP_DOMAIN:i})})]})}function yt({env:e,save:t}){const[r,n]=u.useState(e.CSS_LOGGING_LEVEL??"info"),[a,o]=u.useState(e.CSS_SHOW_STACK_TRACE==="true");return u.useEffect(()=>{let c=!1;return queueMicrotask(()=>{c||(n(e.CSS_LOGGING_LEVEL??"info"),o(e.CSS_SHOW_STACK_TRACE==="true"))}),()=>{c=!0}},[e]),s.jsxs("div",{className:"space-y-4",children:[s.jsx(N,{rows:[{label:"Log retention",value:"30 days",detail:"Runtime logging profile"},{label:"Configuration provenance",value:".env.local allowlist"},{label:"Restart requirement",value:"Required after save"}]}),s.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:["Logging level",s.jsxs("select",{value:r,onChange:c=>n(c.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3 sm:max-w-xs",children:[s.jsx("option",{children:"debug"}),s.jsx("option",{children:"info"}),s.jsx("option",{children:"warn"}),s.jsx("option",{children:"error"})]})]}),s.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-md border border-border p-3 text-sm font-medium",children:["Show stack traces",s.jsx("input",{type:"checkbox",checked:a,onChange:c=>o(c.target.checked)})]}),s.jsx(F,{onClick:()=>t({CSS_LOGGING_LEVEL:r,CSS_SHOW_STACK_TRACE:String(a)})})]})}function N({rows:e}){return s.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:e.map(t=>s.jsxs("div",{className:"rounded-lg border border-border p-3",children:[s.jsx("div",{className:"text-xs text-muted-foreground",children:t.label}),s.jsx("div",{className:"mt-1 break-all text-sm font-medium",children:t.value}),t.detail?s.jsx("div",{className:"mt-1 text-xs text-muted-foreground",children:t.detail}):null]},t.label))})}function j({label:e,value:t,onChange:r}){return s.jsxs("label",{className:"block space-y-2 text-sm font-medium",children:[e,s.jsx("input",{value:t,onChange:n=>r(n.target.value),className:"block h-10 w-full rounded-md border border-input bg-background px-3"})]})}function F({onClick:e}){return s.jsx("div",{className:"flex justify-end",children:s.jsx(C,{type:"button",onClick:e,children:"Save configuration"})})}function oe(e){if(!e)return"Not discovered";try{return new URL(e).pathname.split("/").filter(Boolean).at(-1)||new URL(e).hostname}catch{return e}}function At(e){return e?e.status==="pass"?"Reachable":e.status==="fail"?"Not reachable":"Not verified":"Not checked"}const St={pod:"Pod","identity-access":"Identity & Access",storage:"Storage",runtime:"Runtime",cloud:"Cloud",advanced:"Advanced"},Ct={pod:"Current Pod identity and authority boundary.","identity-access":"Session, account, and app/service access.",storage:"Authority storage backends and health configuration.",runtime:"Edition, startup, paths, and restart behavior.",cloud:"Node registration and cluster coordination.",advanced:"Bounded logging and runtime compatibility controls."};export{Pt as PodSettingsSubjectPanel};
@@ -0,0 +1,3 @@
1
+ import{q as h,k as f,s as w,h as J,t as pe}from"./auth-callback-CAFZ3R0B.js";import{r as me,a as he,b as be}from"./index-browser-DtU38ni3.js";import{A as ae,s as O,d as B,c as k,o as X,p as ye,b as z,e as we,C as L}from"./ai-connections-CryuHGKW.js";function ve(e){const t=new TextEncoder().encode(JSON.stringify(e));let r="";for(const o of t)r+=String.fromCharCode(o);return btoa(r)}function Ie(e){const t=atob(e),r=Uint8Array.from(t,o=>o.charCodeAt(0));return JSON.parse(new TextDecoder().decode(r))}function ge(e){return JSON.stringify({algorithm:"PLAINTEXT",encoding:"base64",ciphertext:ve(e.secret),webId:e.webId,credentialIri:e.credentialIri,provider:e.provider})}function Se(e){if(!(typeof e.envelope!="string"||!e.envelope.trim()))try{const t=JSON.parse(e.envelope);if(t.algorithm!=="PLAINTEXT"||t.webId!==e.webId||t.provider!==e.provider||t.credentialIri!==e.credentialIri)return;const r=t.encoding==="base64"?Ie(String(t.ciphertext)):JSON.parse(String(t.ciphertext));return typeof r=="object"&&r!==null&&!Array.isArray(r)?r:void 0}catch{return}}function Re(e){return h.buildId({id:e})}function _e(e){return h.buildId({id:`custom-instance-${encodeURIComponent(e)}.ttl#this`})}function Q(e,t){const r=crypto.randomUUID();return t==="local"?`${e}-local-${r}`:`${e}-${r}`}function Ye(e){const t=(e.split("#",1)[0]??e).split("/").filter(Boolean).at(-1)??"",r=t.endsWith(".ttl")?t.slice(0,-4):t;if(r)return r.startsWith("custom-")||r==="custom"?"custom":ae.find(o=>r===o||r.startsWith(`${o}-`))}function A(e){if(!e)return;const t=e.split("#",1)[0]??e,r=t.split("/").filter(Boolean).at(-1)??t;if(!r)return;const o=r.endsWith(".ttl")?r:`${r}.ttl`,n=e.indexOf("#");return n<0?o:`${o}${e.slice(n)}`}function _(e){const t=A(e);if(t)return(t.split("#",1)[0]??t).replace(/\.ttl$/u,"")}var xe=me(),Ee=he();const M=Array.from(new Set([...ae,"zhipu","ollama","custom"])),G=new WeakMap,Ae=J.storage.base.slice(J.storage.base.lastIndexOf("/")+1);function Ce(e){const t=e.indexOf("#");return t<0?e:e.slice(0,t)}function Ze(e){Te(),pe({createQueryEngine:async()=>new be.QueryEngine});const t=new URL("settings/-/sparql",e.podUrl).toString();return f.setSparqlEndpoint(t),h.setSparqlEndpoint(t),w.setSparqlEndpoint(t),{credentialsTableDocument(){return f.buildIri(e.podUrl,{id:Ae})},providerTableDocument(r,o){const n=v(r);if(!n)throw new Error("unsupported_provider");const i=n==="custom"&&o?j(o):x(n);return h.buildIri(e.podUrl,{id:Ce(i)})},async listModels(){return await e.database.init?.(w),(await e.database.select().from(w).execute()).map($e).filter(U)},async listProviders(){await e.database.init?.(f,h,w);const r=await e.database.select().from(f).execute(),o=await e.database.select().from(h).execute(),n=await e.database.select().from(w).execute();return Me(e,r,o,n)},async createApiKeyCredential(r,o){const n=v(r);if(!n)throw new Error("unsupported_provider");await e.database.init?.(f,h);const i=d(o.id),a=i??f.buildId({id:Q(n,"apiKey")}),c=1,u=O(n,o.offeringId??B(n,"apiKey")),l=o.baseUrl??X(n,u),s=D(o.proxyUrl),p={id:a,provider:n==="custom"?j(a):x(n),service:"ai",authMode:"apiKey",offeringId:u,status:"active",accountLabel:o.label,label:o.label,baseUrl:l,proxyUrl:s,keyVersion:String(c),reauthRequired:!1,encryptedSecret:$(e,n,a,{type:"apiKey",apiKey:o.apiKey}),encryptionAlgorithm:"PLAINTEXT",metadata:{...k({offeringId:u,baseUrl:l,priority:o.priority}),...o.compatibility?{compatibility:o.compatibility}:{}}};return await ee(e,a,p,i!==void 0),y(e,n,p)},async createLocalCredential(r,o){const n=v(r);if(!n)throw new Error("unsupported_provider");await e.database.init?.(f,h);const i=d(o.id),a=i??f.buildId({id:Q(n,"local")}),c=O(n,o.offeringId??B(n,"local")),u=o.baseUrl??X(n,c),l={id:a,provider:x(n),service:"ai",authMode:"local",offeringId:c,status:"active",accountLabel:o.label??"Local",label:o.label??"Local",baseUrl:u,keyVersion:"1",reauthRequired:!1,encryptedSecret:$(e,n,a,{type:"local"}),encryptionAlgorithm:"PLAINTEXT",metadata:k({offeringId:c,baseUrl:u,priority:o.priority})};return await ee(e,a,l,i!==void 0),y(e,n,l)},async saveOAuthCredential(r,o){const n=v(r);if(!n)throw new Error("unsupported_provider");const a=(G.get(e.database)??Promise.resolve()).then(async()=>{await e.database.init?.(f,h);const c=O(n,o.offeringId??B(n,"deviceCode")),l=(await e.database.select().from(f).execute()).find(R=>{const C=y(e,n,R);if(!C||C.authMode!=="deviceCode"&&C.authMode!=="oauth"||re(n,C.offeringId)!==re(n,c)||R.status!=="active"&&R.status!=="disabled")return!1;const fe=T(e,n,C.id,R.encryptedSecret);return Oe(o,I(R.metadata),fe)}),s=l&&y(e,n,l),p=I(l?.metadata),m=s&&T(e,n,s.id,l?.encryptedSecret),b=s?.id??f.buildId({id:`${n}-oauth-${crypto.randomUUID()}`}),g=o.accountLabel??"OAuth",S=o.accountId??d(p?.accountId)??d(m?.accountId),H=o.accountSubject??d(p?.authoritativeSubject)??d(m?.accountSubject)??d(m?.authoritativeSubject),N={...l,id:b,provider:x(n),service:"ai",authMode:"deviceCodeOAuth",offeringId:c,status:s?.enabled===!1?"disabled":"active",accountLabel:l?.accountLabel??g,label:l?.label??g,expiresAt:o.expiresAt,scopes:o.scope?o.scope.split(/\s+/u).filter(Boolean):void 0,keyVersion:String((s?.version??0)+1),reauthRequired:!1,encryptedSecret:$(e,n,b,{type:"deviceCodeOAuth",accessToken:o.accessToken,refreshToken:o.refreshToken,expiresAt:o.expiresAt,scope:o.scope,idToken:o.idToken,accountId:S,accountSubject:H,accountLabel:o.accountLabel,offeringId:c,authorizationMethodId:o.authorizationMethodId}),encryptionAlgorithm:"PLAINTEXT",metadata:{...p,...k({offeringId:c,priority:s?.priority,enabled:s?.enabled,health:"healthy"}),authoritativeSubject:H,accountId:S,authorizationMethodId:o.authorizationMethodId}};if(l){const R={...N};if(delete R.id,!await e.database.updateById(f,b,R))throw new Error("credential_version_conflict")}else await e.database.insert(f).values(N).execute();return y(e,n,N)});return G.set(e.database,a.then(()=>{},()=>{})),a},async updateOAuthCredential(r,o,n,i){const a=v(r);if(!a)throw new Error("unsupported_provider");await e.database.init?.(f,h);const c=await e.database.findById(f,o),u=c&&y(e,a,c);if(!c||!u||u.authMode!=="deviceCode")throw new Error("oauth_credential_not_found");if(u.version!==n)throw new Error("credential_version_conflict");const l=T(e,a,o,c.encryptedSecret),s=i.accountId??d(I(c.metadata)?.accountId)??d(l?.accountId),p=i.accountSubject??d(I(c.metadata)?.authoritativeSubject)??d(l?.accountSubject)??d(l?.authoritativeSubject),m=O(a,i.offeringId??u.offeringId),b={expiresAt:i.expiresAt,scopes:i.scope?i.scope.split(/\s+/u).filter(Boolean):void 0,keyVersion:String(n+1),reauthRequired:!1,status:"active",encryptedSecret:$(e,a,o,{type:"deviceCodeOAuth",accessToken:i.accessToken,refreshToken:i.refreshToken,expiresAt:i.expiresAt,scope:i.scope,idToken:i.idToken,accountId:s,accountSubject:p,accountLabel:i.accountLabel??d(c.accountLabel),offeringId:m,authorizationMethodId:i.authorizationMethodId??d(I(c.metadata)?.authorizationMethodId)}),accountLabel:i.accountLabel??d(c.accountLabel),label:i.accountLabel??d(c.label),offeringId:m,metadata:{...I(c.metadata),...k({offeringId:m,health:"healthy"}),authoritativeSubject:p,accountId:s,authorizationMethodId:i.authorizationMethodId??d(I(c.metadata)?.authorizationMethodId)}},g=await e.database.updateById(f,o,b);if(!g)throw new Error("credential_version_conflict");return y(e,a,g)},async updateProviderCredential(r,o,n){const i=v(r);if(!i)throw new Error("unsupported_provider");await e.database.init?.(f,h);const a=await e.database.findById(f,o),c=a&&y(e,i,a);if(!a||!c)throw new Error("credential_not_found");if(c.version!==n.expectedVersion)throw new Error("credential_version_conflict");const u={...I(a.metadata),...n.priority===void 0?{}:{priority:n.priority},...n.enabled===void 0?{}:{enabled:n.enabled},...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},...n.proxyUrl===void 0?{}:{proxyUrl:D(n.proxyUrl)}},l={...n.label===void 0?{}:{accountLabel:n.label,label:n.label},...n.baseUrl===void 0?{}:{baseUrl:n.baseUrl},...n.proxyUrl===void 0?{}:{proxyUrl:D(n.proxyUrl)},...n.enabled===void 0?{}:{status:n.enabled?"active":"disabled"},keyVersion:String(c.version+1),metadata:u},s=await e.database.updateById(f,o,l);if(!s)throw new Error("credential_update_failed");const p=y(e,i,s);if(!p)throw new Error("credential_update_failed");return p},async markCredentialHealth(r,o,n,i){const a=v(r);if(!a)throw new Error("unsupported_provider");await e.database.init?.(f);const c=await e.database.findById(f,o),u=c&&y(e,a,c);if(!c||!u)throw new Error("credential_not_found");if(u.version!==i)throw new Error("credential_version_conflict");const l=await e.database.updateById(f,o,{keyVersion:String(u.version+1),metadata:{...I(c.metadata),health:n}});if(!l)throw new Error("credential_update_failed");const s=y(e,a,l);if(!s)throw new Error("credential_update_failed");return s},async deleteProviderCredential(r,o){const n=v(r);if(!n)throw new Error("unsupported_provider");await e.database.init?.(f,h);const i=await e.database.findById(f,o),a=i&&y(e,n,i);if(a)return await e.database.deleteById(f,o),a},async readCredentialSecret(r,o){const n=v(r);if(!n)throw new Error("unsupported_provider");const i=await e.database.findById(f,o);if(!i||!y(e,n,i))throw new Error("credential_not_found");const a=T(e,n,o,i.encryptedSecret);if(!a)throw new Error("credential_secret_unavailable");return a},async saveDiscoveredModels(r,o,n){const i=v(r);if(!i)throw new Error("unsupported_provider");await e.database.init?.(f,h,w);const a=await Y(e,o),c=te(i,a);await oe(e.database,c,z(i));const u=await e.database.select().from(w).execute(),l=new Set(u.map(m=>d(m.id)).filter(U)),s=n.map(Be).filter(U),p=new Set(s.map(m=>m.id));for(const m of u.filter(b=>ze(b,c,i))){const b=E(d(m.id),c)??ce(d(m.id));b&&!p.has(b)&&d(m.status)!=="unavailable"&&await e.database.updateById(w,String(m.id),{status:"unavailable"})}for(const m of s)await Ne(e.database,c,m,l)},async saveModelSelection(r,o,n){const i=v(r);if(!i)throw new Error("unsupported_provider");await e.database.init?.(h,w);const a=i==="custom"&&n?await Y(e,n):null;if(i==="custom"&&n&&!a)throw new Error("credential_not_found");const c=a?te(i,a):x(i);await oe(e.database,c,z(i));const l=(await e.database.select().from(h).execute()).find(S=>P(d(S.id),c)),s=d(l?.id)??c,p=le(l?.hasModel),m=await e.database.select().from(w).execute(),b=[...new Set(o.map(S=>De(i,S,m,a?c:void 0)))];if(!await e.database.updateById(h,s,{hasModel:b}))throw new Error("provider_model_selection_update_failed");e.authenticatedFetch&&await Ue(e,s,p,b)}}}const Pe="https://undefineds.co/ns#hasModel";async function Ue(e,t,r,o){const n=F(h,e.podUrl,t),i=r.map(s=>F(w,e.podUrl,s)),a=o.map(s=>F(w,e.podUrl,s)),c=s=>s.map(p=>`<${n}> <${Pe}> <${p}> .`).join(`
2
+ `),u=[i.length>0?`DELETE DATA { ${c(i)} }`:void 0,a.length>0?`INSERT DATA { ${c(a)} }`:void 0].filter(s=>!!s);if(u.length===0)return;const l=await e.authenticatedFetch(n.split("#",1)[0],{method:"PATCH",headers:{"content-type":"application/sparql-update"},body:u.join(`;
3
+ `)});if(!l.ok)throw new Error(`provider_model_selection_persist_failed:${l.status}`)}function F(e,t,r){return/^https?:\/\//u.test(r)?r:e.buildIri(t,{id:r})}async function Y(e,t){const r=await e.database.findById(f,t);return r||((await e.database.select().from(f).execute()).find(n=>{const i=d(n.id);return i===t||(i?f.buildIri(e.podUrl,{id:i})===t:!1)})??null)}function Te(){Z(xe.ActionObserverHttp.prototype),Z(Ee.ActionObserverHttp.prototype)}function Z(e){const t=e;if(t.__xpodObservedActorsPatch)return;const r=t.onRun;t.onRun=function(o,n,i){return Array.isArray(this.observedActors)||(this.observedActors=[]),r.call(this,o,n,i)},t.__xpodObservedActorsPatch=!0}function Me(e,t,r,o){const n=t.filter(i=>d(i.service)==="ai").filter(i=>d(i.status)!=="revoked");return M.map(i=>{const a=n.map(s=>y(e,i,s)).filter(U).sort((s,p)=>s.priority-p.priority||s.id.localeCompare(p.id)),c=r.find(s=>_(d(s.id))===i),l=le(c?.hasModel).map(s=>Le(i,s,o));return{id:i,name:i==="custom"?a.find(s=>s.label)?.label??z(i):z(i),offerings:i==="custom"?je(n.filter(s=>y(e,i,s))):ye(i,e.openAiSubscriptionImportAvailable===!0),credentials:a,selectedModels:l,status:Ve(a)}})}async function ee(e,t,r,o){if(!(o?await e.database.findById(f,t):null)){await e.database.insert(f).values(r).execute();return}const i={...r};if(delete i.id,!await e.database.updateById(f,t,i))throw new Error("credential_create_failed")}function $(e,t,r,o){return ge({webId:e.webId,provider:t,credentialIri:f.buildIri(e.podUrl,{id:r}),secret:o})}function Oe(e,t,r){let o=!1;for(const[n,i]of[[e.accountId,[t?.accountId,r?.accountId]],[e.accountSubject,[t?.authoritativeSubject,r?.accountSubject,r?.authoritativeSubject]]]){const a=[...new Set(i.map(d).filter(U).filter(c=>c.trim()))];if(a.length>1)return!1;if(!(!n?.trim()||!a.length)){if(a[0]!==n)return!1;o=!0}}return o}function y(e,t,r){const o=d(r.id);if(!o)return;const n=q(d(r.provider))??qe(o);if(n!==t)return;const i=I(r.metadata),a=ue(r.authMode);if(a)return{id:o,provider:n,offeringId:de(r,n,a),authMode:a,label:d(r.accountLabel)??d(r.label),enabled:ie(i?.enabled)??d(r.status)==="active",priority:ne(i?.priority)??100,health:He(i?.health)??(ie(r.reauthRequired)?"expired":"healthy"),maskedHint:Ke(e,n,o,r.encryptedSecret),baseUrl:d(r.baseUrl),proxyUrl:We(d(r.proxyUrl)??d(i?.proxyUrl)),compatibility:ke(i?.compatibility),expiresAt:Je(r.expiresAt),version:ne(r.keyVersion)??0}}function ke(e){return e==="auto"||e==="openai"||e==="anthropic"?e:void 0}function de(e,t,r){return d(e.offeringId)??d(I(e.metadata)?.offeringId)??W(d(e.provider))??B(t,r)}function Le(e,t,r){const o=r.find(c=>A(d(c.id))===A(t)),n=d(o?.isProvidedBy),i=o?E(t,n??e)??t:E(t,e)??t,a=o??r.find(c=>{const u=d(c.id),l=d(c.isProvidedBy);return u===t||E(u,e)===i||q(l)===e&&E(u,l??e)===i});return{id:i,provider:e,offeringId:W(d(a?.isProvidedBy)),credentialId:K(n),resourceId:d(a?.id)??t,displayName:d(a?.displayName),availability:d(a?.status)==="unavailable"||!a?"unavailable":"available"}}function $e(e){const t=d(e.isProvidedBy),r=q(t),o=r&&E(d(e.id),t??r);if(!(!r||!o))return{id:o,provider:r,offeringId:W(t),credentialId:K(t),resourceId:d(e.id),displayName:d(e.displayName),availability:d(e.status)==="unavailable"?"unavailable":"available",...Fe(e)}}function Be(e){const t=I(e),r=d(t?.id);if(r)return{id:r,displayName:d(t?.displayName),modelType:se(t?.modelType)}}function te(e,t){const r=K(d(t?.provider));return r?j(r):x(e)}function x(e){return Re(e)}function j(e){return _e(e)}function K(e){const t=_(e),r=t?.startsWith("custom-instance-")?t.slice(16):void 0;if(r)try{return decodeURIComponent(r)}catch{return}}function re(e,t){if(!t)return;const r=t.trim().toLowerCase();if(e==="bailian"){if(r==="token-plan")return"token-plan-personal";if(r==="coding-plan")return"coding-plan-pro";if(r==="payg")return"pay-as-you-go"}return r}function P(e,t){const r=A(e),o=A(t);return r!==void 0&&r===o}function ze(e,t,r){const o=d(e.isProvidedBy);return P(o,t)?!0:r==="custom"?!1:_(o)?.startsWith(`${r}-`)===!0}function ce(e){if(!e)return;const t=e.lastIndexOf("#");if(t<0||t===e.length-1)return;const r=e.slice(t+1);try{return decodeURIComponent(r)}catch{return r}}async function oe(e,t,r){(await e.select().from(h).execute()).some(n=>P(d(n.id),t))||await e.insert(h).values({id:t,displayName:r}).execute()}async function Ne(e,t,r,o){const n=V(t,r.id),i={displayName:r.displayName??r.id,isProvidedBy:t,status:"active",...r.modelType?{modelType:r.modelType}:{}};if(o.has(n)){await e.updateById(w,n,i);return}await e.insert(w).values({id:n,...i}).execute(),o.add(n)}function Fe(e){const t=se(e.modelType);return t?{modelType:t,...t==="embedding"?{capabilities:["embedding"]}:{}}:{}}function se(e){const t=d(e)?.trim().toLowerCase();return t==="chat"||t==="embedding"?t:void 0}function V(e,t){const r=A(e)??`${e}.ttl`;return`${r.split("#",1)[0]??r}#${encodeURIComponent(t)}`}function De(e,t,r,o){const n=d(t.resourceId),i=o??x(e),a=d(t.id),c=a?r.filter(l=>{const s=d(l.isProvidedBy),p=_(s);return(o?P(s,o):p===e||p?.startsWith(`${e}-`)===!0)&&E(d(l.id),s??i)===a}):[],u=o||c.length===1?c[0]:void 0;if(n){const l=r.find(b=>d(b.id)===n);if(!l&&u)return String(u.id);const s=d(l?.isProvidedBy),p=_(s),m=o?P(s,o):p===e||p?.startsWith(`${e}-`)===!0;if(l&&!m)throw new Error("invalid_model_selection_resource");if(!l){const b=a??ce(n),g=_(n),S=o?P(g,o):g===e||g?.startsWith(`${e}-`)===!0;if(!b||!S)throw new Error("invalid_model_selection_resource");return V(i,b)}return n}if(!a)throw new Error("invalid_model_selection_resource");return d(u?.id)??V(i,a)}function E(e,t){if(!e)return;const o=A(t)?.split("#",1)[0]??t,n=o.endsWith(".ttl")?`${o}#`:`${o}.ttl#`,i=e.lastIndexOf(n);if(!(i<0))try{return decodeURIComponent(e.slice(i+n.length))}catch{return e.slice(i+n.length)}}function le(e){if(Array.isArray(e))return e.map(d).filter(U);const t=d(e);return t?[t]:[]}function je(e){const t=new Map;for(const r of e){const o=I(r.metadata),n=de(r,"custom",ue(r.authMode)??"apiKey"),i=we(o?.compatibility,n),a=d(r.baseUrl)??d(o?.baseUrl),c=L.find(u=>u.id===n)??L.find(u=>u.id===`${i}-compatible`)??L[0];t.set(n,{...c,id:n,endpoints:a?[{protocol:i==="anthropic"?"anthropic":"chatCompletions",baseUrl:a}]:c.endpoints,modelDiscovery:i==="anthropic"?{strategy:"anthropic",path:"/models",endpointProtocol:"anthropic"}:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"}})}return t.size>0?[...t.values()]:L}function Ve(e){return e.some(t=>t.health==="expired"||t.health==="invalid")?"attention":e.some(t=>t.enabled)?"available":e.length>0?"configured":"unconfigured"}function Ke(e,t,r,o){const n=T(e,t,r,o),i=d(n?.apiKey);if(i)return i.length<=8?`${i.slice(0,2)}…`:`${i.slice(0,3)}...${i.slice(-4)}`}function T(e,t,r,o){return Se({webId:e.webId,provider:t,credentialIri:f.buildIri(e.podUrl,{id:r}),envelope:o})}function q(e){const t=_(e),r=v(t);return r||M.find(o=>t?.startsWith(`${o}-`))}function W(e){const t=_(e);if(t&&!t.startsWith("custom-instance-")){if(t==="bailian-token-plan-personal")return"token-plan";if(t==="bailian-token-plan-team")return"token-plan-team";if(t==="bailian-coding-plan-pro")return"coding-plan";if(t==="bailian-pay-as-you-go")return"pay-as-you-go";for(const r of M)if(t.startsWith(`${r}-`))return t.slice(r.length+1)}}function qe(e){const t=/\/([^/#]+)\.ttl#/u.exec(e);return v(t?.[1])}function v(e){if(typeof e!="string"||!e.trim())return;const t=e.trim().toLowerCase();if(t==="zhipu"||t.startsWith("zhipu-"))return"zhipu";if(M.includes(t))return t;for(const r of M)if(t.startsWith(`${r}-`)||r==="bailian"&&(t==="bailian-token-plan"||t==="bailian-coding-plan"))return r}function D(e){if(e==null||!e.trim())return;let t;try{t=new URL(e.trim())}catch{throw new Error("invalid_proxy_url")}if(!["http:","https:"].includes(t.protocol)||t.username||t.password||t.hash||!t.hostname)throw new Error("invalid_proxy_url");return t.toString().replace(/\/$/u,"")}function We(e){if(e==null||!e.trim())return;let t;try{t=new URL(e.trim())}catch{return}if(!(!["http:","https:"].includes(t.protocol)||!t.hostname))return t.username="",t.password="",t.search="",t.hash="",t.toString().replace(/\/$/u,"")}function ue(e){if(e==="oauth"||e==="deviceCode"||e==="apiKey"||e==="local")return e;if(e==="deviceCodeOAuth")return"deviceCode"}function He(e){if(e==="healthy"||e==="expired"||e==="invalid"||e==="unknown")return e;if(e==="reauthRequired")return"expired";if(e==="disabled")return"unknown"}function I(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function d(e){return typeof e=="string"&&e.trim()?e:void 0}function ne(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Number(e);return Number.isFinite(t)?t:void 0}}function ie(e){if(typeof e=="boolean")return e;if(e==="true")return!0;if(e==="false")return!1}function Je(e){return e instanceof Date?e.toISOString():d(e)}function U(e){return e!==void 0}export{_e as a,Re as b,Q as c,Ze as d,Ye as e,_ as p};
@@ -1 +1 @@
1
- import{c as t}from"./auth-callback-atKg_oig.js";const c=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],o=t("activity",c);export{o as A};
1
+ import{c as t}from"./auth-callback-CAFZ3R0B.js";const c=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],o=t("activity",c);export{o as A};
@@ -0,0 +1 @@
1
+ const s="/api/admin";async function l(t={}){try{const e=await fetch(`${s}/status`,{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get admin status:",e)}return null}async function u(t={}){try{const e=await fetch(`${s}/config`,{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get admin config:",e)}return null}async function f(t,e={}){try{const a=t?"?baseUrl="+encodeURIComponent(t):"",r=await fetch(s+"/public-ip"+a,{signal:e.signal});if(r.ok)return await r.json()}catch(a){console.error("Failed to get public ip check:",a)}return null}async function w(t){try{return(await fetch(`${s}/config`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:t})})).ok}catch(e){return console.error("Failed to update admin config:",e),!1}}async function P(){try{return(await fetch(`${s}/restart`,{method:"POST"})).ok}catch(t){return console.error("Failed to trigger restart:",t),!1}}async function $(t){try{return(await fetch(`/service/restart/${t}`,{method:"POST"})).ok}catch(e){return console.error(`Failed to restart ${t}:`,e),!1}}async function g(t={}){try{const e=await fetch("/service/status",{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get gateway status:",e)}return null}async function k(t={}){try{const a=h(t).toString(),r=await fetch(`${s}/rdf/stats${a?`?${a}`:""}`);if(r.ok)return await r.json()}catch(e){console.error("Failed to get RDF stats:",e)}return null}function h(t){const e=new URLSearchParams;return c(e,"cacheScopeQuery",t.cacheScopeQuery),c(e,"cacheScopePrincipal",t.cacheScopePrincipal),c(e,"cacheScopeBasePath",t.cacheScopeBasePath),c(e,"cacheScopeMode",t.cacheScopeMode),c(e,"cacheScopeAuthorizationModel",t.cacheScopeAuthorizationModel),c(e,"cacheScopePermissionVersion",t.cacheScopePermissionVersion),c(e,"cacheScopeLimit",t.cacheScopeLimit),e}function c(t,e,a){a!==void 0&&a!==""&&t.set(e,String(a))}async function S(t){try{const e=new URLSearchParams;t?.limit&&e.set("limit",t.limit.toString()),t?.level&&t.level!=="all"&&e.set("level",t.level),t?.source&&t.source!=="all"&&e.set("source",t.source);const a=e.toString(),r=await fetch(`${s}/logs${a?`?${a}`:""}`);if(r.ok){const n=await r.json();return Array.isArray(n)?n:n.logs??[]}}catch(e){console.error("Failed to get logs:",e)}return[]}async function m(t){try{const e=new URLSearchParams;t?.lines&&e.set("lines",t.lines.toString());const a=e.toString(),r=await fetch(`${s}/logs/file${a?`?${a}`:""}`);if(r.ok)return await r.json()}catch(e){console.error("Failed to get log file tail:",e)}return null}async function v(){const[t,e,a,r,n,i]=await Promise.all([g(),l(),u(),d(),S({limit:200}),m({lines:120})]);return{generatedAt:new Date().toISOString(),gatewayStatus:t,adminStatus:e,sanitizedConfig:{env:a?.env??{},secrets:a?.secrets??{}},ddnsStatus:r,recentLogs:n,logFile:i}}function F(t,e){const a=new EventSource(`${s}/logs/stream`);return a.onmessage=r=>{try{const n=JSON.parse(r.data);n.logs&&t(n.logs)}catch(n){console.error("Failed to parse log data:",n)}},a.onerror=r=>{console.error("Log stream error:",r),e?.(r)},()=>{a.close()}}function y(t){return t?t.startsWith("http://")||t.startsWith("https://")?t:`https://${t}/`:""}function p(t,e,a=""){return e?.baseUrl||y(e?.fqdn)||t.CSS_BASE_URL||a}async function d(t={}){try{const e=await fetch(`${s}/ddns`,{signal:t.signal});if(e.ok)return await e.json()}catch(e){console.error("Failed to get ddns status:",e)}return null}async function b(t={}){try{const e=await fetch("/provision/status",{signal:t.signal,credentials:"include",headers:{accept:"application/json"}});if(!e.ok)return null;const a=await e.json();return{registered:a.registered===!0,managed:a.managed===!0,nodeId:o(a.nodeId),cloudUrl:o(a.cloudUrl),serviceProviderDomain:o(a.spDomain),publicUrl:o(a.publicUrl)}}catch(e){return console.error("Failed to get provision status:",e),null}}function o(t){return typeof t=="string"&&t.length>0?t:null}async function A(t={}){const[e,a,r,n]=await Promise.all([g(t),l(t),u(t),d(t)]),i=await f(p(r?.env??{},n),t);return{servicesData:e,adminData:a,configData:r,ddnsData:n,publicCheck:i,checkedAt:new Date}}export{S as a,b,d as c,l as d,u as e,A as f,k as g,f as h,p as i,v as j,m as k,$ as r,F as s,P as t,w as u};
@@ -0,0 +1 @@
1
+ const D=["openai","anthropic","kimi","bailian","deepseek","zhipu","ollama","custom"],ee="AI Connection request failed. Please try again.";function Ot(e){if(e==null||!e.trim())return;let t;try{t=new URL(e.trim())}catch{throw new Error("invalid_proxy_url")}if(!["http:","https:"].includes(t.protocol)||t.username||t.password||t.hash)throw new Error("invalid_proxy_url");if(!t.hostname)throw new Error("invalid_proxy_url");return t.href.replace(/\/$/u,"")}class ge extends Error{constructor(t,n){super(t),this.name="AiConnectionsRequestError",this.code=oe(n),this.providerStatus=p(n)&&typeof n.providerStatus=="number"?n.providerStatus:void 0}}function Et(e){return e instanceof Error?F(e.message):F(String(e))}function G(e,t,n={}){const s=oe(e);if(s==="provider_models_response_error"){const f=p(e)&&typeof e.message=="string"?$(e.message):void 0;return f||"模型列表获取失败。请检查密钥、服务地址或网络后重试。"}if(s==="provider_models_fetch_failed"){const f=p(e)&&typeof e.providerStatus=="number"?e.providerStatus:void 0,h=p(e)&&typeof e.providerMessage=="string"?e.providerMessage.trim():void 0;return Ie(be(f,n.authMode),h)}const c=s?E(s,n.provider):void 0;if(c)return c;const d=p(e)&&typeof e.error=="string"?e.error:void 0;if(d){const f=E(d,n.provider);if(f)return f;if(d==="AI Connection service identity is unavailable")return d;if(d==="Provider credential not found for current identity")return"当前身份没有可用的额度凭证。";if(d==="Provider quota adapter not found"||d==="Provider quota lookup failed")return"该接入方式不支持查询官方额度。"}return t===401?"Please sign in again to continue.":t===403?"AI Connection permission was denied.":t===404&&n.provider?`${N(n.provider)} connection is not configured.`:t===429?"AI Connection is rate limited. Please try again later.":t===503?"AI Connection service is unavailable.":ee}const te="订阅登录态自动刷新失败,请稍后重试。",ne="订阅登录态已失效,请在原客户端重新登录后重读,或使用设备码登录。",ie="订阅登录态不可用,请重读登录态或重新登录后再同步模型。",re=new Set([ie,te,ne,"密钥不可用。请检查密钥是否填写正确,或换一个密钥后重试。","模型服务地址不正确。请检查服务地址后重试。","请求太频繁。请稍等一会儿再试。","模型服务暂时没有响应。请稍后重试。","模型列表获取失败。请检查密钥、服务地址或网络后重试。"]);function F(e){if(e.startsWith("provider_models_response_error:"))return $(e.slice(31))??"模型列表获取失败。请检查密钥、服务地址或网络后重试。";const t=E(e);if(t)return t;const n=e.split(":",1)[0]?.trim(),s=n?E(n):void 0;return s||(e==="AI Connection service identity is unavailable"||re.has(e)||Ae(e)?e:e.startsWith("invalid_")?"AI Connection returned an invalid response.":ee)}function oe(e){if(p(e)){if(typeof e.code=="string")return e.code;if(typeof e.errorCode=="string")return e.errorCode;if(typeof e.error=="string"&&/^[a-z][a-z0-9_:-]{0,80}$/i.test(e.error))return e.error}}function E(e,t){switch(e.trim().toLowerCase().replace(/-/g,"_")){case"not_configured":case"notconfigured":return t?`${N(t)} connection is not configured.`:"AI provider connection is not configured.";case"unsupported":return t?`${N(t)} does not support this operation.`:"This AI Connection operation is not supported.";case"service_identity_unavailable":return"AI Connection service identity is unavailable";case"unauthorized":return"Please sign in again to continue.";case"forbidden":case"permission_denied":return"AI Connection permission was denied.";case"rate_limited":return"AI Connection is rate limited. Please try again later.";case"service_unavailable":return"AI Connection service is unavailable.";case"unsafe_provider_base_url":return"该服务地址指向 Xpod 不允许访问的网络,请改用公网 HTTPS 地址。";case"invalid_proxy_url":return"代理地址必须是无账号密码的 HTTP 或 HTTPS 地址。";case"oauth_refresh_failed":case"oauth_refresh_unavailable":case"local_session_refresh_failed":return te;case"oauth_session_reauth_required":case"oauth_refresh_token_required":case"local_session_reauth_required":case"local_session_missing_refresh_token":return ne;case"models_persistence_failed":return"模型已获取,但保存到 Pod 失败。请重试同步模型。";case"quota_credential_not_found":return"当前身份没有可用的额度凭证。";case"credential_secret_unavailable":return"当前凭证密钥不可用,请重新保存后再查询额度。";case"gateway_api_key_plaintext_unavailable":return"Pod 中未找到此 API Key 的原文,无法复制配置。请创建新的 Key,更新客户端后再删除旧 Key。";case"quota_adapter_not_found":return"该接入方式不支持查询官方额度。";default:return}}function be(e,t){return e===401||e===403?t==="deviceCodeOAuth"?ie:"密钥不可用。请检查密钥是否填写正确,或换一个密钥后重试。":e===404?"模型服务地址不正确。请检查服务地址后重试。":e===429?"请求太频繁。请稍等一会儿再试。":e!==void 0&&e>=500?"模型服务暂时没有响应。请稍后重试。":"模型列表获取失败。请检查密钥、服务地址或网络后重试。"}function Ie(e,t){const n=t?$(t):void 0;return n?`${e} 上游返回:${n}`:e}function Ae(e){const n=e.indexOf(" 上游返回:");return n<=0?!1:re.has(e.slice(0,n))}function $(e){return e.replace(/[\u0000-\u001f\u007f]/gu," ").replace(/\bBearer\s+[^\s,;]+/giu,"Bearer [REDACTED]").replace(/(?:sk|id)[._-][A-Za-z0-9._-]{8,}/gu,"[REDACTED]").replace(/https?:\/\/[^\s]+/giu,"[URL]").trim().slice(0,240)||void 0}function N(e){switch(e){case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"kimi":return"Kimi";case"bailian":return"Bailian";case"deepseek":return"DeepSeek";case"zhipu":return"Zhipu";case"ollama":return"Ollama";case"custom":return"Custom"}}async function B(e){const t=await e.text();if(t)try{return JSON.parse(t)}catch{throw new Error(`AI Connection returned invalid JSON (${e.status})`)}}function Pe(e){if(!D.includes(e))throw new Error(`Unsupported AI provider: ${e}`)}function R(e){if(!(!p(e)||typeof e.id!="string"||typeof e.owner!="string"||!Array.isArray(e.scopes)||!e.scopes.every(t=>typeof t=="string")||typeof e.createdAt!="string"))return y({id:e.id,kind:e.kind==="client-credentials"?e.kind:void 0,credentialResource:o(e.credentialResource),fingerprint:o(e.fingerprint),owner:e.owner,scopes:e.scopes,createdAt:e.createdAt,expiresAt:o(e.expiresAt),lastUsedAt:o(e.lastUsedAt),disabledAt:o(e.disabledAt),revokedAt:o(e.revokedAt),name:o(e.name),maskedHint:o(e.maskedHint),plaintextAvailable:typeof e.plaintextAvailable=="boolean"?e.plaintextAvailable:void 0,clientCredentialId:o(e.clientCredentialId),appliedTo:o(e.appliedTo),appliedOn:o(e.appliedOn),appliedAt:o(e.appliedAt),appliedClients:U(e.appliedClients)})}function V(e){if(!Array.isArray(e))throw new Error("AI Connection returned an invalid custom models response");const t=[];for(const n of e)!p(n)||typeof n.id!="string"||!n.id||t.push(y({id:n.id,displayName:o(n.displayName),inputModalities:U(n.inputModalities),outputModalities:U(n.outputModalities),capabilities:U(n.capabilities)}));return t}function U(e){if(!Array.isArray(e))return;const t=e.filter(n=>typeof n=="string");return t.length>0?t:void 0}function ae(e){if(!p(e)||typeof e.id!="string"||Ue(e.id))return;const t=g(e.provider)??g(e.providerId)??g(e.owned_by)??Ce(e.id);if(!t)return;const n=p(e.capabilities)?e.capabilities.imageInput:void 0;return y({id:e.id,provider:t,offeringId:o(e.offeringId),resourceId:o(e.resourceId),displayName:o(e.displayName)??o(e.display_name)??o(e.name),contextWindow:W(e.contextWindow)??W(e.context_window),protocols:Array.isArray(e.protocols)?e.protocols.filter(s=>typeof s=="string"):void 0,custom:e.custom===!0?!0:void 0,inputModalities:J(e.modalities,"input")??(n===!0?["text","image"]:n===!1?["text"]:void 0),outputModalities:J(e.modalities,"output"),capabilities:we(e)})}function J(e,t){if(!p(e))return;const n=e[t];if(!Array.isArray(n))return;const s=n.filter(c=>typeof c=="string");return s.length>0?s:void 0}function we(e){if(Array.isArray(e.custom_capabilities)){const n=e.custom_capabilities.filter(s=>typeof s=="string");if(n.length>0)return n}if(!p(e.capabilities))return;const t=[];return e.capabilities.imageInput===!0&&t.push("image"),e.capabilities.toolCalls===!0&&t.push("tool_call"),e.capabilities.reasoningEffort===!0&&t.push("reasoning"),e.capabilities.fast===!0&&t.push("fast"),e.capabilities.embedding===!0&&t.push("embedding"),t.length>0?t:void 0}function Ue(e){const t=e.toLowerCase();return t==="linx"||t==="linx-lite"||t==="undefineds/linx"||t==="undefineds/linx-lite"}function g(e){if(typeof e!="string")return;const t=e.toLowerCase().trim();return t==="alibaba"||t==="dashscope"||t==="alibaba-bailian"||t==="bailian-coding-plan"||t==="bailian-token-plan"?"bailian":D.includes(t)?t:void 0}function Ce(e){const t=e.split("/",1)[0];return e.includes("/")?g(t):void 0}function W(e){return typeof e=="number"&&Number.isFinite(e)?e:void 0}function _e(e){const t=new Map;for(const n of e){const s=ke(n);if(!s)continue;const c=t.get(s.id);t.set(s.id,c?ze(c,s):s)}return[...t.values()]}function ke(e){return Me(e)??Se(e)}function Se(e){if(!p(e)||typeof e.provider!="string"||!Qe(e.status)||!p(e.connect)||!Array.isArray(e.connect.modes)||!e.connect.modes.every(H)||typeof e.connect.configured!="boolean")return;const t=g(e.provider);if(!t)return;const n=Ke(e,t);return{id:t,name:fe(t),offerings:[],credentials:n?[n]:[],selectedModels:[],status:$e(e.status)}}function Me(e){if(!p(e))return;const t=g(e.id)??g(e.provider);if(!t||!Be(e.status))return;const n=I(e.offerings,Oe),s=I(e.credentials,C),c=I(e.selectedModels,ae);return{id:t,name:o(e.name)??fe(t),offerings:n,credentials:s,selectedModels:c,status:e.status}}function Oe(e){if(!p(e)||typeof e.id!="string"||!e.id)return;const t=I(e.authModes,pe);return y({id:e.id,label:o(e.label),kind:o(e.kind),lifecycle:xe(e.lifecycle),authModes:t,authorizationMethods:I(e.authorizationMethods,se),runtimeProviderIds:U(e.runtimeProviderIds),productLabel:o(e.productLabel),credentialPrefixHints:U(e.credentialPrefixHints),consoleUrl:o(e.consoleUrl),subscriptionUrl:o(e.subscriptionUrl),endpoints:I(e.endpoints,ce),modelDiscovery:Le(e.modelDiscovery),quota:qe(e.quota),usagePolicyUrl:o(e.usagePolicyUrl),region:o(e.region)})}function Ee(e){if(!p(e)||typeof e.offeringId!="string"||!e.offeringId)return;const t=g(e.provider);if(!t)return;const n=I(e.authorizationMethods,se);return{provider:t,offeringId:e.offeringId,...Array.isArray(e.endpoints)?{endpoints:I(e.endpoints,ce)}:{},authorizationMethods:n}}function se(e){if(!p(e)||typeof e.id!="string"||!e.id)return;const t=pe(e.authMode),n=Te(e.lifecycle);if(!t||!n)return;const s=H(e.connectMode)?e.connectMode:void 0;return y({id:e.id,authMode:t,connectMode:s,label:o(e.label)??Re(e.id,t),lifecycle:n,reason:o(e.reason)})}function Te(e){return e==="active"||e==="unavailable"?e:void 0}function Re(e,t){return e==="device-code"?"设备码登录":e==="local-session-import"?"已有登录态":e==="local-service"?"本地服务":e==="api-key"||t==="apiKey"?"API Key":t==="local"?"本地服务":"浏览器登录"}function xe(e){return e==="active"||e==="legacy"||e==="unavailable"?e:void 0}function ce(e){if(!p(e))return;const t=o(e.protocol),n=o(e.baseUrl);if(!(!t||!n))return y({protocol:t,baseUrl:n,region:o(e.region)})}function Le(e){if(!p(e))return;const t=o(e.strategy),n=o(e.path),s=o(e.endpointProtocol);return t&&n&&s?{strategy:t,path:n,endpointProtocol:s}:void 0}function qe(e){if(!p(e))return;const t=o(e.strategy),n=o(e.url);return t&&n?{strategy:t,url:n}:void 0}function C(e){if(!(!p(e)||typeof e.id!="string"||!e.id||typeof e.offeringId!="string"||!e.offeringId||!ue(e.authMode)||typeof e.enabled!="boolean"||typeof e.priority!="number"||!Number.isFinite(e.priority)||!Fe(e.health)||typeof e.version!="number"||!Number.isFinite(e.version)))return y({id:e.id,provider:g(e.provider),offeringId:e.offeringId,authMode:e.authMode,label:o(e.label),enabled:e.enabled,priority:e.priority,health:e.health,maskedHint:o(e.maskedHint),baseUrl:o(e.baseUrl),proxyUrl:o(e.proxyUrl),expiresAt:o(e.expiresAt),version:e.version})}function de(e){return p(e)?Object.fromEntries(Object.entries(e).filter(([t])=>!Ne(t)).map(([t,n])=>[t,le(n)])):{}}function le(e){return Array.isArray(e)?e.map(le):p(e)?de(e):e}function Ne(e){const t=e.toLocaleLowerCase();return t.includes("secret")||t.includes("token")||t.includes("apikey")||t==="api_key"||t==="key"||t==="authorization"}function ze(e,t){const n=x([...e.credentials,...t.credentials],d=>d.id),s=x([...e.offerings,...t.offerings],d=>d.id),c=x([...e.selectedModels,...t.selectedModels],De);return{id:e.id,name:e.name??t.name,offerings:s,credentials:n,selectedModels:c,status:He(e.status,t.status)}}function De(e){return e.resourceId??`${e.provider}:${e.offeringId??""}:${e.id}`}function $e(e){return e==="connected"?"available":e==="reauthRequired"?"attention":"unconfigured"}function He(e,t){return e==="available"||t==="available"?"available":e==="attention"||t==="attention"?"attention":e==="configured"||t==="configured"?"configured":e==="unconfigured"||t==="unconfigured"?"unconfigured":"unavailable"}function Ke(e,t){if(e.status==="disconnected")return;const n=je(e.authMode);return y({id:o(e.credentialIri)??`${t}:current`,offeringId:Ge(t,n),authMode:n,label:o(e.accountLabel),enabled:e.status==="connected",priority:0,health:e.status==="reauthRequired"||e.reauthRequired===!0?"expired":"healthy",maskedHint:o(e.maskedHint),baseUrl:o(e.baseUrl),proxyUrl:o(e.proxyUrl),expiresAt:o(e.expiresAt),version:typeof e.version=="number"?e.version:0})}function je(e){return e==="deviceCodeOAuth"?"deviceCode":"apiKey"}function Ge(e,t){return e==="kimi"&&(t==="deviceCode"||t==="oauth")?"subscription-key":t==="deviceCode"||t==="oauth"?"official-subscription":"api-platform"}function pe(e){return ue(e)?e:void 0}function ue(e){return e==="oauth"||e==="deviceCode"||e==="apiKey"||e==="local"}function Fe(e){return e==="healthy"||e==="expired"||e==="invalid"||e==="unknown"}function Be(e){return e==="unconfigured"||e==="configured"||e==="available"||e==="attention"||e==="unavailable"}function I(e,t){return Array.isArray(e)?e.map(t).filter(_):[]}function x(e,t){const n=new Set,s=[];for(const c of e){const d=t(c);n.has(d)||(n.add(d),s.push(c))}return s}function fe(e){switch(e){case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"kimi":return"Kimi";case"bailian":return"Alibaba Bailian";case"deepseek":return"DeepSeek";case"zhipu":return"Zhipu";case"ollama":return"Ollama";case"custom":return"Custom"}}function Ve(e){if(!p(e)||typeof e.id!="string"||typeof e.credentialIri!="string"||typeof e.webId!="string"||typeof e.provider!="string"||typeof e.authMode!="string"||typeof e.status!="string")return;const t=g(e.provider);if(t)return y({id:e.id,credentialIri:e.credentialIri,webId:e.webId,provider:t,authMode:e.authMode,status:e.status,accountLabel:o(e.accountLabel),expiresAt:o(e.expiresAt),version:typeof e.version=="number"?e.version:void 0,reauthRequired:typeof e.reauthRequired=="boolean"?e.reauthRequired:void 0})}function Je(e,t){if(!p(e)||!H(e.mode)||!Xe(e.status)||e.provider!==t)throw new Error("AI Connection returned an invalid Connect response");return y({mode:e.mode,status:e.status,provider:t,attemptId:o(e.attemptId),state:o(e.state),signature:o(e.signature),expiresAt:o(e.expiresAt),authorizationUrl:L(e.authorizationUrl),userCode:o(e.userCode),verificationUri:L(e.verificationUri),verificationUriComplete:L(e.verificationUriComplete),intervalSeconds:typeof e.intervalSeconds=="number"?e.intervalSeconds:void 0,apiKeyManagementSupported:typeof e.apiKeyManagementSupported=="boolean"?e.apiKeyManagementSupported:void 0,credentialId:o(e.credentialId),offeringId:o(e.offeringId),authorizationMethodId:o(e.authorizationMethodId),oauthCredential:We(e.oauthCredential),message:o(e.message)})}function We(e){if(e!==void 0){if(!p(e)||typeof e.accessToken!="string"||!e.accessToken||typeof e.refreshToken!="string"||!e.refreshToken)throw new Error("AI Connection returned an invalid OAuth credential payload");return y({accessToken:e.accessToken,refreshToken:e.refreshToken,expiresAt:o(e.expiresAt),scope:o(e.scope),idToken:o(e.idToken),accountSubject:o(e.accountSubject),accountId:o(e.accountId),accountLabel:o(e.accountLabel),offeringId:o(e.offeringId),authorizationMethodId:o(e.authorizationMethodId),expectedVersion:typeof e.expectedVersion=="number"?e.expectedVersion:void 0})}}function Ye(e,t){if(!p(e)||!Array.isArray(e.models))throw new Error("AI Connection returned an invalid model discovery response");const n=e.models.map(s=>{if(!p(s)||typeof s.id!="string"||!s.id)return;const c=Array.isArray(s.capabilities)?s.capabilities.filter(f=>typeof f=="string"):void 0,d=Ze(s.modelType);return y({id:s.id,displayName:o(s.displayName),capabilities:c??(d==="embedding"?["embedding"]:void 0),modelType:d})}).filter(_);return{provider:t,credential:typeof e.credential=="string"?e.credential:"",models:n,observedAt:typeof e.observedAt=="string"?e.observedAt:new Date(0).toISOString(),source:typeof e.source=="string"?e.source:""}}function y(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==void 0))}function Ze(e){return e==="chat"||e==="embedding"?e:void 0}function o(e){return typeof e=="string"?e:void 0}function L(e){if(typeof e=="string")try{const t=new URL(e);return t.protocol==="https:"||t.protocol==="http:"?t.href:void 0}catch{return}}function H(e){return e==="browserAssistedApiKey"||e==="deviceCodeOAuth"||e==="authorizationCodeOAuth"||e==="connectUnsupported"}function Xe(e){return e==="pending"||e==="authorization_pending"||e==="slow_down"||e==="completed"||e==="expired"||e==="cancelled"||e==="unsupported"}function Qe(e){return e==="connected"||e==="disconnected"||e==="reauthRequired"}function p(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function _(e){return e!==void 0}function K(e){const t=new URL(e);if(t.protocol!=="https:"&&t.protocol!=="http:")throw new Error("Current Pod URL must use HTTP or HTTPS");return t.origin}function ve({webId:e,podBaseUrl:t,authenticatedFetch:n}){const s=K(t),c=async(r,i,a,l={})=>{const u=await n(`${s}${r}`,{method:i,credentials:"omit",mode:"cors",headers:{accept:"application/json",...a?{"content-type":"application/json"}:{}},...a?{body:JSON.stringify(a)}:{}}),m=await B(u);if(!u.ok)throw new ge(G(m,u.status,l),m);return m},d=r=>(Pe(r),`/api/ai/gateway/providers/${r}`),f=async(r,i,a,l)=>{const u=await c(`${d(r)}${i}`,a,l,{provider:r});return Je(u,r)},h=async()=>{const r=await c("/v1/models","GET");return Array.isArray(r.data)?r.data.map(ae).filter(_):[]};return{webId:e,apiBase:s,getServiceAccess(){return c("/api/applets/service-access/ai-connections","GET")},async listProviders(){const r=await c("/api/ai/providers","GET");return Array.isArray(r.data)?_e(r.data):[]},async listAuthorizationMethods(){const r=await n(`${s}/api/ai/connections/authorization-methods`,{method:"GET",credentials:"omit",mode:"cors",headers:{accept:"application/json"}});if(r.status===404)return[];const i=await B(r);if(!r.ok)throw new Error(G(i,r.status));return p(i)&&Array.isArray(i.data)?i.data.map(Ee).filter(_):[]},listModels:h,listGatewayModels:h,async listGatewayKeys(){const r=await c("/api/ai/gateway/keys","GET");return Array.isArray(r.data)?r.data.map(R).filter(_):[]},async createGatewayKey(r){const i=await c("/api/ai/gateway/keys","POST",y(r));if(typeof i.key!="string"||!i.key)throw new Error("Xpod did not return the new API Key");const a=R(i.record);if(!a)throw new Error("Xpod returned an invalid API Key record");return{plaintext:i.key,record:a}},async updateGatewayKey(r,i){const a=await c(`/api/ai/gateway/keys/${encodeURIComponent(r)}`,"PATCH",i),l=R(a.record);if(!l)throw new Error("Xpod returned an invalid API Key record");return l},async deleteGatewayKey(r){await c(`/api/ai/gateway/keys/${encodeURIComponent(r)}`,"DELETE")},async beginConnect(r,i,a){return await f(r,"/connect/begin","POST",y({mode:i,offeringId:a?.offeringId,authorizationMethodId:a?.authorizationMethodId}))},connectStatus(r,i){if(!i.attemptId)throw new Error("Connect attempt id is required");const a=new URLSearchParams({state:i.state??"",signature:i.signature??""});return i.mode&&a.set("mode",i.mode),f(r,`/connect/status/${encodeURIComponent(i.attemptId)}?${a}`,"GET")},completeApiKey(r,i,a,l,u){return f(r,"/connect/complete-api-key","POST",y({attemptId:i.attemptId,state:i.state,signature:i.signature,offeringId:i.offeringId,apiKey:a,accountLabel:l,baseUrl:u}))},pollDevice(r,i){return f(r,"/connect/poll","POST",y({mode:i.mode,attemptId:i.attemptId,state:i.state,signature:i.signature,offeringId:i.offeringId}))},cancelConnect(r,i){return f(r,"/connect/cancel","POST",y({mode:i.mode,attemptId:i.attemptId,state:i.state,signature:i.signature,offeringId:i.offeringId}))},refreshOAuthCredential(r,i,a,l,u,m){return f(r,"/connect/refresh","POST",{credentialId:i,refreshToken:a,expectedVersion:l,...u?{offeringId:u}:{},...m?{mode:m}:{}})},async disconnect(r,i){const a=i?`?${new URLSearchParams({credentialId:i})}`:"",l=await c(`${d(r)}/connect${a}`,"DELETE");return Ve(l.record)},async createApiKeyCredential(r,i){const a=await c(`/api/ai/providers/${r}/credentials/api-key`,"POST",y({...i}),{provider:r}),l=C(a.credential);if(!l)throw new Error("AI Connection returned an invalid Provider credential");return l},async createLocalCredential(r,i){const a=await c(`/api/ai/providers/${r}/credentials/local`,"POST",y(i),{provider:r}),l=C(a.credential);if(!l)throw new Error("AI Connection returned an invalid Provider credential");return l},async updateProviderCredential(r,i,a){const l=await c(`/api/ai/providers/${r}/credentials/${encodeURIComponent(i)}`,"PATCH",y({...a}),{provider:r}),u=C(l.credential);if(!u)throw new Error("AI Connection returned an invalid Provider credential");return u},async deleteProviderCredential(r,i){const a=await c(`/api/ai/providers/${r}/credentials/${encodeURIComponent(i)}`,"DELETE",void 0,{provider:r});return C(a.credential)},async testProviderCredential(r,i){const a=await c(`/api/ai/providers/${r}/credentials/test`,"POST",y({...i}),{provider:r});return de(a.result)},quota(r,i=!1,a){const l=!i&&a?.credentialIri?`?credentialIri=${encodeURIComponent(a.credentialIri)}${a.offeringId?`&offeringId=${encodeURIComponent(a.offeringId)}`:""}`:"";return c(`${d(r)}/quota/${i?"refresh":"status"}${l}`,i?"POST":"GET",i?y({offeringId:a?.offeringId,credentialId:a?.credentialId,credentialIri:a?.credentialIri}):void 0,{provider:r})},quotaFromSecret(r,i){return c(`${d(r)}/quota/refresh`,"POST",y(i),{provider:r})},async discoverModels(r,i){const a=await c(`${d(r)}/models/refresh`,"POST",y({...i}),{provider:r,authMode:i?.authMode});return Ye(a,r)},async saveProviderModel(r,i){const a=await c(d(r)+"/models","POST",y({id:i.id,displayName:i.displayName,inputModalities:i.inputModalities,outputModalities:i.outputModalities,capabilities:i.capabilities}),{provider:r});return V(a.data)},async deleteProviderModel(r,i){const a=await c(`${d(r)}/models/${encodeURIComponent(i)}`,"DELETE",void 0,{provider:r});return V(a.data)}}}const ye=[{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"]}],et={id:"api-key",authMode:"apiKey",label:"添加 API Key",lifecycle:"active"},tt={id:"browser-login",authMode:"apiKey",connectMode:"browserAssistedApiKey",label:"浏览器登录",lifecycle:"active"},w=[et,tt],nt=[{id:"openai-compatible",label:"OpenAI Compatible",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],runtimeProviderIds:["custom"],consoleUrl:"https://undefineds.co",subscriptionUrl:"https://undefineds.co",endpoints:[{protocol:"chatCompletions",baseUrl:"https://example.invalid/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"unsupported",url:"https://undefineds.co"}},{id:"anthropic-compatible",label:"Anthropic Compatible",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],runtimeProviderIds:["custom"],consoleUrl:"https://undefineds.co",subscriptionUrl:"https://undefineds.co",endpoints:[{protocol:"anthropic",baseUrl:"https://example.invalid/v1"}],modelDiscovery:{strategy:"anthropic",path:"/models",endpointProtocol:"anthropic"},quota:{strategy:"unsupported",url:"https://undefineds.co"}}],q="https://www.kimi.com/code",it="https://www.kimi.com/user/agreement",rt="https://api.kimi.com/coding/v1",ot="https://api.kimi.com/coding/",at="https://platform.moonshot.cn/console/api-keys",Y="https://platform.moonshot.cn/console/account",st="https://platform.moonshot.cn/docs/intro",ct="https://api.moonshot.ai/v1",S="https://bailian.console.aliyun.com/",M="https://help.aliyun.com/zh/model-studio/",Z="https://open.bigmodel.cn/usercenter/apikeys",X="https://open.bigmodel.cn/",dt="https://open.bigmodel.cn/api/paas/v4",lt="https://open.bigmodel.cn/api/coding/paas/v4",me={openai:[{id:"official-subscription",label:"OpenAI Subscription",kind:"oauth-subscription",lifecycle:"unavailable",authModes:["oauth","local"],productLabel:"OpenAI",runtimeProviderIds:["openai"],credentialPrefixHints:[],consoleUrl:"https://chatgpt.com/codex",subscriptionUrl:"https://chatgpt.com/codex",endpoints:[{protocol:"responses",baseUrl:"https://chatgpt.com/backend-api/codex"}],modelDiscovery:{strategy:"unsupported",path:"/models",endpointProtocol:"responses"},quota:{strategy:"subscription",url:"https://chatgpt.com/codex"},usagePolicyUrl:"https://openai.com/policies/usage-policies/",region:"global"},{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],authorizationMethods:w,productLabel:"OpenAI",runtimeProviderIds:["openai"],credentialPrefixHints:["sk-"],consoleUrl:"https://platform.openai.com/api-keys",subscriptionUrl:"https://platform.openai.com/settings/organization/billing/overview",endpoints:[{protocol:"responses",baseUrl:"https://api.openai.com/v1"},{protocol:"chatCompletions",baseUrl:"https://api.openai.com/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"responses"},quota:{strategy:"providerApi",url:"https://platform.openai.com/usage"},usagePolicyUrl:"https://openai.com/policies/usage-policies/",region:"global"}],anthropic:[{id:"official-subscription",label:"Claude Code Subscription",kind:"oauth-subscription",lifecycle:"unavailable",authModes:["oauth"],productLabel:"Anthropic",runtimeProviderIds:["anthropic"],credentialPrefixHints:[],consoleUrl:"https://claude.ai/",subscriptionUrl:"https://claude.ai/settings/billing",endpoints:[],modelDiscovery:{strategy:"unsupported",path:"/models",endpointProtocol:"anthropic"},quota:{strategy:"subscription",url:"https://claude.ai/settings/usage"},usagePolicyUrl:"https://www.anthropic.com/legal/aup",region:"global"},{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],authorizationMethods:w,productLabel:"Anthropic",runtimeProviderIds:["anthropic"],credentialPrefixHints:["sk-ant-"],consoleUrl:"https://console.anthropic.com/settings/keys",subscriptionUrl:"https://console.anthropic.com/settings/plans",endpoints:[{protocol:"anthropic",baseUrl:"https://api.anthropic.com/v1"}],modelDiscovery:{strategy:"anthropic",path:"/models",endpointProtocol:"anthropic"},quota:{strategy:"console",url:"https://console.anthropic.com/settings/limits"},usagePolicyUrl:"https://www.anthropic.com/legal/aup",region:"global"}],kimi:[Q({id:"subscription-key",label:"Token Plan",kind:"token-plan",authModes:["apiKey"],productLabel:"Kimi Coding",runtimeProviderIds:["kimi"],credentialPrefixHints:["sk-kimi-"],baseUrl:rt,anthropicBaseUrl:ot,quotaStrategy:"subscription",quotaUrl:q,consoleUrl:q,subscriptionUrl:q,usagePolicyUrl:it,supportsDeveloperMessages:!1}),Q({id:"api-platform",label:"API Platform",kind:"api-platform",authModes:["apiKey"],productLabel:"Moonshot AI",runtimeProviderIds:["kimi"],credentialPrefixHints:["sk-"],baseUrl:ct,quotaStrategy:"console",quotaUrl:Y,consoleUrl:at,subscriptionUrl:Y,usagePolicyUrl:st})],bailian:[O({id:"pay-as-you-go",label:"Pay as You Go",kind:"api-platform",runtimeProviderIds:["bailian"],credentialPrefixHints:["sk-"],region:"cn",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode/v1",anthropicBaseUrl:"https://dashscope.aliyuncs.com/apps/anthropic",quotaStrategy:"console",consoleUrl:S,usagePolicyUrl:M}),O({id:"token-plan",label:"Token Plan Personal",kind:"token-plan",runtimeProviderIds:["bailian-token-plan"],credentialPrefixHints:["sk-"],region:"cn-beijing",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",anthropicBaseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic",quotaStrategy:"subscription",consoleUrl:S,usagePolicyUrl:M}),O({id:"token-plan-team",label:"Token Plan Team",kind:"token-plan",runtimeProviderIds:["bailian-token-plan"],credentialPrefixHints:["sk-"],region:"cn-beijing",baseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",anthropicBaseUrl:"https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic",quotaStrategy:"subscription",consoleUrl:S,usagePolicyUrl:M}),O({id:"coding-plan",label:"Coding Plan Pro",kind:"token-plan",runtimeProviderIds:["bailian-coding-plan"],credentialPrefixHints:["sk-sp-"],region:"cn",baseUrl:"https://coding.dashscope.aliyuncs.com/v1",anthropicBaseUrl:"https://coding.dashscope.aliyuncs.com/apps/anthropic",quotaStrategy:"subscription",consoleUrl:S,usagePolicyUrl:M})],deepseek:[{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],productLabel:"DeepSeek",runtimeProviderIds:["deepseek"],credentialPrefixHints:["sk-"],consoleUrl:"https://platform.deepseek.com/api_keys",subscriptionUrl:"https://platform.deepseek.com/usage",endpoints:[{protocol:"chatCompletions",baseUrl:"https://api.deepseek.com/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"console",url:"https://platform.deepseek.com/usage"},usagePolicyUrl:"https://cdn.deepseek.com/policies/en-US/deepseek-open-platform-terms-of-use.html",region:"global"}],ollama:[{id:"local",label:"Local Ollama",kind:"local",lifecycle:"active",authModes:["local"],productLabel:"Ollama",runtimeProviderIds:["ollama"],credentialPrefixHints:[],consoleUrl:"https://ollama.com",subscriptionUrl:"https://ollama.com",endpoints:[{protocol:"chatCompletions",baseUrl:"http://localhost:11434/v1"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"unsupported",url:"https://ollama.com"},usagePolicyUrl:"https://ollama.com",region:"local"}],zhipu:[{id:"api-platform",label:"API Platform",kind:"api-platform",lifecycle:"active",authModes:["apiKey"],authorizationMethods:w,productLabel:"智谱 AI",runtimeProviderIds:["zhipu"],credentialPrefixHints:["id."],consoleUrl:Z,subscriptionUrl:"https://open.bigmodel.cn/finance-center/expense-manage",endpoints:[{protocol:"chatCompletions",baseUrl:dt,region:"cn"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"console",url:"https://open.bigmodel.cn/finance-center/expense-manage"},usagePolicyUrl:X,region:"cn"},{id:"coding-plan",label:"GLM Coding Plan",kind:"token-plan",lifecycle:"active",authModes:["apiKey"],authorizationMethods:w,productLabel:"智谱 AI",runtimeProviderIds:["zhipu"],credentialPrefixHints:["id."],consoleUrl:Z,subscriptionUrl:"https://bigmodel.cn/glm-coding",endpoints:[{protocol:"chatCompletions",baseUrl:lt,region:"cn"}],modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:"subscription",url:"https://bigmodel.cn/glm-coding"},usagePolicyUrl:X,region:"cn"}]};function Q(e){return{id:e.id,label:e.label,kind:e.kind,lifecycle:"active",authModes:e.authModes,authorizationMethods:w,productLabel:e.productLabel,runtimeProviderIds:e.runtimeProviderIds,credentialPrefixHints:e.credentialPrefixHints,consoleUrl:e.consoleUrl,subscriptionUrl:e.subscriptionUrl,endpoints:he(e.baseUrl,e.anthropicBaseUrl,"cn",e.supportsDeveloperMessages),modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:e.quotaStrategy,url:e.quotaUrl},usagePolicyUrl:e.usagePolicyUrl,region:"cn"}}function O(e){return{id:e.id,label:e.label,lifecycle:"active",productLabel:"Alibaba Bailian",kind:e.kind,authModes:["apiKey"],authorizationMethods:w,runtimeProviderIds:e.runtimeProviderIds,credentialPrefixHints:e.credentialPrefixHints,consoleUrl:e.consoleUrl,subscriptionUrl:e.consoleUrl,endpoints:he(e.baseUrl,e.anthropicBaseUrl,e.region),modelDiscovery:{strategy:"openaiCompatible",path:"/models",endpointProtocol:"chatCompletions"},quota:{strategy:e.quotaStrategy,url:e.consoleUrl},usagePolicyUrl:e.usagePolicyUrl,region:e.region}}function he(e,t,n,s){return[{protocol:"chatCompletions",baseUrl:e,region:n,...s===void 0?{}:{supportsDeveloperMessages:s}},...t?[{protocol:"anthropic",baseUrl:t,region:n}]:[]]}function pt(e,t=!1){return(me[e]??ye).map(n=>e==="openai"&&n.id==="official-subscription"&&t?{...n,lifecycle:"active",authModes:Array.from(new Set([...n.authModes??[],"local"])),authorizationMethods:[{id:"device-code",authMode:"deviceCode",connectMode:"deviceCodeOAuth",label:"设备码登录",lifecycle:"active"},{id:"local-session-import",authMode:"local",label:"已有登录态",lifecycle:"active"}]}:{...n})}const Tt=D.flatMap(e=>[e,...ut(e).map(t=>`${e}-${t.id}`)]);function ut(e){return e==="custom"?nt:me[e]??ye}function Rt(e,t){return e==="anthropic"||t==="anthropic-compatible"?"anthropic":"openai"}function xt(e){switch(e){case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"kimi":return"Kimi";case"bailian":return"百炼";case"deepseek":return"DeepSeek";case"zhipu":return"智谱 AI";case"ollama":return"Ollama";case"custom":return"Custom"}}function ft(e,t){return e==="openai"&&(t==="local"||t==="oauth"||t==="deviceCode")?"official-subscription":e==="kimi"&&(t==="oauth"||t==="deviceCode")?"subscription-key":e==="bailian"?"pay-as-you-go":e==="ollama"?"local":e==="custom"?"openai-compatible":"api-platform"}function Lt(e,t){const n=pt(e).find(c=>c.id===(t??ft(e,"apiKey")));if(!n)return;const s=n.modelDiscovery?.endpointProtocol;return n.endpoints?.find(c=>c.protocol===s)?.baseUrl??n.endpoints?.[0]?.baseUrl}function qt(e,t){const n=t.trim().toLowerCase();if(e==="bailian"){if(n==="token-plan-personal")return"token-plan";if(n==="coding-plan-pro")return"coding-plan"}return n}function Nt(e){return{offeringId:e.offeringId,priority:e.priority??100,enabled:e.enabled??!0,health:e.health??"unknown",...e.baseUrl?{baseUrl:e.baseUrl}:{}}}const yt=3e4;function zt({webId:e,podUrl:t,authenticatedFetch:n}){return ve({webId:e,podBaseUrl:t,authenticatedFetch:mt(n)})}function mt(e){return(async(t,n)=>z(await e(t,n)))}function ht({podUrl:e,authenticatedFetch:t,invocationFetch:n=t,now:s=()=>new Date,invocationSelector:c=At}){const d=K(e);let f,h;const r=async(u,m)=>{const b=await t(u,m);return f=await It(b.clone(),c),b},i=async()=>{if(wt(f,s()))return f;if(h)return h;h=a();try{return await h}finally{h=void 0}},a=async()=>{if(!(await r(`${d}/api/applets/service-access/ai-connections`,{method:"GET",credentials:"include",headers:{accept:"application/json"}})).ok)throw new Error("AI Connection request failed. Please try again.");const m=f;if(!m?.token)throw new Error("AI Connection request failed. Please try again.");return m},l=async(u,m)=>{const b=await i(),k=Ut(b);if(!k)throw new Error("AI Connection request failed. Please try again.");const j=new Headers(m?.headers);return j.set("Authorization",`Bearer ${k}`),n(u,{...m,credentials:"omit",headers:j})};return(async(u,m)=>{if(gt(u,d))return r(u,m);if(!bt(u,d))return t(u,m);const b=await l(u,m);if(b.status!==401)return z(b);await b.arrayBuffer(),f=void 0;const k=await l(u,m);return z(k)})}function Dt({podUrl:e,controlPlaneOrigin:t,authenticatedFetch:n,invocationFetch:s,now:c}){const d=K(e),f=s??n,r=ht({podUrl:e,authenticatedFetch:n,invocationFetch:(i,a)=>{const l=new URL(i instanceof Request?i.url:String(i),d);if(t&&l.origin===d&&l.pathname.startsWith("/api/ai/client-configuration/")){const u=new URL(`${l.pathname}${l.search}`,t);return f(i instanceof Request?new Request(u,i):u.href,a)}return f(i,a)},now:c,invocationSelector:Pt});return{inspect:async i=>{const a=await r(A(d,i),{method:"GET",credentials:"omit",headers:{accept:"application/json"}});return a.status===403||a.status===404||a.status===503?(await a.arrayBuffer(),v()):P(a)},plan:async i=>P(await r(`${A(d,i.client)}/plan`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({endpoint:t?new URL(t).origin:i.endpoint,...i.activeModels!==void 0?{activeModels:i.activeModels}:{}})})),apply:async i=>P(await r(`${A(d,i.client)}/apply`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({planId:i.planId,apiKey:i.apiKey,confirmation:i.confirmation})})),verify:async i=>P(await r(`${A(d,i.client)}/verify`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({planId:i.planId})})),launch:async i=>P(await r(`${A(d,i)}/launch`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({})})),restore:async i=>{const a=await r(`${A(d,i)}/restore`,{method:"POST",credentials:"omit",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({})});return a.status===403||a.status===404||a.status===503?(await a.arrayBuffer(),v()):P(a)}}}function gt(e,t){try{const n=new URL(String(e),t),s=new URL(t);return n.origin===s.origin&&n.pathname==="/api/applets/service-access/ai-connections"}catch{return!1}}function bt(e,t){try{const n=new URL(String(e),t),s=new URL(t);return n.origin===s.origin&&(n.pathname.startsWith("/api/ai/")||n.pathname.startsWith("/v1/"))}catch{return!1}}async function It(e,t){if(!(!e.ok||!e.headers.get("content-type")?.includes("application/json")))try{const n=await e.json();return Ct(t(n))}catch{return}}function At(e){return e.invocation}function Pt(e){const t=e.aiClientConfiguration;return T(t)?t.invocation:void 0}function wt(e,t){if(!e?.token)return!1;if(!e.expiresAt)return!0;const n=Date.parse(e.expiresAt);return Number.isFinite(n)&&n-t.getTime()>yt}function Ut(e){return e?.token}function Ct(e){if(!T(e))return;const t=["gateway","Key"].join("");return{token:typeof e.token=="string"?e.token:typeof e.apiKey=="string"?e.apiKey:typeof e[t]=="string"?e[t]:void 0,baseUrl:typeof e.baseUrl=="string"?e.baseUrl:void 0,expiresAt:typeof e.expiresAt=="string"?e.expiresAt:void 0}}async function z(e){return e.ok?e:e.headers.get("content-type")?.includes("application/json")?kt(e):(await e.arrayBuffer(),new Response(JSON.stringify({error:"internal_error"}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}))}function A(e,t){return`${e}/api/ai/client-configuration/${encodeURIComponent(t)}`}async function P(e){if(!e.ok)throw await _t(e);if(!e.headers.get("content-type")?.includes("application/json"))throw await e.arrayBuffer(),new Error("AI client configuration request failed. Please try again.");return await e.json()}async function _t(e){let t;try{t=e.headers.get("content-type")?.includes("application/json")?await e.json():void 0}catch{t=void 0}if(T(t)){const n=typeof t.code=="string"?t.code:typeof t.error=="string"?t.error:void 0,s=typeof t.message=="string"?t.message:"AI client configuration request failed. Please try again.",c=new Error(s);return c.code=n,c.status=e.status,c.details=t.details,c}return await e.arrayBuffer().catch(()=>{}),new Error("AI client configuration request failed. Please try again.")}function v(){return{status:"unavailable",message:"Host does not support local client configuration. Use the manual setup instructions for your client."}}async function kt(e){let t;try{t=await e.clone().json()}catch{return e}const n=Mt(t);return n?new Response(JSON.stringify({code:n}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}):St(t)?new Response(JSON.stringify({code:t.error.code,error:t.error.message}),{status:e.status,statusText:e.statusText,headers:{"content-type":"application/json"}}):e}function St(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;const t=e.error;return!!(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.code=="string"&&typeof t.message=="string"&&typeof t.status=="number")}function Mt(e){if(!(!T(e)||typeof e.error!="string")&&e.error==="Gateway API Key plaintext is not available")return"gateway_api_key_plaintext_unavailable"}function T(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}export{D as A,nt as C,zt as a,xt as b,Nt as c,ft as d,Rt as e,Tt as f,ve as g,ge as h,Et as i,Dt as j,Ot as n,Lt as o,pt as p,qt as s};