create-principles-disciple 1.82.0 → 1.83.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 +135 -0
- package/console/dist/server/config/pd-config-store.js +660 -0
- package/console/dist/server/index.js +40 -389
- package/console/dist/server/models/ActivationsConsoleModel.d.ts +33 -0
- package/console/dist/server/models/ActivationsConsoleModel.js +112 -0
- package/console/dist/server/models/ApprovalsConsoleModel.d.ts +5 -0
- package/console/dist/server/models/ApprovalsConsoleModel.js +14 -0
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.d.ts +25 -0
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +126 -0
- package/console/dist/server/models/ConsoleLifecycleDatasource.d.ts +13 -0
- package/console/dist/server/models/ConsoleLifecycleDatasource.js +73 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +58 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.js +493 -0
- package/console/dist/server/models/GovernanceConsoleModel.d.ts +74 -0
- package/console/dist/server/models/GovernanceConsoleModel.js +246 -0
- package/console/dist/server/models/HealthCheckModel.d.ts +0 -4
- package/console/dist/server/models/HealthCheckModel.js +49 -80
- package/console/dist/server/models/LifecycleConsoleModel.d.ts +19 -0
- package/console/dist/server/models/LifecycleConsoleModel.js +55 -0
- package/console/dist/server/models/PrincipleClassifier.d.ts +41 -0
- package/console/dist/server/models/PrincipleClassifier.js +100 -0
- package/console/dist/server/models/PrinciplesConsoleModel.d.ts +12 -1
- package/console/dist/server/models/PrinciplesConsoleModel.js +53 -6
- package/console/dist/server/models/WorkspaceService.d.ts +2 -1
- package/console/dist/server/models/WorkspaceService.js +51 -23
- package/console/dist/server/routes/activations.d.ts +3 -0
- package/console/dist/server/routes/activations.js +111 -0
- package/console/dist/server/routes/approvals-grouped.d.ts +3 -0
- package/console/dist/server/routes/approvals-grouped.js +32 -0
- package/console/dist/server/routes/approvals.js +28 -4
- package/console/dist/server/routes/config.d.ts +27 -0
- package/console/dist/server/routes/config.js +213 -0
- package/console/dist/server/routes/evidence-chain.d.ts +9 -0
- package/console/dist/server/routes/evidence-chain.js +32 -0
- package/console/dist/server/routes/governance.d.ts +3 -0
- package/console/dist/server/routes/governance.js +32 -0
- package/console/dist/server/routes/{evolution.d.ts → lifecycle.d.ts} +2 -2
- package/console/dist/server/routes/lifecycle.js +48 -0
- package/console/dist/server/routes/principles.js +74 -1
- package/console/dist/server/routes/workspaces.js +8 -1
- package/console/dist/server/utils/response.d.ts +1 -1
- package/console/dist/server/utils/response.js +6 -2
- package/console/dist/types.d.ts +1 -0
- package/console/dist/ui/App.js +116 -40
- package/console/dist/ui/api.d.ts +88 -501
- package/console/dist/ui/api.js +139 -162
- package/console/dist/ui/components/approval-card.js +1 -1
- package/console/dist/ui/components/approval-detail-dialog.js +1 -1
- package/console/dist/ui/components/auth/login-form.d.ts +3 -0
- package/console/dist/ui/components/auth/login-form.js +36 -0
- package/console/dist/ui/components/auth/splash-screen.d.ts +8 -0
- package/console/dist/ui/components/auth/splash-screen.js +22 -0
- package/console/dist/ui/components/layout/app-sidebar.d.ts +1 -0
- package/console/dist/ui/components/layout/app-sidebar.js +56 -0
- package/console/dist/ui/components/layout/page-shell.d.ts +11 -0
- package/console/dist/ui/components/layout/page-shell.js +10 -0
- package/console/dist/ui/components/layout/section-title.d.ts +10 -0
- package/console/dist/ui/components/layout/section-title.js +9 -0
- package/console/dist/ui/components/theme-provider.d.ts +1 -1
- package/console/dist/ui/components/theme-provider.js +13 -8
- package/console/dist/ui/components/theme-toggle.js +2 -21
- package/console/dist/ui/components/ui/badge.d.ts +1 -1
- package/console/dist/ui/components/ui/badge.js +7 -5
- package/console/dist/ui/components/ui/button.d.ts +2 -2
- package/console/dist/ui/components/ui/button.js +12 -11
- package/console/dist/ui/components/ui/card.js +6 -6
- package/console/dist/ui/components/ui/sheet.d.ts +1 -1
- package/console/dist/ui/i18n/en.json +401 -343
- package/console/dist/ui/i18n/index.js +2 -2
- package/console/dist/ui/i18n/zh-CN.json +406 -348
- package/console/dist/ui/main.d.ts +1 -1
- package/console/dist/ui/main.js +1 -0
- package/console/dist/ui/pages/activation/ActivationPage.d.ts +1 -0
- package/console/dist/ui/pages/activation/ActivationPage.js +150 -0
- package/console/dist/ui/pages/activation/ActivationValidators.d.ts +20 -0
- package/console/dist/ui/pages/activation/ActivationValidators.js +156 -0
- package/console/dist/ui/pages/control-center/ControlCenterPage.d.ts +1 -0
- package/console/dist/ui/pages/control-center/ControlCenterPage.js +447 -0
- package/console/dist/ui/pages/debt/DebtPage.d.ts +1 -0
- package/console/dist/ui/pages/debt/DebtPage.js +5 -0
- package/console/dist/ui/pages/design-system/DesignSystemPage.d.ts +1 -0
- package/console/dist/ui/pages/design-system/DesignSystemPage.js +30 -0
- package/console/dist/ui/pages/focus/FocusPage.d.ts +1 -0
- package/console/dist/ui/pages/focus/FocusPage.js +265 -0
- package/console/dist/ui/pages/pain/PainEvidenceValidators.d.ts +59 -0
- package/console/dist/ui/pages/pain/PainEvidenceValidators.js +125 -0
- package/console/dist/ui/pages/pain/PainPage.js +136 -0
- package/console/dist/ui/pages/principles/PrincipleDetailPage.js +264 -0
- package/console/dist/ui/pages/principles/PrinciplesPage.js +244 -0
- package/console/dist/ui/pages/report-problem/ReportProblemPage.js +245 -0
- package/console/dist/ui/pages/settings/SettingsPage.d.ts +4 -0
- package/console/dist/ui/pages/settings/SettingsPage.js +202 -0
- package/console/dist/ui/pages/settings/UpdatePage.d.ts +5 -0
- package/console/dist/ui/pages/settings/UpdatePage.js +168 -0
- package/console/dist/ui/utils/control-center-helpers.d.ts +58 -0
- package/console/dist/ui/utils/control-center-helpers.js +152 -0
- package/console/dist/ui/utils/validators.d.ts +350 -0
- package/console/dist/ui/utils/validators.js +995 -0
- package/console/dist/web/assets/app.css +672 -902
- package/console/dist/web/assets/app.js +6404 -15347
- package/console/dist/web/assets/jetbrains-mono-cyrillic-400-normal-C5JECUCT.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-cyrillic-400-normal-FGCZYWMY.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-cyrillic-ext-400-normal-C7IFWGF6.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-cyrillic-ext-400-normal-PWXUA557.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-greek-400-normal-JJNQZMPZ.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-greek-400-normal-O7JTTR3P.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-400-normal-3OOWLGQ2.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-400-normal-WDD34GPP.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-ext-400-normal-55RNMRQS.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-latin-ext-400-normal-JVR3IR4Z.woff2 +0 -0
- package/console/dist/web/assets/jetbrains-mono-vietnamese-400-normal-7ULXAK72.woff +0 -0
- package/console/dist/web/assets/jetbrains-mono-vietnamese-400-normal-KU7YLUPA.woff2 +0 -0
- package/console/package.json +2 -1
- package/core/dist/runtime-v2/__tests__/admission-gate.test.js +49 -0
- package/core/dist/runtime-v2/__tests__/admission-gate.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js +16 -1
- package/core/dist/runtime-v2/__tests__/architecture-regression.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.d.ts +21 -0
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.js +354 -0
- package/core/dist/runtime-v2/__tests__/evidence-sanitizer.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.d.ts +12 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.js +162 -0
- package/core/dist/runtime-v2/__tests__/language-directive.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js +23 -1
- package/core/dist/runtime-v2/__tests__/pain-signal-observability.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js +48 -3
- package/core/dist/runtime-v2/__tests__/pain-to-principle-service.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js +13 -1
- package/core/dist/runtime-v2/__tests__/proven-channel-baseline.test.js.map +1 -1
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.d.ts +12 -0
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js +194 -0
- package/core/dist/runtime-v2/__tests__/resolve-runtime-config-from-pd-config.test.js.map +1 -0
- package/core/dist/runtime-v2/__tests__/runtime-config-boundary.test.js +5 -3
- package/core/dist/runtime-v2/__tests__/runtime-config-boundary.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js +1 -0
- package/core/dist/runtime-v2/activation/__tests__/activation-dispatcher.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js +54 -0
- package/core/dist/runtime-v2/activation/__tests__/approval-queue.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/memory-activation-state-store.test.js +15 -2
- package/core/dist/runtime-v2/activation/__tests__/memory-activation-state-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js +10 -0
- package/core/dist/runtime-v2/activation/__tests__/prompt-activation-reader-contract.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js +17 -2
- package/core/dist/runtime-v2/activation/__tests__/sqlite-activation-state-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js +36 -0
- package/core/dist/runtime-v2/activation/__tests__/sqlite-approval-store.test.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js +1 -1
- package/core/dist/runtime-v2/activation/activation-dispatcher.js.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.d.ts +10 -0
- package/core/dist/runtime-v2/activation/activation-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/activation-types.js.map +1 -1
- package/core/dist/runtime-v2/activation/approval-queue.d.ts +6 -0
- package/core/dist/runtime-v2/activation/approval-queue.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/approval-queue.js +3 -0
- package/core/dist/runtime-v2/activation/approval-queue.js.map +1 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts +2 -0
- package/core/dist/runtime-v2/activation/memory-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.js +17 -1
- package/core/dist/runtime-v2/activation/memory-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/memory-approval-store.d.ts +6 -0
- package/core/dist/runtime-v2/activation/memory-approval-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/memory-approval-store.js +16 -0
- package/core/dist/runtime-v2/activation/memory-approval-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +1 -1
- package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts +2 -0
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js +34 -6
- package/core/dist/runtime-v2/activation/sqlite-activation-state-store.js.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts +6 -0
- package/core/dist/runtime-v2/activation/sqlite-approval-store.d.ts.map +1 -1
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js +10 -0
- package/core/dist/runtime-v2/activation/sqlite-approval-store.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js +51 -1
- package/core/dist/runtime-v2/adapter/__tests__/json-extractor.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/__tests__/openclaw-cli-runtime-adapter.test.js +145 -0
- package/core/dist/runtime-v2/adapter/__tests__/openclaw-cli-runtime-adapter.test.js.map +1 -1
- package/core/dist/runtime-v2/adapter/json-extractor.d.ts +13 -0
- package/core/dist/runtime-v2/adapter/json-extractor.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/json-extractor.js +103 -0
- package/core/dist/runtime-v2/adapter/json-extractor.js.map +1 -1
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.d.ts +4 -2
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.js +57 -5
- package/core/dist/runtime-v2/adapter/openclaw-cli-runtime-adapter.js.map +1 -1
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.d.ts +18 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js +633 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-agent-binding.test.js.map +1 -0
- package/core/dist/runtime-v2/config/__tests__/pd-config-validation-edge-cases.test.js +92 -0
- 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 +3 -1
- package/core/dist/runtime-v2/config/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/index.js +1 -0
- package/core/dist/runtime-v2/config/index.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts +93 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.d.ts.map +1 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js +184 -0
- package/core/dist/runtime-v2/config/pd-config-agent-binding.js.map +1 -0
- package/core/dist/runtime-v2/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-defaults.js +2 -0
- 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 +3 -0
- package/core/dist/runtime-v2/config/pd-config-effective.js.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.d.ts +8 -0
- package/core/dist/runtime-v2/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts +13 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js +97 -0
- package/core/dist/runtime-v2/diagnostician/__tests__/diagnostician-prompt-language.test.js.map +1 -0
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts +3 -2
- package/core/dist/runtime-v2/diagnostician-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/diagnostician-prompt-builder.js +6 -4
- package/core/dist/runtime-v2/diagnostician-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/evidence-sanitizer.d.ts +57 -0
- package/core/dist/runtime-v2/evidence-sanitizer.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-sanitizer.js +213 -0
- package/core/dist/runtime-v2/evidence-sanitizer.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.d.ts +7 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.js +170 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/admission-events.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.d.ts +18 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.js +277 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/source-descriptors.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.d.ts +13 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js +264 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/triage-policy.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.d.ts +16 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.js +316 -0
- package/core/dist/runtime-v2/evidence-triage/__tests__/trigger-controller.test.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.d.ts +126 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.js +159 -0
- package/core/dist/runtime-v2/evidence-triage/admission-events.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/index.d.ts +16 -0
- package/core/dist/runtime-v2/evidence-triage/index.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/index.js +13 -0
- package/core/dist/runtime-v2/evidence-triage/index.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts +48 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js +131 -0
- package/core/dist/runtime-v2/evidence-triage/source-descriptors.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts +32 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js +95 -0
- package/core/dist/runtime-v2/evidence-triage/triage-policy.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.d.ts +116 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.js +218 -0
- package/core/dist/runtime-v2/evidence-triage/trigger-controller.js.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/types.d.ts +65 -0
- package/core/dist/runtime-v2/evidence-triage/types.d.ts.map +1 -0
- package/core/dist/runtime-v2/evidence-triage/types.js +38 -0
- package/core/dist/runtime-v2/evidence-triage/types.js.map +1 -0
- package/core/dist/runtime-v2/feature-flags/__tests__/feature-flag-contract.test.js +10 -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 +1 -0
- package/core/dist/runtime-v2/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime-v2/index.d.ts +8 -1
- package/core/dist/runtime-v2/index.d.ts.map +1 -1
- package/core/dist/runtime-v2/index.js +7 -1
- package/core/dist/runtime-v2/index.js.map +1 -1
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.d.ts +12 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.d.ts.map +1 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js +83 -0
- package/core/dist/runtime-v2/internalization/__tests__/scribe-prompt-language.test.js.map +1 -0
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts +10 -0
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js +13 -1
- package/core/dist/runtime-v2/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.d.ts +3 -0
- package/core/dist/runtime-v2/internalization/scribe-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/internalization/scribe-runner.js +2 -0
- package/core/dist/runtime-v2/internalization/scribe-runner.js.map +1 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js +1 -1
- package/core/dist/runtime-v2/internalization-chain-integrity-read-model.js.map +1 -1
- package/core/dist/runtime-v2/language-directive.d.ts +80 -0
- package/core/dist/runtime-v2/language-directive.d.ts.map +1 -0
- package/core/dist/runtime-v2/language-directive.js +108 -0
- package/core/dist/runtime-v2/language-directive.js.map +1 -0
- package/core/dist/runtime-v2/pain-signal-observability.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-signal-observability.js +24 -11
- package/core/dist/runtime-v2/pain-signal-observability.js.map +1 -1
- package/core/dist/runtime-v2/pain-signal-runtime-factory.d.ts +16 -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 +97 -6
- package/core/dist/runtime-v2/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts +7 -0
- package/core/dist/runtime-v2/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime-v2/pain-to-principle-service.js +2 -0
- package/core/dist/runtime-v2/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.d.ts.map +1 -1
- package/core/dist/runtime-v2/proven-channel-baseline.js +14 -0
- package/core/dist/runtime-v2/proven-channel-baseline.js.map +1 -1
- package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js +40 -0
- package/core/dist/runtime-v2/runner/__tests__/diagnostician-runner.test.js.map +1 -1
- package/core/dist/runtime-v2/runner/base-peer-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/runner/base-peer-runner.js +1 -0
- package/core/dist/runtime-v2/runner/base-peer-runner.js.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.d.ts +10 -0
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.d.ts.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.js +1 -0
- package/core/dist/runtime-v2/runner/diagnostician-runner-options.js.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime-v2/runner/diagnostician-runner.js +28 -4
- package/core/dist/runtime-v2/runner/diagnostician-runner.js.map +1 -1
- package/core/dist/runtime-v2/runner/peer-runner-types.d.ts +9 -0
- package/core/dist/runtime-v2/runner/peer-runner-types.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.integration.test.js +34 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.integration.test.js.map +1 -1
- package/core/dist/runtime-v2/store/runtime-state-manager.js +1 -0
- package/core/dist/runtime-v2/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js +9 -1
- package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js +1 -1
- package/core/dist/runtime-v2/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime-v2/task-status.d.ts +4 -4
- package/core/dist/runtime-v2/task-status.d.ts.map +1 -1
- package/core/dist/runtime-v2/task-status.js +2 -2
- package/core/dist/runtime-v2/task-status.js.map +1 -1
- package/core/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/console.d.ts +2 -0
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +6 -1
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +18 -1
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/pain-evidence.d.ts +41 -0
- package/pd-cli/dist/commands/pain-evidence.d.ts.map +1 -0
- package/pd-cli/dist/commands/pain-evidence.js +177 -0
- package/pd-cli/dist/commands/pain-evidence.js.map +1 -0
- package/pd-cli/dist/commands/pain-record.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-record.js +24 -9
- package/pd-cli/dist/commands/pain-record.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts +19 -0
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -0
- package/pd-cli/dist/commands/pain-retry.js +485 -0
- package/pd-cli/dist/commands/pain-retry.js.map +1 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +59 -9
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.d.ts +1 -0
- package/pd-cli/dist/commands/runtime-uat.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-uat.guard.test.d.ts +2 -0
- package/pd-cli/dist/commands/runtime-uat.guard.test.d.ts.map +1 -0
- package/pd-cli/dist/commands/runtime-uat.guard.test.js +155 -0
- package/pd-cli/dist/commands/runtime-uat.guard.test.js.map +1 -0
- package/pd-cli/dist/commands/runtime-uat.js +29 -3
- package/pd-cli/dist/commands/runtime-uat.js.map +1 -1
- package/pd-cli/dist/config-reader.d.ts +25 -0
- package/pd-cli/dist/config-reader.d.ts.map +1 -0
- package/pd-cli/dist/config-reader.js +109 -0
- package/pd-cli/dist/config-reader.js.map +1 -0
- package/pd-cli/dist/index.js +40 -5
- package/pd-cli/dist/index.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +29 -15
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.d.ts.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js +1 -0
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/utils/production-workspace-guard.d.ts +77 -0
- package/pd-cli/dist/utils/production-workspace-guard.d.ts.map +1 -0
- package/pd-cli/dist/utils/production-workspace-guard.js +170 -0
- package/pd-cli/dist/utils/production-workspace-guard.js.map +1 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.d.ts +2 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.d.ts.map +1 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.js +95 -0
- package/pd-cli/dist/utils/production-workspace-guard.test.js.map +1 -0
- package/pd-cli/package.json +1 -1
- package/plugin/dist/commands/pain.js +27 -2
- package/plugin/dist/core/pain-diagnostic-gate.d.ts +6 -0
- package/plugin/dist/core/pain-diagnostic-gate.js +9 -0
- package/plugin/dist/hooks/after-tool-call-helpers.d.ts +90 -0
- package/plugin/dist/hooks/after-tool-call-helpers.js +486 -0
- package/plugin/dist/hooks/after-tool-call-types.d.ts +92 -0
- package/plugin/dist/hooks/after-tool-call-types.js +13 -0
- package/plugin/dist/hooks/gate-block-helper.js +73 -29
- package/plugin/dist/hooks/llm.js +49 -29
- package/plugin/dist/hooks/message-sanitize.d.ts +21 -0
- package/plugin/dist/hooks/message-sanitize.js +30 -0
- package/plugin/dist/hooks/pain.d.ts +26 -3
- package/plugin/dist/hooks/pain.js +165 -425
- package/plugin/dist/hooks/prompt.js +3 -2
- package/plugin/dist/hooks/trajectory-evidence.d.ts +11 -0
- package/plugin/dist/hooks/trajectory-evidence.js +65 -0
- package/plugin/dist/hooks/triage-adapter.d.ts +82 -0
- package/plugin/dist/hooks/triage-adapter.js +121 -0
- package/console/dist/server/models/EventLogReadModel.d.ts +0 -33
- package/console/dist/server/models/EventLogReadModel.js +0 -218
- package/console/dist/server/models/EvolutionConsoleModel.d.ts +0 -79
- package/console/dist/server/models/EvolutionConsoleModel.js +0 -179
- package/console/dist/server/models/FeedbackConsoleModel.d.ts +0 -38
- package/console/dist/server/models/FeedbackConsoleModel.js +0 -129
- package/console/dist/server/models/GateConsoleModel.d.ts +0 -50
- package/console/dist/server/models/GateConsoleModel.js +0 -151
- package/console/dist/server/models/OverviewConsoleModel.d.ts +0 -22
- package/console/dist/server/models/OverviewConsoleModel.js +0 -202
- package/console/dist/server/models/PipelineStatsModel.d.ts +0 -35
- package/console/dist/server/models/PipelineStatsModel.js +0 -129
- package/console/dist/server/models/SampleConsoleModel.d.ts +0 -21
- package/console/dist/server/models/SampleConsoleModel.js +0 -188
- package/console/dist/server/models/ThinkingModelsConsoleModel.d.ts +0 -22
- package/console/dist/server/models/ThinkingModelsConsoleModel.js +0 -75
- package/console/dist/server/routes/agents.d.ts +0 -3
- package/console/dist/server/routes/agents.js +0 -442
- package/console/dist/server/routes/central.d.ts +0 -5
- package/console/dist/server/routes/central.js +0 -31
- package/console/dist/server/routes/events.d.ts +0 -10
- package/console/dist/server/routes/events.js +0 -99
- package/console/dist/server/routes/evolution.js +0 -73
- package/console/dist/server/routes/feedback.d.ts +0 -3
- package/console/dist/server/routes/feedback.js +0 -65
- package/console/dist/server/routes/gates.d.ts +0 -3
- package/console/dist/server/routes/gates.js +0 -52
- package/console/dist/server/routes/overview.d.ts +0 -3
- package/console/dist/server/routes/overview.js +0 -49
- package/console/dist/server/routes/pipeline.d.ts +0 -3
- package/console/dist/server/routes/pipeline.js +0 -33
- package/console/dist/server/routes/samples.d.ts +0 -3
- package/console/dist/server/routes/samples.js +0 -101
- package/console/dist/server/routes/thinking-models.d.ts +0 -3
- package/console/dist/server/routes/thinking-models.js +0 -54
- package/console/dist/ui/components/app-sidebar.d.ts +0 -7
- package/console/dist/ui/components/app-sidebar.js +0 -75
- package/console/dist/ui/components/compare-view.d.ts +0 -7
- package/console/dist/ui/components/compare-view.js +0 -32
- package/console/dist/ui/components/data-freshness-indicator.d.ts +0 -10
- package/console/dist/ui/components/data-freshness-indicator.js +0 -63
- package/console/dist/ui/components/health-diagnostic-card.d.ts +0 -15
- package/console/dist/ui/components/health-diagnostic-card.js +0 -42
- package/console/dist/ui/components/page-header.d.ts +0 -10
- package/console/dist/ui/components/page-header.js +0 -37
- package/console/dist/ui/hooks/useAutoRefresh.d.ts +0 -13
- package/console/dist/ui/hooks/useAutoRefresh.js +0 -64
- package/console/dist/ui/hooks/useBookmarks.d.ts +0 -6
- package/console/dist/ui/hooks/useBookmarks.js +0 -43
- package/console/dist/ui/hooks/useDebounce.d.ts +0 -2
- package/console/dist/ui/hooks/useDebounce.js +0 -32
- package/console/dist/ui/hooks/useKeyboardNavigation.d.ts +0 -14
- package/console/dist/ui/hooks/useKeyboardNavigation.js +0 -75
- package/console/dist/ui/pages/AgentsPage.d.ts +0 -1
- package/console/dist/ui/pages/AgentsPage.js +0 -167
- package/console/dist/ui/pages/ApprovalsPage.d.ts +0 -1
- package/console/dist/ui/pages/ApprovalsPage.js +0 -123
- package/console/dist/ui/pages/CentralPage.d.ts +0 -1
- package/console/dist/ui/pages/CentralPage.js +0 -57
- package/console/dist/ui/pages/DataFlowPage.d.ts +0 -1
- package/console/dist/ui/pages/DataFlowPage.js +0 -158
- package/console/dist/ui/pages/EventLogPage.d.ts +0 -1
- package/console/dist/ui/pages/EventLogPage.js +0 -176
- package/console/dist/ui/pages/EvolutionPage.d.ts +0 -1
- package/console/dist/ui/pages/EvolutionPage.js +0 -118
- package/console/dist/ui/pages/FeedbackPage.d.ts +0 -1
- package/console/dist/ui/pages/FeedbackPage.js +0 -46
- package/console/dist/ui/pages/GatesPage.d.ts +0 -1
- package/console/dist/ui/pages/GatesPage.js +0 -31
- package/console/dist/ui/pages/LoginPage.d.ts +0 -5
- package/console/dist/ui/pages/LoginPage.js +0 -39
- package/console/dist/ui/pages/OverviewPage.d.ts +0 -1
- package/console/dist/ui/pages/OverviewPage.js +0 -50
- package/console/dist/ui/pages/PainPage.js +0 -50
- package/console/dist/ui/pages/PrincipleDetailPage.js +0 -145
- package/console/dist/ui/pages/PrinciplesPage.js +0 -322
- package/console/dist/ui/pages/ReportProblemPage.js +0 -186
- package/console/dist/ui/pages/SamplesPage.d.ts +0 -1
- package/console/dist/ui/pages/SamplesPage.js +0 -105
- package/console/dist/ui/pages/SettingsPage.d.ts +0 -1
- package/console/dist/ui/pages/SettingsPage.js +0 -86
- package/console/dist/ui/pages/TasksPage.d.ts +0 -1
- package/console/dist/ui/pages/TasksPage.js +0 -373
- package/console/dist/ui/pages/ThinkingModelsPage.d.ts +0 -1
- package/console/dist/ui/pages/ThinkingModelsPage.js +0 -32
- package/console/dist/ui/pages/UpdatePage.d.ts +0 -1
- package/console/dist/ui/pages/UpdatePage.js +0 -142
- /package/console/dist/ui/pages/{PainPage.d.ts → pain/PainPage.d.ts} +0 -0
- /package/console/dist/ui/pages/{PrincipleDetailPage.d.ts → principles/PrincipleDetailPage.d.ts} +0 -0
- /package/console/dist/ui/pages/{PrinciplesPage.d.ts → principles/PrinciplesPage.d.ts} +0 -0
- /package/console/dist/ui/pages/{ReportProblemPage.d.ts → report-problem/ReportProblemPage.d.ts} +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PrincipleClassifier — Read model that classifies principles into
|
|
3
|
+
* owner-actionable vs noise categories.
|
|
4
|
+
*
|
|
5
|
+
* Categories:
|
|
6
|
+
* - owner_actionable: Needs a real governance decision (pending, probation, candidate)
|
|
7
|
+
* - demo: Demo / example principles planted by the framework
|
|
8
|
+
* - smoke: Smoke-test principles for CI validation
|
|
9
|
+
* - historical: Archived or deprecated principles (already decided long ago)
|
|
10
|
+
* - builtin: Core Thinking OS axioms (T-01..T-10) — not governance targets
|
|
11
|
+
* - already_decided: Approved / rejected via approval queue
|
|
12
|
+
*
|
|
13
|
+
* Classification is purely read-side; it does NOT mutate any data.
|
|
14
|
+
*/
|
|
15
|
+
// ── Heuristics ────────────────────────────────────────────────────────────────
|
|
16
|
+
/** Regex that matches exactly T-01 through T-10 (Thinking OS axioms) */
|
|
17
|
+
const BUILTIN_ID_REGEX = /^T-(0[1-9]|10)$/;
|
|
18
|
+
/** ID prefixes that indicate demo / dogfood data */
|
|
19
|
+
const DEMO_ID_PREFIXES = ['DEMO_', 'demo_', 'story-a', 'story_a', 'dogfood_'];
|
|
20
|
+
/** ID prefixes that indicate smoke / test data */
|
|
21
|
+
const SMOKE_ID_PREFIXES = ['SMOKE_', 'smoke_', 'probe_', 'test_principle_'];
|
|
22
|
+
/** Substrings that indicate demo/smoke principles (only matched in ID, not in text) */
|
|
23
|
+
const DEMO_ID_KEYWORDS = ['demo', 'example', 'sample', 'placeholder'];
|
|
24
|
+
const SMOKE_ID_KEYWORDS = ['smoke', 'smoketest', 'smoke_test', 'probe'];
|
|
25
|
+
/** Substrings in text that indicate demo/smoke — more restrictive than ID matching */
|
|
26
|
+
const DEMO_TEXT_KEYWORDS = ['[demo]', '[example]', '[placeholder]'];
|
|
27
|
+
const SMOKE_TEXT_KEYWORDS = ['[smoke]', '[smoketest]'];
|
|
28
|
+
function hasPrefix(id, prefixes) {
|
|
29
|
+
return prefixes.some((p) => id.toLowerCase().startsWith(p.toLowerCase()));
|
|
30
|
+
}
|
|
31
|
+
function hasKeyword(text, keywords) {
|
|
32
|
+
const lower = text.toLowerCase();
|
|
33
|
+
return keywords.some((k) => lower.includes(k));
|
|
34
|
+
}
|
|
35
|
+
function isBuiltinId(id) {
|
|
36
|
+
return BUILTIN_ID_REGEX.test(id);
|
|
37
|
+
}
|
|
38
|
+
// ── Classifier ────────────────────────────────────────────────────────────────
|
|
39
|
+
/**
|
|
40
|
+
* Classify a single principle. Order matters — earlier checks win.
|
|
41
|
+
*
|
|
42
|
+
* @param p - The principle to classify
|
|
43
|
+
* @param decidedPrincipleIds - Set of principle IDs that have been decided
|
|
44
|
+
* via the approval queue (approved or rejected). These should be classified
|
|
45
|
+
* as already_decided regardless of their ledger status.
|
|
46
|
+
*/
|
|
47
|
+
export function classifyPrinciple(p, decidedPrincipleIds) {
|
|
48
|
+
// 1. Builtin axioms (T-01..T-10) are never governance targets
|
|
49
|
+
if (isBuiltinId(p.id)) {
|
|
50
|
+
return 'builtin';
|
|
51
|
+
}
|
|
52
|
+
// 2. Demo / dogfood principles — ID prefix is primary signal
|
|
53
|
+
if (hasPrefix(p.id, DEMO_ID_PREFIXES) || hasKeyword(p.id, DEMO_ID_KEYWORDS)) {
|
|
54
|
+
return 'demo';
|
|
55
|
+
}
|
|
56
|
+
// Text matching is intentionally restrictive (bracketed tags only) to avoid
|
|
57
|
+
// false positives on real principles that happen to mention "sample" or "template"
|
|
58
|
+
if (hasKeyword(p.text + p.triggerPattern, DEMO_TEXT_KEYWORDS)) {
|
|
59
|
+
return 'demo';
|
|
60
|
+
}
|
|
61
|
+
// 3. Smoke test principles — ID prefix is primary signal
|
|
62
|
+
if (hasPrefix(p.id, SMOKE_ID_PREFIXES) || hasKeyword(p.id, SMOKE_ID_KEYWORDS)) {
|
|
63
|
+
return 'smoke';
|
|
64
|
+
}
|
|
65
|
+
if (hasKeyword(p.text + p.triggerPattern, SMOKE_TEXT_KEYWORDS)) {
|
|
66
|
+
return 'smoke';
|
|
67
|
+
}
|
|
68
|
+
// 4. Already decided via approval queue (approved or rejected)
|
|
69
|
+
// This catches principles whose ledger status is still 'candidate' but
|
|
70
|
+
// have been decided through the approval workflow.
|
|
71
|
+
if (decidedPrincipleIds && decidedPrincipleIds.has(p.id)) {
|
|
72
|
+
return 'already_decided';
|
|
73
|
+
}
|
|
74
|
+
// 5. Already decided: active = approved & in effect, no governance needed
|
|
75
|
+
if (p.status === 'active') {
|
|
76
|
+
return 'already_decided';
|
|
77
|
+
}
|
|
78
|
+
// 6. Historical: archived or deprecated
|
|
79
|
+
if (p.status === 'archived' || p.status === 'deprecated') {
|
|
80
|
+
return 'historical';
|
|
81
|
+
}
|
|
82
|
+
// 7. Only candidate / probation need owner decision
|
|
83
|
+
return 'owner_actionable';
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Classify a batch of principles. Returns the classified array.
|
|
87
|
+
*
|
|
88
|
+
* @param principles - The principles to classify
|
|
89
|
+
* @param decidedPrincipleIds - Set of principle IDs that have been decided
|
|
90
|
+
* via the approval queue (approved or rejected).
|
|
91
|
+
*/
|
|
92
|
+
export function classifyPrinciples(principles, decidedPrincipleIds) {
|
|
93
|
+
return principles.map((p) => ({ principle: p, category: classifyPrinciple(p, decidedPrincipleIds) }));
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Filter to only owner-actionable principles.
|
|
97
|
+
*/
|
|
98
|
+
export function filterOwnerActionable(classified) {
|
|
99
|
+
return classified.filter((c) => c.category === 'owner_actionable');
|
|
100
|
+
}
|
|
@@ -21,6 +21,10 @@ export interface PrincipleListItem {
|
|
|
21
21
|
conflictsWithCount: number;
|
|
22
22
|
createdAt: string;
|
|
23
23
|
updatedAt: string;
|
|
24
|
+
/** Detected language of the principle text ('en' | 'zh' | 'unknown'). PRI-332 */
|
|
25
|
+
detectedLanguage: 'en' | 'zh' | 'unknown';
|
|
26
|
+
/** Structured readability warning code — front-end renders via i18n. PRI-332 P1-5 */
|
|
27
|
+
readabilityWarningCode?: ReadabilityWarningCode;
|
|
24
28
|
}
|
|
25
29
|
export interface RuleItem {
|
|
26
30
|
id: string;
|
|
@@ -53,10 +57,17 @@ export interface PrinciplesListOutput {
|
|
|
53
57
|
archived: number;
|
|
54
58
|
total: number;
|
|
55
59
|
};
|
|
60
|
+
/** Category breakdown (PRI-330) */
|
|
61
|
+
categories?: Record<string, number>;
|
|
62
|
+
/** If the approval cross-check was unavailable, this explains why (ERR-002) */
|
|
63
|
+
approvalCrossCheckUnavailable?: string;
|
|
56
64
|
}
|
|
65
|
+
export type PrincipleFilter = 'all' | 'actionable';
|
|
57
66
|
export interface PrincipleDetailOutput {
|
|
58
67
|
principle: PrincipleDetail;
|
|
59
68
|
}
|
|
69
|
+
/** Structured readability warning codes — front-end renders via i18n (PRI-332 P1-5). */
|
|
70
|
+
export type ReadabilityWarningCode = 'technical_pattern' | 'diagnostic_residue' | 'title_too_long';
|
|
60
71
|
export declare class PrinciplesConsoleModel {
|
|
61
72
|
private readonly workspaceDir;
|
|
62
73
|
private cachedLedger;
|
|
@@ -64,6 +75,6 @@ export declare class PrinciplesConsoleModel {
|
|
|
64
75
|
constructor(workspaceDir: string);
|
|
65
76
|
private getLedgerPath;
|
|
66
77
|
private loadLedger;
|
|
67
|
-
listPrinciples(): Promise<PrinciplesListOutput>;
|
|
78
|
+
listPrinciples(filter?: PrincipleFilter, decidedPrincipleIds?: Set<string>): Promise<PrinciplesListOutput>;
|
|
68
79
|
getPrincipleDetail(principleId: string): Promise<PrincipleDetailOutput | null>;
|
|
69
80
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
|
+
import { classifyPrinciples, filterOwnerActionable } from './PrincipleClassifier.js';
|
|
3
4
|
const VALID_STATUSES = ['candidate', 'active', 'archived', 'deprecated', 'probation'];
|
|
4
5
|
const VALID_PRIORITIES = ['P0', 'P1', 'P2'];
|
|
5
6
|
const VALID_SCOPES = ['general', 'domain'];
|
|
@@ -7,6 +8,33 @@ const VALID_EVALUABILITIES = ['manual_only', 'deterministic', 'weak_heuristic'];
|
|
|
7
8
|
const VALID_RULE_TYPES = ['hook', 'gate', 'skill', 'lora', 'test', 'prompt'];
|
|
8
9
|
const VALID_RULE_STATUSES = ['proposed', 'implemented', 'enforced', 'retired'];
|
|
9
10
|
const VALID_ENFORCEMENTS = ['block', 'warn', 'log'];
|
|
11
|
+
// ── PRI-332: Language detection & readability helpers ────────────────────────
|
|
12
|
+
const CJK_REGEX = /[\u4e00-\u9fff\u3400-\u4dbf]/;
|
|
13
|
+
const REGEX_LIKE_PATTERN = /^[/^.*+?()[\]{}|$\\]|\/.*\/[gimsuy]*$/;
|
|
14
|
+
const TECHNICAL_RESIDUE_PATTERN = /^[a-zA-Z_]+\.[a-zA-Z_]+\(|^Error:|^TypeError:|\{\{.*\}\}|<\/?\w+>/;
|
|
15
|
+
/** Simple CJK-based language detection for principle text. */
|
|
16
|
+
function detectLanguage(text) {
|
|
17
|
+
if (!text || text.trim().length === 0)
|
|
18
|
+
return 'unknown';
|
|
19
|
+
return CJK_REGEX.test(text) ? 'zh' : 'en';
|
|
20
|
+
}
|
|
21
|
+
/** Check if a triggerPattern/title looks like unreadable technical residue.
|
|
22
|
+
* Returns a structured code instead of an English string (PRI-332 P1-5). */
|
|
23
|
+
function checkReadabilityWarning(triggerPattern, text) {
|
|
24
|
+
const title = triggerPattern || text.slice(0, 80);
|
|
25
|
+
if (!title)
|
|
26
|
+
return undefined;
|
|
27
|
+
if (REGEX_LIKE_PATTERN.test(title.trim())) {
|
|
28
|
+
return 'technical_pattern';
|
|
29
|
+
}
|
|
30
|
+
if (TECHNICAL_RESIDUE_PATTERN.test(title.trim())) {
|
|
31
|
+
return 'diagnostic_residue';
|
|
32
|
+
}
|
|
33
|
+
if (title.length > 120) {
|
|
34
|
+
return 'title_too_long';
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
10
38
|
function isRecord(value) {
|
|
11
39
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
12
40
|
}
|
|
@@ -95,7 +123,7 @@ export class PrinciplesConsoleModel {
|
|
|
95
123
|
this.cacheTimestamp = now;
|
|
96
124
|
return ledger;
|
|
97
125
|
}
|
|
98
|
-
async listPrinciples() {
|
|
126
|
+
async listPrinciples(filter, decidedPrincipleIds) {
|
|
99
127
|
const ledger = this.loadLedger();
|
|
100
128
|
const principles = Object.values(ledger.tree.principles);
|
|
101
129
|
const summary = {
|
|
@@ -126,10 +154,12 @@ export class PrinciplesConsoleModel {
|
|
|
126
154
|
summary.archived++;
|
|
127
155
|
break;
|
|
128
156
|
}
|
|
157
|
+
const principleText = p.text ?? '';
|
|
158
|
+
const principleTrigger = p.triggerPattern ?? '';
|
|
129
159
|
items.push({
|
|
130
160
|
id: p.id,
|
|
131
|
-
text:
|
|
132
|
-
triggerPattern:
|
|
161
|
+
text: principleText,
|
|
162
|
+
triggerPattern: principleTrigger,
|
|
133
163
|
action: p.action ?? '',
|
|
134
164
|
status,
|
|
135
165
|
priority: safeCastEnum(p.priority, VALID_PRIORITIES, 'P2'),
|
|
@@ -143,10 +173,23 @@ export class PrinciplesConsoleModel {
|
|
|
143
173
|
conflictsWithCount: (p.conflictsWithPrincipleIds ?? []).length,
|
|
144
174
|
createdAt: p.createdAt ?? '',
|
|
145
175
|
updatedAt: p.updatedAt ?? '',
|
|
176
|
+
detectedLanguage: detectLanguage(principleText),
|
|
177
|
+
readabilityWarningCode: checkReadabilityWarning(principleTrigger, principleText),
|
|
146
178
|
});
|
|
147
179
|
}
|
|
148
180
|
items.sort((a, b) => b.valueScore - a.valueScore);
|
|
149
|
-
|
|
181
|
+
// PRI-330: classify and optionally filter
|
|
182
|
+
const classified = classifyPrinciples(items, decidedPrincipleIds);
|
|
183
|
+
const categories = {};
|
|
184
|
+
for (const c of classified) {
|
|
185
|
+
categories[c.category] = (categories[c.category] ?? 0) + 1;
|
|
186
|
+
}
|
|
187
|
+
let outputItems = items;
|
|
188
|
+
if (filter === 'actionable') {
|
|
189
|
+
const actionable = filterOwnerActionable(classified);
|
|
190
|
+
outputItems = actionable.map((c) => c.principle);
|
|
191
|
+
}
|
|
192
|
+
return { principles: outputItems, summary, categories };
|
|
150
193
|
}
|
|
151
194
|
async getPrincipleDetail(principleId) {
|
|
152
195
|
const ledger = this.loadLedger();
|
|
@@ -170,10 +213,12 @@ export class PrinciplesConsoleModel {
|
|
|
170
213
|
falsePositiveRate: r.falsePositiveRate ?? 0,
|
|
171
214
|
}));
|
|
172
215
|
const status = safeCastEnum(p.status, VALID_STATUSES, 'candidate');
|
|
216
|
+
const detailText = p.text ?? '';
|
|
217
|
+
const detailTrigger = p.triggerPattern ?? '';
|
|
173
218
|
const principle = {
|
|
174
219
|
id: p.id,
|
|
175
|
-
text:
|
|
176
|
-
triggerPattern:
|
|
220
|
+
text: detailText,
|
|
221
|
+
triggerPattern: detailTrigger,
|
|
177
222
|
action: p.action ?? '',
|
|
178
223
|
status,
|
|
179
224
|
priority: safeCastEnum(p.priority, VALID_PRIORITIES, 'P2'),
|
|
@@ -194,6 +239,8 @@ export class PrinciplesConsoleModel {
|
|
|
194
239
|
createdAt: p.createdAt ?? '',
|
|
195
240
|
updatedAt: p.updatedAt ?? '',
|
|
196
241
|
rules,
|
|
242
|
+
detectedLanguage: detectLanguage(detailText),
|
|
243
|
+
readabilityWarningCode: checkReadabilityWarning(detailTrigger, detailText),
|
|
197
244
|
};
|
|
198
245
|
return { principle };
|
|
199
246
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OperatorHealthReadModel, PainChainReadModel, PruningReadModel, RuntimeStateManager, } from '@principles/core/runtime-v2';
|
|
2
|
+
const noop = () => { };
|
|
2
3
|
export class WorkspaceService {
|
|
3
4
|
configStore;
|
|
4
5
|
models = new Map();
|
|
@@ -10,14 +11,18 @@ export class WorkspaceService {
|
|
|
10
11
|
const results = [];
|
|
11
12
|
for (const ws of workspaces) {
|
|
12
13
|
try {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
14
|
+
const models = this.getModels(ws);
|
|
15
|
+
const [snapshot, pruningSummary] = await Promise.all([
|
|
16
|
+
models.operatorHealth.getSnapshot(),
|
|
17
|
+
Promise.resolve(models.pruning.getHealthSummary()),
|
|
18
|
+
]);
|
|
19
|
+
const { byStatus } = pruningSummary;
|
|
15
20
|
results.push({
|
|
16
21
|
name: ws.name,
|
|
17
22
|
path: ws.path,
|
|
18
|
-
status:
|
|
19
|
-
gfi:
|
|
20
|
-
principleCount:
|
|
23
|
+
status: snapshot.overallStatus === 'healthy' ? 'healthy' : snapshot.overallStatus === 'degraded' ? 'degraded' : 'error',
|
|
24
|
+
gfi: snapshot.gfi.active?.currentGfi ?? 0,
|
|
25
|
+
principleCount: (byStatus.active ?? 0) + (byStatus.candidate ?? 0),
|
|
21
26
|
});
|
|
22
27
|
}
|
|
23
28
|
catch {
|
|
@@ -42,20 +47,26 @@ export class WorkspaceService {
|
|
|
42
47
|
let overallStatus = 'healthy';
|
|
43
48
|
for (const ws of workspaces) {
|
|
44
49
|
try {
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
50
|
+
const models = this.getModels(ws);
|
|
51
|
+
const [snapshot, pruningSummary, pendingTasks] = await Promise.all([
|
|
52
|
+
models.operatorHealth.getSnapshot(),
|
|
53
|
+
Promise.resolve(models.pruning.getHealthSummary()),
|
|
54
|
+
models.runtime.listTasks({ status: 'pending', limit: 100 }),
|
|
55
|
+
]);
|
|
56
|
+
const { byStatus } = pruningSummary;
|
|
57
|
+
const wsStatus = snapshot.overallStatus === 'healthy' ? 'healthy' : snapshot.overallStatus === 'degraded' ? 'degraded' : 'error';
|
|
58
|
+
if (wsStatus === 'error') {
|
|
48
59
|
overallStatus = 'error';
|
|
49
60
|
}
|
|
50
|
-
else if (
|
|
61
|
+
else if (wsStatus !== 'healthy' && overallStatus === 'healthy') {
|
|
51
62
|
overallStatus = 'degraded';
|
|
52
63
|
}
|
|
53
64
|
results.push({
|
|
54
65
|
name: ws.name,
|
|
55
|
-
status:
|
|
56
|
-
gfi:
|
|
57
|
-
activePrinciples:
|
|
58
|
-
pendingTasks:
|
|
66
|
+
status: wsStatus,
|
|
67
|
+
gfi: snapshot.gfi.active?.currentGfi ?? 0,
|
|
68
|
+
activePrinciples: (byStatus.active ?? 0) + (byStatus.candidate ?? 0),
|
|
69
|
+
pendingTasks: pendingTasks.length,
|
|
59
70
|
});
|
|
60
71
|
}
|
|
61
72
|
catch {
|
|
@@ -80,7 +91,7 @@ export class WorkspaceService {
|
|
|
80
91
|
if (!entry) {
|
|
81
92
|
throw new Error(`Workspace "${name}" not found`);
|
|
82
93
|
}
|
|
83
|
-
this.
|
|
94
|
+
this.disposeWorkspace(name);
|
|
84
95
|
this.configStore.updateSyncTime(name);
|
|
85
96
|
return {
|
|
86
97
|
success: true,
|
|
@@ -89,17 +100,34 @@ export class WorkspaceService {
|
|
|
89
100
|
};
|
|
90
101
|
}
|
|
91
102
|
dispose() {
|
|
92
|
-
for (const
|
|
93
|
-
|
|
103
|
+
for (const name of this.models.keys()) {
|
|
104
|
+
this.disposeWorkspace(name);
|
|
94
105
|
}
|
|
95
106
|
this.models.clear();
|
|
96
107
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
108
|
+
disposeWorkspace(name) {
|
|
109
|
+
const existing = this.models.get(name);
|
|
110
|
+
if (existing) {
|
|
111
|
+
existing.operatorHealth.close().catch(noop);
|
|
112
|
+
existing.painChain.close().catch(noop);
|
|
113
|
+
existing.runtime.close().catch(noop);
|
|
114
|
+
this.models.delete(name);
|
|
102
115
|
}
|
|
103
|
-
|
|
116
|
+
}
|
|
117
|
+
getModels(entry) {
|
|
118
|
+
let existing = this.models.get(entry.name);
|
|
119
|
+
if (!existing) {
|
|
120
|
+
const runtime = new RuntimeStateManager({ workspaceDir: entry.path });
|
|
121
|
+
const painChain = new PainChainReadModel({ workspaceDir: entry.path, stateManager: runtime });
|
|
122
|
+
const pruning = new PruningReadModel({ workspaceDir: entry.path });
|
|
123
|
+
const operatorHealth = new OperatorHealthReadModel({
|
|
124
|
+
workspaceDir: entry.path,
|
|
125
|
+
painChainReadModel: painChain,
|
|
126
|
+
pruningReadModel: pruning,
|
|
127
|
+
});
|
|
128
|
+
existing = { operatorHealth, painChain, pruning, runtime };
|
|
129
|
+
this.models.set(entry.name, existing);
|
|
130
|
+
}
|
|
131
|
+
return existing;
|
|
104
132
|
}
|
|
105
133
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ActivationsConsoleModel } from '../models/ActivationsConsoleModel.js';
|
|
2
|
+
import { sendSuccess, sendError, sendNotFound } from '../utils/response.js';
|
|
3
|
+
const MAX_BODY_SIZE = 1024 * 1024; // 1 MB
|
|
4
|
+
const models = new Map();
|
|
5
|
+
function getModel(workspaceDir) {
|
|
6
|
+
let model = models.get(workspaceDir);
|
|
7
|
+
if (!model) {
|
|
8
|
+
model = new ActivationsConsoleModel(workspaceDir);
|
|
9
|
+
models.set(workspaceDir, model);
|
|
10
|
+
}
|
|
11
|
+
return model;
|
|
12
|
+
}
|
|
13
|
+
// ── Request body validation (ERR-001/005/009/013) ───────────────────────────
|
|
14
|
+
function isRecord(value) {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
function validateDisableRequest(body) {
|
|
18
|
+
if (!isRecord(body)) {
|
|
19
|
+
return { ok: false, reason: 'Request body must be a JSON object' };
|
|
20
|
+
}
|
|
21
|
+
if (!Object.hasOwn(body, 'confirmed')) {
|
|
22
|
+
return { ok: false, reason: 'Missing required field: confirmed' };
|
|
23
|
+
}
|
|
24
|
+
if (typeof body.confirmed !== 'boolean') {
|
|
25
|
+
return { ok: false, reason: 'Field "confirmed" must be a boolean' };
|
|
26
|
+
}
|
|
27
|
+
if (!body.confirmed) {
|
|
28
|
+
return { ok: false, reason: 'Disable operation requires confirmed=true' };
|
|
29
|
+
}
|
|
30
|
+
return { ok: true, confirmed: true };
|
|
31
|
+
}
|
|
32
|
+
// ── Route handler ────────────────────────────────────────────────────────────
|
|
33
|
+
/* eslint-disable @typescript-eslint/max-params */
|
|
34
|
+
export async function handleActivationsRoute(req, res, workspaceDir, subPath) {
|
|
35
|
+
// GET /api/v1/activations
|
|
36
|
+
if (req.method === 'GET' && (subPath === '' || subPath === '/')) {
|
|
37
|
+
const model = getModel(workspaceDir);
|
|
38
|
+
try {
|
|
39
|
+
const result = await model.getActivations();
|
|
40
|
+
sendSuccess(res, result);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
44
|
+
sendError(res, 500, 'activations_error', message);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// POST /api/v1/activations/:id/disable
|
|
49
|
+
const disableExec = /^\/([^/]+)\/disable$/.exec(subPath);
|
|
50
|
+
if (req.method === 'POST' && disableExec) {
|
|
51
|
+
const [, rawId] = disableExec;
|
|
52
|
+
let activationId;
|
|
53
|
+
try {
|
|
54
|
+
activationId = decodeURIComponent(rawId);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
sendError(res, 400, 'invalid_id', 'Activation ID contains invalid URI encoding');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const model = getModel(workspaceDir);
|
|
61
|
+
// Read and validate request body
|
|
62
|
+
let body;
|
|
63
|
+
try {
|
|
64
|
+
const chunks = [];
|
|
65
|
+
let totalSize = 0;
|
|
66
|
+
for await (const chunk of req) {
|
|
67
|
+
const buf = typeof chunk === 'string' ? Buffer.from(chunk) : chunk;
|
|
68
|
+
totalSize += buf.length;
|
|
69
|
+
if (totalSize > MAX_BODY_SIZE) {
|
|
70
|
+
sendError(res, 413, 'payload_too_large', 'Request body exceeds maximum allowed size');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
chunks.push(buf);
|
|
74
|
+
}
|
|
75
|
+
const rawBody = Buffer.concat(chunks).toString('utf-8');
|
|
76
|
+
body = JSON.parse(rawBody);
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
if (res.writableEnded)
|
|
80
|
+
return;
|
|
81
|
+
sendError(res, 400, 'invalid_body', 'Request body must be valid JSON');
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const validation = validateDisableRequest(body);
|
|
85
|
+
if (!validation.ok) {
|
|
86
|
+
sendError(res, 400, 'validation_error', validation.reason);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
const result = await model.deactivateActivation(activationId);
|
|
91
|
+
if (result.ok) {
|
|
92
|
+
sendSuccess(res, { activationId, status: 'inactive' });
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
sendError(res, 409, 'deactivate_failed', result.reason, { nextAction: result.nextAction });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (err) {
|
|
99
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
100
|
+
sendError(res, 500, 'deactivate_error', message, { nextAction: 'Check server logs. The activation state has not been changed.' });
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
sendNotFound(res, `Route /api/v1/activations${subPath} not found`);
|
|
105
|
+
}
|
|
106
|
+
export function disposeActivationsModels() {
|
|
107
|
+
for (const model of models.values()) {
|
|
108
|
+
model.dispose();
|
|
109
|
+
}
|
|
110
|
+
models.clear();
|
|
111
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApprovalsGroupedConsoleModel } from '../models/ApprovalsGroupedConsoleModel.js';
|
|
2
|
+
import { sendSuccess, sendError, sendNotFound } from '../utils/response.js';
|
|
3
|
+
const models = new Map();
|
|
4
|
+
function getModel(workspaceDir) {
|
|
5
|
+
let model = models.get(workspaceDir);
|
|
6
|
+
if (!model) {
|
|
7
|
+
model = new ApprovalsGroupedConsoleModel(workspaceDir);
|
|
8
|
+
models.set(workspaceDir, model);
|
|
9
|
+
}
|
|
10
|
+
return model;
|
|
11
|
+
}
|
|
12
|
+
export async function handleApprovalsGroupedRoute(req, res, workspaceDir) {
|
|
13
|
+
if (req.method !== 'GET') {
|
|
14
|
+
sendNotFound(res, 'Route /api/v1/approvals/grouped not found');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const model = getModel(workspaceDir);
|
|
18
|
+
try {
|
|
19
|
+
const result = await model.getApprovalsGrouped();
|
|
20
|
+
sendSuccess(res, result);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
24
|
+
sendError(res, 500, 'approvals_grouped_error', message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function disposeApprovalsGroupedModels() {
|
|
28
|
+
for (const model of models.values()) {
|
|
29
|
+
model.dispose();
|
|
30
|
+
}
|
|
31
|
+
models.clear();
|
|
32
|
+
}
|
|
@@ -77,7 +77,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
77
77
|
// GET /api/v1/approvals/:id - detail
|
|
78
78
|
const detailMatch = /^[/]([^/]+)$/.exec(subPath);
|
|
79
79
|
if (req.method === 'GET' && detailMatch) {
|
|
80
|
-
|
|
80
|
+
let approvalId;
|
|
81
|
+
try {
|
|
82
|
+
approvalId = decodeURIComponent(detailMatch[1]);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
81
88
|
try {
|
|
82
89
|
const detail = await model.getApprovalDetail(approvalId);
|
|
83
90
|
if (!detail) {
|
|
@@ -94,7 +101,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
94
101
|
// POST /api/v1/approvals/:id/approve
|
|
95
102
|
const approveMatch = /^[/]([^/]+)[/]approve$/.exec(subPath);
|
|
96
103
|
if (req.method === 'POST' && approveMatch) {
|
|
97
|
-
|
|
104
|
+
let approvalId;
|
|
105
|
+
try {
|
|
106
|
+
approvalId = decodeURIComponent(approveMatch[1]);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
98
112
|
try {
|
|
99
113
|
const body = await readBody(req);
|
|
100
114
|
const parsed = parseJsonBody(body, res);
|
|
@@ -113,12 +127,15 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
113
127
|
else if (result.error === 'unsupported_channel') {
|
|
114
128
|
sendError(res, 403, 'unsupported_channel', `Cannot approve unsupported channel. Only MVP proven channels (${MVP_CHANNEL_LIST}) can be approved.`);
|
|
115
129
|
}
|
|
130
|
+
else if (result.error === 'activation_failed') {
|
|
131
|
+
sendError(res, 500, 'activation_failed', `Approval was ${result.approvalRolledBack ? 'rolled back to pending' : 'approved but activation failed'}. Reason: ${result.reason}`);
|
|
132
|
+
}
|
|
116
133
|
else {
|
|
117
134
|
sendError(res, 409, 'conflict', 'Approval already decided: ' + (result.status ?? 'unknown'));
|
|
118
135
|
}
|
|
119
136
|
return;
|
|
120
137
|
}
|
|
121
|
-
sendSuccess(res, {
|
|
138
|
+
sendSuccess(res, { ...result.record, activation: result.activation });
|
|
122
139
|
}
|
|
123
140
|
catch (err) {
|
|
124
141
|
const message = getErrorMessage(err);
|
|
@@ -134,7 +151,14 @@ export async function handleApprovalsRoute(req, res, workspaceDir, subPath) {
|
|
|
134
151
|
// POST /api/v1/approvals/:id/reject
|
|
135
152
|
const rejectMatch = /^[/]([^/]+)[/]reject$/.exec(subPath);
|
|
136
153
|
if (req.method === 'POST' && rejectMatch) {
|
|
137
|
-
|
|
154
|
+
let approvalId;
|
|
155
|
+
try {
|
|
156
|
+
approvalId = decodeURIComponent(rejectMatch[1]);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
sendError(res, 400, 'invalid_id', 'Approval ID contains invalid URI encoding');
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
138
162
|
try {
|
|
139
163
|
const body = await readBody(req);
|
|
140
164
|
const parsed = parseJsonBody(body, res);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Config API Routes — PRI-309
|
|
3
|
+
*
|
|
4
|
+
* Console backend APIs for the Control Center:
|
|
5
|
+
* - GET /api/v1/config/summary — redacted config summary
|
|
6
|
+
* - GET /api/v1/config/catalog — available runtime/model catalog
|
|
7
|
+
* - PATCH /api/v1/config/agents/:name/binding — update agent runtime binding
|
|
8
|
+
* - GET /api/v1/config/readiness/:name — readiness test for agent
|
|
9
|
+
*
|
|
10
|
+
* Security:
|
|
11
|
+
* - Never returns raw provider objects, tokens, API keys, or env values
|
|
12
|
+
* - Validates before write, rejects malformed existing config
|
|
13
|
+
* - Rejects payloads with secret-like fields
|
|
14
|
+
*
|
|
15
|
+
* ERR entries:
|
|
16
|
+
* - ERR-001/ERR-005: No `as` bypasses on untrusted input
|
|
17
|
+
* - ERR-002: Graceful degradation includes reason
|
|
18
|
+
* - ERR-009/ERR-010: Required fields fail loud
|
|
19
|
+
* - ERR-013: Object.hasOwn() for untrusted keys
|
|
20
|
+
* - ERR-014/ERR-016/ERR-017: Safe serialization for previews
|
|
21
|
+
* - ERR-045: ANY-segment redaction for sensitive keys
|
|
22
|
+
*/
|
|
23
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
24
|
+
export declare function handleConfigRoute(req: IncomingMessage, res: ServerResponse, ctx: {
|
|
25
|
+
workspaceDir: string;
|
|
26
|
+
subPath: string;
|
|
27
|
+
}): Promise<void>;
|