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,213 @@
|
|
|
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 { sendSuccess, sendError, sendNotFound, sendMethodNotAllowed, sendBadRequest } from '../utils/response.js';
|
|
24
|
+
import { getConfigSummary, getConfigCatalog, updateAgentBinding, updateDefaultRuntime, checkReadiness, getPrinciplesOutputLanguage, updatePrinciplesOutputLanguage, } from '../config/pd-config-store.js';
|
|
25
|
+
// ── Constants ────────────────────────────────────────────────────────────────
|
|
26
|
+
const MAX_BODY_SIZE = 1024 * 64; // 64 KB — generous for config binding updates
|
|
27
|
+
// ── Request Body Reader ──────────────────────────────────────────────────────
|
|
28
|
+
function readBody(req) {
|
|
29
|
+
return new Promise((resolve, reject) => {
|
|
30
|
+
const chunks = [];
|
|
31
|
+
let totalSize = 0;
|
|
32
|
+
req.on('data', (chunk) => {
|
|
33
|
+
totalSize += chunk.length;
|
|
34
|
+
if (totalSize > MAX_BODY_SIZE) {
|
|
35
|
+
reject(new Error('Request body exceeds maximum allowed size'));
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
chunks.push(chunk);
|
|
39
|
+
});
|
|
40
|
+
req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
|
|
41
|
+
req.on('error', reject);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
function safeParseBody(text) {
|
|
45
|
+
try {
|
|
46
|
+
return JSON.parse(text);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// ── Route Handler ────────────────────────────────────────────────────────────
|
|
53
|
+
export async function handleConfigRoute(req, res, ctx) {
|
|
54
|
+
const { workspaceDir, subPath } = ctx;
|
|
55
|
+
const method = req.method ?? 'GET';
|
|
56
|
+
// GET /summary
|
|
57
|
+
if (subPath === '/summary') {
|
|
58
|
+
if (method !== 'GET') {
|
|
59
|
+
sendMethodNotAllowed(res);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const { summary, errors } = getConfigSummary(workspaceDir);
|
|
63
|
+
sendSuccess(res, { ...summary, ...(errors ? { errors } : {}) });
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
// GET /catalog
|
|
67
|
+
if (subPath === '/catalog') {
|
|
68
|
+
if (method !== 'GET') {
|
|
69
|
+
sendMethodNotAllowed(res);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const catalog = getConfigCatalog(workspaceDir);
|
|
73
|
+
sendSuccess(res, catalog);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// PATCH /default-runtime
|
|
77
|
+
if (subPath === '/default-runtime') {
|
|
78
|
+
if (method !== 'PATCH') {
|
|
79
|
+
sendMethodNotAllowed(res);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let bodyText;
|
|
83
|
+
try {
|
|
84
|
+
bodyText = await readBody(req);
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
sendBadRequest(res, 'Request body exceeds maximum allowed size');
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const payload = safeParseBody(bodyText);
|
|
91
|
+
if (payload === null) {
|
|
92
|
+
sendBadRequest(res, 'Invalid JSON body');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const result = updateDefaultRuntime(workspaceDir, payload);
|
|
96
|
+
if (!result.ok) {
|
|
97
|
+
sendError(res, result.statusCode, result.error, result.message);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
sendSuccess(res, { defaultRuntime: result.defaultRuntime });
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
// PATCH /agents/:agentName/binding
|
|
104
|
+
const agentBindingMatch = /^\/agents\/([^/]+)\/binding$/.exec(subPath);
|
|
105
|
+
if (agentBindingMatch) {
|
|
106
|
+
if (method !== 'PATCH') {
|
|
107
|
+
sendMethodNotAllowed(res);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
let agentName;
|
|
111
|
+
try {
|
|
112
|
+
agentName = decodeURIComponent(agentBindingMatch[1] ?? '');
|
|
113
|
+
}
|
|
114
|
+
catch {
|
|
115
|
+
sendBadRequest(res, 'Invalid agent name encoding');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
let bodyText;
|
|
119
|
+
try {
|
|
120
|
+
bodyText = await readBody(req);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
sendBadRequest(res, 'Request body exceeds maximum allowed size');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const payload = safeParseBody(bodyText);
|
|
127
|
+
if (payload === null) {
|
|
128
|
+
sendBadRequest(res, 'Invalid JSON body');
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const result = updateAgentBinding(workspaceDir, agentName, payload);
|
|
132
|
+
if (!result.ok) {
|
|
133
|
+
sendError(res, result.statusCode, result.error, result.message);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
sendSuccess(res, {
|
|
137
|
+
agent: result.agent,
|
|
138
|
+
runtimeProfile: result.runtimeProfile,
|
|
139
|
+
enabled: result.enabled,
|
|
140
|
+
});
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
// GET /readiness/:agentName
|
|
144
|
+
const readinessMatch = /^\/readiness\/([^/]+)$/.exec(subPath);
|
|
145
|
+
if (readinessMatch) {
|
|
146
|
+
if (method !== 'GET') {
|
|
147
|
+
sendMethodNotAllowed(res);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
let agentName;
|
|
151
|
+
try {
|
|
152
|
+
agentName = decodeURIComponent(readinessMatch[1] ?? '');
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
sendBadRequest(res, 'Invalid agent name encoding');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const result = checkReadiness(workspaceDir, agentName);
|
|
159
|
+
if (!result.ok) {
|
|
160
|
+
sendError(res, result.statusCode, result.error, result.message);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
sendSuccess(res, {
|
|
164
|
+
agent: result.agent,
|
|
165
|
+
readiness: result.readiness,
|
|
166
|
+
profileId: result.profileId,
|
|
167
|
+
profileLabel: result.profileLabel,
|
|
168
|
+
...(result.reason ? { reason: result.reason } : {}),
|
|
169
|
+
...(result.nextAction ? { nextAction: result.nextAction } : {}),
|
|
170
|
+
});
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// GET/PATCH /principles/output-language — PRI-332 P1-1
|
|
174
|
+
if (subPath === '/principles/output-language') {
|
|
175
|
+
if (method === 'GET') {
|
|
176
|
+
const result = getPrinciplesOutputLanguage(workspaceDir);
|
|
177
|
+
if (!result.ok) {
|
|
178
|
+
sendError(res, result.statusCode, result.error, result.message);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
sendSuccess(res, { outputLanguage: result.outputLanguage, source: result.source });
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
if (method === 'PATCH') {
|
|
185
|
+
let bodyText;
|
|
186
|
+
try {
|
|
187
|
+
bodyText = await readBody(req);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
sendBadRequest(res, 'Request body is too large or unreadable');
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const body = safeParseBody(bodyText);
|
|
194
|
+
const result = updatePrinciplesOutputLanguage(workspaceDir, body);
|
|
195
|
+
if (!result.ok) {
|
|
196
|
+
sendError(res, result.statusCode, result.error, result.message);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
// Re-read to confirm actual persisted state — fail loud if re-read fails (ERR-002)
|
|
200
|
+
const confirmResult = getPrinciplesOutputLanguage(workspaceDir);
|
|
201
|
+
if (!confirmResult.ok) {
|
|
202
|
+
sendError(res, confirmResult.statusCode, 'confirm_read_failed', `Write succeeded but re-read failed: ${confirmResult.message}`);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
sendSuccess(res, { outputLanguage: confirmResult.outputLanguage, source: confirmResult.source });
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
sendMethodNotAllowed(res);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
// 404 fallback
|
|
212
|
+
sendNotFound(res, `Route /api/v1/config${subPath} not found`);
|
|
213
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Evidence Chain API — exposes behavior evidence chain records for the Pain page.
|
|
3
|
+
*
|
|
4
|
+
* GET /api/v1/evidence-chain
|
|
5
|
+
* Returns evidence chain records from pain_events, tasks, candidates, and ledger.
|
|
6
|
+
*/
|
|
7
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
8
|
+
export declare function handleEvidenceChainRoute(req: IncomingMessage, res: ServerResponse, workspaceDir: string): Promise<void>;
|
|
9
|
+
export declare function disposeEvidenceChainModels(): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EvidenceChainConsoleModel } from '../models/EvidenceChainConsoleModel.js';
|
|
2
|
+
import { sendSuccess, sendError } 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 EvidenceChainConsoleModel(workspaceDir);
|
|
8
|
+
models.set(workspaceDir, model);
|
|
9
|
+
}
|
|
10
|
+
return model;
|
|
11
|
+
}
|
|
12
|
+
export async function handleEvidenceChainRoute(req, res, workspaceDir) {
|
|
13
|
+
if (req.method !== 'GET') {
|
|
14
|
+
sendError(res, 405, 'method_not_allowed', 'Only GET is allowed for this route');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const model = getModel(workspaceDir);
|
|
18
|
+
try {
|
|
19
|
+
const result = await model.getEvidenceChain();
|
|
20
|
+
sendSuccess(res, result);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
24
|
+
sendError(res, 500, 'evidence_chain_error', message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function disposeEvidenceChainModels() {
|
|
28
|
+
for (const model of models.values()) {
|
|
29
|
+
model.dispose();
|
|
30
|
+
}
|
|
31
|
+
models.clear();
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { GovernanceConsoleModel } from '../models/GovernanceConsoleModel.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 GovernanceConsoleModel(workspaceDir);
|
|
8
|
+
models.set(workspaceDir, model);
|
|
9
|
+
}
|
|
10
|
+
return model;
|
|
11
|
+
}
|
|
12
|
+
export async function handleGovernanceRoute(req, res, workspaceDir) {
|
|
13
|
+
if (req.method !== 'GET') {
|
|
14
|
+
sendNotFound(res, 'Route /api/v1/governance/queue not found');
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const model = getModel(workspaceDir);
|
|
18
|
+
try {
|
|
19
|
+
const result = await model.getGovernanceQueue();
|
|
20
|
+
sendSuccess(res, result);
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
24
|
+
sendError(res, 500, 'governance_queue_error', message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function disposeGovernanceModels() {
|
|
28
|
+
for (const model of models.values()) {
|
|
29
|
+
model.dispose();
|
|
30
|
+
}
|
|
31
|
+
models.clear();
|
|
32
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
2
|
+
export declare function handleLifecycleRoute(req: IncomingMessage, res: ServerResponse, workspaceDir: string, subPath: string): Promise<void>;
|
|
3
|
+
export declare function disposeLifecycleModels(): void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { LifecycleConsoleModel } from '../models/LifecycleConsoleModel.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 LifecycleConsoleModel(workspaceDir);
|
|
8
|
+
models.set(workspaceDir, model);
|
|
9
|
+
}
|
|
10
|
+
return model;
|
|
11
|
+
}
|
|
12
|
+
/* eslint-disable @typescript-eslint/max-params */
|
|
13
|
+
export async function handleLifecycleRoute(req, res, workspaceDir, subPath) {
|
|
14
|
+
if (req.method !== 'GET') {
|
|
15
|
+
sendNotFound(res, `Route /api/v1/lifecycle${subPath} not found`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// GET /api/v1/lifecycle/principles/:principleId
|
|
19
|
+
const principleMatch = /^[/]principles[/]([^/]+)$/.exec(subPath);
|
|
20
|
+
if (principleMatch) {
|
|
21
|
+
let principleId;
|
|
22
|
+
try {
|
|
23
|
+
principleId = decodeURIComponent(principleMatch[1]);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
sendError(res, 400, 'invalid_encoding', 'Principle ID contains invalid percent encoding');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const model = getModel(workspaceDir);
|
|
30
|
+
try {
|
|
31
|
+
const result = model.getLifecycleMetrics(principleId);
|
|
32
|
+
if (!result) {
|
|
33
|
+
sendNotFound(res, `Principle "${principleId}" not found in lifecycle read model`);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
sendSuccess(res, result);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
40
|
+
sendError(res, 500, 'lifecycle_metrics_error', message);
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
sendNotFound(res, `Route /api/v1/lifecycle${subPath} not found`);
|
|
45
|
+
}
|
|
46
|
+
export function disposeLifecycleModels() {
|
|
47
|
+
models.clear();
|
|
48
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as fs from 'fs';
|
|
1
3
|
import { PrinciplesConsoleModel } from '../models/PrinciplesConsoleModel.js';
|
|
2
4
|
import { sendSuccess, sendError, sendNotFound } from '../utils/response.js';
|
|
3
5
|
const models = new Map();
|
|
@@ -9,6 +11,65 @@ function getModel(workspaceDir) {
|
|
|
9
11
|
}
|
|
10
12
|
return model;
|
|
11
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Safely read an own string property from an unknown object.
|
|
16
|
+
* Returns the string value if the key exists and the value is a string,
|
|
17
|
+
* otherwise undefined. Uses Object.getOwnPropertyDescriptor to avoid
|
|
18
|
+
* any `as` cast on the row (EP-01 Rule 2).
|
|
19
|
+
*/
|
|
20
|
+
function getOwnStringField(obj, key) {
|
|
21
|
+
if (typeof obj !== 'object' || obj === null)
|
|
22
|
+
return undefined;
|
|
23
|
+
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
24
|
+
if (desc === undefined)
|
|
25
|
+
return undefined;
|
|
26
|
+
return typeof desc.value === 'string' ? desc.value : undefined;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Query the SQLite state.db for principle IDs that have been decided
|
|
30
|
+
* (approved or rejected) via the approval queue.
|
|
31
|
+
*
|
|
32
|
+
* Returns { ids, unavailableReason } — if the DB is not available or the
|
|
33
|
+
* query fails, ids is empty and unavailableReason explains why, so the
|
|
34
|
+
* caller can surface this to the UI (ERR-002: no silent degradation).
|
|
35
|
+
*/
|
|
36
|
+
async function getDecidedPrincipleIds(workspaceDir) {
|
|
37
|
+
// Runtime V2 uses <workspace>/.pd/state.db (NOT .state/state.db)
|
|
38
|
+
const dbPath = path.join(workspaceDir, '.pd', 'state.db');
|
|
39
|
+
if (!fs.existsSync(dbPath)) {
|
|
40
|
+
return { ids: new Set(), unavailableReason: 'approval_db_not_found' };
|
|
41
|
+
}
|
|
42
|
+
let closeFn = null;
|
|
43
|
+
try {
|
|
44
|
+
const { SqliteConnection } = await import('@principles/core/runtime-v2');
|
|
45
|
+
const conn = new SqliteConnection({ workspaceDir, readonly: true });
|
|
46
|
+
closeFn = () => conn.close();
|
|
47
|
+
const db = conn.getDb();
|
|
48
|
+
// Join approvals with pi_artifacts to find decided principle IDs
|
|
49
|
+
const rows = db.prepare("SELECT DISTINCT a.source_principle_id " +
|
|
50
|
+
"FROM approvals ap " +
|
|
51
|
+
"JOIN pi_artifacts a ON a.artifact_id = ap.artifact_id " +
|
|
52
|
+
"WHERE ap.status IN ('approved', 'rejected') " +
|
|
53
|
+
"AND a.source_principle_id IS NOT NULL").all();
|
|
54
|
+
// EP-01 Rule 1: treat DB rows as unknown; validate before use
|
|
55
|
+
// EP-01 Rule 2: no `as` cast — use getOwnStringField instead
|
|
56
|
+
const ids = new Set();
|
|
57
|
+
for (const row of rows) {
|
|
58
|
+
const val = getOwnStringField(row, 'source_principle_id');
|
|
59
|
+
if (val !== undefined) {
|
|
60
|
+
ids.add(val);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return { ids };
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
67
|
+
return { ids: new Set(), unavailableReason: `approval_query_failed: ${message}` };
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
closeFn?.();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
12
73
|
export async function handlePrinciplesRoute({ req, res, workspaceDir, subPath, }) {
|
|
13
74
|
if (req.method !== 'GET') {
|
|
14
75
|
sendNotFound(res, `Route /api/principles${subPath} not found`);
|
|
@@ -17,7 +78,19 @@ export async function handlePrinciplesRoute({ req, res, workspaceDir, subPath, }
|
|
|
17
78
|
const model = getModel(workspaceDir);
|
|
18
79
|
if (subPath === '' || subPath === '/') {
|
|
19
80
|
try {
|
|
20
|
-
|
|
81
|
+
// Parse query string for filter parameter
|
|
82
|
+
const urlParts = (req.url ?? '').split('?');
|
|
83
|
+
const queryString = urlParts[1] ?? '';
|
|
84
|
+
const params = new URLSearchParams(queryString);
|
|
85
|
+
const filterRaw = params.get('filter');
|
|
86
|
+
const VALID_FILTERS = new Set(['all', 'actionable']);
|
|
87
|
+
const filter = (filterRaw !== null && VALID_FILTERS.has(filterRaw) ? filterRaw : 'actionable');
|
|
88
|
+
const decidedResult = await getDecidedPrincipleIds(workspaceDir);
|
|
89
|
+
const result = await model.listPrinciples(filter, decidedResult.ids);
|
|
90
|
+
// Surface approval cross-check unavailability to the UI (ERR-002)
|
|
91
|
+
if (decidedResult.unavailableReason) {
|
|
92
|
+
result.approvalCrossCheckUnavailable = decidedResult.unavailableReason;
|
|
93
|
+
}
|
|
21
94
|
sendSuccess(res, result);
|
|
22
95
|
}
|
|
23
96
|
catch (err) {
|
|
@@ -56,7 +56,14 @@ export function createWorkspacesRoutes(configStore, workspaceService) {
|
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
58
|
const [, wsName, rest] = nameMatch;
|
|
59
|
-
|
|
59
|
+
let decodedWsName;
|
|
60
|
+
try {
|
|
61
|
+
decodedWsName = decodeURIComponent(wsName);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
sendError(res, 400, 'invalid_name', 'Workspace name contains invalid URI encoding');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
60
67
|
if (req.method === 'GET' && (rest === '' || rest === '/')) {
|
|
61
68
|
const entry = configStore.getWorkspace(decodedWsName);
|
|
62
69
|
if (!entry) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ServerResponse } from 'node:http';
|
|
2
2
|
export declare function sendJson(res: ServerResponse, statusCode: number, payload: unknown): void;
|
|
3
3
|
export declare function sendSuccess<T>(res: ServerResponse, data: T): void;
|
|
4
|
-
export declare function sendError(res: ServerResponse, statusCode: number, error: string, message?: string): void;
|
|
4
|
+
export declare function sendError(res: ServerResponse, statusCode: number, error: string, message?: string, extras?: Record<string, unknown>): void;
|
|
5
5
|
export declare function sendNotFound(res: ServerResponse, message?: string): void;
|
|
6
6
|
export declare function sendUnauthorized(res: ServerResponse, message?: string): void;
|
|
7
7
|
export declare function sendMethodNotAllowed(res: ServerResponse): void;
|
|
@@ -14,8 +14,12 @@ export function sendSuccess(res, data) {
|
|
|
14
14
|
sendJson(res, 200, { success: true, data });
|
|
15
15
|
}
|
|
16
16
|
/* eslint-disable @typescript-eslint/max-params */
|
|
17
|
-
export function sendError(res, statusCode, error, message) {
|
|
18
|
-
|
|
17
|
+
export function sendError(res, statusCode, error, message, extras) {
|
|
18
|
+
const payload = { success: false, error, message: message ?? error };
|
|
19
|
+
if (extras) {
|
|
20
|
+
Object.assign(payload, extras);
|
|
21
|
+
}
|
|
22
|
+
sendJson(res, statusCode, payload);
|
|
19
23
|
}
|
|
20
24
|
export function sendNotFound(res, message = 'Not found') {
|
|
21
25
|
sendError(res, 404, 'not_found', message);
|