@undefineds.co/xpod 0.4.11 → 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 (372) 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/chatkit/pod-store.d.ts +31 -0
  52. package/dist/api/chatkit/pod-store.js +132 -8
  53. package/dist/api/container/common.js +24 -4
  54. package/dist/api/container/routes.js +17 -2
  55. package/dist/api/container/types.d.ts +3 -1
  56. package/dist/api/handlers/AdminHandler.d.ts +13 -0
  57. package/dist/api/handlers/AdminHandler.js +47 -18
  58. package/dist/api/handlers/AiConfigHandler.d.ts +6 -0
  59. package/dist/api/handlers/AiConfigHandler.js +28 -0
  60. package/dist/api/handlers/AiGatewayManagementHandler.js +36 -0
  61. package/dist/api/runs/RdfRunContextRetriever.d.ts +14 -0
  62. package/dist/api/runs/RdfRunContextRetriever.js +41 -5
  63. package/dist/api/runtime.js +2 -1
  64. package/dist/cli/commands/secret.d.ts +1 -0
  65. package/dist/cli/commands/secret.js +25 -7
  66. package/dist/components/components.jsonld +3 -1
  67. package/dist/components/context.jsonld +53 -1
  68. package/dist/http/SubgraphSparqlHttpHandler.d.ts +59 -2
  69. package/dist/http/SubgraphSparqlHttpHandler.js +145 -13
  70. package/dist/http/SubgraphSparqlHttpHandler.jsonld +37 -0
  71. package/dist/identity/drizzle/EdgeNodeRepository.d.ts +0 -12
  72. package/dist/identity/drizzle/EdgeNodeRepository.js +5 -13
  73. package/dist/index.d.ts +2 -1
  74. package/dist/index.js +7 -3
  75. package/dist/logging/log-file.d.ts +17 -0
  76. package/dist/logging/log-file.js +69 -0
  77. package/dist/main.js +2 -1
  78. package/dist/notifications/NotificationChannelSweeper.d.ts +50 -0
  79. package/dist/notifications/NotificationChannelSweeper.js +131 -0
  80. package/dist/notifications/NotificationChannelSweeper.jsonld +136 -0
  81. package/dist/notifications/ReclaimingWebSocket2023Storer.d.ts +25 -0
  82. package/dist/notifications/ReclaimingWebSocket2023Storer.js +56 -0
  83. package/dist/notifications/ReclaimingWebSocket2023Storer.jsonld +77 -0
  84. package/dist/notifications/index.d.ts +2 -0
  85. package/dist/notifications/index.js +2 -0
  86. package/dist/runtime/Proxy.d.ts +37 -0
  87. package/dist/runtime/Proxy.js +88 -16
  88. package/dist/runtime/bootstrap.js +2 -1
  89. package/dist/runtime/upgrade/BunNativeUpgradeRelay.d.ts +116 -0
  90. package/dist/runtime/upgrade/BunNativeUpgradeRelay.js +423 -0
  91. package/dist/runtime/upgrade/UpgradeHandshake.d.ts +63 -0
  92. package/dist/runtime/upgrade/UpgradeHandshake.js +199 -0
  93. package/dist/runtime/upgrade/WebSocketFrames.d.ts +67 -0
  94. package/dist/runtime/upgrade/WebSocketFrames.js +224 -0
  95. package/node_modules/@undefineds.co/ai-connections/dist/AiApiKeyPool.js +8 -1
  96. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.d.ts +11 -2
  97. package/node_modules/@undefineds.co/ai-connections/dist/AiAuthorizationActions.js +27 -10
  98. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.d.ts +7 -0
  99. package/node_modules/@undefineds.co/ai-connections/dist/AiClientConfigurationSection.js +13 -11
  100. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectDialog.js +1 -1
  101. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsList.js +10 -6
  102. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.d.ts +15 -0
  103. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMain.js +29 -3
  104. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsMainHeader.js +18 -3
  105. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.d.ts +16 -1
  106. package/node_modules/@undefineds.co/ai-connections/dist/AiConnectionsPanel.js +92 -20
  107. package/node_modules/@undefineds.co/ai-connections/dist/AiCopyButton.d.ts +35 -0
  108. package/node_modules/@undefineds.co/ai-connections/dist/AiCopyButton.js +45 -0
  109. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialPoolSection.js +71 -11
  110. package/node_modules/@undefineds.co/ai-connections/dist/AiCredentialRow.js +9 -7
  111. package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.d.ts +23 -0
  112. package/node_modules/@undefineds.co/ai-connections/dist/AiEndpointList.js +24 -0
  113. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.d.ts +13 -4
  114. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayKeysSection.js +35 -38
  115. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.d.ts +21 -0
  116. package/node_modules/@undefineds.co/ai-connections/dist/AiGatewayModelsSection.js +51 -0
  117. package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.d.ts +15 -0
  118. package/node_modules/@undefineds.co/ai-connections/dist/AiInfoTooltip.js +16 -0
  119. package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.d.ts +175 -0
  120. package/node_modules/@undefineds.co/ai-connections/dist/AiModelCatalog.js +133 -0
  121. package/node_modules/@undefineds.co/ai-connections/dist/AiOfferingDetails.js +2 -2
  122. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderCard.js +13 -64
  123. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.d.ts +21 -0
  124. package/node_modules/@undefineds.co/ai-connections/dist/AiProviderHeader.js +12 -0
  125. package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.d.ts +15 -0
  126. package/node_modules/@undefineds.co/ai-connections/dist/AiRowAction.js +12 -0
  127. package/node_modules/@undefineds.co/ai-connections/dist/AiSortableCredentialList.js +2 -1
  128. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.d.ts +7 -0
  129. package/node_modules/@undefineds.co/ai-connections/dist/ai-connections-client.js +6 -0
  130. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.d.ts +36 -5
  131. package/node_modules/@undefineds.co/ai-connections/dist/authorization-methods.js +52 -9
  132. package/node_modules/@undefineds.co/ai-connections/dist/client/normalize.js +30 -3
  133. package/node_modules/@undefineds.co/ai-connections/dist/client/types.d.ts +21 -1
  134. package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.d.ts +1 -3
  135. package/node_modules/@undefineds.co/ai-connections/dist/client-config/base-adapter.js +3 -7
  136. package/node_modules/@undefineds.co/ai-connections/dist/client-config/index.cjs +9 -7
  137. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.d.ts +46 -0
  138. package/node_modules/@undefineds.co/ai-connections/dist/collection-runtime.js +231 -0
  139. package/node_modules/@undefineds.co/ai-connections/dist/collections.d.ts +119 -0
  140. package/node_modules/@undefineds.co/ai-connections/dist/collections.js +173 -0
  141. package/node_modules/@undefineds.co/ai-connections/dist/controller.d.ts +71 -5
  142. package/node_modules/@undefineds.co/ai-connections/dist/controller.js +285 -16
  143. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.d.ts +5 -0
  144. package/node_modules/@undefineds.co/ai-connections/dist/credential-labels.js +8 -3
  145. package/node_modules/@undefineds.co/ai-connections/dist/credential-storage.d.ts +59 -0
  146. package/node_modules/@undefineds.co/ai-connections/dist/credential-storage.js +131 -0
  147. package/node_modules/@undefineds.co/ai-connections/dist/endpoint-urls.d.ts +15 -0
  148. package/node_modules/@undefineds.co/ai-connections/dist/endpoint-urls.js +20 -0
  149. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.d.ts +14 -0
  150. package/node_modules/@undefineds.co/ai-connections/dist/gateway-endpoints.js +20 -0
  151. package/node_modules/@undefineds.co/ai-connections/dist/index.d.ts +8 -0
  152. package/node_modules/@undefineds.co/ai-connections/dist/index.js +8 -0
  153. package/node_modules/@undefineds.co/ai-connections/dist/manifest.js +1 -1
  154. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.d.ts +14 -0
  155. package/node_modules/@undefineds.co/ai-connections/dist/offering-endpoints.js +17 -0
  156. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.cjs +68 -1
  157. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.d.ts +75 -1
  158. package/node_modules/@undefineds.co/ai-connections/dist/provider-catalog.js +119 -0
  159. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.d.ts +5 -0
  160. package/node_modules/@undefineds.co/ai-connections/dist/provider-visuals.js +5 -0
  161. package/node_modules/@undefineds.co/ai-connections/dist/service-access.js +2 -27
  162. package/node_modules/@undefineds.co/ai-connections/package.json +1 -0
  163. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.d.ts +1 -1
  164. package/node_modules/@undefineds.co/extension-sdk/dist/manifest.js +2 -0
  165. package/node_modules/@undefineds.co/extension-sdk/dist/web.d.ts +150 -0
  166. package/node_modules/@undefineds.co/extension-sdk/package.json +2 -1
  167. package/node_modules/@undefineds.co/models/README.md +1 -1
  168. package/node_modules/@undefineds.co/models/dist/ai-config/index.d.ts +3 -3
  169. package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.d.ts +5 -0
  170. package/node_modules/@undefineds.co/models/dist/ai-gateway.schema.js +9 -0
  171. package/node_modules/@undefineds.co/models/dist/ai-runtime.repository.d.ts +1 -1
  172. package/node_modules/@undefineds.co/models/dist/approval.repository.d.ts +2 -2
  173. package/node_modules/@undefineds.co/models/dist/audit.presentation.d.ts +2 -2
  174. package/node_modules/@undefineds.co/models/dist/capture.repository.d.ts +1 -1
  175. package/node_modules/@undefineds.co/models/dist/chat-project.repository.d.ts +1 -1
  176. package/node_modules/@undefineds.co/models/dist/chat.repository.d.ts +2 -2
  177. package/node_modules/@undefineds.co/models/dist/control-request.repository.d.ts +2 -2
  178. package/node_modules/@undefineds.co/models/dist/conversation-share.repository.d.ts +1 -1
  179. package/node_modules/@undefineds.co/models/dist/credential.schema.d.ts +12 -0
  180. package/node_modules/@undefineds.co/models/dist/credential.schema.js +15 -1
  181. package/node_modules/@undefineds.co/models/dist/discovery/index.d.ts +2 -2
  182. package/node_modules/@undefineds.co/models/dist/discovery/providers.json +248 -7
  183. package/node_modules/@undefineds.co/models/dist/discovery/types.d.ts +31 -0
  184. package/node_modules/@undefineds.co/models/dist/extension/index.d.ts +1 -1
  185. package/node_modules/@undefineds.co/models/dist/favorite/index.d.ts +2 -2
  186. package/node_modules/@undefineds.co/models/dist/fixtures/contracts-chat-contact.d.ts +5 -5
  187. package/node_modules/@undefineds.co/models/dist/import/index.d.ts +1 -1
  188. package/node_modules/@undefineds.co/models/dist/index.d.ts +73 -73
  189. package/node_modules/@undefineds.co/models/dist/index.js +1 -1
  190. package/node_modules/@undefineds.co/models/dist/input-request.repository.d.ts +2 -2
  191. package/node_modules/@undefineds.co/models/dist/knowledge/index.d.ts +1 -1
  192. package/node_modules/@undefineds.co/models/dist/message.repository.d.ts +1 -1
  193. package/node_modules/@undefineds.co/models/dist/namespaces.js +5 -0
  194. package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.d.ts +4815 -26
  195. package/node_modules/@undefineds.co/models/dist/pod-storage-descriptor.js +482 -132
  196. package/node_modules/@undefineds.co/models/dist/schema.d.ts +4 -0
  197. package/node_modules/@undefineds.co/models/dist/session/index.d.ts +1 -1
  198. package/node_modules/@undefineds.co/models/dist/settings/index.d.ts +1 -1
  199. package/node_modules/@undefineds.co/models/dist/sidecar/persistence-mapping.d.ts +5 -5
  200. package/node_modules/@undefineds.co/models/dist/thread.repository.d.ts +2 -2
  201. package/node_modules/@undefineds.co/models/dist/types/message-block.d.ts +1 -1
  202. package/node_modules/@undefineds.co/models/dist/vocab/_namespaces.d.ts +1 -1
  203. package/node_modules/@undefineds.co/models/dist/vocab/index.d.ts +10 -10
  204. package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.d.ts +1 -0
  205. package/node_modules/@undefineds.co/models/dist/vocab/sidecar.vocab.js +1 -0
  206. package/node_modules/@undefineds.co/models/package.json +4 -2
  207. package/node_modules/@undefineds.co/pod-collections/README.md +71 -0
  208. package/node_modules/@undefineds.co/pod-collections/dist/diff.d.ts +85 -0
  209. package/node_modules/@undefineds.co/pod-collections/dist/diff.js +166 -0
  210. package/node_modules/@undefineds.co/pod-collections/dist/feed.d.ts +17 -0
  211. package/node_modules/@undefineds.co/pod-collections/dist/feed.js +27 -0
  212. package/node_modules/@undefineds.co/pod-collections/dist/index.cjs +1042 -0
  213. package/node_modules/@undefineds.co/pod-collections/dist/index.d.ts +37 -0
  214. package/node_modules/@undefineds.co/pod-collections/dist/index.js +89 -0
  215. package/node_modules/@undefineds.co/pod-collections/dist/layout.d.ts +75 -0
  216. package/node_modules/@undefineds.co/pod-collections/dist/layout.js +173 -0
  217. package/node_modules/@undefineds.co/pod-collections/dist/mapping.d.ts +78 -0
  218. package/node_modules/@undefineds.co/pod-collections/dist/mapping.js +287 -0
  219. package/node_modules/@undefineds.co/pod-collections/dist/mutations.d.ts +83 -0
  220. package/node_modules/@undefineds.co/pod-collections/dist/mutations.js +273 -0
  221. package/node_modules/@undefineds.co/pod-collections/dist/react.d.ts +21 -0
  222. package/node_modules/@undefineds.co/pod-collections/dist/react.js +22 -0
  223. package/node_modules/@undefineds.co/pod-collections/dist/read.d.ts +65 -0
  224. package/node_modules/@undefineds.co/pod-collections/dist/read.js +31 -0
  225. package/node_modules/@undefineds.co/pod-collections/dist/sync.d.ts +66 -0
  226. package/node_modules/@undefineds.co/pod-collections/dist/sync.js +260 -0
  227. package/node_modules/@undefineds.co/pod-collections/dist/types.d.ts +155 -0
  228. package/node_modules/@undefineds.co/pod-collections/dist/types.js +9 -0
  229. package/node_modules/@undefineds.co/pod-collections/package.json +42 -0
  230. package/package.json +15 -7
  231. package/static/app/assets/main.css +1 -1
  232. package/static/auth-callback/assets/AiConfigContext-DnQs1ZpW.js +1 -0
  233. package/static/auth-callback/assets/AiConfigPage-DOtvlxH0.js +1 -0
  234. package/static/auth-callback/assets/DocumentProcessingPanel-BS2voQgL.js +1 -0
  235. package/static/auth-callback/assets/IndexLifecyclePanel-Cvt0cJtN.js +1 -0
  236. package/static/auth-callback/assets/{IndexSubjectPanel-BbUqop4b.js → IndexSubjectPanel-Dhf01GqF.js} +1 -1
  237. package/static/auth-callback/assets/ModelAssignmentsPanel-BJutWaAF.js +1 -0
  238. package/static/auth-callback/assets/ModelsPage-BRS0sje3.js +11 -0
  239. package/static/auth-callback/assets/{NetworkPage-Vp2PrMxs.js → NetworkPage-B3qBfANA.js} +2 -2
  240. package/static/auth-callback/assets/{PaneListHeader-DY7baSFl.js → PaneListHeader-QQeJGTp4.js} +1 -1
  241. package/static/auth-callback/assets/SearchIndexingPanel-MyNUSEwT.js +1 -0
  242. package/static/auth-callback/assets/{StatusSubjectPanel-ArIS-TxT.js → StatusSubjectPanel-DQkEVsFs.js} +1 -1
  243. package/static/{settings/assets/StatusWorkspace-CoMFRXoV.js → auth-callback/assets/StatusWorkspace-Dkv63Uwk.js} +1 -1
  244. package/static/auth-callback/assets/{SystemSettingsPage-BDvT1NUz.js → SystemSettingsPage-TIsUfX5d.js} +1 -1
  245. package/static/{dashboard/assets/SystemSettingsSubjectPanel-WaE8mTQi.js → auth-callback/assets/SystemSettingsSubjectPanel-BJWEt2-7.js} +5 -5
  246. package/static/auth-callback/assets/XpodAiConnectionsPodStore-BJiXm-PF.js +3 -0
  247. package/static/auth-callback/assets/{activity-D1Dsfa_0.js → activity-5hNeNKnL.js} +1 -1
  248. package/static/auth-callback/assets/ai-connections-CryuHGKW.js +1 -0
  249. package/static/auth-callback/assets/{auth-callback-Cmf4hXVZ.js → auth-callback-CAFZ3R0B.js} +6 -6
  250. package/static/auth-callback/assets/auth-callback-rk080mvG.css +1 -0
  251. package/static/auth-callback/assets/{badge-CZsHq3Ih.js → badge-CAIPI0CB.js} +1 -1
  252. package/static/auth-callback/assets/collection-runtime-D9s7h9YA.js +1 -0
  253. package/static/auth-callback/assets/dialog-BjA109aX.js +1 -0
  254. package/static/auth-callback/assets/{download-DU9ntlHw.js → download-B3Up5W2G.js} +1 -1
  255. package/static/auth-callback/assets/{external-link-BfzaaZDx.js → external-link-BTXgSPzB.js} +1 -1
  256. package/static/auth-callback/assets/index-BppXlxcp.js +41 -0
  257. package/static/auth-callback/assets/index-CirW4CJf.js +1 -0
  258. package/static/auth-callback/assets/index-DlLYWOhw.js +4 -0
  259. package/static/auth-callback/assets/{index-browser-BNFqqC74.js → index-browser-DtU38ni3.js} +1 -1
  260. package/static/auth-callback/assets/{key-round-BwP3DBWo.js → key-round-CQCOrZ7x.js} +1 -1
  261. package/static/auth-callback/assets/layout-DB3pMyTl.js +1 -0
  262. package/static/auth-callback/assets/pod-collections-host-KnnGFZHL.js +8 -0
  263. package/static/auth-callback/assets/{rotate-ccw-VMwnmyab.js → rotate-ccw-C1zM2KtS.js} +1 -1
  264. package/static/auth-callback/assets/{skeleton-CoD55rBT.js → skeleton-Cqp7_M9-.js} +1 -1
  265. package/static/auth-callback/assets/{waypoints-DRo_1Ca7.js → waypoints-Bj6gAUSQ.js} +1 -1
  266. package/static/auth-callback/assets/{workspace-layout--mcXl3My.js → workspace-layout-DK8mDzrY.js} +1 -1
  267. package/static/auth-callback/auth-callback.html +2 -2
  268. package/static/dashboard/assets/AiConfigContext-BsE7MqX8.js +1 -0
  269. package/static/dashboard/assets/AiConfigPage-DvM-lRXa.js +1 -0
  270. package/static/dashboard/assets/DocumentProcessingPanel-BPfdlfuf.js +1 -0
  271. package/static/dashboard/assets/IndexLifecyclePanel--m0AGxvh.js +1 -0
  272. package/static/dashboard/assets/{IndexSubjectPanel-B2cXwl8X.js → IndexSubjectPanel-Bb7m1k3d.js} +1 -1
  273. package/static/dashboard/assets/ModelAssignmentsPanel-BLi_zbMa.js +1 -0
  274. package/static/dashboard/assets/ModelsPage-CxdpgnfR.js +11 -0
  275. package/static/dashboard/assets/{NetworkPage-DV2V0qWO.js → NetworkPage-BAIPw-D_.js} +2 -2
  276. package/static/dashboard/assets/{PaneListHeader-D0c1yCFH.js → PaneListHeader-BBCMei0r.js} +1 -1
  277. package/static/dashboard/assets/SearchIndexingPanel-Ck4Y-xjR.js +1 -0
  278. package/static/dashboard/assets/{StatusSubjectPanel-oPSECj7i.js → StatusSubjectPanel-D1KWfAXE.js} +1 -1
  279. package/static/dashboard/assets/{StatusWorkspace-PdovQPKa.js → StatusWorkspace-JbA5gzXx.js} +1 -1
  280. package/static/dashboard/assets/{SystemSettingsPage-CtNDklkx.js → SystemSettingsPage-BbwQWsSR.js} +1 -1
  281. package/static/{settings/assets/SystemSettingsSubjectPanel-DExjDo_v.js → dashboard/assets/SystemSettingsSubjectPanel-N117nMt5.js} +5 -5
  282. package/static/dashboard/assets/XpodAiConnectionsPodStore-CdDOb4SV.js +18 -0
  283. package/static/dashboard/assets/{activity-B9ylSoyr.js → activity-DX1I96o_.js} +1 -1
  284. package/static/dashboard/assets/ai-connections-DwCRqOQa.js +1 -0
  285. package/static/dashboard/assets/{badge-BNbFbpIb.js → badge-k2vhtDqH.js} +1 -1
  286. package/static/dashboard/assets/collection-runtime-BFQ8teQJ.js +1 -0
  287. package/static/dashboard/assets/{dashboard-CD-FFVRD.js → dashboard-DWZ-fmCT.js} +4 -4
  288. package/static/dashboard/assets/dashboard-rk080mvG.css +1 -0
  289. package/static/dashboard/assets/dialog-1CCw-iHT.js +1 -0
  290. package/static/dashboard/assets/{download-nOP38LtW.js → download-C6-SNY1q.js} +1 -1
  291. package/static/dashboard/assets/{external-link-Bh2ewN9E.js → external-link-BgPcZ_j2.js} +1 -1
  292. package/static/dashboard/assets/index-6LcIUIYO.js +1 -0
  293. package/static/dashboard/assets/index-D7A8U6Pt.js +41 -0
  294. package/static/dashboard/assets/index-UD6QOE7H.js +4 -0
  295. package/static/dashboard/assets/{key-round-bGmguBLv.js → key-round-BOd7Jo0Q.js} +1 -1
  296. package/static/dashboard/assets/layout-DB3pMyTl.js +1 -0
  297. package/static/dashboard/assets/pod-collections-host-KnnGFZHL.js +8 -0
  298. package/static/dashboard/assets/{rotate-ccw-D2x__ODW.js → rotate-ccw-CCgJqsvx.js} +1 -1
  299. package/static/dashboard/assets/{skeleton-VOqft8WS.js → skeleton-Bc7abAn5.js} +1 -1
  300. package/static/dashboard/assets/{waypoints-fgRqm4oH.js → waypoints-s-opmJxx.js} +1 -1
  301. package/static/dashboard/assets/{workspace-layout-DV4dgeHX.js → workspace-layout-DqIQeTBV.js} +1 -1
  302. package/static/dashboard/dashboard.html +2 -2
  303. package/static/settings/assets/AiConfigContext-BB9KZySa.js +1 -0
  304. package/static/settings/assets/AiConfigPage-DGSXUkLs.js +1 -0
  305. package/static/settings/assets/DocumentProcessingPanel-Da2Re6Rg.js +1 -0
  306. package/static/settings/assets/IndexLifecyclePanel-BSZuIzgr.js +1 -0
  307. package/static/settings/assets/{IndexSubjectPanel-BgbI9c-a.js → IndexSubjectPanel-CFd0ay-r.js} +1 -1
  308. package/static/settings/assets/ModelAssignmentsPanel-CSAryvWJ.js +1 -0
  309. package/static/settings/assets/ModelsPage-BQwCwLHU.js +11 -0
  310. package/static/settings/assets/{NetworkPage-C8OA9Mtp.js → NetworkPage-BKymvsQc.js} +2 -2
  311. package/static/settings/assets/{PaneListHeader-COvlPJWj.js → PaneListHeader-Bjh3hRdQ.js} +1 -1
  312. package/static/settings/assets/SearchIndexingPanel-MjKL5QLU.js +1 -0
  313. package/static/settings/assets/{StatusSubjectPanel-BuLml7qn.js → StatusSubjectPanel-Bvl6K4mx.js} +1 -1
  314. package/static/settings/assets/StatusWorkspace-B0NzrP--.js +1 -0
  315. package/static/settings/assets/{SystemSettingsPage-DlzmaWV-.js → SystemSettingsPage-D2z6Z4FE.js} +1 -1
  316. package/static/{auth-callback/assets/SystemSettingsSubjectPanel-CDqRuC4t.js → settings/assets/SystemSettingsSubjectPanel-4sxma4X4.js} +5 -5
  317. package/static/settings/assets/XpodAiConnectionsPodStore-BkNQ8fZx.js +3 -0
  318. package/static/settings/assets/{activity-TLerXgMs.js → activity-CgJJGpjx.js} +1 -1
  319. package/static/settings/assets/ai-connections-CryuHGKW.js +1 -0
  320. package/static/settings/assets/{badge-Bcs8iWrH.js → badge-C4NypVyT.js} +1 -1
  321. package/static/settings/assets/collection-runtime-CTLCDxAi.js +1 -0
  322. package/static/settings/assets/dialog-Csq0vWUi.js +1 -0
  323. package/static/settings/assets/{download-Ct3QmHPt.js → download-DaLJJ-Wp.js} +1 -1
  324. package/static/settings/assets/{external-link-C8KiHbss.js → external-link--w_iW5Au.js} +1 -1
  325. package/static/settings/assets/index-B0mQa59b.js +4 -0
  326. package/static/settings/assets/index-BukHiu4y.js +1 -0
  327. package/static/settings/assets/index-COmVnZi2.js +41 -0
  328. package/static/settings/assets/{index-browser-CazX1pc2.js → index-browser-BGpvHwD0.js} +1 -1
  329. package/static/settings/assets/{key-round-B19YD1GA.js → key-round-Bk4YRjBu.js} +1 -1
  330. package/static/settings/assets/layout-DB3pMyTl.js +1 -0
  331. package/static/settings/assets/pod-collections-host-KnnGFZHL.js +8 -0
  332. package/static/settings/assets/{rotate-ccw-AQm2kMgU.js → rotate-ccw-TCabbqsr.js} +1 -1
  333. package/static/settings/assets/{settings-C-VBtt9r.js → settings-CJWpdbNC.js} +5 -5
  334. package/static/settings/assets/settings-rk080mvG.css +1 -0
  335. package/static/settings/assets/{skeleton-DyZ1OBYf.js → skeleton-JDHYVe7t.js} +1 -1
  336. package/static/settings/assets/{waypoints-CC3wq-SU.js → waypoints-DDvEl-MU.js} +1 -1
  337. package/static/settings/assets/{workspace-layout-BxXNKgf9.js → workspace-layout-DV5QU30U.js} +1 -1
  338. package/static/settings/settings.html +2 -2
  339. package/static/auth-callback/assets/AiConfigContext-DqWRSm7n.js +0 -1
  340. package/static/auth-callback/assets/AiConfigPage-C5YYyvzl.js +0 -1
  341. package/static/auth-callback/assets/DocumentProcessingPanel-DZCiacBz.js +0 -1
  342. package/static/auth-callback/assets/IndexLifecyclePanel-CCLeOljB.js +0 -1
  343. package/static/auth-callback/assets/ModelAssignmentsPanel-jUUTDKuh.js +0 -1
  344. package/static/auth-callback/assets/ModelsPage-B08zdtff.js +0 -10
  345. package/static/auth-callback/assets/SearchIndexingPanel-D4YRg1-8.js +0 -1
  346. package/static/auth-callback/assets/StatusWorkspace-Cp5LQ9Yx.js +0 -1
  347. package/static/auth-callback/assets/ai-connections-CHNTKemd.js +0 -1
  348. package/static/auth-callback/assets/auth-callback-DWMMiFjh.css +0 -1
  349. package/static/auth-callback/assets/index-DSNnLUbU.js +0 -4
  350. package/static/auth-callback/assets/index-FHhHoKgp.js +0 -41
  351. package/static/dashboard/assets/AiConfigContext-BpPDKSzI.js +0 -1
  352. package/static/dashboard/assets/AiConfigPage-wsqEZDIX.js +0 -1
  353. package/static/dashboard/assets/DocumentProcessingPanel-CDSy3juc.js +0 -1
  354. package/static/dashboard/assets/IndexLifecyclePanel-CVd6vQCX.js +0 -1
  355. package/static/dashboard/assets/ModelAssignmentsPanel-BeBZhnQd.js +0 -1
  356. package/static/dashboard/assets/ModelsPage-B6McSCJw.js +0 -25
  357. package/static/dashboard/assets/SearchIndexingPanel-CGs0OZ12.js +0 -1
  358. package/static/dashboard/assets/ai-connections-CHNTKemd.js +0 -1
  359. package/static/dashboard/assets/dashboard-DWMMiFjh.css +0 -1
  360. package/static/dashboard/assets/index-PgS-Bt7X.js +0 -41
  361. package/static/dashboard/assets/index-QN2QgEwr.js +0 -4
  362. package/static/settings/assets/AiConfigContext-zKQYdfai.js +0 -1
  363. package/static/settings/assets/AiConfigPage-Bs1EE3Ei.js +0 -1
  364. package/static/settings/assets/DocumentProcessingPanel-CSFfdOXS.js +0 -1
  365. package/static/settings/assets/IndexLifecyclePanel-BR9Su49B.js +0 -1
  366. package/static/settings/assets/ModelAssignmentsPanel-C0BE7nbk.js +0 -1
  367. package/static/settings/assets/ModelsPage-CU-YQ8_7.js +0 -10
  368. package/static/settings/assets/SearchIndexingPanel-Bdd46mIV.js +0 -1
  369. package/static/settings/assets/ai-connections-CHNTKemd.js +0 -1
  370. package/static/settings/assets/index-1Q2cRjZd.js +0 -41
  371. package/static/settings/assets/index-DBO_Vq0P.js +0 -4
  372. package/static/settings/assets/settings-DWMMiFjh.css +0 -1
