create-principles-disciple 1.101.0 → 1.103.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/console/dist/server/config/pd-config-store.d.ts +50 -1
- package/console/dist/server/config/pd-config-store.js +364 -1
- package/console/dist/server/index.js +9 -0
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +44 -5
- package/console/dist/server/models/ActivationsConsoleModel.js +118 -16
- package/console/dist/server/routes/config.js +92 -2
- package/console/dist/server/routes/onboarding.d.ts +34 -0
- package/console/dist/server/routes/onboarding.js +324 -0
- package/console/dist/ui/App.js +74 -15
- package/console/dist/ui/api.d.ts +60 -3
- package/console/dist/ui/api.js +63 -2
- package/console/dist/ui/components/onboarding/CircuitDiagram.d.ts +8 -0
- package/console/dist/ui/components/onboarding/CircuitDiagram.js +18 -0
- package/console/dist/ui/components/onboarding/DemoResultView.d.ts +22 -0
- package/console/dist/ui/components/onboarding/DemoResultView.js +33 -0
- package/console/dist/ui/i18n/en.json +189 -1
- package/console/dist/ui/i18n/zh-CN.json +189 -1
- package/console/dist/ui/pages/activation/ActivationPage.js +11 -11
- package/console/dist/ui/pages/activation/ActivationValidators.js +15 -14
- package/console/dist/ui/pages/control-center/AgentCard.js +66 -10
- package/console/dist/ui/pages/control-center/ControlCenterPage.js +3 -2
- package/console/dist/ui/pages/control-center/RuntimeProfileManager.d.ts +31 -0
- package/console/dist/ui/pages/control-center/RuntimeProfileManager.js +234 -0
- package/console/dist/ui/pages/debt/DebtPage.js +2 -2
- package/console/dist/ui/pages/settings/SettingsPage.js +64 -5
- package/console/dist/ui/pages/signal-keywords/KeywordEditDialog.d.ts +12 -0
- package/console/dist/ui/pages/signal-keywords/KeywordEditDialog.js +41 -0
- package/console/dist/ui/pages/signal-keywords/KeywordListSection.d.ts +10 -0
- package/console/dist/ui/pages/signal-keywords/KeywordListSection.js +39 -0
- package/console/dist/ui/pages/signal-keywords/PendingTermsSection.d.ts +14 -0
- package/console/dist/ui/pages/signal-keywords/PendingTermsSection.js +35 -0
- package/console/dist/ui/pages/signal-keywords/SignalKeywordsPage.d.ts +1 -0
- package/console/dist/ui/pages/signal-keywords/SignalKeywordsPage.js +49 -0
- package/console/dist/ui/pages/welcome/WelcomePage.d.ts +5 -0
- package/console/dist/ui/pages/welcome/WelcomePage.js +185 -0
- package/console/dist/ui/utils/__tests__/onboarding-state.test.d.ts +1 -0
- package/console/dist/ui/utils/__tests__/onboarding-state.test.js +72 -0
- package/console/dist/ui/utils/agent-metadata.d.ts +13 -0
- package/console/dist/ui/utils/agent-metadata.js +26 -0
- package/console/dist/ui/utils/onboarding-state.d.ts +25 -0
- package/console/dist/ui/utils/onboarding-state.js +77 -0
- package/console/dist/ui/utils/signal-keywords-api.d.ts +68 -0
- package/console/dist/ui/utils/signal-keywords-api.js +121 -0
- package/console/dist/ui/utils/signal-keywords-types.d.ts +57 -0
- package/console/dist/ui/utils/signal-keywords-types.js +10 -0
- package/console/dist/ui/utils/signal-keywords-validators.d.ts +20 -0
- package/console/dist/ui/utils/signal-keywords-validators.js +114 -0
- package/console/dist/ui/utils/validators.d.ts +26 -3
- package/console/dist/ui/utils/validators.js +23 -6
- package/console/dist/web/assets/app.css +442 -0
- package/console/dist/web/assets/app.js +7793 -1966
- package/core/dist/index.d.ts +2 -0
- package/core/dist/index.d.ts.map +1 -1
- package/core/dist/index.js +1 -0
- package/core/dist/index.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +14 -2
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js +28 -0
- package/core/dist/runtime-v2/__tests__/evaluator-runner-vslice-v2.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js +8 -0
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js +8 -10
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/index.d.ts +1 -1
- package/core/dist/runtime-v2/activation/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/index.js +1 -1
- package/core/dist/runtime-v2/activation/index.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js +240 -1
- package/core/dist/runtime-v2/activation/writers/__tests__/rule-host-writer.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts +12 -0
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js +81 -1
- package/core/dist/runtime-v2/activation/writers/rule-host-writer.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.d.ts +2 -0
- package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.js +81 -0
- package/core/dist/runtime-v2/adapter/__tests__/l2-resolve-model-compat.test.js.map +1 -0
- package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js +19 -0
- package/core/dist/runtime-v2/adapter/__tests__/pi-ai-runtime-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts +8 -0
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js +4 -1
- package/core/dist/runtime-v2/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime-v2/candidate-intake-service.d.ts.map +1 -1
- package/core/dist/runtime-v2/candidate-intake-service.js +92 -6
- package/core/dist/runtime-v2/candidate-intake-service.js.map +1 -1
- package/core/dist/runtime-v2/candidate-intake.d.ts +38 -0
- package/core/dist/runtime-v2/candidate-intake.d.ts.map +1 -1
- package/core/dist/runtime-v2/candidate-intake.js +48 -0
- package/core/dist/runtime-v2/candidate-intake.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.d.ts +2 -0
- package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.js +15 -0
- package/core/dist/runtime-v2/config/__tests__/internal-agent-names.test.js.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +33 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js +10 -5
- package/core/dist/runtime-v2/config/__tests__/pd-config-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-redaction-deep.test.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +54 -33
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js.map +1 -1
- package/core/dist/runtime-v2/config/index.d.ts +5 -3
- package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/index.js +8 -2
- package/core/dist/runtime-v2/config/index.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts +2 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js +3 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.d.ts +8 -3
- package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js +39 -3
- package/core/dist/runtime-v2/config/pd-config-defaults.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-effective.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-effective.js +25 -1
- package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-redaction.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-redaction.js +14 -2
- package/core/dist/runtime-v2/config/pd-config-redaction.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.d.ts +116 -1
- package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.js +7 -0
- package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-validate.js +125 -7
- package/core/dist/runtime-v2/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-profile-constants.d.ts +27 -0
- package/core/dist/runtime-v2/config/pd-profile-constants.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/pd-profile-constants.js +145 -0
- package/core/dist/runtime-v2/config/pd-profile-constants.js.map +1 -0
- package/core/dist/runtime-v2/config/pd-validate-profile.d.ts +28 -0
- package/core/dist/runtime-v2/config/pd-validate-profile.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/pd-validate-profile.js +482 -0
- package/core/dist/runtime-v2/config/pd-validate-profile.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +26 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js +8 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +7 -4
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +5 -2
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js +32 -0
- package/core/dist/runtime-v2/internalization/__tests__/artificer-prompt-builder-v2.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js +139 -0
- package/core/dist/runtime-v2/internalization/__tests__/artificer-rule-output.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js +20 -1
- package/core/dist/runtime-v2/internalization/__tests__/diag-chain-e2e.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js +7 -0
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-intent-tension.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js +7 -6
- package/core/dist/runtime-v2/internalization/__tests__/diag-rootcause-runner.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/internalization-task-guards.test.js +1 -53
- package/core/dist/runtime-v2/internalization/__tests__/internalization-task-guards.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.js +23 -0
- package/core/dist/runtime-v2/internalization/__tests__/rule-host-input-builder.test.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-output.d.ts +7 -0
- package/core/dist/runtime-v2/internalization/artificer-output.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-output.js +22 -1
- package/core/dist/runtime-v2/internalization/artificer-output.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js +2 -0
- package/core/dist/runtime-v2/internalization/artificer-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/artificer-runner.js +13 -0
- package/core/dist/runtime-v2/internalization/artificer-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-distiller-runner.js +4 -4
- package/core/dist/runtime-v2/internalization/diag-distiller-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js +5 -5
- package/core/dist/runtime-v2/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/diag-router-runner.js +4 -4
- package/core/dist/runtime-v2/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.js +7 -1
- package/core/dist/runtime-v2/internalization/evaluator-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization/index.d.ts +1 -1
- package/core/dist/runtime-v2/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/index.js +1 -1
- package/core/dist/runtime-v2/internalization/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/internalization-task-guards.d.ts +0 -19
- package/core/dist/runtime-v2/internalization/internalization-task-guards.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/internalization-task-guards.js +1 -29
- package/core/dist/runtime-v2/internalization/internalization-task-guards.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +2 -0
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js +2 -0
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.d.ts +2 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.js +39 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/keyword-stage.test.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.d.ts +2 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.js +34 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/llm-stage.test.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.d.ts +2 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.js +222 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/signal-collector.test.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/types.test.d.ts +2 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/types.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/types.test.js +35 -0
- package/core/dist/runtime-v2/signal-collector/__tests__/types.test.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/index.d.ts +5 -0
- package/core/dist/runtime-v2/signal-collector/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/index.js +5 -0
- package/core/dist/runtime-v2/signal-collector/index.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts +20 -0
- package/core/dist/runtime-v2/signal-collector/keyword-stage.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/keyword-stage.js +61 -0
- package/core/dist/runtime-v2/signal-collector/keyword-stage.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/llm-stage.d.ts +16 -0
- package/core/dist/runtime-v2/signal-collector/llm-stage.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/llm-stage.js +34 -0
- package/core/dist/runtime-v2/signal-collector/llm-stage.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/signal-collector.d.ts +16 -0
- package/core/dist/runtime-v2/signal-collector/signal-collector.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/signal-collector.js +71 -0
- package/core/dist/runtime-v2/signal-collector/signal-collector.js.map +1 -0
- package/core/dist/runtime-v2/signal-collector/types.d.ts +61 -0
- package/core/dist/runtime-v2/signal-collector/types.d.ts.map +1 -0
- package/core/dist/runtime-v2/signal-collector/types.js +45 -0
- package/core/dist/runtime-v2/signal-collector/types.js.map +1 -0
- package/core/dist/runtime-v2/store/schema-conformance.test.js +43 -0
- package/core/dist/runtime-v2/store/schema-conformance.test.js.map +1 -1
- package/core/dist/runtime-v2/types/event-types.d.ts +40 -3
- package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/event-types.js +9 -0
- package/core/dist/runtime-v2/types/event-types.js.map +1 -1
- package/core/dist/runtime-v2/types/index.d.ts +2 -2
- package/core/dist/runtime-v2/types/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/types/index.js +1 -1
- package/core/dist/runtime-v2/types/index.js.map +1 -1
- package/core/dist/workflow-funnel-loader.js +1 -1
- package/core/dist/workflow-funnel-loader.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +6 -0
- package/dist/i18n.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +3 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +150 -1
- package/dist/installer.js.map +1 -1
- package/dist/mvp-config.d.ts +8 -0
- package/dist/mvp-config.d.ts.map +1 -1
- package/dist/mvp-config.js +34 -12
- package/dist/mvp-config.js.map +1 -1
- package/package.json +1 -1
- package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js +2 -2
- package/pd-cli/dist/commands/__tests__/runtime-probe-config.test.js.map +1 -1
- package/pd-cli/dist/commands/demo-story-a.d.ts.map +1 -1
- package/pd-cli/dist/commands/demo-story-a.js +4 -2
- package/pd-cli/dist/commands/demo-story-a.js.map +1 -1
- package/pd-cli/dist/commands/proven-channel-baseline.d.ts.map +1 -1
- package/pd-cli/dist/commands/proven-channel-baseline.js +4 -2
- package/pd-cli/dist/commands/proven-channel-baseline.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts +4 -0
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +187 -10
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-canary.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-canary.js +4 -2
- package/pd-cli/dist/commands/runtime-canary.js.map +1 -1
- package/pd-cli/dist/commands/runtime-health-snapshot.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-health-snapshot.js +4 -2
- package/pd-cli/dist/commands/runtime-health-snapshot.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-integrity.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-integrity.js +4 -2
- package/pd-cli/dist/commands/runtime-internalization-integrity.js.map +1 -1
- package/pd-cli/dist/index.js +5 -63
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/config-doctor.d.ts.map +1 -1
- package/pd-cli/dist/services/config-doctor.js +9 -2
- package/pd-cli/dist/services/config-doctor.js.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.d.ts.map +1 -1
- package/pd-cli/dist/services/runtime-adapter-resolver.js +1 -0
- package/pd-cli/dist/services/runtime-adapter-resolver.js.map +1 -1
- package/plugin/dist/commands/context.js +17 -11
- package/plugin/dist/commands/samples.js +25 -0
- package/plugin/dist/core/event-log.d.ts +11 -1
- package/plugin/dist/core/event-log.js +13 -0
- package/plugin/dist/core/init.js +3 -4
- package/plugin/dist/core/rule-host.d.ts +50 -0
- package/plugin/dist/core/rule-host.js +116 -19
- package/plugin/dist/core/signal-collector-host.d.ts +105 -0
- package/plugin/dist/core/signal-collector-host.js +337 -0
- package/plugin/dist/hooks/gate.js +1 -1
- package/plugin/dist/hooks/prompt.d.ts +3 -2
- package/plugin/dist/hooks/prompt.js +48 -586
- package/plugin/dist/service/evolution-dedup.d.ts +1 -1
- package/plugin/dist/service/evolution-worker.d.ts +7 -31
- package/plugin/dist/service/evolution-worker.js +17 -36
- package/plugin/dist/service/queue-io.js +14 -2
- package/plugin/dist/service/queue-migration.d.ts +27 -26
- package/plugin/dist/service/queue-migration.js +57 -0
- package/plugin/dist/types/event-types.d.ts +1 -1
- package/plugin/dist/types.d.ts +5 -25
- package/plugin/dist/types.js +4 -9
- package/plugin/dist/utils/hashing.js +1 -1
- package/plugin/templates/langs/en/core/AGENTS.md +2 -2
- package/plugin/templates/langs/en/core/TOOLS.md +1 -1
- package/plugin/templates/langs/zh/core/AGENTS.md +2 -2
- package/plugin/templates/langs/zh/core/TOOLS.md +1 -1
- package/templates/langs/en/core/AGENTS.md +2 -2
- package/templates/langs/en/core/TOOLS.md +1 -1
- package/templates/langs/zh/core/AGENTS.md +2 -2
- package/templates/langs/zh/core/TOOLS.md +1 -1
- package/plugin/dist/constants/diagnostician.d.ts +0 -12
- package/plugin/dist/constants/diagnostician.js +0 -65
- package/plugin/dist/service/evolution-queue-migration.d.ts +0 -128
- package/plugin/dist/service/evolution-queue-migration.js +0 -53
- package/plugin/templates/langs/en/skills/pd-diagnostician/SKILL.md +0 -466
- package/plugin/templates/langs/zh/skills/pd-diagnostician/SKILL.md +0 -391
- package/templates/langs/zh/skills/pd-diagnostician/SKILL.md +0 -287
|
@@ -30,12 +30,44 @@ export interface RuleHostOptions {
|
|
|
30
30
|
/** Workspace directory for SQLite access. Required for RuleHost to load active code_tool_hook activations. */
|
|
31
31
|
workspaceDir?: string;
|
|
32
32
|
}
|
|
33
|
+
type RuleHostActivationMode = 'shadow' | 'live';
|
|
33
34
|
export interface RuleHostObservedDecision extends RuleHostResult {
|
|
34
35
|
readonly activationId: string;
|
|
35
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* PRI-491 — A structured record of an activation that was skipped at load
|
|
39
|
+
* time (flag-off v2, unsupported action, unsupported context version,
|
|
40
|
+
* missing target_ref, content_json not an object, no implementationCode,
|
|
41
|
+
* or duplicate active activation for target_ref).
|
|
42
|
+
*
|
|
43
|
+
* Unlike compile/load failures (which emit rulehost_unhealthy), skipped
|
|
44
|
+
* activations have a configuration/flag reason — the RuleCode itself may be
|
|
45
|
+
* valid, but the runtime chose not to execute it. Duplicate activations are
|
|
46
|
+
* a special case: they ALSO emit rulehost_unhealthy (for telemetry), but are
|
|
47
|
+
* surfaced in skippedActivations so the owner can observe and act (rc-9).
|
|
48
|
+
*
|
|
49
|
+
* ERR-002 (rc-9): every skip carries a reason + nextAction, never silent.
|
|
50
|
+
*/
|
|
51
|
+
export interface SkippedActivation {
|
|
52
|
+
readonly activationId: string;
|
|
53
|
+
readonly ruleId: string;
|
|
54
|
+
/**
|
|
55
|
+
* The mode the activation WOULD have had if loaded. Optional for cases
|
|
56
|
+
* where the action itself is unrecognized (neither shadow nor live).
|
|
57
|
+
*/
|
|
58
|
+
readonly mode?: RuleHostActivationMode;
|
|
59
|
+
readonly reason: string;
|
|
60
|
+
readonly nextAction: string;
|
|
61
|
+
}
|
|
36
62
|
export interface RuleHostEvaluationReport {
|
|
37
63
|
readonly liveDecision: RuleHostResult | undefined;
|
|
38
64
|
readonly shadowDecisions: readonly RuleHostObservedDecision[];
|
|
65
|
+
/**
|
|
66
|
+
* PRI-491 — Activations that were skipped at load time. Empty when all
|
|
67
|
+
* active activations loaded successfully. Each entry carries a structured
|
|
68
|
+
* reason + nextAction so the owner can act without reading SQLite rows.
|
|
69
|
+
*/
|
|
70
|
+
readonly skippedActivations: readonly SkippedActivation[];
|
|
39
71
|
}
|
|
40
72
|
export declare class RuleHost {
|
|
41
73
|
private readonly stateDir;
|
|
@@ -44,6 +76,12 @@ export declare class RuleHost {
|
|
|
44
76
|
private readonly implementationSources;
|
|
45
77
|
private activationFingerprint;
|
|
46
78
|
private cachedImplementations;
|
|
79
|
+
/**
|
|
80
|
+
* PRI-491: Cached skipped activations from the last load. Returned alongside
|
|
81
|
+
* cachedImplementations on fingerprint hit so evaluateDetailed can surface
|
|
82
|
+
* them without re-scanning SQLite.
|
|
83
|
+
*/
|
|
84
|
+
private cachedSkipped;
|
|
47
85
|
private sqliteConnection;
|
|
48
86
|
/**
|
|
49
87
|
* R2-RH-002: Guards the "armed but empty" warn so it fires at most once per
|
|
@@ -125,4 +163,16 @@ export declare class RuleHost {
|
|
|
125
163
|
* Failures in EventLog recording are caught and logged (never throw).
|
|
126
164
|
*/
|
|
127
165
|
private _recordUnhealthy;
|
|
166
|
+
/**
|
|
167
|
+
* PRI-491: Record a skipped activation to EventLog.
|
|
168
|
+
*
|
|
169
|
+
* Unlike _recordUnhealthy (compile/load failures), skipped activations have
|
|
170
|
+
* a configuration/flag reason — the RuleCode itself may be valid, but the
|
|
171
|
+
* runtime chose not to execute it (flag-off v2, unsupported context version,
|
|
172
|
+
* unsupported action, content_json not object, no implementationCode).
|
|
173
|
+
*
|
|
174
|
+
* ERR-002: degradation includes a reason and nextAction (rc-9-no-silent-fallback).
|
|
175
|
+
* Failures in EventLog recording are caught and logged (never throw).
|
|
176
|
+
*/
|
|
177
|
+
private _recordSkipped;
|
|
128
178
|
}
|
|
@@ -50,6 +50,12 @@ export class RuleHost {
|
|
|
50
50
|
implementationSources = new Map();
|
|
51
51
|
activationFingerprint = null;
|
|
52
52
|
cachedImplementations = [];
|
|
53
|
+
/**
|
|
54
|
+
* PRI-491: Cached skipped activations from the last load. Returned alongside
|
|
55
|
+
* cachedImplementations on fingerprint hit so evaluateDetailed can surface
|
|
56
|
+
* them without re-scanning SQLite.
|
|
57
|
+
*/
|
|
58
|
+
cachedSkipped = [];
|
|
53
59
|
sqliteConnection = null;
|
|
54
60
|
/**
|
|
55
61
|
* R2-RH-002: Guards the "armed but empty" warn so it fires at most once per
|
|
@@ -93,13 +99,14 @@ export class RuleHost {
|
|
|
93
99
|
this.sqliteConnection?.close();
|
|
94
100
|
this.sqliteConnection = null;
|
|
95
101
|
this.cachedImplementations = [];
|
|
102
|
+
this.cachedSkipped = [];
|
|
96
103
|
this.activationFingerprint = null;
|
|
97
104
|
this.implementationSources.clear();
|
|
98
105
|
this.emptyLoadWarnEmitted = false;
|
|
99
106
|
}
|
|
100
107
|
evaluateDetailed(input) {
|
|
101
108
|
try {
|
|
102
|
-
const activeImpls = this._loadActiveCodeImplementations(input.context?.version === 2);
|
|
109
|
+
const { loaded: activeImpls, skipped } = this._loadActiveCodeImplementations(input.context?.version === 2);
|
|
103
110
|
const liveImpls = activeImpls.filter((impl) => impl.activationMode === 'live');
|
|
104
111
|
const shadowImpls = activeImpls.filter((impl) => impl.activationMode === 'shadow');
|
|
105
112
|
const shadowDecisions = [];
|
|
@@ -128,12 +135,12 @@ export class RuleHost {
|
|
|
128
135
|
this._recordUnhealthy(source.activationId, source.artifactId, source.ruleId, reason, 'Fix the RuleCode runtime error or return shape, then re-activate the rule');
|
|
129
136
|
},
|
|
130
137
|
});
|
|
131
|
-
return { liveDecision, shadowDecisions };
|
|
138
|
+
return { liveDecision, shadowDecisions, skippedActivations: skipped };
|
|
132
139
|
}
|
|
133
140
|
catch (hostError) {
|
|
134
141
|
// Conservative degradation: log and return undefined (D-08)
|
|
135
142
|
this.logger.warn?.(`[RuleHost] Host evaluation failed, degrading conservatively: ${String(hostError)}`);
|
|
136
|
-
return { liveDecision: undefined, shadowDecisions: [] };
|
|
143
|
+
return { liveDecision: undefined, shadowDecisions: [], skippedActivations: [] };
|
|
137
144
|
}
|
|
138
145
|
}
|
|
139
146
|
/**
|
|
@@ -149,18 +156,18 @@ export class RuleHost {
|
|
|
149
156
|
_loadActiveCodeImplementations(supportsContextV2) {
|
|
150
157
|
if (!this.workspaceDir) {
|
|
151
158
|
this._emitEmptyLoadWarn('workspaceDir not configured — RuleHost cannot load active code_tool_hook rules', 'Provide workspaceDir when constructing RuleHost (required for code_tool_hook channel)');
|
|
152
|
-
return [];
|
|
159
|
+
return { loaded: [], skipped: [] };
|
|
153
160
|
}
|
|
154
161
|
try {
|
|
155
|
-
const loaded = this._loadFromActivationsTable(this.workspaceDir, supportsContextV2);
|
|
162
|
+
const { loaded, skipped } = this._loadFromActivationsTable(this.workspaceDir, supportsContextV2);
|
|
156
163
|
if (loaded.length === 0) {
|
|
157
|
-
this._emitEmptyLoadWarn('armed but empty — 0 active code_tool_hook activations loaded (RuleHost will not block or require approval)', 'If this is unexpected, run `pd
|
|
164
|
+
this._emitEmptyLoadWarn('armed but empty — 0 active code_tool_hook activations loaded (RuleHost will not block or require approval)', 'If this is unexpected, run `pd activation list --channel code_tool_hook` to inspect activations, or `pd activation promote --activation-id <id> --confirm` to enable a live rule');
|
|
158
165
|
}
|
|
159
|
-
return loaded;
|
|
166
|
+
return { loaded, skipped };
|
|
160
167
|
}
|
|
161
168
|
catch (activationError) {
|
|
162
169
|
this.logger.warn?.(`[RuleHost] Failed to load code_tool_hook activations: ${String(activationError)}`);
|
|
163
|
-
return [];
|
|
170
|
+
return { loaded: [], skipped: [] };
|
|
164
171
|
}
|
|
165
172
|
}
|
|
166
173
|
/**
|
|
@@ -210,7 +217,7 @@ export class RuleHost {
|
|
|
210
217
|
`).all();
|
|
211
218
|
if (!Array.isArray(rows)) {
|
|
212
219
|
this.logger.warn?.('[RuleHost] Activations table query returned non-array, skipping');
|
|
213
|
-
return [];
|
|
220
|
+
return { loaded: [], skipped: [] };
|
|
214
221
|
}
|
|
215
222
|
const fingerprintParts = [supportsContextV2 ? 'context-v2' : 'context-v1'];
|
|
216
223
|
for (const row of rows) {
|
|
@@ -223,7 +230,7 @@ export class RuleHost {
|
|
|
223
230
|
}
|
|
224
231
|
const fingerprint = fingerprintParts.join('\u0002');
|
|
225
232
|
if (fingerprint === this.activationFingerprint) {
|
|
226
|
-
return [...this.cachedImplementations];
|
|
233
|
+
return { loaded: [...this.cachedImplementations], skipped: [...this.cachedSkipped] };
|
|
227
234
|
}
|
|
228
235
|
this.implementationSources.clear();
|
|
229
236
|
// PRI-436: Group active rows by target_ref to detect duplicates.
|
|
@@ -251,7 +258,13 @@ export class RuleHost {
|
|
|
251
258
|
}
|
|
252
259
|
}
|
|
253
260
|
// Emit structured unhealthy evidence for duplicate groups; collect valid (non-duplicate) rows.
|
|
261
|
+
// PRI-497: duplicate activations are ALSO pushed to the `skipped` array
|
|
262
|
+
// so callers (gate.ts, CLI, Console) can observe them via
|
|
263
|
+
// skippedActivations — not just via rulehost_unhealthy event log.
|
|
264
|
+
// Both paths are populated (rc-9-no-silent-fallback): event log for
|
|
265
|
+
// telemetry, skipped array for structured caller-facing observability.
|
|
254
266
|
const validRows = [];
|
|
267
|
+
const skipped = [];
|
|
255
268
|
for (const [targetRef, group] of rowsByTargetRef) {
|
|
256
269
|
if (group.length > 1) {
|
|
257
270
|
const activationIds = [];
|
|
@@ -273,6 +286,14 @@ export class RuleHost {
|
|
|
273
286
|
const artifactId = typeof r['artifact_id'] === 'string' ? r['artifact_id'] : '';
|
|
274
287
|
if (activationId && artifactId) {
|
|
275
288
|
this._recordUnhealthy(activationId, artifactId, targetRef, `duplicate active activation for target_ref ${targetRef}`, 'Deactivate all but one activation for this target_ref');
|
|
289
|
+
// PRI-497: also surface in skippedActivations for caller observability
|
|
290
|
+
skipped.push({
|
|
291
|
+
activationId,
|
|
292
|
+
ruleId: targetRef,
|
|
293
|
+
mode: 'live',
|
|
294
|
+
reason: 'duplicate_active_activation',
|
|
295
|
+
nextAction: 'Deactivate all but one activation for this target_ref',
|
|
296
|
+
});
|
|
276
297
|
}
|
|
277
298
|
}
|
|
278
299
|
}
|
|
@@ -305,8 +326,17 @@ export class RuleHost {
|
|
|
305
326
|
? 'live'
|
|
306
327
|
: null;
|
|
307
328
|
if (!activationMode) {
|
|
308
|
-
|
|
309
|
-
|
|
329
|
+
const reason = `unsupported action: ${action || '(missing)'}`;
|
|
330
|
+
const nextAction = 'Deactivate and recreate the activation through RuleHostWriter with action code_tool_hook_shadow_activate or code_tool_hook_live_activate';
|
|
331
|
+
this.logger.warn?.(`[RuleHost] Activation ${activationId}: ${reason}, skipping. nextAction=${nextAction}`);
|
|
332
|
+
const skipRecord = {
|
|
333
|
+
activationId,
|
|
334
|
+
ruleId: sourceRuleId ?? artifactId,
|
|
335
|
+
reason,
|
|
336
|
+
nextAction,
|
|
337
|
+
};
|
|
338
|
+
skipped.push(skipRecord);
|
|
339
|
+
this._recordSkipped(activationId, artifactId, sourceRuleId ?? artifactId, undefined, reason, nextAction);
|
|
310
340
|
continue;
|
|
311
341
|
}
|
|
312
342
|
if (activationMode === 'shadow') {
|
|
@@ -327,25 +357,63 @@ export class RuleHost {
|
|
|
327
357
|
try {
|
|
328
358
|
const content = JSON.parse(contentJson);
|
|
329
359
|
if (!content || typeof content !== 'object' || Array.isArray(content)) {
|
|
330
|
-
|
|
360
|
+
const reason = 'content_json is not a valid object';
|
|
361
|
+
const nextAction = 'Regenerate the rule artifact with valid JSON content_json';
|
|
362
|
+
this.logger.warn?.(`[RuleHost] Activation ${activationId}: ${reason}, skipping. nextAction=${nextAction}`);
|
|
363
|
+
skipped.push({
|
|
364
|
+
activationId,
|
|
365
|
+
ruleId: sourceRuleId ?? artifactId,
|
|
366
|
+
mode: activationMode,
|
|
367
|
+
reason,
|
|
368
|
+
nextAction,
|
|
369
|
+
});
|
|
370
|
+
this._recordSkipped(activationId, artifactId, sourceRuleId ?? artifactId, activationMode, reason, nextAction);
|
|
331
371
|
continue;
|
|
332
372
|
}
|
|
333
373
|
const contentObj = content;
|
|
334
374
|
if (Object.hasOwn(contentObj, 'requiresContextVersion')) {
|
|
335
375
|
if (contentObj['requiresContextVersion'] !== 2) {
|
|
336
|
-
|
|
337
|
-
|
|
376
|
+
const reason = `unsupported context version: ${String(contentObj['requiresContextVersion'])}`;
|
|
377
|
+
const nextAction = 'Regenerate the rule artifact with requiresContextVersion: 2 or omit the field for v1';
|
|
378
|
+
this.logger.warn?.(`[RuleHost] Activation ${activationId}: ${reason}, skipping. nextAction=${nextAction}`);
|
|
379
|
+
skipped.push({
|
|
380
|
+
activationId,
|
|
381
|
+
ruleId: typeof contentObj['ruleId'] === 'string' ? contentObj['ruleId'] : (sourceRuleId ?? artifactId),
|
|
382
|
+
mode: activationMode,
|
|
383
|
+
reason,
|
|
384
|
+
nextAction,
|
|
385
|
+
});
|
|
386
|
+
this._recordSkipped(activationId, artifactId, typeof contentObj['ruleId'] === 'string' ? contentObj['ruleId'] : (sourceRuleId ?? artifactId), activationMode, reason, nextAction);
|
|
338
387
|
continue;
|
|
339
388
|
}
|
|
340
389
|
if (!supportsContextV2) {
|
|
341
|
-
|
|
342
|
-
|
|
390
|
+
const reason = 'suspended_by_flag: rulecode_context_v2 is disabled or unavailable';
|
|
391
|
+
const nextAction = 'Enable rulecode_context_v2 with valid config, or deactivate this activation';
|
|
392
|
+
this.logger.warn?.(`[RuleHost] Activation ${activationId}: ${reason}, skipping. nextAction=${nextAction}`);
|
|
393
|
+
skipped.push({
|
|
394
|
+
activationId,
|
|
395
|
+
ruleId: typeof contentObj['ruleId'] === 'string' ? contentObj['ruleId'] : (sourceRuleId ?? artifactId),
|
|
396
|
+
mode: activationMode,
|
|
397
|
+
reason,
|
|
398
|
+
nextAction,
|
|
399
|
+
});
|
|
400
|
+
this._recordSkipped(activationId, artifactId, typeof contentObj['ruleId'] === 'string' ? contentObj['ruleId'] : (sourceRuleId ?? artifactId), activationMode, reason, nextAction);
|
|
343
401
|
continue;
|
|
344
402
|
}
|
|
345
403
|
}
|
|
346
404
|
const implementationCode = contentObj['implementationCode'];
|
|
347
405
|
if (typeof implementationCode !== 'string' || implementationCode.length === 0) {
|
|
348
|
-
|
|
406
|
+
const reason = 'no implementationCode in artifact';
|
|
407
|
+
const nextAction = 'Regenerate the rule artifact with a non-empty implementationCode field';
|
|
408
|
+
this.logger.warn?.(`[RuleHost] Activation ${activationId}: ${reason}, skipping. nextAction=${nextAction}`);
|
|
409
|
+
skipped.push({
|
|
410
|
+
activationId,
|
|
411
|
+
ruleId: typeof contentObj['ruleId'] === 'string' ? contentObj['ruleId'] : (sourceRuleId ?? artifactId),
|
|
412
|
+
mode: activationMode,
|
|
413
|
+
reason,
|
|
414
|
+
nextAction,
|
|
415
|
+
});
|
|
416
|
+
this._recordSkipped(activationId, artifactId, typeof contentObj['ruleId'] === 'string' ? contentObj['ruleId'] : (sourceRuleId ?? artifactId), activationMode, reason, nextAction);
|
|
349
417
|
continue;
|
|
350
418
|
}
|
|
351
419
|
const ruleId = typeof contentObj['ruleId'] === 'string'
|
|
@@ -421,7 +489,8 @@ export class RuleHost {
|
|
|
421
489
|
}
|
|
422
490
|
this.activationFingerprint = fingerprint;
|
|
423
491
|
this.cachedImplementations = loaded;
|
|
424
|
-
|
|
492
|
+
this.cachedSkipped = skipped;
|
|
493
|
+
return { loaded, skipped };
|
|
425
494
|
}
|
|
426
495
|
}
|
|
427
496
|
/**
|
|
@@ -454,4 +523,32 @@ export class RuleHost {
|
|
|
454
523
|
this.logger.warn?.(`[RuleHost] Failed to record unhealthy event for activation ${activationId}: ${String(recordError)}`);
|
|
455
524
|
}
|
|
456
525
|
}
|
|
526
|
+
/**
|
|
527
|
+
* PRI-491: Record a skipped activation to EventLog.
|
|
528
|
+
*
|
|
529
|
+
* Unlike _recordUnhealthy (compile/load failures), skipped activations have
|
|
530
|
+
* a configuration/flag reason — the RuleCode itself may be valid, but the
|
|
531
|
+
* runtime chose not to execute it (flag-off v2, unsupported context version,
|
|
532
|
+
* unsupported action, content_json not object, no implementationCode).
|
|
533
|
+
*
|
|
534
|
+
* ERR-002: degradation includes a reason and nextAction (rc-9-no-silent-fallback).
|
|
535
|
+
* Failures in EventLog recording are caught and logged (never throw).
|
|
536
|
+
*/
|
|
537
|
+
_recordSkipped(activationId, artifactId, ruleId, mode, reason, nextAction) {
|
|
538
|
+
try {
|
|
539
|
+
const eventLog = EventLogService.get(this.stateDir);
|
|
540
|
+
eventLog.recordRuleHostSkipped({
|
|
541
|
+
activationId,
|
|
542
|
+
artifactId,
|
|
543
|
+
ruleId,
|
|
544
|
+
mode,
|
|
545
|
+
reason,
|
|
546
|
+
nextAction,
|
|
547
|
+
});
|
|
548
|
+
}
|
|
549
|
+
catch (recordError) {
|
|
550
|
+
// EventLog recording must never break RuleHost evaluation
|
|
551
|
+
this.logger.warn?.(`[RuleHost] Failed to record skipped event for activation ${activationId}: ${String(recordError)}`);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
457
554
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SignalCollectorHost — plugin I/O 外壳 (design spec §4.2)
|
|
3
|
+
*
|
|
4
|
+
* 把 core 的纯逻辑 (collectSync / mapLlmResultToOutput) 接进 openclaw 运行时。
|
|
5
|
+
*
|
|
6
|
+
* 同步路径 (prompt.ts before_prompt_build 钩子调用,绝不阻塞):
|
|
7
|
+
* - trigger 门控 (仅 user)
|
|
8
|
+
* - Stage1 关键词快扫 (零成本)
|
|
9
|
+
* - 写 user_turns (复用 recordUserTurn)
|
|
10
|
+
* - 高精度短语命中 (high) → 直接走 STRONG 分流 (同步,纯内存)
|
|
11
|
+
* - 普通歧义词 / 未命中 → 入队异步 LLM 确认 (不阻塞)
|
|
12
|
+
*
|
|
13
|
+
* 异步路径 (fire-and-forget):
|
|
14
|
+
* - Stage2 LLM 确认 (后台,不阻塞 prompt hook)
|
|
15
|
+
* - LLM 不可用 → 降级:丢弃 ambiguous 候选 (不触发 STRONG,避免误判泛滥)
|
|
16
|
+
* - 按 strength 分流:STRONG → emitPainDetectedEvent (修断裂 ③);WEAK → trackFriction 累积 GFI
|
|
17
|
+
*
|
|
18
|
+
* 降级不静默 (rc-9):所有降级路径走 SystemLogger。
|
|
19
|
+
*/
|
|
20
|
+
import { type UnifiedKeywordStore, type SignalCollectorConfig } from '@principles/core/runtime-v2';
|
|
21
|
+
import type { PluginLogger } from '../openclaw-sdk.js';
|
|
22
|
+
import type { WorkspaceContext } from './workspace-context.js';
|
|
23
|
+
export declare const DEFAULT_SIGNAL_CONFIG: SignalCollectorConfig;
|
|
24
|
+
export declare function buildDefaultKeywordStore(): UnifiedKeywordStore;
|
|
25
|
+
/**
|
|
26
|
+
* adapter 抽象 (Stage2 LLM 调用)。plugin 层可注入真实 adapter (LMStudio);
|
|
27
|
+
* 为 null / 不可用时 host 走纯关键词降级。
|
|
28
|
+
*
|
|
29
|
+
* 本文件不依赖具体的 PDRuntimeAdapter 实现,只依赖一个最小的分类函数,
|
|
30
|
+
* 以保持 host 可单测 (测试可注入 mock classifier)。
|
|
31
|
+
*/
|
|
32
|
+
export type SignalLlmClassifier = (text: string, promptTemplate: string) => Promise<{
|
|
33
|
+
is_feedback: boolean;
|
|
34
|
+
type: 'correction' | 'empathy' | 'none';
|
|
35
|
+
confidence: number;
|
|
36
|
+
reason: string;
|
|
37
|
+
} | null>;
|
|
38
|
+
export interface SignalCollectorHostOptions {
|
|
39
|
+
keywordStore?: UnifiedKeywordStore;
|
|
40
|
+
config?: SignalCollectorConfig;
|
|
41
|
+
/** Stage2 LLM 分类器。null/undefined → 降级纯关键词。 */
|
|
42
|
+
llmClassifier?: SignalLlmClassifier | null;
|
|
43
|
+
}
|
|
44
|
+
export declare class SignalCollectorHost {
|
|
45
|
+
private readonly wctx;
|
|
46
|
+
private readonly store;
|
|
47
|
+
private readonly config;
|
|
48
|
+
private readonly llmClassifier;
|
|
49
|
+
/** rate limit 状态:sessionId → STRONG 计数桶 */
|
|
50
|
+
private readonly rateLimit;
|
|
51
|
+
constructor(wctx: WorkspaceContext, options?: SignalCollectorHostOptions);
|
|
52
|
+
/**
|
|
53
|
+
* ★ 同步路径 (prompt.ts before_prompt_build 钩子里调用,绝不能阻塞)。
|
|
54
|
+
*
|
|
55
|
+
* 只做:trigger 门控 + Stage1 关键词快扫 + 写 user_turns。
|
|
56
|
+
* 高精度短语命中 (high) → 直接走 STRONG 分流 (同步,纯内存)。
|
|
57
|
+
* 普通歧义词 / 未命中 → 入队异步 LLM 确认 (不阻塞)。
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* 可选入参:lineage 字段(由调用方算好传入,host 不感知 trajectory 结构)。
|
|
61
|
+
* referencesAssistantTurnId 让诊断 evidence 能 JOIN 到前置 assistant turn。
|
|
62
|
+
*/
|
|
63
|
+
detectSync(userMessage: string, sessionId: string, trigger: string, options?: {
|
|
64
|
+
referencesAssistantTurnId?: number | null;
|
|
65
|
+
turnIndex?: number;
|
|
66
|
+
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* ★ 异步路径 (fire-and-forget)。
|
|
69
|
+
*
|
|
70
|
+
* 1. Stage2 LLM 确认 (后台,不阻塞用户)
|
|
71
|
+
* 2. LLM 不可用 → 降级:empathy ambiguous 候选作为 WEAK 信号路由(保留旧版 GFI 累积);
|
|
72
|
+
* correction ambiguous / 未命中候选丢弃(不触发 STRONG,避免误判泛滥)
|
|
73
|
+
* 3. 按 strength 分流:STRONG → emitPainDetectedEvent;WEAK → trackFriction 累积 GFI;none → 仅记录
|
|
74
|
+
*/
|
|
75
|
+
private detectAsyncAndRoute;
|
|
76
|
+
/**
|
|
77
|
+
* STRONG 分流 → emitPainDetectedEvent (修断裂 ③)。
|
|
78
|
+
* 带 STRONG rate limit 门控 (spec §7.2):单 session 每小时上限 strongRateLimitPerHour。
|
|
79
|
+
*/
|
|
80
|
+
private routeStrong;
|
|
81
|
+
/**
|
|
82
|
+
* WEAK 分流 → trackFriction 累积 GFI + 写 evidence (维持现状,spec §3.2)。
|
|
83
|
+
*
|
|
84
|
+
* WEAK 是 Layer 3 弱信号,用较小的摩擦分(20)累积,过 highGfi 阈值(70)才触发诊断。
|
|
85
|
+
* 不用 strongPainScore(70),因为 WEAK 单条不该直接顶满 GFI。
|
|
86
|
+
*/
|
|
87
|
+
private routeWeak;
|
|
88
|
+
/**
|
|
89
|
+
* STRONG rate limit 门控:成功消耗一个名额返回 true;超限返回 false。
|
|
90
|
+
* 窗口满一小时自动重置。
|
|
91
|
+
*/
|
|
92
|
+
private tryConsumeRateLimit;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 从 .pd/config.yaml 的 signalCollector runtimeProfile 构造 SignalLlmClassifier。
|
|
96
|
+
* 完成配置单轨化(spec §3.3 决策3):统一走 .pd/config.yaml,移除 empathy 的 workflows.yaml 双轨。
|
|
97
|
+
*
|
|
98
|
+
* 返回 null 的情况(走纯关键词降级,rc-9 不静默):
|
|
99
|
+
* - feature flag signal_collector 关闭
|
|
100
|
+
* - runtimeProfile 未配置 / apiKeyEnv 缺失
|
|
101
|
+
* - profile 是 openclaw 类型(observer 不支持)
|
|
102
|
+
*
|
|
103
|
+
* 这是 Task 11 的最后一块:让本地 LLM(LMStudio)真正参与检测。
|
|
104
|
+
*/
|
|
105
|
+
export declare function createSignalLlmClassifierFromConfig(wctx: WorkspaceContext, logger?: Pick<PluginLogger, 'info' | 'warn' | 'error' | 'debug'>): SignalLlmClassifier | null;
|