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,127 @@
|
|
|
1
|
+
# BailingHub v0.1.9:可选 OpenMetrics 运维指标
|
|
2
|
+
|
|
3
|
+
`v0.1.9` 为自托管部署增加一个默认关闭、可独立鉴权的 OpenMetrics 端点。它把任务积压、执行器存活、审批等待、租约过期和审计写失败等关键运行状态转成稳定、低基数的机器指标,让部署方能够接入 Prometheus 或兼容采集器,而不必解析日志或读取业务载荷。
|
|
4
|
+
|
|
5
|
+
## 为什么需要它
|
|
6
|
+
|
|
7
|
+
日志适合调查单次事件,Trace 适合追踪一条调用链,但生产运维还需要持续回答另一类问题:
|
|
8
|
+
|
|
9
|
+
- 当前有多少任务排队、运行、等待审批或失败;
|
|
10
|
+
- 最老的排队任务已经等待多久;
|
|
11
|
+
- 是否存在过期租约、延迟任务或阻塞线程;
|
|
12
|
+
- 执行器是否在线;
|
|
13
|
+
- 审计写入是否失败;
|
|
14
|
+
- 中枢是否暂停,以及指标采集器自身是否健康。
|
|
15
|
+
|
|
16
|
+
这些信息应当来自状态库和控制面的有界聚合,而不是从日志正文、任务参数或业务数据中推断。
|
|
17
|
+
|
|
18
|
+
## 主要变化
|
|
19
|
+
|
|
20
|
+
### 默认关闭并独立鉴权
|
|
21
|
+
|
|
22
|
+
启用时配置:
|
|
23
|
+
|
|
24
|
+
```text
|
|
25
|
+
BAILING_METRICS_ENABLED=true
|
|
26
|
+
BAILING_METRICS_TOKEN=<至少 24 字符的独立随机令牌>
|
|
27
|
+
BAILING_METRICS_SCRAPE_TIMEOUT_MS=5000
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
安全语义如下:
|
|
31
|
+
|
|
32
|
+
- 默认不暴露 `/metrics`;
|
|
33
|
+
- 启用后必须使用 `Authorization: Bearer <token>`;
|
|
34
|
+
- 不接受 query-string Token;
|
|
35
|
+
- 指标 Token 不能与管理根 Token 复用;
|
|
36
|
+
- 缺少、过短或复用的 Token 会使配置拒绝启动。
|
|
37
|
+
|
|
38
|
+
建议生成独立令牌:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
openssl rand -hex 32
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### 稳定、低基数的指标面
|
|
45
|
+
|
|
46
|
+
指标只暴露固定状态和有界分类,包括:
|
|
47
|
+
|
|
48
|
+
- 当前任务状态计数;
|
|
49
|
+
- 最近时间窗口内的终态结果;
|
|
50
|
+
- 最老排队任务年龄;
|
|
51
|
+
- 延迟任务、过期租约和阻塞线程;
|
|
52
|
+
- 待审批任务;
|
|
53
|
+
- 执行器在线、离线和过期心跳状态;
|
|
54
|
+
- 审计写失败;
|
|
55
|
+
- 运行时暂停状态;
|
|
56
|
+
- 状态库与控制面采集器健康。
|
|
57
|
+
|
|
58
|
+
指标不会包含任务 ID、租户、主体、路由、参数、提示词、响应正文或业务载荷等高基数或敏感标签。
|
|
59
|
+
|
|
60
|
+
### 采集故障隔离
|
|
61
|
+
|
|
62
|
+
状态库和控制面分别在有界超时内采集。任一采集器失败时:
|
|
63
|
+
|
|
64
|
+
- 其他可用指标继续返回;
|
|
65
|
+
- 对应 collector health 指标变为不健康;
|
|
66
|
+
- `/metrics` 不伪造缺失业务状态为零;
|
|
67
|
+
- 采集失败不会改变任务执行、审批或审计主链路。
|
|
68
|
+
|
|
69
|
+
### 数据库索引
|
|
70
|
+
|
|
71
|
+
新增迁移:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
sql/050_operational_metrics_indexes.sql
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
迁移只增加任务终态时间窗口和执行器心跳聚合所需索引,不改变现有表字段或业务语义。
|
|
78
|
+
|
|
79
|
+
官方 Docker 镜像启动时会自动执行 `npm run db:init`。直接从源码运行、使用自定义启动入口或跳过官方 entrypoint 的既有部署,升级后必须先执行:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm run db:init
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## 抓取示例
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
curl -fsS \
|
|
89
|
+
-H "Authorization: Bearer $BAILING_METRICS_TOKEN" \
|
|
90
|
+
http://127.0.0.1:18900/metrics
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
不要把指标 Token 写入 URL、公开配置、截图或日志。
|
|
94
|
+
|
|
95
|
+
## 兼容性边界
|
|
96
|
+
|
|
97
|
+
- `/metrics` 默认关闭,未启用部署的公开行为不变;
|
|
98
|
+
- 不修改 Client API、执行器协议、工具签名、聊天协议或 ACC 语义;
|
|
99
|
+
- 新增状态聚合与控制面指标方法均为可选扩展,既有第三方实现可以继续省略;
|
|
100
|
+
- 指标用于观测,不构成授权、审批证据或业务系统最终裁决。
|
|
101
|
+
|
|
102
|
+
## 验证
|
|
103
|
+
|
|
104
|
+
发布前执行:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
npm run typecheck
|
|
108
|
+
npm test
|
|
109
|
+
npm run docs:check
|
|
110
|
+
npm run security:scan
|
|
111
|
+
npm run release:check
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
部署后建议验证:
|
|
115
|
+
|
|
116
|
+
1. `npm run db:init` 完成且迁移账本包含 `050_operational_metrics_indexes.sql`;
|
|
117
|
+
2. `/health/ready` 返回就绪;
|
|
118
|
+
3. 未启用时 `/metrics` 不可用;
|
|
119
|
+
4. 启用后缺少或使用错误 Token 会被拒绝;
|
|
120
|
+
5. 正确 Token 能得到 OpenMetrics 文本;
|
|
121
|
+
6. 输出不包含任务 ID、主体、参数或业务载荷。
|
|
122
|
+
|
|
123
|
+
## 相关文档
|
|
124
|
+
|
|
125
|
+
- [生产运维](OPERATIONS.md)
|
|
126
|
+
- [兼容性与升级](兼容性与升级.md)
|
|
127
|
+
- [发布记录](CHANGELOG.md)
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# BailingHub v0.2.0: Tool Catalog Access Protection and Active Verification
|
|
2
|
+
|
|
3
|
+
`v0.2.0` turns URL tool-catalog access from an implicit convention into an explicit, verifiable governance control. Operators must state whether a catalog requires signed access or is intentionally public. The console reports configured intent separately from observed evidence instead of assuming that sending a signature proves the endpoint is protected.
|
|
4
|
+
|
|
5
|
+
This release governs who may download a tool catalog. Tool execution keeps the existing signatures, trusted subject, route allowlist, risk approval, idempotency, and final business authorization. ACC and the Client API are unchanged.
|
|
6
|
+
|
|
7
|
+
## User-visible results
|
|
8
|
+
|
|
9
|
+
- New URL providers default to **Signed protection (recommended)**. Operators choose **Public allowed** only when they intentionally accept exposing paths, parameters, scopes, and risk declarations to anyone who can reach the URL. Saving public access requires a second confirmation.
|
|
10
|
+
- The provider list shows the expected policy and the latest observed result independently, including signed, unsigned, and invalid-signature HTTP evidence.
|
|
11
|
+
- Signed mode is `protected` only when the valid signed request returns 2xx and the unsigned plus invalid-signature requests each return 401, 403, or 404.
|
|
12
|
+
- A negative request returning 2xx is `public`. Redirects, 429, 5xx, network errors, and other insufficient evidence are `inconclusive`. Both cases reject the candidate refresh and preserve the previous usable catalog.
|
|
13
|
+
- Public mode sends only an unsigned request and never silently retries with a signature.
|
|
14
|
+
|
|
15
|
+
## Two access policies
|
|
16
|
+
|
|
17
|
+
| Policy | Use case | Hub refresh behavior | Business-side requirement |
|
|
18
|
+
|---|---|---|---|
|
|
19
|
+
| `signed_required` | Default; the catalog must not be anonymous | Read with a valid signature, then run unsigned and invalid-signature probes | Verify the same provider secret used for tool calls; reject negative probes with 401/403/404; prevent protected-response caching |
|
|
20
|
+
| `public_allowed` | Intentional public catalog discovery | Send only an unsigned request | Anonymous GET may return the catalog; tool calls still require independent signatures and authorization |
|
|
21
|
+
|
|
22
|
+
The catalog policy does not replace business authorization. Even with a public catalog, actual tool requests must still validate `X-Bailing-Signature`, `X-Bailing-On-Behalf-Of`, task identity, and business permissions under the existing protocol.
|
|
23
|
+
|
|
24
|
+
## Active probes and cache safety
|
|
25
|
+
|
|
26
|
+
- Each request has a 10-second bound. The two negative probes run concurrently, so their worst-case waits do not add up to 20 seconds.
|
|
27
|
+
- The successful primary response is limited to 5 MiB using both `Content-Length` and actual streamed bytes.
|
|
28
|
+
- Formal policies do not follow redirects, preventing evidence from being attributed to the wrong target after a redirect.
|
|
29
|
+
- Exposure or inconclusive results persist probe evidence and sanitized audit events, while full `spec_url` values are excluded from alert notifications.
|
|
30
|
+
- The cached catalog is replaced only after both policy verification and catalog parsing succeed. Every failure preserves the old cache.
|
|
31
|
+
|
|
32
|
+
## Upgrading existing providers
|
|
33
|
+
|
|
34
|
+
Migration `053_tool_spec_access_policy.sql` adds nullable policy and latest-probe columns to `bz_tool_providers`. The normal upgrade sequence remains:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run db:init
|
|
38
|
+
# then restart BailingHub
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Existing URL providers are not guessed to be public or protected:
|
|
42
|
+
|
|
43
|
+
- their cached catalogs remain unchanged and refresh keeps the previous signed-read behavior;
|
|
44
|
+
- the console labels them **Pending confirmation (historical configuration)** and preselects neither real policy;
|
|
45
|
+
- the internal `legacy_unverified` compatibility marker is read-only, absent from the public Schema, and rejected as a create or update value;
|
|
46
|
+
- disabling a provider or changing descriptive, governance, retrieval, and other non-catalog fields does not force a policy choice;
|
|
47
|
+
- changing the catalog URL, secret, auto-refresh, re-enabling, or another action that changes catalog reads first requires a formal policy;
|
|
48
|
+
- when the latest probe already proves protection, the console can adopt **Signed protection** with one click, while the operator still confirms the decision.
|
|
49
|
+
|
|
50
|
+
After confirmation, the database stores only `signed_required` or `public_allowed`. The internal historical marker is normalized to `NULL` during a later normal save or refresh, with no additional data-cleanup migration.
|
|
51
|
+
|
|
52
|
+
## PHP and PHP7 SDKs
|
|
53
|
+
|
|
54
|
+
PHP and PHP7 `SpecServer` add:
|
|
55
|
+
|
|
56
|
+
- `handlePublic()` for an explicit public catalog response;
|
|
57
|
+
- `respondPublic()` for an explicit bare-PHP public response;
|
|
58
|
+
- `responseHeaders()` for framework integrations;
|
|
59
|
+
- automatic `Cache-Control: private, no-store` on protected `respond($spec, $secret)` responses.
|
|
60
|
+
|
|
61
|
+
The older `handle(..., null)` and `respond($spec, null)` public forms remain compatible. New code should prefer the explicit `Public` helpers so public exposure is not hidden inside a `null` argument.
|
|
62
|
+
|
|
63
|
+
## Compatibility and boundaries
|
|
64
|
+
|
|
65
|
+
- This is an additive minor upgrade. The new database columns are nullable, and older code ignores them.
|
|
66
|
+
- ACC, the Client API version, executor protocol, tool-call signatures, approval semantics, idempotency rules, and final business authorization are unchanged.
|
|
67
|
+
- A new URL provider that omits the policy safely defaults to `signed_required`. Explicitly submitting the internal historical marker is rejected.
|
|
68
|
+
- Custom provider repositories may continue using the existing `upsert` path. The narrow probe-update method is an optional extension point.
|
|
69
|
+
- An application rollback should keep migration 053 and its ledger entry. Restore a full pre-upgrade database snapshot only together with the old application; do not drop the columns or delete the ledger entry independently.
|
|
70
|
+
|
|
71
|
+
## Validation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm run release:check
|
|
75
|
+
npm run e2e:console
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Focused coverage includes:
|
|
79
|
+
|
|
80
|
+
- request behavior and fail-closed handling for both formal policies;
|
|
81
|
+
- signed, unsigned, and invalid-signature status classification;
|
|
82
|
+
- timeout, response-size, and redirect boundaries;
|
|
83
|
+
- old-cache preservation, probe persistence, and alert sanitization;
|
|
84
|
+
- historical records remaining unguessed and requiring confirmation before catalog-sensitive changes;
|
|
85
|
+
- second confirmation for public mode and one-click adoption for protected historical providers;
|
|
86
|
+
- Schema, API, database repository, and PHP/PHP7 SDK compatibility.
|
|
87
|
+
|
|
88
|
+
## Related documentation
|
|
89
|
+
|
|
90
|
+
- [Compatibility and upgrades](COMPATIBILITY.en.md#url-tool-catalog-access-policy-upgrade)
|
|
91
|
+
- [Runtime contract](CONTRACT.en.md)
|
|
92
|
+
- [Integration guide](INTEGRATION.en.md#publish-tools)
|
|
93
|
+
- [Tool governance](TOOLS.en.md)
|
|
94
|
+
- [SDK guide](SDK.en.md)
|
|
95
|
+
- [中文发布说明](RELEASE_NOTES_v0.2.0.md)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# BailingHub v0.2.0:工具清单访问保护与主动核验
|
|
2
|
+
|
|
3
|
+
`v0.2.0` 把 URL 工具清单的读取边界从隐含约定变成可配置、可验证的治理能力。管理员现在必须在“签名保护”和“允许公开”之间明确表达意图;中枢会把配置意图与实际探针结果分开显示,不再因为请求带了签名就假定接口已经受到保护。
|
|
4
|
+
|
|
5
|
+
本版本只治理“谁能下载工具清单”。工具调用继续使用既有签名、可信主体、路由白名单、风险审批、幂等和业务系统最终授权,ACC 与 Client API 均未变化。
|
|
6
|
+
|
|
7
|
+
## 用户可见结果
|
|
8
|
+
|
|
9
|
+
- 新建 URL 工具源默认选择“签名保护(推荐)”。只有管理员明确接受接口路径、参数、scope 和风险声明可被 URL 访问者查看时,才选择“允许公开”,保存时还会再次确认。
|
|
10
|
+
- 工具源列表同时显示“期望策略”和“实测结果”,并保留签名、未签名、错误签名三类 HTTP 状态证据。
|
|
11
|
+
- 受保护模式只有在正确签名返回 2xx,且未签名与错误签名分别返回 401、403 或 404 时才判定为 `protected`。
|
|
12
|
+
- 负向请求仍返回 2xx 时判定为 `public`;重定向、429、5xx、网络错误等不足以证明保护有效的结果判定为 `inconclusive`。两种情况都拒绝替换清单缓存,继续使用上一份可用清单。
|
|
13
|
+
- 公开模式只发送未签名请求,不会在失败时偷偷改用签名读取。
|
|
14
|
+
|
|
15
|
+
## 两种访问策略
|
|
16
|
+
|
|
17
|
+
| 策略 | 适用场景 | 中枢刷新行为 | 业务侧要求 |
|
|
18
|
+
|---|---|---|---|
|
|
19
|
+
| `signed_required` | 默认;清单不应匿名公开 | 正签读取,再执行未签名和错误签名负向探针 | 使用工具源同一密钥验签;负向请求返回 401/403/404;受保护响应禁止缓存 |
|
|
20
|
+
| `public_allowed` | 明确接受公开发现能力清单 | 只发送未签名请求 | 匿名 GET 可返回清单;工具调用仍须独立验签和授权 |
|
|
21
|
+
|
|
22
|
+
配置策略不代替业务授权。即使清单允许公开,真实工具请求仍必须按原协议校验 `X-Bailing-Signature`、`X-Bailing-On-Behalf-Of`、任务身份和业务权限。
|
|
23
|
+
|
|
24
|
+
## 主动探针与缓存安全
|
|
25
|
+
|
|
26
|
+
- 三类请求各自使用 10 秒上限;两个负向探针并发执行,最坏等待不叠加成 20 秒。
|
|
27
|
+
- 正向清单响应最多读取 5 MiB,并同时检查 `Content-Length` 与流式实际字节数。
|
|
28
|
+
- 正式策略不跟随重定向,避免探针在跳转后对错误目标形成结论。
|
|
29
|
+
- 访问泄露或结果无法判定时,探针证据与脱敏审计会被保存,但完整 `spec_url` 不进入告警通知。
|
|
30
|
+
- 只有策略验证和清单解析都通过后才替换缓存;失败始终保留旧缓存。
|
|
31
|
+
|
|
32
|
+
## 历史来源升级
|
|
33
|
+
|
|
34
|
+
新增迁移 `053_tool_spec_access_policy.sql`,为 `bz_tool_providers` 增加可空的访问策略和最近探针字段。升级顺序仍是:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run db:init
|
|
38
|
+
# 然后重启 BailingHub
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
升级前已有的 URL 工具源不会被系统猜成公开或已保护:
|
|
42
|
+
|
|
43
|
+
- 现有缓存保持不变,刷新继续沿用原来的签名读取方式;
|
|
44
|
+
- 控制台显示“待确认(历史配置)”,两个正式策略均不预选;
|
|
45
|
+
- 内部兼容标记 `legacy_unverified` 只用于读取历史记录,不属于公开 Schema,也不能作为 API 新建或更新值;
|
|
46
|
+
- 停用来源或修改说明、治理、检索等非清单字段不强迫选择策略;
|
|
47
|
+
- 修改清单 URL、密钥、自动刷新、重新启用等会改变清单读取面的操作,必须先选择正式策略;
|
|
48
|
+
- 最近探针已证明端点受保护时,控制台可一键采用“签名保护”,但仍由管理员明确确认。
|
|
49
|
+
|
|
50
|
+
管理员完成选择后,数据库只保存 `signed_required` 或 `public_allowed`。内部历史标记在后续正常保存或刷新时归一化为 `NULL`,无需额外数据清洗迁移。
|
|
51
|
+
|
|
52
|
+
## PHP / PHP7 SDK
|
|
53
|
+
|
|
54
|
+
PHP 与 PHP7 `SpecServer` 新增:
|
|
55
|
+
|
|
56
|
+
- `handlePublic()`:显式返回公开清单;
|
|
57
|
+
- `respondPublic()`:裸 PHP 显式公开响应;
|
|
58
|
+
- `responseHeaders()`:框架接入时取得推荐响应头;
|
|
59
|
+
- `respond($spec, $secret)`:传入密钥的受保护响应自动增加 `Cache-Control: private, no-store`。
|
|
60
|
+
|
|
61
|
+
旧的 `handle(..., null)` / `respond($spec, null)` 公开写法继续兼容,但新代码推荐使用带 `Public` 的显式入口,避免把公开意图隐藏在 `null` 中。
|
|
62
|
+
|
|
63
|
+
## 兼容性与边界
|
|
64
|
+
|
|
65
|
+
- 这是只增不改的 minor 升级;新增数据库字段均可空,旧代码会忽略它们。
|
|
66
|
+
- 不修改 ACC、Client API 版本、执行器协议、工具调用签名、审批语义、幂等规则或最终业务授权。
|
|
67
|
+
- 新建 URL 来源省略策略时安全默认 `signed_required`;显式提交内部历史标记会被拒绝。
|
|
68
|
+
- 自定义工具源仓储可继续使用既有 `upsert`;新的窄探针更新方法为可选扩展点。
|
|
69
|
+
- 回滚应用时应保留 053 新列和迁移账本。只有协调恢复旧应用与完整数据库快照时才回退数据库,不要单独删除账本或字段。
|
|
70
|
+
|
|
71
|
+
## 验证
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm run release:check
|
|
75
|
+
npm run e2e:console
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
重点覆盖:
|
|
79
|
+
|
|
80
|
+
- 两种正式策略的请求方式和失败关闭行为;
|
|
81
|
+
- 正签、未签名、错误签名状态分类;
|
|
82
|
+
- 超时、响应大小和重定向边界;
|
|
83
|
+
- 旧缓存保留、探针持久化与告警脱敏;
|
|
84
|
+
- 历史记录不被自动猜测、敏感修改前强制确认;
|
|
85
|
+
- 公开模式二次确认和已保护历史来源的一键采用;
|
|
86
|
+
- Schema、API、数据库仓储与 PHP / PHP7 SDK 兼容性。
|
|
87
|
+
|
|
88
|
+
## 相关文档
|
|
89
|
+
|
|
90
|
+
- [兼容性与升级](兼容性与升级.md#十url-工具清单访问策略升级)
|
|
91
|
+
- [公开运行时契约](CONTRACT.md)
|
|
92
|
+
- [第三方对接指南](第三方对接指南.md#63-发布接口清单--后台注册)
|
|
93
|
+
- [工具治理设计](TOOLS_DESIGN.md)
|
|
94
|
+
- [PHP SDK](../sdk/php/README.md)
|
|
95
|
+
- [PHP7 SDK](../sdk/php7/README.md)
|
|
96
|
+
- [English release notes](RELEASE_NOTES_v0.2.0.en.md)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# BailingHub v0.3.0: Composable Core and Kernel Host API v1
|
|
2
|
+
|
|
3
|
+
`v0.3.0` makes the same open-source BailingHub Core usable either as the existing standalone service or as a formally composed Kernel inside another host. An external product, managed platform, or deployment system can pin the public npm artifact and create and mount Kernels through `bailinghub/kernel-api/v1` without copying or forking Core routing, tools, jobs, messages, approvals, or audit behavior.
|
|
4
|
+
|
|
5
|
+
The startup path, console, and public HTTP contract for ordinary self-hosted deployments remain unchanged. This release adds a composition boundary; it does not move hosted multi-tenancy into the open-source Core.
|
|
6
|
+
|
|
7
|
+
## Main changes
|
|
8
|
+
|
|
9
|
+
- Added the stable `bailinghub/kernel-api/v1` export for Kernel construction, lifecycle, HTTP mounting, Core Schema migration, and exact artifact identity.
|
|
10
|
+
- One process may create multiple independent Kernel instances. The host must provide a separate state database, runtime directory, configuration, and request prefix for every instance, while retaining responsibility for tenant identity, authorization, plans, and lifecycle.
|
|
11
|
+
- HTTP mounting supports path prefixes without relying on one global singleton or a fixed root path. The standalone server now composes the same Kernel so hosted and standalone execution do not become separate implementations.
|
|
12
|
+
- The mount prefix also scopes built-in self-smoke requests. `runtimeRoot` takes over the historical default pause file, and Kernel shutdown destroys its own transient channel-credential caches.
|
|
13
|
+
- Once an `identityProvider` is injected, human accounts and password changes explicitly belong to the Host identity domain. Core no longer exposes or accepts local accounts that the Host login flow cannot use.
|
|
14
|
+
- Configuration, state, runtime, and route dependencies are exposed through narrow composition seams. Internal modules outside `kernel-api/v1` are not public extension contracts.
|
|
15
|
+
- The npm package includes the Kernel API, official SQL, console assets, and artifact-verification inputs. Release checks install the real `.tgz` and verify its stable exports.
|
|
16
|
+
|
|
17
|
+
## Official Schema Migrator
|
|
18
|
+
|
|
19
|
+
A host must not rely on Kernel startup to mutate a database implicitly. Deployment and upgrade orchestration calls the official migrator explicitly and starts or resumes traffic only after it succeeds.
|
|
20
|
+
|
|
21
|
+
The migration ledger now includes `checksum_sha256`:
|
|
22
|
+
|
|
23
|
+
- a fresh Schema executes only the current 49 active migrations and records each digest;
|
|
24
|
+
- an existing deployment safely backfills digests without replaying recorded SQL;
|
|
25
|
+
- three early-deployment records, `020_provider_sign_version.sql`, `021_drop_provider_sign_version.sql`, and `037_route_tools_shape.sql`, are preserved as retired evidence with `replay: never`; old ledgers can recognize and backfill their original digests, while fresh Schemas never execute or insert them;
|
|
26
|
+
- any published-migration digest drift or ledger filename unknown to the installed artifact fails closed before digest backfill or new migration execution.
|
|
27
|
+
|
|
28
|
+
This release adds no business table or business column. A standalone upgrade still runs:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run db:init
|
|
32
|
+
# restart BailingHub only after it succeeds
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Digest-backfill messages are expected on the first run with a legacy ledger. Do not delete historical ledger rows or restore retired SQL files to `sql/`.
|
|
36
|
+
|
|
37
|
+
## Exact artifacts and host requirements
|
|
38
|
+
|
|
39
|
+
Production hosts should use an exact package version and lockfile rather than `latest`, a SemVer range, a Git branch, or a local link:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install --save-exact bailinghub@0.3.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Before startup, verify the installed version and the lockfile's immutable HTTPS `.tgz` URL plus sha512 `integrity`. `BAILINGHUB_CORE_ARTIFACT_V1` exposes the version, active migrations, retired evidence, and aggregate digest for startup, provisioning, and fleet-upgrade checks.
|
|
46
|
+
|
|
47
|
+
## Compatibility and boundaries
|
|
48
|
+
|
|
49
|
+
- Standalone public pages, the Client API, chat protocol, Executor Protocol, tool signatures, approval semantics, and final business authorization are unchanged.
|
|
50
|
+
- ACC is unchanged. Ecosystem adapters continue to consume the existing Client API or Executor Protocol and do not need a package release solely because of the Kernel Host API.
|
|
51
|
+
- The Kernel Host API does not provide platform accounts, tenant directories, registration, billing, plans, or cross-tenant routing. Those remain host-product control-plane responsibilities.
|
|
52
|
+
- `kernel-api/v1` is the supported composition entry. Direct imports from `src/app`, `src/routes`, repository implementations, or other internal files are outside the compatibility commitment.
|
|
53
|
+
- Image publication now enforces an executable policy: prerelease tags can never update `latest`; stable tags may update the stable channel according to release configuration.
|
|
54
|
+
|
|
55
|
+
## Validation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run release:check
|
|
59
|
+
npm pack --dry-run
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Focused coverage includes:
|
|
63
|
+
|
|
64
|
+
- standalone and hosted execution composing the same Kernel path;
|
|
65
|
+
- per-instance state, configuration, runtime-directory, and request-prefix isolation;
|
|
66
|
+
- Kernel start, drain, stop, and resource cleanup;
|
|
67
|
+
- fresh and legacy migration ledgers, digest backfill, retired evidence, and fail-closed unknown migrations;
|
|
68
|
+
- real npm tarball exports, assets, SQL, and artifact identity;
|
|
69
|
+
- prerelease images being unable to overwrite `latest`.
|
|
70
|
+
|
|
71
|
+
## Related documentation
|
|
72
|
+
|
|
73
|
+
- [Kernel Host API v1](KERNEL_HOST_API.en.md)
|
|
74
|
+
- [SQL migration discipline](../sql/README.en.md)
|
|
75
|
+
- [Architecture](ARCHITECTURE.en.md)
|
|
76
|
+
- [Compatibility and upgrades](COMPATIBILITY.en.md)
|
|
77
|
+
- [中文发布说明](RELEASE_NOTES_v0.3.0.md)
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# BailingHub v0.3.0:可组合 Core 与 Kernel Host API v1
|
|
2
|
+
|
|
3
|
+
`v0.3.0` 把原来只能作为单体服务运行的开源 BailingHub,进一步整理成既可独立部署、也可由其他宿主按正式接口装配的同一套 Core。外部产品、托管平台或其他部署系统可以精确依赖公开 npm 制品,通过 `bailinghub/kernel-api/v1` 创建并挂载 Kernel,而不需要复制或分叉 Core 的路由、工具、任务、消息、审批和审计实现。
|
|
4
|
+
|
|
5
|
+
普通自托管用户的启动方式、控制台和公开 HTTP 契约保持不变。本版本新增的是组合边界,不是把托管平台或多租户实现放进开源 Core。
|
|
6
|
+
|
|
7
|
+
## 主要变化
|
|
8
|
+
|
|
9
|
+
- 新增稳定导出 `bailinghub/kernel-api/v1`,提供 Kernel 创建、生命周期、HTTP 挂载、Core Schema 迁移与精确制品身份。
|
|
10
|
+
- 同一进程可以创建多个彼此独立的 Kernel 实例;宿主必须为每个实例提供独立状态库、运行目录、配置和请求前缀,并继续承担租户身份、授权、套餐及生命周期管理。
|
|
11
|
+
- HTTP 挂载支持前缀路径,不依赖全局单例或固定根路径。开源版原有服务入口也改为装配同一个 Kernel,避免“独立部署一套实现、被宿主使用又是一套实现”。
|
|
12
|
+
- 挂载前缀同时用于内建自检;`runtimeRoot` 会承接历史默认暂停文件,Kernel 关闭时还会销毁自己的瞬时渠道凭证缓存。
|
|
13
|
+
- 注入 `identityProvider` 后,人类账号和改密明确归宿主身份域管理;Core 不再展示或接受无法被宿主登录流程使用的本地账号。
|
|
14
|
+
- Core 内部的配置、状态、运行时和路由依赖通过窄接口注入;未列入 `kernel-api/v1` 的内部模块仍不是公共扩展契约。
|
|
15
|
+
- npm 包会携带 Kernel API、官方 SQL、控制台静态产物和制品校验所需文件;发布门禁会从真实 `.tgz` 安装并验证稳定导出。
|
|
16
|
+
|
|
17
|
+
## 官方 Schema Migrator
|
|
18
|
+
|
|
19
|
+
宿主不能依靠 Kernel 启动时隐式改库。部署或升级必须显式调用官方迁移器,并在成功后再启动或恢复流量。
|
|
20
|
+
|
|
21
|
+
迁移账本现在增加 `checksum_sha256`:
|
|
22
|
+
|
|
23
|
+
- 新 Schema 只执行当前 49 条活动迁移,并为每条迁移写入摘要;
|
|
24
|
+
- 旧部署会为已有账本安全补录摘要,不重放已记账 SQL;
|
|
25
|
+
- 三条只存在于早期部署历史中的迁移 `020_provider_sign_version.sql`、`021_drop_provider_sign_version.sql` 和 `037_route_tools_shape.sql` 被登记为 `replay: never` 的退役证据;旧账本可以识别并补录其原始摘要,新 Schema 永不执行或插入它们;
|
|
26
|
+
- 任一已发布迁移摘要漂移,或账本出现当前制品不认识的迁移,都会在补录摘要和执行新迁移前失败关闭。
|
|
27
|
+
|
|
28
|
+
这次没有新增业务表或业务字段。独立部署升级仍运行:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm run db:init
|
|
32
|
+
# 成功后再重启 BailingHub
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
首次从旧迁移器升级时,看到已有文件被“摘要补录”属于预期;不应手工删除历史账本或把退役 SQL 放回 `sql/`。
|
|
36
|
+
|
|
37
|
+
## 精确制品与宿主要求
|
|
38
|
+
|
|
39
|
+
宿主应使用精确版本和锁文件,不使用 `latest`、SemVer 范围、Git 分支或本地软链接作为正式环境来源:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install --save-exact bailinghub@0.3.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
运行前应核对安装版本、lockfile 中的 HTTPS `.tgz` 地址与 sha512 `integrity`。`BAILINGHUB_CORE_ARTIFACT_V1` 同时暴露当前版本、活动迁移、退役证据和整体摘要,供宿主在启动、租户开通与升级编排中做一致性检查。
|
|
46
|
+
|
|
47
|
+
## 兼容性与边界
|
|
48
|
+
|
|
49
|
+
- 独立部署的公开页面、Client API、聊天协议、Executor Protocol、工具签名、审批语义和业务系统最终授权均未改变。
|
|
50
|
+
- ACC 规范没有变化;生态适配器仍只消费既有 Client API 或 Executor Protocol,不需要因 Kernel Host API 升级包版本。
|
|
51
|
+
- Kernel Host API 不提供平台账号、租户目录、注册、计费、套餐或跨租户路由。这些属于宿主产品自己的控制面。
|
|
52
|
+
- `kernel-api/v1` 是本版本承诺的组合入口;直接导入 `src/app`、`src/routes`、仓储实现或其他内部文件不属于兼容承诺。
|
|
53
|
+
- 镜像发布策略新增可执行门禁:预发布标签永远不能更新 `latest`,稳定标签才可按发布配置更新稳定通道。
|
|
54
|
+
|
|
55
|
+
## 验证
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run release:check
|
|
59
|
+
npm pack --dry-run
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
重点覆盖:
|
|
63
|
+
|
|
64
|
+
- 独立服务与宿主挂载使用同一个 Kernel 组合路径;
|
|
65
|
+
- 多实例状态、配置、运行目录和请求前缀隔离;
|
|
66
|
+
- Kernel 启停、请求排空和资源释放;
|
|
67
|
+
- 新旧迁移账本、摘要补录、退役迁移与未知迁移失败关闭;
|
|
68
|
+
- 真实 npm tarball 的导出、静态资源、SQL 和制品描述完整性;
|
|
69
|
+
- 预发布镜像不能覆盖 `latest`。
|
|
70
|
+
|
|
71
|
+
## 相关文档
|
|
72
|
+
|
|
73
|
+
- [Kernel Host API v1](KERNEL_HOST_API.md)
|
|
74
|
+
- [SQL 迁移纪律](../sql/README.md)
|
|
75
|
+
- [架构说明](ARCHITECTURE.md)
|
|
76
|
+
- [兼容性与升级](兼容性与升级.md)
|
|
77
|
+
- [English release notes](RELEASE_NOTES_v0.3.0.en.md)
|
package/docs/SDK.en.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# SDK Guide
|
|
2
|
+
|
|
3
|
+
BailingHub SDKs are helper libraries for business systems.
|
|
4
|
+
|
|
5
|
+
They do six things:
|
|
6
|
+
|
|
7
|
+
1. generate OpenAPI tool specs
|
|
8
|
+
2. verify signed tool calls from the hub
|
|
9
|
+
3. verify delivery callbacks
|
|
10
|
+
4. sign authenticated visitor tickets for the web widget
|
|
11
|
+
5. implement authorization-probe helpers
|
|
12
|
+
6. call hub APIs such as `/run`, `/jobs/{id}`, and `/send`
|
|
13
|
+
|
|
14
|
+
The SDK is a convenience layer. The stable contract is still OpenAPI + `x-agent-capability` metadata + HMAC signatures.
|
|
15
|
+
|
|
16
|
+
## Available SDKs
|
|
17
|
+
|
|
18
|
+
| Runtime | Path | Purpose |
|
|
19
|
+
|---|---|---|
|
|
20
|
+
| PHP 8+ | `sdk/php` | Attribute-based tool declarations and signature helpers. |
|
|
21
|
+
| PHP 7.3+ | `sdk/php7` | Builder-style tool declarations for older PHP projects. |
|
|
22
|
+
| Node.js | `sdk/node` | `buildOpenApiSpec`, `tool`, `param`, `signTicket`, `HubClient`, verification helpers. |
|
|
23
|
+
| Python | `sdk/python` | `build_openapi_spec`, `tool`, `param`, `sign_ticket`, `HubClient`, verification helpers. |
|
|
24
|
+
| Java 11+ | `sdk/java` | Standard-library SDK for JVM business services. |
|
|
25
|
+
| Go 1.21+ | `sdk/go` | Standard-library SDK for Go services and gateways. |
|
|
26
|
+
| .NET 8+ | `sdk/dotnet` | Standard-library SDK for C# business services. |
|
|
27
|
+
|
|
28
|
+
## Common Helper Surface
|
|
29
|
+
|
|
30
|
+
The exact method names follow each language's style, but every official SDK should cover the same surface:
|
|
31
|
+
|
|
32
|
+
| Capability | PHP | Node | Python | Java / Go / .NET |
|
|
33
|
+
|---|---|---|---|---|
|
|
34
|
+
| Tool spec | annotations / builder | `buildOpenApiSpec` | `build_openapi_spec` | `BuildOpenApiSpec` / `BuildOpenAPISpec` |
|
|
35
|
+
| Visitor ticket | `Ticket::sign` | `signTicket` | `sign_ticket` | `signTicket` / `SignTicket` |
|
|
36
|
+
| Tool call verification | `Verify::gate` / `Verify::toolCall` | `verifyToolCall` | `verify_tool_call` | `verifyToolCall` / `VerifyToolCall` |
|
|
37
|
+
| Callback verification | `Verify::callback` | `verifyCallback` | `verify_callback` | `verifyCallback` / `VerifyCallback` |
|
|
38
|
+
| Authz probe | `SpecServer::authzProbe` | `authzProbeResponse` | `authz_probe_response` | `authzProbeResponse` / `AuthzProbeResponse` |
|
|
39
|
+
| PHP spec serving | `SpecServer::handle` / `respond` / `handlePublic` / `respondPublic` | — | — | — |
|
|
40
|
+
| Hub APIs | `HubClient` | `HubClient` | `HubClient` | `HubClient` |
|
|
41
|
+
|
|
42
|
+
## PHP Spec Endpoint Security
|
|
43
|
+
|
|
44
|
+
Pass the tool-provider secret to `SpecServer::handle()` or `respond()` for a
|
|
45
|
+
signed-only spec endpoint. Bare PHP `respond()` automatically emits
|
|
46
|
+
`Cache-Control: private, no-store`; framework integrations should apply
|
|
47
|
+
`SpecServer::responseHeaders($secret)` to the returned response.
|
|
48
|
+
|
|
49
|
+
The console exposes exactly two catalog policies: `signed_required` for the
|
|
50
|
+
protected form above and `public_allowed` for an intentionally public catalog.
|
|
51
|
+
For the latter, use `SpecServer::handlePublic()` or
|
|
52
|
+
`SpecServer::respondPublic()`. The
|
|
53
|
+
older `null` secret argument remains compatible, but the explicit helper keeps
|
|
54
|
+
the security decision visible in code. Public catalog access never makes tool
|
|
55
|
+
calls public: every tool call still requires signature verification and the
|
|
56
|
+
business system's on-behalf-of authorization.
|
|
57
|
+
|
|
58
|
+
## Node Example
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { buildOpenApiSpec, param, tool } from '@bailinghub/connect';
|
|
62
|
+
|
|
63
|
+
const spec = buildOpenApiSpec({
|
|
64
|
+
title: 'CRM Tools',
|
|
65
|
+
version: '1.0.0',
|
|
66
|
+
authzProbe: { method: 'POST', path: '/.well-known/bailing/authz-probe' },
|
|
67
|
+
tools: [
|
|
68
|
+
tool({
|
|
69
|
+
name: 'member_query',
|
|
70
|
+
method: 'GET',
|
|
71
|
+
path: '/api/members/{id}',
|
|
72
|
+
description: 'Query member profile',
|
|
73
|
+
scope: 'member.read',
|
|
74
|
+
requiresSubject: true,
|
|
75
|
+
params: [param('id', { in: 'path', required: true, description: 'Member ID' })],
|
|
76
|
+
}),
|
|
77
|
+
],
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
console.log(JSON.stringify(spec, null, 2));
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Verify a tool call:
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
import { verifyToolCall } from '@bailinghub/connect';
|
|
87
|
+
|
|
88
|
+
const ok = verifyToolCall(process.env.BAILING_TOOL_SECRET, {
|
|
89
|
+
method: request.method,
|
|
90
|
+
pathWithQuery,
|
|
91
|
+
body: rawBody,
|
|
92
|
+
timestamp: request.headers.get('x-bailing-timestamp'),
|
|
93
|
+
signature: request.headers.get('x-bailing-signature'),
|
|
94
|
+
onBehalfOf: request.headers.get('x-bailing-on-behalf-of') || '',
|
|
95
|
+
jobId: request.headers.get('x-bailing-job-id') || '',
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
After verification, still check your own permission table.
|
|
100
|
+
|
|
101
|
+
## Python Example
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
from bailing_connect import build_openapi_spec, param, tool
|
|
105
|
+
|
|
106
|
+
spec = build_openapi_spec(
|
|
107
|
+
title="CRM Tools",
|
|
108
|
+
version="1.0.0",
|
|
109
|
+
authz_probe={"method": "POST", "path": "/.well-known/bailing/authz-probe"},
|
|
110
|
+
tools=[
|
|
111
|
+
tool(
|
|
112
|
+
name="member_query",
|
|
113
|
+
method="GET",
|
|
114
|
+
path="/api/members/{id}",
|
|
115
|
+
description="Query member profile",
|
|
116
|
+
scope="member.read",
|
|
117
|
+
requiresSubject=True,
|
|
118
|
+
params=[param("id", **{"in": "path", "required": True, "description": "Member ID"})],
|
|
119
|
+
)
|
|
120
|
+
],
|
|
121
|
+
)
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Hub Client Example
|
|
125
|
+
|
|
126
|
+
The hub client is a thin wrapper over the stable HTTP contract:
|
|
127
|
+
|
|
128
|
+
```js
|
|
129
|
+
import { HubClient } from '@bailinghub/connect';
|
|
130
|
+
|
|
131
|
+
const hub = new HubClient({ baseUrl: 'https://hub.example.com', token: process.env.BAILING_CLIENT_TOKEN });
|
|
132
|
+
|
|
133
|
+
const job = await hub.run({
|
|
134
|
+
requestId: 'crm_1001',
|
|
135
|
+
route: 'member-support',
|
|
136
|
+
input: 'Check member recharge records',
|
|
137
|
+
metadata: { principal: { id: 'u1001', tenant: 't1' } },
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const result = await hub.getJob(job.job_id);
|
|
141
|
+
await hub.send({ requestId: 'notice_1001', channel: 'team-im', to: 'user_001', text: 'Task completed' });
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## PHP 8+ Example
|
|
145
|
+
|
|
146
|
+
```php
|
|
147
|
+
#[AiTool(
|
|
148
|
+
description: 'Query member profile',
|
|
149
|
+
name: 'member_query',
|
|
150
|
+
scope: 'member.read',
|
|
151
|
+
path: '/api/members/query',
|
|
152
|
+
method: 'POST',
|
|
153
|
+
readonly: true,
|
|
154
|
+
idempotent: true,
|
|
155
|
+
sensitive: true,
|
|
156
|
+
requiresSubject: true,
|
|
157
|
+
)]
|
|
158
|
+
#[AiParam('mobile', description: 'Member mobile phone', required: true, format: 'phone')]
|
|
159
|
+
public function memberQuery(): void
|
|
160
|
+
{
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Contract Test
|
|
165
|
+
|
|
166
|
+
All SDKs are validated against the same tool contract:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
npm run sdk:test
|
|
170
|
+
npm run sdk:test7
|
|
171
|
+
npm run sdk:test-node
|
|
172
|
+
npm run sdk:test-python
|
|
173
|
+
npm run sdk:test-runtime
|
|
174
|
+
npm run sdk:test-p1
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
These tests build SDK-generated specs, compile them through the hub's OpenAPI tool compiler, verify runtime helpers across PHP/Node/Python, and compile or source-check the Java/Go/.NET SDKs depending on the local toolchain.
|