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,184 @@
|
|
|
1
|
+
# 独立验证任务卡
|
|
2
|
+
|
|
3
|
+
这张任务卡用于回答一个具体问题:**一位此前不了解 BailingHub 的开发者,能否仅凭公开资料,在非生产环境独立部署并验证一次受治理的业务操作闭环?**
|
|
4
|
+
|
|
5
|
+
它不是认证、性能测试或生产采用证明。跑通本任务只说明公开安装路径和 demo 治理链路可以被独立复现;不代表验证者已把 BailingHub 接入真实业务。
|
|
6
|
+
|
|
7
|
+
## 验证范围
|
|
8
|
+
|
|
9
|
+
- 验证对象:BailingHub 开源版 Docker demo;
|
|
10
|
+
- 稳定基线:`v0.3.0`;
|
|
11
|
+
- 数据范围:仓库自带的 demo 订单、工单、退款和故障工具;
|
|
12
|
+
- 预计用时:镜像和依赖下载完成后约 20 分钟;
|
|
13
|
+
- 不需要:真实大模型 Key、生产 API、生产凭据或真实业务数据。
|
|
14
|
+
|
|
15
|
+
Dify、n8n、MCP 和执行器/OpenClaw 验证都属于可选扩展,不属于本任务的通过条件。请先完成核心 Docker demo,再按需继续扩展验证。
|
|
16
|
+
|
|
17
|
+
## 前置条件
|
|
18
|
+
|
|
19
|
+
请选择下面一种路径:
|
|
20
|
+
|
|
21
|
+
- **全新服务器一键安装(推荐)**:非生产 Ubuntu/Debian、`curl`、可用的 `sudo` 或 root 权限;安装脚本会检查并安装 Docker 与 Compose;
|
|
22
|
+
- **本地源码复现**:macOS 或 Linux、Git、`curl`、OpenSSL、Docker Engine 或 Docker Desktop、Docker Compose v2(`docker compose`)。
|
|
23
|
+
|
|
24
|
+
两条路径验证的是同一个 demo 治理闭环。请不要在生产主机、生产网络或已有重要数据的 Docker 环境中运行本任务。
|
|
25
|
+
|
|
26
|
+
## 1. 安装稳定版本
|
|
27
|
+
|
|
28
|
+
### 路径 A:全新 Ubuntu/Debian 服务器(推荐)
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
curl -fsSL https://www.bailinghub.com/install.sh | sh
|
|
32
|
+
cd "$HOME/bailinghub"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
脚本默认拉取 `v0.3.0` 官方镜像,生成随机 Token 与后台密码,启动服务并自动运行基础体检。首次管理员只在数据库管理员表为空时创建;对同一持久化数据库进行重启、升级、容器重建或重新安装,不会覆盖已经修改的管理员密码。可选 `/metrics` 端点默认关闭,不影响基础验证。请保留终端输出中的版本、安装模式、耗时和“常用命令”,但不要把密码或 Token 写入反馈。新安装 Docker 后,当前非 root 会话通常仍需使用脚本打印的 `sudo docker compose ...` 命令;重新登录后 Docker 组权限才可能生效。
|
|
36
|
+
|
|
37
|
+
如果默认目录已被占用,请使用一个新的空目录,不要覆盖现有部署:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
curl -fsSL https://www.bailinghub.com/install.sh | env \
|
|
41
|
+
BAILING_INSTALL_DIR="$HOME/bailinghub-validation" \
|
|
42
|
+
sh
|
|
43
|
+
cd "$HOME/bailinghub-validation"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 路径 B:本地源码复现
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
git clone --depth 1 --branch v0.3.0 https://github.com/bailinghub/bailinghub.git
|
|
50
|
+
cd bailinghub
|
|
51
|
+
git rev-parse HEAD
|
|
52
|
+
export BAILING_TOKEN="$(openssl rand -hex 32)"
|
|
53
|
+
docker compose up -d --build
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
请保留提交号,并在后续命令中沿用同一终端和同一个 `BAILING_TOKEN`。所有写操作只会作用于本地 demo 数据。
|
|
57
|
+
|
|
58
|
+
## 2. 检查服务与控制台
|
|
59
|
+
|
|
60
|
+
路径 A 请使用安装器“常用命令”中打印的完整 Compose 前缀;在刚安装 Docker 的非 root 会话中通常是:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
sudo docker compose -f docker-compose.images.yml ps
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
路径 B 使用:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
docker compose ps
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
两条路径都检查:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
curl -fsS http://localhost:18900/health
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
控制台地址为 <http://localhost:18900/console/>:
|
|
79
|
+
|
|
80
|
+
- 路径 A 使用安装完成时打印的随机后台密码;密码也保存在安装目录的 `.env`,不得提交到 Issue;
|
|
81
|
+
- 路径 B 使用默认 demo 账号 `admin / bailing-demo-admin`。
|
|
82
|
+
|
|
83
|
+
## 3. 运行基础体检
|
|
84
|
+
|
|
85
|
+
路径 A 使用安装器打印的命令,通常是:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
sudo docker compose -f docker-compose.images.yml exec -T bailinghub npm run smoke
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
路径 B 使用:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
docker compose exec -T bailinghub npm run smoke
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
通过标准:命令退出码为 `0`,最终汇总中的失败数为 `0`。
|
|
98
|
+
|
|
99
|
+
## 4. 运行完整业务闭环
|
|
100
|
+
|
|
101
|
+
路径 A 使用安装器打印的命令,通常是:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
sudo docker compose -f docker-compose.images.yml exec -T bailinghub npm run demo:e2e
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
路径 B 使用:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
docker compose exec -T bailinghub npm run demo:e2e
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
该命令会真实经过本地 demo 的以下路径:
|
|
114
|
+
|
|
115
|
+
1. 查询订单并创建售后工单;
|
|
116
|
+
2. 高风险退款生成业务侧审批意图;
|
|
117
|
+
3. demo 业务系统批准后,中枢只放行已批准的调用;
|
|
118
|
+
4. 故障工具返回 5xx,任务仍可在 trace 中追踪。
|
|
119
|
+
|
|
120
|
+
通过标准:命令退出码为 `0`,末尾出现:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
结果:demo e2e passed
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## 5. 记录结果
|
|
127
|
+
|
|
128
|
+
请记录以下四个检查点:
|
|
129
|
+
|
|
130
|
+
| 检查点 | PASS 标准 |
|
|
131
|
+
|---|---|
|
|
132
|
+
| 服务启动 | `docker compose ps` 中服务正常,`/health` 可访问 |
|
|
133
|
+
| 控制台 | 可以登录并看到 demo 配置 |
|
|
134
|
+
| 基础体检 | `npm run smoke` 退出码为 0,失败数为 0 |
|
|
135
|
+
| 业务闭环 | `npm run demo:e2e` 退出码为 0,并输出 `结果:demo e2e passed` |
|
|
136
|
+
|
|
137
|
+
无论 PASS、部分通过还是失败,都欢迎使用 [独立验证报告模板](https://github.com/bailinghub/bailinghub/issues/new?template=independent_validation.yml) 反馈。报告建议包含:
|
|
138
|
+
|
|
139
|
+
- BailingHub 版本、安装路径,以及源码复现时的提交号;
|
|
140
|
+
- 操作系统、CPU 架构、Docker 与 Compose 版本;
|
|
141
|
+
- 四个检查点的结果;
|
|
142
|
+
- 镜像下载之外的实际耗时;
|
|
143
|
+
- 第一个阻塞点和脱敏日志;
|
|
144
|
+
- 是否只依赖公开文档,哪一步最不清楚。
|
|
145
|
+
|
|
146
|
+
**不要提交** `BAILING_TOKEN`、Client Token、执行器 Token、管理员凭据、模型 Key、完整 `.env`、个人信息或生产业务数据。
|
|
147
|
+
|
|
148
|
+
## 可选扩展
|
|
149
|
+
|
|
150
|
+
核心任务通过后,可以继续验证:
|
|
151
|
+
|
|
152
|
+
- [生态接入总览与首次成功标准](https://www.bailinghub.com/integrations);
|
|
153
|
+
- [Dify 最小接入配方](integrations/dify/README.md);
|
|
154
|
+
- [n8n 社区节点](https://github.com/bailinghub/bailinghub-n8n-node);
|
|
155
|
+
- [MCP Server](https://github.com/bailinghub/bailinghub-mcp-server);
|
|
156
|
+
- [执行器接入与 OpenClaw 适配](https://github.com/bailinghub/bailinghub-openclaw-skill)。
|
|
157
|
+
- [网页聊天真实流式输出与可重连 SSE](RELEASE_NOTES_v0.1.4.md)。
|
|
158
|
+
- [一键安装参数可靠性与全新服务器兼容性](RELEASE_NOTES_v0.1.5.md)。
|
|
159
|
+
- [独立验证路径与安装后权限提示](RELEASE_NOTES_v0.1.6.md)。
|
|
160
|
+
- [版本化 Client API 与跨生态兼容门禁](RELEASE_NOTES_v0.1.7.md)。
|
|
161
|
+
- [首次管理员只创建一次与重启安全](RELEASE_NOTES_v0.1.8.md)。
|
|
162
|
+
- [实例品牌设置、模型标识诊断与生态接入配方](RELEASE_NOTES_v0.1.10.md)。
|
|
163
|
+
- [流式对话阶段性进度提示](RELEASE_NOTES_v0.1.14.md)。
|
|
164
|
+
- [可信富内容渲染与聊天可靠性](RELEASE_NOTES_v0.1.15.md)。
|
|
165
|
+
- [工具运行时收敛与语义检索韧性](RELEASE_NOTES_v0.1.16.md)。
|
|
166
|
+
- [可组合 Core 与 Kernel Host API v1](RELEASE_NOTES_v0.3.0.md)。
|
|
167
|
+
|
|
168
|
+
扩展验证请在同一 Issue 模板中选择对应路径,并说明是否获得过维护者的直接帮助。
|
|
169
|
+
|
|
170
|
+
## 清理本地 demo
|
|
171
|
+
|
|
172
|
+
确认不再需要本地测试数据后,可在本仓目录执行:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
# 路径 A:沿用安装器打印的 Compose 前缀
|
|
176
|
+
sudo docker compose -f docker-compose.images.yml down -v
|
|
177
|
+
|
|
178
|
+
# 路径 B
|
|
179
|
+
docker compose down -v
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
如果路径 A 由 root 用户执行,或当前用户已经拥有 Docker socket 权限,请去掉 `sudo`。只运行与你选择的路径对应的一条清理命令。
|
|
183
|
+
|
|
184
|
+
该命令会删除本次 demo 创建的容器和本地数据卷。
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Third-Party Integration Guide
|
|
2
|
+
|
|
3
|
+
This guide is for business systems that want to connect to BailingHub.
|
|
4
|
+
|
|
5
|
+
## Integration Responsibilities
|
|
6
|
+
|
|
7
|
+
| Side | Responsibility |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Business system | Trigger jobs, publish selected tools, verify signatures, authorize subjects, and consume callbacks. |
|
|
10
|
+
| BailingHub | Route tasks, assemble context, govern tools, record trace/audit, emit approval intents, and deliver results. |
|
|
11
|
+
|
|
12
|
+
## Trigger Jobs
|
|
13
|
+
|
|
14
|
+
Use `POST /run` with a route key and business idempotency key.
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"request_id": "order-10001-ai-001",
|
|
19
|
+
"route": "order_assistant",
|
|
20
|
+
"input": "Analyze why this order has not shipped.",
|
|
21
|
+
"metadata": {
|
|
22
|
+
"principal": {
|
|
23
|
+
"id": "u_42",
|
|
24
|
+
"tenant": "tenant_100",
|
|
25
|
+
"roles": ["manager"]
|
|
26
|
+
},
|
|
27
|
+
"order_id": "SO20260701001"
|
|
28
|
+
},
|
|
29
|
+
"callback": "https://business.example.com/ai/callback"
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Embed The Chat Widget
|
|
34
|
+
|
|
35
|
+
Create a chat entry in the console, restrict its allowed origins, and embed the
|
|
36
|
+
hub-hosted script:
|
|
37
|
+
|
|
38
|
+
```html
|
|
39
|
+
<script src="<hub-url>/widget.js" data-entry="pub_xxx" async></script>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The widget renders safe Markdown tables without extra dependencies. A host page
|
|
43
|
+
that needs charts or interactive reports may register a trusted renderer while
|
|
44
|
+
keeping the model output declarative and untrusted. See
|
|
45
|
+
[WIDGET_RENDERERS.en.md](WIDGET_RENDERERS.en.md) for the versioned API, fallback
|
|
46
|
+
behavior, cleanup rules, and a library-neutral adapter example.
|
|
47
|
+
|
|
48
|
+
A custom chat frontend must also advertise only the renderer types it actually
|
|
49
|
+
supports through `client_capabilities.renderers`, treat `delta` as provisional,
|
|
50
|
+
discard it on `reset`, and parse rich blocks only from the authoritative
|
|
51
|
+
`done.reply`. See the custom-client section of
|
|
52
|
+
[WIDGET_RENDERERS.en.md](WIDGET_RENDERERS.en.md#custom-streaming-clients-without-widgetjs)
|
|
53
|
+
and the [minimal transport example](examples/custom-streaming-chat-client.mjs).
|
|
54
|
+
|
|
55
|
+
## Publish Tools
|
|
56
|
+
|
|
57
|
+
Expose a tool spec at a stable endpoint such as:
|
|
58
|
+
|
|
59
|
+
```text
|
|
60
|
+
/.well-known/bailing/tools.json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use OpenAPI plus `x-agent-capability` fields, or an SDK that generates the same shape. The URL must return the final document directly; the new access policies do not follow redirects.
|
|
64
|
+
|
|
65
|
+
Choose one of exactly two configurable catalog policies:
|
|
66
|
+
|
|
67
|
+
| Policy | Business endpoint | Console |
|
|
68
|
+
|---|---|---|
|
|
69
|
+
| Protected (recommended) | Verify `X-Bailing-Timestamp` and `X-Bailing-Signature` with the same provider secret used for tool calls. For this GET, the body, subject, and job id are empty. Reject unsigned and invalid signatures with 401, 403, or 404, and return `Cache-Control: private, no-store` on success. | `signed_required` |
|
|
70
|
+
| Deliberately public | Return a valid spec to an unsigned GET. Never include secrets, private addresses, or operations that should not be discoverable. | `public_allowed` |
|
|
71
|
+
|
|
72
|
+
PHP and PHP7 applications can use `SpecServer::respond($spec, $secret)` or framework-mode `handle(...)` plus `responseHeaders($secret)`. Use `respondPublic()` or `handlePublic()` only for a deliberate public catalog. Other stacks should implement the frozen spec-signature vector in `CONTRACT.en.md` rather than inventing a second signature scheme.
|
|
73
|
+
|
|
74
|
+
After saving the provider, refresh it and compare configured intent with observed evidence. `protected` means both negative probes were rejected, `public` means an unsigned read succeeded, and `inconclusive` means the result could not be established reliably. Changing the URL, secret, or policy clears old evidence and requires another refresh. For providers created before this policy existed, follow the read-only migration procedure in [COMPATIBILITY.en.md](COMPATIBILITY.en.md#url-tool-catalog-access-policy-upgrade).
|
|
75
|
+
|
|
76
|
+
For `signed_required`, the signed request must return 2xx and both negative probes must return 401/403/404. A negative 2xx is a public mismatch. Redirects, 429, 5xx, network failures, a request longer than 10 seconds, a body larger than 5 MiB, or an invalid document are inconclusive/failures. A 404 on the correctly signed primary request is a failure; only a 404 on a negative probe counts as rejection. Failures preserve the previous cached catalog.
|
|
77
|
+
|
|
78
|
+
## Verify Tool Calls
|
|
79
|
+
|
|
80
|
+
Every tool call from the hub must be verified:
|
|
81
|
+
|
|
82
|
+
- signature;
|
|
83
|
+
- timestamp freshness;
|
|
84
|
+
- tool name;
|
|
85
|
+
- job id;
|
|
86
|
+
- on-behalf-of subject.
|
|
87
|
+
|
|
88
|
+
After verification, apply your own business authorization. Do not treat signature verification as permission approval.
|
|
89
|
+
|
|
90
|
+
## Handle Approvals
|
|
91
|
+
|
|
92
|
+
If a tool call becomes high-risk or confirmation-required, the hub emits an approval intent with a frozen argument snapshot. The business system should usually route that intent to its own approval workflow.
|
|
93
|
+
|
|
94
|
+
Approvers do not need to be hub administrators.
|
|
95
|
+
|
|
96
|
+
## Consume Results
|
|
97
|
+
|
|
98
|
+
You can use polling or signed callbacks:
|
|
99
|
+
|
|
100
|
+
- polling: `GET /jobs/{job_id}`;
|
|
101
|
+
- callback: verify `X-Bailing-Signature` before consuming the result.
|
|
102
|
+
|
|
103
|
+
Business systems should keep a fallback path in case callbacks fail or are retried.
|
|
104
|
+
|
|
105
|
+
## Connect an External OpenClaw Executor
|
|
106
|
+
|
|
107
|
+
Register an `executor` target and issue a target-scoped executor token in the console. The versioned machine-readable workflow is available at `<hub-url>/connect/skills/connect-bailinghub-executor/SKILL.md`. On the machine that will run OpenClaw:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
curl -fsSL <hub-url>/connect/executor.mjs -o bailing-executor.mjs
|
|
111
|
+
curl -fsSL <hub-url>/connect/openclaw-stdio.mjs -o bailing-openclaw.mjs
|
|
112
|
+
read -rsp 'BailingHub executor token: ' BAILING_EXECUTOR_TOKEN && printf '\n'
|
|
113
|
+
export BAILING_EXECUTOR_TOKEN
|
|
114
|
+
node bailing-executor.mjs --hub <hub-url> --targets <target-name> \
|
|
115
|
+
--runtime openclaw --cmd 'node bailing-openclaw.mjs --agent bailinghub-executor'
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The generic executor owns claim leases, heartbeats, retries, and result reporting. The OpenClaw adapter maps BailingHub session ids to OpenClaw sessions and emits only the final reply on stdout.
|
|
119
|
+
|
|
120
|
+
Use a dedicated OpenClaw agent with a minimal tool profile. The adapter does not forward business-tool credentials by default; connect governed tool invocation only after the basic claim/result path has been verified.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Kernel Host API v1
|
|
2
|
+
|
|
3
|
+
`bailinghub/kernel-api/v1` is the versioned, high-level entry point for embedding a complete BailingHub Core in a trusted host. Normal single-organization deployments should keep using `npm start`; this API is for distributions that need host-owned process orchestration, identity integration, or multiple isolated Core instances.
|
|
4
|
+
|
|
5
|
+
The current Core npm artifact keeps TypeScript sources as its runtime entry points. A host must start through the `tsx` runtime installed with Core (for example, `tsx host.ts` or `node --import tsx host.mjs`); this is not a precompiled JavaScript library that plain Node.js can import without a loader. Production hosts should declare `tsx` as a direct runtime dependency instead of relying on transitive installation details.
|
|
6
|
+
|
|
7
|
+
## Boundary
|
|
8
|
+
|
|
9
|
+
- Each Kernel assembles the native configuration repositories, runtime ledger, HTTP routes, tool governance, and lifecycle. A host must not copy or replace the `bz_*` data plane.
|
|
10
|
+
- Every instance needs a separate MySQL schema and a distinct, non-empty absolute `runtimeRoot`. `instanceKey` must come from a trusted host directory, never directly from an end user.
|
|
11
|
+
- `identityProvider` may return only a human `admin/session` identity with explicit permissions. Once injected, human accounts and password changes belong to the Host identity domain; Core hides and disables its local account/password surfaces so a Host cannot create accounts that its own login flow will never accept. Core rejects Host-injected Client, Executor, or admin-token principals at runtime. Native Core credentials still verify Client tokens, Executor tokens, tool signatures, approvals, and final business authorization.
|
|
12
|
+
- `launchGuard` may add distribution policy before Core job creation, but it cannot bypass Core governance.
|
|
13
|
+
- `httpMountPath`, such as `/tenant/acme`, is a trusted same-origin prefix preserved by the console, widget, chat, media, callback URLs, and built-in self-smoke loopback.
|
|
14
|
+
- Hosts must import only this entry point, not `src/app/*`, default singletons, or other internal source paths.
|
|
15
|
+
|
|
16
|
+
## Lifecycle
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {
|
|
20
|
+
createBailingHubKernel,
|
|
21
|
+
loadConfig,
|
|
22
|
+
} from 'bailinghub/kernel-api/v1';
|
|
23
|
+
|
|
24
|
+
const config = loadConfig({ mode: 'kernel-host' });
|
|
25
|
+
// In Host mode config.root resolves to the installed Core artifact; consumer cwd is neither read nor trusted.
|
|
26
|
+
config.runtimeRoot = '/var/lib/my-host/acme';
|
|
27
|
+
// The historical root/.paused default is automatically rebased to runtimeRoot/.paused.
|
|
28
|
+
// An explicitly supplied custom killSwitchFile remains authoritative.
|
|
29
|
+
config.state.backend = 'mysql';
|
|
30
|
+
config.state.mysql = tenantScopedMysql;
|
|
31
|
+
|
|
32
|
+
const kernel = createBailingHubKernel({
|
|
33
|
+
instanceKey: 'tenant:acme',
|
|
34
|
+
config,
|
|
35
|
+
schedulerMode: 'managed',
|
|
36
|
+
httpMountPath: '/tenant/acme',
|
|
37
|
+
bootstrapLocalAdmin: false,
|
|
38
|
+
identityProvider,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await kernel.initialize();
|
|
42
|
+
await kernel.handle(req, res, trustedInnerUrl);
|
|
43
|
+
await kernel.tick(1);
|
|
44
|
+
await kernel.close(30_000);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Managed mode does not create a full timer set per Kernel. The host must call `tick()` fairly and call `close()` during eviction, upgrade, or process shutdown. The 0-600000 ms `close(drainMs)` budget covers initialization, in-flight maintenance/ticks, HTTP, InHub, and execution-queue drain; after drain, Core also clears Kernel-owned transient credential caches such as WeCom access tokens. A timeout preserves the original instance dependencies and reports an error, so the host can retry on that same instance or alert. New `initialize()` and `tick()` calls cannot reopen resources after closing begins.
|
|
48
|
+
|
|
49
|
+
Multiple Kernels may share `KernelExecutionQueueV1` as a process-wide concurrency ceiling. This v1 wrapper exposes only `run()` to the Host; admission, statistics, and drain for each Kernel-local queue remain Core-owned. All Kernels in one process currently need the same `display_tz` and `display_tz_label`.
|
|
50
|
+
|
|
51
|
+
## Artifact And Schema Upgrades
|
|
52
|
+
|
|
53
|
+
`BAILINGHUB_CORE_ARTIFACT_V1` identifies the installed package version, ordered active migration checksums, latest migration, retired-migration evidence, and aggregate manifest checksum. A host should persist these values in its instance directory and match all of them before loading a Kernel. `migrations` is the only sequence that may execute against a new schema. `retiredMigrations` only recognizes ledger history from early deployments; `replay: never` means the corresponding SQL must not be restored or replayed into a new database.
|
|
54
|
+
|
|
55
|
+
`migrateBailingHubCoreSchema()` is the explicit migration entry point. It executes only the installed Core artifact's `sql/*.sql`, uses an advisory lock and migration ledger, and detects historical migration drift with SHA-256. Existing retired-migration ledger rows may receive their checksum from the immutable evidence catalog, but they never enter the execution or fresh-schema ledger sequence. Any unknown history or checksum mismatch fails closed before a new migration runs. Kernel startup never runs DDL implicitly. A host must quiesce the target, drain every replica, migrate with a short-lived schema-only DDL identity, and restore traffic only after the new Kernel passes readiness.
|
|
56
|
+
|
|
57
|
+
## Out Of Scope
|
|
58
|
+
|
|
59
|
+
The Kernel Host API does not provide tenant signup, plans, billing, a platform console, cluster directories, database account management, or multi-replica upgrade orchestration. Those belong to an independent host or distribution and must not add product-specific branches to the open-source single-organization Core.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Kernel Host API v1
|
|
2
|
+
|
|
3
|
+
`bailinghub/kernel-api/v1` 是把完整 BailingHub Core 嵌入受信任宿主的版本化高层入口。它适合需要统一进程编排、独立身份提供方或多个相互隔离 Core 实例的发行版;普通单组织部署继续使用 `npm start`,不需要接触这个 API。
|
|
4
|
+
|
|
5
|
+
当前 Core npm 制品保留 TypeScript 源码作为运行入口,宿主必须通过随 Core 安装的 `tsx` 运行时启动(例如 `tsx host.ts` 或 `node --import tsx host.mjs`);它不是可由纯 Node.js 无 Loader 直接导入的预编译 JavaScript 库。正式宿主应把 `tsx` 作为自己的直接运行依赖,避免依赖传递安装细节。
|
|
6
|
+
|
|
7
|
+
## 边界
|
|
8
|
+
|
|
9
|
+
- Kernel 自己装配原生配置仓储、运行账本、HTTP 路由、工具治理和生命周期。宿主不能复制或替代 `bz_*` 数据面。
|
|
10
|
+
- 每个实例必须使用独立 MySQL Schema 和独立、非空的绝对路径 `runtimeRoot`;`instanceKey` 必须来自宿主可信目录,不能直接相信终端用户输入。
|
|
11
|
+
- `identityProvider` 只能返回带显式权限的 `admin/session` 人类身份;一旦注入,人类账号与改密便归宿主身份域所有,Core 会隐藏并关闭本地账号/密码入口,避免产生无法登录的“死账号”。Core 会在运行时拒绝 Host 注入的 client、executor 或 admin token。Client Token、Executor Token、工具签名、审批与业务系统最终授权仍由 Core 原生链路验证。
|
|
12
|
+
- `launchGuard` 可以增加发行版策略,但只能在 Core 落单前故障关闭,不能绕过 Core 内部治理。
|
|
13
|
+
- `httpMountPath` 是同源路径前缀,例如 `/tenant/acme`;Core 会让控制台、Widget、聊天、媒体、回调 URL 和内建自检保留该前缀。
|
|
14
|
+
- 宿主只能依赖本入口,不应 import `src/app/*`、默认单例或其他内部源码路径。
|
|
15
|
+
|
|
16
|
+
## 生命周期
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import {
|
|
20
|
+
createBailingHubKernel,
|
|
21
|
+
loadConfig,
|
|
22
|
+
} from 'bailinghub/kernel-api/v1';
|
|
23
|
+
|
|
24
|
+
const config = loadConfig({ mode: 'kernel-host' });
|
|
25
|
+
// Host 模式的 config.root 自动指向已安装 Core 制品,不读取或信任宿主 cwd。
|
|
26
|
+
config.runtimeRoot = '/var/lib/my-host/acme';
|
|
27
|
+
// 历史默认 root/.paused 会自动改用 runtimeRoot/.paused;
|
|
28
|
+
// 若宿主显式给出其他 killSwitchFile,Core 保留该值。
|
|
29
|
+
config.state.backend = 'mysql';
|
|
30
|
+
config.state.mysql = tenantScopedMysql;
|
|
31
|
+
|
|
32
|
+
const kernel = createBailingHubKernel({
|
|
33
|
+
instanceKey: 'tenant:acme',
|
|
34
|
+
config,
|
|
35
|
+
schedulerMode: 'managed',
|
|
36
|
+
httpMountPath: '/tenant/acme',
|
|
37
|
+
bootstrapLocalAdmin: false,
|
|
38
|
+
identityProvider,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await kernel.initialize();
|
|
42
|
+
await kernel.handle(req, res, trustedInnerUrl);
|
|
43
|
+
await kernel.tick(1);
|
|
44
|
+
await kernel.close(30_000);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`managed` 模式不为每个 Kernel 创建完整定时器组;宿主必须公平调用 `tick()`,并在淘汰、升级或进程退出时调用 `close()`。`close(drainMs)` 的 0~600000 毫秒时限覆盖初始化、在途维护/tick、HTTP、InHub 与执行队列排空;排空后还会清理 Kernel 自己的企微令牌等瞬时凭证缓存。超时会保留原实例依赖并报错,宿主应在同一实例上重试或告警。`close()` 开始后的新 `initialize()` / `tick()` 不会重开资源。
|
|
48
|
+
|
|
49
|
+
多个 Kernel 可以共享 `KernelExecutionQueueV1` 作为进程级并发上限。这个 v1 包装只向宿主暴露 `run()`;每个 Kernel 内部队列的接入、统计和排空仍由 Core 自己管理。当前同进程实例必须使用相同的 `display_tz` / `display_tz_label`。
|
|
50
|
+
|
|
51
|
+
## 制品与数据库升级
|
|
52
|
+
|
|
53
|
+
`BAILINGHUB_CORE_ARTIFACT_V1` 包含已安装包版本、官方活动迁移摘要、最新迁移名、退役迁移证据和整体 manifest 摘要。宿主应把这些值写入自己的实例目录,并在加载前逐项匹配。`migrations` 只是可在新 Schema 中执行的活动序列;`retiredMigrations` 只用于识别早期部署的历史账本,`replay: never` 表示不得恢复相应 SQL 文件或在新库中重放。
|
|
54
|
+
|
|
55
|
+
`migrateBailingHubCoreSchema()` 是显式迁移入口:它只执行当前 Core 制品自带的 `sql/*.sql`,使用命名锁、迁移账本和 SHA-256 检测历史文件漂移。已存在的退役迁移账本行可按固化证据补录摘要,但不进入执行或新库记账序列;任何未知历史文件或摘要不一致都会在新迁移前失败关闭。Kernel 启动不会隐式执行 DDL;宿主应先停止目标实例新流量、排空所有副本,再用短生命周期且仅限目标 Schema 的 DDL 身份迁移,最后通过新 Kernel readiness 后恢复流量。
|
|
56
|
+
|
|
57
|
+
## 不提供的能力
|
|
58
|
+
|
|
59
|
+
Kernel Host API 不提供租户注册、套餐、计费、平台后台、集群目录、数据库账号管理或多副本升级编排。这些属于独立宿主/发行版,不能以产品便利反向污染开源 Core 的单组织部署边界。
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# Production Operations Guide
|
|
2
|
+
|
|
3
|
+
This guide covers stable self-hosted operation of BailingHub: topology, readiness, capacity, upgrades, backups, and recovery. Use [DEMO.en.md](DEMO.en.md) for evaluation and [QUICKSTART.en.md](QUICKSTART.en.md) for the first installation.
|
|
4
|
+
|
|
5
|
+
## 1. Deployment Topology
|
|
6
|
+
|
|
7
|
+
For development and small pilots, run one BailingHub instance behind an HTTPS reverse proxy with MySQL. Jobs, leases, approvals, distributed rate limits, and audit records are persisted in MySQL. The in-process `Queue` only limits local concurrency; it is not the durable job queue.
|
|
8
|
+
|
|
9
|
+
For rolling upgrades and instance failover, run multiple identical BailingHub replicas behind a load balancer. Every replica must share the same MySQL database, security configuration, build version, and migration level. Use shared object storage for chat media in multi-replica deployments; local media storage is intended for a single instance.
|
|
10
|
+
|
|
11
|
+
Incremental chat events use a short process-local replay window by default. In a multi-replica deployment, route job creation and the SSE connection for the same `job_id` to one replica, or inject a shared `JobStreamBroker`. Without either, the canonical `done` result remains available from MySQL, but the client may not see incremental text.
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
Business systems / channels
|
|
15
|
+
|
|
|
16
|
+
Load balancer / Ingress
|
|
17
|
+
|
|
|
18
|
+
+----+----+
|
|
19
|
+
| |
|
|
20
|
+
Hub A Hub B
|
|
21
|
+
| |
|
|
22
|
+
+----+----+
|
|
23
|
+
|
|
|
24
|
+
Shared MySQL
|
|
25
|
+
|
|
|
26
|
+
Shared object storage
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 2. Health Endpoints
|
|
30
|
+
|
|
31
|
+
| Endpoint | Purpose | Failure action |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| `GET /health` | Liveness: the process responds | Restart the process |
|
|
34
|
+
| `GET /health/ready` | Readiness: MySQL is reachable and migrations are complete | Remove the instance from new traffic |
|
|
35
|
+
|
|
36
|
+
Readiness intentionally does not probe models, tool providers, or channels. A third-party outage must not remove the entire hub from the load balancer. Use system diagnostics and alert rules for those dependencies.
|
|
37
|
+
|
|
38
|
+
`/health` exposes the process-local `observability.audit_write_failures` counter and `last_audit_failure_at`. Any non-zero value should trigger an investigation of structured `audit_write_failed` runtime log events and database health. The counter resets on process restart and does not replace external monitoring. Security-critical audit remains fail-closed; best-effort callers may degrade, but their write failures still pass through this observer first.
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
livenessProbe:
|
|
42
|
+
httpGet: { path: /health, port: 18900 }
|
|
43
|
+
readinessProbe:
|
|
44
|
+
httpGet: { path: /health/ready, port: 18900 }
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## 3. OpenMetrics Operational Metrics
|
|
48
|
+
|
|
49
|
+
`GET /metrics` exposes low-cardinality OpenMetrics text for Prometheus-compatible monitoring systems. It is disabled by default and returns 404 while disabled so an unconfigured deployment does not accidentally expose runtime state.
|
|
50
|
+
|
|
51
|
+
Enable it with:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
BAILING_METRICS_ENABLED=true
|
|
55
|
+
BAILING_METRICS_TOKEN="$(openssl rand -hex 32)"
|
|
56
|
+
BAILING_METRICS_SCRAPE_TIMEOUT_MS=5000
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
`BAILING_METRICS_TOKEN` must be a dedicated random token of at least 24 characters and must not equal `BAILING_TOKEN`. Send it only through the `Authorization: Bearer ...` header; query-string authentication is not supported. Restrict `/metrics` to the monitoring network and retain HTTPS or a controlled cluster network.
|
|
60
|
+
|
|
61
|
+
Verify a scrape:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
curl -fsS \
|
|
65
|
+
-H "Authorization: Bearer ${BAILING_METRICS_TOKEN}" \
|
|
66
|
+
https://hub.example.com/metrics
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Prometheus example:
|
|
70
|
+
|
|
71
|
+
```yaml
|
|
72
|
+
scrape_configs:
|
|
73
|
+
- job_name: bailinghub
|
|
74
|
+
metrics_path: /metrics
|
|
75
|
+
authorization:
|
|
76
|
+
type: Bearer
|
|
77
|
+
credentials_file: /etc/prometheus/secrets/bailinghub_metrics_token
|
|
78
|
+
static_configs:
|
|
79
|
+
- targets: ["bailinghub:18900"]
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Primary metrics:
|
|
83
|
+
|
|
84
|
+
| Metric | Meaning |
|
|
85
|
+
|---|---|
|
|
86
|
+
| `bailinghub_info` | Current version and build commit |
|
|
87
|
+
| `bailinghub_up` | The metrics endpoint served this scrape |
|
|
88
|
+
| `bailinghub_runtime_paused` | Global runtime pause state |
|
|
89
|
+
| `bailinghub_runtime_queue` | Process-local running and waiting counts |
|
|
90
|
+
| `bailinghub_job_records` | Current jobs by fixed lifecycle status |
|
|
91
|
+
| `bailinghub_jobs_terminal_15m` | Jobs entering a terminal state in the last 15 minutes |
|
|
92
|
+
| `bailinghub_queue_oldest_queued_age_seconds` | Age of the oldest non-monitor queued job |
|
|
93
|
+
| `bailinghub_queue_delayed_jobs` | Queued jobs whose `run_after` is still in the future |
|
|
94
|
+
| `bailinghub_jobs_expired_leases` | Running or dispatched jobs with explicitly expired leases |
|
|
95
|
+
| `bailinghub_threads_blocked` | Conversation threads blocked by in-flight work |
|
|
96
|
+
| `bailinghub_approvals_pending` | Tool approvals awaiting a decision |
|
|
97
|
+
| `bailinghub_executors` | Registered executors by online or offline heartbeat state |
|
|
98
|
+
| `bailinghub_audit_write_failures_total` | Audit-write failures observed by this process |
|
|
99
|
+
| `bailinghub_metrics_collector_available` | Whether each optional collector is implemented |
|
|
100
|
+
| `bailinghub_metrics_collector_success` | Whether each collector succeeded during this scrape |
|
|
101
|
+
| `bailinghub_metrics_scrape_duration_seconds` | Collection and rendering duration |
|
|
102
|
+
|
|
103
|
+
Labels are fixed and low-cardinality. They never include job IDs, tenants, principals, route arguments, or business payloads. If an optional collector times out or fails, the endpoint still returns the remaining metrics and sets that collector's `bailinghub_metrics_collector_success` to 0. Logs contain only the collector class and failure class, never exception text or business data. The JSONL state backend can expose job metrics; without the MySQL control-plane aggregation, `control_plane` is reported as unavailable.
|
|
104
|
+
|
|
105
|
+
At minimum, alert on collector failures, expired leases, sustained oldest-queue age above the service objective, increases in audit-write failures, expected executors becoming offline, and abnormal recent error or rejection ratios.
|
|
106
|
+
|
|
107
|
+
Metrics feed external monitoring. They do not replace `/health/ready`, final business authorization, the audit ledger, or console diagnostics.
|
|
108
|
+
|
|
109
|
+
## 4. Concurrency And Database Connections
|
|
110
|
+
|
|
111
|
+
- `concurrency` limits tasks running concurrently in one replica.
|
|
112
|
+
- `BAILING_MYSQL_CONNECTION_LIMIT` controls the pool size per replica; the default is 15.
|
|
113
|
+
- Approximate total connection budget as `replicas × pool size + migration and operator connections`.
|
|
114
|
+
- Do not size the system by HTTP QPS alone. Model latency, tool calls, job duration, and SSE connections materially change capacity.
|
|
115
|
+
- Disable reverse-proxy buffering for SSE and set the upstream read timeout above the maximum chat wait. BailingHub sends `X-Accel-Buffering: no`, but CDN and Ingress behavior must still be verified independently.
|
|
116
|
+
|
|
117
|
+
Measure queue depth, oldest queued age, success rate, P95/P99 duration, tool latency, MySQL connections and lock waits, CPU, memory, and event-loop delay. BailingHub does not publish an unverified universal QPS number; load-test with your actual task mix before making capacity commitments.
|
|
118
|
+
|
|
119
|
+
### Tool semantic retrieval safeguards
|
|
120
|
+
|
|
121
|
+
Tool semantic retrieval is an optional context enhancement. If the index store or query-embedding service exceeds its deadline, that turn falls back to progressive tool discovery instead of leaving the whole conversation waiting indefinitely for retrieval. Two deployment environment variables set independent deadlines:
|
|
122
|
+
|
|
123
|
+
After startup, the process prewarms persisted indexes sequentially in the background; HTTP readiness does not wait for prewarm. An expired in-memory cache continues serving its previous snapshot while a single background refresh runs. Only a true cold cache waits, bounded by the index deadline below.
|
|
124
|
+
|
|
125
|
+
| Variable | Default | Allowed range | Purpose |
|
|
126
|
+
|---|---:|---:|---|
|
|
127
|
+
| `BAILING_TOOL_INDEX_LOAD_TIMEOUT_MS` | 5000 ms | 100–60000 ms | Bounds each database wait for tool vectors and their embedding credential metadata |
|
|
128
|
+
| `BAILING_TOOL_QUERY_EMBEDDING_TIMEOUT_MS` | 15000 ms | 250–120000 ms | Bounds the wait while embedding the current query |
|
|
129
|
+
|
|
130
|
+
These are infrastructure safeguards for one BailingHub deployment, not route-level or provider-level business policy, so they apply to every tool semantic retrieval performed by the process. Validate the deployment's normal latency distribution before lowering them; increasing them prolongs conversation waits during dependency failures.
|
|
131
|
+
|
|
132
|
+
The new stage-diagnostic event records cache state, index/credential/query-embedding latency, and stable reason codes, but carries no user query, service URL, or credential. Diagnostic writes are best-effort and never hold up retrieval fallback.
|
|
133
|
+
|
|
134
|
+
## 5. Upgrades
|
|
135
|
+
|
|
136
|
+
1. Back up MySQL.
|
|
137
|
+
2. Run `npm run release:check` outside production.
|
|
138
|
+
3. Run forward-only migrations from one deployment step. Do not let every replica migrate concurrently.
|
|
139
|
+
4. Start a new replica and wait for `/health/ready` to return 200.
|
|
140
|
+
5. Replace old replicas gradually while observing queue, errors, and lease recovery.
|
|
141
|
+
|
|
142
|
+
Migration state is recorded in `bz_schema_migrations`.
|
|
143
|
+
|
|
144
|
+
## 6. Backup And Recovery
|
|
145
|
+
|
|
146
|
+
Back up the complete MySQL database, object-storage media and knowledge-source files, and a secure copy of deployment configuration and external secrets. Use a consistent MySQL snapshot or `mysqldump --single-transaction`, and regularly perform restore drills.
|
|
147
|
+
|
|
148
|
+
Recovery order:
|
|
149
|
+
|
|
150
|
+
1. Stop traffic to all hub replicas.
|
|
151
|
+
2. Restore MySQL and shared object storage.
|
|
152
|
+
3. Start one build compatible with the restored migration level.
|
|
153
|
+
4. Verify readiness, diagnostics, and a representative trace.
|
|
154
|
+
5. Restore remaining replicas and traffic gradually.
|
|
155
|
+
|
|
156
|
+
## 7. Failure Semantics
|
|
157
|
+
|
|
158
|
+
- A hub crash during work is recovered through the database lease and reaper.
|
|
159
|
+
- Executor report failures are retried; unreported work is eventually recovered by lease expiry.
|
|
160
|
+
- Approval intents remain durable in MySQL.
|
|
161
|
+
- Tool and model failures are recorded in job trace; retry behavior depends on route policy and error type.
|
|
162
|
+
- Security-critical tool audit is fail-closed. Best-effort operational audit must still feed metrics and alerts.
|
|
163
|
+
|
|
164
|
+
## 8. Security Baseline
|
|
165
|
+
|
|
166
|
+
- Expose public traffic only through HTTPS.
|
|
167
|
+
- Use separate credentials for admins, callers, executors, and tool providers.
|
|
168
|
+
- Use a dedicated `BAILING_METRICS_TOKEN` for metrics; never reuse the administrative root token.
|
|
169
|
+
- Do not expose MySQL directly to the Internet.
|
|
170
|
+
- Unattended deployments should set `BAILING_BOOTSTRAP_ADMIN_USERNAME` and `BAILING_BOOTSTRAP_ADMIN_PASSWORD` together. They only create the first account when the admin table is empty; they are not continuously reconciled configuration. Rotate passwords through the console or explicit `admin:create`, not by restarting the service.
|
|
171
|
+
- Rotate credentials and remove demo defaults in production.
|
|
172
|
+
- Keep API keys, database passwords, and sensitive payloads out of public errors, logs, and metric labels.
|
|
173
|
+
|
|
174
|
+
## 9. Go-Live Checklist
|
|
175
|
+
|
|
176
|
+
- `/health` and `/health/ready` return 200.
|
|
177
|
+
- Migration pending count is zero.
|
|
178
|
+
- If operational metrics are enabled, `/metrics` succeeds with the monitoring-only token and collector availability matches the selected backends.
|
|
179
|
+
- System diagnostics report no configuration errors or expired leases.
|
|
180
|
+
- A real `/run`, tool call, trace, and result delivery have completed.
|
|
181
|
+
- Backup restoration has been verified.
|
|
182
|
+
- Alerts cover queue backlog, error rate, executor offline state, and delivery dead letters.
|