jishushell 0.6.18 → 0.7.3
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.
- package/apps/anythingllm-container.yaml +1 -0
- package/apps/browserless-chromium-container.yaml +1 -0
- package/apps/filebrowser-container.yaml +1 -0
- package/apps/hermes-container.yaml +1 -7
- package/apps/immich-container-lite.yaml +337 -0
- package/apps/immich-container.yaml +371 -0
- package/apps/jishu-kb-container.yaml +26 -21
- package/apps/ollama-binary.yaml +1 -0
- package/apps/ollama-cpu-container.yaml +1 -0
- package/apps/ollama-with-hollama-binary.yaml +2 -0
- package/apps/openclaw-binary.yaml +4 -8
- package/apps/openclaw-container.yaml +1 -7
- package/apps/openclaw-with-ollama-container.yaml +1 -0
- package/apps/openclaw-with-searxng-container.yaml +20 -0
- package/apps/searxng-container.yaml +20 -0
- package/apps/weknora-container.yaml +5 -0
- package/dependencies/jishushell-panel-0.7.3.tgz +0 -0
- package/dist/cli/core.js +1 -1
- package/dist/cli/core.js.map +1 -1
- package/dist/cli/doctor.js +96 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/config.d.ts +9 -1
- package/dist/config.js +72 -2
- package/dist/config.js.map +1 -1
- package/dist/install.js +60 -19
- package/dist/install.js.map +1 -1
- package/dist/routes/admin.d.ts +2 -0
- package/dist/routes/admin.js +72 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/docker.d.ts +2 -0
- package/dist/routes/docker.js +58 -0
- package/dist/routes/docker.js.map +1 -0
- package/dist/routes/file-mounts.js +5 -8
- package/dist/routes/file-mounts.js.map +1 -1
- package/dist/routes/instances.d.ts +0 -14
- package/dist/routes/instances.js +44 -1184
- package/dist/routes/instances.js.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.js +53 -20
- package/dist/server.js.map +1 -1
- package/dist/services/app-common/catalog-service.js +15 -5
- package/dist/services/app-common/catalog-service.js.map +1 -1
- package/dist/services/app-common/delete-service.js +5 -0
- package/dist/services/app-common/delete-service.js.map +1 -1
- package/dist/services/app-common/instance-store.js +3 -0
- package/dist/services/app-common/instance-store.js.map +1 -1
- package/dist/services/app-common/lifecycle-service.js +12 -4
- package/dist/services/app-common/lifecycle-service.js.map +1 -1
- package/dist/services/app-common/ownership.d.ts +3 -0
- package/dist/services/app-common/ownership.js +11 -0
- package/dist/services/app-common/ownership.js.map +1 -0
- package/dist/services/app-common/runtime-facts.js +2 -0
- package/dist/services/app-common/runtime-facts.js.map +1 -1
- package/dist/services/app-common/spec-materializer.d.ts +0 -1
- package/dist/services/app-common/spec-materializer.js +21 -87
- package/dist/services/app-common/spec-materializer.js.map +1 -1
- package/dist/services/app-common/status-refresh.js +25 -13
- package/dist/services/app-common/status-refresh.js.map +1 -1
- package/dist/services/app-modules/browserless/routes.js +5 -3
- package/dist/services/app-modules/browserless/routes.js.map +1 -1
- package/dist/services/capabilities/contract.d.ts +1 -2
- package/dist/services/capabilities/contract.js +0 -10
- package/dist/services/capabilities/contract.js.map +1 -1
- package/dist/services/capabilities/endpoint-validator.js +0 -1
- package/dist/services/capabilities/endpoint-validator.js.map +1 -1
- package/dist/services/capabilities/health.js +1 -1
- package/dist/services/capabilities/health.js.map +1 -1
- package/dist/services/capability-proxy/http.d.ts +7 -0
- package/dist/services/capability-proxy/http.js +555 -0
- package/dist/services/capability-proxy/http.js.map +1 -0
- package/dist/services/capability-proxy/terminal.d.ts +4 -0
- package/dist/services/capability-proxy/terminal.js +179 -0
- package/dist/services/capability-proxy/terminal.js.map +1 -0
- package/dist/services/connections/admin.js +19 -9
- package/dist/services/connections/admin.js.map +1 -1
- package/dist/services/connections/apply.d.ts +3 -9
- package/dist/services/connections/apply.js +0 -29
- package/dist/services/connections/apply.js.map +1 -1
- package/dist/services/connections/transactor.js +2 -2
- package/dist/services/connections/transactor.js.map +1 -1
- package/dist/services/files/bootstrap.d.ts +7 -0
- package/dist/services/files/bootstrap.js +16 -0
- package/dist/services/files/bootstrap.js.map +1 -0
- package/dist/services/files/photos/upload-page.d.ts +2 -0
- package/dist/services/files/photos/upload-page.js +248 -0
- package/dist/services/files/photos/upload-page.js.map +1 -0
- package/dist/services/files/photos/upload-store.d.ts +74 -0
- package/dist/services/files/photos/upload-store.js +432 -0
- package/dist/services/files/photos/upload-store.js.map +1 -0
- package/dist/services/http/proxy-utils.d.ts +7 -0
- package/dist/services/http/proxy-utils.js +29 -0
- package/dist/services/http/proxy-utils.js.map +1 -0
- package/dist/services/http/request-utils.d.ts +3 -0
- package/dist/services/http/request-utils.js +23 -0
- package/dist/services/http/request-utils.js.map +1 -0
- package/dist/services/instances/manager.d.ts +6 -5
- package/dist/services/instances/manager.js +45 -51
- package/dist/services/instances/manager.js.map +1 -1
- package/dist/services/instances/pairing.d.ts +17 -0
- package/dist/services/instances/pairing.js +53 -0
- package/dist/services/instances/pairing.js.map +1 -0
- package/dist/services/instances/status.d.ts +2 -0
- package/dist/services/instances/status.js +11 -0
- package/dist/services/instances/status.js.map +1 -0
- package/dist/services/integrations/hermes/integration.d.ts +1 -1
- package/dist/services/integrations/hermes/integration.js +7 -8
- package/dist/services/integrations/hermes/integration.js.map +1 -1
- package/dist/services/integrations/immich/client.d.ts +93 -0
- package/dist/services/integrations/immich/client.js +458 -0
- package/dist/services/integrations/immich/client.js.map +1 -0
- package/dist/services/integrations/immich/config.d.ts +15 -0
- package/dist/services/integrations/immich/config.js +178 -0
- package/dist/services/integrations/immich/config.js.map +1 -0
- package/dist/services/integrations/immich/discovery.d.ts +9 -0
- package/dist/services/integrations/immich/discovery.js +101 -0
- package/dist/services/integrations/immich/discovery.js.map +1 -0
- package/dist/services/integrations/immich/gallery-renderer.d.ts +5 -0
- package/dist/services/integrations/immich/gallery-renderer.js +150 -0
- package/dist/services/integrations/immich/gallery-renderer.js.map +1 -0
- package/dist/services/integrations/immich/immich-shim.d.ts +11 -0
- package/dist/services/integrations/immich/immich-shim.js +439 -0
- package/dist/services/integrations/immich/immich-shim.js.map +1 -0
- package/dist/services/integrations/immich/integration.d.ts +18 -0
- package/dist/services/integrations/immich/integration.js +64 -0
- package/dist/services/integrations/immich/integration.js.map +1 -0
- package/dist/services/integrations/immich/photo-library.d.ts +4 -0
- package/dist/services/integrations/immich/photo-library.js +63 -0
- package/dist/services/integrations/immich/photo-library.js.map +1 -0
- package/dist/services/integrations/immich/review-executor.d.ts +3 -0
- package/dist/services/integrations/immich/review-executor.js +41 -0
- package/dist/services/integrations/immich/review-executor.js.map +1 -0
- package/dist/services/integrations/immich/review-session-service.d.ts +27 -0
- package/dist/services/integrations/immich/review-session-service.js +206 -0
- package/dist/services/integrations/immich/review-session-service.js.map +1 -0
- package/dist/services/integrations/immich/review-store.d.ts +47 -0
- package/dist/services/integrations/immich/review-store.js +347 -0
- package/dist/services/integrations/immich/review-store.js.map +1 -0
- package/dist/services/integrations/immich/routes.d.ts +7 -0
- package/dist/services/integrations/immich/routes.js +363 -0
- package/dist/services/integrations/immich/routes.js.map +1 -0
- package/dist/services/integrations/immich/types.d.ts +186 -0
- package/dist/services/integrations/immich/types.js +2 -0
- package/dist/services/integrations/immich/types.js.map +1 -0
- package/dist/services/integrations/index.d.ts +1 -0
- package/dist/services/integrations/index.js +1 -0
- package/dist/services/integrations/index.js.map +1 -1
- package/dist/services/integrations/installable/installers/integration.js +113 -7
- package/dist/services/integrations/installable/installers/integration.js.map +1 -1
- package/dist/services/integrations/jishukb/integration.d.ts +3 -1
- package/dist/services/integrations/jishukb/integration.js +121 -10
- package/dist/services/integrations/jishukb/integration.js.map +1 -1
- package/dist/services/integrations/openclaw/integration.d.ts +21 -7
- package/dist/services/integrations/openclaw/integration.js +385 -158
- package/dist/services/integrations/openclaw/integration.js.map +1 -1
- package/dist/services/integrations/openclaw/jishukb-native-mcp.d.ts +58 -0
- package/dist/services/integrations/openclaw/jishukb-native-mcp.js +373 -0
- package/dist/services/integrations/openclaw/jishukb-native-mcp.js.map +1 -0
- package/dist/services/integrations/openclaw/jishukb-shim.d.ts +8 -4
- package/dist/services/integrations/openclaw/jishukb-shim.js +624 -17
- package/dist/services/integrations/openclaw/jishukb-shim.js.map +1 -1
- package/dist/services/integrations/openclaw/mcporter.d.ts +13 -0
- package/dist/services/integrations/openclaw/mcporter.js +31 -0
- package/dist/services/integrations/openclaw/mcporter.js.map +1 -1
- package/dist/services/integrations/openclaw/native-mcp.d.ts +48 -0
- package/dist/services/integrations/openclaw/native-mcp.js +125 -0
- package/dist/services/integrations/openclaw/native-mcp.js.map +1 -0
- package/dist/services/integrations/openclaw/routes.js +4 -1
- package/dist/services/integrations/openclaw/routes.js.map +1 -1
- package/dist/services/integrations/types.d.ts +5 -17
- package/dist/services/repair/runtime-repair.js +68 -1
- package/dist/services/repair/runtime-repair.js.map +1 -1
- package/dist/services/runtime/docker-network.d.ts +8 -0
- package/dist/services/runtime/docker-network.js +123 -0
- package/dist/services/runtime/docker-network.js.map +1 -0
- package/dist/services/runtime/driver-registry.d.ts +4 -0
- package/dist/services/runtime/driver-registry.js.map +1 -1
- package/dist/services/runtime/drivers/nomad.d.ts +1 -0
- package/dist/services/runtime/drivers/nomad.js +35 -5
- package/dist/services/runtime/drivers/nomad.js.map +1 -1
- package/dist/services/runtime/service-manager.d.ts +2 -0
- package/dist/services/runtime/service-manager.js +18 -0
- package/dist/services/runtime/service-manager.js.map +1 -0
- package/dist/services/runtime/types.d.ts +1 -0
- package/dist/services/runtime/workload-compiler.js +29 -4
- package/dist/services/runtime/workload-compiler.js.map +1 -1
- package/dist/services/setup/setup-manager.js +29 -73
- package/dist/services/setup/setup-manager.js.map +1 -1
- package/dist/services/system/runtime-ownership.d.ts +36 -0
- package/dist/services/system/runtime-ownership.js +250 -0
- package/dist/services/system/runtime-ownership.js.map +1 -0
- package/dist/services/system/system-reconciler.js +53 -0
- package/dist/services/system/system-reconciler.js.map +1 -1
- package/dist/types.d.ts +19 -3
- package/dist/utils/path-safety.js +1 -1
- package/dist/utils/service-user.d.ts +13 -0
- package/dist/utils/service-user.js +129 -0
- package/dist/utils/service-user.js.map +1 -0
- package/install/jishu-install.sh +0 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js +24 -14
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +24 -14
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +2 -2
- package/node_modules/fast-uri/index.js +1 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +28 -0
- package/node_modules/fastify/SECURITY.md +1 -1
- package/node_modules/fastify/SPONSORS.md +6 -4
- package/node_modules/fastify/docs/Guides/Database.md +0 -28
- package/node_modules/fastify/docs/Guides/Ecosystem.md +13 -2
- package/node_modules/fastify/docs/Guides/Serverless.md +2 -2
- package/node_modules/fastify/docs/Guides/Write-Plugin.md +1 -1
- package/node_modules/fastify/docs/Reference/Encapsulation.md +27 -26
- package/node_modules/fastify/docs/Reference/Errors.md +10 -4
- package/node_modules/fastify/docs/Reference/HTTP2.md +10 -10
- package/node_modules/fastify/docs/Reference/Hooks.md +4 -4
- package/node_modules/fastify/docs/Reference/Index.md +14 -16
- package/node_modules/fastify/docs/Reference/LTS.md +12 -13
- package/node_modules/fastify/docs/Reference/Lifecycle.md +9 -8
- package/node_modules/fastify/docs/Reference/Logging.md +44 -39
- package/node_modules/fastify/docs/Reference/Middleware.md +21 -25
- package/node_modules/fastify/docs/Reference/Principles.md +2 -2
- package/node_modules/fastify/docs/Reference/Reply.md +6 -1
- package/node_modules/fastify/docs/Reference/Request.md +27 -16
- package/node_modules/fastify/docs/Reference/Routes.md +5 -2
- package/node_modules/fastify/docs/Reference/Server.md +31 -3
- package/node_modules/fastify/docs/Reference/Type-Providers.md +29 -5
- package/node_modules/fastify/docs/Reference/Validation-and-Serialization.md +15 -2
- package/node_modules/fastify/docs/Reference/Warnings.md +7 -6
- package/node_modules/fastify/eslint.config.js +7 -2
- package/node_modules/fastify/fastify.d.ts +8 -3
- package/node_modules/fastify/fastify.js +43 -14
- package/node_modules/fastify/lib/content-type-parser.js +13 -1
- package/node_modules/fastify/lib/decorate.js +11 -3
- package/node_modules/fastify/lib/error-handler.js +4 -3
- package/node_modules/fastify/lib/error-serializer.js +59 -59
- package/node_modules/fastify/lib/errors.js +16 -1
- package/node_modules/fastify/lib/four-oh-four.js +14 -9
- package/node_modules/fastify/lib/handle-request.js +11 -5
- package/node_modules/fastify/lib/plugin-override.js +2 -1
- package/node_modules/fastify/lib/plugin-utils.js +5 -5
- package/node_modules/fastify/lib/reply.js +63 -8
- package/node_modules/fastify/lib/request.js +14 -4
- package/node_modules/fastify/lib/route.js +20 -6
- package/node_modules/fastify/lib/schema-controller.js +1 -1
- package/node_modules/fastify/lib/schemas.js +37 -30
- package/node_modules/fastify/lib/symbols.js +3 -1
- package/node_modules/fastify/lib/validation.js +1 -13
- package/node_modules/fastify/lib/warnings.js +3 -3
- package/node_modules/fastify/package.json +13 -15
- package/node_modules/fastify/scripts/validate-ecosystem-links.js +1 -0
- package/node_modules/fastify/test/bundler/esbuild/package.json +1 -1
- package/node_modules/fastify/test/close-pipelining.test.js +1 -2
- package/node_modules/fastify/test/custom-http-server.test.js +38 -0
- package/node_modules/fastify/test/decorator-instance-properties.test.js +63 -0
- package/node_modules/fastify/test/diagnostics-channel/async-error-handler.test.js +74 -0
- package/node_modules/fastify/test/hooks.test.js +23 -0
- package/node_modules/fastify/test/http-methods/get.test.js +1 -1
- package/node_modules/fastify/test/http2/plain.test.js +135 -0
- package/node_modules/fastify/test/http2/secure-with-fallback.test.js +1 -1
- package/node_modules/fastify/test/https/https.test.js +1 -2
- package/node_modules/fastify/test/internals/errors.test.js +31 -1
- package/node_modules/fastify/test/internals/plugin.test.js +3 -1
- package/node_modules/fastify/test/internals/request.test.js +27 -3
- package/node_modules/fastify/test/internals/schema-controller-perf.test.js +33 -0
- package/node_modules/fastify/test/logger/logging.test.js +18 -1
- package/node_modules/fastify/test/logger/options.test.js +38 -1
- package/node_modules/fastify/test/reply-error.test.js +1 -1
- package/node_modules/fastify/test/reply-trailers.test.js +70 -0
- package/node_modules/fastify/test/request-media-type.test.js +105 -0
- package/node_modules/fastify/test/route-prefix.test.js +34 -0
- package/node_modules/fastify/test/router-options.test.js +222 -11
- package/node_modules/fastify/test/schema-serialization.test.js +108 -0
- package/node_modules/fastify/test/schema-validation.test.js +24 -0
- package/node_modules/fastify/test/scripts/validate-ecosystem-links.test.js +40 -57
- package/node_modules/fastify/test/throw.test.js +14 -0
- package/node_modules/fastify/test/trust-proxy.test.js +21 -0
- package/node_modules/fastify/test/types/content-type-parser.tst.ts +70 -0
- package/node_modules/fastify/test/types/{decorate-request-reply.test-d.ts → decorate-request-reply.tst.ts} +4 -4
- package/node_modules/fastify/test/types/{dummy-plugin.ts → dummy-plugin.mts} +1 -1
- package/node_modules/fastify/test/types/errors.tst.ts +91 -0
- package/node_modules/fastify/test/types/fastify.tst.ts +351 -0
- package/node_modules/fastify/test/types/hooks.tst.ts +578 -0
- package/node_modules/fastify/test/types/instance.tst.ts +597 -0
- package/node_modules/fastify/test/types/{logger.test-d.ts → logger.tst.ts} +61 -62
- package/node_modules/fastify/test/types/plugin.tst.ts +96 -0
- package/node_modules/fastify/test/types/register.tst.ts +245 -0
- package/node_modules/fastify/test/types/reply.tst.ts +297 -0
- package/node_modules/fastify/test/types/request.tst.ts +199 -0
- package/node_modules/fastify/test/types/route.tst.ts +576 -0
- package/node_modules/fastify/test/types/{schema.test-d.ts → schema.tst.ts} +22 -22
- package/node_modules/fastify/test/types/{serverFactory.test-d.ts → serverFactory.tst.ts} +4 -4
- package/node_modules/fastify/test/types/tsconfig.json +9 -0
- package/node_modules/fastify/test/types/{type-provider.test-d.ts → type-provider.tst.ts} +256 -250
- package/node_modules/fastify/test/types/using.tst.ts +14 -0
- package/node_modules/fastify/types/errors.d.ts +3 -0
- package/node_modules/fastify/types/request.d.ts +23 -2
- package/node_modules/jishushell-panel/output/public/assets/{ApiKeyField-NKcbHjNz.js → ApiKeyField-Ce5d1xna.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{Dashboard-Da1fL38t.js → Dashboard-BXame3yg.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{HermesChatPanel-DZvmYsoh.js → HermesChatPanel-BHZtPCJd.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{HermesConfigForm-BLUWlKwm.js → HermesConfigForm-CB3GbNX9.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{InitPassword-BAKsshzk.js → InitPassword-Boab9F6g.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-DrIWCqo-.js +14 -0
- package/node_modules/jishushell-panel/output/public/assets/{Login-DHeOmwI8.js → Login-CzpOkNau.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/NewInstance-CANXyCcL.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{ProviderRecommendations-H0ByEYF0.js → ProviderRecommendations-BABo9VOC.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/Settings-CKp5XxFh.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/Setup-C7xVDPow.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{WeixinLoginPanel-D-T6BxkQ.js → WeixinLoginPanel-B765Xz4C.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{index-ERt6_ngA.js → index-Bs6DSbiR.js} +6 -6
- package/node_modules/jishushell-panel/output/public/assets/{registry-DF93EzIb.js → registry-sWIZsIEF.js} +2 -2
- package/node_modules/jishushell-panel/output/public/assets/{usePolling-DeoThIQn.js → usePolling-D4IDOQd_.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-Df8aUdv8.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{vendor-react-Cc84NArf.js → vendor-react-0L0rjmYG.js} +3 -3
- package/node_modules/jishushell-panel/output/public/index.html +3 -3
- package/node_modules/jishushell-panel/package.json +1 -1
- package/node_modules/semver/classes/range.js +6 -2
- package/node_modules/semver/package.json +1 -1
- package/package.json +4 -4
- package/scripts/check-app-spec.mjs +4 -12
- package/scripts/check-architecture-boundaries.mjs +178 -0
- package/scripts/pack-gui-and-send-pi.sh +5 -3
- package/dependencies/jishushell-panel-0.6.18.tgz +0 -0
- package/dist/services/connections/suggestions.d.ts +0 -27
- package/dist/services/connections/suggestions.js +0 -124
- package/dist/services/connections/suggestions.js.map +0 -1
- package/node_modules/fastify/test/types/content-type-parser.test-d.ts +0 -72
- package/node_modules/fastify/test/types/errors.test-d.ts +0 -90
- package/node_modules/fastify/test/types/fastify.test-d.ts +0 -352
- package/node_modules/fastify/test/types/hooks.test-d.ts +0 -550
- package/node_modules/fastify/test/types/import.ts +0 -2
- package/node_modules/fastify/test/types/instance.test-d.ts +0 -588
- package/node_modules/fastify/test/types/plugin.test-d.ts +0 -97
- package/node_modules/fastify/test/types/register.test-d.ts +0 -237
- package/node_modules/fastify/test/types/reply.test-d.ts +0 -254
- package/node_modules/fastify/test/types/request.test-d.ts +0 -188
- package/node_modules/fastify/test/types/route.test-d.ts +0 -553
- package/node_modules/fastify/test/types/using.test-d.ts +0 -17
- package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-Dgyc_TX5.js +0 -14
- package/node_modules/jishushell-panel/output/public/assets/NewInstance-CIy0cYtp.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/Settings-DAT-UMfP.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/Setup-g3uckFYR.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-CS8DFbkQ.js +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { expect, test } from 'tstyche'
|
|
2
|
+
import fastify, { FastifyInstance } from '../../fastify.js'
|
|
3
|
+
|
|
4
|
+
test("has 'Symbol.dispose' when declared with 'using'", async () => {
|
|
5
|
+
await using app = fastify()
|
|
6
|
+
expect(app).type.toBeAssignableTo<FastifyInstance>()
|
|
7
|
+
expect(app[Symbol.asyncDispose]).type.toBe<() => Promise<undefined>>()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
test("has 'Symbol.dispose'", async () => {
|
|
11
|
+
await using app = fastify()
|
|
12
|
+
expect(app).type.toBeAssignableTo<FastifyInstance>()
|
|
13
|
+
expect(app[Symbol.asyncDispose]).type.toBe<() => Promise<undefined>>()
|
|
14
|
+
})
|
|
@@ -65,6 +65,7 @@ export type FastifyErrorCodes = Record<
|
|
|
65
65
|
'FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE' |
|
|
66
66
|
'FST_ERR_DUPLICATED_ROUTE' |
|
|
67
67
|
'FST_ERR_BAD_URL' |
|
|
68
|
+
'FST_ERR_MAX_PARAM_LENGTH' |
|
|
68
69
|
'FST_ERR_ASYNC_CONSTRAINT' |
|
|
69
70
|
'FST_ERR_INVALID_URL' |
|
|
70
71
|
'FST_ERR_ROUTE_OPTIONS_NOT_OBJ' |
|
|
@@ -73,6 +74,7 @@ export type FastifyErrorCodes = Record<
|
|
|
73
74
|
'FST_ERR_ROUTE_MISSING_HANDLER' |
|
|
74
75
|
'FST_ERR_ROUTE_METHOD_INVALID' |
|
|
75
76
|
'FST_ERR_ROUTE_METHOD_NOT_SUPPORTED' |
|
|
77
|
+
'FST_ERR_ROUTE_LOG_LEVEL_INVALID' |
|
|
76
78
|
'FST_ERR_ROUTE_BODY_VALIDATION_SCHEMA_NOT_SUPPORTED' |
|
|
77
79
|
'FST_ERR_ROUTE_BODY_LIMIT_OPTION_NOT_INT' |
|
|
78
80
|
'FST_ERR_HANDLER_TIMEOUT' |
|
|
@@ -84,6 +86,7 @@ export type FastifyErrorCodes = Record<
|
|
|
84
86
|
'FST_ERR_PLUGIN_VERSION_MISMATCH' |
|
|
85
87
|
'FST_ERR_PLUGIN_NOT_PRESENT_IN_INSTANCE' |
|
|
86
88
|
'FST_ERR_PLUGIN_INVALID_ASYNC_HANDLER' |
|
|
89
|
+
'FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED' |
|
|
87
90
|
'FST_ERR_PLUGIN_CALLBACK_NOT_FN' |
|
|
88
91
|
'FST_ERR_PLUGIN_NOT_VALID' |
|
|
89
92
|
'FST_ERR_ROOT_PLG_BOOTED' |
|
|
@@ -71,22 +71,43 @@ export interface FastifyRequest<RouteGeneric extends RouteGenericInterface = Rou
|
|
|
71
71
|
* @deprecated Use `raw` property
|
|
72
72
|
*/
|
|
73
73
|
readonly req: RawRequest & RouteGeneric['Headers']; // this enables the developer to extend the existing http(s|2) headers list
|
|
74
|
+
/**
|
|
75
|
+
* Derived from request socket metadata or forwarding headers.
|
|
76
|
+
* Treat as untrusted input and validate before security-sensitive use.
|
|
77
|
+
*/
|
|
74
78
|
readonly ip: string;
|
|
79
|
+
/**
|
|
80
|
+
* Derived from forwarding headers when trustProxy is enabled.
|
|
81
|
+
* Treat as untrusted input and validate before security-sensitive use.
|
|
82
|
+
*/
|
|
75
83
|
readonly ips?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* Derived from Host/:authority/X-Forwarded-Host request metadata.
|
|
86
|
+
* Treat as untrusted input and validate before security-sensitive use.
|
|
87
|
+
*/
|
|
76
88
|
readonly host: string;
|
|
89
|
+
/**
|
|
90
|
+
* Parsed from request host metadata.
|
|
91
|
+
* Treat as untrusted input and validate before security-sensitive use.
|
|
92
|
+
*/
|
|
77
93
|
readonly port: number | null;
|
|
78
94
|
readonly hostname: string;
|
|
79
95
|
readonly url: string;
|
|
80
96
|
readonly originalUrl: string;
|
|
97
|
+
/**
|
|
98
|
+
* Derived from socket state or forwarding headers.
|
|
99
|
+
* Treat as untrusted input and validate before security-sensitive use.
|
|
100
|
+
*/
|
|
81
101
|
readonly protocol: 'http' | 'https';
|
|
82
102
|
readonly method: string;
|
|
83
103
|
readonly routeOptions: Readonly<RequestRouteOptions<ContextConfig, SchemaCompiler>>
|
|
84
104
|
readonly is404: boolean;
|
|
85
105
|
readonly socket: RawRequest['socket'];
|
|
86
106
|
readonly signal: AbortSignal;
|
|
107
|
+
readonly mediaType: string | undefined;
|
|
87
108
|
|
|
88
|
-
getValidationFunction(httpPart: HTTPRequestPart): ValidationFunction
|
|
89
|
-
getValidationFunction(schema: { [key: string]: any }): ValidationFunction
|
|
109
|
+
getValidationFunction(httpPart: HTTPRequestPart): ValidationFunction | undefined
|
|
110
|
+
getValidationFunction(schema: { [key: string]: any }): ValidationFunction | undefined
|
|
90
111
|
compileValidationSchema(schema: { [key: string]: any }, httpPart?: HTTPRequestPart): ValidationFunction
|
|
91
112
|
validateInput(input: any, schema: { [key: string]: any }, httpPart?: HTTPRequestPart): boolean
|
|
92
113
|
validateInput(input: any, httpPart?: HTTPRequestPart): boolean
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-CS8DFbkQ.js";import{t as r}from"./vendor-react-Cc84NArf.js";import{It as i}from"./api-C70Gt678.js";import{c as a,f as o,p as s,s as c}from"./index-ERt6_ngA.js";var l=[{providerId:`zhipu`,label:`GLM`,purchaseUrl:`https://bigmodel.cn/glm-coding`},{providerId:`moonshot`,label:`Kimi`,purchaseUrl:`https://www.kimi.com/membership/pricing?from=kfc_membership_topbar`},{providerId:`deepseek`,label:`DeepSeek`,purchaseUrl:`https://platform.deepseek.com/sign_in`},{providerId:`minimax`,label:`MiniMax`,purchaseUrl:`https://platform.minimaxi.com/subscribe/token-plan`},{providerId:`stepfun`,label:`阶跃星辰`,purchaseUrl:`https://platform.stepfun.com/step-plan`},{providerId:`xiaomi`,label:`小米Mimo`,purchaseUrl:`https://platform.xiaomimimo.com/token-plan`}],u=[{id:`minimax`,label:`MiniMax (国内)`,group:`国内厂商`,baseUrl:`https://api.minimaxi.com/v1`,api:`openai-completions`,models:[{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800}]},{id:`minimax-intl`,label:`MiniMax (国际)`,group:`国际厂商`,baseUrl:`https://api.minimax.io/anthropic`,api:`anthropic-messages`,authHeader:!0,models:[{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800}]},{id:`moonshot`,label:`Kimi (Moonshot)`,group:`国内厂商`,baseUrl:`https://api.moonshot.cn/v1`,api:`openai-completions`,models:[{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:256e3},{id:`moonshot-v1-128k`,name:`Moonshot V1 128K`,contextWindow:128e3},{id:`moonshot-v1-32k`,name:`Moonshot V1 32K`,contextWindow:32e3},{id:`moonshot-v1-8k`,name:`Moonshot V1 8K`,contextWindow:8e3}]},{id:`moonshot-coding`,label:`Kimi (编码计划)`,group:`国内厂商`,baseUrl:`https://api.moonshot.cn/anthropic`,api:`anthropic-messages`,authHeader:!0,models:[{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:256e3},{id:`kimi-k2-thinking-turbo`,name:`Kimi K2 Thinking Turbo`,contextWindow:256e3},{id:`kimi-k2-thinking`,name:`Kimi K2 Thinking`,contextWindow:256e3},{id:`kimi-k2-0905-preview`,name:`Kimi K2 0905 Preview`,contextWindow:256e3},{id:`kimi-k2-turbo-preview`,name:`Kimi K2 Turbo Preview`,contextWindow:256e3}]},{id:`moonshot-intl`,label:`Kimi (国际)`,group:`国际厂商`,baseUrl:`https://api.moonshot.ai/v1`,api:`openai-completions`,models:[{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:256e3},{id:`moonshot-v1-128k`,name:`Moonshot V1 128K`,contextWindow:128e3}]},{id:`zhipu`,label:`智谱AI (GLM)`,group:`国内厂商`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,api:`openai-completions`,models:[{id:`glm-5.1`,name:`GLM-5.1`,contextWindow:2e5},{id:`glm-5`,name:`GLM-5`,contextWindow:2e5},{id:`glm-5-turbo`,name:`GLM-5 Turbo`,contextWindow:2e5},{id:`glm-4.7`,name:`GLM-4.7`,contextWindow:2e5},{id:`glm-4.7-flashx`,name:`GLM-4.7 FlashX`,contextWindow:2e5},{id:`glm-4.7-flash`,name:`GLM-4.7 Flash (免费)`,contextWindow:2e5},{id:`glm-4-plus`,name:`GLM-4 Plus`,contextWindow:128e3},{id:`glm-4-long`,name:`GLM-4 Long`,contextWindow:1e6}]},{id:`zhipu-intl`,label:`Z.AI (GLM)`,group:`国际厂商`,baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,models:[{id:`glm-5.1`,name:`GLM-5.1`,contextWindow:2e5},{id:`glm-5`,name:`GLM-5`,contextWindow:2e5},{id:`glm-5-turbo`,name:`GLM-5 Turbo`,contextWindow:2e5},{id:`glm-4.7`,name:`GLM-4.7`,contextWindow:2e5},{id:`glm-4.7-flash`,name:`GLM-4.7 Flash`,contextWindow:2e5},{id:`glm-4-plus`,name:`GLM-4 Plus`,contextWindow:128e3}]},{id:`byteplus`,label:`火山引擎国际版 (Doubao)`,group:`国际厂商`,baseUrl:`https://ark.ap-southeast.bytepluses.com/api/v3`,api:`openai-completions`,models:[{id:`seed-2-0-lite-260228`,name:`Seed 2.0 Lite`,contextWindow:256e3},{id:`seed-2-0-mini-260215`,name:`Seed 2.0 Mini`,contextWindow:256e3},{id:`seed-1-8-251228`,name:`Seed 1.8`,contextWindow:256e3}]},{id:`deepseek`,label:`DeepSeek`,group:`国内厂商`,baseUrl:`https://api.deepseek.com/v1`,api:`openai-completions`,models:[{id:`deepseek-chat`,name:`DeepSeek V3.2`,contextWindow:128e3},{id:`deepseek-reasoner`,name:`DeepSeek V3.2 (推理)`,contextWindow:128e3}]},{id:`dashscope`,label:`阿里云百炼`,group:`国内厂商`,baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,models:[{id:`qwen3.5-plus`,name:`Qwen 3.5 Plus`,contextWindow:1e6},{id:`qwen3.5-flash`,name:`Qwen 3.5 Flash`,contextWindow:1e6},{id:`qwen3-max`,name:`Qwen 3 Max`,contextWindow:262144},{id:`qwen3-coder-plus`,name:`Qwen 3 Coder Plus`,contextWindow:1e6},{id:`qwen3-coder-next`,name:`Qwen 3 Coder Next`,contextWindow:262144},{id:`qwen3-coder-flash`,name:`Qwen 3 Coder Flash`,contextWindow:1e6},{id:`qwen-plus`,name:`Qwen Plus`,contextWindow:1e6},{id:`qwen-long`,name:`Qwen Long (10M)`,contextWindow:1e7}]},{id:`modelstudio`,label:`阿里云百炼 (国际/Coding)`,group:`国内厂商`,baseUrl:`https://coding-intl.dashscope.aliyuncs.com/v1`,api:`openai-completions`,models:[{id:`qwen3.5-plus`,name:`Qwen 3.5 Plus`,contextWindow:1e6},{id:`qwen3-coder-plus`,name:`Qwen 3 Coder Plus`,contextWindow:1e6},{id:`qwen3-coder-next`,name:`Qwen 3 Coder Next`,contextWindow:262144}]},{id:`volcengine`,label:`火山引擎 (豆包)`,group:`国内厂商`,baseUrl:`https://ark.cn-beijing.volces.com/api/v3`,api:`openai-completions`,models:[{id:`doubao-seed-2-0-pro-260215`,name:`Doubao Seed 2.0 Pro (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-2-0-lite-260228`,name:`Doubao Seed 2.0 Lite (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-2-0-code-preview-260215`,name:`Doubao Seed 2.0 Code (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-2-0-mini-260215`,name:`Doubao Seed 2.0 Mini (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-1-8-251228`,name:`Doubao Seed 1.8 (需替换为接入点ID)`,contextWindow:256e3}]},{id:`qianfan`,label:`百度千帆 (ERNIE)`,group:`国内厂商`,baseUrl:`https://qianfan.baidubce.com/v2`,api:`openai-completions`,models:[{id:`ernie-5.0`,name:`ERNIE 5.0`,contextWindow:128e3},{id:`ernie-5.0-thinking-preview`,name:`ERNIE 5.0 Thinking`,contextWindow:128e3},{id:`ernie-4.5-turbo-128k`,name:`ERNIE 4.5 Turbo (MoE)`,contextWindow:128e3},{id:`ernie-x1.1`,name:`ERNIE X1.1 (推理)`,contextWindow:64e3},{id:`deepseek-v3.2`,name:`DeepSeek V3.2 (千帆)`,contextWindow:128e3}]},{id:`tencent`,label:`腾讯混元`,group:`国内厂商`,baseUrl:`https://api.hunyuan.cloud.tencent.com/v1`,api:`openai-completions`,models:[{id:`hunyuan-2.0-thinking-20251109`,name:`Hunyuan 2.0 Think (推理)`,contextWindow:128e3},{id:`hunyuan-2.0-instruct-20251111`,name:`Hunyuan 2.0 Instruct`,contextWindow:128e3},{id:`hunyuan-t1-latest`,name:`Hunyuan T1 (推理)`,contextWindow:32e3},{id:`hunyuan-turbos-latest`,name:`Hunyuan TurboS`,contextWindow:32e3},{id:`hunyuan-a13b`,name:`Hunyuan A13B (MoE)`,contextWindow:224e3},{id:`hunyuan-lite`,name:`Hunyuan Lite (免费)`,contextWindow:25e4}]},{id:`xiaomi`,label:`MiMo (小米)`,group:`国内厂商`,baseUrl:`https://api.xiaomimimo.com/v1`,api:`openai-completions`,models:[{id:`mimo-v2-pro`,name:`MiMo V2 Pro (推理)`,contextWindow:1048576},{id:`mimo-v2-omni`,name:`MiMo V2 Omni (多模)`,contextWindow:262144},{id:`mimo-v2-flash`,name:`MiMo V2 Flash`,contextWindow:262144}]},{id:`spark`,label:`讯飞星火`,group:`国内厂商`,baseUrl:`https://spark-api-open.xf-yun.com/v1`,api:`openai-completions`,models:[{id:`spark-x`,name:`Spark X1.5 (推理)`,contextWindow:32768},{id:`4.0Ultra`,name:`Spark 4.0 Ultra`,contextWindow:32768},{id:`pro-128k`,name:`Spark Pro 128K`,contextWindow:131072},{id:`lite`,name:`Spark Lite (免费)`,contextWindow:8192}]},{id:`stepfun`,label:`阶跃星辰`,group:`国内厂商`,baseUrl:`https://api.stepfun.com/v1`,api:`openai-completions`,models:[{id:`step-3.5-flash`,name:`Step 3.5 Flash (推理)`,contextWindow:262144},{id:`step-3`,name:`Step 3 (多模推理)`,contextWindow:65536},{id:`step-2-mini`,name:`Step 2 Mini`,contextWindow:32e3},{id:`step-1o-turbo-vision`,name:`Step 1o Turbo Vision`,contextWindow:32e3},{id:`step-1-256k`,name:`Step 1 256K`,contextWindow:256e3}]},{id:`openai`,label:`OpenAI`,group:`国际厂商`,baseUrl:`https://api.openai.com/v1`,api:`openai-completions`,models:[{id:`gpt-5.4`,name:`GPT-5.4`,contextWindow:105e4},{id:`gpt-5.4-pro`,name:`GPT-5.4 Pro`,contextWindow:105e4},{id:`gpt-5.4-mini`,name:`GPT-5.4 Mini`,contextWindow:4e5},{id:`gpt-5.4-nano`,name:`GPT-5.4 Nano`,contextWindow:4e5},{id:`o3-pro`,name:`o3-pro (推理)`,contextWindow:2e5},{id:`o3`,name:`o3 (推理)`,contextWindow:2e5},{id:`o4-mini`,name:`o4-mini (推理)`,contextWindow:2e5},{id:`gpt-4.1`,name:`GPT-4.1`,contextWindow:1e6},{id:`gpt-4.1-mini`,name:`GPT-4.1 Mini`,contextWindow:1e6}]},{id:`anthropic`,label:`Anthropic (Claude)`,group:`国际厂商`,baseUrl:`https://api.anthropic.com`,api:`anthropic-messages`,models:[{id:`claude-opus-4-6`,name:`Claude Opus 4.6`,contextWindow:1e6},{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`,contextWindow:1e6},{id:`claude-haiku-4-5`,name:`Claude Haiku 4.5`,contextWindow:2e5}]},{id:`google`,label:`Google Gemini`,group:`国际厂商`,baseUrl:`https://generativelanguage.googleapis.com`,api:`google-generative-ai`,models:[{id:`gemini-3.1-pro-preview`,name:`Gemini 3.1 Pro (Preview)`,contextWindow:1048576},{id:`gemini-3-flash-preview`,name:`Gemini 3 Flash (Preview)`,contextWindow:1048576},{id:`gemini-3.1-flash-lite-preview`,name:`Gemini 3.1 Flash Lite (Preview)`,contextWindow:1048576},{id:`gemini-2.5-flash`,name:`Gemini 2.5 Flash`,contextWindow:1048576},{id:`gemini-2.5-pro`,name:`Gemini 2.5 Pro`,contextWindow:1048576}]},{id:`mistral`,label:`Mistral AI`,group:`国际厂商`,baseUrl:`https://api.mistral.ai/v1`,api:`openai-completions`,models:[{id:`mistral-large-latest`,name:`Mistral Large 3`,contextWindow:262144},{id:`mistral-small-latest`,name:`Mistral Small 4`,contextWindow:256e3},{id:`codestral-latest`,name:`Codestral (代码)`,contextWindow:256e3},{id:`devstral-latest`,name:`Devstral 2 (代码Agent)`,contextWindow:256e3},{id:`devstral-2-latest`,name:`Devstral 2 123B (代码)`,contextWindow:256e3},{id:`magistral-medium-latest`,name:`Magistral Medium (推理)`,contextWindow:4e4}]},{id:`xai`,label:`xAI (Grok)`,group:`国际厂商`,baseUrl:`https://api.x.ai/v1`,api:`openai-completions`,models:[{id:`grok-4.20-0309-reasoning`,name:`Grok 4.20 (推理)`,contextWindow:2e6},{id:`grok-4-1-fast-reasoning`,name:`Grok 4 Fast (推理)`,contextWindow:2e6},{id:`grok-4-1-fast-non-reasoning`,name:`Grok 4 Fast`,contextWindow:2e6},{id:`grok-4`,name:`Grok 4`,contextWindow:256e3},{id:`grok-code-fast-1`,name:`Grok Code Fast 1 (代码)`,contextWindow:256e3},{id:`grok-3`,name:`Grok 3`,contextWindow:131072},{id:`grok-3-mini`,name:`Grok 3 Mini`,contextWindow:131072}]},{id:`cohere`,label:`Cohere`,group:`国际厂商`,baseUrl:`https://api.cohere.com/compatibility/v1`,api:`openai-completions`,models:[{id:`command-a-03-2025`,name:`Command A`,contextWindow:256e3},{id:`command-a-reasoning-08-2025`,name:`Command A (推理)`,contextWindow:256e3},{id:`command-a-vision-07-2025`,name:`Command A (视觉)`,contextWindow:128e3},{id:`command-r-plus-08-2024`,name:`Command R+`,contextWindow:128e3},{id:`command-r-08-2024`,name:`Command R`,contextWindow:128e3}]},{id:`groq`,label:`Groq`,group:`推理加速`,baseUrl:`https://api.groq.com/openai/v1`,api:`openai-completions`,models:[{id:`openai/gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`llama-3.3-70b-versatile`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`meta-llama/llama-4-scout-17b-16e-instruct`,name:`Llama 4 Scout 17B`,contextWindow:128e3},{id:`qwen/qwen3-32b`,name:`Qwen 3 32B`,contextWindow:128e3},{id:`llama-3.1-8b-instant`,name:`Llama 3.1 8B`,contextWindow:131072}]},{id:`fireworks`,label:`Fireworks AI`,group:`推理加速`,baseUrl:`https://api.fireworks.ai/inference/v1`,api:`openai-completions`,models:[{id:`accounts/fireworks/models/deepseek-v3`,name:`DeepSeek V3`,contextWindow:131072},{id:`accounts/fireworks/models/deepseek-v3p1`,name:`DeepSeek V3.1`,contextWindow:163840},{id:`accounts/fireworks/models/deepseek-v3p2`,name:`DeepSeek V3.2`,contextWindow:163840},{id:`accounts/fireworks/models/deepseek-r1`,name:`DeepSeek R1`,contextWindow:163840},{id:`accounts/fireworks/models/llama-v3p3-70b-instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`accounts/fireworks/models/qwen2.5-coder-32b-instruct`,name:`Qwen 2.5 Coder 32B`,contextWindow:32768}]},{id:`sambanova`,label:`SambaNova`,group:`推理加速`,baseUrl:`https://api.sambanova.ai/v1`,api:`openai-completions`,models:[{id:`gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`DeepSeek-R1-0528`,name:`DeepSeek R1`,contextWindow:65536},{id:`DeepSeek-V3-0324`,name:`DeepSeek V3`,contextWindow:65536},{id:`DeepSeek-V3.1`,name:`DeepSeek V3.1`,contextWindow:65536},{id:`DeepSeek-V3.2`,name:`DeepSeek V3.2`,contextWindow:65536},{id:`Meta-Llama-3.3-70B-Instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`Qwen3-235B`,name:`Qwen 3 235B`,contextWindow:65536}]},{id:`cerebras`,label:`Cerebras`,group:`推理加速`,baseUrl:`https://api.cerebras.ai/v1`,api:`openai-completions`,models:[{id:`gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`qwen-3-235b-a22b-instruct-2507`,name:`Qwen 3 235B (MoE)`,contextWindow:131072},{id:`zai-glm-4.7`,name:`Z.AI GLM 4.7`,contextWindow:131072},{id:`llama-4-scout-17b-16e-instruct`,name:`Llama 4 Scout 17B`,contextWindow:131072}]},{id:`hyperbolic`,label:`Hyperbolic`,group:`推理加速`,baseUrl:`https://api.hyperbolic.xyz/v1`,api:`openai-completions`,models:[{id:`gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-V3-0324`,name:`DeepSeek V3`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-R1-0528`,name:`DeepSeek R1`,contextWindow:131072},{id:`meta-llama/Llama-3.3-70B-Instruct`,name:`Llama 3.3 70B`,contextWindow:131072}]},{id:`openrouter`,label:`OpenRouter`,group:`聚合平台`,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,models:[{id:`openrouter/auto`,name:`Auto (自动选择)`,contextWindow:2e6},{id:`anthropic/claude-opus-4.6`,name:`Claude Opus 4.6`,contextWindow:1e6},{id:`openai/gpt-4.1`,name:`GPT-4.1`,contextWindow:1e6},{id:`google/gemini-2.5-flash`,name:`Gemini 2.5 Flash`,contextWindow:1048576},{id:`deepseek/deepseek-chat-v3.1`,name:`DeepSeek V3.1`,contextWindow:128e3},{id:`deepseek/deepseek-r1-0528`,name:`DeepSeek R1`,contextWindow:163840}]},{id:`together`,label:`Together AI`,group:`聚合平台`,baseUrl:`https://api.together.xyz/v1`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3.1`,name:`DeepSeek V3.1`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-R1`,name:`DeepSeek R1`,contextWindow:163840},{id:`moonshotai/Kimi-K2.5`,name:`Kimi K2.5`,contextWindow:262144},{id:`meta-llama/Llama-3.3-70B-Instruct-Turbo`,name:`Llama 3.3 70B Turbo`,contextWindow:131072},{id:`Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8`,name:`Qwen 3 Coder 480B`,contextWindow:131072}]},{id:`siliconflow`,label:`SiliconFlow`,group:`聚合平台`,baseUrl:`https://api.siliconflow.cn/v1`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3`,name:`DeepSeek V3`,contextWindow:128e3},{id:`deepseek-ai/DeepSeek-R1`,name:`DeepSeek R1`,contextWindow:128e3},{id:`Qwen/Qwen3-235B-A22B`,name:`Qwen3 235B (MoE)`,contextWindow:131072},{id:`moonshotai/Kimi-K2.5`,name:`Kimi K2.5`,contextWindow:262144},{id:`Pro/deepseek-ai/DeepSeek-V3`,name:`DeepSeek V3 (Pro)`,contextWindow:128e3}]},{id:`perplexity`,label:`Perplexity`,group:`聚合平台`,baseUrl:`https://api.perplexity.ai`,api:`openai-completions`,models:[{id:`sonar-pro`,name:`Sonar Pro (联网)`,contextWindow:2e5},{id:`sonar`,name:`Sonar (联网)`,contextWindow:127072},{id:`sonar-reasoning-pro`,name:`Sonar Reasoning Pro (联网推理)`,contextWindow:128e3},{id:`sonar-deep-research`,name:`Sonar Deep Research (深度研究)`,contextWindow:128e3}]},{id:`deepinfra`,label:`DeepInfra`,group:`聚合平台`,baseUrl:`https://api.deepinfra.com/v1/openai`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3-0324`,name:`DeepSeek V3`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-V3.1`,name:`DeepSeek V3.1`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-R1-0528-Turbo`,name:`DeepSeek R1 Turbo`,contextWindow:131072},{id:`meta-llama/Llama-3.3-70B-Instruct-Turbo`,name:`Llama 3.3 70B Turbo`,contextWindow:131072},{id:`Qwen/Qwen3-235B-A22B-Instruct-2507`,name:`Qwen 3 235B`,contextWindow:131072},{id:`Qwen/Qwen2.5-Coder-32B-Instruct`,name:`Qwen 2.5 Coder 32B`,contextWindow:32768}]},{id:`nvidia`,label:`NVIDIA NIM`,group:`聚合平台`,baseUrl:`https://integrate.api.nvidia.com/v1`,api:`openai-completions`,models:[{id:`meta/llama-3.3-70b-instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`deepseek-ai/deepseek-r1`,name:`DeepSeek R1`,contextWindow:131072}]},{id:`huggingface`,label:`Hugging Face`,group:`聚合平台`,baseUrl:`https://router.huggingface.co/v1`,api:`openai-completions`,models:[{id:`meta-llama/Llama-3.3-70B-Instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`Qwen/Qwen2.5-Coder-32B-Instruct`,name:`Qwen 2.5 Coder 32B`,contextWindow:32768}]},{id:`novita`,label:`Novita AI`,group:`聚合平台`,baseUrl:`https://api.novita.ai/v3/openai`,api:`openai-completions`,models:[{id:`deepseek/deepseek-chat-v3-0324`,name:`DeepSeek V3`,contextWindow:131072},{id:`deepseek/deepseek-r1`,name:`DeepSeek R1`,contextWindow:131072},{id:`meta-llama/llama-3.3-70b-instruct`,name:`Llama 3.3 70B`,contextWindow:131072}]},{id:`infini`,label:`Infini-AI`,group:`聚合平台`,baseUrl:`https://cloud.infini-ai.com/maas/v1`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3`,name:`DeepSeek V3`,contextWindow:128e3},{id:`deepseek-ai/DeepSeek-R1`,name:`DeepSeek R1`,contextWindow:128e3}]},{id:`venice`,label:`Venice AI`,group:`聚合平台`,baseUrl:`https://api.venice.ai/api/v1`,api:`openai-completions`,models:[{id:`kimi-k2-5`,name:`Kimi K2.5`,contextWindow:262144}]},{id:`vercel-ai-gateway`,label:`Vercel AI Gateway`,group:`聚合平台`,baseUrl:`https://ai-gateway.vercel.sh`,api:`anthropic-messages`,models:[{id:`anthropic/claude-opus-4.6`,name:`Claude Opus 4.6`,contextWindow:2e5}]},{id:`synthetic`,label:`Synthetic`,group:`聚合平台`,baseUrl:`https://api.synthetic.new/anthropic`,api:`anthropic-messages`,models:[{id:`hf:MiniMaxAI/MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800},{id:`hf:MiniMaxAI/MiniMax-M2.5`,name:`MiniMax M2.5`,contextWindow:204800}]},{id:`opencode`,label:`OpenCode Zen`,group:`聚合平台`,baseUrl:`https://opencode.ai/zen/v1`,api:`openai-completions`,models:[{id:`claude-opus-4-6`,name:`Claude Opus 4.6`,contextWindow:2e5}]},{id:`ollama`,label:`Ollama (本地)`,group:`本地部署`,baseUrl:`http://127.0.0.1:11434`,api:`ollama`,local:!0,models:[]},{id:`vllm`,label:`vLLM (本地)`,group:`本地部署`,baseUrl:`http://127.0.0.1:8000/v1`,api:`openai-completions`,local:!0,models:[]},{id:`sglang`,label:`SGLang (本地)`,group:`本地部署`,baseUrl:`http://127.0.0.1:30000/v1`,api:`openai-completions`,local:!0,models:[]},{id:`custom`,label:`Custom (OpenAI Compatible)`,group:`本地部署`,baseUrl:``,api:`openai-completions`,local:!0,models:[]}],d=e(t(),1),f=r(),p=[{id:`feishu`,labelKey:`configForm.channel.feishu`,fields:[],defaults:{connectionMode:`websocket`}},{id:`openclaw-weixin`,labelKey:`configForm.channel.openclaw-weixin`,fields:[],defaults:{}},{id:`telegram`,labelKey:`configForm.channel.telegram`,fields:[{key:`botToken`,label:`Bot Token`,type:`password`,placeholder:`From @BotFather`}]},{id:`discord`,labelKey:`configForm.channel.discord`,fields:[{key:`token`,label:`Bot Token`,type:`password`,placeholder:`From Discord Developer Portal`}]},{id:`slack`,labelKey:`configForm.channel.slack`,fields:[{key:`botToken`,label:`Bot Token (xoxb-...)`,type:`password`,placeholder:`xoxb-...`},{key:`appToken`,label:`App Token (xapp-...)`,type:`password`,placeholder:`xapp-...`}]},{id:`whatsapp`,labelKey:`configForm.channel.whatsapp`,fields:[],defaults:{}},{id:`msteams`,labelKey:`configForm.channel.msteams`,fields:[{key:`appId`,label:`App ID`,placeholder:`Azure App Registration ID`},{key:`appPassword`,label:`App Password`,type:`password`,placeholder:`Azure App Secret`},{key:`tenantId`,label:`Tenant ID`,placeholder:`Azure AD Tenant ID`}]},{id:`signal`,labelKey:`configForm.channel.signal`,fields:[{key:`account`,label:`Phone (E.164)`,placeholder:`+8613800138000`}]},{id:`line`,labelKey:`configForm.channel.line`,fields:[{key:`channelAccessToken`,label:`Channel Access Token`,type:`password`,placeholder:`From LINE Developers`},{key:`channelSecret`,label:`Channel Secret`,type:`password`,placeholder:`LINE Channel Secret`}]},{id:`googlechat`,labelKey:`configForm.channel.googlechat`,fields:[{key:`serviceAccountFile`,label:`Service Account JSON Path`,placeholder:`/path/to/service-account.json`}]}];function m(e,t,n){let r=structuredClone(e),i=t.split(`.`),a=r;for(let e=0;e<i.length-1;e++)a[i[e]]===void 0&&(a[i[e]]={}),a=a[i[e]];return a[i[i.length-1]]=n,r}var h=`w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200`,g=`w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200 appearance-none`;function _({label:e,hint:t,children:n}){return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-muted mb-1.5`,children:e}),n,t&&(0,f.jsx)(`p`,{className:`text-xs text-muted mt-1 opacity-60`,children:t})]})}function v({value:e,saved:t,onChange:r,placeholder:i,onPaste:a}){let{t:o}=n(`instance`),[s,c]=(0,d.useState)(!1);return t&&!s&&!e?(0,f.jsx)(`div`,{className:`relative`,children:(0,f.jsx)(`input`,{type:`password`,value:`••••••••••••••••••••••••••••••`,readOnly:!0,onFocus:()=>c(!0),onPaste:e=>{let t=e.clipboardData?.getData(`text`)??``;t&&(e.preventDefault(),c(!0),r(t),a?.(e))},className:`${h} cursor-text`,title:o(`config.clickToEdit`)})}):(0,f.jsx)(y,{value:e,onChange:r,onPaste:a,placeholder:i,type:`password`,mono:!0})}function y({value:e,onChange:t,placeholder:r,type:i=`text`,mono:a,onPaste:c}){let{t:l}=n(`common`),[u,p]=(0,d.useState)(!1),m=i===`password`;return(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(`input`,{type:m&&!u?`password`:`text`,value:e||``,onChange:e=>t(e.target.value),onPaste:c,placeholder:r,className:`${h} ${a?`font-mono text-[13px]`:``} ${m?`pr-9`:``}`}),m&&(0,f.jsx)(`button`,{type:`button`,onClick:()=>p(!u),"aria-label":l(`action.togglePassword`),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground`,children:u?(0,f.jsx)(s,{className:`w-3.5 h-3.5`}):(0,f.jsx)(o,{className:`w-3.5 h-3.5`})})]})}function b({value:e,onChange:t,children:n}){return(0,f.jsx)(`select`,{value:e||``,onChange:e=>t(e.target.value),className:g,children:n})}function x({checked:e,onChange:t,label:n}){return(0,f.jsxs)(`label`,{className:`flex items-center gap-2.5 cursor-pointer`,children:[(0,f.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>t(!e),className:`w-9 h-5 rounded-full relative transition-colors duration-200 ${e?`bg-[#0066FF]`:`bg-[var(--input-bg)]`}`,children:(0,f.jsx)(`div`,{className:`w-3.5 h-3.5 bg-white rounded-full absolute top-[3px] transition-transform duration-200 ${e?`left-[18px]`:`left-[3px]`}`})}),(0,f.jsx)(`span`,{className:`text-sm text-muted`,children:n})]})}function S({title:e,defaultOpen:t=!0,id:n,children:r}){let[i,o]=(0,d.useState)(t);return(0,f.jsxs)(`div`,{id:n,className:`bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden hover:border-[var(--border-hover)] transition-colors duration-200`,children:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>o(!i),className:`w-full px-4 py-3 flex items-center justify-between text-left hover:bg-[var(--card-hover)] transition-colors duration-150`,children:[(0,f.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),i?(0,f.jsx)(c,{className:`w-4 h-4 text-muted`}):(0,f.jsx)(a,{className:`w-4 h-4 text-muted`})]}),i&&(0,f.jsx)(`div`,{className:`px-4 pb-4 space-y-4 border-t border-[var(--border)] pt-4`,children:r})]})}function C(e){switch(e){case`ok`:return`valid`;case`auth_failed`:case`forbidden`:return`error`;case`unreachable`:case`timeout`:case`models_empty`:case`unknown_error`:return`warning`;default:return`warning`}}function w(e){let[t,n]=(0,d.useState)(`idle`),[r,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(null),u=(0,d.useRef)(null),f=(0,d.useRef)(e);return f.current=e,{state:t,models:r,message:o,rawStatus:c,validate:(0,d.useCallback)(e=>{if(u.current&&u.current.abort(),!e.trim()){n(`idle`),a([]),s(``),l(null);return}let{baseUrl:t,api:r,authHeader:o,providerId:c}=f.current;if(!t){n(`idle`);return}let d=new AbortController;u.current=d,n(`validating`),s(``),l(null),i({baseUrl:t,apiKey:e.trim(),api:r,authHeader:o,providerId:c},d.signal).then(e=>{d.signal.aborted||(n(C(e.status)),l(e.status),a(e.models||[]),s(e.message||``))}).catch(e=>{e.name===`AbortError`||d.signal.aborted||(n(`warning`),l(null),s(e.message||`Validation failed`))})},[]),reset:(0,d.useCallback)(()=>{u.current&&=(u.current.abort(),null),n(`idle`),a([]),s(``),l(null)},[])}}function T({state:e,rawStatus:t,message:n,modelCount:r,t:i}){if(e===`idle`)return null;if(e===`validating`)return(0,f.jsxs)(`p`,{className:`text-xs text-muted mt-1.5 flex items-center gap-1`,"aria-live":`polite`,children:[(0,f.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-muted border-t-transparent rounded-full animate-spin`}),i(`llm.validating`)]});if(e===`valid`)return(0,f.jsxs)(`p`,{className:`text-xs text-green-500 mt-1.5`,"aria-live":`polite`,children:[`✅ `,i(`llm.keyValid`,{count:r})]});if(e===`error`)return(0,f.jsxs)(`p`,{className:`text-xs text-red-400 mt-1.5`,"aria-live":`polite`,children:[`❌ `,i(t===`forbidden`?`llm.keyForbidden`:`llm.keyAuthFailed`)]});let a;switch(t){case`timeout`:a=i(`llm.keyTimeout`);break;case`unreachable`:a=i(`llm.keyUnreachable`);break;case`models_empty`:a=i(`llm.keyModelsEmpty`);break;default:a=n||i(`llm.keyWarning`)}return(0,f.jsxs)(`p`,{className:`text-xs text-yellow-500 mt-1.5`,"aria-live":`polite`,children:[`⚠️ `,a]})}function E({value:e,saved:t,onChange:r,baseUrl:a,api:o,authHeader:s,providerId:c,placeholder:l,onModels:u,onStateChange:p,selectedModelId:m}){let{t:h}=n(`common`),{state:g,models:_,message:y,rawStatus:b,validate:x,reset:S}=w({baseUrl:a,api:o,authHeader:s,providerId:c}),[C,E]=(0,d.useState)(`idle`),[D,O]=(0,d.useState)(``),k=(0,d.useRef)(null),A=(0,d.useRef)(e);A.current=e;let j=(0,d.useCallback)(e=>{E(`idle`),O(``),x(e)},[x]),M=(0,d.useCallback)(e=>{r(e),S(),E(`idle`),O(``)},[r,S]),N=(0,d.useCallback)(e=>{let t=e.clipboardData?.getData(`text`)??``;t.trim()&&setTimeout(()=>j(t.trim()),0)},[j]),P=(0,d.useCallback)(()=>{let e=A.current;e.trim()&&g===`idle`&&j(e)},[g,j]),F=(0,d.useCallback)(()=>{let e=A.current;e.trim()&&j(e)},[j]),I=(0,d.useCallback)(()=>{if(!m||!A.current.trim())return;k.current&&k.current.abort();let e=new AbortController;k.current=e,E(`testing`),O(``),i({baseUrl:a,apiKey:A.current.trim(),api:o,authHeader:s,providerId:c,mode:`completion`,modelId:m},e.signal).then(t=>{e.signal.aborted||(t.status===`ok`?(E(`ok`),O(h(`llm.deepValidateOk`))):(E(`error`),t.status===`quota_exceeded`?O(h(`llm.deepQuotaExceeded`)):t.status===`model_not_found`?O(h(`llm.deepModelNotFound`)):O(t.message||h(`llm.keyWarning`))))}).catch(t=>{t.name===`AbortError`||e.signal.aborted||(E(`error`),O(t.message||h(`llm.keyWarning`)))})},[a,o,s,c,m,h]);(0,d.useEffect)(()=>()=>{k.current?.abort()},[]);let L=(0,d.useRef)(u);L.current=u,(0,d.useEffect)(()=>{g===`valid`&&_.length>0&&L.current&&L.current(_)},[g,_]);let R=(0,d.useRef)(p);R.current=p,(0,d.useEffect)(()=>{R.current?.(g)},[g]);let z=g===`valid`;return(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,f.jsx)(`div`,{className:`flex-1`,onBlur:P,children:(0,f.jsx)(v,{value:e,saved:t,onChange:M,placeholder:l,onPaste:N})}),(0,f.jsx)(`button`,{type:`button`,onClick:F,disabled:g===`validating`||!e.trim(),className:`shrink-0 px-3 py-2 text-xs font-medium rounded-md border border-[var(--border)] bg-[var(--input-bg)] text-foreground hover:bg-[var(--hover-bg)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:h(g===`validating`?`llm.validating`:`llm.fetchModelsBtn`)})]}),(0,f.jsx)(T,{state:g,rawStatus:b,message:y,modelCount:_.length,t:h}),z&&(0,f.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:I,disabled:C===`testing`||!m,className:`shrink-0 px-2.5 py-1 text-[11px] font-medium rounded border border-[var(--border)] bg-[var(--input-bg)] text-foreground hover:bg-[var(--hover-bg)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:h(C===`testing`?`llm.deepValidating`:`llm.deepValidateBtn`)}),C===`idle`&&!m&&(0,f.jsx)(`span`,{className:`text-[11px] text-muted`,children:h(`llm.deepSelectModel`)}),C===`idle`&&m&&(0,f.jsx)(`span`,{className:`text-[11px] text-muted`,children:h(`llm.deepValidateHint`)}),C===`ok`&&(0,f.jsxs)(`span`,{className:`text-[11px] text-green-500`,children:[`✅ `,D]}),C===`error`&&(0,f.jsxs)(`span`,{className:`text-[11px] text-red-400`,children:[`❌ `,D]})]})]})}export{v as a,x as c,l as d,y as i,m as l,p as n,S as o,_ as r,b as s,E as t,u};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-Df8aUdv8.js";import{t as r}from"./vendor-react-0L0rjmYG.js";import{It as i}from"./api-C70Gt678.js";import{c as a,f as o,p as s,s as c}from"./index-Bs6DSbiR.js";var l=[{providerId:`zhipu`,label:`GLM`,purchaseUrl:`https://bigmodel.cn/glm-coding`},{providerId:`moonshot`,label:`Kimi`,purchaseUrl:`https://www.kimi.com/membership/pricing?from=kfc_membership_topbar`},{providerId:`deepseek`,label:`DeepSeek`,purchaseUrl:`https://platform.deepseek.com/sign_in`},{providerId:`minimax`,label:`MiniMax`,purchaseUrl:`https://platform.minimaxi.com/subscribe/token-plan`},{providerId:`stepfun`,label:`阶跃星辰`,purchaseUrl:`https://platform.stepfun.com/step-plan`},{providerId:`xiaomi`,label:`小米Mimo`,purchaseUrl:`https://platform.xiaomimimo.com/token-plan`}],u=[{id:`minimax`,label:`MiniMax (国内)`,group:`国内厂商`,baseUrl:`https://api.minimaxi.com/v1`,api:`openai-completions`,models:[{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800}]},{id:`minimax-intl`,label:`MiniMax (国际)`,group:`国际厂商`,baseUrl:`https://api.minimax.io/anthropic`,api:`anthropic-messages`,authHeader:!0,models:[{id:`MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800},{id:`MiniMax-M2.7-highspeed`,name:`MiniMax M2.7 Highspeed`,contextWindow:204800}]},{id:`moonshot`,label:`Kimi (Moonshot)`,group:`国内厂商`,baseUrl:`https://api.moonshot.cn/v1`,api:`openai-completions`,models:[{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:256e3},{id:`moonshot-v1-128k`,name:`Moonshot V1 128K`,contextWindow:128e3},{id:`moonshot-v1-32k`,name:`Moonshot V1 32K`,contextWindow:32e3},{id:`moonshot-v1-8k`,name:`Moonshot V1 8K`,contextWindow:8e3}]},{id:`moonshot-coding`,label:`Kimi (编码计划)`,group:`国内厂商`,baseUrl:`https://api.moonshot.cn/anthropic`,api:`anthropic-messages`,authHeader:!0,models:[{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:256e3},{id:`kimi-k2-thinking-turbo`,name:`Kimi K2 Thinking Turbo`,contextWindow:256e3},{id:`kimi-k2-thinking`,name:`Kimi K2 Thinking`,contextWindow:256e3},{id:`kimi-k2-0905-preview`,name:`Kimi K2 0905 Preview`,contextWindow:256e3},{id:`kimi-k2-turbo-preview`,name:`Kimi K2 Turbo Preview`,contextWindow:256e3}]},{id:`moonshot-intl`,label:`Kimi (国际)`,group:`国际厂商`,baseUrl:`https://api.moonshot.ai/v1`,api:`openai-completions`,models:[{id:`kimi-k2.5`,name:`Kimi K2.5`,contextWindow:256e3},{id:`moonshot-v1-128k`,name:`Moonshot V1 128K`,contextWindow:128e3}]},{id:`zhipu`,label:`智谱AI (GLM)`,group:`国内厂商`,baseUrl:`https://open.bigmodel.cn/api/paas/v4`,api:`openai-completions`,models:[{id:`glm-5.1`,name:`GLM-5.1`,contextWindow:2e5},{id:`glm-5`,name:`GLM-5`,contextWindow:2e5},{id:`glm-5-turbo`,name:`GLM-5 Turbo`,contextWindow:2e5},{id:`glm-4.7`,name:`GLM-4.7`,contextWindow:2e5},{id:`glm-4.7-flashx`,name:`GLM-4.7 FlashX`,contextWindow:2e5},{id:`glm-4.7-flash`,name:`GLM-4.7 Flash (免费)`,contextWindow:2e5},{id:`glm-4-plus`,name:`GLM-4 Plus`,contextWindow:128e3},{id:`glm-4-long`,name:`GLM-4 Long`,contextWindow:1e6}]},{id:`zhipu-intl`,label:`Z.AI (GLM)`,group:`国际厂商`,baseUrl:`https://api.z.ai/api/paas/v4`,api:`openai-completions`,models:[{id:`glm-5.1`,name:`GLM-5.1`,contextWindow:2e5},{id:`glm-5`,name:`GLM-5`,contextWindow:2e5},{id:`glm-5-turbo`,name:`GLM-5 Turbo`,contextWindow:2e5},{id:`glm-4.7`,name:`GLM-4.7`,contextWindow:2e5},{id:`glm-4.7-flash`,name:`GLM-4.7 Flash`,contextWindow:2e5},{id:`glm-4-plus`,name:`GLM-4 Plus`,contextWindow:128e3}]},{id:`byteplus`,label:`火山引擎国际版 (Doubao)`,group:`国际厂商`,baseUrl:`https://ark.ap-southeast.bytepluses.com/api/v3`,api:`openai-completions`,models:[{id:`seed-2-0-lite-260228`,name:`Seed 2.0 Lite`,contextWindow:256e3},{id:`seed-2-0-mini-260215`,name:`Seed 2.0 Mini`,contextWindow:256e3},{id:`seed-1-8-251228`,name:`Seed 1.8`,contextWindow:256e3}]},{id:`deepseek`,label:`DeepSeek`,group:`国内厂商`,baseUrl:`https://api.deepseek.com/v1`,api:`openai-completions`,models:[{id:`deepseek-chat`,name:`DeepSeek V3.2`,contextWindow:128e3},{id:`deepseek-reasoner`,name:`DeepSeek V3.2 (推理)`,contextWindow:128e3}]},{id:`dashscope`,label:`阿里云百炼`,group:`国内厂商`,baseUrl:`https://dashscope.aliyuncs.com/compatible-mode/v1`,api:`openai-completions`,models:[{id:`qwen3.5-plus`,name:`Qwen 3.5 Plus`,contextWindow:1e6},{id:`qwen3.5-flash`,name:`Qwen 3.5 Flash`,contextWindow:1e6},{id:`qwen3-max`,name:`Qwen 3 Max`,contextWindow:262144},{id:`qwen3-coder-plus`,name:`Qwen 3 Coder Plus`,contextWindow:1e6},{id:`qwen3-coder-next`,name:`Qwen 3 Coder Next`,contextWindow:262144},{id:`qwen3-coder-flash`,name:`Qwen 3 Coder Flash`,contextWindow:1e6},{id:`qwen-plus`,name:`Qwen Plus`,contextWindow:1e6},{id:`qwen-long`,name:`Qwen Long (10M)`,contextWindow:1e7}]},{id:`modelstudio`,label:`阿里云百炼 (国际/Coding)`,group:`国内厂商`,baseUrl:`https://coding-intl.dashscope.aliyuncs.com/v1`,api:`openai-completions`,models:[{id:`qwen3.5-plus`,name:`Qwen 3.5 Plus`,contextWindow:1e6},{id:`qwen3-coder-plus`,name:`Qwen 3 Coder Plus`,contextWindow:1e6},{id:`qwen3-coder-next`,name:`Qwen 3 Coder Next`,contextWindow:262144}]},{id:`volcengine`,label:`火山引擎 (豆包)`,group:`国内厂商`,baseUrl:`https://ark.cn-beijing.volces.com/api/v3`,api:`openai-completions`,models:[{id:`doubao-seed-2-0-pro-260215`,name:`Doubao Seed 2.0 Pro (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-2-0-lite-260228`,name:`Doubao Seed 2.0 Lite (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-2-0-code-preview-260215`,name:`Doubao Seed 2.0 Code (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-2-0-mini-260215`,name:`Doubao Seed 2.0 Mini (需替换为接入点ID)`,contextWindow:256e3},{id:`doubao-seed-1-8-251228`,name:`Doubao Seed 1.8 (需替换为接入点ID)`,contextWindow:256e3}]},{id:`qianfan`,label:`百度千帆 (ERNIE)`,group:`国内厂商`,baseUrl:`https://qianfan.baidubce.com/v2`,api:`openai-completions`,models:[{id:`ernie-5.0`,name:`ERNIE 5.0`,contextWindow:128e3},{id:`ernie-5.0-thinking-preview`,name:`ERNIE 5.0 Thinking`,contextWindow:128e3},{id:`ernie-4.5-turbo-128k`,name:`ERNIE 4.5 Turbo (MoE)`,contextWindow:128e3},{id:`ernie-x1.1`,name:`ERNIE X1.1 (推理)`,contextWindow:64e3},{id:`deepseek-v3.2`,name:`DeepSeek V3.2 (千帆)`,contextWindow:128e3}]},{id:`tencent`,label:`腾讯混元`,group:`国内厂商`,baseUrl:`https://api.hunyuan.cloud.tencent.com/v1`,api:`openai-completions`,models:[{id:`hunyuan-2.0-thinking-20251109`,name:`Hunyuan 2.0 Think (推理)`,contextWindow:128e3},{id:`hunyuan-2.0-instruct-20251111`,name:`Hunyuan 2.0 Instruct`,contextWindow:128e3},{id:`hunyuan-t1-latest`,name:`Hunyuan T1 (推理)`,contextWindow:32e3},{id:`hunyuan-turbos-latest`,name:`Hunyuan TurboS`,contextWindow:32e3},{id:`hunyuan-a13b`,name:`Hunyuan A13B (MoE)`,contextWindow:224e3},{id:`hunyuan-lite`,name:`Hunyuan Lite (免费)`,contextWindow:25e4}]},{id:`xiaomi`,label:`MiMo (小米)`,group:`国内厂商`,baseUrl:`https://api.xiaomimimo.com/v1`,api:`openai-completions`,models:[{id:`mimo-v2-pro`,name:`MiMo V2 Pro (推理)`,contextWindow:1048576},{id:`mimo-v2-omni`,name:`MiMo V2 Omni (多模)`,contextWindow:262144},{id:`mimo-v2-flash`,name:`MiMo V2 Flash`,contextWindow:262144}]},{id:`spark`,label:`讯飞星火`,group:`国内厂商`,baseUrl:`https://spark-api-open.xf-yun.com/v1`,api:`openai-completions`,models:[{id:`spark-x`,name:`Spark X1.5 (推理)`,contextWindow:32768},{id:`4.0Ultra`,name:`Spark 4.0 Ultra`,contextWindow:32768},{id:`pro-128k`,name:`Spark Pro 128K`,contextWindow:131072},{id:`lite`,name:`Spark Lite (免费)`,contextWindow:8192}]},{id:`stepfun`,label:`阶跃星辰`,group:`国内厂商`,baseUrl:`https://api.stepfun.com/v1`,api:`openai-completions`,models:[{id:`step-3.5-flash`,name:`Step 3.5 Flash (推理)`,contextWindow:262144},{id:`step-3`,name:`Step 3 (多模推理)`,contextWindow:65536},{id:`step-2-mini`,name:`Step 2 Mini`,contextWindow:32e3},{id:`step-1o-turbo-vision`,name:`Step 1o Turbo Vision`,contextWindow:32e3},{id:`step-1-256k`,name:`Step 1 256K`,contextWindow:256e3}]},{id:`openai`,label:`OpenAI`,group:`国际厂商`,baseUrl:`https://api.openai.com/v1`,api:`openai-completions`,models:[{id:`gpt-5.4`,name:`GPT-5.4`,contextWindow:105e4},{id:`gpt-5.4-pro`,name:`GPT-5.4 Pro`,contextWindow:105e4},{id:`gpt-5.4-mini`,name:`GPT-5.4 Mini`,contextWindow:4e5},{id:`gpt-5.4-nano`,name:`GPT-5.4 Nano`,contextWindow:4e5},{id:`o3-pro`,name:`o3-pro (推理)`,contextWindow:2e5},{id:`o3`,name:`o3 (推理)`,contextWindow:2e5},{id:`o4-mini`,name:`o4-mini (推理)`,contextWindow:2e5},{id:`gpt-4.1`,name:`GPT-4.1`,contextWindow:1e6},{id:`gpt-4.1-mini`,name:`GPT-4.1 Mini`,contextWindow:1e6}]},{id:`anthropic`,label:`Anthropic (Claude)`,group:`国际厂商`,baseUrl:`https://api.anthropic.com`,api:`anthropic-messages`,models:[{id:`claude-opus-4-6`,name:`Claude Opus 4.6`,contextWindow:1e6},{id:`claude-sonnet-4-6`,name:`Claude Sonnet 4.6`,contextWindow:1e6},{id:`claude-haiku-4-5`,name:`Claude Haiku 4.5`,contextWindow:2e5}]},{id:`google`,label:`Google Gemini`,group:`国际厂商`,baseUrl:`https://generativelanguage.googleapis.com`,api:`google-generative-ai`,models:[{id:`gemini-3.1-pro-preview`,name:`Gemini 3.1 Pro (Preview)`,contextWindow:1048576},{id:`gemini-3-flash-preview`,name:`Gemini 3 Flash (Preview)`,contextWindow:1048576},{id:`gemini-3.1-flash-lite-preview`,name:`Gemini 3.1 Flash Lite (Preview)`,contextWindow:1048576},{id:`gemini-2.5-flash`,name:`Gemini 2.5 Flash`,contextWindow:1048576},{id:`gemini-2.5-pro`,name:`Gemini 2.5 Pro`,contextWindow:1048576}]},{id:`mistral`,label:`Mistral AI`,group:`国际厂商`,baseUrl:`https://api.mistral.ai/v1`,api:`openai-completions`,models:[{id:`mistral-large-latest`,name:`Mistral Large 3`,contextWindow:262144},{id:`mistral-small-latest`,name:`Mistral Small 4`,contextWindow:256e3},{id:`codestral-latest`,name:`Codestral (代码)`,contextWindow:256e3},{id:`devstral-latest`,name:`Devstral 2 (代码Agent)`,contextWindow:256e3},{id:`devstral-2-latest`,name:`Devstral 2 123B (代码)`,contextWindow:256e3},{id:`magistral-medium-latest`,name:`Magistral Medium (推理)`,contextWindow:4e4}]},{id:`xai`,label:`xAI (Grok)`,group:`国际厂商`,baseUrl:`https://api.x.ai/v1`,api:`openai-completions`,models:[{id:`grok-4.20-0309-reasoning`,name:`Grok 4.20 (推理)`,contextWindow:2e6},{id:`grok-4-1-fast-reasoning`,name:`Grok 4 Fast (推理)`,contextWindow:2e6},{id:`grok-4-1-fast-non-reasoning`,name:`Grok 4 Fast`,contextWindow:2e6},{id:`grok-4`,name:`Grok 4`,contextWindow:256e3},{id:`grok-code-fast-1`,name:`Grok Code Fast 1 (代码)`,contextWindow:256e3},{id:`grok-3`,name:`Grok 3`,contextWindow:131072},{id:`grok-3-mini`,name:`Grok 3 Mini`,contextWindow:131072}]},{id:`cohere`,label:`Cohere`,group:`国际厂商`,baseUrl:`https://api.cohere.com/compatibility/v1`,api:`openai-completions`,models:[{id:`command-a-03-2025`,name:`Command A`,contextWindow:256e3},{id:`command-a-reasoning-08-2025`,name:`Command A (推理)`,contextWindow:256e3},{id:`command-a-vision-07-2025`,name:`Command A (视觉)`,contextWindow:128e3},{id:`command-r-plus-08-2024`,name:`Command R+`,contextWindow:128e3},{id:`command-r-08-2024`,name:`Command R`,contextWindow:128e3}]},{id:`groq`,label:`Groq`,group:`推理加速`,baseUrl:`https://api.groq.com/openai/v1`,api:`openai-completions`,models:[{id:`openai/gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`llama-3.3-70b-versatile`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`meta-llama/llama-4-scout-17b-16e-instruct`,name:`Llama 4 Scout 17B`,contextWindow:128e3},{id:`qwen/qwen3-32b`,name:`Qwen 3 32B`,contextWindow:128e3},{id:`llama-3.1-8b-instant`,name:`Llama 3.1 8B`,contextWindow:131072}]},{id:`fireworks`,label:`Fireworks AI`,group:`推理加速`,baseUrl:`https://api.fireworks.ai/inference/v1`,api:`openai-completions`,models:[{id:`accounts/fireworks/models/deepseek-v3`,name:`DeepSeek V3`,contextWindow:131072},{id:`accounts/fireworks/models/deepseek-v3p1`,name:`DeepSeek V3.1`,contextWindow:163840},{id:`accounts/fireworks/models/deepseek-v3p2`,name:`DeepSeek V3.2`,contextWindow:163840},{id:`accounts/fireworks/models/deepseek-r1`,name:`DeepSeek R1`,contextWindow:163840},{id:`accounts/fireworks/models/llama-v3p3-70b-instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`accounts/fireworks/models/qwen2.5-coder-32b-instruct`,name:`Qwen 2.5 Coder 32B`,contextWindow:32768}]},{id:`sambanova`,label:`SambaNova`,group:`推理加速`,baseUrl:`https://api.sambanova.ai/v1`,api:`openai-completions`,models:[{id:`gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`DeepSeek-R1-0528`,name:`DeepSeek R1`,contextWindow:65536},{id:`DeepSeek-V3-0324`,name:`DeepSeek V3`,contextWindow:65536},{id:`DeepSeek-V3.1`,name:`DeepSeek V3.1`,contextWindow:65536},{id:`DeepSeek-V3.2`,name:`DeepSeek V3.2`,contextWindow:65536},{id:`Meta-Llama-3.3-70B-Instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`Qwen3-235B`,name:`Qwen 3 235B`,contextWindow:65536}]},{id:`cerebras`,label:`Cerebras`,group:`推理加速`,baseUrl:`https://api.cerebras.ai/v1`,api:`openai-completions`,models:[{id:`gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`qwen-3-235b-a22b-instruct-2507`,name:`Qwen 3 235B (MoE)`,contextWindow:131072},{id:`zai-glm-4.7`,name:`Z.AI GLM 4.7`,contextWindow:131072},{id:`llama-4-scout-17b-16e-instruct`,name:`Llama 4 Scout 17B`,contextWindow:131072}]},{id:`hyperbolic`,label:`Hyperbolic`,group:`推理加速`,baseUrl:`https://api.hyperbolic.xyz/v1`,api:`openai-completions`,models:[{id:`gpt-oss-120b`,name:`GPT-OSS 120B`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-V3-0324`,name:`DeepSeek V3`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-R1-0528`,name:`DeepSeek R1`,contextWindow:131072},{id:`meta-llama/Llama-3.3-70B-Instruct`,name:`Llama 3.3 70B`,contextWindow:131072}]},{id:`openrouter`,label:`OpenRouter`,group:`聚合平台`,baseUrl:`https://openrouter.ai/api/v1`,api:`openai-completions`,models:[{id:`openrouter/auto`,name:`Auto (自动选择)`,contextWindow:2e6},{id:`anthropic/claude-opus-4.6`,name:`Claude Opus 4.6`,contextWindow:1e6},{id:`openai/gpt-4.1`,name:`GPT-4.1`,contextWindow:1e6},{id:`google/gemini-2.5-flash`,name:`Gemini 2.5 Flash`,contextWindow:1048576},{id:`deepseek/deepseek-chat-v3.1`,name:`DeepSeek V3.1`,contextWindow:128e3},{id:`deepseek/deepseek-r1-0528`,name:`DeepSeek R1`,contextWindow:163840}]},{id:`together`,label:`Together AI`,group:`聚合平台`,baseUrl:`https://api.together.xyz/v1`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3.1`,name:`DeepSeek V3.1`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-R1`,name:`DeepSeek R1`,contextWindow:163840},{id:`moonshotai/Kimi-K2.5`,name:`Kimi K2.5`,contextWindow:262144},{id:`meta-llama/Llama-3.3-70B-Instruct-Turbo`,name:`Llama 3.3 70B Turbo`,contextWindow:131072},{id:`Qwen/Qwen3-Coder-480B-A35B-Instruct-FP8`,name:`Qwen 3 Coder 480B`,contextWindow:131072}]},{id:`siliconflow`,label:`SiliconFlow`,group:`聚合平台`,baseUrl:`https://api.siliconflow.cn/v1`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3`,name:`DeepSeek V3`,contextWindow:128e3},{id:`deepseek-ai/DeepSeek-R1`,name:`DeepSeek R1`,contextWindow:128e3},{id:`Qwen/Qwen3-235B-A22B`,name:`Qwen3 235B (MoE)`,contextWindow:131072},{id:`moonshotai/Kimi-K2.5`,name:`Kimi K2.5`,contextWindow:262144},{id:`Pro/deepseek-ai/DeepSeek-V3`,name:`DeepSeek V3 (Pro)`,contextWindow:128e3}]},{id:`perplexity`,label:`Perplexity`,group:`聚合平台`,baseUrl:`https://api.perplexity.ai`,api:`openai-completions`,models:[{id:`sonar-pro`,name:`Sonar Pro (联网)`,contextWindow:2e5},{id:`sonar`,name:`Sonar (联网)`,contextWindow:127072},{id:`sonar-reasoning-pro`,name:`Sonar Reasoning Pro (联网推理)`,contextWindow:128e3},{id:`sonar-deep-research`,name:`Sonar Deep Research (深度研究)`,contextWindow:128e3}]},{id:`deepinfra`,label:`DeepInfra`,group:`聚合平台`,baseUrl:`https://api.deepinfra.com/v1/openai`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3-0324`,name:`DeepSeek V3`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-V3.1`,name:`DeepSeek V3.1`,contextWindow:131072},{id:`deepseek-ai/DeepSeek-R1-0528-Turbo`,name:`DeepSeek R1 Turbo`,contextWindow:131072},{id:`meta-llama/Llama-3.3-70B-Instruct-Turbo`,name:`Llama 3.3 70B Turbo`,contextWindow:131072},{id:`Qwen/Qwen3-235B-A22B-Instruct-2507`,name:`Qwen 3 235B`,contextWindow:131072},{id:`Qwen/Qwen2.5-Coder-32B-Instruct`,name:`Qwen 2.5 Coder 32B`,contextWindow:32768}]},{id:`nvidia`,label:`NVIDIA NIM`,group:`聚合平台`,baseUrl:`https://integrate.api.nvidia.com/v1`,api:`openai-completions`,models:[{id:`meta/llama-3.3-70b-instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`deepseek-ai/deepseek-r1`,name:`DeepSeek R1`,contextWindow:131072}]},{id:`huggingface`,label:`Hugging Face`,group:`聚合平台`,baseUrl:`https://router.huggingface.co/v1`,api:`openai-completions`,models:[{id:`meta-llama/Llama-3.3-70B-Instruct`,name:`Llama 3.3 70B`,contextWindow:131072},{id:`Qwen/Qwen2.5-Coder-32B-Instruct`,name:`Qwen 2.5 Coder 32B`,contextWindow:32768}]},{id:`novita`,label:`Novita AI`,group:`聚合平台`,baseUrl:`https://api.novita.ai/v3/openai`,api:`openai-completions`,models:[{id:`deepseek/deepseek-chat-v3-0324`,name:`DeepSeek V3`,contextWindow:131072},{id:`deepseek/deepseek-r1`,name:`DeepSeek R1`,contextWindow:131072},{id:`meta-llama/llama-3.3-70b-instruct`,name:`Llama 3.3 70B`,contextWindow:131072}]},{id:`infini`,label:`Infini-AI`,group:`聚合平台`,baseUrl:`https://cloud.infini-ai.com/maas/v1`,api:`openai-completions`,models:[{id:`deepseek-ai/DeepSeek-V3`,name:`DeepSeek V3`,contextWindow:128e3},{id:`deepseek-ai/DeepSeek-R1`,name:`DeepSeek R1`,contextWindow:128e3}]},{id:`venice`,label:`Venice AI`,group:`聚合平台`,baseUrl:`https://api.venice.ai/api/v1`,api:`openai-completions`,models:[{id:`kimi-k2-5`,name:`Kimi K2.5`,contextWindow:262144}]},{id:`vercel-ai-gateway`,label:`Vercel AI Gateway`,group:`聚合平台`,baseUrl:`https://ai-gateway.vercel.sh`,api:`anthropic-messages`,models:[{id:`anthropic/claude-opus-4.6`,name:`Claude Opus 4.6`,contextWindow:2e5}]},{id:`synthetic`,label:`Synthetic`,group:`聚合平台`,baseUrl:`https://api.synthetic.new/anthropic`,api:`anthropic-messages`,models:[{id:`hf:MiniMaxAI/MiniMax-M2.7`,name:`MiniMax M2.7`,contextWindow:204800},{id:`hf:MiniMaxAI/MiniMax-M2.5`,name:`MiniMax M2.5`,contextWindow:204800}]},{id:`opencode`,label:`OpenCode Zen`,group:`聚合平台`,baseUrl:`https://opencode.ai/zen/v1`,api:`openai-completions`,models:[{id:`claude-opus-4-6`,name:`Claude Opus 4.6`,contextWindow:2e5}]},{id:`ollama`,label:`Ollama (本地)`,group:`本地部署`,baseUrl:`http://127.0.0.1:11434`,api:`ollama`,local:!0,models:[]},{id:`vllm`,label:`vLLM (本地)`,group:`本地部署`,baseUrl:`http://127.0.0.1:8000/v1`,api:`openai-completions`,local:!0,models:[]},{id:`sglang`,label:`SGLang (本地)`,group:`本地部署`,baseUrl:`http://127.0.0.1:30000/v1`,api:`openai-completions`,local:!0,models:[]},{id:`custom`,label:`Custom (OpenAI Compatible)`,group:`本地部署`,baseUrl:``,api:`openai-completions`,local:!0,models:[]}],d=e(t(),1),f=r(),p=[{id:`feishu`,labelKey:`configForm.channel.feishu`,fields:[],defaults:{connectionMode:`websocket`}},{id:`openclaw-weixin`,labelKey:`configForm.channel.openclaw-weixin`,fields:[],defaults:{}},{id:`telegram`,labelKey:`configForm.channel.telegram`,fields:[{key:`botToken`,label:`Bot Token`,type:`password`,placeholder:`From @BotFather`}]},{id:`discord`,labelKey:`configForm.channel.discord`,fields:[{key:`token`,label:`Bot Token`,type:`password`,placeholder:`From Discord Developer Portal`}]},{id:`slack`,labelKey:`configForm.channel.slack`,fields:[{key:`botToken`,label:`Bot Token (xoxb-...)`,type:`password`,placeholder:`xoxb-...`},{key:`appToken`,label:`App Token (xapp-...)`,type:`password`,placeholder:`xapp-...`}]},{id:`whatsapp`,labelKey:`configForm.channel.whatsapp`,fields:[],defaults:{}},{id:`msteams`,labelKey:`configForm.channel.msteams`,fields:[{key:`appId`,label:`App ID`,placeholder:`Azure App Registration ID`},{key:`appPassword`,label:`App Password`,type:`password`,placeholder:`Azure App Secret`},{key:`tenantId`,label:`Tenant ID`,placeholder:`Azure AD Tenant ID`}]},{id:`signal`,labelKey:`configForm.channel.signal`,fields:[{key:`account`,label:`Phone (E.164)`,placeholder:`+8613800138000`}]},{id:`line`,labelKey:`configForm.channel.line`,fields:[{key:`channelAccessToken`,label:`Channel Access Token`,type:`password`,placeholder:`From LINE Developers`},{key:`channelSecret`,label:`Channel Secret`,type:`password`,placeholder:`LINE Channel Secret`}]},{id:`googlechat`,labelKey:`configForm.channel.googlechat`,fields:[{key:`serviceAccountFile`,label:`Service Account JSON Path`,placeholder:`/path/to/service-account.json`}]}];function m(e,t,n){let r=structuredClone(e),i=t.split(`.`),a=r;for(let e=0;e<i.length-1;e++)a[i[e]]===void 0&&(a[i[e]]={}),a=a[i[e]];return a[i[i.length-1]]=n,r}var h=`w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200`,g=`w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200 appearance-none`;function _({label:e,hint:t,children:n}){return(0,f.jsxs)(`div`,{children:[(0,f.jsx)(`label`,{className:`block text-sm font-medium text-muted mb-1.5`,children:e}),n,t&&(0,f.jsx)(`p`,{className:`text-xs text-muted mt-1 opacity-60`,children:t})]})}function v({value:e,saved:t,onChange:r,placeholder:i,onPaste:a}){let{t:o}=n(`instance`),[s,c]=(0,d.useState)(!1);return t&&!s&&!e?(0,f.jsx)(`div`,{className:`relative`,children:(0,f.jsx)(`input`,{type:`password`,value:`••••••••••••••••••••••••••••••`,readOnly:!0,onFocus:()=>c(!0),onPaste:e=>{let t=e.clipboardData?.getData(`text`)??``;t&&(e.preventDefault(),c(!0),r(t),a?.(e))},className:`${h} cursor-text`,title:o(`config.clickToEdit`)})}):(0,f.jsx)(y,{value:e,onChange:r,onPaste:a,placeholder:i,type:`password`,mono:!0})}function y({value:e,onChange:t,placeholder:r,type:i=`text`,mono:a,onPaste:c}){let{t:l}=n(`common`),[u,p]=(0,d.useState)(!1),m=i===`password`;return(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(`input`,{type:m&&!u?`password`:`text`,value:e||``,onChange:e=>t(e.target.value),onPaste:c,placeholder:r,className:`${h} ${a?`font-mono text-[13px]`:``} ${m?`pr-9`:``}`}),m&&(0,f.jsx)(`button`,{type:`button`,onClick:()=>p(!u),"aria-label":l(`action.togglePassword`),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground`,children:u?(0,f.jsx)(s,{className:`w-3.5 h-3.5`}):(0,f.jsx)(o,{className:`w-3.5 h-3.5`})})]})}function b({value:e,onChange:t,children:n}){return(0,f.jsx)(`select`,{value:e||``,onChange:e=>t(e.target.value),className:g,children:n})}function x({checked:e,onChange:t,label:n}){return(0,f.jsxs)(`label`,{className:`flex items-center gap-2.5 cursor-pointer`,children:[(0,f.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>t(!e),className:`w-9 h-5 rounded-full relative transition-colors duration-200 ${e?`bg-[#0066FF]`:`bg-[var(--input-bg)]`}`,children:(0,f.jsx)(`div`,{className:`w-3.5 h-3.5 bg-white rounded-full absolute top-[3px] transition-transform duration-200 ${e?`left-[18px]`:`left-[3px]`}`})}),(0,f.jsx)(`span`,{className:`text-sm text-muted`,children:n})]})}function S({title:e,defaultOpen:t=!0,id:n,children:r}){let[i,o]=(0,d.useState)(t);return(0,f.jsxs)(`div`,{id:n,className:`bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden hover:border-[var(--border-hover)] transition-colors duration-200`,children:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>o(!i),className:`w-full px-4 py-3 flex items-center justify-between text-left hover:bg-[var(--card-hover)] transition-colors duration-150`,children:[(0,f.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e}),i?(0,f.jsx)(c,{className:`w-4 h-4 text-muted`}):(0,f.jsx)(a,{className:`w-4 h-4 text-muted`})]}),i&&(0,f.jsx)(`div`,{className:`px-4 pb-4 space-y-4 border-t border-[var(--border)] pt-4`,children:r})]})}function C(e){switch(e){case`ok`:return`valid`;case`auth_failed`:case`forbidden`:return`error`;case`unreachable`:case`timeout`:case`models_empty`:case`unknown_error`:return`warning`;default:return`warning`}}function w(e){let[t,n]=(0,d.useState)(`idle`),[r,a]=(0,d.useState)([]),[o,s]=(0,d.useState)(``),[c,l]=(0,d.useState)(null),u=(0,d.useRef)(null),f=(0,d.useRef)(e);return f.current=e,{state:t,models:r,message:o,rawStatus:c,validate:(0,d.useCallback)(e=>{if(u.current&&u.current.abort(),!e.trim()){n(`idle`),a([]),s(``),l(null);return}let{baseUrl:t,api:r,authHeader:o,providerId:c}=f.current;if(!t){n(`idle`);return}let d=new AbortController;u.current=d,n(`validating`),s(``),l(null),i({baseUrl:t,apiKey:e.trim(),api:r,authHeader:o,providerId:c},d.signal).then(e=>{if(d.signal.aborted)return;let t=C(e.status);n(t),l(e.status),a(e.models||[]),s(e.message||``)}).catch(e=>{e.name===`AbortError`||d.signal.aborted||(n(`warning`),l(null),s(e.message||`Validation failed`))})},[]),reset:(0,d.useCallback)(()=>{u.current&&=(u.current.abort(),null),n(`idle`),a([]),s(``),l(null)},[])}}function T({state:e,rawStatus:t,message:n,modelCount:r,t:i}){if(e===`idle`)return null;if(e===`validating`)return(0,f.jsxs)(`p`,{className:`text-xs text-muted mt-1.5 flex items-center gap-1`,"aria-live":`polite`,children:[(0,f.jsx)(`span`,{className:`inline-block w-3 h-3 border-2 border-muted border-t-transparent rounded-full animate-spin`}),i(`llm.validating`)]});if(e===`valid`)return(0,f.jsxs)(`p`,{className:`text-xs text-green-500 mt-1.5`,"aria-live":`polite`,children:[`✅ `,i(`llm.keyValid`,{count:r})]});if(e===`error`)return(0,f.jsxs)(`p`,{className:`text-xs text-red-400 mt-1.5`,"aria-live":`polite`,children:[`❌ `,i(t===`forbidden`?`llm.keyForbidden`:`llm.keyAuthFailed`)]});let a;switch(t){case`timeout`:a=i(`llm.keyTimeout`);break;case`unreachable`:a=i(`llm.keyUnreachable`);break;case`models_empty`:a=i(`llm.keyModelsEmpty`);break;default:a=n||i(`llm.keyWarning`)}return(0,f.jsxs)(`p`,{className:`text-xs text-yellow-500 mt-1.5`,"aria-live":`polite`,children:[`⚠️ `,a]})}function E({value:e,saved:t,onChange:r,baseUrl:a,api:o,authHeader:s,providerId:c,placeholder:l,onModels:u,onStateChange:p,selectedModelId:m}){let{t:h}=n(`common`),{state:g,models:_,message:y,rawStatus:b,validate:x,reset:S}=w({baseUrl:a,api:o,authHeader:s,providerId:c}),[C,E]=(0,d.useState)(`idle`),[D,O]=(0,d.useState)(``),k=(0,d.useRef)(null),A=(0,d.useRef)(e);A.current=e;let j=(0,d.useCallback)(e=>{E(`idle`),O(``),x(e)},[x]),M=(0,d.useCallback)(e=>{r(e),S(),E(`idle`),O(``)},[r,S]),N=(0,d.useCallback)(e=>{let t=e.clipboardData?.getData(`text`)??``;t.trim()&&setTimeout(()=>j(t.trim()),0)},[j]),P=(0,d.useCallback)(()=>{let e=A.current;e.trim()&&g===`idle`&&j(e)},[g,j]),F=(0,d.useCallback)(()=>{let e=A.current;e.trim()&&j(e)},[j]),I=(0,d.useCallback)(()=>{if(!m||!A.current.trim())return;k.current&&k.current.abort();let e=new AbortController;k.current=e,E(`testing`),O(``),i({baseUrl:a,apiKey:A.current.trim(),api:o,authHeader:s,providerId:c,mode:`completion`,modelId:m},e.signal).then(t=>{e.signal.aborted||(t.status===`ok`?(E(`ok`),O(h(`llm.deepValidateOk`))):(E(`error`),t.status===`quota_exceeded`?O(h(`llm.deepQuotaExceeded`)):t.status===`model_not_found`?O(h(`llm.deepModelNotFound`)):O(t.message||h(`llm.keyWarning`))))}).catch(t=>{t.name===`AbortError`||e.signal.aborted||(E(`error`),O(t.message||h(`llm.keyWarning`)))})},[a,o,s,c,m,h]);(0,d.useEffect)(()=>()=>{k.current?.abort()},[]);let L=(0,d.useRef)(u);L.current=u,(0,d.useEffect)(()=>{g===`valid`&&_.length>0&&L.current&&L.current(_)},[g,_]);let R=(0,d.useRef)(p);R.current=p,(0,d.useEffect)(()=>{R.current?.(g)},[g]);let z=g===`valid`;return(0,f.jsxs)(`div`,{children:[(0,f.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,f.jsx)(`div`,{className:`flex-1`,onBlur:P,children:(0,f.jsx)(v,{value:e,saved:t,onChange:M,placeholder:l,onPaste:N})}),(0,f.jsx)(`button`,{type:`button`,onClick:F,disabled:g===`validating`||!e.trim(),className:`shrink-0 px-3 py-2 text-xs font-medium rounded-md border border-[var(--border)] bg-[var(--input-bg)] text-foreground hover:bg-[var(--hover-bg)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:h(g===`validating`?`llm.validating`:`llm.fetchModelsBtn`)})]}),(0,f.jsx)(T,{state:g,rawStatus:b,message:y,modelCount:_.length,t:h}),z&&(0,f.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,f.jsx)(`button`,{type:`button`,onClick:I,disabled:C===`testing`||!m,className:`shrink-0 px-2.5 py-1 text-[11px] font-medium rounded border border-[var(--border)] bg-[var(--input-bg)] text-foreground hover:bg-[var(--hover-bg)] disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:h(C===`testing`?`llm.deepValidating`:`llm.deepValidateBtn`)}),C===`idle`&&!m&&(0,f.jsx)(`span`,{className:`text-[11px] text-muted`,children:h(`llm.deepSelectModel`)}),C===`idle`&&m&&(0,f.jsx)(`span`,{className:`text-[11px] text-muted`,children:h(`llm.deepValidateHint`)}),C===`ok`&&(0,f.jsxs)(`span`,{className:`text-[11px] text-green-500`,children:[`✅ `,D]}),C===`error`&&(0,f.jsxs)(`span`,{className:`text-[11px] text-red-400`,children:[`❌ `,D]})]})]})}export{v as a,x as c,l as d,y as i,m as l,p as n,S as o,_ as r,b as s,E as t,u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-CS8DFbkQ.js";import{l as r,t as i}from"./vendor-react-Cc84NArf.js";import{Et as a,Pt as o,dt as s,ft as c,kt as l,nt as u,q as d}from"./api-C70Gt678.js";import{a as f,g as p,h as m,r as h,y as g}from"./index-ERt6_ngA.js";import{t as _}from"./usePolling-DeoThIQn.js";var v=e(t(),1),y=i();function b(e){if(!e)return`-`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`}function x({status:e}){let{t}=n(),r={running:{cls:`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`,labelKey:`status.running`},pending:{cls:`bg-amber-500/10 text-amber-400 border border-amber-500/20`,labelKey:`status.starting`},failed:{cls:`bg-red-500/10 text-red-400 border border-red-500/20`,labelKey:`status.failed`},dead:{cls:`bg-red-500/10 text-red-400 border border-red-500/20`,labelKey:`status.crashed`}}[e]||{cls:`bg-[var(--card)] text-muted border border-[var(--border)]`,labelKey:`status.stopped`};return(0,y.jsx)(`span`,{className:`inline-flex items-center text-xs px-2 py-0.5 rounded-full font-medium ${r.cls}`,children:t(r.labelKey)})}var S=[{key:`localInference`,labelKey:`capability.localInference`,cls:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`},{key:`knowledgeBase`,labelKey:`capability.knowledgeBase`,cls:`bg-indigo-500/10 text-indigo-400 border-indigo-500/20`},{key:`files`,labelKey:`capability.files`,cls:`bg-amber-500/10 text-amber-400 border-amber-500/20`},{key:`search`,labelKey:`capability.search`,cls:`bg-sky-500/10 text-sky-400 border-sky-500/20`},{key:`browser`,labelKey:`capability.browser`,cls:`bg-violet-500/10 text-violet-400 border-violet-500/20`},{key:`aiWebUi`,labelKey:`capability.aiWebUi`,cls:`bg-cyan-500/10 text-cyan-400 border-cyan-500/20`},{key:`webUi`,labelKey:`capability.webUi`,cls:`bg-slate-500/10 text-muted border-[var(--border)]`}];function C(e){let t=Array.isArray(e?.provides)?e.provides:[],n=new Set(t.map(e=>String(e?.capability??``).toLowerCase()).filter(Boolean)),r=new Set(t.map(e=>String(e?.kind??``).toLowerCase()).filter(Boolean));if(n.has(`llm-agent`))return[];let i=e=>{for(let t of n)if(e(t))return!0;return!1},a=e=>r.has(e),o=new Set;return(a(`llm`)||i(e=>e===`llm-ollama`||e===`ollama-api`))&&o.add(`localInference`),(a(`knowledge`)||i(e=>e.startsWith(`knowledge-`)||e.includes(`anythingllm`)||e.includes(`weknora`)))&&o.add(`knowledgeBase`),(a(`files`)||i(e=>e.startsWith(`files-`)||e.includes(`filebrowser`)))&&o.add(`files`),(a(`search`)||i(e=>e===`search`||e.startsWith(`search-`)))&&o.add(`search`),(a(`browser`)||i(e=>e===`browser`||e.startsWith(`browser-`)||e.startsWith(`web-browserless`)||e.startsWith(`playwright`)))&&o.add(`browser`),i(e=>e.includes(`openwebui`))&&o.add(`aiWebUi`),!o.size&&i(e=>e.startsWith(`web-`)||e.endsWith(`-web`)||e.endsWith(`-dashboard`))&&o.add(`webUi`),S.filter(e=>o.has(e.key))}function w(e){let t=e?.upgrade;return t?.updateAvailable===!0&&typeof t.currentVersion==`string`&&typeof t.latestVersion==`string`?t:null}function T(){let{t:e}=n([`dashboard`,`common`]),[t,i]=(0,v.useState)([]),[S,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(!1),M=r(),{showToast:N}=h(),P=()=>{u().then(e=>{i(e),k(``)}).catch(t=>k(t.message||e(`common:error.loadFailed`))),d().then(T).catch(()=>{})};_(P,1e4);let F=async()=>{if(window.confirm(e(`engine.restartConfirm`))){j(!0);try{await s(),N(e(`engine.restarted`),`success`),setTimeout(P,2e3)}catch(t){N(t.message||e(`engine.restartFailed`),`error`)}finally{j(!1)}}},I=async(t,n,r)=>{t.stopPropagation(),D(`${r}-${n}`);try{let t=null;n===`start`&&(t=await a(r,`dashboard`)),n===`stop`&&(t=await l(r,`dashboard`)),n===`restart`&&(t=await c(r,`dashboard`)),N(e(`common:action.${n}Done`),`success`);let i=t?.port_allocation;i&&typeof i.from==`number`&&typeof i.to==`number`&&i.from!==i.to&&N(e(`common:toast.portReallocated`,{defaultValue:`端口 {{from}} 被占用,已自动切换到 {{to}}`,from:i.from,to:i.to}),`info`),setTimeout(P,1e3)}catch(t){N(t.message||e(`common:error.operationFailed`),`error`)}finally{D(``)}},L=async(t,n)=>{t.stopPropagation(),D(`${n.id}-upgrade`);try{await o(n.id,`dashboard`),N(e(`appUpgrade.started`,{name:n.name||n.id}),`success`),setTimeout(P,1500)}catch(t){N(t.message||e(`appUpgrade.failed`),`error`)}finally{D(``)}},R=t.filter(e=>e.service?.status===`running`).length,z=t.filter(e=>w(e)),B=z[0]||null,V=B?w(B):null,H=!!S&&S.disk.percent>90,U=S?[{label:e(`stats.runningInstances`),value:`${R} / ${t.length}`,sub:S.nomad_running?e(`stats.engineRunning`):e(`stats.engineStopped`),subColor:S.nomad_running?`text-emerald-400`:`text-red-400`,icon:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,y.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,y.jsx)(`line`,{x1:`8`,y1:`21`,x2:`16`,y2:`21`}),(0,y.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`21`})]}),iconColor:`text-[#0066FF]`,glowColor:`rgba(0,102,255,0.12)`,accent:`border-l-2 border-l-[#0066FF]`},{label:e(`stats.cpu`),value:`${S.cpu_percent}%`,sub:S.temperature?`${S.temperature}°C`:null,icon:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,y.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`}),(0,y.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`}),(0,y.jsx)(`line`,{x1:`9`,y1:`2`,x2:`9`,y2:`4`}),(0,y.jsx)(`line`,{x1:`15`,y1:`2`,x2:`15`,y2:`4`}),(0,y.jsx)(`line`,{x1:`9`,y1:`20`,x2:`9`,y2:`22`}),(0,y.jsx)(`line`,{x1:`15`,y1:`20`,x2:`15`,y2:`22`}),(0,y.jsx)(`line`,{x1:`20`,y1:`9`,x2:`22`,y2:`9`}),(0,y.jsx)(`line`,{x1:`20`,y1:`15`,x2:`22`,y2:`15`}),(0,y.jsx)(`line`,{x1:`2`,y1:`9`,x2:`4`,y2:`9`}),(0,y.jsx)(`line`,{x1:`2`,y1:`15`,x2:`4`,y2:`15`})]}),iconColor:`text-[#0066FF]`,glowColor:`rgba(0,102,255,0.12)`,accent:`border-l-2 border-l-[#0066FF]`,warn:S.cpu_percent>90},{label:e(`stats.memory`),value:`${S.memory.percent}%`,sub:`${S.memory.used_mb}MB / ${S.memory.total_mb}MB`,icon:(0,y.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:(0,y.jsx)(`path`,{d:`M6 19v-8m4 8v-4m4 4v-6m4 6v-2`})}),iconColor:`text-[#00D4AA]`,glowColor:`rgba(0,212,170,0.12)`,accent:`border-l-2 border-l-[#00D4AA]`},{label:e(`stats.disk`),value:`${S.disk.percent}%`,sub:`${S.disk.used_gb}GB / ${S.disk.total_gb}GB`,icon:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,y.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}),(0,y.jsx)(`path`,{d:`M3 5v14a9 3 0 0018 0V5`}),(0,y.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`22`})]}),iconColor:H?`text-red-400`:`text-[#0066FF]`,glowColor:H?`rgba(239,68,68,0.12)`:`rgba(0,102,255,0.12)`,accent:H?`border-l-2 border-l-red-400`:`border-l-2 border-l-[#0066FF]`,warn:H}]:[];return(0,y.jsxs)(`div`,{className:`p-4 2xl:px-6 2xl:py-3 max-w-5xl xl:max-w-6xl 2xl:max-w-none mx-auto`,children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h1`,{className:`text-base font-semibold text-foreground`,children:e(`title`)}),(0,y.jsx)(`p`,{className:`text-xs text-muted mt-0.5`,children:e(`subtitle`)})]}),(0,y.jsx)(f,{})]}),B&&V&&(0,y.jsxs)(`div`,{className:`mb-4 border border-[#0066FF]/25 bg-[#0066FF]/10 rounded-lg px-4 py-3 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`appUpgrade.title`)}),(0,y.jsx)(`div`,{className:`text-xs text-muted mt-0.5`,children:e(`appUpgrade.description`,{name:B.name||B.id,currentVersion:V.currentVersion,latestVersion:V.latestVersion,count:z.length})})]}),(0,y.jsx)(`button`,{onClick:e=>L(e,B),disabled:!!E,className:`shrink-0 bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200`,children:E===`${B.id}-upgrade`?e(`appUpgrade.upgrading`):e(`appUpgrade.action`)})]}),S&&(0,y.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4`,children:U.map(e=>(0,y.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 relative overflow-hidden hover:border-[var(--border-hover)] hover:bg-[var(--card-hover)] transition-all duration-200 ${e.accent}`,children:[(0,y.jsx)(`div`,{className:`absolute top-0 right-0 w-16 h-16 rounded-full opacity-60 pointer-events-none`,style:{background:`radial-gradient(circle, ${e.glowColor} 0%, transparent 70%)`}}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[11px] text-muted`,children:e.label}),(0,y.jsx)(`span`,{className:`${e.iconColor} opacity-80`,children:e.icon})]}),(0,y.jsx)(`div`,{className:`text-lg font-semibold ${e.warn?`text-red-400`:`text-foreground`}`,children:e.value}),e.sub&&(0,y.jsx)(`div`,{className:`text-[11px] mt-0.5 truncate ${e.subColor??`text-muted`}`,children:e.sub})]},e.label))}),(0,y.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-[var(--border)] flex items-center justify-between`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e(`instances.title`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`button`,{onClick:()=>M(`/instances/new`),className:`bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 transition-all duration-200 shadow-[0_0_12px_rgba(0,102,255,0.3)]`,children:e(`instances.new`)}),(0,y.jsx)(`button`,{onClick:()=>M(`/instances/new?import=true`),className:`px-3 py-1.5 rounded-md text-xs font-medium text-muted border border-[var(--border)] bg-[var(--card)] hover:bg-[var(--card-hover)] hover:text-foreground transition-all duration-200`,children:e(`instances.import`)}),(0,y.jsxs)(`button`,{onClick:F,disabled:A,title:e(`instances.restartEngineTitle`),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium text-red-400 border border-red-500/20 bg-red-500/5 hover:bg-red-500/15 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200`,children:[(0,y.jsx)(p,{className:`w-3 h-3 ${A?`animate-spin`:``}`}),e(A?`instances.restarting`:`instances.restartEngine`)]})]})]}),O?(0,y.jsxs)(`div`,{className:`text-center py-12 px-4`,children:[(0,y.jsx)(`p`,{className:`text-sm text-red-400 mb-2`,children:e(`instances.loadError`,{error:O})}),(0,y.jsx)(`button`,{onClick:P,className:`text-xs text-muted hover:text-foreground underline`,children:e(`common:action.retry`)})]}):t.length===0?(0,y.jsxs)(`div`,{className:`text-center py-12 px-4`,children:[(0,y.jsx)(`div`,{className:`text-muted opacity-40 mb-3`,children:(0,y.jsxs)(`svg`,{className:`w-8 h-8 mx-auto`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,y.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,y.jsx)(`line`,{x1:`8`,y1:`21`,x2:`16`,y2:`21`}),(0,y.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`21`})]})}),(0,y.jsx)(`p`,{className:`text-sm text-muted mb-1`,children:e(`instances.empty`)}),(0,y.jsx)(`p`,{className:`text-xs text-muted opacity-60`,children:e(`instances.emptyHint`)})]}):(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`text-xs text-muted border-b border-[var(--border)]`,children:[(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2`,children:e(`table.name`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2`,children:e(`table.status`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2 hidden sm:table-cell`,children:e(`table.uptime`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2 hidden md:table-cell`,children:e(`table.memory`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2 hidden lg:table-cell`,children:e(`table.localCapability`)}),(0,y.jsx)(`th`,{className:`text-right font-medium px-4 py-2`,children:e(`table.actions`)})]})}),(0,y.jsx)(`tbody`,{className:`divide-y divide-[var(--border)]`,children:t.map(t=>{let n=t.service?.status||`stopped`,r=n===`running`,i=C(t),a=w(t);return(0,y.jsxs)(`tr`,{className:`hover:bg-[var(--card-hover)] cursor-pointer transition-colors duration-150`,onClick:()=>M(`/instances/${t.id}`),children:[(0,y.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,y.jsx)(`div`,{className:`font-medium text-foreground`,children:t.name}),(0,y.jsxs)(`div`,{className:`text-xs text-muted font-mono flex items-center gap-2`,children:[(0,y.jsx)(`span`,{children:t.id}),a&&(0,y.jsx)(`span`,{className:`rounded border border-[#0066FF]/25 bg-[#0066FF]/10 px-1.5 py-0.5 text-[10px] font-sans text-[#0066FF]`,children:e(`appUpgrade.badge`,{version:a.latestVersion})})]})]}),(0,y.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,y.jsx)(x,{status:n}),t.auto_backup?.enabled&&(0,y.jsx)(`span`,{className:`text-xs leading-none ${t.auto_backup.last_backup_ok===!1?`text-red-400`:`text-green-400`}`,title:t.auto_backup.last_backup_ok===!1?`Backup failed`:`Backup OK`,children:t.auto_backup.last_backup_ok===!1?`⚠`:`●`})]})}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 text-muted hidden sm:table-cell font-mono text-xs`,children:r?b(t.service.uptime):`-`}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 text-muted hidden md:table-cell font-mono text-xs`,children:t.service?.memory_mb?`${t.service.memory_mb} MB`:`-`}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 hidden lg:table-cell`,children:i.length?(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(t=>(0,y.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium ${t.cls}`,children:e(t.labelKey)},t.key))}):(0,y.jsx)(`span`,{className:`text-muted text-xs`,children:`-`})}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 text-right`,children:(0,y.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:r||n===`pending`?(0,y.jsxs)(y.Fragment,{children:[a&&(0,y.jsx)(`button`,{title:e(`appUpgrade.action`),onClick:e=>L(e,t),disabled:!!E,className:`px-2 py-1 rounded-md text-xs text-[#0066FF] border border-[#0066FF]/25 bg-[#0066FF]/10 hover:bg-[#0066FF]/15 disabled:opacity-30 transition-colors duration-150`,children:E===`${t.id}-upgrade`?e(`appUpgrade.shortUpgrading`):e(`appUpgrade.shortAction`)}),(0,y.jsx)(`button`,{title:e(`common:action.restart`),onClick:e=>I(e,`restart`,t.id),disabled:!!E,className:`p-1.5 rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-colors duration-150`,children:(0,y.jsx)(p,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{title:e(`common:action.stop`),onClick:e=>I(e,`stop`,t.id),disabled:!!E,className:`p-1.5 rounded-md text-muted hover:text-red-400 hover:bg-red-500/10 disabled:opacity-30 transition-colors duration-150`,children:(0,y.jsx)(g,{className:`w-3.5 h-3.5`})})]}):(0,y.jsxs)(y.Fragment,{children:[a&&(0,y.jsx)(`button`,{title:e(`appUpgrade.action`),onClick:e=>L(e,t),disabled:!!E,className:`px-2 py-1 rounded-md text-xs text-[#0066FF] border border-[#0066FF]/25 bg-[#0066FF]/10 hover:bg-[#0066FF]/15 disabled:opacity-30 transition-colors duration-150`,children:E===`${t.id}-upgrade`?e(`appUpgrade.shortUpgrading`):e(`appUpgrade.shortAction`)}),(0,y.jsx)(`button`,{title:e(`common:action.start`),onClick:e=>I(e,`start`,t.id),disabled:!!E,className:`p-1.5 rounded-md text-muted hover:text-emerald-400 hover:bg-emerald-500/10 disabled:opacity-30 transition-colors duration-150`,children:(0,y.jsx)(m,{className:`w-3.5 h-3.5`})})]})})})]},t.id)})})]})]})]})}export{T as default};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-Df8aUdv8.js";import{l as r,t as i}from"./vendor-react-0L0rjmYG.js";import{Et as a,Pt as o,dt as s,ft as c,kt as l,nt as u,q as d}from"./api-C70Gt678.js";import{a as f,g as p,h as m,r as h,y as g}from"./index-Bs6DSbiR.js";import{t as _}from"./usePolling-D4IDOQd_.js";var v=e(t(),1),y=i();function b(e){if(!e)return`-`;let t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`}function x({status:e}){let{t}=n(),r={running:{cls:`bg-emerald-500/10 text-emerald-400 border border-emerald-500/20`,labelKey:`status.running`},pending:{cls:`bg-amber-500/10 text-amber-400 border border-amber-500/20`,labelKey:`status.starting`},failed:{cls:`bg-red-500/10 text-red-400 border border-red-500/20`,labelKey:`status.failed`},dead:{cls:`bg-red-500/10 text-red-400 border border-red-500/20`,labelKey:`status.crashed`}}[e]||{cls:`bg-[var(--card)] text-muted border border-[var(--border)]`,labelKey:`status.stopped`};return(0,y.jsx)(`span`,{className:`inline-flex items-center text-xs px-2 py-0.5 rounded-full font-medium ${r.cls}`,children:t(r.labelKey)})}var S=[{key:`localInference`,labelKey:`capability.localInference`,cls:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`},{key:`knowledgeBase`,labelKey:`capability.knowledgeBase`,cls:`bg-indigo-500/10 text-indigo-400 border-indigo-500/20`},{key:`files`,labelKey:`capability.files`,cls:`bg-amber-500/10 text-amber-400 border-amber-500/20`},{key:`search`,labelKey:`capability.search`,cls:`bg-sky-500/10 text-sky-400 border-sky-500/20`},{key:`browser`,labelKey:`capability.browser`,cls:`bg-violet-500/10 text-violet-400 border-violet-500/20`},{key:`aiWebUi`,labelKey:`capability.aiWebUi`,cls:`bg-cyan-500/10 text-cyan-400 border-cyan-500/20`},{key:`webUi`,labelKey:`capability.webUi`,cls:`bg-slate-500/10 text-muted border-[var(--border)]`}];function C(e){let t=Array.isArray(e?.provides)?e.provides:[],n=new Set(t.map(e=>String(e?.capability??``).toLowerCase()).filter(Boolean)),r=new Set(t.map(e=>String(e?.kind??``).toLowerCase()).filter(Boolean));if(n.has(`llm-agent`))return[];let i=e=>{for(let t of n)if(e(t))return!0;return!1},a=e=>r.has(e),o=new Set;return(a(`llm`)||i(e=>e===`llm-ollama`||e===`ollama-api`))&&o.add(`localInference`),(a(`knowledge`)||i(e=>e.startsWith(`knowledge-`)||e.includes(`anythingllm`)||e.includes(`weknora`)))&&o.add(`knowledgeBase`),(a(`files`)||i(e=>e.startsWith(`files-`)||e.includes(`filebrowser`)))&&o.add(`files`),(a(`search`)||i(e=>e===`search`||e.startsWith(`search-`)))&&o.add(`search`),(a(`browser`)||i(e=>e===`browser`||e.startsWith(`browser-`)||e.startsWith(`web-browserless`)||e.startsWith(`playwright`)))&&o.add(`browser`),i(e=>e.includes(`openwebui`))&&o.add(`aiWebUi`),!o.size&&i(e=>e.startsWith(`web-`)||e.endsWith(`-web`)||e.endsWith(`-dashboard`))&&o.add(`webUi`),S.filter(e=>o.has(e.key))}function w(e){let t=e?.upgrade;return t?.updateAvailable===!0&&typeof t.currentVersion==`string`&&typeof t.latestVersion==`string`?t:null}function T(){let{t:e}=n([`dashboard`,`common`]),[t,i]=(0,v.useState)([]),[S,T]=(0,v.useState)(null),[E,D]=(0,v.useState)(``),[O,k]=(0,v.useState)(``),[A,j]=(0,v.useState)(!1),M=r(),{showToast:N}=h(),P=()=>{u().then(e=>{i(e),k(``)}).catch(t=>k(t.message||e(`common:error.loadFailed`))),d().then(T).catch(()=>{})};_(P,1e4);let F=async()=>{if(window.confirm(e(`engine.restartConfirm`))){j(!0);try{await s(),N(e(`engine.restarted`),`success`),setTimeout(P,2e3)}catch(t){N(t.message||e(`engine.restartFailed`),`error`)}finally{j(!1)}}},I=async(t,n,r)=>{t.stopPropagation(),D(`${r}-${n}`);try{let t=null;n===`start`&&(t=await a(r,`dashboard`)),n===`stop`&&(t=await l(r,`dashboard`)),n===`restart`&&(t=await c(r,`dashboard`)),N(e(`common:action.${n}Done`),`success`);let i=t?.port_allocation;i&&typeof i.from==`number`&&typeof i.to==`number`&&i.from!==i.to&&N(e(`common:toast.portReallocated`,{defaultValue:`端口 {{from}} 被占用,已自动切换到 {{to}}`,from:i.from,to:i.to}),`info`),setTimeout(P,1e3)}catch(t){N(t.message||e(`common:error.operationFailed`),`error`)}finally{D(``)}},L=async(t,n)=>{t.stopPropagation(),D(`${n.id}-upgrade`);try{await o(n.id,`dashboard`),N(e(`appUpgrade.started`,{name:n.name||n.id}),`success`),setTimeout(P,1500)}catch(t){N(t.message||e(`appUpgrade.failed`),`error`)}finally{D(``)}},R=t.filter(e=>e.service?.status===`running`).length,z=t.filter(e=>w(e)),B=z[0]||null,V=B?w(B):null,H=!!S&&S.disk.percent>90,U=S?[{label:e(`stats.runningInstances`),value:`${R} / ${t.length}`,sub:S.nomad_running?e(`stats.engineRunning`):e(`stats.engineStopped`),subColor:S.nomad_running?`text-emerald-400`:`text-red-400`,icon:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,y.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,y.jsx)(`line`,{x1:`8`,y1:`21`,x2:`16`,y2:`21`}),(0,y.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`21`})]}),iconColor:`text-[#0066FF]`,glowColor:`rgba(0,102,255,0.12)`,accent:`border-l-2 border-l-[#0066FF]`},{label:e(`stats.cpu`),value:`${S.cpu_percent}%`,sub:S.temperature?`${S.temperature}°C`:null,icon:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,y.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`}),(0,y.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`}),(0,y.jsx)(`line`,{x1:`9`,y1:`2`,x2:`9`,y2:`4`}),(0,y.jsx)(`line`,{x1:`15`,y1:`2`,x2:`15`,y2:`4`}),(0,y.jsx)(`line`,{x1:`9`,y1:`20`,x2:`9`,y2:`22`}),(0,y.jsx)(`line`,{x1:`15`,y1:`20`,x2:`15`,y2:`22`}),(0,y.jsx)(`line`,{x1:`20`,y1:`9`,x2:`22`,y2:`9`}),(0,y.jsx)(`line`,{x1:`20`,y1:`15`,x2:`22`,y2:`15`}),(0,y.jsx)(`line`,{x1:`2`,y1:`9`,x2:`4`,y2:`9`}),(0,y.jsx)(`line`,{x1:`2`,y1:`15`,x2:`4`,y2:`15`})]}),iconColor:`text-[#0066FF]`,glowColor:`rgba(0,102,255,0.12)`,accent:`border-l-2 border-l-[#0066FF]`,warn:S.cpu_percent>90},{label:e(`stats.memory`),value:`${S.memory.percent}%`,sub:`${S.memory.used_mb}MB / ${S.memory.total_mb}MB`,icon:(0,y.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:(0,y.jsx)(`path`,{d:`M6 19v-8m4 8v-4m4 4v-6m4 6v-2`})}),iconColor:`text-[#00D4AA]`,glowColor:`rgba(0,212,170,0.12)`,accent:`border-l-2 border-l-[#00D4AA]`},{label:e(`stats.disk`),value:`${S.disk.percent}%`,sub:`${S.disk.used_gb}GB / ${S.disk.total_gb}GB`,icon:(0,y.jsxs)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,children:[(0,y.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`}),(0,y.jsx)(`path`,{d:`M3 5v14a9 3 0 0018 0V5`}),(0,y.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`22`})]}),iconColor:H?`text-red-400`:`text-[#0066FF]`,glowColor:H?`rgba(239,68,68,0.12)`:`rgba(0,102,255,0.12)`,accent:H?`border-l-2 border-l-red-400`:`border-l-2 border-l-[#0066FF]`,warn:H}]:[];return(0,y.jsxs)(`div`,{className:`p-4 2xl:px-6 2xl:py-3 max-w-5xl xl:max-w-6xl 2xl:max-w-none mx-auto`,children:[(0,y.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h1`,{className:`text-base font-semibold text-foreground`,children:e(`title`)}),(0,y.jsx)(`p`,{className:`text-xs text-muted mt-0.5`,children:e(`subtitle`)})]}),(0,y.jsx)(f,{})]}),B&&V&&(0,y.jsxs)(`div`,{className:`mb-4 border border-[#0066FF]/25 bg-[#0066FF]/10 rounded-lg px-4 py-3 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`appUpgrade.title`)}),(0,y.jsx)(`div`,{className:`text-xs text-muted mt-0.5`,children:e(`appUpgrade.description`,{name:B.name||B.id,currentVersion:V.currentVersion,latestVersion:V.latestVersion,count:z.length})})]}),(0,y.jsx)(`button`,{onClick:e=>L(e,B),disabled:!!E,className:`shrink-0 bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200`,children:E===`${B.id}-upgrade`?e(`appUpgrade.upgrading`):e(`appUpgrade.action`)})]}),S&&(0,y.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4`,children:U.map(e=>(0,y.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 relative overflow-hidden hover:border-[var(--border-hover)] hover:bg-[var(--card-hover)] transition-all duration-200 ${e.accent}`,children:[(0,y.jsx)(`div`,{className:`absolute top-0 right-0 w-16 h-16 rounded-full opacity-60 pointer-events-none`,style:{background:`radial-gradient(circle, ${e.glowColor} 0%, transparent 70%)`}}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[11px] text-muted`,children:e.label}),(0,y.jsx)(`span`,{className:`${e.iconColor} opacity-80`,children:e.icon})]}),(0,y.jsx)(`div`,{className:`text-lg font-semibold ${e.warn?`text-red-400`:`text-foreground`}`,children:e.value}),e.sub&&(0,y.jsx)(`div`,{className:`text-[11px] mt-0.5 truncate ${e.subColor??`text-muted`}`,children:e.sub})]},e.label))}),(0,y.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden`,children:[(0,y.jsxs)(`div`,{className:`px-4 py-2.5 border-b border-[var(--border)] flex items-center justify-between`,children:[(0,y.jsx)(`h2`,{className:`text-sm font-medium text-foreground`,children:e(`instances.title`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`button`,{onClick:()=>M(`/instances/new`),className:`bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 transition-all duration-200 shadow-[0_0_12px_rgba(0,102,255,0.3)]`,children:e(`instances.new`)}),(0,y.jsx)(`button`,{onClick:()=>M(`/instances/new?import=true`),className:`px-3 py-1.5 rounded-md text-xs font-medium text-muted border border-[var(--border)] bg-[var(--card)] hover:bg-[var(--card-hover)] hover:text-foreground transition-all duration-200`,children:e(`instances.import`)}),(0,y.jsxs)(`button`,{onClick:F,disabled:A,title:e(`instances.restartEngineTitle`),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium text-red-400 border border-red-500/20 bg-red-500/5 hover:bg-red-500/15 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200`,children:[(0,y.jsx)(p,{className:`w-3 h-3 ${A?`animate-spin`:``}`}),e(A?`instances.restarting`:`instances.restartEngine`)]})]})]}),O?(0,y.jsxs)(`div`,{className:`text-center py-12 px-4`,children:[(0,y.jsx)(`p`,{className:`text-sm text-red-400 mb-2`,children:e(`instances.loadError`,{error:O})}),(0,y.jsx)(`button`,{onClick:P,className:`text-xs text-muted hover:text-foreground underline`,children:e(`common:action.retry`)})]}):t.length===0?(0,y.jsxs)(`div`,{className:`text-center py-12 px-4`,children:[(0,y.jsx)(`div`,{className:`text-muted opacity-40 mb-3`,children:(0,y.jsxs)(`svg`,{className:`w-8 h-8 mx-auto`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,y.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,y.jsx)(`line`,{x1:`8`,y1:`21`,x2:`16`,y2:`21`}),(0,y.jsx)(`line`,{x1:`12`,y1:`17`,x2:`12`,y2:`21`})]})}),(0,y.jsx)(`p`,{className:`text-sm text-muted mb-1`,children:e(`instances.empty`)}),(0,y.jsx)(`p`,{className:`text-xs text-muted opacity-60`,children:e(`instances.emptyHint`)})]}):(0,y.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`text-xs text-muted border-b border-[var(--border)]`,children:[(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2`,children:e(`table.name`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2`,children:e(`table.status`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2 hidden sm:table-cell`,children:e(`table.uptime`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2 hidden md:table-cell`,children:e(`table.memory`)}),(0,y.jsx)(`th`,{className:`text-left font-medium px-4 py-2 hidden lg:table-cell`,children:e(`table.localCapability`)}),(0,y.jsx)(`th`,{className:`text-right font-medium px-4 py-2`,children:e(`table.actions`)})]})}),(0,y.jsx)(`tbody`,{className:`divide-y divide-[var(--border)]`,children:t.map(t=>{let n=t.service?.status||`stopped`,r=n===`running`,i=C(t),a=w(t);return(0,y.jsxs)(`tr`,{className:`hover:bg-[var(--card-hover)] cursor-pointer transition-colors duration-150`,onClick:()=>M(`/instances/${t.id}`),children:[(0,y.jsxs)(`td`,{className:`px-4 py-2.5`,children:[(0,y.jsx)(`div`,{className:`font-medium text-foreground`,children:t.name}),(0,y.jsxs)(`div`,{className:`text-xs text-muted font-mono flex items-center gap-2`,children:[(0,y.jsx)(`span`,{children:t.id}),a&&(0,y.jsx)(`span`,{className:`rounded border border-[#0066FF]/25 bg-[#0066FF]/10 px-1.5 py-0.5 text-[10px] font-sans text-[#0066FF]`,children:e(`appUpgrade.badge`,{version:a.latestVersion})})]})]}),(0,y.jsx)(`td`,{className:`px-4 py-2.5`,children:(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,y.jsx)(x,{status:n}),t.auto_backup?.enabled&&(0,y.jsx)(`span`,{className:`text-xs leading-none ${t.auto_backup.last_backup_ok===!1?`text-red-400`:`text-green-400`}`,title:t.auto_backup.last_backup_ok===!1?`Backup failed`:`Backup OK`,children:t.auto_backup.last_backup_ok===!1?`⚠`:`●`})]})}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 text-muted hidden sm:table-cell font-mono text-xs`,children:r?b(t.service.uptime):`-`}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 text-muted hidden md:table-cell font-mono text-xs`,children:t.service?.memory_mb?`${t.service.memory_mb} MB`:`-`}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 hidden lg:table-cell`,children:i.length?(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:i.map(t=>(0,y.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-0.5 text-[11px] font-medium ${t.cls}`,children:e(t.labelKey)},t.key))}):(0,y.jsx)(`span`,{className:`text-muted text-xs`,children:`-`})}),(0,y.jsx)(`td`,{className:`px-4 py-2.5 text-right`,children:(0,y.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:r||n===`pending`?(0,y.jsxs)(y.Fragment,{children:[a&&(0,y.jsx)(`button`,{title:e(`appUpgrade.action`),onClick:e=>L(e,t),disabled:!!E,className:`px-2 py-1 rounded-md text-xs text-[#0066FF] border border-[#0066FF]/25 bg-[#0066FF]/10 hover:bg-[#0066FF]/15 disabled:opacity-30 transition-colors duration-150`,children:E===`${t.id}-upgrade`?e(`appUpgrade.shortUpgrading`):e(`appUpgrade.shortAction`)}),(0,y.jsx)(`button`,{title:e(`common:action.restart`),onClick:e=>I(e,`restart`,t.id),disabled:!!E,className:`p-1.5 rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-colors duration-150`,children:(0,y.jsx)(p,{className:`w-3.5 h-3.5`})}),(0,y.jsx)(`button`,{title:e(`common:action.stop`),onClick:e=>I(e,`stop`,t.id),disabled:!!E,className:`p-1.5 rounded-md text-muted hover:text-red-400 hover:bg-red-500/10 disabled:opacity-30 transition-colors duration-150`,children:(0,y.jsx)(g,{className:`w-3.5 h-3.5`})})]}):(0,y.jsxs)(y.Fragment,{children:[a&&(0,y.jsx)(`button`,{title:e(`appUpgrade.action`),onClick:e=>L(e,t),disabled:!!E,className:`px-2 py-1 rounded-md text-xs text-[#0066FF] border border-[#0066FF]/25 bg-[#0066FF]/10 hover:bg-[#0066FF]/15 disabled:opacity-30 transition-colors duration-150`,children:E===`${t.id}-upgrade`?e(`appUpgrade.shortUpgrading`):e(`appUpgrade.shortAction`)}),(0,y.jsx)(`button`,{title:e(`common:action.start`),onClick:e=>I(e,`start`,t.id),disabled:!!E,className:`p-1.5 rounded-md text-muted hover:text-emerald-400 hover:bg-emerald-500/10 disabled:opacity-30 transition-colors duration-150`,children:(0,y.jsx)(m,{className:`w-3.5 h-3.5`})})]})})})]},t.id)})})]})]})]})}export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t}from"./vendor-i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t}from"./vendor-i18n-Df8aUdv8.js";import{t as n}from"./vendor-react-0L0rjmYG.js";import{r}from"./api-C70Gt678.js";var i=e(t(),1),a=n(),o=`hermes-chat:`,s=`hermes-chat-epoch:`,c=10,l=10;function u(e,t){if(!t)return null;try{let n=localStorage.getItem(s+e),r=localStorage.getItem(o+e)!=null;(n!==null&&n!==t||n===null&&r)&&localStorage.removeItem(o+e),n!==t&&localStorage.setItem(s+e,t)}catch{}return t}function d(e,t){u(e,t);try{let t=localStorage.getItem(o+e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>e&&(e.role===`user`||e.role===`assistant`||e.role===`system`)).map(e=>({role:e.role,content:String(e.content??``),error:!!e.error})):[]}catch{return[]}}function f({instanceId:e,instanceEpoch:t=null}){let[n,s]=(0,i.useState)(()=>d(e,t)),[u,f]=(0,i.useState)(()=>Math.min(c,n.length||c)),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(!1),[_,v]=(0,i.useState)(!1),y=(0,i.useRef)(null),b=(0,i.useRef)(n.length),x=(0,i.useRef)(null),S=n.slice(-u),C=u<n.length;(0,i.useEffect)(()=>{try{let t=n.filter(e=>!e.pending).slice(-500);t.length===0?localStorage.removeItem(o+e):localStorage.setItem(o+e,JSON.stringify(t))}catch{}},[e,n]),(0,i.useEffect)(()=>{let n=d(e,t);s(n),f(Math.min(c,n.length||c))},[e,t]),(0,i.useEffect)(()=>{let e=y.current;if(e){if(x.current){let t=x.current.prevScrollHeight;e.scrollTop=e.scrollHeight-t,x.current=null;return}n.length>=b.current&&(e.scrollTop=e.scrollHeight),b.current=n.length}},[n,u]);let w=()=>{if(!C||_)return;v(!0);let e=y.current;e&&(x.current={prevScrollHeight:e.scrollHeight}),f(e=>Math.min(e+l,n.length)),requestAnimationFrame(()=>v(!1))},T=()=>{let e=y.current;!e||!C||_||e.scrollTop<40&&w()},E=async()=>{let t=p.trim();if(!t||h)return;m(``),g(!0);let i={role:`user`,content:t},a={role:`assistant`,content:``,pending:!0},o=[...n,i,a];s(o);let c=o.slice(0,-1).slice(-20).map(e=>({role:e.role,content:e.content}));try{let t=await r(e,{model:`hermes-agent`,messages:c,max_tokens:512}),n=t?.choices?.[0]?.message?.content??t?.error?.message??`(empty response)`;s(e=>e.map((t,r)=>r===e.length-1?{role:`assistant`,content:String(n)}:t))}catch(e){s(t=>t.map((n,r)=>r===t.length-1?{role:`assistant`,content:e?.message||`(request failed)`,error:!0}:n))}finally{g(!1)}};return(0,a.jsxs)(`div`,{className:`overflow-hidden rounded-[22px] border border-[var(--border)] bg-[var(--card)] shadow-[0_18px_48px_rgba(15,23,42,0.06)] flex flex-col`,style:{height:`calc(100vh - 160px)`,minHeight:`500px`},children:[(0,a.jsxs)(`div`,{className:`px-5 py-3 border-b border-[var(--border)] flex items-center justify-between`,children:[(0,a.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,a.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full bg-emerald-500 shadow-[0_0_6px_rgba(16,185,129,0.7)]`}),(0,a.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:`Chat`}),(0,a.jsx)(`span`,{className:`text-[10px] text-muted font-mono`,children:`inline → /v1/chat/completions`})]}),n.length>0&&(0,a.jsx)(`button`,{onClick:()=>{s([]),f(c)},className:`text-xs text-muted hover:text-foreground transition-colors`,disabled:h,children:`清空对话`})]}),(0,a.jsxs)(`div`,{ref:y,onScroll:T,className:`flex-1 overflow-y-auto p-5 space-y-3`,children:[C&&(0,a.jsx)(`div`,{className:`flex justify-center py-1`,children:(0,a.jsx)(`button`,{onClick:w,disabled:_,className:`text-xs text-muted hover:text-foreground transition-colors`,children:_?`加载中...`:`向上滚动或点击加载更早的 ${Math.min(l,n.length-u)} 条 (共 ${n.length} 条)`})}),n.length===0?(0,a.jsxs)(`div`,{className:`h-full flex flex-col items-center justify-center text-center`,children:[(0,a.jsx)(`div`,{className:`text-4xl mb-3 opacity-40`,children:`⚕`}),(0,a.jsx)(`div`,{className:`text-sm text-foreground/70 font-medium mb-1`,children:`和 Hermes agent 开始对话`}),(0,a.jsx)(`div`,{className:`text-xs text-muted max-w-md`,children:`消息会走完整的 agent loop(skills + tools + memory), 经 JishuShell LLM 代理转发到上游模型。首次请求因冷启动约 20-30 秒。`})]}):S.map((e,t)=>(0,a.jsx)(`div`,{className:`flex ${e.role===`user`?`justify-end`:`justify-start`}`,children:(0,a.jsx)(`div`,{className:`max-w-[80%] rounded-2xl px-4 py-2.5 text-sm whitespace-pre-wrap break-words ${e.role===`user`?`bg-[#0066FF] text-white`:e.error?`bg-red-500/10 border border-red-500/20 text-red-400`:`bg-[var(--input-bg)] border border-[var(--border)] text-foreground`}`,children:e.pending?(0,a.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-muted`,children:[(0,a.jsx)(`span`,{className:`w-3 h-3 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin`}),`agent 正在思考...`]}):e.content})},n.length-S.length+t))]}),(0,a.jsx)(`div`,{className:`p-4 border-t border-[var(--border)]`,children:(0,a.jsxs)(`div`,{className:`flex gap-2`,children:[(0,a.jsx)(`textarea`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),E())},placeholder:`输入消息 (Enter 发送,Shift+Enter 换行)`,rows:2,disabled:h,className:`flex-1 bg-[var(--input-bg)] border border-[var(--border)] rounded-lg px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 resize-none`}),(0,a.jsx)(`button`,{onClick:E,disabled:!p.trim()||h,className:`self-end px-4 py-2 bg-[#0066FF] text-white rounded-lg text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200`,children:h?(0,a.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,a.jsx)(`span`,{className:`w-3 h-3 border-2 border-white/30 border-t-white rounded-full animate-spin`}),`发送中`]}):`发送`})]})})]})}export{f as HermesChatPanel};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-Df8aUdv8.js";import{r,t as i}from"./vendor-react-0L0rjmYG.js";import{F as a,j as o,lt as ee}from"./api-C70Gt678.js";import{a as s,i as c,o as l,r as u,s as d,t as te,u as f}from"./ApiKeyField-Ce5d1xna.js";import{n as p,t as m}from"./WeixinLoginPanel-B765Xz4C.js";var h=e(t(),1),g=i(),ne=new Set([`feishu`,`weixin`]),_={telegram:{label:`Telegram`,fields:[{key:`token`,envKey:`TELEGRAM_BOT_TOKEN`,label:`Bot Token`,secret:!0,hint:`从 @BotFather 获取`},{key:`allowed`,envKey:`TELEGRAM_ALLOWED_USERS`,label:`Allowed Users`,hint:`逗号分隔 user id,留空=所有人`}]},discord:{label:`Discord`,fields:[{key:`token`,envKey:`DISCORD_BOT_TOKEN`,label:`Bot Token`,secret:!0,hint:`从 Discord Developer Portal`}]},slack:{label:`Slack`,fields:[{key:`bot`,envKey:`SLACK_BOT_TOKEN`,label:`Bot Token (xoxb-…)`,secret:!0,placeholder:`xoxb-...`},{key:`app`,envKey:`SLACK_APP_TOKEN`,label:`App Token (xapp-…)`,secret:!0,placeholder:`xapp-...`}]},whatsapp:{label:`WhatsApp`,fields:[{key:`token`,envKey:`WHATSAPP_TOKEN`,label:`Access Token`,secret:!0}]},signal:{label:`Signal`,fields:[{key:`account`,envKey:`SIGNAL_ACCOUNT`,label:`Phone (E.164)`,placeholder:`+8613800138000`}]},email:{label:`Email (SMTP)`,fields:[{key:`host`,envKey:`SMTP_HOST`,label:`SMTP Host`,placeholder:`smtp.gmail.com`},{key:`port`,envKey:`SMTP_PORT`,label:`SMTP Port`,placeholder:`587`},{key:`user`,envKey:`SMTP_USER`,label:`SMTP User`},{key:`pass`,envKey:`SMTP_PASSWORD`,label:`SMTP Password`,secret:!0}]}};function re(e){let t=new Map;for(let n of e.split(`
|
|
2
2
|
`)){let e=n.trim();if(!e||e.startsWith(`#`))continue;let r=e.indexOf(`=`);if(r<0)continue;let i=e.slice(0,r).trim(),a=e.slice(r+1).trim();(a.startsWith(`"`)&&a.endsWith(`"`)||a.startsWith(`'`)&&a.endsWith(`'`))&&(a=a.slice(1,-1)),t.set(i,a)}return t}function v(e,t){let n=e.split(`
|
|
3
3
|
`),r=new Set,i=[];for(let e of n){let n=e.trim();if(!n||n.startsWith(`#`)){i.push(e);continue}let a=n.indexOf(`=`);if(a<0){i.push(e);continue}let o=n.slice(0,a).trim();if(o in t){r.add(o);let e=t[o];if(e===``)continue;i.push(`${o}=${e}`)}else i.push(e)}for(let[e,n]of Object.entries(t))!r.has(e)&&n!==``&&i.push(`${e}=${n}`);return i.join(`
|
|
4
4
|
`)}function y({config:e,onChange:t,instanceId:i,capabilities:y}){let{t:b}=n([`instance`,`common`]),x=String(e?.yaml||``),S=String(e?.env||``),C=(0,h.useMemo)(()=>re(S),[S]),w=((e?.[`x-jishushell`]||{}).proxy||{}).upstream||{},T=w.providerId||``,E=f.find(e=>e.id===T),D=w.models||[],O=E?E.models.map(e=>({id:e.id,name:e.name,contextWindow:e.contextWindow})):D.map(e=>({id:e.id,name:e.name||e.id,contextWindow:e.contextWindow||0})),k=w.selectedModelId||O[0]?.id||``,A=D.find(e=>e.id===k)||O.find(e=>e.id===k)||{id:``,name:``,contextWindow:0},[j,ie]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(!(w.hasApiKey&&T)),[I,L]=(0,h.useState)([]),[R,z]=(0,h.useState)([]),[B,V]=(0,h.useState)(!1);(0,h.useEffect)(()=>{a().then(ie).catch(()=>{})},[]);let H=n=>{let r=JSON.parse(JSON.stringify(e));r[`x-jishushell`]||={},r[`x-jishushell`].proxy||={},r[`x-jishushell`].proxy.upstream={...r[`x-jishushell`].proxy.upstream||{},...n},t(r)},U=(e,t)=>H({[e]:t}),ae=n=>{let r=f.find(e=>e.id===n);if(!r){H({providerId:``});return}if(w.apiKey&&!window.confirm(b(`configForm.switchProviderConfirm`,{defaultValue:`切换 provider 会清空当前 API key,确定继续?`})))return;let i=JSON.parse(JSON.stringify(e));i[`x-jishushell`]||={},i[`x-jishushell`].proxy||={},i[`x-jishushell`].proxy.upstream={providerId:r.id,baseUrl:r.baseUrl,api:r.api,authHeader:r.authHeader===!0,headers:r.headers||{},models:r.models.map(e=>({id:e.id,name:e.name,contextWindow:e.contextWindow})),selectedModelId:r.models[0]?.id||``,apiKey:``,hasApiKey:!1,clearApiKey:!1},t(i)},W=e=>U(`selectedModelId`,e),G=n=>{let r=[...D],i=r.findIndex(e=>e.id===k),a={...A,...n};i>=0?r[i]=a:r.push(a);let o=JSON.parse(JSON.stringify(e));o[`x-jishushell`]||={},o[`x-jishushell`].proxy||={},o[`x-jishushell`].proxy.upstream={...o[`x-jishushell`].proxy.upstream||{},models:r,selectedModelId:typeof n.id==`string`&&n.id?n.id:k},t(o)},oe=async e=>{if(!T)return;let t=f.find(e=>e.id===T);if(!t)return;let n=[`ollama`,`vllm`,`sglang`].includes(T)&&w.baseUrl?String(w.baseUrl):t.baseUrl,r=t.authHeader?`x-api-key`:`Authorization`,i=e??(w.apiKey||``);V(!0);try{let{models:e}=await ee(n,i,r,t.id,t.api);z(e),e.length&&!k&&W(e[0].id)}catch{}finally{V(!1)}},K=Array.isArray(y?.messagingPlatforms)?y.messagingPlatforms:[],q=(0,h.useMemo)(()=>K.filter(e=>!ne.has(e)),[K]),J=(0,h.useMemo)(()=>{let e=[];for(let t of q){let n=_[t];n&&n.fields.some(e=>(C.get(e.envKey)||``).trim()!==``)&&e.push(t)}return e},[q,C]),Y=(0,h.useMemo)(()=>Array.from(new Set([...J,...I])),[J,I]),X=q.filter(e=>!Y.includes(e)&&_[e]),Z=C.get(`FEISHU_APP_ID`)||``,se=(0,h.useMemo)(()=>x.match(/platforms:\s*[\s\S]*?feishu:\s*[\s\S]*?domain_name:\s*["']?(\w+)["']?/)?.[1]===`lark`?`lark`:`feishu`,[x]),Q=()=>{i&&o(i).then(e=>{e&&t(e)}).catch(()=>{})},$=(n,r)=>{t({...e,format:`yaml+env`,yaml:x,env:v(S,{[n]:r})})},ce=e=>{L(t=>t.includes(e)?t:[...t,e])},le=n=>{let r=_[n];if(!r)return;let i={};r.fields.forEach(e=>{i[e.envKey]=``}),t({...e,format:`yaml+env`,yaml:x,env:v(S,i)}),L(e=>e.filter(e=>e!==n))},ue=n=>t({...e,format:`yaml+env`,yaml:n,env:S}),de=n=>t({...e,format:`yaml+env`,yaml:x,env:n}),fe=[...new Set(f.map(e=>e.group))];return(0,g.jsxs)(`div`,{className:`space-y-4`,children:[(0,g.jsxs)(l,{title:b(`configForm.modelConfig`),children:[(0,g.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 text-sm text-muted`,children:[(0,g.jsx)(`div`,{className:`font-medium text-foreground mb-1`,children:b(`configForm.proxyChain`)}),(0,g.jsx)(`p`,{children:b(`configForm.proxyChainDesc`)}),(0,g.jsxs)(`div`,{className:`mt-2 text-xs text-muted opacity-60 space-y-1`,children:[(0,g.jsxs)(`div`,{children:[`面板全局 provider:`,` `,j?.configured?(0,g.jsxs)(`span`,{className:`font-mono`,children:[j.providerId,j.selectedModelId?` · ${j.selectedModelId}`:``]}):(0,g.jsx)(r,{to:`/settings`,className:`text-amber-400 underline hover:text-amber-300`,children:`未配置`}),` `,(0,g.jsx)(r,{to:`/settings`,className:`text-[#0066FF] hover:text-[#0066FF]/80`,children:`(修改)`})]}),(0,g.jsx)(`div`,{className:`opacity-70`,children:`本实例 API key 留空 → 自动回退全局 key (src/services/llm-proxy/index.ts:137)`})]})]}),!P&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>F(!0),className:`text-xs text-[#0066FF] hover:text-[#0066FF]/80 transition-colors`,children:b(`configForm.editModelConfig`)}),P&&(0,g.jsx)(u,{label:b(`configForm.upstreamProvider`),hint:b(`configForm.upstreamProviderHint`),children:(0,g.jsxs)(d,{value:T,onChange:ae,children:[(0,g.jsx)(`option`,{value:``,children:b(`configForm.selectProvider`)}),!E&&T&&(0,g.jsxs)(`option`,{value:T,children:[T,` `,b(`configForm.custom`)]}),fe.map(e=>(0,g.jsx)(`optgroup`,{label:b(`configForm.providerGroup.${e}`,{defaultValue:e}),children:f.filter(t=>t.group===e).map(e=>(0,g.jsx)(`option`,{value:e.id,children:b(`configForm.providerLabel.${e.id}`,{defaultValue:e.label})},e.id))},e))]})}),P&&![`ollama`,`vllm`,`sglang`].includes(T)&&T&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(u,{label:b(`configForm.upstreamApiKey`),hint:w.hasApiKey&&!w.clearApiKey?b(`configForm.apiKeyHintSaved`):b(`configForm.apiKeyHintNew`),children:[(0,g.jsx)(te,{value:w.apiKey||``,saved:w.hasApiKey&&!w.clearApiKey,onChange:e=>H({apiKey:e,clearApiKey:!1}),baseUrl:w.baseUrl||f.find(e=>e.id===T)?.baseUrl||``,api:f.find(e=>e.id===T)?.api||``,authHeader:f.find(e=>e.id===T)?.authHeader?`x-api-key`:void 0,providerId:T,placeholder:b(`configForm.enterApiKey`),onModels:e=>{z(e),e.length>0&&!k&&W(e[0].id)},selectedModelId:k}),w.hasApiKey&&(0,g.jsx)(`button`,{type:`button`,onClick:()=>H({apiKey:``,clearApiKey:!w.clearApiKey}),className:`text-xs text-muted hover:text-foreground transition-colors mt-2`,children:w.clearApiKey?b(`configForm.restoreApiKey`):b(`configForm.clearApiKey`)})]}),(0,g.jsx)(u,{label:b(`configForm.selectedModel`),children:(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`div`,{className:`flex-1`,children:(0,g.jsxs)(d,{value:k,onChange:W,children:[(0,g.jsx)(`option`,{value:``,children:b(`configForm.selectModel`)}),O.map(e=>(0,g.jsxs)(`option`,{value:e.id,children:[e.name||e.id,e.contextWindow?` (${Math.round(e.contextWindow/1e3)}K)`:``]},e.id)),R.filter(e=>!O.some(t=>t.id===e.id)).map(e=>(0,g.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))]})}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>{oe()},disabled:B||!T,className:`px-3 py-2 border border-[var(--border)] text-muted rounded-md text-xs hover:bg-[var(--card-hover)] hover:text-foreground disabled:opacity-40 transition-colors`,children:B?b(`common:label.loading`,{defaultValue:`加载中`}):b(`configForm.fetchModels`,{defaultValue:`拉取模型`})})]})}),(0,g.jsx)(`button`,{type:`button`,onClick:()=>N(!M),className:`text-xs text-muted hover:text-foreground transition-colors`,children:b(M?`configForm.collapseAdvanced`:`configForm.advancedOptions`)}),M&&(0,g.jsxs)(`div`,{className:`space-y-4 border-t border-[var(--border)] pt-4`,children:[(0,g.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,g.jsx)(u,{label:b(`configForm.upstreamBaseUrl`),children:(0,g.jsx)(c,{value:w.baseUrl||``,onChange:e=>U(`baseUrl`,e),placeholder:b(`configForm.baseUrlPlaceholder`),mono:!0})}),(0,g.jsx)(u,{label:b(`configForm.upstreamApiProtocol`),children:(0,g.jsxs)(d,{value:w.api||`openai-completions`,onChange:e=>U(`api`,e),children:[(0,g.jsx)(`option`,{value:`openai-completions`,children:`OpenAI Compatible`}),(0,g.jsx)(`option`,{value:`openai-responses`,children:`OpenAI Responses`}),(0,g.jsx)(`option`,{value:`anthropic-messages`,children:`Anthropic Messages`}),(0,g.jsx)(`option`,{value:`google-generative-ai`,children:`Google Generative AI`}),(0,g.jsx)(`option`,{value:`ollama`,children:`Ollama`})]})})]}),k&&(0,g.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-4`,children:[(0,g.jsx)(u,{label:b(`configForm.modelId`),children:(0,g.jsx)(c,{value:A.id||``,onChange:e=>G({id:e}),placeholder:`model-id`,mono:!0})}),(0,g.jsx)(u,{label:b(`configForm.modelName`),children:(0,g.jsx)(c,{value:A.name||``,onChange:e=>G({name:e}),placeholder:`Model Name`})}),(0,g.jsx)(u,{label:b(`configForm.contextWindow`),children:(0,g.jsx)(c,{value:String(A.contextWindow||``),onChange:e=>G({contextWindow:parseInt(e,10)||0}),placeholder:`200000`,mono:!0})})]}),(0,g.jsx)(`div`,{className:`text-xs text-muted bg-[var(--card)] border border-[var(--border)] rounded-md p-3`,children:b(`configForm.proxyNote`)})]})]})]}),K.length>0&&(0,g.jsxs)(l,{title:b(`configForm.imChannelConfig`),children:[(0,g.jsxs)(`p`,{className:`text-xs text-muted`,children:[`Hermes 通过 `,(0,g.jsx)(`code`,{className:`font-mono text-[11px]`,children:`.env`}),` 环境变量读取消息平台凭证。 保存后重启实例生效。`]}),K.includes(`feishu`)&&(0,g.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:b(`configForm.channel.feishu`,{defaultValue:`飞书 / Lark`})}),(0,g.jsx)(`span`,{className:`text-[11px] text-muted font-mono`,children:`feishu`})]}),(0,g.jsx)(p,{instanceId:i,channelKey:`feishu`,existingAppId:Z||void 0,existingDomain:Z?se:void 0,onConfigured:Q})]}),K.includes(`weixin`)&&(0,g.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:b(`configForm.channel.weixin`,{defaultValue:`个人微信`})}),(0,g.jsx)(`span`,{className:`text-[11px] text-muted font-mono`,children:`weixin`})]}),(0,g.jsx)(m,{instanceId:i,onConfigured:Q})]}),(0,g.jsx)(`div`,{className:`space-y-3`,children:Y.map(e=>{let t=_[e];return t?(0,g.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]`,children:[(0,g.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,g.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:t.label}),(0,g.jsx)(`span`,{className:`text-[11px] text-muted font-mono`,children:e})]}),(0,g.jsx)(`button`,{onClick:()=>le(e),className:`text-xs text-red-400 hover:text-red-300 transition-colors`,children:b(`configForm.remove`)})]}),(0,g.jsx)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:t.fields.map(e=>{let t=C.get(e.envKey)||``;return(0,g.jsx)(u,{label:e.label,hint:e.hint||`.env: ${e.envKey}`,children:e.secret?(0,g.jsx)(s,{value:t,saved:!!t,onChange:t=>$(e.envKey,t),placeholder:e.placeholder}):(0,g.jsx)(c,{value:t,onChange:t=>$(e.envKey,t),placeholder:e.placeholder,mono:!0})},e.key)})})]},e):null})}),X.length>0&&(0,g.jsxs)(`div`,{className:`pt-2`,children:[(0,g.jsx)(`p`,{className:`text-xs text-muted mb-2`,children:b(`configForm.addImChannel`)}),(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:X.map(e=>(0,g.jsxs)(`button`,{onClick:()=>ce(e),className:`px-3 py-1.5 text-xs border border-dashed rounded-md transition-colors duration-150 border-[var(--border)] text-muted hover:border-[var(--border-hover)] hover:text-foreground`,children:[`+ `,_[e]?.label||e]},e))})]})]}),(0,g.jsxs)(l,{title:`高级 (原始 YAML + .env)`,defaultOpen:!1,children:[(0,g.jsx)(`p`,{className:`text-xs text-muted`,children:`直接编辑 YAML / .env。上方 Channels 字段与此处同步 — 任一侧修改都会反映到另一侧。`}),(0,g.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden`,children:[(0,g.jsx)(`div`,{className:`border-b border-[var(--border)] px-4 py-2`,children:(0,g.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:`config.yaml`})}),(0,g.jsx)(`textarea`,{value:x,onChange:e=>ue(e.target.value),className:`w-full font-mono text-[13px] p-4 min-h-[240px] focus:outline-none resize-y text-foreground bg-transparent`,spellCheck:!1})]}),(0,g.jsxs)(`div`,{className:`bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden`,children:[(0,g.jsx)(`div`,{className:`border-b border-[var(--border)] px-4 py-2`,children:(0,g.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:`.env`})}),(0,g.jsx)(`textarea`,{value:S,onChange:e=>de(e.target.value),className:`w-full font-mono text-[13px] p-4 min-h-[220px] focus:outline-none resize-y text-foreground bg-transparent`,spellCheck:!1})]})]})]})}export{y as HermesConfigForm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{a as t,t as n}from"./vendor-i18n-Df8aUdv8.js";import{t as r}from"./vendor-react-0L0rjmYG.js";import{c as i,xt as a}from"./api-C70Gt678.js";import{a as o,f as s,i as c,p as l}from"./index-Bs6DSbiR.js";var u=e(t(),1),d=r(),f=`w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2.5 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200`;function p({onDone:e}){let{t}=n(`auth`),[r,p]=(0,u.useState)(``),[m,h]=(0,u.useState)(``),[g,_]=(0,u.useState)(!1),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(!1),S=r.length>=8&&r===m;return(0,d.jsxs)(`div`,{className:`min-h-screen flex items-center justify-center p-4 bg-background relative overflow-hidden`,children:[(0,d.jsx)(`div`,{className:`grid-bg absolute inset-0 pointer-events-none`}),(0,d.jsx)(`div`,{className:`absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[500px] h-[300px] rounded-full bg-[#0066FF]/[0.07] blur-[90px] pointer-events-none`}),(0,d.jsx)(`div`,{className:`absolute left-4 bottom-4 z-20`,children:(0,d.jsx)(o,{className:`bg-card/80 backdrop-blur-sm`})}),(0,d.jsxs)(`div`,{className:`w-full max-w-sm relative z-10`,children:[(0,d.jsxs)(`div`,{className:`text-center mb-8`,children:[(0,d.jsx)(c,{className:`w-40 h-40 mx-auto mb-4 object-contain`}),(0,d.jsx)(`p`,{className:`text-sm text-muted mt-1`,children:t(`init.title`)})]}),(0,d.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),S){y(``),x(!0);try{a((await i(r)).token),e()}catch(e){y(e.message||t(`init.failed`))}finally{x(!1)}}},className:`space-y-4`,children:[v&&(0,d.jsx)(`div`,{className:`bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-3 py-2.5`,children:v}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-sm font-medium text-muted mb-1.5`,children:t(`init.password`)}),(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`input`,{type:g?`text`:`password`,value:r,onChange:e=>p(e.target.value),placeholder:t(`init.passwordPlaceholder`),className:`${f} pr-10`,autoFocus:!0}),(0,d.jsx)(`button`,{type:`button`,onClick:()=>_(!g),"aria-label":t(`common:action.togglePassword`),className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors duration-200`,children:g?(0,d.jsx)(l,{}):(0,d.jsx)(s,{})})]})]}),(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`label`,{className:`block text-sm font-medium text-muted mb-1.5`,children:t(`init.confirm`)}),(0,d.jsx)(`input`,{type:g?`text`:`password`,value:m,onChange:e=>h(e.target.value),placeholder:t(`init.confirmPlaceholder`),className:f}),r&&m&&r!==m&&(0,d.jsx)(`p`,{className:`text-red-400 text-xs mt-1.5`,children:t(`init.mismatch`)})]}),(0,d.jsx)(`button`,{type:`submit`,disabled:b||!S,className:`w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]`,children:b?(0,d.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,d.jsx)(`span`,{className:`w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin`}),t(`init.loading`)]}):t(`init.submit`)})]})]})]})}export{p as default};
|