bailinghub 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +42 -0
- package/.env.example +83 -0
- package/.gitignore +44 -0
- package/.npmignore +56 -0
- package/CODE_OF_CONDUCT.md +24 -0
- package/CONTRIBUTING.md +74 -0
- package/Dockerfile +16 -0
- package/LICENSE +176 -0
- package/LICENSING.md +9 -0
- package/NOTICE +23 -0
- package/README.en.md +264 -0
- package/README.md +279 -0
- package/SECURITY.md +30 -0
- package/THIRD_PARTY_NOTICES.md +254 -0
- package/VISION.md +41 -0
- package/assets/architecture-overview.en-dark.png +0 -0
- package/assets/architecture-overview.en-dark.svg +57 -0
- package/assets/architecture-overview.en.png +0 -0
- package/assets/architecture-overview.en.svg +57 -0
- package/assets/architecture-overview.zh-CN-dark.png +0 -0
- package/assets/architecture-overview.zh-CN-dark.svg +57 -0
- package/assets/architecture-overview.zh-CN.png +0 -0
- package/assets/architecture-overview.zh-CN.svg +57 -0
- package/assets/bailinghub-lockup-dark.png +0 -0
- package/assets/bailinghub-lockup-dark.svg +8 -0
- package/assets/bailinghub-lockup.png +0 -0
- package/assets/bailinghub-lockup.svg +8 -0
- package/brain/README.en.md +23 -0
- package/brain/README.md +45 -0
- package/brain/agents/code-review.md +41 -0
- package/brain/agents/triage.md +37 -0
- package/brain/profiles.json +114 -0
- package/brain/runbooks/ticket-triage.md +24 -0
- package/config.example.json +58 -0
- package/contracts/client-api/consumers.json +28 -0
- package/contracts/client-api/v1/error-response.schema.json +21 -0
- package/contracts/client-api/v1/health-response.schema.json +13 -0
- package/contracts/client-api/v1/job-response.schema.json +49 -0
- package/contracts/client-api/v1/manifest.json +63 -0
- package/contracts/client-api/v1/run-request.schema.json +42 -0
- package/contracts/client-api/v1/submit-response.schema.json +35 -0
- package/contracts/client-api/v1/vectors.json +153 -0
- package/demo/business/Dockerfile +8 -0
- package/demo/business/server.mjs +483 -0
- package/docker-compose.images.yml +67 -0
- package/docker-compose.yml +79 -0
- package/docs/AI_FRIENDLY_TOOLS.en.md +69 -0
- package/docs/AI/345/217/213/345/245/275/345/267/245/345/205/267/350/256/276/350/256/241/346/214/207/345/215/227.md +198 -0
- package/docs/ARCHITECTURE.en.md +81 -0
- package/docs/ARCHITECTURE.md +795 -0
- package/docs/CHANGELOG.en.md +275 -0
- package/docs/CHANGELOG.md +279 -0
- package/docs/CHANNELS.en.md +35 -0
- package/docs/CHANNELS.md +72 -0
- package/docs/CLIENT_API.md +89 -0
- package/docs/COMPATIBILITY.en.md +103 -0
- package/docs/CONTRACT.en.md +254 -0
- package/docs/CONTRACT.md +653 -0
- package/docs/DEMO.en.md +90 -0
- package/docs/DEMO.md +297 -0
- package/docs/ECOSYSTEM.en.md +39 -0
- package/docs/ECOSYSTEM.md +39 -0
- package/docs/INDEPENDENT_VALIDATION.en.md +184 -0
- package/docs/INDEPENDENT_VALIDATION.md +184 -0
- package/docs/INTEGRATION.en.md +120 -0
- package/docs/KERNEL_HOST_API.en.md +59 -0
- package/docs/KERNEL_HOST_API.md +59 -0
- package/docs/OPERATIONS.en.md +182 -0
- package/docs/OPERATIONS.md +231 -0
- package/docs/PIPELINE.en.md +74 -0
- package/docs/PIPELINE.md +67 -0
- package/docs/QUICKSTART.en.md +297 -0
- package/docs/QUICKSTART.md +152 -0
- package/docs/README.en.md +103 -0
- package/docs/README.md +119 -0
- package/docs/RELEASE_NOTES_v0.1.0.en.md +46 -0
- package/docs/RELEASE_NOTES_v0.1.0.md +66 -0
- package/docs/RELEASE_NOTES_v0.1.1.en.md +38 -0
- package/docs/RELEASE_NOTES_v0.1.1.md +38 -0
- package/docs/RELEASE_NOTES_v0.1.10.en.md +102 -0
- package/docs/RELEASE_NOTES_v0.1.10.md +102 -0
- package/docs/RELEASE_NOTES_v0.1.11.en.md +99 -0
- package/docs/RELEASE_NOTES_v0.1.11.md +99 -0
- package/docs/RELEASE_NOTES_v0.1.12.en.md +64 -0
- package/docs/RELEASE_NOTES_v0.1.12.md +64 -0
- package/docs/RELEASE_NOTES_v0.1.13.en.md +46 -0
- package/docs/RELEASE_NOTES_v0.1.13.md +46 -0
- package/docs/RELEASE_NOTES_v0.1.14.en.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.14.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.15.en.md +50 -0
- package/docs/RELEASE_NOTES_v0.1.15.md +50 -0
- package/docs/RELEASE_NOTES_v0.1.16.en.md +106 -0
- package/docs/RELEASE_NOTES_v0.1.16.md +105 -0
- package/docs/RELEASE_NOTES_v0.1.2.en.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.2.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.3.en.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.3.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.4.en.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.4.md +55 -0
- package/docs/RELEASE_NOTES_v0.1.5.en.md +49 -0
- package/docs/RELEASE_NOTES_v0.1.5.md +49 -0
- package/docs/RELEASE_NOTES_v0.1.6.en.md +41 -0
- package/docs/RELEASE_NOTES_v0.1.6.md +41 -0
- package/docs/RELEASE_NOTES_v0.1.7.en.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.7.md +39 -0
- package/docs/RELEASE_NOTES_v0.1.8.en.md +88 -0
- package/docs/RELEASE_NOTES_v0.1.8.md +88 -0
- package/docs/RELEASE_NOTES_v0.1.9.en.md +127 -0
- package/docs/RELEASE_NOTES_v0.1.9.md +127 -0
- package/docs/RELEASE_NOTES_v0.2.0.en.md +95 -0
- package/docs/RELEASE_NOTES_v0.2.0.md +96 -0
- package/docs/RELEASE_NOTES_v0.3.0.en.md +77 -0
- package/docs/RELEASE_NOTES_v0.3.0.md +77 -0
- package/docs/SDK.en.md +177 -0
- package/docs/STREAMING.en.md +78 -0
- package/docs/STREAMING.md +109 -0
- package/docs/TOOLS.en.md +205 -0
- package/docs/TOOLS_DESIGN.en.md +142 -0
- package/docs/TOOLS_DESIGN.md +466 -0
- package/docs/TOOLS_MODEL.en.md +56 -0
- package/docs/TOOLS_MODEL.md +903 -0
- package/docs/WIDGET_RENDERERS.en.md +133 -0
- package/docs/WIDGET_RENDERERS.md +139 -0
- package/docs/examples/bailing-tool-verify.mjs +94 -0
- package/docs/examples/bailing-tool-verify.php +154 -0
- package/docs/examples/bailing-tool-verify.py +107 -0
- package/docs/examples/custom-streaming-chat-client.mjs +108 -0
- package/docs/examples/widget-chart-renderer-adapter.mjs +44 -0
- package/docs/integrations/bailian/README.en.md +181 -0
- package/docs/integrations/bailian/README.md +165 -0
- package/docs/integrations/bailian/bailian-mcp-config.json +17 -0
- package/docs/integrations/bailian/verify_recipe.py +97 -0
- package/docs/integrations/deepseek/README.en.md +225 -0
- package/docs/integrations/deepseek/README.md +225 -0
- package/docs/integrations/deepseek/verify_e2e.py +131 -0
- package/docs/integrations/dify/README.en.md +131 -0
- package/docs/integrations/dify/README.md +131 -0
- package/docs/integrations/dify/bailinghub-control-plane.openapi.json +129 -0
- package/docs/integrations/dify/verify_contract.py +88 -0
- package/docs/integrations/dify/verify_e2e.py +117 -0
- package/docs/integrations/jeecgboot/README.en.md +193 -0
- package/docs/integrations/jeecgboot/README.md +161 -0
- package/docs/integrations/jeecgboot/adapter-contract.v1.json +94 -0
- package/docs/integrations/jeecgboot/jeecgboot-user-adapter.openapi.json +183 -0
- package/docs/integrations/jeecgboot/verify_recipe.mjs +97 -0
- package/docs/integrations/ruoyi-vue-pro/README.en.md +91 -0
- package/docs/integrations/ruoyi-vue-pro/README.md +155 -0
- package/docs/integrations/ruoyi-vue-pro/adapter-contract.v1.json +71 -0
- package/docs/integrations/ruoyi-vue-pro/ruoyi-vue-pro-trade-adapter.openapi.json +148 -0
- package/docs/integrations/ruoyi-vue-pro/verify_recipe.mjs +71 -0
- package/docs/user-guide/README.en.md +39 -0
- package/docs/user-guide/README.md +40 -0
- package/docs/user-guide/concepts.en.md +69 -0
- package/docs/user-guide/concepts.md +225 -0
- package/docs/user-guide/console-map.en.md +58 -0
- package/docs/user-guide/console-map.md +473 -0
- package/docs/user-guide/overview.en.md +61 -0
- package/docs/user-guide/overview.md +156 -0
- package/docs/user-guide/scenarios.en.md +70 -0
- package/docs/user-guide/scenarios.md +398 -0
- package/docs//345/205/274/345/256/271/346/200/247/344/270/216/345/215/207/347/272/247.md +134 -0
- package/docs//347/254/254/344/270/211/346/226/271/345/257/271/346/216/245/346/214/207/345/215/227.md +625 -0
- package/package.json +119 -0
- package/schemas/agent-capability-contract.schema.json +104 -0
- package/schemas/api/approval-decision.schema.json +28 -0
- package/schemas/api/approval-request.schema.json +31 -0
- package/schemas/api/delivery-callback.schema.json +28 -0
- package/schemas/api/job-response.schema.json +6 -0
- package/schemas/api/kb-doc-upsert.schema.json +21 -0
- package/schemas/api/run-request.schema.json +6 -0
- package/schemas/api/run-response.schema.json +6 -0
- package/schemas/api/tool-spec.schema.json +38 -0
- package/schemas/config/alert-rule.schema.json +22 -0
- package/schemas/config/channel.schema.json +91 -0
- package/schemas/config/chat-entry.schema.json +47 -0
- package/schemas/config/client.schema.json +56 -0
- package/schemas/config/common.schema.json +215 -0
- package/schemas/config/credential.schema.json +48 -0
- package/schemas/config/executor-token.schema.json +20 -0
- package/schemas/config/page-context.schema.json +21 -0
- package/schemas/config/route.schema.json +152 -0
- package/schemas/config/storage-bucket.schema.json +31 -0
- package/schemas/config/target.schema.json +17 -0
- package/schemas/config/tool-provider.schema.json +60 -0
- package/schemas/tool-definition.schema.json +188 -0
- package/scripts/check-client-api-ecosystem.mjs +69 -0
- package/scripts/check-doc-links.mjs +136 -0
- package/scripts/check-image-tags.sh +43 -0
- package/scripts/check-package-artifact.mjs +185 -0
- package/scripts/check-release-consistency.mjs +199 -0
- package/scripts/check-release-consistency.test.mjs +63 -0
- package/scripts/client-api-contract-test.ts +127 -0
- package/scripts/create-admin.ts +27 -0
- package/scripts/demo-e2e.ts +133 -0
- package/scripts/docker-entrypoint.sh +33 -0
- package/scripts/doctor.ts +107 -0
- package/scripts/e2e-console.mjs +214 -0
- package/scripts/export-oss.mjs +204 -0
- package/scripts/generate-readme-assets.mjs +181 -0
- package/scripts/generate-third-party-notices.mjs +93 -0
- package/scripts/image-release-policy.mjs +75 -0
- package/scripts/image-release-policy.test.mjs +58 -0
- package/scripts/init-db.ts +21 -0
- package/scripts/install.sh +461 -0
- package/scripts/oss-boundary-check.mjs +183 -0
- package/scripts/publish-images.sh +63 -0
- package/scripts/publish-mysql-image.sh +41 -0
- package/scripts/release-audit.mjs +348 -0
- package/scripts/sdk-contract-test.ts +62 -0
- package/scripts/sdk-p1-check.mjs +58 -0
- package/scripts/sdk-runtime-test.mjs +106 -0
- package/scripts/security-scan.mjs +110 -0
- package/scripts/seed-demo.ts +116 -0
- package/scripts/selftest.ts +226 -0
- package/scripts/smoke.ts +31 -0
- package/scripts/validate-examples.mjs +93 -0
- package/scripts/verify-bootstrap-admin-restart.ts +66 -0
- package/scripts/verify-github-repo.mjs +195 -0
- package/scripts/verify-oss-export.mjs +192 -0
- package/scripts/verify-routing.ts +29 -0
- package/scripts/widget-renderer-test.mjs +206 -0
- package/scripts/write-build-info.mjs +29 -0
- package/sdk/dotnet/Bailing.Connect/Bailing.Connect.csproj +12 -0
- package/sdk/dotnet/Bailing.Connect/BailingConnect.cs +260 -0
- package/sdk/dotnet/README.md +32 -0
- package/sdk/dotnet/examples/BuildSpec/BuildSpec.csproj +11 -0
- package/sdk/dotnet/examples/BuildSpec/Program.cs +36 -0
- package/sdk/go/README.md +33 -0
- package/sdk/go/bailingconnect/connect.go +367 -0
- package/sdk/go/examples/build-spec/main.go +39 -0
- package/sdk/go/go.mod +3 -0
- package/sdk/java/README.md +43 -0
- package/sdk/java/examples/BuildSpec.java +31 -0
- package/sdk/java/src/main/java/com/bailing/connect/BailingConnect.java +376 -0
- package/sdk/node/README.md +107 -0
- package/sdk/node/examples/build-spec.mjs +84 -0
- package/sdk/node/package.json +22 -0
- package/sdk/node/src/index.mjs +250 -0
- package/sdk/php/README.md +204 -0
- package/sdk/php/composer.json +18 -0
- package/sdk/php/examples/DemoStaffController.php +108 -0
- package/sdk/php/examples/build-spec.php +27 -0
- package/sdk/php/examples/thinkphp-integration.php +81 -0
- package/sdk/php/src/Attributes/AiParam.php +40 -0
- package/sdk/php/src/Attributes/AiTool.php +75 -0
- package/sdk/php/src/HubClient.php +122 -0
- package/sdk/php/src/SpecBuilder.php +328 -0
- package/sdk/php/src/SpecServer.php +209 -0
- package/sdk/php/src/Ticket.php +37 -0
- package/sdk/php/src/Verify.php +178 -0
- package/sdk/php7/README.md +191 -0
- package/sdk/php7/composer.json +18 -0
- package/sdk/php7/examples/build-spec.php +68 -0
- package/sdk/php7/examples/well-known.php +33 -0
- package/sdk/php7/src/HubClient.php +111 -0
- package/sdk/php7/src/SpecServer.php +203 -0
- package/sdk/php7/src/Ticket.php +33 -0
- package/sdk/php7/src/ToolDef.php +169 -0
- package/sdk/php7/src/ToolSpec.php +334 -0
- package/sdk/php7/src/Verify.php +165 -0
- package/sdk/python/README.md +107 -0
- package/sdk/python/bailing_connect/__init__.py +307 -0
- package/sdk/python/examples/build_spec.py +90 -0
- package/sdk/python/pyproject.toml +24 -0
- package/sql/001_init_state.sql +66 -0
- package/sql/002_routes.sql +44 -0
- package/sql/003_executor.sql +15 -0
- package/sql/004_clients.sql +22 -0
- package/sql/005_admins.sql +25 -0
- package/sql/006_ledger.sql +57 -0
- package/sql/007_delivery.sql +8 -0
- package/sql/008_kb.sql +66 -0
- package/sql/009_rbac.sql +5 -0
- package/sql/010_targets.sql +28 -0
- package/sql/011_observability.sql +11 -0
- package/sql/012_generic.sql +5 -0
- package/sql/013_tools.sql +24 -0
- package/sql/014_approvals.sql +27 -0
- package/sql/015_chat.sql +21 -0
- package/sql/016_chat_feedback.sql +19 -0
- package/sql/017_provider_autorefresh.sql +6 -0
- package/sql/018_kb_ingest.sql +11 -0
- package/sql/019_kb_datasources.sql +32 -0
- package/sql/022_storage_buckets.sql +25 -0
- package/sql/024_channels.sql +15 -0
- package/sql/025_chat_appearance.sql +7 -0
- package/sql/026_thread_memory.sql +10 -0
- package/sql/027_page_contexts.sql +23 -0
- package/sql/028_executor_capabilities.sql +4 -0
- package/sql/029_executor_tokens.sql +13 -0
- package/sql/030_route_permission.sql +5 -0
- package/sql/031_tool_embeddings.sql +20 -0
- package/sql/032_tool_provider_embed.sql +7 -0
- package/sql/033_alert_rules.sql +21 -0
- package/sql/034_client_allowed_channels.sql +6 -0
- package/sql/035_tool_idempotency.sql +15 -0
- package/sql/036_delivery_dlq.sql +15 -0
- package/sql/038_audit_trace_shape.sql +15 -0
- package/sql/039_runtime_locks.sql +9 -0
- package/sql/040_budget_policy.sql +3 -0
- package/sql/041_approval_intent.sql +14 -0
- package/sql/042_approval_decision_contract.sql +11 -0
- package/sql/043_rate_limits.sql +7 -0
- package/sql/044_job_run_after.sql +3 -0
- package/sql/045_job_claim_lease.sql +7 -0
- package/sql/046_tool_authz_probe.sql +5 -0
- package/sql/047_route_audience.sql +4 -0
- package/sql/048_llm_target.sql +17 -0
- package/sql/049_llm_input_shape.sql +11 -0
- package/sql/050_operational_metrics_indexes.sql +8 -0
- package/sql/051_instance_branding.sql +17 -0
- package/sql/052_tool_execution_journal.sql +19 -0
- package/sql/053_tool_spec_access_policy.sql +9 -0
- package/sql/README.en.md +41 -0
- package/sql/README.md +40 -0
- package/src/adapters/channels/wecom-api.test.ts +77 -0
- package/src/adapters/channels/wecom-api.ts +224 -0
- package/src/adapters/channels/wecom-crypto.test.ts +85 -0
- package/src/adapters/channels/wecom-crypto.ts +77 -0
- package/src/adapters/executors/claudecode.ts +39 -0
- package/src/adapters/executors/profiles.ts +86 -0
- package/src/adapters/executors/report.ts +35 -0
- package/src/adapters/executors/runner.ts +114 -0
- package/src/adapters/executors/wecomnotify.ts +63 -0
- package/src/adapters/llm/file.test.ts +81 -0
- package/src/adapters/llm/file.ts +250 -0
- package/src/adapters/llm/openai-chat-stream.test.ts +74 -0
- package/src/adapters/llm/openai-chat-stream.ts +154 -0
- package/src/adapters/llm/perception.ts +159 -0
- package/src/adapters/llm/speech.test.ts +75 -0
- package/src/adapters/llm/speech.ts +146 -0
- package/src/adapters/storage/object-storage.test.ts +38 -0
- package/src/adapters/storage/object-storage.ts +140 -0
- package/src/adapters/targets/demo-agent.ts +88 -0
- package/src/adapters/targets/llm.test.ts +733 -0
- package/src/adapters/targets/llm.ts +862 -0
- package/src/app/admin-bootstrap.test.ts +112 -0
- package/src/app/admin-bootstrap.ts +48 -0
- package/src/app/auth-default.ts +26 -0
- package/src/app/auth.test.ts +57 -0
- package/src/app/auth.ts +207 -0
- package/src/app/builtin-tools-default.ts +17 -0
- package/src/app/builtin-tools.test.ts +202 -0
- package/src/app/builtin-tools.ts +380 -0
- package/src/app/channels-default.ts +8 -0
- package/src/app/channels.ts +141 -0
- package/src/app/delivery-default.ts +14 -0
- package/src/app/delivery.test.ts +46 -0
- package/src/app/delivery.ts +215 -0
- package/src/app/engine-default.ts +54 -0
- package/src/app/engine.ts +427 -0
- package/src/app/http-mount.test.ts +27 -0
- package/src/app/http-server.test.ts +114 -0
- package/src/app/http-server.ts +127 -0
- package/src/app/http.test.ts +27 -0
- package/src/app/http.ts +118 -0
- package/src/app/kernel.test.ts +191 -0
- package/src/app/kernel.ts +544 -0
- package/src/app/monitor-default.ts +9 -0
- package/src/app/monitor.ts +46 -0
- package/src/app/operational-metrics.test.ts +73 -0
- package/src/app/operational-metrics.ts +124 -0
- package/src/app/oss-edition.test.ts +71 -0
- package/src/app/oss-edition.ts +108 -0
- package/src/app/outbound-default.ts +57 -0
- package/src/app/outbound.ts +133 -0
- package/src/app/readiness.test.ts +37 -0
- package/src/app/readiness.ts +39 -0
- package/src/app/runtime-composition.test.ts +51 -0
- package/src/app/runtime-composition.ts +73 -0
- package/src/app/runtime-context-default.ts +30 -0
- package/src/app/runtime-context.test.ts +60 -0
- package/src/app/runtime-context.ts +79 -0
- package/src/app/runtime-lifecycle-default.ts +48 -0
- package/src/app/runtime-lifecycle.test.ts +322 -0
- package/src/app/runtime-lifecycle.ts +440 -0
- package/src/app/runtime.ts +36 -0
- package/src/app/tool-approvals-default.ts +16 -0
- package/src/app/tool-approvals.ts +214 -0
- package/src/app/tool-assembly-default.ts +11 -0
- package/src/app/tool-assembly.test.ts +112 -0
- package/src/app/tool-assembly.ts +83 -0
- package/src/app/tool-context-default.ts +7 -0
- package/src/app/tool-context.test.ts +82 -0
- package/src/app/tool-context.ts +109 -0
- package/src/app/tool-debug.test.ts +111 -0
- package/src/app/tool-debug.ts +152 -0
- package/src/app/tool-proxy-default.ts +35 -0
- package/src/app/tool-proxy.ts +173 -0
- package/src/app/tool-specs-default.ts +33 -0
- package/src/app/tool-specs.test.ts +322 -0
- package/src/app/tool-specs.ts +555 -0
- package/src/app/tools-runtime-default.ts +14 -0
- package/src/app/tools-runtime.ts +23 -0
- package/src/architecture-boundary.test.ts +119 -0
- package/src/core/config/config-codec.test.ts +105 -0
- package/src/core/config/config-codec.ts +231 -0
- package/src/core/config/config-diagnostics.test.ts +285 -0
- package/src/core/config/config-diagnostics.ts +436 -0
- package/src/core/config/config-models.test.ts +584 -0
- package/src/core/config/config-models.ts +392 -0
- package/src/core/config/config-schema.test.ts +153 -0
- package/src/core/config/config.test.ts +314 -0
- package/src/core/config/config.ts +324 -0
- package/src/core/config/route-config.test.ts +232 -0
- package/src/core/config/route-config.ts +246 -0
- package/src/core/config/target-config.test.ts +139 -0
- package/src/core/config/target-config.ts +219 -0
- package/src/core/config/tools-config.test.ts +124 -0
- package/src/core/config/tools-config.ts +126 -0
- package/src/core/contracts/approval-decision.test.ts +67 -0
- package/src/core/contracts/approval-decision.ts +93 -0
- package/src/core/contracts/openapi-tools.ts +201 -0
- package/src/core/contracts/tool-annotations.ts +121 -0
- package/src/core/contracts/tool-definition.test.ts +147 -0
- package/src/core/contracts/tool-definition.ts +304 -0
- package/src/core/contracts/tools-idempotency.test.ts +435 -0
- package/src/core/contracts/tools.test.ts +487 -0
- package/src/core/contracts/tools.ts +831 -0
- package/src/core/contracts/types.ts +408 -0
- package/src/core/edition/capabilities.ts +6 -0
- package/src/core/edition/context.test.ts +20 -0
- package/src/core/edition/context.ts +78 -0
- package/src/core/edition/index.ts +4 -0
- package/src/core/edition/scope-resolver.ts +24 -0
- package/src/core/edition/store-factory.ts +6 -0
- package/src/core/observability/openmetrics.test.ts +57 -0
- package/src/core/observability/openmetrics.ts +103 -0
- package/src/core/platform/content.test.ts +46 -0
- package/src/core/platform/content.ts +90 -0
- package/src/core/platform/fence.test.ts +31 -0
- package/src/core/platform/fence.ts +11 -0
- package/src/core/platform/instance-branding.test.ts +65 -0
- package/src/core/platform/instance-branding.ts +202 -0
- package/src/core/platform/metrics-token.test.ts +31 -0
- package/src/core/platform/metrics-token.ts +42 -0
- package/src/core/platform/pagecontext.ts +0 -0
- package/src/core/platform/password.test.ts +13 -0
- package/src/core/platform/password.ts +38 -0
- package/src/core/platform/queue.test.ts +59 -0
- package/src/core/platform/queue.ts +75 -0
- package/src/core/platform/serial.test.ts +73 -0
- package/src/core/platform/serial.ts +64 -0
- package/src/core/platform/server-token.test.ts +46 -0
- package/src/core/platform/server-token.ts +60 -0
- package/src/core/platform/signing.test.ts +24 -0
- package/src/core/platform/signing.ts +22 -0
- package/src/core/platform/time.ts +73 -0
- package/src/core/platform/version.test.ts +19 -0
- package/src/core/platform/version.ts +90 -0
- package/src/core/runtime/budget-runtime.test.ts +93 -0
- package/src/core/runtime/budget-runtime.ts +110 -0
- package/src/core/runtime/context-runtime.test.ts +106 -0
- package/src/core/runtime/context-runtime.ts +95 -0
- package/src/core/runtime/credential-resolver.test.ts +129 -0
- package/src/core/runtime/credential-resolver.ts +93 -0
- package/src/core/runtime/credential-verify.test.ts +76 -0
- package/src/core/runtime/credential-verify.ts +161 -0
- package/src/core/runtime/debug-report.test.ts +20 -0
- package/src/core/runtime/debug-report.ts +100 -0
- package/src/core/runtime/execution-runtime.test.ts +350 -0
- package/src/core/runtime/execution-runtime.ts +197 -0
- package/src/core/runtime/finish-runtime.test.ts +168 -0
- package/src/core/runtime/finish-runtime.ts +83 -0
- package/src/core/runtime/identity-runtime.test.ts +38 -0
- package/src/core/runtime/identity-runtime.ts +104 -0
- package/src/core/runtime/inhub-runtime.test.ts +297 -0
- package/src/core/runtime/inhub-runtime.ts +198 -0
- package/src/core/runtime/job-stream.test.ts +55 -0
- package/src/core/runtime/job-stream.ts +187 -0
- package/src/core/runtime/knowledge-runtime.test.ts +120 -0
- package/src/core/runtime/knowledge-runtime.ts +98 -0
- package/src/core/runtime/launch-runtime.test.ts +187 -0
- package/src/core/runtime/launch-runtime.ts +182 -0
- package/src/core/runtime/memory-runtime.test.ts +85 -0
- package/src/core/runtime/memory-runtime.ts +32 -0
- package/src/core/runtime/memory.ts +141 -0
- package/src/core/runtime/redaction-runtime.test.ts +35 -0
- package/src/core/runtime/redaction-runtime.ts +60 -0
- package/src/core/runtime/routing-runtime.test.ts +89 -0
- package/src/core/runtime/routing-runtime.ts +146 -0
- package/src/core/runtime/smoke-runtime.test.ts +65 -0
- package/src/core/runtime/smoke-runtime.ts +237 -0
- package/src/core/runtime/summary-runtime.test.ts +234 -0
- package/src/core/runtime/summary-runtime.ts +153 -0
- package/src/core/runtime/trace-runtime.test.ts +234 -0
- package/src/core/runtime/trace-runtime.ts +330 -0
- package/src/core/state/audit-observability.test.ts +51 -0
- package/src/core/state/audit-observability.ts +74 -0
- package/src/core/state/state-codec.ts +44 -0
- package/src/core/state/state-contracts.ts +59 -0
- package/src/core/targets/adapter.ts +69 -0
- package/src/core/targets/registry.test.ts +65 -0
- package/src/core/targets/registry.ts +153 -0
- package/src/core/targets/resolve.ts +21 -0
- package/src/executor.ts +201 -0
- package/src/extension-api.test.ts +84 -0
- package/src/extension-api.ts +194 -0
- package/src/infrastructure/config/config-admin-repository.test.ts +193 -0
- package/src/infrastructure/config/config-admin-repository.ts +175 -0
- package/src/infrastructure/config/config-alert-rule-repository.ts +38 -0
- package/src/infrastructure/config/config-approval-ledger.ts +74 -0
- package/src/infrastructure/config/config-channel-repository.ts +31 -0
- package/src/infrastructure/config/config-chat-repository.ts +83 -0
- package/src/infrastructure/config/config-client-repository.ts +46 -0
- package/src/infrastructure/config/config-conversation-ledger.ts +222 -0
- package/src/infrastructure/config/config-credential-repository.test.ts +32 -0
- package/src/infrastructure/config/config-credential-repository.ts +47 -0
- package/src/infrastructure/config/config-delivery-dlq-ledger.ts +49 -0
- package/src/infrastructure/config/config-executor-ledger.ts +30 -0
- package/src/infrastructure/config/config-executor-token-repository.ts +44 -0
- package/src/infrastructure/config/config-instance-branding-repository.ts +75 -0
- package/src/infrastructure/config/config-knowledge-repository.ts +249 -0
- package/src/infrastructure/config/config-observability-ledger.ts +262 -0
- package/src/infrastructure/config/config-project-repository.ts +30 -0
- package/src/infrastructure/config/config-rate-limit-ledger.ts +56 -0
- package/src/infrastructure/config/config-route-repository.ts +41 -0
- package/src/infrastructure/config/config-storage-bucket-repository.ts +43 -0
- package/src/infrastructure/config/config-target-repository.ts +25 -0
- package/src/infrastructure/config/config-tool-call-ledger.ts +142 -0
- package/src/infrastructure/config/config-tool-embedding-repository.test.ts +124 -0
- package/src/infrastructure/config/config-tool-embedding-repository.ts +78 -0
- package/src/infrastructure/config/config-tool-provider-repository.test.ts +71 -0
- package/src/infrastructure/config/config-tool-provider-repository.ts +50 -0
- package/src/infrastructure/config/configstore.ts +130 -0
- package/src/infrastructure/config/local-instance-branding-provider.test.ts +94 -0
- package/src/infrastructure/config/local-instance-branding-provider.ts +79 -0
- package/src/infrastructure/mysql/pool-owner.test.ts +36 -0
- package/src/infrastructure/mysql/pool-owner.ts +56 -0
- package/src/infrastructure/schema/core-schema-migrator.test.ts +340 -0
- package/src/infrastructure/schema/core-schema-migrator.ts +461 -0
- package/src/infrastructure/schema/migration-files.test.ts +18 -0
- package/src/infrastructure/schema/migration-files.ts +27 -0
- package/src/infrastructure/schema/retired-migrations.ts +35 -0
- package/src/infrastructure/state/operational-metrics-storage.test.ts +107 -0
- package/src/infrastructure/state/state-jsonl.ts +268 -0
- package/src/infrastructure/state/state-mysql-update-plan.test.ts +54 -0
- package/src/infrastructure/state/state-mysql-update-plan.ts +63 -0
- package/src/infrastructure/state/state-mysql.ts +359 -0
- package/src/infrastructure/state/state.test.ts +319 -0
- package/src/infrastructure/state/state.ts +11 -0
- package/src/kernel-api/v1/artifact.test.ts +46 -0
- package/src/kernel-api/v1/artifact.ts +71 -0
- package/src/kernel-api/v1/contracts.ts +168 -0
- package/src/kernel-api/v1/execution-gate.test.ts +25 -0
- package/src/kernel-api/v1/execution-gate.ts +18 -0
- package/src/kernel-api/v1/index.ts +51 -0
- package/src/openclaw-stdio.test.ts +60 -0
- package/src/routes/admin-access-default.ts +20 -0
- package/src/routes/admin-access.ts +94 -0
- package/src/routes/admin-branding.test.ts +116 -0
- package/src/routes/admin-branding.ts +48 -0
- package/src/routes/admin-chat-default.ts +12 -0
- package/src/routes/admin-chat.ts +84 -0
- package/src/routes/admin-default.ts +35 -0
- package/src/routes/admin-dispatch-config-default.ts +13 -0
- package/src/routes/admin-dispatch-config.ts +121 -0
- package/src/routes/admin-format.ts +12 -0
- package/src/routes/admin-host.test.ts +56 -0
- package/src/routes/admin-infra-default.ts +12 -0
- package/src/routes/admin-infra.ts +142 -0
- package/src/routes/admin-kb-default.ts +13 -0
- package/src/routes/admin-kb.ts +160 -0
- package/src/routes/admin-runtime-default.ts +31 -0
- package/src/routes/admin-runtime.ts +444 -0
- package/src/routes/admin-tool-providers-default.ts +20 -0
- package/src/routes/admin-tool-providers.test.ts +114 -0
- package/src/routes/admin-tool-providers.ts +186 -0
- package/src/routes/admin.ts +246 -0
- package/src/routes/approvals-default.ts +32 -0
- package/src/routes/approvals.ts +120 -0
- package/src/routes/chat-default.ts +61 -0
- package/src/routes/chat-mount.test.ts +58 -0
- package/src/routes/chat.test.ts +222 -0
- package/src/routes/chat.ts +478 -0
- package/src/routes/critical-routes.test.ts +292 -0
- package/src/routes/executor-default.ts +45 -0
- package/src/routes/executor.ts +226 -0
- package/src/routes/kb-default.ts +23 -0
- package/src/routes/kb.ts +92 -0
- package/src/routes/private-default.ts +38 -0
- package/src/routes/private-host-auth.test.ts +84 -0
- package/src/routes/private.ts +210 -0
- package/src/routes/public-default.ts +46 -0
- package/src/routes/public.test.ts +504 -0
- package/src/routes/public.ts +313 -0
- package/src/routes/run-default.ts +25 -0
- package/src/routes/run.ts +188 -0
- package/src/routes/send-default.ts +24 -0
- package/src/routes/send.ts +143 -0
- package/src/routes/wecom-default.ts +27 -0
- package/src/routes/wecom.ts +307 -0
- package/src/server.ts +13 -0
- package/src/services/embedding.test.ts +185 -0
- package/src/services/embedding.ts +138 -0
- package/src/services/kb-repository.ts +79 -0
- package/src/services/kb.ts +328 -0
- package/src/services/kbsync.ts +166 -0
- package/src/services/tool-index-repository.ts +50 -0
- package/src/services/tools-index.test.ts +756 -0
- package/src/services/tools-index.ts +427 -0
- package/tsconfig.json +17 -0
- package/web/connect/bailing-connect-php.tgz +0 -0
- package/web/connect/bailing-connect-php7.tgz +0 -0
- package/web/connect/executor.mjs +152 -0
- package/web/connect/openclaw-stdio.mjs +145 -0
- package/web/connect/skills/connect-bailinghub-executor/SKILL.md +97 -0
- package/web/connect/skills/connect-bailinghub-executor/agents/openai.yaml +4 -0
- package/web/connect/skills/connect-bailinghub-executor/references/direct-protocol.md +99 -0
- package/web/connect/skills/connect-bailinghub-executor/references/openclaw.md +39 -0
- package/web/console/assets/Accounts-B4ePH5jp.css +1 -0
- package/web/console/assets/Accounts-Dwzm4D_V.js +3 -0
- package/web/console/assets/Approvals-BxhuI0ku.js +1 -0
- package/web/console/assets/Approvals-DlTSHl_7.css +1 -0
- package/web/console/assets/Audit-CSu6_3oD.css +1 -0
- package/web/console/assets/Audit-dFAbGynl.js +1 -0
- package/web/console/assets/BrandLockup-BtZyvkM5.js +1 -0
- package/web/console/assets/BrandLockup-DKYBYzKU.css +1 -0
- package/web/console/assets/Channels-CCn0L1jg.css +1 -0
- package/web/console/assets/Channels-Dqg4-_yr.js +105 -0
- package/web/console/assets/ChatEntries-BweMx_CU.css +1 -0
- package/web/console/assets/ChatEntries-CEGZ3NnJ.js +7 -0
- package/web/console/assets/Clients-C0QD1x7g.js +3 -0
- package/web/console/assets/Clients-DcTYN-Js.css +1 -0
- package/web/console/assets/Cost-BAJqLhpK.js +1 -0
- package/web/console/assets/Cost-CjT39DSZ.css +1 -0
- package/web/console/assets/Credentials-D_GDRgWi.js +1 -0
- package/web/console/assets/Credentials-ioLP0qYN.css +1 -0
- package/web/console/assets/Diagnostics-BWYnDxRj.js +1 -0
- package/web/console/assets/Diagnostics-Ya05PTDp.css +1 -0
- package/web/console/assets/Executors-CjhEM54c.css +1 -0
- package/web/console/assets/Executors-Cmryk4Vk.js +1 -0
- package/web/console/assets/HelpTip-CA6Bm7Nx.css +1 -0
- package/web/console/assets/HelpTip-CT07o3kB.js +1 -0
- package/web/console/assets/Kb-BSXQE0Fa.js +5 -0
- package/web/console/assets/Kb-CzIzd9xr.css +1 -0
- package/web/console/assets/Login-BnBPqC8Z.js +1 -0
- package/web/console/assets/Login-xtPwDB5_.css +1 -0
- package/web/console/assets/Projects-Bm8AjsNx.css +1 -0
- package/web/console/assets/Projects-CNHx4L_7.js +1 -0
- package/web/console/assets/Routes-DWGQN5Pv.css +1 -0
- package/web/console/assets/Routes-u5cEAEXQ.js +124 -0
- package/web/console/assets/Runs-BeFUR77_.js +3 -0
- package/web/console/assets/Runs-CUtSsPW-.css +1 -0
- package/web/console/assets/Setup-BjZfrmfN.js +1 -0
- package/web/console/assets/Setup-QjlHZKdB.css +1 -0
- package/web/console/assets/Shell-CbGNTN91.css +1 -0
- package/web/console/assets/Shell-EJuYf3OO.js +1 -0
- package/web/console/assets/StorageBuckets-DMXRJxUA.js +1 -0
- package/web/console/assets/StorageBuckets-GnXnVvF0.css +1 -0
- package/web/console/assets/SystemSettings-B72F-loY.js +1 -0
- package/web/console/assets/SystemSettings-BjiHyrXO.css +1 -0
- package/web/console/assets/SystemStatus-I11I67rw.css +1 -0
- package/web/console/assets/SystemStatus-hOj_TPYE.js +1 -0
- package/web/console/assets/Targets-DTb5tn6z.css +1 -0
- package/web/console/assets/Targets-UVVf7twC.js +1 -0
- package/web/console/assets/Tools-A20oaMaQ.css +1 -0
- package/web/console/assets/Tools-ihkr9R9x.js +2 -0
- package/web/console/assets/_plugin-vue_export-helper-DlAUqK2U.js +1 -0
- package/web/console/assets/docs-DPUOCa7R.js +1 -0
- package/web/console/assets/index-DZEQL_yy.js +1 -0
- package/web/console/assets/index-DxvruykG.js +2 -0
- package/web/console/assets/index-Fi9gkGxV.css +1 -0
- package/web/console/assets/llm-catalog-HwRIrS94.js +1 -0
- package/web/console/assets/request-BisL2T9B.js +1 -0
- package/web/console/assets/schema-CzpUpoLk.js +1 -0
- package/web/console/assets/util-SiQC2MJh.js +1 -0
- package/web/console/assets/vendor-element-D7WRzHhy.js +37 -0
- package/web/console/assets/vendor-mammoth-DvgsHdlx.js +231 -0
- package/web/console/assets/vendor-turndown-kLzRgxYD.js +61 -0
- package/web/console/assets/vendor-vue-B2uhHUfE.js +29 -0
- package/web/console/index.html +16 -0
- package/web/widget/widget.js +1490 -0
- package/web-admin/index.html +13 -0
- package/web-admin/package-lock.json +1854 -0
- package/web-admin/package.json +25 -0
- package/web-admin/src/App.vue +9 -0
- package/web-admin/src/branding.ts +90 -0
- package/web-admin/src/components/BrandLockup.vue +40 -0
- package/web-admin/src/components/HelpTip.vue +51 -0
- package/web-admin/src/components/RichText.vue +35 -0
- package/web-admin/src/docs.ts +16 -0
- package/web-admin/src/layout/Shell.vue +356 -0
- package/web-admin/src/llm-catalog.ts +129 -0
- package/web-admin/src/main.ts +116 -0
- package/web-admin/src/pages/Accounts.vue +162 -0
- package/web-admin/src/pages/Approvals.vue +179 -0
- package/web-admin/src/pages/Audit.vue +110 -0
- package/web-admin/src/pages/Channels.vue +738 -0
- package/web-admin/src/pages/ChatEntries.vue +778 -0
- package/web-admin/src/pages/Clients.vue +353 -0
- package/web-admin/src/pages/Cost.vue +314 -0
- package/web-admin/src/pages/Credentials.vue +418 -0
- package/web-admin/src/pages/Diagnostics.vue +440 -0
- package/web-admin/src/pages/Executors.vue +398 -0
- package/web-admin/src/pages/Kb.vue +698 -0
- package/web-admin/src/pages/Login.vue +314 -0
- package/web-admin/src/pages/Projects.vue +106 -0
- package/web-admin/src/pages/Routes.vue +1661 -0
- package/web-admin/src/pages/Runs.vue +1113 -0
- package/web-admin/src/pages/Setup.vue +354 -0
- package/web-admin/src/pages/StorageBuckets.vue +182 -0
- package/web-admin/src/pages/SystemSettings.vue +281 -0
- package/web-admin/src/pages/SystemStatus.vue +185 -0
- package/web-admin/src/pages/Targets.vue +193 -0
- package/web-admin/src/pages/Tools.vue +1051 -0
- package/web-admin/src/request.ts +18 -0
- package/web-admin/src/router.ts +142 -0
- package/web-admin/src/runtime-path.ts +27 -0
- package/web-admin/src/schema.ts +52 -0
- package/web-admin/src/store.ts +35 -0
- package/web-admin/src/styles/base.css +272 -0
- package/web-admin/src/table-widths.ts +603 -0
- package/web-admin/src/util.ts +16 -0
- package/web-admin/tsconfig.json +15 -0
- package/web-admin/vite.config.ts +35 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
|
|
4
|
+
APP_NAME="bailinghub"
|
|
5
|
+
SOURCE_TGZ="${BAILING_SOURCE_TGZ:-https://www.bailinghub.com/connect/bailinghub-source.tgz}"
|
|
6
|
+
REPO="${BAILING_REPO:-}"
|
|
7
|
+
REF="${BAILING_REF:-main}"
|
|
8
|
+
INSTALL_DIR="${BAILING_INSTALL_DIR:-$HOME/bailinghub}"
|
|
9
|
+
INSTALL_MODE="${BAILING_INSTALL_MODE:-image}"
|
|
10
|
+
PUBLIC_PORT="${BAILING_PUBLIC_PORT:-18900}"
|
|
11
|
+
DEMO_PORT="${BAILING_DEMO_PUBLIC_PORT:-19080}"
|
|
12
|
+
MYSQL_PORT="${BAILING_MYSQL_PUBLIC_PORT:-3307}"
|
|
13
|
+
SKIP_SMOKE="${BAILING_INSTALL_SKIP_SMOKE:-0}"
|
|
14
|
+
PUBLIC_HOST="${BAILING_PUBLIC_HOST:-}"
|
|
15
|
+
SKIP_PORT_CHECK="${BAILING_SKIP_PORT_CHECK:-0}"
|
|
16
|
+
DEFAULT_IMAGE_REGISTRY="crpi-xm97pbcjrmf5in3s.cn-shanghai.personal.cr.aliyuncs.com"
|
|
17
|
+
DEFAULT_IMAGE_NAMESPACE="bailinghub"
|
|
18
|
+
DEFAULT_MYSQL_IMAGE="$DEFAULT_IMAGE_REGISTRY/$DEFAULT_IMAGE_NAMESPACE/bailing-mysql:8.4"
|
|
19
|
+
COMPOSE_FILES=""
|
|
20
|
+
|
|
21
|
+
log() { printf '%s\n' "[$APP_NAME] $*"; }
|
|
22
|
+
die() { printf '%s\n' "[$APP_NAME] ERROR: $*" >&2; exit 1; }
|
|
23
|
+
have() { command -v "$1" >/dev/null 2>&1; }
|
|
24
|
+
|
|
25
|
+
as_root() {
|
|
26
|
+
if [ "$(id -u)" -eq 0 ]; then
|
|
27
|
+
"$@"
|
|
28
|
+
elif have sudo; then
|
|
29
|
+
sudo "$@"
|
|
30
|
+
else
|
|
31
|
+
die "需要 root 权限执行:$*。请安装 sudo 或切换 root 后重试。"
|
|
32
|
+
fi
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
secret() {
|
|
36
|
+
if have openssl; then
|
|
37
|
+
openssl rand -base64 24 | tr -d '\n'
|
|
38
|
+
else
|
|
39
|
+
date +%s | sha256sum | awk '{print $1}'
|
|
40
|
+
fi
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
install_packages() {
|
|
44
|
+
if have git && have curl && have tar; then return; fi
|
|
45
|
+
if have apt-get; then
|
|
46
|
+
log "安装基础工具 git/curl/tar/ca-certificates"
|
|
47
|
+
as_root apt-get update
|
|
48
|
+
as_root apt-get install -y ca-certificates curl git tar openssl
|
|
49
|
+
return
|
|
50
|
+
fi
|
|
51
|
+
die "未找到 git/curl/tar,且当前系统没有 apt-get。请先安装 git、curl、tar、openssl。"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
install_docker() {
|
|
55
|
+
if have docker && docker compose version >/dev/null 2>&1; then return; fi
|
|
56
|
+
if ! have apt-get; then
|
|
57
|
+
die "未找到 Docker Compose。请先安装 Docker Engine 与 compose plugin。"
|
|
58
|
+
fi
|
|
59
|
+
log "安装 Docker 与 Docker Compose plugin"
|
|
60
|
+
as_root apt-get update
|
|
61
|
+
if apt-cache show docker-compose-plugin >/dev/null 2>&1; then
|
|
62
|
+
COMPOSE_PACKAGE="docker-compose-plugin"
|
|
63
|
+
elif apt-cache show docker-compose-v2 >/dev/null 2>&1; then
|
|
64
|
+
COMPOSE_PACKAGE="docker-compose-v2"
|
|
65
|
+
else
|
|
66
|
+
die "当前 apt 软件源未提供 Docker Compose plugin。请配置可用软件源后重试。"
|
|
67
|
+
fi
|
|
68
|
+
if have docker; then
|
|
69
|
+
as_root apt-get install -y "$COMPOSE_PACKAGE"
|
|
70
|
+
else
|
|
71
|
+
as_root apt-get install -y docker.io "$COMPOSE_PACKAGE"
|
|
72
|
+
fi
|
|
73
|
+
if ! docker compose version >/dev/null 2>&1; then
|
|
74
|
+
die "Docker 已安装但 docker compose 不可用,请检查 Docker Compose plugin。"
|
|
75
|
+
fi
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
docker_cmd() {
|
|
79
|
+
if docker info >/dev/null 2>&1; then
|
|
80
|
+
docker "$@"
|
|
81
|
+
else
|
|
82
|
+
as_root docker "$@"
|
|
83
|
+
fi
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
compose_cmd() {
|
|
87
|
+
if [ -n "$COMPOSE_FILES" ]; then
|
|
88
|
+
# shellcheck disable=SC2086
|
|
89
|
+
docker_cmd compose $COMPOSE_FILES "$@"
|
|
90
|
+
else
|
|
91
|
+
docker_cmd compose "$@"
|
|
92
|
+
fi
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
validate_port() {
|
|
96
|
+
name="$1"
|
|
97
|
+
value="$2"
|
|
98
|
+
case "$value" in
|
|
99
|
+
''|*[!0-9]*) die "$name 必须是 1-65535 之间的端口号,当前为:$value" ;;
|
|
100
|
+
esac
|
|
101
|
+
if [ "$value" -lt 1 ] || [ "$value" -gt 65535 ]; then
|
|
102
|
+
die "$name 必须是 1-65535 之间的端口号,当前为:$value"
|
|
103
|
+
fi
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
port_in_use() {
|
|
107
|
+
port="$1"
|
|
108
|
+
if have ss; then
|
|
109
|
+
ss -ltn 2>/dev/null | awk '{print $4}' | grep -Eq "[:.]$port$"
|
|
110
|
+
return $?
|
|
111
|
+
fi
|
|
112
|
+
if have lsof; then
|
|
113
|
+
lsof -nP -iTCP:"$port" -sTCP:LISTEN >/dev/null 2>&1
|
|
114
|
+
return $?
|
|
115
|
+
fi
|
|
116
|
+
if have netstat; then
|
|
117
|
+
netstat -ltn 2>/dev/null | awk '{print $4}' | grep -Eq "[:.]$port$"
|
|
118
|
+
return $?
|
|
119
|
+
fi
|
|
120
|
+
return 1
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
preflight_environment() {
|
|
124
|
+
validate_port BAILING_PUBLIC_PORT "$PUBLIC_PORT"
|
|
125
|
+
validate_port BAILING_DEMO_PUBLIC_PORT "$DEMO_PORT"
|
|
126
|
+
validate_port BAILING_MYSQL_PUBLIC_PORT "$MYSQL_PORT"
|
|
127
|
+
if [ "$PUBLIC_PORT" = "$DEMO_PORT" ] || [ "$PUBLIC_PORT" = "$MYSQL_PORT" ] || [ "$DEMO_PORT" = "$MYSQL_PORT" ]; then
|
|
128
|
+
die "三个对外端口不能重复:BAILING_PUBLIC_PORT=$PUBLIC_PORT, BAILING_DEMO_PUBLIC_PORT=$DEMO_PORT, BAILING_MYSQL_PUBLIC_PORT=$MYSQL_PORT"
|
|
129
|
+
fi
|
|
130
|
+
|
|
131
|
+
arch="$(uname -m 2>/dev/null || echo unknown)"
|
|
132
|
+
case "$arch" in
|
|
133
|
+
x86_64|amd64) ;;
|
|
134
|
+
aarch64|arm64)
|
|
135
|
+
if [ "$INSTALL_MODE" = "image" ] || [ "$INSTALL_MODE" = "images" ]; then
|
|
136
|
+
if [ "${BAILING_ALLOW_UNTESTED_ARCH:-0}" != "1" ]; then
|
|
137
|
+
die "当前机器架构为 $arch。官方预构建镜像首版优先覆盖 x86_64;请改用 BAILING_INSTALL_MODE=source,或设置 BAILING_ALLOW_UNTESTED_ARCH=1 后自行确认镜像兼容。"
|
|
138
|
+
fi
|
|
139
|
+
fi
|
|
140
|
+
;;
|
|
141
|
+
*)
|
|
142
|
+
if [ "${BAILING_ALLOW_UNTESTED_ARCH:-0}" != "1" ]; then
|
|
143
|
+
die "当前机器架构为 $arch,未在安装脚本白名单内。确认可运行后可设置 BAILING_ALLOW_UNTESTED_ARCH=1。"
|
|
144
|
+
fi
|
|
145
|
+
;;
|
|
146
|
+
esac
|
|
147
|
+
|
|
148
|
+
if [ "$SKIP_PORT_CHECK" != "1" ]; then
|
|
149
|
+
for item in "$PUBLIC_PORT:中枢控制台" "$DEMO_PORT:demo 业务系统" "$MYSQL_PORT:demo MySQL"; do
|
|
150
|
+
port="${item%%:*}"
|
|
151
|
+
label="${item#*:}"
|
|
152
|
+
if port_in_use "$port"; then
|
|
153
|
+
die "$label 端口 $port 已被占用。请换端口,例如:curl -fsSL https://www.bailinghub.com/install.sh | env BAILING_PUBLIC_PORT=28900 BAILING_DEMO_PUBLIC_PORT=29080 BAILING_MYSQL_PUBLIC_PORT=13307 sh"
|
|
154
|
+
fi
|
|
155
|
+
done
|
|
156
|
+
fi
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
preflight_docker() {
|
|
160
|
+
if ! docker_cmd info >/dev/null 2>&1; then
|
|
161
|
+
die "Docker daemon 不可用。请确认 Docker 服务已启动,当前用户可运行 docker,或已安装 sudo。"
|
|
162
|
+
fi
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
preflight_images() {
|
|
166
|
+
APP_DIR="$1"
|
|
167
|
+
cd "$APP_DIR"
|
|
168
|
+
if [ "$INSTALL_MODE" = "image" ] || [ "$INSTALL_MODE" = "images" ]; then
|
|
169
|
+
log "检查官方镜像是否可拉取"
|
|
170
|
+
if ! compose_cmd pull; then
|
|
171
|
+
cat >&2 <<'EOF'
|
|
172
|
+
|
|
173
|
+
[bailinghub] 官方镜像拉取失败。
|
|
174
|
+
|
|
175
|
+
常见原因:
|
|
176
|
+
1. 当前网络无法访问官方镜像仓库;
|
|
177
|
+
2. 指定的 BAILING_IMAGE_TAG 尚未发布;
|
|
178
|
+
3. 当前机器架构暂未提供对应镜像。
|
|
179
|
+
|
|
180
|
+
可选处理:
|
|
181
|
+
curl -fsSL https://www.bailinghub.com/install.sh | env BAILING_INSTALL_MODE=source sh
|
|
182
|
+
|
|
183
|
+
或显式指定你自己的镜像仓库:
|
|
184
|
+
curl -fsSL https://www.bailinghub.com/install.sh | env \
|
|
185
|
+
BAILINGHUB_IMAGE=<registry>/bailinghub:<tag> \
|
|
186
|
+
BAILING_DEMO_BUSINESS_IMAGE=<registry>/bailing-demo-business:<tag> \
|
|
187
|
+
BAILING_MYSQL_IMAGE=<registry>/bailing-mysql:8.4 \
|
|
188
|
+
sh
|
|
189
|
+
EOF
|
|
190
|
+
exit 1
|
|
191
|
+
fi
|
|
192
|
+
else
|
|
193
|
+
log "检查源码构建基础镜像"
|
|
194
|
+
if ! compose_cmd pull mysql; then
|
|
195
|
+
die "MySQL 基础镜像拉取失败。请检查 BAILING_MYSQL_IMAGE 或当前网络。"
|
|
196
|
+
fi
|
|
197
|
+
node_image="${BAILING_NODE_IMAGE:-node:22-bookworm-slim}"
|
|
198
|
+
if ! docker_cmd pull "$node_image"; then
|
|
199
|
+
die "Node 基础镜像 $node_image 拉取失败。请配置 Docker registry mirror,或设置 BAILING_NODE_IMAGE 为当前网络可访问的等价镜像。"
|
|
200
|
+
fi
|
|
201
|
+
fi
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
wait_hub_ready() {
|
|
205
|
+
URL="http://127.0.0.1:$PUBLIC_PORT/health"
|
|
206
|
+
log "等待中枢就绪:$URL"
|
|
207
|
+
i=0
|
|
208
|
+
while [ "$i" -lt 90 ]; do
|
|
209
|
+
if curl -fsS "$URL" >/dev/null 2>&1; then
|
|
210
|
+
log "中枢已就绪"
|
|
211
|
+
return
|
|
212
|
+
fi
|
|
213
|
+
i=$((i + 1))
|
|
214
|
+
sleep 2
|
|
215
|
+
done
|
|
216
|
+
compose_cmd ps || true
|
|
217
|
+
compose_cmd logs --tail=120 bailinghub || true
|
|
218
|
+
die "中枢启动后 180 秒内未通过健康检查:$URL"
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
resolve_app_dir() {
|
|
222
|
+
if [ -f "./package.json" ] && [ -f "./docker-compose.yml" ] && [ -d "./scripts" ]; then
|
|
223
|
+
pwd
|
|
224
|
+
return
|
|
225
|
+
fi
|
|
226
|
+
printf '%s\n' "$INSTALL_DIR"
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
checkout_code() {
|
|
230
|
+
APP_DIR="$1"
|
|
231
|
+
if [ -f "$APP_DIR/package.json" ] && [ -f "$APP_DIR/docker-compose.yml" ]; then
|
|
232
|
+
log "使用已有目录:$APP_DIR"
|
|
233
|
+
return
|
|
234
|
+
fi
|
|
235
|
+
if [ -z "$REPO" ]; then
|
|
236
|
+
if [ -e "$APP_DIR" ] && [ "$(find "$APP_DIR" -mindepth 1 -maxdepth 1 2>/dev/null | wc -l | tr -d ' ')" != "0" ]; then
|
|
237
|
+
die "$APP_DIR 已存在且不是可识别的百灵中枢目录。请换一个 BAILING_INSTALL_DIR,或手动处理该目录。"
|
|
238
|
+
fi
|
|
239
|
+
TMP_DIR="$(mktemp -d)"
|
|
240
|
+
log "下载开源分发包:$SOURCE_TGZ"
|
|
241
|
+
curl -fsSL "$SOURCE_TGZ" -o "$TMP_DIR/source.tgz"
|
|
242
|
+
tar -xzf "$TMP_DIR/source.tgz" -C "$TMP_DIR"
|
|
243
|
+
SRC_DIR="$(find "$TMP_DIR" -mindepth 1 -maxdepth 1 -type d | head -1)"
|
|
244
|
+
[ -n "$SRC_DIR" ] || die "开源分发包格式不正确"
|
|
245
|
+
mkdir -p "$APP_DIR"
|
|
246
|
+
(cd "$SRC_DIR" && tar -cf - .) | (cd "$APP_DIR" && tar -xf -)
|
|
247
|
+
rm -rf "$TMP_DIR"
|
|
248
|
+
return
|
|
249
|
+
fi
|
|
250
|
+
if [ -e "$APP_DIR" ] && [ ! -d "$APP_DIR/.git" ]; then
|
|
251
|
+
die "$APP_DIR 已存在但不是 git 仓库。请换一个 BAILING_INSTALL_DIR,或手动处理该目录。"
|
|
252
|
+
fi
|
|
253
|
+
if [ -d "$APP_DIR/.git" ]; then
|
|
254
|
+
log "更新已有仓库:$APP_DIR"
|
|
255
|
+
git -C "$APP_DIR" fetch --depth 1 origin "$REF"
|
|
256
|
+
git -C "$APP_DIR" checkout FETCH_HEAD
|
|
257
|
+
return
|
|
258
|
+
fi
|
|
259
|
+
log "拉取代码:$REPO ($REF) → $APP_DIR"
|
|
260
|
+
mkdir -p "$(dirname "$APP_DIR")"
|
|
261
|
+
git clone --depth 1 --branch "$REF" "$REPO" "$APP_DIR"
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
write_env() {
|
|
265
|
+
APP_DIR="$1"
|
|
266
|
+
ENV_FILE="$APP_DIR/.env"
|
|
267
|
+
if [ -f "$ENV_FILE" ]; then
|
|
268
|
+
log ".env 已存在,保持原样"
|
|
269
|
+
return
|
|
270
|
+
fi
|
|
271
|
+
ADMIN_PASSWORD="${BAILING_DEMO_ADMIN_PASSWORD:-$(secret)}"
|
|
272
|
+
ADMIN_TOKEN="${BAILING_TOKEN:-$(secret)}"
|
|
273
|
+
MYSQL_ROOT_PASSWORD="${BAILING_DEMO_MYSQL_ROOT_PASSWORD:-$(secret)}"
|
|
274
|
+
MYSQL_PASSWORD="${BAILING_DEMO_MYSQL_PASSWORD:-$(secret)}"
|
|
275
|
+
TOOL_SECRET="${DEMO_TOOL_SECRET:-$(secret)}"
|
|
276
|
+
CLIENT_TOKEN="${DEMO_CLIENT_TOKEN:-$(secret)}"
|
|
277
|
+
IMAGE_TAG="${BAILING_IMAGE_TAG:-$(sed -n 's/.*"version"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$APP_DIR/package.json" | head -1)}"
|
|
278
|
+
[ -n "$IMAGE_TAG" ] || IMAGE_TAG="0.3.0"
|
|
279
|
+
IMAGE_REGISTRY="${BAILING_IMAGE_REGISTRY:-$DEFAULT_IMAGE_REGISTRY}"
|
|
280
|
+
IMAGE_NAMESPACE="${BAILING_IMAGE_NAMESPACE:-$DEFAULT_IMAGE_NAMESPACE}"
|
|
281
|
+
cat > "$ENV_FILE" <<EOF
|
|
282
|
+
# Generated by scripts/install.sh. Safe to edit, but do not commit.
|
|
283
|
+
BAILING_INSTALL_MODE=$INSTALL_MODE
|
|
284
|
+
BAILING_PUBLIC_PORT=$PUBLIC_PORT
|
|
285
|
+
BAILING_DEMO_PUBLIC_PORT=$DEMO_PORT
|
|
286
|
+
BAILING_MYSQL_PUBLIC_PORT=$MYSQL_PORT
|
|
287
|
+
|
|
288
|
+
BAILINGHUB_IMAGE=${BAILINGHUB_IMAGE:-$IMAGE_REGISTRY/$IMAGE_NAMESPACE/bailinghub:$IMAGE_TAG}
|
|
289
|
+
BAILING_DEMO_BUSINESS_IMAGE=${BAILING_DEMO_BUSINESS_IMAGE:-$IMAGE_REGISTRY/$IMAGE_NAMESPACE/bailing-demo-business:$IMAGE_TAG}
|
|
290
|
+
BAILING_MYSQL_IMAGE=${BAILING_MYSQL_IMAGE:-$DEFAULT_MYSQL_IMAGE}
|
|
291
|
+
BAILING_NODE_IMAGE=${BAILING_NODE_IMAGE:-node:22-bookworm-slim}
|
|
292
|
+
|
|
293
|
+
BAILING_TOKEN=$ADMIN_TOKEN
|
|
294
|
+
BAILING_BOOTSTRAP_ADMIN_USERNAME=admin
|
|
295
|
+
BAILING_BOOTSTRAP_ADMIN_PASSWORD=$ADMIN_PASSWORD
|
|
296
|
+
BAILING_DEMO_ADMIN_PASSWORD=$ADMIN_PASSWORD
|
|
297
|
+
|
|
298
|
+
BAILING_DEMO_MYSQL_ROOT_PASSWORD=$MYSQL_ROOT_PASSWORD
|
|
299
|
+
BAILING_DEMO_MYSQL_DATABASE=bailinghub
|
|
300
|
+
BAILING_DEMO_MYSQL_USER=bailing
|
|
301
|
+
BAILING_DEMO_MYSQL_PASSWORD=$MYSQL_PASSWORD
|
|
302
|
+
|
|
303
|
+
DEMO_TOOL_SECRET=$TOOL_SECRET
|
|
304
|
+
DEMO_CLIENT_TOKEN=$CLIENT_TOKEN
|
|
305
|
+
EOF
|
|
306
|
+
chmod 600 "$ENV_FILE"
|
|
307
|
+
log "已生成 .env(不会被 git 跟踪)"
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
host_ip() {
|
|
311
|
+
if [ -n "$PUBLIC_HOST" ]; then
|
|
312
|
+
printf '%s\n' "$PUBLIC_HOST"
|
|
313
|
+
return
|
|
314
|
+
fi
|
|
315
|
+
if have curl; then
|
|
316
|
+
PUBLIC_IP="$(curl -fsS --max-time 3 https://api.ipify.org 2>/dev/null || true)"
|
|
317
|
+
case "$PUBLIC_IP" in
|
|
318
|
+
''|127.*|10.*|172.16.*|172.17.*|172.18.*|172.19.*|172.20.*|172.21.*|172.22.*|172.23.*|172.24.*|172.25.*|172.26.*|172.27.*|172.28.*|172.29.*|172.30.*|172.31.*|192.168.*) ;;
|
|
319
|
+
*) printf '%s\n' "$PUBLIC_IP"; return ;;
|
|
320
|
+
esac
|
|
321
|
+
fi
|
|
322
|
+
hostname -I 2>/dev/null | awk '{
|
|
323
|
+
for (i = 1; i <= NF; i++) {
|
|
324
|
+
if ($i !~ /^127\\./ && $i !~ /^10\\./ && $i !~ /^172\\.(1[6-9]|2[0-9]|3[0-1])\\./ && $i !~ /^192\\.168\\./) {
|
|
325
|
+
print $i;
|
|
326
|
+
exit;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}'
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
select_compose_mode() {
|
|
333
|
+
APP_DIR="$1"
|
|
334
|
+
case "$INSTALL_MODE" in
|
|
335
|
+
image|images)
|
|
336
|
+
[ -f "$APP_DIR/docker-compose.images.yml" ] || die "缺少 docker-compose.images.yml,不能使用 BAILING_INSTALL_MODE=image。"
|
|
337
|
+
COMPOSE_FILES="-f docker-compose.images.yml"
|
|
338
|
+
log "安装模式:官方预构建镜像"
|
|
339
|
+
;;
|
|
340
|
+
source|build)
|
|
341
|
+
COMPOSE_FILES=""
|
|
342
|
+
log "安装模式:源码构建"
|
|
343
|
+
;;
|
|
344
|
+
*)
|
|
345
|
+
die "BAILING_INSTALL_MODE 只支持 source 或 image,当前为:$INSTALL_MODE"
|
|
346
|
+
;;
|
|
347
|
+
esac
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
main() {
|
|
351
|
+
preflight_environment
|
|
352
|
+
install_packages
|
|
353
|
+
install_docker
|
|
354
|
+
preflight_docker
|
|
355
|
+
APP_DIR="$(resolve_app_dir)"
|
|
356
|
+
checkout_code "$APP_DIR"
|
|
357
|
+
write_env "$APP_DIR"
|
|
358
|
+
select_compose_mode "$APP_DIR"
|
|
359
|
+
preflight_images "$APP_DIR"
|
|
360
|
+
|
|
361
|
+
log "启动 Docker demo"
|
|
362
|
+
cd "$APP_DIR"
|
|
363
|
+
if [ "$INSTALL_MODE" = "image" ] || [ "$INSTALL_MODE" = "images" ]; then
|
|
364
|
+
UP_ARGS="-d"
|
|
365
|
+
else
|
|
366
|
+
UP_ARGS="-d --build"
|
|
367
|
+
fi
|
|
368
|
+
# shellcheck disable=SC2086
|
|
369
|
+
if ! compose_cmd up $UP_ARGS; then
|
|
370
|
+
cat >&2 <<'EOF'
|
|
371
|
+
|
|
372
|
+
[bailinghub] Docker demo 启动失败。
|
|
373
|
+
|
|
374
|
+
如果使用 BAILING_INSTALL_MODE=image 且日志里包含 bailinghub 或 bailing-demo-business 拉取失败,
|
|
375
|
+
说明当前网络无法访问官方镜像仓库,或官方镜像版本尚未发布。可切到源码构建:
|
|
376
|
+
|
|
377
|
+
curl -fsSL https://www.bailinghub.com/install.sh | env BAILING_INSTALL_MODE=source sh
|
|
378
|
+
|
|
379
|
+
如果日志里包含 docker.io、registry-1.docker.io 或 node:22-bookworm-slim 超时,
|
|
380
|
+
说明当前服务器无法稳定访问 Docker Hub。可选处理方式:
|
|
381
|
+
|
|
382
|
+
1. 给 Docker 配置当前云环境可用的 registry mirror,然后重试:
|
|
383
|
+
cd <安装目录>
|
|
384
|
+
docker compose up -d --build
|
|
385
|
+
|
|
386
|
+
2. 或在安装前显式指定可访问的等价镜像:
|
|
387
|
+
curl -fsSL https://www.bailinghub.com/install.sh | env \
|
|
388
|
+
BAILING_NODE_IMAGE=<registry>/library/node:22-bookworm-slim \
|
|
389
|
+
sh
|
|
390
|
+
|
|
391
|
+
一键安装默认使用官方预构建镜像;如需本机源码构建,可设置 BAILING_INSTALL_MODE=source。
|
|
392
|
+
EOF
|
|
393
|
+
exit 1
|
|
394
|
+
fi
|
|
395
|
+
|
|
396
|
+
if [ "$SKIP_SMOKE" != "1" ]; then
|
|
397
|
+
wait_hub_ready
|
|
398
|
+
log "运行 smoke 验证"
|
|
399
|
+
if ! compose_cmd exec -T bailinghub npm run smoke; then
|
|
400
|
+
compose_cmd ps || true
|
|
401
|
+
compose_cmd logs --tail=160 bailinghub || true
|
|
402
|
+
die "smoke 验证失败"
|
|
403
|
+
fi
|
|
404
|
+
fi
|
|
405
|
+
|
|
406
|
+
IP="$(host_ip)"
|
|
407
|
+
if [ -n "$IP" ]; then
|
|
408
|
+
ADDRESS_NOTE="已自动识别访问地址。"
|
|
409
|
+
else
|
|
410
|
+
IP="localhost"
|
|
411
|
+
ADDRESS_NOTE="未自动识别公网地址。远程访问时请将 localhost 替换为服务器公网 IP 或域名。"
|
|
412
|
+
fi
|
|
413
|
+
ADMIN_PASSWORD="$(grep '^BAILING_DEMO_ADMIN_PASSWORD=' .env | cut -d= -f2-)"
|
|
414
|
+
CLIENT_TOKEN="$(grep '^DEMO_CLIENT_TOKEN=' .env | cut -d= -f2-)"
|
|
415
|
+
if docker info >/dev/null 2>&1 || [ "$(id -u)" -eq 0 ]; then
|
|
416
|
+
COMPOSE_HINT="docker compose"
|
|
417
|
+
else
|
|
418
|
+
COMPOSE_HINT="sudo docker compose"
|
|
419
|
+
fi
|
|
420
|
+
if [ -n "$COMPOSE_FILES" ]; then
|
|
421
|
+
COMPOSE_HINT="$COMPOSE_HINT $COMPOSE_FILES"
|
|
422
|
+
fi
|
|
423
|
+
|
|
424
|
+
cat <<EOF
|
|
425
|
+
|
|
426
|
+
[$APP_NAME] 安装完成
|
|
427
|
+
|
|
428
|
+
控制台:
|
|
429
|
+
http://$IP:$PUBLIC_PORT/console/
|
|
430
|
+
|
|
431
|
+
demo 业务系统:
|
|
432
|
+
http://$IP:$DEMO_PORT/
|
|
433
|
+
|
|
434
|
+
访问地址:
|
|
435
|
+
$ADDRESS_NOTE
|
|
436
|
+
|
|
437
|
+
后台账号:
|
|
438
|
+
username: admin
|
|
439
|
+
password: $ADMIN_PASSWORD
|
|
440
|
+
|
|
441
|
+
demo 接入方:
|
|
442
|
+
route: demo_support
|
|
443
|
+
token: $CLIENT_TOKEN
|
|
444
|
+
|
|
445
|
+
常用命令:
|
|
446
|
+
cd $APP_DIR
|
|
447
|
+
$COMPOSE_HINT ps
|
|
448
|
+
$COMPOSE_HINT logs -f bailinghub
|
|
449
|
+
$COMPOSE_HINT exec bailinghub npm run smoke
|
|
450
|
+
$COMPOSE_HINT exec bailinghub npm run demo:e2e
|
|
451
|
+
|
|
452
|
+
安装模式:
|
|
453
|
+
$INSTALL_MODE
|
|
454
|
+
|
|
455
|
+
如需显式指定对外显示的地址,可重新安装时使用:
|
|
456
|
+
curl -fsSL https://www.bailinghub.com/install.sh | env BAILING_PUBLIC_HOST=<server-public-ip-or-domain> sh
|
|
457
|
+
|
|
458
|
+
EOF
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
main "$@"
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
const root = process.cwd();
|
|
6
|
+
const findings = [];
|
|
7
|
+
|
|
8
|
+
function read(file) {
|
|
9
|
+
return existsSync(join(root, file)) ? readFileSync(join(root, file), 'utf8') : '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function requireIgnore(file, pattern) {
|
|
13
|
+
const text = read(file);
|
|
14
|
+
const lines = text.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith('#'));
|
|
15
|
+
if (!lines.includes(pattern)) findings.push(`${file} must exclude ${pattern}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const sharedRequiredIgnorePatterns = [
|
|
19
|
+
'web/site/',
|
|
20
|
+
'web/console.bak.*/',
|
|
21
|
+
'deploy/',
|
|
22
|
+
'.deploy-backup/',
|
|
23
|
+
'.oss-dist/',
|
|
24
|
+
'.oss-publish/',
|
|
25
|
+
'bailinghub-*.tgz',
|
|
26
|
+
'*.bak.*',
|
|
27
|
+
'*.bak.*/',
|
|
28
|
+
'src.bak.*/',
|
|
29
|
+
'config.json',
|
|
30
|
+
'.env',
|
|
31
|
+
'.paused',
|
|
32
|
+
'build-info.json',
|
|
33
|
+
'data/',
|
|
34
|
+
'internal/',
|
|
35
|
+
'*.internal.md',
|
|
36
|
+
'*.private.md',
|
|
37
|
+
'private/',
|
|
38
|
+
'enterprise/',
|
|
39
|
+
'src/private/',
|
|
40
|
+
'src/enterprise/',
|
|
41
|
+
'sql/private/',
|
|
42
|
+
'sql/enterprise/',
|
|
43
|
+
'web-admin/src/private/',
|
|
44
|
+
'web-admin/src/platform/',
|
|
45
|
+
'*.private.*',
|
|
46
|
+
'*.enterprise.*',
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
for (const pattern of sharedRequiredIgnorePatterns) {
|
|
50
|
+
requireIgnore('.dockerignore', pattern);
|
|
51
|
+
requireIgnore('.npmignore', pattern);
|
|
52
|
+
}
|
|
53
|
+
// The source/Docker context still excludes generated console output. The npm
|
|
54
|
+
// Core artifact is different: prepack builds and intentionally ships the
|
|
55
|
+
// console required by an embedded Kernel Host.
|
|
56
|
+
requireIgnore('.dockerignore', 'web/console/');
|
|
57
|
+
|
|
58
|
+
const dockerfile = read('Dockerfile');
|
|
59
|
+
if (/COPY\s+\.\s+\./.test(dockerfile) && !read('.dockerignore').includes('web/site/')) {
|
|
60
|
+
findings.push('Dockerfile copies the repository context, so .dockerignore must exclude web/site/');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let packFiles = [];
|
|
64
|
+
try {
|
|
65
|
+
const packed = spawnSync(
|
|
66
|
+
process.platform === 'win32' ? 'npm.cmd' : 'npm',
|
|
67
|
+
// This check only needs npm's final file manifest. Running lifecycle
|
|
68
|
+
// scripts under --dry-run propagates npm_config_dry_run into prepack, so
|
|
69
|
+
// nested installs are simulated and the following console build fails in
|
|
70
|
+
// a clean checkout. The real package build is covered independently by
|
|
71
|
+
// prepack and package:artifact:check.
|
|
72
|
+
['pack', '--dry-run', '--ignore-scripts', '--json', '--silent'],
|
|
73
|
+
{
|
|
74
|
+
cwd: root,
|
|
75
|
+
encoding: 'utf8',
|
|
76
|
+
env: { ...process.env, npm_config_loglevel: 'silent' },
|
|
77
|
+
maxBuffer: 32 * 1024 * 1024,
|
|
78
|
+
},
|
|
79
|
+
);
|
|
80
|
+
if (packed.status !== 0) {
|
|
81
|
+
throw new Error(packed.stderr || packed.stdout || `npm pack exited ${packed.status}`);
|
|
82
|
+
}
|
|
83
|
+
// npm may forward lifecycle output before the final JSON array even with
|
|
84
|
+
// --silent. Parse only the manifest suffix instead of trusting pure stdout.
|
|
85
|
+
const jsonStart = packed.stdout.search(/(?:^|\n)\[\s*\{/);
|
|
86
|
+
if (jsonStart < 0) throw new Error('npm pack JSON manifest not found');
|
|
87
|
+
const parsed = JSON.parse(packed.stdout.slice(packed.stdout.indexOf('[', jsonStart)));
|
|
88
|
+
packFiles = Array.isArray(parsed) && parsed[0]?.files ? parsed[0].files.map((f) => String(f.path ?? '')) : [];
|
|
89
|
+
} catch (e) {
|
|
90
|
+
findings.push(`npm pack --dry-run failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const forbiddenPackPrefixes = [
|
|
94
|
+
'web/site/',
|
|
95
|
+
'web/console.bak.',
|
|
96
|
+
'deploy/',
|
|
97
|
+
'.deploy-backup/',
|
|
98
|
+
'.oss-dist/',
|
|
99
|
+
'.oss-publish/',
|
|
100
|
+
'src.bak.',
|
|
101
|
+
'data/',
|
|
102
|
+
'internal/',
|
|
103
|
+
'private/',
|
|
104
|
+
'enterprise/',
|
|
105
|
+
'src/private/',
|
|
106
|
+
'src/enterprise/',
|
|
107
|
+
'sql/private/',
|
|
108
|
+
'sql/enterprise/',
|
|
109
|
+
'web-admin/src/private/',
|
|
110
|
+
'web-admin/src/platform/',
|
|
111
|
+
];
|
|
112
|
+
const forbiddenPackFiles = new Set(['config.json', '.env', '.paused', 'build-info.json']);
|
|
113
|
+
const forbiddenPublicWording = new RegExp([
|
|
114
|
+
'商业' + '版',
|
|
115
|
+
'商业' + '扩展',
|
|
116
|
+
'商业' + '仓',
|
|
117
|
+
'\\b[Cc]om' + 'mercial\\b',
|
|
118
|
+
].join('|'));
|
|
119
|
+
const forbiddenImplementationText = [
|
|
120
|
+
{ name: 'private edition implementation', re: new RegExp(`\\b(?:${['Com' + 'mercialEdition', 'com' + 'mercialEdition', 'TenantAwareStoreFactory', 'TenantScopeResolver', 'Com' + 'mercialScopeResolver', 'Com' + 'mercialIdentityProvider', 'Com' + 'mercialPolicyEngine'].join('|')})\\b`) },
|
|
121
|
+
{ name: 'platform tenant implementation', re: /\b(?:PlatformTenantAdmin|platformTenantAdmin|tenantRegistry|TenantRegistry|platformTenantRoutes|PlatformTenantRoutes)\b/ },
|
|
122
|
+
{ name: 'private licensing or billing implementation', re: /\b(?:LicenseServer|licenseServer|BillingPolicy|billingPolicy|TenantBilling|tenantBilling|WhiteLabel|whiteLabel)\b/ },
|
|
123
|
+
];
|
|
124
|
+
const forbiddenLegacyText = [
|
|
125
|
+
{ name: 'retired capability header', re: new RegExp(`\b${'x-' + 'ai'}\b`, 'i') },
|
|
126
|
+
{ name: 'retired target name', re: new RegExp(`\b${'cloud-' + 'llm'}(?:-v\d+)?\b`, 'i') },
|
|
127
|
+
{ name: 'retired product name', re: new RegExp(`\b${'bailing-' + 'ai'}\b`, 'i') },
|
|
128
|
+
{ name: 'internal editor metadata', re: new RegExp(`${'\.qo' + 'der'}|${'Co-Authored-' + 'By:'}`, 'i') },
|
|
129
|
+
{ name: 'pre-release historical narration', re: new RegExp([
|
|
130
|
+
'v1\\.5\\s*' + '定稿',
|
|
131
|
+
'兼容' + '老部署',
|
|
132
|
+
'向旧' + '模块导出',
|
|
133
|
+
'历史「[^」]+」路径' + '已废弃',
|
|
134
|
+
].join('|')) },
|
|
135
|
+
];
|
|
136
|
+
const guardScriptFiles = new Set([
|
|
137
|
+
'scripts/export-oss.mjs',
|
|
138
|
+
'scripts/oss-boundary-check.mjs',
|
|
139
|
+
'scripts/verify-oss-export.mjs',
|
|
140
|
+
'scripts/release-audit.mjs',
|
|
141
|
+
]);
|
|
142
|
+
const forbiddenSqlSchemaText = [
|
|
143
|
+
{ name: 'platform isolation table', re: /\bCREATE\s+TABLE\b[\s\S]*?\b(?:bz_)?(?:tenants|tenant_members|tenant_roles|tenant_plans|tenant_quotas|tenant_registry|platform_tenants|platform_admins|plans|subscriptions|billing_accounts)\b/i },
|
|
144
|
+
{ name: 'platform isolation column', re: /\bADD\s+COLUMN\s+`?tenant_id`?\b/i },
|
|
145
|
+
{ name: 'platform isolation index', re: /\b(?:KEY|INDEX|CONSTRAINT)\b[\s\S]{0,160}\btenant_id\b/i },
|
|
146
|
+
];
|
|
147
|
+
for (const file of packFiles) {
|
|
148
|
+
if (forbiddenPackFiles.has(file) || forbiddenPackPrefixes.some((prefix) => file.startsWith(prefix)) || file.includes('.bak.')) {
|
|
149
|
+
findings.push(`open-source package must not include ${file}`);
|
|
150
|
+
}
|
|
151
|
+
if (/^bailinghub-.*\.tgz$/.test(file)) {
|
|
152
|
+
findings.push(`open-source package must not include generated package tarball ${file}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
for (const file of packFiles.filter((file) => /\.(?:ts|tsx|js|mjs|vue|json|sql|md|yml|yaml|php|py|sh|html|css|txt)$/.test(file))) {
|
|
157
|
+
const text = read(file);
|
|
158
|
+
if (!text) continue;
|
|
159
|
+
if (file !== 'LICENSE' && forbiddenPublicWording.test(text)) {
|
|
160
|
+
findings.push(`${file}: use neutral public wording for private extension boundaries`);
|
|
161
|
+
}
|
|
162
|
+
if (!guardScriptFiles.has(file)) {
|
|
163
|
+
for (const rule of forbiddenImplementationText) {
|
|
164
|
+
if (rule.re.test(text)) findings.push(`${file}: ${rule.name} must stay out of the OSS package`);
|
|
165
|
+
}
|
|
166
|
+
for (const rule of forbiddenLegacyText) {
|
|
167
|
+
if (rule.re.test(text)) findings.push(`${file}: ${rule.name} must stay out of the first public release`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (/^sql\/.+\.sql$/.test(file)) {
|
|
171
|
+
for (const rule of forbiddenSqlSchemaText) {
|
|
172
|
+
if (rule.re.test(text)) findings.push(`${file}: ${rule.name} must stay in private migrations`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (findings.length) {
|
|
178
|
+
console.error('OSS boundary check failed:');
|
|
179
|
+
for (const finding of findings) console.error(` - ${finding}`);
|
|
180
|
+
process.exit(1);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
console.log(`✓ oss boundary check passed (${packFiles.length} package files inspected)`);
|