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
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import Database from 'better-sqlite3';
|
|
4
|
-
import { RuntimeStateManager } from '@principles/core/runtime-v2';
|
|
5
|
-
import { sendSuccess, sendError, sendNotFound, sendBadRequest } from '../utils/response.js';
|
|
6
|
-
const AGENT_REGISTRY = [
|
|
7
|
-
{
|
|
8
|
-
id: 'evolution-worker',
|
|
9
|
-
name: 'Evolution Worker',
|
|
10
|
-
nameZh: '进化工作者',
|
|
11
|
-
description: '总调度引擎,驱动整个进化管道的心跳服务',
|
|
12
|
-
descriptionZh: '总调度引擎,驱动整个进化管道的心跳服务',
|
|
13
|
-
icon: 'Cpu',
|
|
14
|
-
category: 'scheduler',
|
|
15
|
-
taskKind: null,
|
|
16
|
-
prompt: 'N/A - Heartbeat-driven scheduler, no LLM prompt',
|
|
17
|
-
tools: ['processCompilationBackfill', 'processEvolutionQueue', 'processDetectionQueue', 'sweepExpiredWorkflows', 'runWorkflowWatchdog'],
|
|
18
|
-
subAgents: ['correction-observer'],
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
id: 'diagnostician',
|
|
22
|
-
name: 'Diagnostician',
|
|
23
|
-
nameZh: '诊断者',
|
|
24
|
-
description: 'Uses 5-Whys method for root cause analysis, extracting principles from pain signals',
|
|
25
|
-
descriptionZh: '使用 5-Whys 方法进行根因分析,从痛苦信号中提取原则',
|
|
26
|
-
icon: 'Stethoscope',
|
|
27
|
-
category: 'analyzer',
|
|
28
|
-
taskKind: 'diagnostician',
|
|
29
|
-
prompt: '## Diagnostic Protocol (5 Whys)\nPhase 1 - Evidence Gathering\nPhase 2 - Causal Chain (5 Whys)\nPhase 3 - Root Cause Classification\nPhase 4 - Principle Extraction',
|
|
30
|
-
tools: ['PainSignalBridge', 'DiagnosticianRunner', 'SqliteContextAssembler'],
|
|
31
|
-
subAgents: [],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
id: 'correction-observer',
|
|
35
|
-
name: 'Correction Observer',
|
|
36
|
-
nameZh: '纠正观察者',
|
|
37
|
-
description: 'Optimizes the correction keyword store by analyzing hit rates and false positive rates',
|
|
38
|
-
descriptionZh: '通过分析命中率和误报率来优化纠正关键词库',
|
|
39
|
-
icon: 'SearchCheck',
|
|
40
|
-
category: 'optimizer',
|
|
41
|
-
taskKind: 'keyword_optimization',
|
|
42
|
-
prompt: 'You are a correction keyword optimizer.\nAnalyze the current correction keyword store and recent user messages.\nRecommend ADD/UPDATE/REMOVE actions to improve correction cue accuracy.\nOutput: {"updated": boolean, "updates": {...}, "fpTerms": [...], "summary": string}',
|
|
43
|
-
tools: ['KeywordOptimizationService', 'CorrectionCueLearner'],
|
|
44
|
-
subAgents: [],
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
id: 'pain-diagnostic-gate',
|
|
48
|
-
name: 'Pain Diagnostic Gate',
|
|
49
|
-
nameZh: '痛苦诊断门控',
|
|
50
|
-
description: 'Gatekeeper that decides which pain signals warrant diagnostic analysis based on source, score, and GFI',
|
|
51
|
-
descriptionZh: '守门人,基于来源、分数和 GFI 决定哪些痛苦信号值得诊断分析',
|
|
52
|
-
icon: 'ShieldCheck',
|
|
53
|
-
category: 'gate',
|
|
54
|
-
taskKind: null,
|
|
55
|
-
prompt: 'N/A - Rule-based gate, no LLM prompt. Evaluates: source type, score thresholds (40-70 depending on source), GFI, consecutive errors, cooldown.',
|
|
56
|
-
tools: ['evaluatePainDiagnosticGate'],
|
|
57
|
-
subAgents: [],
|
|
58
|
-
},
|
|
59
|
-
];
|
|
60
|
-
const WORKER_STALE_THRESHOLD_MS = 30 * 60 * 1000;
|
|
61
|
-
function mapTaskStatusToAgentStatus(taskStatus) {
|
|
62
|
-
switch (taskStatus) {
|
|
63
|
-
case 'pending':
|
|
64
|
-
case 'leased':
|
|
65
|
-
return 'running';
|
|
66
|
-
case 'succeeded':
|
|
67
|
-
return 'idle';
|
|
68
|
-
case 'failed':
|
|
69
|
-
return 'failed';
|
|
70
|
-
case 'retry_wait':
|
|
71
|
-
return 'cooldown';
|
|
72
|
-
default:
|
|
73
|
-
return 'unknown';
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
function mapTaskStatusToLastStatus(taskStatus) {
|
|
77
|
-
switch (taskStatus) {
|
|
78
|
-
case 'succeeded':
|
|
79
|
-
return 'succeeded';
|
|
80
|
-
case 'failed':
|
|
81
|
-
return 'failed';
|
|
82
|
-
case 'pending':
|
|
83
|
-
return 'pending';
|
|
84
|
-
case 'leased':
|
|
85
|
-
return 'leased';
|
|
86
|
-
default:
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
function formatCooldownRemaining(leaseExpiresAt) {
|
|
91
|
-
if (!leaseExpiresAt)
|
|
92
|
-
return null;
|
|
93
|
-
const remaining = new Date(leaseExpiresAt).getTime() - Date.now();
|
|
94
|
-
if (remaining <= 0)
|
|
95
|
-
return null;
|
|
96
|
-
const totalSeconds = Math.floor(remaining / 1000);
|
|
97
|
-
const hours = Math.floor(totalSeconds / 3600);
|
|
98
|
-
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
|
99
|
-
const seconds = totalSeconds % 60;
|
|
100
|
-
const parts = [];
|
|
101
|
-
if (hours > 0)
|
|
102
|
-
parts.push(`${hours}h`);
|
|
103
|
-
if (minutes > 0)
|
|
104
|
-
parts.push(`${minutes}m`);
|
|
105
|
-
if (seconds > 0 || parts.length === 0)
|
|
106
|
-
parts.push(`${seconds}s`);
|
|
107
|
-
return parts.join(' ');
|
|
108
|
-
}
|
|
109
|
-
const models = new Map();
|
|
110
|
-
class AgentConsoleModel {
|
|
111
|
-
workspaceDir;
|
|
112
|
-
stateManager = null;
|
|
113
|
-
initPromise = null;
|
|
114
|
-
stageEventsCache = new Map();
|
|
115
|
-
constructor(workspaceDir) {
|
|
116
|
-
this.workspaceDir = workspaceDir;
|
|
117
|
-
}
|
|
118
|
-
async ensureInitialized() {
|
|
119
|
-
if (this.stateManager)
|
|
120
|
-
return this.stateManager;
|
|
121
|
-
if (this.initPromise) {
|
|
122
|
-
try {
|
|
123
|
-
await this.initPromise;
|
|
124
|
-
if (this.stateManager)
|
|
125
|
-
return this.stateManager;
|
|
126
|
-
throw new Error('initPromise resolved but stateManager is null');
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
this.initPromise = null;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
const manager = new RuntimeStateManager({ workspaceDir: this.workspaceDir });
|
|
133
|
-
this.initPromise = manager.initialize();
|
|
134
|
-
try {
|
|
135
|
-
await this.initPromise;
|
|
136
|
-
this.stateManager = manager;
|
|
137
|
-
return manager;
|
|
138
|
-
}
|
|
139
|
-
catch {
|
|
140
|
-
this.stateManager = null;
|
|
141
|
-
this.initPromise = null;
|
|
142
|
-
throw new Error('Failed to initialize RuntimeStateManager');
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
readWorkerStatus() {
|
|
146
|
-
const statusPath = path.join(this.workspaceDir, '.state', 'worker-status.json');
|
|
147
|
-
if (!fs.existsSync(statusPath))
|
|
148
|
-
return null;
|
|
149
|
-
try {
|
|
150
|
-
const raw = fs.readFileSync(statusPath, 'utf8');
|
|
151
|
-
return JSON.parse(raw);
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
readWorkflowData() {
|
|
158
|
-
const dbPath = path.join(this.workspaceDir, '.state', 'subagent_workflows.db');
|
|
159
|
-
if (!fs.existsSync(dbPath))
|
|
160
|
-
return [];
|
|
161
|
-
let db = null;
|
|
162
|
-
try {
|
|
163
|
-
db = new Database(dbPath, { readonly: true });
|
|
164
|
-
const rows = db.prepare(`
|
|
165
|
-
SELECT workflow_id, workflow_type, state, created_at, updated_at, duration_ms
|
|
166
|
-
FROM subagent_workflows
|
|
167
|
-
ORDER BY updated_at DESC
|
|
168
|
-
LIMIT 50
|
|
169
|
-
`).all();
|
|
170
|
-
return rows;
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
return [];
|
|
174
|
-
}
|
|
175
|
-
finally {
|
|
176
|
-
db?.close();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
getEvolutionWorkerStatus() {
|
|
180
|
-
const report = this.readWorkerStatus();
|
|
181
|
-
if (!report)
|
|
182
|
-
return { status: 'unknown', lastRunAt: null };
|
|
183
|
-
const lastRun = new Date(report.timestamp).getTime();
|
|
184
|
-
const isFresh = Date.now() - lastRun < WORKER_STALE_THRESHOLD_MS;
|
|
185
|
-
return {
|
|
186
|
-
status: isFresh ? 'running' : 'idle',
|
|
187
|
-
lastRunAt: report.timestamp,
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
getStageEvents(workflowId) {
|
|
191
|
-
const cached = this.stageEventsCache.get(workflowId);
|
|
192
|
-
if (cached)
|
|
193
|
-
return cached;
|
|
194
|
-
return {};
|
|
195
|
-
}
|
|
196
|
-
refreshStageEvents() {
|
|
197
|
-
const dbPath = path.join(this.workspaceDir, '.state', 'subagent_workflows.db');
|
|
198
|
-
if (!fs.existsSync(dbPath))
|
|
199
|
-
return;
|
|
200
|
-
let db = null;
|
|
201
|
-
try {
|
|
202
|
-
db = new Database(dbPath, { readonly: true });
|
|
203
|
-
const events = db.prepare(`
|
|
204
|
-
SELECT workflow_id, event_type, payload_json
|
|
205
|
-
FROM subagent_workflow_events
|
|
206
|
-
WHERE event_type LIKE 'trinity_%'
|
|
207
|
-
ORDER BY created_at DESC
|
|
208
|
-
`).all();
|
|
209
|
-
const grouped = new Map();
|
|
210
|
-
for (const ev of events) {
|
|
211
|
-
const states = grouped.get(ev.workflow_id) || {};
|
|
212
|
-
const stage = ev.event_type.replace('trinity_', '').replace('_start', '').replace('_complete', '').replace('_failed', '');
|
|
213
|
-
if (!states[stage]) {
|
|
214
|
-
if (ev.event_type.endsWith('_failed'))
|
|
215
|
-
states[stage] = 'failed';
|
|
216
|
-
else if (ev.event_type.endsWith('_complete'))
|
|
217
|
-
states[stage] = 'completed';
|
|
218
|
-
else if (ev.event_type.endsWith('_start'))
|
|
219
|
-
states[stage] = 'started';
|
|
220
|
-
}
|
|
221
|
-
grouped.set(ev.workflow_id, states);
|
|
222
|
-
}
|
|
223
|
-
this.stageEventsCache = grouped;
|
|
224
|
-
}
|
|
225
|
-
catch {
|
|
226
|
-
this.stageEventsCache.clear();
|
|
227
|
-
}
|
|
228
|
-
finally {
|
|
229
|
-
db?.close();
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
async buildAgentInfo(agent, allTasks, _workflows) {
|
|
233
|
-
let status = 'unknown';
|
|
234
|
-
let lastRunAt = null;
|
|
235
|
-
let lastStatus = null;
|
|
236
|
-
let recentTaskCount = 0;
|
|
237
|
-
let failedTaskCount = 0;
|
|
238
|
-
let cooldownRemaining = null;
|
|
239
|
-
if (agent.id === 'evolution-worker') {
|
|
240
|
-
const workerStatus = this.getEvolutionWorkerStatus();
|
|
241
|
-
({ status, lastRunAt } = workerStatus);
|
|
242
|
-
const queueTasks = allTasks.filter(t => t.taskKind === 'diagnostician' || t.taskKind === 'keyword_optimization');
|
|
243
|
-
recentTaskCount = queueTasks.length;
|
|
244
|
-
failedTaskCount = queueTasks.filter(t => t.status === 'failed').length;
|
|
245
|
-
if (queueTasks.length > 0) {
|
|
246
|
-
const latest = queueTasks.reduce((a, b) => (a.updatedAt > b.updatedAt ? a : b));
|
|
247
|
-
lastStatus = mapTaskStatusToLastStatus(latest.status);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else if (agent.taskKind) {
|
|
251
|
-
const agentTasks = allTasks.filter(t => t.taskKind === agent.taskKind);
|
|
252
|
-
recentTaskCount = agentTasks.length;
|
|
253
|
-
failedTaskCount = agentTasks.filter(t => t.status === 'failed').length;
|
|
254
|
-
if (agentTasks.length > 0) {
|
|
255
|
-
const sorted = [...agentTasks].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
256
|
-
const [latest] = sorted;
|
|
257
|
-
status = mapTaskStatusToAgentStatus(latest.status);
|
|
258
|
-
lastRunAt = latest.updatedAt;
|
|
259
|
-
lastStatus = mapTaskStatusToLastStatus(latest.status);
|
|
260
|
-
if (latest.status === 'retry_wait') {
|
|
261
|
-
cooldownRemaining = formatCooldownRemaining(latest.leaseExpiresAt);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
status = 'idle';
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
else if (agent.id === 'pain-diagnostic-gate') {
|
|
269
|
-
status = 'idle';
|
|
270
|
-
}
|
|
271
|
-
return {
|
|
272
|
-
id: agent.id,
|
|
273
|
-
name: agent.name,
|
|
274
|
-
nameZh: agent.nameZh,
|
|
275
|
-
description: agent.description,
|
|
276
|
-
descriptionZh: agent.descriptionZh,
|
|
277
|
-
icon: agent.icon,
|
|
278
|
-
category: agent.category,
|
|
279
|
-
status,
|
|
280
|
-
lastRunAt,
|
|
281
|
-
lastStatus,
|
|
282
|
-
recentTaskCount,
|
|
283
|
-
failedTaskCount,
|
|
284
|
-
subAgents: agent.subAgents,
|
|
285
|
-
prompt: agent.prompt,
|
|
286
|
-
tools: agent.tools,
|
|
287
|
-
taskKind: agent.taskKind,
|
|
288
|
-
cooldownRemaining,
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
async listAgents() {
|
|
292
|
-
const mgr = await this.ensureInitialized();
|
|
293
|
-
const allTasks = await mgr.listTasks();
|
|
294
|
-
const workflows = this.readWorkflowData();
|
|
295
|
-
this.refreshStageEvents();
|
|
296
|
-
const results = [];
|
|
297
|
-
for (const agent of AGENT_REGISTRY) {
|
|
298
|
-
results.push(await this.buildAgentInfo(agent, allTasks, workflows));
|
|
299
|
-
}
|
|
300
|
-
return results;
|
|
301
|
-
}
|
|
302
|
-
async getAgentDetail(agentId) {
|
|
303
|
-
const agent = AGENT_REGISTRY.find(a => a.id === agentId);
|
|
304
|
-
if (!agent)
|
|
305
|
-
return null;
|
|
306
|
-
const mgr = await this.ensureInitialized();
|
|
307
|
-
const allTasks = await mgr.listTasks();
|
|
308
|
-
const workflows = this.readWorkflowData();
|
|
309
|
-
this.refreshStageEvents();
|
|
310
|
-
const info = await this.buildAgentInfo(agent, allTasks, workflows);
|
|
311
|
-
let agentTasks = agent.taskKind
|
|
312
|
-
? allTasks.filter(t => t.taskKind === agent.taskKind)
|
|
313
|
-
: [];
|
|
314
|
-
agentTasks = [...agentTasks].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
315
|
-
const recentTasks = agentTasks.slice(0, 20).map(t => ({
|
|
316
|
-
taskId: t.taskId,
|
|
317
|
-
status: t.status,
|
|
318
|
-
createdAt: t.createdAt,
|
|
319
|
-
updatedAt: t.updatedAt,
|
|
320
|
-
lastError: t.lastError ?? null,
|
|
321
|
-
attemptCount: t.attemptCount,
|
|
322
|
-
}));
|
|
323
|
-
return { ...info, recentTasks };
|
|
324
|
-
}
|
|
325
|
-
async getAgentTasks(agentId) {
|
|
326
|
-
const agent = AGENT_REGISTRY.find(a => a.id === agentId);
|
|
327
|
-
if (!agent)
|
|
328
|
-
return null;
|
|
329
|
-
if (!agent.taskKind)
|
|
330
|
-
return { tasks: [] };
|
|
331
|
-
const mgr = await this.ensureInitialized();
|
|
332
|
-
const agentTasks = await mgr.listTasks({ taskKind: agent.taskKind });
|
|
333
|
-
const sorted = [...agentTasks].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
334
|
-
return {
|
|
335
|
-
tasks: sorted.map(t => ({
|
|
336
|
-
taskId: t.taskId,
|
|
337
|
-
taskKind: t.taskKind,
|
|
338
|
-
status: t.status,
|
|
339
|
-
createdAt: t.createdAt,
|
|
340
|
-
updatedAt: t.updatedAt,
|
|
341
|
-
lastError: t.lastError ?? null,
|
|
342
|
-
attemptCount: t.attemptCount,
|
|
343
|
-
inputRef: t.inputRef ?? null,
|
|
344
|
-
resultRef: t.resultRef ?? null,
|
|
345
|
-
})),
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
dispose() {
|
|
349
|
-
if (this.stateManager) {
|
|
350
|
-
this.stateManager.close().catch((_e) => { });
|
|
351
|
-
this.stateManager = null;
|
|
352
|
-
}
|
|
353
|
-
this.initPromise = null;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
function getModel(workspaceDir) {
|
|
357
|
-
let model = models.get(workspaceDir);
|
|
358
|
-
if (!model) {
|
|
359
|
-
model = new AgentConsoleModel(workspaceDir);
|
|
360
|
-
models.set(workspaceDir, model);
|
|
361
|
-
}
|
|
362
|
-
return model;
|
|
363
|
-
}
|
|
364
|
-
/* eslint-disable @typescript-eslint/max-params */
|
|
365
|
-
export async function handleAgentsRoute(req, res, workspaceDir, subPath) {
|
|
366
|
-
if (req.method !== 'GET') {
|
|
367
|
-
sendNotFound(res, `Route /api/agents${subPath} not found`);
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
const model = getModel(workspaceDir);
|
|
371
|
-
if (subPath === '' || subPath === '/') {
|
|
372
|
-
try {
|
|
373
|
-
const result = await model.listAgents();
|
|
374
|
-
sendSuccess(res, result);
|
|
375
|
-
}
|
|
376
|
-
catch (err) {
|
|
377
|
-
sendError(res, 500, 'agents_list_error', err.message);
|
|
378
|
-
}
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
const tasksMatch = /^\/([^/]+)\/tasks\/?$/.exec(subPath);
|
|
382
|
-
if (tasksMatch) {
|
|
383
|
-
const agentId = (() => {
|
|
384
|
-
try {
|
|
385
|
-
return decodeURIComponent(tasksMatch[1]);
|
|
386
|
-
}
|
|
387
|
-
catch {
|
|
388
|
-
return null;
|
|
389
|
-
}
|
|
390
|
-
})();
|
|
391
|
-
if (!agentId) {
|
|
392
|
-
sendBadRequest(res, 'Invalid agent ID encoding');
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
try {
|
|
396
|
-
const result = await model.getAgentTasks(agentId);
|
|
397
|
-
if (!result) {
|
|
398
|
-
sendNotFound(res, `Agent '${agentId}' not found`);
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
sendSuccess(res, result);
|
|
402
|
-
}
|
|
403
|
-
catch (err) {
|
|
404
|
-
sendError(res, 500, 'agent_tasks_error', err.message);
|
|
405
|
-
}
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
const detailMatch = /^\/([^/]+)\/?$/.exec(subPath);
|
|
409
|
-
if (detailMatch) {
|
|
410
|
-
const agentId = (() => {
|
|
411
|
-
try {
|
|
412
|
-
return decodeURIComponent(detailMatch[1]);
|
|
413
|
-
}
|
|
414
|
-
catch {
|
|
415
|
-
return null;
|
|
416
|
-
}
|
|
417
|
-
})();
|
|
418
|
-
if (!agentId) {
|
|
419
|
-
sendBadRequest(res, 'Invalid agent ID encoding');
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
try {
|
|
423
|
-
const result = await model.getAgentDetail(agentId);
|
|
424
|
-
if (!result) {
|
|
425
|
-
sendNotFound(res, `Agent '${agentId}' not found`);
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
sendSuccess(res, result);
|
|
429
|
-
}
|
|
430
|
-
catch (err) {
|
|
431
|
-
sendError(res, 500, 'agent_detail_error', err.message);
|
|
432
|
-
}
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
sendNotFound(res, `Route /api/agents${subPath} not found`);
|
|
436
|
-
}
|
|
437
|
-
export function disposeAgentModels() {
|
|
438
|
-
for (const model of models.values()) {
|
|
439
|
-
model.dispose();
|
|
440
|
-
}
|
|
441
|
-
models.clear();
|
|
442
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
import type { WorkspaceService } from '../models/WorkspaceService.js';
|
|
3
|
-
export declare function createCentralRoutes(workspaceService: WorkspaceService): {
|
|
4
|
-
handleCentralRoute: (req: IncomingMessage, res: ServerResponse, subPath: string) => Promise<void>;
|
|
5
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { sendSuccess, sendError, sendNotFound } from '../utils/response.js';
|
|
2
|
-
export function createCentralRoutes(workspaceService) {
|
|
3
|
-
async function handleCentralRoute(req, res, subPath) {
|
|
4
|
-
if (req.method !== 'GET') {
|
|
5
|
-
sendNotFound(res, 'Method not allowed');
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
if (subPath === '/overview') {
|
|
9
|
-
try {
|
|
10
|
-
const overview = await workspaceService.getCentralOverview();
|
|
11
|
-
sendSuccess(res, overview);
|
|
12
|
-
}
|
|
13
|
-
catch (err) {
|
|
14
|
-
sendError(res, 500, 'central_overview_error', err.message);
|
|
15
|
-
}
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (subPath === '/health') {
|
|
19
|
-
try {
|
|
20
|
-
const health = await workspaceService.getCentralHealth();
|
|
21
|
-
sendSuccess(res, health);
|
|
22
|
-
}
|
|
23
|
-
catch (err) {
|
|
24
|
-
sendError(res, 500, 'central_health_error', err.message);
|
|
25
|
-
}
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
sendNotFound(res, `Route /api/central${subPath} not found`);
|
|
29
|
-
}
|
|
30
|
-
return { handleCentralRoute };
|
|
31
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
-
interface EventsRouteContext {
|
|
3
|
-
req: IncomingMessage;
|
|
4
|
-
res: ServerResponse;
|
|
5
|
-
workspaceDir: string;
|
|
6
|
-
subPath: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function handleEventsRoute(ctx: EventsRouteContext): Promise<void>;
|
|
9
|
-
export declare function disposeEventsModels(): void;
|
|
10
|
-
export {};
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import { EventLogReadModel } from '../models/EventLogReadModel.js';
|
|
3
|
-
import { sendSuccess, sendError, sendNotFound } from '../utils/response.js';
|
|
4
|
-
const MAX_PAGE_SIZE = 1000;
|
|
5
|
-
const MODEL_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
6
|
-
const models = new Map();
|
|
7
|
-
function getModel(workspaceDir) {
|
|
8
|
-
const stateDir = path.join(workspaceDir, '.state');
|
|
9
|
-
const cached = models.get(stateDir);
|
|
10
|
-
if (cached && Date.now() - cached.cachedAt < MODEL_CACHE_TTL_MS) {
|
|
11
|
-
return cached.model;
|
|
12
|
-
}
|
|
13
|
-
const model = new EventLogReadModel(stateDir);
|
|
14
|
-
models.set(stateDir, { model, cachedAt: Date.now() });
|
|
15
|
-
return model;
|
|
16
|
-
}
|
|
17
|
-
export async function handleEventsRoute(ctx) {
|
|
18
|
-
const { req, res, workspaceDir, subPath } = ctx;
|
|
19
|
-
const model = getModel(workspaceDir);
|
|
20
|
-
const parsedUrl = new URL(req.url || '', 'http://localhost');
|
|
21
|
-
const { searchParams } = parsedUrl;
|
|
22
|
-
// GET /api/events
|
|
23
|
-
if (subPath === '' || subPath === '/') {
|
|
24
|
-
if (req.method !== 'GET') {
|
|
25
|
-
sendError(res, 405, 'method_not_allowed', 'Only GET method is allowed');
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const types = searchParams.getAll('type');
|
|
29
|
-
const startDate = searchParams.get('startDate') || undefined;
|
|
30
|
-
const endDate = searchParams.get('endDate') || undefined;
|
|
31
|
-
const searchQuery = searchParams.get('q') || undefined;
|
|
32
|
-
const pageStr = searchParams.get('page');
|
|
33
|
-
const pageSizeStr = searchParams.get('pageSize');
|
|
34
|
-
const page = pageStr ? parseInt(pageStr, 10) : 1;
|
|
35
|
-
const pageSize = pageSizeStr ? Math.min(parseInt(pageSizeStr, 10), MAX_PAGE_SIZE) : 50;
|
|
36
|
-
try {
|
|
37
|
-
const result = await model.getEventsPaginated({
|
|
38
|
-
types: types.length > 0 ? types : undefined,
|
|
39
|
-
startDate,
|
|
40
|
-
endDate,
|
|
41
|
-
searchQuery,
|
|
42
|
-
page,
|
|
43
|
-
pageSize,
|
|
44
|
-
});
|
|
45
|
-
sendSuccess(res, result);
|
|
46
|
-
}
|
|
47
|
-
catch (err) {
|
|
48
|
-
sendError(res, 500, 'server_error', err.message);
|
|
49
|
-
}
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
// GET /api/events/grouped
|
|
53
|
-
if (subPath === '/grouped') {
|
|
54
|
-
if (req.method !== 'GET') {
|
|
55
|
-
sendError(res, 405, 'method_not_allowed', 'Only GET method is allowed');
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const startDate = searchParams.get('startDate') || undefined;
|
|
59
|
-
const endDate = searchParams.get('endDate') || undefined;
|
|
60
|
-
try {
|
|
61
|
-
const counts = await model.countEventsGroupedByType({ startDate, endDate });
|
|
62
|
-
sendSuccess(res, counts);
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
sendError(res, 500, 'server_error', err.message);
|
|
66
|
-
}
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
// GET /api/events/:id/related
|
|
70
|
-
if (subPath.startsWith('/') && subPath.endsWith('/related')) {
|
|
71
|
-
if (req.method !== 'GET') {
|
|
72
|
-
sendError(res, 405, 'method_not_allowed', 'Only GET method is allowed');
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const match = /\/([^/]+)\/related$/.exec(subPath);
|
|
76
|
-
if (!match) {
|
|
77
|
-
sendNotFound(res, 'Invalid event ID');
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const [, eventId] = match;
|
|
81
|
-
const maxDistanceStr = searchParams.get('maxDistance');
|
|
82
|
-
const maxDistance = maxDistanceStr ? parseInt(maxDistanceStr, 10) : 10;
|
|
83
|
-
try {
|
|
84
|
-
const relatedEvents = await model.getRelatedEvents(eventId, maxDistance);
|
|
85
|
-
sendSuccess(res, { events: relatedEvents });
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
sendError(res, 500, 'server_error', err.message);
|
|
89
|
-
}
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
sendNotFound(res, 'Route not found');
|
|
93
|
-
}
|
|
94
|
-
export function disposeEventsModels() {
|
|
95
|
-
for (const [, cached] of models) {
|
|
96
|
-
cached.model.dispose();
|
|
97
|
-
}
|
|
98
|
-
models.clear();
|
|
99
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { EvolutionConsoleModel } from '../models/EvolutionConsoleModel.js';
|
|
2
|
-
import { sendSuccess, sendError, sendNotFound } from '../utils/response.js';
|
|
3
|
-
import { parseQuery, safeParseInt } from '../utils/request.js';
|
|
4
|
-
const models = new Map();
|
|
5
|
-
function getModel(workspaceDir) {
|
|
6
|
-
let model = models.get(workspaceDir);
|
|
7
|
-
if (!model) {
|
|
8
|
-
model = new EvolutionConsoleModel(workspaceDir);
|
|
9
|
-
models.set(workspaceDir, model);
|
|
10
|
-
}
|
|
11
|
-
return model;
|
|
12
|
-
}
|
|
13
|
-
/* eslint-disable @typescript-eslint/max-params */
|
|
14
|
-
export async function handleEvolutionRoute(req, res, workspaceDir, subPath) {
|
|
15
|
-
if (req.method !== 'GET') {
|
|
16
|
-
sendNotFound(res, `Route /api/evolution${subPath} not found`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const model = getModel(workspaceDir);
|
|
20
|
-
if (subPath === '/stats' || subPath === '/stats/') {
|
|
21
|
-
try {
|
|
22
|
-
const result = await model.getStats();
|
|
23
|
-
sendSuccess(res, result);
|
|
24
|
-
}
|
|
25
|
-
catch (err) {
|
|
26
|
-
sendError(res, 500, 'evolution_stats_error', err.message);
|
|
27
|
-
}
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
if (subPath === '/tasks' || subPath === '/tasks/') {
|
|
31
|
-
try {
|
|
32
|
-
const query = parseQuery(req.url ?? '');
|
|
33
|
-
const result = await model.getTasks({
|
|
34
|
-
status: query.status,
|
|
35
|
-
taskKind: query.taskKind,
|
|
36
|
-
page: safeParseInt(query.page, 1, 1, 10000),
|
|
37
|
-
pageSize: safeParseInt(query.pageSize, 20, 1, 100),
|
|
38
|
-
});
|
|
39
|
-
sendSuccess(res, result);
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
sendError(res, 500, 'evolution_tasks_error', err.message);
|
|
43
|
-
}
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
if (subPath === '/principles' || subPath === '/principles/') {
|
|
47
|
-
try {
|
|
48
|
-
const result = await model.getPrinciples();
|
|
49
|
-
sendSuccess(res, result);
|
|
50
|
-
}
|
|
51
|
-
catch (err) {
|
|
52
|
-
sendError(res, 500, 'evolution_principles_error', err.message);
|
|
53
|
-
}
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (subPath === '/queue' || subPath === '/queue/') {
|
|
57
|
-
try {
|
|
58
|
-
const result = await model.getQueueHealth();
|
|
59
|
-
sendSuccess(res, result);
|
|
60
|
-
}
|
|
61
|
-
catch (err) {
|
|
62
|
-
sendError(res, 500, 'evolution_queue_error', err.message);
|
|
63
|
-
}
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
sendNotFound(res, `Route /api/evolution${subPath} not found`);
|
|
67
|
-
}
|
|
68
|
-
export function disposeEvolutionModels() {
|
|
69
|
-
for (const model of models.values()) {
|
|
70
|
-
model.dispose();
|
|
71
|
-
}
|
|
72
|
-
models.clear();
|
|
73
|
-
}
|