@@ -1,2 +1,2 @@
1
- import{c as E,k as pe,r as d,H as B,j as e,C as N,a as w,b as k,d as C,e as S,B as y,I as se,R as xe,N as he,l as fe,m as be}from"./auth-callback-Cmf4hXVZ.js";import{P as ve}from"./PaneListHeader-DY7baSFl.js";import{N as re,W as je}from"./waypoints-DRo_1Ca7.js";import{A as ie}from"./activity-D1Dsfa_0.js";import{T as ge,u as ye}from"./workspace-layout--mcXl3My.js";import{E as Ne}from"./external-link-BfzaaZDx.js";import{B as L}from"./badge-CZsHq3Ih.js";import{R as we}from"./rotate-ccw-VMwnmyab.js";import{D as ke}from"./download-DU9ntlHw.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-Cmf4hXVZ.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-Cmf4hXVZ.js";import{f as D,a as M,t as _,r as O}from"./admin-C6qCRFiY.js";import{E as q}from"./external-link-BfzaaZDx.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-C-VBtt9r.js";import{A as u}from"./activity-TLerXgMs.js";import{W as f,N as w}from"./waypoints-CC3wq-SU.js";import{P as g}from"./PaneListHeader-COvlPJWj.js";import{T as N,u as j}from"./workspace-layout-BxXNKgf9.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};
@@ -1 +1 @@
1
- import{c as l,D as h,k as u,r as c,j as e,O as x,N as b,l as y,m as g}from"./auth-callback-Cmf4hXVZ.js";import{K as f}from"./key-round-BwP3DBWo.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-DY7baSFl.js";import{T as S,u as w}from"./workspace-layout--mcXl3My.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};
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};
@@ -1,6 +1,6 @@
1
- import{n as Z,s as ee,o as te,x as I,p as ie,q as T,t as ce,v as G,w as de,y as le,z as ue,A as pe,u as he,r as u,j as s,B as C,R as fe,C as me,a as ge,b as we,d as be,e as ve,E as xe,F as ye}from"./dashboard-CD-FFVRD.js";import{d as Ae,e as Se,b as Ce,c as Ie,h as Ne,i as je,t as _e,u as Re}from"./admin-C6qCRFiY.js";import{a as Ee}from"./settings-projection-CUkyprDQ.js";import{c as z}from"./ai-connections-CHNTKemd.js";import{R as Ue}from"./rotate-ccw-D2x__ODW.js";import{S as X}from"./skeleton-VOqft8WS.js";import{E as Pe}from"./external-link-Bh2ewN9E.js";class v extends Error{code;constructor(t,r){super(r),this.name="AccountStorageBindingsError",this.code=t}}async function ke(e){const t=Le(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=De(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 Oe(d,a.origin,Fe(a,e.trustedAccountIndex,t))}function Oe(e,t,r=!1){if(!H(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(!H(o)||typeof o.webId!="string"||typeof o.storageUrl!="string")throw new v("invalid-response","Account storage binding row is malformed");const c=Te(o.webId),i=Be(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 Le(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 De(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 Te(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 Be(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 Fe(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 H(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}const q="co.undefineds.ai-connections",We={providerCredentials:"settings/credentials.ttl",providerDefinitions:"settings/providers/__service_access__.ttl",gatewayAccessKeys:".data/ai/gateway/access-keys.ttl",quotaSnapshots:".data/ai/gateway/quota.ttl"},Me=["openai","openai-official-subscription","openai-api-platform","anthropic","anthropic-official-subscription","anthropic-api-platform","kimi","kimi-subscription-key","kimi-api-platform","bailian","bailian-pay-as-you-go","bailian-token-plan","bailian-token-plan-team","bailian-coding-plan","deepseek","deepseek-api-platform","zhipu","zhipu-api-platform","zhipu-coding-plan","ollama","ollama-local","custom","custom-openai-compatible","custom-anthropic-compatible"],$e=new Set(Me);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=ze(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 ze(e,t){const r=We[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=He(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 He(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 m=async b=>{a();const y=await b();return a(),y},g=l.json.bind(l),w=l.text.bind(l);return l.json=()=>m(g),l.text=()=>m(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 m=lt(l);if(!e.pickWebIdUrl)return m;const g=await ot({fetchImpl:r,headers:t.headers,maxAttempts:e.maxAttempts,pickWebIdUrl:e.pickWebIdUrl,pollIntervalMs:e.pollIntervalMs});return t.assertCurrentAccount(),g.length>0?g:m}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 pe(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 pt(e,t){if(e)try{return new URL(new URL(e).pathname,t).toString()}catch{return}}const ht="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?`
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
4
  <#serviceAccess>
5
5
  a acp:AccessControl;
6
6
  acp:apply [
@@ -12,7 +12,7 @@ ${d.storageUrl}`;o.has(l)||(o.add(l),c.push(d))}return c}async function ct(e){co
12
12
  ]
13
13
  ].
14
14
  `:"",o=n?"<#ownerAccess>, <#serviceAccess>":"<#ownerAccess>";return`@prefix acl: <${ft}>.
15
- @prefix acp: <${ht}>.
15
+ @prefix acp: <${pt}>.
16
16
 
17
17
  <#managed>
18
18
  a acp:AccessControlResource;
@@ -30,4 +30,4 @@ ${d.storageUrl}`;o.has(l)||(o.add(l),c.push(d))}return c}async function ct(e){co
30
30
  acp:agent <${t}>
31
31
  ]
32
32
  ].
33
- ${a}`}function mt(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=>mt(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 E(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(()=>{}),E(r,!1);const o=await a.text();if(!o.includes(`<${r.service.webId}>`)||!o.includes("acp:AccessControlResource"))return E(r,!1)}return E(r,!0)}catch{return E(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=he(),[r,n]=u.useState(null),[a,o]=u.useState(null),[c,i]=u.useState(null),[d,l]=u.useState(null),[m,g]=u.useState(!0),[w,b]=u.useState(""),[y,A]=u.useState(""),S=u.useCallback(async()=>{g(!0),b("");try{const[p,h,k,f]=await Promise.all([Ae(),Se(),Ce(),Ie()]);if(!p||!h)throw new Error("unavailable");n(p),o(h),i(k),l(await Ne(je(h.env,f,p.env.CSS_BASE_URL??"")))}catch{b("Settings evidence could not be loaded.")}finally{g(!1)}},[]);u.useEffect(()=>{let p=!1;return queueMicrotask(()=>{p||S()}),()=>{p=!0}},[S]);const j=async p=>{if(b(""),!await Re(p)){b("Configuration could not be saved.");return}o(h=>h&&{...h,env:{...h.env,...p}}),A("Saved · restart required")},R=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:m,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:()=>{_e()},children:[s.jsx(Ue,{className:"mr-2 h-4 w-4"}),"Restart Xpod"]})]}):null,s.jsxs(me,{children:[s.jsxs(ge,{children:[s.jsx(we,{children:R}),s.jsx(be,{children:Ct[e]})]}),s.jsx(ve,{className:"space-y-4",children:m&&!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(p=>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"})]},p))}):s.jsx(wt,{kind:e,runtime:t,admin:r,configuration:a,provision:c,publicRoute:d,save:j})})]})]})}function gt({runtime:e,publicRoute:t}){const r=xe(),[n,a]=u.useState(null),[o,c]=u.useState(""),[i,d]=u.useState(""),[l,m]=u.useState(!1),[g,w]=u.useState(""),[b,y]=u.useState(""),A=r.controls,S=r.idpIndex,j=u.useCallback(async()=>{c("");try{a(await ke({controls:A,origin:window.location.origin,trustedAccountIndex:S}))}catch{a(null),c("暂时无法读取存储绑定,请重试。")}},[A,S]);u.useEffect(()=>{let f=!1;return queueMicrotask(()=>{f||j()}),()=>{f=!0}},[j]);const R=u.useMemo(()=>st([e.webId,r.identity?.username,A?.account?.username]),[e.webId,r.identity?.username,A?.account?.username]),p=async f=>{f.preventDefault();const W=A?.account?.pod,M=(i.trim()||R||"").trim();if(!l){if(!W){w("当前部署没有公布创建存储空间的入口。");return}if(!M){w("无法从当前账号推断 Pod 名称,请手动填写。");return}m(!0),w(""),y("");try{await at({assertCurrentAccount:r.bindAccountCapability?.(),createPodUrl:W,headers:ee(),provisionCode:await ye(),trustedAccountIndex:S,username:M}),d(""),y("存储空间已创建。"),await j()}catch($){w($ instanceof Error?$.message:"无法创建存储空间,请重试。")}finally{m(!1)}}},h=pt(e.podUrl,window.location.origin),k=[{label:"Pod name",value:oe(e.podUrl)},{label:"Pod URL",value:h??"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:!h,onClick:()=>h&&window.open(h,"_blank","noopener,noreferrer"),children:[s.jsx(Pe,{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:p,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:R||"my-pod",disabled:l,onChange:f=>d(f.currentTarget.value)}),s.jsx(C,{type:"submit",disabled:l,children:l?"正在创建…":"创建"})]}),g?s.jsx("div",{role:"alert",className:"text-sm text-destructive",children:g}):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(gt,{runtime:t,publicRoute:o}):e==="identity-access"?s.jsx(bt,{runtime:t}):e==="storage"?s.jsxs(s.Fragment,{children:[s.jsx(N,{rows:Ee(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=z({webId:e.webId,podUrl:e.podUrl,authenticatedFetch:e.fetch}),l=V(await d.getServiceAccess(),e.podUrl),g=await Y({authenticatedFetch:e.fetch,ownerWebId:e.webId}).inspectAgentAccess(l);r(g.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=z({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(_,{label:"Base URL",value:a,onChange:o}),s.jsx(_,{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(_,{label:"Cloud endpoint",value:n,onChange:a}),s.jsx(_,{label:"Node ID",value:o,onChange:c}),s.jsx(_,{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 _({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};
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-Cmf4hXVZ.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};