principles-disciple 1.8.0 → 1.8.2
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/ADVANCED_CONFIG_ZH.md +97 -0
- package/AGENT_INSTALL.md +173 -0
- package/AGENT_INSTALL_EN.md +173 -0
- package/INSTALL.md +256 -0
- package/SKILL.md +63 -0
- package/docs/COMMAND_REFERENCE.md +76 -0
- package/docs/COMMAND_REFERENCE_EN.md +79 -0
- package/esbuild.config.js +75 -0
- package/openclaw.plugin.json +6 -1
- package/package.json +13 -15
- package/scripts/build-web.mjs +46 -0
- package/scripts/install-dependencies.cjs +47 -0
- package/scripts/sync-plugin.mjs +802 -0
- package/scripts/verify-build.mjs +109 -0
- package/src/agents/nocturnal-dreamer.md +152 -0
- package/src/agents/nocturnal-philosopher.md +138 -0
- package/src/agents/nocturnal-reflector.md +126 -0
- package/src/agents/nocturnal-scribe.md +164 -0
- package/src/commands/capabilities.ts +85 -0
- package/{dist/commands/context.js → src/commands/context.ts} +78 -38
- package/src/commands/evolution-status.ts +146 -0
- package/src/commands/export.ts +111 -0
- package/src/commands/focus.ts +533 -0
- package/src/commands/nocturnal-review.ts +311 -0
- package/src/commands/nocturnal-rollout.ts +763 -0
- package/src/commands/nocturnal-train.ts +1002 -0
- package/{dist/commands/pain.js → src/commands/pain.ts} +68 -49
- package/src/commands/principle-rollback.ts +27 -0
- package/{dist/commands/rollback.js → src/commands/rollback.ts} +44 -12
- package/src/commands/samples.ts +60 -0
- package/src/commands/strategy.ts +38 -0
- package/{dist/commands/thinking-os.js → src/commands/thinking-os.ts} +59 -36
- package/src/commands/workflow-debug.ts +128 -0
- package/{dist/config/defaults/runtime.js → src/config/defaults/runtime.ts} +12 -5
- package/src/config/errors.ts +163 -0
- package/{dist/config/index.d.ts → src/config/index.ts} +2 -1
- package/src/constants/diagnostician.ts +66 -0
- package/src/constants/tools.ts +62 -0
- package/src/core/adaptive-thresholds.ts +476 -0
- package/{dist/core/config-service.js → src/core/config-service.ts} +7 -4
- package/{dist/core/config.js → src/core/config.ts} +158 -46
- package/src/core/control-ui-db.ts +435 -0
- package/{dist/core/detection-funnel.js → src/core/detection-funnel.ts} +36 -21
- package/{dist/core/detection-service.js → src/core/detection-service.ts} +7 -4
- package/{dist/core/dictionary-service.js → src/core/dictionary-service.ts} +7 -4
- package/{dist/core/dictionary.js → src/core/dictionary.ts} +57 -34
- package/src/core/empathy-keyword-matcher.ts +327 -0
- package/src/core/empathy-types.ts +218 -0
- package/src/core/event-log.ts +544 -0
- package/src/core/evolution-engine.ts +612 -0
- package/src/core/evolution-logger.ts +353 -0
- package/src/core/evolution-migration.ts +77 -0
- package/src/core/evolution-reducer.ts +731 -0
- package/src/core/evolution-types.ts +456 -0
- package/src/core/external-training-contract.ts +527 -0
- package/src/core/focus-history.ts +1458 -0
- package/src/core/hygiene/tracker.ts +117 -0
- package/{dist/core/init.js → src/core/init.ts} +39 -26
- package/src/core/local-worker-routing.ts +617 -0
- package/{dist/core/migration.js → src/core/migration.ts} +18 -11
- package/src/core/model-deployment-registry.ts +722 -0
- package/src/core/model-training-registry.ts +813 -0
- package/src/core/nocturnal-arbiter.ts +706 -0
- package/src/core/nocturnal-candidate-scoring.ts +392 -0
- package/src/core/nocturnal-compliance.ts +1075 -0
- package/src/core/nocturnal-dataset.ts +668 -0
- package/src/core/nocturnal-executability.ts +428 -0
- package/src/core/nocturnal-export.ts +390 -0
- package/{dist/core/nocturnal-paths.js → src/core/nocturnal-paths.ts} +49 -23
- package/src/core/nocturnal-trajectory-extractor.ts +484 -0
- package/src/core/nocturnal-trinity.ts +1384 -0
- package/src/core/pain.ts +122 -0
- package/{dist/core/path-resolver.js → src/core/path-resolver.ts} +157 -36
- package/{dist/core/paths.js → src/core/paths.ts} +13 -4
- package/src/core/principle-training-state.ts +450 -0
- package/src/core/profile.ts +226 -0
- package/src/core/promotion-gate.ts +822 -0
- package/{dist/core/risk-calculator.js → src/core/risk-calculator.ts} +42 -16
- package/{dist/core/session-tracker.js → src/core/session-tracker.ts} +185 -63
- package/src/core/shadow-observation-registry.ts +534 -0
- package/{dist/core/system-logger.js → src/core/system-logger.ts} +9 -5
- package/src/core/thinking-models.ts +217 -0
- package/src/core/training-program.ts +630 -0
- package/src/core/trajectory-types.ts +243 -0
- package/src/core/trajectory.ts +1673 -0
- package/{dist/core/workspace-context.js → src/core/workspace-context.ts} +57 -32
- package/src/hooks/bash-risk.ts +171 -0
- package/src/hooks/edit-verification.ts +295 -0
- package/src/hooks/gate-block-helper.ts +160 -0
- package/src/hooks/gate.ts +210 -0
- package/src/hooks/gfi-gate.ts +177 -0
- package/src/hooks/lifecycle.ts +326 -0
- package/{dist/hooks/llm.js → src/hooks/llm.ts} +166 -139
- package/src/hooks/message-sanitize.ts +45 -0
- package/src/hooks/pain.ts +384 -0
- package/src/hooks/progressive-trust-gate.ts +174 -0
- package/src/hooks/prompt.ts +920 -0
- package/src/hooks/subagent.ts +207 -0
- package/src/hooks/thinking-checkpoint.ts +73 -0
- package/src/hooks/trajectory-collector.ts +290 -0
- package/src/http/principles-console-route.ts +716 -0
- package/src/i18n/commands.ts +117 -0
- package/src/index.ts +694 -0
- package/src/service/central-database.ts +831 -0
- package/src/service/control-ui-query-service.ts +888 -0
- package/src/service/evolution-query-service.ts +405 -0
- package/src/service/evolution-worker.ts +1646 -0
- package/src/service/health-query-service.ts +836 -0
- package/{dist/service/nocturnal-runtime.js → src/service/nocturnal-runtime.ts} +263 -36
- package/src/service/nocturnal-service.ts +1015 -0
- package/src/service/nocturnal-target-selector.ts +532 -0
- package/src/service/phase3-input-filter.ts +237 -0
- package/src/service/runtime-summary-service.ts +757 -0
- package/src/service/subagent-workflow/deep-reflect-workflow-manager.ts +513 -0
- package/src/service/subagent-workflow/empathy-observer-workflow-manager.ts +603 -0
- package/src/service/subagent-workflow/index.ts +51 -0
- package/src/service/subagent-workflow/nocturnal-workflow-manager.ts +856 -0
- package/src/service/subagent-workflow/runtime-direct-driver.ts +166 -0
- package/src/service/subagent-workflow/types.ts +378 -0
- package/src/service/subagent-workflow/workflow-store.ts +328 -0
- package/src/service/trajectory-service.ts +15 -0
- package/{dist/tools/critique-prompt.js → src/tools/critique-prompt.ts} +25 -8
- package/src/tools/deep-reflect.ts +349 -0
- package/{dist/tools/model-index.js → src/tools/model-index.ts} +33 -17
- package/src/types/event-types.ts +453 -0
- package/src/types/hygiene-types.ts +31 -0
- package/src/types/principle-tree-schema.ts +244 -0
- package/src/types/runtime-summary.ts +49 -0
- package/src/types.ts +74 -0
- package/src/utils/file-lock.ts +391 -0
- package/{dist/utils/glob-match.js → src/utils/glob-match.ts} +21 -20
- package/{dist/utils/hashing.js → src/utils/hashing.ts} +6 -4
- package/src/utils/io.ts +110 -0
- package/{dist/utils/nlp.js → src/utils/nlp.ts} +19 -12
- package/{dist/utils/plugin-logger.js → src/utils/plugin-logger.ts} +33 -8
- package/src/utils/subagent-probe.ts +94 -0
- package/templates/langs/zh/skills/pd-diagnostician/SKILL.md +70 -1
- package/templates/pain_settings.json +2 -1
- package/tests/README.md +120 -0
- package/tests/build-artifacts.test.ts +111 -0
- package/tests/commands/evolution-status.test.ts +222 -0
- package/tests/commands/evolver.test.ts +22 -0
- package/tests/commands/export.test.ts +78 -0
- package/tests/commands/nocturnal-review.test.ts +448 -0
- package/tests/commands/nocturnal-train.test.ts +97 -0
- package/tests/commands/pain.test.ts +108 -0
- package/tests/commands/samples.test.ts +65 -0
- package/tests/commands/strategy.test.ts +34 -0
- package/tests/commands/thinking-os.test.ts +88 -0
- package/tests/core/adaptive-thresholds.test.ts +261 -0
- package/tests/core/config-service.test.ts +89 -0
- package/tests/core/config.test.ts +90 -0
- package/tests/core/control-ui-db.test.ts +75 -0
- package/tests/core/core-template-guidance.test.ts +21 -0
- package/tests/core/detection-funnel.test.ts +63 -0
- package/tests/core/detection-service.test.ts +50 -0
- package/tests/core/dictionary-service.test.ts +116 -0
- package/tests/core/dictionary.test.ts +168 -0
- package/tests/core/empathy-keyword-matcher.test.ts +209 -0
- package/tests/core/event-log.test.ts +181 -0
- package/tests/core/evolution-e2e.test.ts +58 -0
- package/tests/core/evolution-engine-gate-integration.test.ts +543 -0
- package/tests/core/evolution-engine.test.ts +562 -0
- package/tests/core/evolution-logger.test.ts +148 -0
- package/tests/core/evolution-migration.test.ts +50 -0
- package/tests/core/evolution-paths.test.ts +21 -0
- package/tests/core/evolution-reducer.detector-metadata.test.ts +602 -0
- package/tests/core/evolution-reducer.test.ts +180 -0
- package/tests/core/evolution-types-loop.test.ts +48 -0
- package/tests/core/evolution-user-stories.e2e.test.ts +249 -0
- package/tests/core/external-training-contract.test.ts +463 -0
- package/tests/core/focus-history.test.ts +682 -0
- package/tests/core/init-flatten.test.ts +69 -0
- package/tests/core/init-refactor.test.ts +87 -0
- package/tests/core/init-v1.3.test.ts +46 -0
- package/tests/core/init.test.ts +190 -0
- package/tests/core/local-worker-routing.test.ts +757 -0
- package/tests/core/migration.test.ts +84 -0
- package/tests/core/model-deployment-registry.test.ts +845 -0
- package/tests/core/model-training-registry.test.ts +889 -0
- package/tests/core/nocturnal-arbiter.test.ts +494 -0
- package/tests/core/nocturnal-candidate-scoring.test.ts +400 -0
- package/tests/core/nocturnal-compliance.test.ts +646 -0
- package/tests/core/nocturnal-dataset.test.ts +892 -0
- package/tests/core/nocturnal-executability.test.ts +357 -0
- package/tests/core/nocturnal-export.test.ts +462 -0
- package/tests/core/nocturnal-reviewed-subset-comparison.test.ts +428 -0
- package/tests/core/nocturnal-trajectory-extractor.test.ts +634 -0
- package/tests/core/nocturnal-trinity.test.ts +953 -0
- package/tests/core/pain.test.ts +33 -0
- package/tests/core/path-resolver.test.ts +57 -0
- package/tests/core/paths-refactor.test.ts +42 -0
- package/tests/core/phase7-rollout-integration.test.ts +477 -0
- package/tests/core/principle-training-state.test.ts +712 -0
- package/tests/core/profile.test.ts +56 -0
- package/tests/core/promotion-gate.test.ts +556 -0
- package/tests/core/risk-calculator.test.ts +168 -0
- package/tests/core/session-tracker.test.ts +191 -0
- package/tests/core/training-program.test.ts +472 -0
- package/tests/core/trajectory.test.ts +265 -0
- package/tests/core/workspace-context-factory.test.ts +18 -0
- package/tests/core/workspace-context.test.ts +134 -0
- package/tests/fixtures/nocturnal-reviewed-subset.json +183 -0
- package/tests/fixtures/production-compatibility.test.ts +147 -0
- package/tests/fixtures/production-mock-generator.ts +282 -0
- package/tests/hooks/bash-risk-integration.test.ts +137 -0
- package/tests/hooks/bash-risk.test.ts +81 -0
- package/tests/hooks/edit-verification.test.ts +678 -0
- package/tests/hooks/gate-edit-verification-p1.test.ts +632 -0
- package/tests/hooks/gate-edit-verification.test.ts +435 -0
- package/tests/hooks/gate-pipeline-integration.test.ts +404 -0
- package/tests/hooks/gate.test.ts +271 -0
- package/tests/hooks/gfi-gate-unit.test.ts +422 -0
- package/tests/hooks/gfi-gate.test.ts +669 -0
- package/tests/hooks/lifecycle.test.ts +248 -0
- package/tests/hooks/llm.test.ts +308 -0
- package/tests/hooks/message-sanitize.test.ts +36 -0
- package/tests/hooks/pain.test.ts +141 -0
- package/tests/hooks/progressive-trust-gate.test.ts +277 -0
- package/tests/hooks/prompt.test.ts +1411 -0
- package/tests/hooks/subagent.test.ts +467 -0
- package/tests/hooks/thinking-gate.test.ts +313 -0
- package/tests/http/principles-console-route.test.ts +140 -0
- package/tests/hygiene-tracker.test.ts +77 -0
- package/tests/index.integration.test.ts +179 -0
- package/tests/index.shadow-routing.integration.test.ts +140 -0
- package/tests/index.test.ts +9 -0
- package/tests/integration/empathy-workflow-integration.test.ts +627 -0
- package/tests/service/control-ui-query-service.test.ts +121 -0
- package/tests/service/empathy-observer-workflow-manager.test.ts +176 -0
- package/tests/service/evolution-worker.test.ts +585 -0
- package/tests/service/nocturnal-runtime.test.ts +470 -0
- package/tests/service/nocturnal-service.test.ts +577 -0
- package/tests/service/nocturnal-target-selector.test.ts +615 -0
- package/tests/service/nocturnal-workflow-manager.test.ts +439 -0
- package/tests/service/phase3-input-filter.test.ts +289 -0
- package/tests/service/runtime-summary-service.test.ts +919 -0
- package/tests/task-compliance.test.ts +166 -0
- package/tests/test-utils.ts +48 -0
- package/tests/tools/critique-prompt.test.ts +260 -0
- package/tests/tools/deep-reflect.test.ts +232 -0
- package/tests/tools/model-index.test.ts +246 -0
- package/tests/ui/app.test.tsx +114 -0
- package/tests/utils/file-lock.test.ts +407 -0
- package/tests/utils/hashing.test.ts +32 -0
- package/tests/utils/io.test.ts +39 -0
- package/tests/utils/nlp.test.ts +53 -0
- package/tests/utils/plugin-logger.test.ts +156 -0
- package/tsconfig.json +16 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/ui/src/App.tsx +45 -0
- package/ui/src/api.ts +216 -0
- package/ui/src/charts.tsx +586 -0
- package/ui/src/components/ErrorState.tsx +6 -0
- package/ui/src/components/Loading.tsx +13 -0
- package/ui/src/components/ProtectedRoute.tsx +12 -0
- package/ui/src/components/Shell.tsx +91 -0
- package/ui/src/components/WorkspaceConfig.tsx +146 -0
- package/ui/src/components/index.ts +5 -0
- package/ui/src/context/auth.tsx +80 -0
- package/ui/src/context/theme.tsx +66 -0
- package/ui/src/hooks/useAutoRefresh.ts +39 -0
- package/ui/src/i18n/ui.ts +363 -0
- package/ui/src/main.tsx +16 -0
- package/ui/src/pages/EvolutionPage.tsx +352 -0
- package/ui/src/pages/FeedbackPage.tsx +140 -0
- package/ui/src/pages/GateMonitorPage.tsx +136 -0
- package/ui/src/pages/LoginPage.tsx +88 -0
- package/ui/src/pages/OverviewPage.tsx +238 -0
- package/ui/src/pages/SamplesPage.tsx +174 -0
- package/ui/src/pages/ThinkingModelsPage.tsx +127 -0
- package/ui/src/styles.css +1661 -0
- package/ui/src/types.ts +368 -0
- package/ui/src/utils/format.ts +15 -0
- package/vitest.config.ts +23 -0
- package/dist/commands/capabilities.d.ts +0 -3
- package/dist/commands/capabilities.js +0 -73
- package/dist/commands/context.d.ts +0 -5
- package/dist/commands/evolution-status.d.ts +0 -4
- package/dist/commands/evolution-status.js +0 -117
- package/dist/commands/evolver.d.ts +0 -9
- package/dist/commands/evolver.js +0 -26
- package/dist/commands/export.d.ts +0 -2
- package/dist/commands/export.js +0 -98
- package/dist/commands/focus.d.ts +0 -14
- package/dist/commands/focus.js +0 -457
- package/dist/commands/nocturnal-review.d.ts +0 -24
- package/dist/commands/nocturnal-review.js +0 -265
- package/dist/commands/nocturnal-rollout.d.ts +0 -27
- package/dist/commands/nocturnal-rollout.js +0 -671
- package/dist/commands/nocturnal-train.d.ts +0 -25
- package/dist/commands/nocturnal-train.js +0 -919
- package/dist/commands/pain.d.ts +0 -5
- package/dist/commands/principle-rollback.d.ts +0 -4
- package/dist/commands/principle-rollback.js +0 -22
- package/dist/commands/rollback.d.ts +0 -19
- package/dist/commands/samples.d.ts +0 -2
- package/dist/commands/samples.js +0 -55
- package/dist/commands/strategy.d.ts +0 -3
- package/dist/commands/strategy.js +0 -29
- package/dist/commands/thinking-os.d.ts +0 -2
- package/dist/config/defaults/runtime.d.ts +0 -40
- package/dist/config/errors.d.ts +0 -84
- package/dist/config/errors.js +0 -94
- package/dist/config/index.js +0 -7
- package/dist/constants/diagnostician.d.ts +0 -12
- package/dist/constants/diagnostician.js +0 -56
- package/dist/constants/tools.d.ts +0 -17
- package/dist/constants/tools.js +0 -54
- package/dist/core/adaptive-thresholds.d.ts +0 -186
- package/dist/core/adaptive-thresholds.js +0 -300
- package/dist/core/config-service.d.ts +0 -15
- package/dist/core/config.d.ts +0 -127
- package/dist/core/control-ui-db.d.ts +0 -95
- package/dist/core/control-ui-db.js +0 -292
- package/dist/core/detection-funnel.d.ts +0 -33
- package/dist/core/detection-service.d.ts +0 -15
- package/dist/core/dictionary-service.d.ts +0 -15
- package/dist/core/dictionary.d.ts +0 -38
- package/dist/core/event-log.d.ts +0 -82
- package/dist/core/event-log.js +0 -463
- package/dist/core/evolution-engine.d.ts +0 -118
- package/dist/core/evolution-engine.js +0 -464
- package/dist/core/evolution-logger.d.ts +0 -137
- package/dist/core/evolution-logger.js +0 -256
- package/dist/core/evolution-migration.d.ts +0 -5
- package/dist/core/evolution-migration.js +0 -65
- package/dist/core/evolution-reducer.d.ts +0 -98
- package/dist/core/evolution-reducer.js +0 -465
- package/dist/core/evolution-types.d.ts +0 -287
- package/dist/core/evolution-types.js +0 -78
- package/dist/core/external-training-contract.d.ts +0 -276
- package/dist/core/external-training-contract.js +0 -269
- package/dist/core/focus-history.d.ts +0 -210
- package/dist/core/focus-history.js +0 -1185
- package/dist/core/hygiene/tracker.d.ts +0 -22
- package/dist/core/hygiene/tracker.js +0 -106
- package/dist/core/init.d.ts +0 -12
- package/dist/core/local-worker-routing.d.ts +0 -175
- package/dist/core/local-worker-routing.js +0 -525
- package/dist/core/migration.d.ts +0 -6
- package/dist/core/model-deployment-registry.d.ts +0 -218
- package/dist/core/model-deployment-registry.js +0 -503
- package/dist/core/model-training-registry.d.ts +0 -295
- package/dist/core/model-training-registry.js +0 -475
- package/dist/core/nocturnal-arbiter.d.ts +0 -159
- package/dist/core/nocturnal-arbiter.js +0 -534
- package/dist/core/nocturnal-candidate-scoring.d.ts +0 -137
- package/dist/core/nocturnal-candidate-scoring.js +0 -266
- package/dist/core/nocturnal-compliance.d.ts +0 -175
- package/dist/core/nocturnal-compliance.js +0 -824
- package/dist/core/nocturnal-dataset.d.ts +0 -224
- package/dist/core/nocturnal-dataset.js +0 -443
- package/dist/core/nocturnal-executability.d.ts +0 -85
- package/dist/core/nocturnal-executability.js +0 -331
- package/dist/core/nocturnal-export.d.ts +0 -124
- package/dist/core/nocturnal-export.js +0 -275
- package/dist/core/nocturnal-paths.d.ts +0 -124
- package/dist/core/nocturnal-trajectory-extractor.d.ts +0 -242
- package/dist/core/nocturnal-trajectory-extractor.js +0 -307
- package/dist/core/nocturnal-trinity.d.ts +0 -311
- package/dist/core/nocturnal-trinity.js +0 -880
- package/dist/core/pain.d.ts +0 -4
- package/dist/core/pain.js +0 -70
- package/dist/core/path-resolver.d.ts +0 -46
- package/dist/core/paths.d.ts +0 -65
- package/dist/core/principle-training-state.d.ts +0 -121
- package/dist/core/principle-training-state.js +0 -321
- package/dist/core/profile.d.ts +0 -62
- package/dist/core/profile.js +0 -210
- package/dist/core/promotion-gate.d.ts +0 -238
- package/dist/core/promotion-gate.js +0 -529
- package/dist/core/risk-calculator.d.ts +0 -22
- package/dist/core/session-tracker.d.ts +0 -99
- package/dist/core/shadow-observation-registry.d.ts +0 -217
- package/dist/core/shadow-observation-registry.js +0 -308
- package/dist/core/system-logger.d.ts +0 -8
- package/dist/core/thinking-models.d.ts +0 -38
- package/dist/core/thinking-models.js +0 -170
- package/dist/core/training-program.d.ts +0 -233
- package/dist/core/training-program.js +0 -433
- package/dist/core/trajectory.d.ts +0 -411
- package/dist/core/trajectory.js +0 -1307
- package/dist/core/workspace-context.d.ts +0 -71
- package/dist/hooks/bash-risk.d.ts +0 -57
- package/dist/hooks/bash-risk.js +0 -137
- package/dist/hooks/edit-verification.d.ts +0 -62
- package/dist/hooks/edit-verification.js +0 -256
- package/dist/hooks/gate-block-helper.d.ts +0 -44
- package/dist/hooks/gate-block-helper.js +0 -119
- package/dist/hooks/gate.d.ts +0 -24
- package/dist/hooks/gate.js +0 -173
- package/dist/hooks/gfi-gate.d.ts +0 -40
- package/dist/hooks/gfi-gate.js +0 -113
- package/dist/hooks/lifecycle.d.ts +0 -5
- package/dist/hooks/lifecycle.js +0 -284
- package/dist/hooks/llm.d.ts +0 -12
- package/dist/hooks/message-sanitize.d.ts +0 -3
- package/dist/hooks/message-sanitize.js +0 -37
- package/dist/hooks/pain.d.ts +0 -5
- package/dist/hooks/pain.js +0 -301
- package/dist/hooks/progressive-trust-gate.d.ts +0 -51
- package/dist/hooks/progressive-trust-gate.js +0 -89
- package/dist/hooks/prompt.d.ts +0 -47
- package/dist/hooks/prompt.js +0 -884
- package/dist/hooks/subagent.d.ts +0 -10
- package/dist/hooks/subagent.js +0 -387
- package/dist/hooks/thinking-checkpoint.d.ts +0 -37
- package/dist/hooks/thinking-checkpoint.js +0 -51
- package/dist/hooks/trajectory-collector.d.ts +0 -32
- package/dist/hooks/trajectory-collector.js +0 -256
- package/dist/http/principles-console-route.d.ts +0 -9
- package/dist/http/principles-console-route.js +0 -567
- package/dist/i18n/commands.d.ts +0 -26
- package/dist/i18n/commands.js +0 -116
- package/dist/index.d.ts +0 -7
- package/dist/index.js +0 -581
- package/dist/service/central-database.d.ts +0 -104
- package/dist/service/central-database.js +0 -649
- package/dist/service/control-ui-query-service.d.ts +0 -221
- package/dist/service/control-ui-query-service.js +0 -543
- package/dist/service/empathy-observer-manager.d.ts +0 -52
- package/dist/service/empathy-observer-manager.js +0 -229
- package/dist/service/evolution-query-service.d.ts +0 -155
- package/dist/service/evolution-query-service.js +0 -258
- package/dist/service/evolution-worker.d.ts +0 -101
- package/dist/service/evolution-worker.js +0 -974
- package/dist/service/nocturnal-runtime.d.ts +0 -183
- package/dist/service/nocturnal-service.d.ts +0 -163
- package/dist/service/nocturnal-service.js +0 -787
- package/dist/service/nocturnal-target-selector.d.ts +0 -145
- package/dist/service/nocturnal-target-selector.js +0 -315
- package/dist/service/phase3-input-filter.d.ts +0 -73
- package/dist/service/phase3-input-filter.js +0 -172
- package/dist/service/runtime-summary-service.d.ts +0 -122
- package/dist/service/runtime-summary-service.js +0 -485
- package/dist/service/trajectory-service.d.ts +0 -2
- package/dist/service/trajectory-service.js +0 -15
- package/dist/tools/critique-prompt.d.ts +0 -14
- package/dist/tools/deep-reflect.d.ts +0 -39
- package/dist/tools/deep-reflect.js +0 -350
- package/dist/tools/model-index.d.ts +0 -9
- package/dist/types/event-types.d.ts +0 -306
- package/dist/types/event-types.js +0 -106
- package/dist/types/hygiene-types.d.ts +0 -20
- package/dist/types/hygiene-types.js +0 -12
- package/dist/types/runtime-summary.d.ts +0 -47
- package/dist/types/runtime-summary.js +0 -1
- package/dist/types.d.ts +0 -50
- package/dist/types.js +0 -22
- package/dist/utils/file-lock.d.ts +0 -71
- package/dist/utils/file-lock.js +0 -309
- package/dist/utils/glob-match.d.ts +0 -28
- package/dist/utils/hashing.d.ts +0 -9
- package/dist/utils/io.d.ts +0 -6
- package/dist/utils/io.js +0 -106
- package/dist/utils/nlp.d.ts +0 -9
- package/dist/utils/plugin-logger.d.ts +0 -39
- package/dist/utils/subagent-probe.d.ts +0 -34
- package/dist/utils/subagent-probe.js +0 -81
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Control UI database stores ANALYTICS READ MODELS.
|
|
3
|
-
*
|
|
4
|
-
* PURPOSE: Aggregated data for dashboard visualization and historical insights.
|
|
5
|
-
* USAGE: Control UI queries and dashboard displays.
|
|
6
|
-
* NOT FOR: Control decisions, Phase 3 eligibility, or real-time operations.
|
|
7
|
-
*
|
|
8
|
-
* Runtime truth comes from: queue state, workspace trust scorecard, active sessions
|
|
9
|
-
*/
|
|
10
|
-
export interface ThinkingModelEventInput {
|
|
11
|
-
sessionId: string;
|
|
12
|
-
runId: string;
|
|
13
|
-
assistantTurnId: number;
|
|
14
|
-
modelId: string;
|
|
15
|
-
matchedPattern: string;
|
|
16
|
-
scenarioJson: unknown;
|
|
17
|
-
toolContextJson: unknown;
|
|
18
|
-
painContextJson: unknown;
|
|
19
|
-
principleContextJson: unknown;
|
|
20
|
-
triggerExcerpt: string;
|
|
21
|
-
createdAt: string;
|
|
22
|
-
}
|
|
23
|
-
export interface ControlUiDatabaseOptions {
|
|
24
|
-
workspaceDir: string;
|
|
25
|
-
busyTimeoutMs?: number;
|
|
26
|
-
}
|
|
27
|
-
export interface RecentThinkingContext {
|
|
28
|
-
toolCalls: Array<{
|
|
29
|
-
id: number;
|
|
30
|
-
toolName: string;
|
|
31
|
-
outcome: 'success' | 'failure' | 'blocked';
|
|
32
|
-
errorType: string | null;
|
|
33
|
-
errorMessage: string | null;
|
|
34
|
-
createdAt: string;
|
|
35
|
-
}>;
|
|
36
|
-
painEvents: Array<{
|
|
37
|
-
id: number;
|
|
38
|
-
source: string;
|
|
39
|
-
score: number;
|
|
40
|
-
reason: string | null;
|
|
41
|
-
createdAt: string;
|
|
42
|
-
}>;
|
|
43
|
-
gateBlocks: Array<{
|
|
44
|
-
id: number;
|
|
45
|
-
toolName: string;
|
|
46
|
-
reason: string;
|
|
47
|
-
filePath: string | null;
|
|
48
|
-
createdAt: string;
|
|
49
|
-
}>;
|
|
50
|
-
userCorrections: Array<{
|
|
51
|
-
id: number;
|
|
52
|
-
correctionCue: string | null;
|
|
53
|
-
rawExcerpt: string | null;
|
|
54
|
-
createdAt: string;
|
|
55
|
-
}>;
|
|
56
|
-
principleEvents: Array<{
|
|
57
|
-
id: number;
|
|
58
|
-
principleId: string | null;
|
|
59
|
-
eventType: string;
|
|
60
|
-
createdAt: string;
|
|
61
|
-
}>;
|
|
62
|
-
}
|
|
63
|
-
export declare class ControlUiDatabase {
|
|
64
|
-
private readonly workspaceDir;
|
|
65
|
-
private readonly dbPath;
|
|
66
|
-
private readonly blobDir;
|
|
67
|
-
private readonly db;
|
|
68
|
-
constructor(opts: ControlUiDatabaseOptions);
|
|
69
|
-
dispose(): void;
|
|
70
|
-
recordThinkingModelEvent(input: ThinkingModelEventInput): number;
|
|
71
|
-
/**
|
|
72
|
-
* Get recent thinking context for a session.
|
|
73
|
-
*
|
|
74
|
-
* Returns: Analytics data (read model) aggregated from trajectory database.
|
|
75
|
-
* Not: Runtime truth or real-time queue state.
|
|
76
|
-
*/
|
|
77
|
-
getRecentThinkingContext(sessionId: string, beforeCreatedAt: string, limit?: number): RecentThinkingContext;
|
|
78
|
-
/**
|
|
79
|
-
* Execute SQL query and return all rows.
|
|
80
|
-
*
|
|
81
|
-
* Returns: Analytics data (read model) aggregated from trajectory database.
|
|
82
|
-
* Not: Runtime truth or real-time queue state.
|
|
83
|
-
*/
|
|
84
|
-
all<T>(sql: string, ...params: unknown[]): T[];
|
|
85
|
-
/**
|
|
86
|
-
* Execute SQL query and return first row.
|
|
87
|
-
*
|
|
88
|
-
* Returns: Analytics data (read model) aggregated from trajectory database.
|
|
89
|
-
* Not: Runtime truth or real-time queue state.
|
|
90
|
-
*/
|
|
91
|
-
get<T>(sql: string, ...params: unknown[]): T | undefined;
|
|
92
|
-
restoreRawText(inlineText?: string | null, blobRef?: string | null): string;
|
|
93
|
-
private initSchema;
|
|
94
|
-
private withWrite;
|
|
95
|
-
}
|
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import Database from 'better-sqlite3';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { withLock } from '../utils/file-lock.js';
|
|
5
|
-
import { resolvePdPath } from './paths.js';
|
|
6
|
-
const DEFAULT_BUSY_TIMEOUT_MS = 5000;
|
|
7
|
-
function safeJson(value) {
|
|
8
|
-
return JSON.stringify(value ?? []);
|
|
9
|
-
}
|
|
10
|
-
export class ControlUiDatabase {
|
|
11
|
-
workspaceDir;
|
|
12
|
-
dbPath;
|
|
13
|
-
blobDir;
|
|
14
|
-
db;
|
|
15
|
-
constructor(opts) {
|
|
16
|
-
this.workspaceDir = path.resolve(opts.workspaceDir);
|
|
17
|
-
this.dbPath = resolvePdPath(this.workspaceDir, 'TRAJECTORY_DB');
|
|
18
|
-
this.blobDir = resolvePdPath(this.workspaceDir, 'TRAJECTORY_BLOBS_DIR');
|
|
19
|
-
fs.mkdirSync(path.dirname(this.dbPath), { recursive: true });
|
|
20
|
-
fs.mkdirSync(this.blobDir, { recursive: true });
|
|
21
|
-
this.db = new Database(this.dbPath);
|
|
22
|
-
this.db.pragma('journal_mode = WAL');
|
|
23
|
-
this.db.pragma('foreign_keys = ON');
|
|
24
|
-
this.db.pragma('synchronous = NORMAL');
|
|
25
|
-
this.db.pragma(`busy_timeout = ${Math.max(0, opts.busyTimeoutMs ?? DEFAULT_BUSY_TIMEOUT_MS)}`);
|
|
26
|
-
this.initSchema();
|
|
27
|
-
}
|
|
28
|
-
dispose() {
|
|
29
|
-
this.db.close();
|
|
30
|
-
}
|
|
31
|
-
recordThinkingModelEvent(input) {
|
|
32
|
-
return this.withWrite(() => {
|
|
33
|
-
const result = this.db.prepare(`
|
|
34
|
-
INSERT INTO thinking_model_events (
|
|
35
|
-
session_id, run_id, assistant_turn_id, model_id, matched_pattern, scenario_json,
|
|
36
|
-
tool_context_json, pain_context_json, principle_context_json, trigger_excerpt, created_at
|
|
37
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
38
|
-
`).run(input.sessionId, input.runId, input.assistantTurnId, input.modelId, input.matchedPattern, safeJson(input.scenarioJson), safeJson(input.toolContextJson), safeJson(input.painContextJson), safeJson(input.principleContextJson), input.triggerExcerpt, input.createdAt);
|
|
39
|
-
return Number(result.lastInsertRowid);
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get recent thinking context for a session.
|
|
44
|
-
*
|
|
45
|
-
* Returns: Analytics data (read model) aggregated from trajectory database.
|
|
46
|
-
* Not: Runtime truth or real-time queue state.
|
|
47
|
-
*/
|
|
48
|
-
getRecentThinkingContext(sessionId, beforeCreatedAt, limit = 5) {
|
|
49
|
-
return {
|
|
50
|
-
toolCalls: this.all(`
|
|
51
|
-
SELECT id, tool_name, outcome, error_type, error_message, created_at
|
|
52
|
-
FROM tool_calls
|
|
53
|
-
WHERE session_id = ? AND created_at <= ?
|
|
54
|
-
ORDER BY created_at DESC
|
|
55
|
-
LIMIT ?
|
|
56
|
-
`, sessionId, beforeCreatedAt, limit).map((row) => ({
|
|
57
|
-
id: Number(row.id),
|
|
58
|
-
toolName: String(row.tool_name),
|
|
59
|
-
outcome: row.outcome,
|
|
60
|
-
errorType: row.error_type,
|
|
61
|
-
errorMessage: row.error_message,
|
|
62
|
-
createdAt: String(row.created_at),
|
|
63
|
-
})),
|
|
64
|
-
painEvents: this.all(`
|
|
65
|
-
SELECT id, source, score, reason, created_at
|
|
66
|
-
FROM pain_events
|
|
67
|
-
WHERE session_id = ? AND created_at <= ?
|
|
68
|
-
ORDER BY created_at DESC
|
|
69
|
-
LIMIT ?
|
|
70
|
-
`, sessionId, beforeCreatedAt, limit).map((row) => ({
|
|
71
|
-
id: Number(row.id),
|
|
72
|
-
source: String(row.source),
|
|
73
|
-
score: Number(row.score),
|
|
74
|
-
reason: row.reason,
|
|
75
|
-
createdAt: String(row.created_at),
|
|
76
|
-
})),
|
|
77
|
-
gateBlocks: this.all(`
|
|
78
|
-
SELECT id, tool_name, reason, file_path, created_at
|
|
79
|
-
FROM gate_blocks
|
|
80
|
-
WHERE session_id = ? AND created_at <= ?
|
|
81
|
-
ORDER BY created_at DESC
|
|
82
|
-
LIMIT ?
|
|
83
|
-
`, sessionId, beforeCreatedAt, limit).map((row) => ({
|
|
84
|
-
id: Number(row.id),
|
|
85
|
-
toolName: String(row.tool_name),
|
|
86
|
-
reason: String(row.reason),
|
|
87
|
-
filePath: row.file_path,
|
|
88
|
-
createdAt: String(row.created_at),
|
|
89
|
-
})),
|
|
90
|
-
userCorrections: this.all(`
|
|
91
|
-
SELECT id, correction_cue, raw_excerpt, created_at
|
|
92
|
-
FROM user_turns
|
|
93
|
-
WHERE session_id = ? AND correction_detected = 1 AND created_at <= ?
|
|
94
|
-
ORDER BY created_at DESC
|
|
95
|
-
LIMIT ?
|
|
96
|
-
`, sessionId, beforeCreatedAt, limit).map((row) => ({
|
|
97
|
-
id: Number(row.id),
|
|
98
|
-
correctionCue: row.correction_cue,
|
|
99
|
-
rawExcerpt: row.raw_excerpt,
|
|
100
|
-
createdAt: String(row.created_at),
|
|
101
|
-
})),
|
|
102
|
-
principleEvents: this.all(`
|
|
103
|
-
SELECT id, principle_id, event_type, created_at
|
|
104
|
-
FROM principle_events
|
|
105
|
-
WHERE created_at <= ?
|
|
106
|
-
ORDER BY created_at DESC
|
|
107
|
-
LIMIT ?
|
|
108
|
-
`, beforeCreatedAt, limit).map((row) => ({
|
|
109
|
-
id: Number(row.id),
|
|
110
|
-
principleId: row.principle_id,
|
|
111
|
-
eventType: String(row.event_type),
|
|
112
|
-
createdAt: String(row.created_at),
|
|
113
|
-
})),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Execute SQL query and return all rows.
|
|
118
|
-
*
|
|
119
|
-
* Returns: Analytics data (read model) aggregated from trajectory database.
|
|
120
|
-
* Not: Runtime truth or real-time queue state.
|
|
121
|
-
*/
|
|
122
|
-
all(sql, ...params) {
|
|
123
|
-
return this.db.prepare(sql).all(...params);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Execute SQL query and return first row.
|
|
127
|
-
*
|
|
128
|
-
* Returns: Analytics data (read model) aggregated from trajectory database.
|
|
129
|
-
* Not: Runtime truth or real-time queue state.
|
|
130
|
-
*/
|
|
131
|
-
get(sql, ...params) {
|
|
132
|
-
return this.db.prepare(sql).get(...params);
|
|
133
|
-
}
|
|
134
|
-
restoreRawText(inlineText, blobRef) {
|
|
135
|
-
if (inlineText)
|
|
136
|
-
return inlineText;
|
|
137
|
-
if (!blobRef)
|
|
138
|
-
return '';
|
|
139
|
-
const fullPath = path.join(this.blobDir, blobRef);
|
|
140
|
-
return fs.existsSync(fullPath) ? fs.readFileSync(fullPath, 'utf8') : '';
|
|
141
|
-
}
|
|
142
|
-
initSchema() {
|
|
143
|
-
this.db.exec(`
|
|
144
|
-
CREATE TABLE IF NOT EXISTS thinking_model_events (
|
|
145
|
-
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
146
|
-
session_id TEXT NOT NULL,
|
|
147
|
-
run_id TEXT NOT NULL,
|
|
148
|
-
assistant_turn_id INTEGER NOT NULL,
|
|
149
|
-
model_id TEXT NOT NULL,
|
|
150
|
-
matched_pattern TEXT NOT NULL,
|
|
151
|
-
scenario_json TEXT NOT NULL,
|
|
152
|
-
tool_context_json TEXT NOT NULL,
|
|
153
|
-
pain_context_json TEXT NOT NULL,
|
|
154
|
-
principle_context_json TEXT NOT NULL,
|
|
155
|
-
trigger_excerpt TEXT NOT NULL,
|
|
156
|
-
created_at TEXT NOT NULL
|
|
157
|
-
);
|
|
158
|
-
CREATE INDEX IF NOT EXISTS idx_thinking_model_events_model_created
|
|
159
|
-
ON thinking_model_events(model_id, created_at);
|
|
160
|
-
CREATE INDEX IF NOT EXISTS idx_thinking_model_events_session_created
|
|
161
|
-
ON thinking_model_events(session_id, created_at);
|
|
162
|
-
CREATE INDEX IF NOT EXISTS idx_thinking_model_events_assistant_turn
|
|
163
|
-
ON thinking_model_events(assistant_turn_id);
|
|
164
|
-
CREATE INDEX IF NOT EXISTS idx_thinking_model_events_run_id
|
|
165
|
-
ON thinking_model_events(run_id);
|
|
166
|
-
|
|
167
|
-
DROP VIEW IF EXISTS v_thinking_model_usage;
|
|
168
|
-
CREATE VIEW v_thinking_model_usage AS
|
|
169
|
-
WITH totals AS (
|
|
170
|
-
SELECT COUNT(*) AS assistant_turns FROM assistant_turns
|
|
171
|
-
),
|
|
172
|
-
usage_rows AS (
|
|
173
|
-
SELECT
|
|
174
|
-
model_id,
|
|
175
|
-
COUNT(*) AS hits,
|
|
176
|
-
COUNT(DISTINCT session_id) AS distinct_sessions,
|
|
177
|
-
COUNT(DISTINCT assistant_turn_id) AS distinct_turns
|
|
178
|
-
FROM thinking_model_events
|
|
179
|
-
GROUP BY model_id
|
|
180
|
-
)
|
|
181
|
-
SELECT
|
|
182
|
-
usage_rows.model_id AS model_id,
|
|
183
|
-
usage_rows.hits AS hits,
|
|
184
|
-
usage_rows.distinct_sessions AS distinct_sessions,
|
|
185
|
-
usage_rows.distinct_turns AS distinct_turns,
|
|
186
|
-
CASE
|
|
187
|
-
WHEN totals.assistant_turns = 0 THEN 0
|
|
188
|
-
ELSE ROUND(CAST(usage_rows.distinct_turns AS REAL) / CAST(totals.assistant_turns AS REAL), 4)
|
|
189
|
-
END AS coverage_rate
|
|
190
|
-
FROM usage_rows, totals
|
|
191
|
-
ORDER BY usage_rows.hits DESC, usage_rows.model_id ASC;
|
|
192
|
-
|
|
193
|
-
DROP VIEW IF EXISTS v_thinking_model_effectiveness;
|
|
194
|
-
CREATE VIEW v_thinking_model_effectiveness AS
|
|
195
|
-
WITH event_windows AS (
|
|
196
|
-
SELECT
|
|
197
|
-
e.id,
|
|
198
|
-
e.session_id,
|
|
199
|
-
e.model_id,
|
|
200
|
-
e.created_at,
|
|
201
|
-
(
|
|
202
|
-
SELECT MIN(a.created_at)
|
|
203
|
-
FROM assistant_turns a
|
|
204
|
-
WHERE a.session_id = e.session_id AND a.created_at > e.created_at
|
|
205
|
-
) AS next_assistant_at,
|
|
206
|
-
datetime(e.created_at, '+10 minutes') AS max_window_end
|
|
207
|
-
FROM thinking_model_events e
|
|
208
|
-
),
|
|
209
|
-
bounded_windows AS (
|
|
210
|
-
SELECT
|
|
211
|
-
id,
|
|
212
|
-
session_id,
|
|
213
|
-
model_id,
|
|
214
|
-
created_at,
|
|
215
|
-
CASE
|
|
216
|
-
WHEN next_assistant_at IS NULL THEN max_window_end
|
|
217
|
-
WHEN next_assistant_at < max_window_end THEN next_assistant_at
|
|
218
|
-
ELSE max_window_end
|
|
219
|
-
END AS window_end
|
|
220
|
-
FROM event_windows
|
|
221
|
-
)
|
|
222
|
-
SELECT
|
|
223
|
-
b.model_id AS model_id,
|
|
224
|
-
COUNT(*) AS events,
|
|
225
|
-
SUM(CASE WHEN EXISTS (
|
|
226
|
-
SELECT 1 FROM tool_calls t
|
|
227
|
-
WHERE t.session_id = b.session_id
|
|
228
|
-
AND t.created_at > b.created_at
|
|
229
|
-
AND t.created_at <= b.window_end
|
|
230
|
-
AND t.outcome = 'success'
|
|
231
|
-
) THEN 1 ELSE 0 END) AS success_windows,
|
|
232
|
-
SUM(CASE WHEN EXISTS (
|
|
233
|
-
SELECT 1 FROM tool_calls t
|
|
234
|
-
WHERE t.session_id = b.session_id
|
|
235
|
-
AND t.created_at > b.created_at
|
|
236
|
-
AND t.created_at <= b.window_end
|
|
237
|
-
AND t.outcome = 'failure'
|
|
238
|
-
) THEN 1 ELSE 0 END) AS failure_windows,
|
|
239
|
-
SUM(CASE WHEN EXISTS (
|
|
240
|
-
SELECT 1 FROM pain_events p
|
|
241
|
-
WHERE p.session_id = b.session_id
|
|
242
|
-
AND p.created_at > b.created_at
|
|
243
|
-
AND p.created_at <= b.window_end
|
|
244
|
-
) THEN 1 ELSE 0 END) AS pain_windows,
|
|
245
|
-
SUM(CASE WHEN EXISTS (
|
|
246
|
-
SELECT 1 FROM user_turns u
|
|
247
|
-
WHERE u.session_id = b.session_id
|
|
248
|
-
AND u.created_at > b.created_at
|
|
249
|
-
AND u.created_at <= b.window_end
|
|
250
|
-
AND u.correction_detected = 1
|
|
251
|
-
) THEN 1 ELSE 0 END) AS correction_windows,
|
|
252
|
-
SUM(CASE WHEN EXISTS (
|
|
253
|
-
SELECT 1 FROM correction_samples c
|
|
254
|
-
WHERE c.session_id = b.session_id
|
|
255
|
-
AND c.created_at > b.created_at
|
|
256
|
-
AND c.created_at <= b.window_end
|
|
257
|
-
) THEN 1 ELSE 0 END) AS correction_sample_windows
|
|
258
|
-
FROM bounded_windows b
|
|
259
|
-
GROUP BY b.model_id
|
|
260
|
-
ORDER BY events DESC, model_id ASC;
|
|
261
|
-
|
|
262
|
-
DROP VIEW IF EXISTS v_thinking_model_scenarios;
|
|
263
|
-
CREATE VIEW v_thinking_model_scenarios AS
|
|
264
|
-
SELECT
|
|
265
|
-
e.model_id AS model_id,
|
|
266
|
-
CAST(j.value AS TEXT) AS scenario,
|
|
267
|
-
COUNT(*) AS hits
|
|
268
|
-
FROM thinking_model_events e
|
|
269
|
-
JOIN json_each(
|
|
270
|
-
CASE
|
|
271
|
-
WHEN json_valid(e.scenario_json) THEN e.scenario_json
|
|
272
|
-
ELSE '[]'
|
|
273
|
-
END
|
|
274
|
-
) AS j
|
|
275
|
-
GROUP BY e.model_id, CAST(j.value AS TEXT)
|
|
276
|
-
ORDER BY hits DESC, scenario ASC;
|
|
277
|
-
|
|
278
|
-
DROP VIEW IF EXISTS v_thinking_model_daily_trend;
|
|
279
|
-
CREATE VIEW v_thinking_model_daily_trend AS
|
|
280
|
-
SELECT
|
|
281
|
-
substr(created_at, 1, 10) AS day,
|
|
282
|
-
model_id,
|
|
283
|
-
COUNT(*) AS hits
|
|
284
|
-
FROM thinking_model_events
|
|
285
|
-
GROUP BY substr(created_at, 1, 10), model_id
|
|
286
|
-
ORDER BY day ASC, model_id ASC;
|
|
287
|
-
`);
|
|
288
|
-
}
|
|
289
|
-
withWrite(fn) {
|
|
290
|
-
return withLock(this.dbPath, fn, { lockSuffix: '.trajectory.lock', lockStaleMs: 30000 });
|
|
291
|
-
}
|
|
292
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type PainDictionary } from './dictionary.js';
|
|
2
|
-
export interface DetectionResult {
|
|
3
|
-
detected: boolean;
|
|
4
|
-
severity?: number;
|
|
5
|
-
ruleId?: string;
|
|
6
|
-
source: 'l1_exact' | 'l2_cache' | 'l3_async_queued' | 'l3_semantic_hit';
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Orchestrates the three-layer detection funnel for pain signals.
|
|
10
|
-
*/
|
|
11
|
-
export declare class DetectionFunnel {
|
|
12
|
-
private dictionary;
|
|
13
|
-
private cache;
|
|
14
|
-
private asyncQueue;
|
|
15
|
-
constructor(dictionary: PainDictionary);
|
|
16
|
-
/**
|
|
17
|
-
* Detects pain in the given text using L1 (Exact), L2 (Cache), and L3 (Async).
|
|
18
|
-
*/
|
|
19
|
-
detect(text: string): DetectionResult;
|
|
20
|
-
private computeHash;
|
|
21
|
-
private enqueueAsync;
|
|
22
|
-
/**
|
|
23
|
-
* Internal method for the worker to update the cache after a semantic hit.
|
|
24
|
-
*/
|
|
25
|
-
updateCache(text: string, result: {
|
|
26
|
-
detected: boolean;
|
|
27
|
-
severity?: number;
|
|
28
|
-
}): void;
|
|
29
|
-
/**
|
|
30
|
-
* Retrieves and clears the current asynchronous queue.
|
|
31
|
-
*/
|
|
32
|
-
flushQueue(): string[];
|
|
33
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DetectionFunnel } from './detection-funnel.js';
|
|
2
|
-
/**
|
|
3
|
-
* Singleton service to manage the Semantic Detection Funnel.
|
|
4
|
-
*/
|
|
5
|
-
export declare const DetectionService: {
|
|
6
|
-
/**
|
|
7
|
-
* Gets or initializes the Detection Funnel instance.
|
|
8
|
-
* @param stateDir The directory used to initialize the dictionary.
|
|
9
|
-
*/
|
|
10
|
-
get(stateDir: string): DetectionFunnel;
|
|
11
|
-
/**
|
|
12
|
-
* Resets the singleton instance (primarily for testing).
|
|
13
|
-
*/
|
|
14
|
-
reset(): void;
|
|
15
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { PainDictionary } from './dictionary.js';
|
|
2
|
-
/**
|
|
3
|
-
* Singleton service to manage the Pain Dictionary.
|
|
4
|
-
*/
|
|
5
|
-
export declare const DictionaryService: {
|
|
6
|
-
/**
|
|
7
|
-
* Gets or initializes the Pain Dictionary instance.
|
|
8
|
-
* @param stateDir The directory where the dictionary JSON is stored.
|
|
9
|
-
*/
|
|
10
|
-
get(stateDir: string): PainDictionary;
|
|
11
|
-
/**
|
|
12
|
-
* Resets the singleton instance (primarily for testing).
|
|
13
|
-
*/
|
|
14
|
-
reset(): void;
|
|
15
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export type RuleType = 'regex' | 'exact_match';
|
|
2
|
-
export interface PainRule {
|
|
3
|
-
type: RuleType;
|
|
4
|
-
pattern?: string;
|
|
5
|
-
phrases?: string[];
|
|
6
|
-
severity: number;
|
|
7
|
-
hits: number;
|
|
8
|
-
status: 'active' | 'dormant' | 'archived';
|
|
9
|
-
}
|
|
10
|
-
export interface PainDictionaryData {
|
|
11
|
-
rules: Record<string, PainRule>;
|
|
12
|
-
}
|
|
13
|
-
export declare const PAIN_PROTOCOL_TOKENS: readonly ["[EVOLUTION_ACK]", "HEARTBEAT_OK", "HEARTBEAT_CHECK"];
|
|
14
|
-
export declare function shouldIgnorePainProtocolText(text: string): boolean;
|
|
15
|
-
export declare class PainDictionary {
|
|
16
|
-
private stateDir;
|
|
17
|
-
private data;
|
|
18
|
-
private filePath;
|
|
19
|
-
private compiledRegex;
|
|
20
|
-
constructor(stateDir: string);
|
|
21
|
-
load(): void;
|
|
22
|
-
private compile;
|
|
23
|
-
getRule(id: string): PainRule | undefined;
|
|
24
|
-
getAllRules(): Record<string, PainRule>;
|
|
25
|
-
/**
|
|
26
|
-
* Adds a new rule or updates an existing one.
|
|
27
|
-
*/
|
|
28
|
-
addRule(id: string, rule: Omit<PainRule, 'hits'>): void;
|
|
29
|
-
match(text: string): {
|
|
30
|
-
ruleId: string;
|
|
31
|
-
severity: number;
|
|
32
|
-
} | undefined;
|
|
33
|
-
flush(): void;
|
|
34
|
-
getStats(): {
|
|
35
|
-
totalRules: number;
|
|
36
|
-
totalHits: number;
|
|
37
|
-
};
|
|
38
|
-
}
|
package/dist/core/event-log.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { EventLogEntry, DailyStats, EmpathyEventStats, ToolCallEventData, PainSignalEventData, RuleMatchEventData, RulePromotionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, PlanApprovalEventData, EvolutionTaskEventData, DeepReflectionEventData, EmpathyRollbackEventData } from '../types/event-types.js';
|
|
2
|
-
import type { PluginLogger } from '../openclaw-sdk.js';
|
|
3
|
-
/**
|
|
4
|
-
* EventLog - Structured event logging with daily statistics aggregation.
|
|
5
|
-
*/
|
|
6
|
-
export declare class EventLog {
|
|
7
|
-
private readonly eventsFile;
|
|
8
|
-
private readonly statsFile;
|
|
9
|
-
private readonly logger?;
|
|
10
|
-
private statsCache;
|
|
11
|
-
private eventBuffer;
|
|
12
|
-
private readonly maxBufferSize;
|
|
13
|
-
private readonly flushIntervalMs;
|
|
14
|
-
private flushTimer?;
|
|
15
|
-
constructor(stateDir: string, logger?: PluginLogger);
|
|
16
|
-
recordToolCall(sessionId: string | undefined, data: ToolCallEventData): void;
|
|
17
|
-
recordPainSignal(sessionId: string | undefined, data: PainSignalEventData): void;
|
|
18
|
-
recordRuleMatch(sessionId: string | undefined, data: RuleMatchEventData): void;
|
|
19
|
-
recordRulePromotion(data: RulePromotionEventData): void;
|
|
20
|
-
recordHookExecution(data: HookExecutionEventData): void;
|
|
21
|
-
recordGateBlock(sessionId: string | undefined, data: GateBlockEventData): void;
|
|
22
|
-
recordGateBypass(sessionId: string | undefined, data: GateBypassEventData): void;
|
|
23
|
-
recordPlanApproval(sessionId: string | undefined, data: PlanApprovalEventData): void;
|
|
24
|
-
recordEvolutionTask(data: EvolutionTaskEventData): void;
|
|
25
|
-
recordDeepReflection(sessionId: string | undefined, data: DeepReflectionEventData): void;
|
|
26
|
-
recordEmpathyRollback(sessionId: string | undefined, data: EmpathyRollbackEventData): void;
|
|
27
|
-
recordError(sessionId: string | undefined, message: string, context?: Record<string, unknown>): void;
|
|
28
|
-
recordWarn(sessionId: string | undefined, message: string, context?: Record<string, unknown>): void;
|
|
29
|
-
private record;
|
|
30
|
-
private formatDate;
|
|
31
|
-
private loadStats;
|
|
32
|
-
private updateStats;
|
|
33
|
-
private startFlushTimer;
|
|
34
|
-
flush(): void;
|
|
35
|
-
/**
|
|
36
|
-
* Return in-memory buffered events that have not been flushed yet.
|
|
37
|
-
* Intended for live runtime summaries that should not lag behind disk snapshots.
|
|
38
|
-
*/
|
|
39
|
-
getBufferedEvents(): EventLogEntry[];
|
|
40
|
-
private getEventDedupKey;
|
|
41
|
-
private readPersistedEvents;
|
|
42
|
-
private getMergedEvents;
|
|
43
|
-
private flushEvents;
|
|
44
|
-
private flushStats;
|
|
45
|
-
/**
|
|
46
|
-
* Get daily statistics for a specific date.
|
|
47
|
-
* Returns empty stats if no events recorded for that date.
|
|
48
|
-
*/
|
|
49
|
-
getDailyStats(date: string): DailyStats;
|
|
50
|
-
/**
|
|
51
|
-
* Get aggregated empathy statistics for multiple time ranges.
|
|
52
|
-
* @param range 'today' | 'week' | 'session'
|
|
53
|
-
* @param sessionId Optional session ID for session-scoped stats
|
|
54
|
-
*/
|
|
55
|
-
getEmpathyStats(range: 'today' | 'week' | 'session', sessionId?: string): EmpathyEventStats;
|
|
56
|
-
/**
|
|
57
|
-
* Aggregate empathy stats for a specific session.
|
|
58
|
-
*/
|
|
59
|
-
private aggregateSessionEmpathy;
|
|
60
|
-
/**
|
|
61
|
-
* Rollback an empathy event by ID.
|
|
62
|
-
* Returns the rolled back score, or 0 if event not found.
|
|
63
|
-
*/
|
|
64
|
-
rollbackEmpathyEvent(eventId: string, sessionId: string | undefined, reason: string, triggeredBy: 'user_command' | 'natural_language' | 'system'): number;
|
|
65
|
-
/**
|
|
66
|
-
* Get the last empathy event ID for a session (for rollback).
|
|
67
|
-
*/
|
|
68
|
-
getLastEmpathyEventId(sessionId: string): string | null;
|
|
69
|
-
/**
|
|
70
|
-
* Dispose of the EventLog, flushing pending data and clearing timer.
|
|
71
|
-
*/
|
|
72
|
-
dispose(): void;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Service to manage multiple EventLog instances by stateDir.
|
|
76
|
-
*/
|
|
77
|
-
export declare class EventLogService {
|
|
78
|
-
private static instances;
|
|
79
|
-
static get(stateDir: string, logger?: PluginLogger): EventLog;
|
|
80
|
-
static flushAll(): void;
|
|
81
|
-
static disposeAll(): void;
|
|
82
|
-
}
|