create-principles-disciple 1.150.4 → 1.151.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/README.md +5 -5
- package/_release/product-identity.json +1 -1
- package/codex-adapter/dist/ingestion/codex-version.d.ts +14 -12
- package/codex-adapter/dist/ingestion/codex-version.js +19 -20
- package/codex-adapter/dist/ingestion/ingestion.js +25 -4
- package/codex-adapter/dist/ingestion/transcript-decoder.d.ts +5 -3
- package/codex-adapter/dist/ingestion/transcript-decoder.js +61 -5
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/bind-guard.d.ts +6 -13
- package/console/dist/server/bind-guard.js +8 -17
- package/console/dist/server/index.d.ts +9 -3
- package/console/dist/server/index.js +69 -55
- package/console/dist/server/models/ActivationsConsoleModel.js +5 -3
- package/console/dist/server/models/ApprovalsConsoleModel.js +2 -1
- package/console/dist/server/models/ApprovalsGroupedConsoleModel.js +2 -1
- package/console/dist/server/models/EvidenceChainConsoleModel.d.ts +46 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.js +121 -2
- package/console/dist/server/models/GovernanceConsoleModel.js +3 -2
- package/console/dist/server/models/GovernanceExperienceCollector.js +2 -1
- package/console/dist/server/models/GovernanceProjectionCollector.js +2 -1
- package/console/dist/server/models/IngestionHealthModel.d.ts +34 -0
- package/console/dist/server/models/IngestionHealthModel.js +254 -0
- package/console/dist/server/models/IntentDecisionModel.js +2 -2
- package/console/dist/server/models/IntentPageModel.js +2 -1
- package/console/dist/server/models/OwnerDecisionConsoleModel.js +61 -22
- package/console/dist/server/models/OwnerDecisionViewModel.js +2 -2
- package/console/dist/server/models/PrincipleTrajectoryModel.js +2 -1
- package/console/dist/server/models/ReceiptsConsoleModel.js +2 -2
- package/console/dist/server/models/RuleCandidateBindingConsoleModel.js +3 -2
- package/console/dist/server/routes/activations.js +2 -2
- package/console/dist/server/routes/diagnostician.js +3 -2
- package/console/dist/server/routes/evidence-chain.d.ts +4 -0
- package/console/dist/server/routes/evidence-chain.js +22 -0
- package/console/dist/server/routes/evidence-outcomes.d.ts +3 -2
- package/console/dist/server/routes/evidence-outcomes.js +1 -1
- package/console/dist/server/routes/failed-tasks.js +79 -3
- package/console/dist/server/routes/governance.d.ts +9 -6
- package/console/dist/server/routes/governance.js +10 -6
- package/console/dist/server/routes/health.d.ts +8 -0
- package/console/dist/server/routes/health.js +72 -0
- package/console/dist/server/routes/owner-decisions.d.ts +3 -3
- package/console/dist/server/routes/owner-decisions.js +1 -1
- package/console/dist/server/routes/owner-identity.d.ts +10 -5
- package/console/dist/server/routes/owner-identity.js +11 -7
- package/console/dist/server/routes/principles.js +3 -3
- package/console/dist/server/routes/rule-candidate-bindings.js +1 -1
- package/console/dist/server/routes/update.js +24 -6
- package/console/dist/server/utils/request-guard.d.ts +35 -0
- package/console/dist/server/utils/request-guard.js +81 -0
- package/console/dist/server/utils/response.d.ts +0 -1
- package/console/dist/server/utils/response.js +0 -3
- package/console/dist/web/assets/app.css +98 -167
- package/console/dist/web/assets/app.js +34 -37
- package/core/dist/runtime/activation/activation-control-types.d.ts +3 -0
- package/core/dist/runtime/activation/activation-control-types.d.ts.map +1 -1
- package/core/dist/runtime/activation/adaptive-selection-output.d.ts +0 -21
- package/core/dist/runtime/activation/adaptive-selection-output.d.ts.map +1 -1
- package/core/dist/runtime/activation/adaptive-selection-output.js.map +1 -1
- package/core/dist/runtime/activation/index.d.ts +2 -6
- package/core/dist/runtime/activation/index.d.ts.map +1 -1
- package/core/dist/runtime/activation/index.js.map +1 -1
- package/core/dist/runtime/activation/production-gate-deps.d.ts +2 -1
- package/core/dist/runtime/activation/production-gate-deps.d.ts.map +1 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts +2 -1
- package/core/dist/runtime/activation/prompt-activation-reader-contract.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.d.ts.map +1 -1
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js +3 -2
- package/core/dist/runtime/activation/rulecode-owner-decision-service.js.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.d.ts.map +1 -1
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js +26 -13
- package/core/dist/runtime/activation/sqlite-activation-safety-store.js.map +1 -1
- package/core/dist/runtime/activation/writers/index.d.ts +0 -1
- package/core/dist/runtime/activation/writers/index.d.ts.map +1 -1
- package/core/dist/runtime/activation/writers/rule-host-writer.d.ts.map +1 -1
- package/core/dist/runtime/activation/writers/rule-host-writer.js +15 -6
- package/core/dist/runtime/activation/writers/rule-host-writer.js.map +1 -1
- package/core/dist/runtime/activation-compatibility-read-model.d.ts +3 -2
- package/core/dist/runtime/activation-compatibility-read-model.d.ts.map +1 -1
- package/core/dist/runtime/adapter/context-budget.d.ts +3 -14
- package/core/dist/runtime/adapter/context-budget.d.ts.map +1 -1
- package/core/dist/runtime/adapter/context-budget.js +2 -2
- package/core/dist/runtime/adapter/context-budget.js.map +1 -1
- package/core/dist/runtime/adapter/index.d.ts +1 -2
- package/core/dist/runtime/adapter/index.d.ts.map +1 -1
- package/core/dist/runtime/adapter/index.js +1 -1
- package/core/dist/runtime/adapter/index.js.map +1 -1
- package/core/dist/runtime/adapter/output-repair-contract.d.ts +18 -1
- package/core/dist/runtime/adapter/output-repair-contract.d.ts.map +1 -1
- package/core/dist/runtime/adapter/output-repair-contract.js +94 -0
- package/core/dist/runtime/adapter/output-repair-contract.js.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts +2 -3
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js +27 -10
- package/core/dist/runtime/adapter/pi-ai-runtime-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts +1 -1
- package/core/dist/runtime/adapter/principle-tree-ledger-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts +0 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.d.ts.map +1 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.js +43 -1
- package/core/dist/runtime/adapter/schema-prompt-adapter.js.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.d.ts +17 -2
- package/core/dist/runtime/adapter/structured-output-repair.d.ts.map +1 -1
- package/core/dist/runtime/adapter/structured-output-repair.js +26 -5
- package/core/dist/runtime/adapter/structured-output-repair.js.map +1 -1
- package/core/dist/runtime/bridge-result-shaper.d.ts +1 -1
- package/core/dist/runtime/bridge-result-shaper.d.ts.map +1 -1
- package/core/dist/runtime/candidate-intake-service.d.ts +2 -1
- package/core/dist/runtime/candidate-intake-service.d.ts.map +1 -1
- package/core/dist/runtime/cli/diagnose.d.ts +4 -3
- package/core/dist/runtime/cli/diagnose.d.ts.map +1 -1
- package/core/dist/runtime/config/index.d.ts +2 -2
- package/core/dist/runtime/config/index.d.ts.map +1 -1
- package/core/dist/runtime/config/index.js +3 -3
- package/core/dist/runtime/config/index.js.map +1 -1
- package/core/dist/runtime/config/pd-config-defaults.d.ts +0 -2
- package/core/dist/runtime/config/pd-config-defaults.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-defaults.js +2 -2
- package/core/dist/runtime/config/pd-config-defaults.js.map +1 -1
- package/core/dist/runtime/config/pd-config-types.d.ts +2 -0
- package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-types.js.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-config-validate.js +10 -1
- package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
- package/core/dist/runtime/config/pd-profile-constants.d.ts +1 -7
- package/core/dist/runtime/config/pd-profile-constants.d.ts.map +1 -1
- package/core/dist/runtime/config/pd-profile-constants.js +5 -6
- package/core/dist/runtime/config/pd-profile-constants.js.map +1 -1
- package/core/dist/runtime/config/pd-validate-profile.d.ts +3 -2
- package/core/dist/runtime/config/pd-validate-profile.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.d.ts +0 -7
- package/core/dist/runtime/context-payload.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.js +1 -1
- package/core/dist/runtime/context-payload.js.map +1 -1
- package/core/dist/runtime/core-principles/index.d.ts +1 -1
- package/core/dist/runtime/core-principles/index.d.ts.map +1 -1
- package/core/dist/runtime/correction/correction-types.d.ts +0 -10
- package/core/dist/runtime/correction/correction-types.d.ts.map +1 -1
- package/core/dist/runtime/correction/correction-types.js.map +1 -1
- package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts +0 -3
- package/core/dist/runtime/diagnostician/diag-distiller-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/diag-distiller-output.js +1 -1
- package/core/dist/runtime/diagnostician/diag-distiller-output.js.map +1 -1
- package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts +3 -11
- package/core/dist/runtime/diagnostician/diag-rootcause-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/diag-rootcause-output.js +3 -3
- package/core/dist/runtime/diagnostician/diag-rootcause-output.js.map +1 -1
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts +5 -4
- package/core/dist/runtime/diagnostician/distiller-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts +2 -1
- package/core/dist/runtime/diagnostician/evidence-ref-binding.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts +2 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts +22 -3
- package/core/dist/runtime/diagnostician/router-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.js +11 -1
- package/core/dist/runtime/diagnostician/router-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician-association-shadow.d.ts +2 -2
- package/core/dist/runtime/diagnostician-association-shadow.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-association-validation.d.ts +3 -2
- package/core/dist/runtime/diagnostician-association-validation.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-output.d.ts +32 -5
- package/core/dist/runtime/diagnostician-output.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-output.js +47 -4
- package/core/dist/runtime/diagnostician-output.js.map +1 -1
- package/core/dist/runtime/diagnostician-prompt-builder.d.ts +2 -1
- package/core/dist/runtime/diagnostician-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/error-categories.d.ts.map +1 -1
- package/core/dist/runtime/error-categories.js +10 -1
- package/core/dist/runtime/error-categories.js.map +1 -1
- package/core/dist/runtime/evidence-sanitizer.d.ts +8 -1
- package/core/dist/runtime/evidence-sanitizer.d.ts.map +1 -1
- package/core/dist/runtime/evidence-sanitizer.js +10 -3
- package/core/dist/runtime/evidence-sanitizer.js.map +1 -1
- package/core/dist/runtime/evolution/evolution-types.d.ts +0 -26
- package/core/dist/runtime/evolution/evolution-types.d.ts.map +1 -1
- package/core/dist/runtime/evolution/evolution-types.js.map +1 -1
- package/core/dist/runtime/feature-flags/index.d.ts +0 -1
- package/core/dist/runtime/feature-flags/index.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/index.js.map +1 -1
- package/core/dist/runtime/golden-trace.d.ts +9 -1
- package/core/dist/runtime/golden-trace.d.ts.map +1 -1
- package/core/dist/runtime/golden-trace.js +7 -0
- package/core/dist/runtime/golden-trace.js.map +1 -1
- package/core/dist/runtime/governance-experience-contract.d.ts +12 -12
- package/core/dist/runtime/governance-experience-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience-contract.js +0 -2
- package/core/dist/runtime/governance-experience-contract.js.map +1 -1
- package/core/dist/runtime/governance-experience.d.ts.map +1 -1
- package/core/dist/runtime/governance-experience.js +8 -16
- package/core/dist/runtime/governance-experience.js.map +1 -1
- package/core/dist/runtime/governance-projection-contract.d.ts +0 -6
- package/core/dist/runtime/governance-projection-contract.d.ts.map +1 -1
- package/core/dist/runtime/governance-projection-contract.js +3 -3
- package/core/dist/runtime/governance-projection-contract.js.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.d.ts.map +1 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js +2 -1
- package/core/dist/runtime/internalization/approved-rule-revision.js.map +1 -1
- package/core/dist/runtime/internalization/artifact-summary.d.ts +5 -4
- package/core/dist/runtime/internalization/artifact-summary.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artifact-summary.js +1 -1
- package/core/dist/runtime/internalization/artifact-summary.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts +1 -1
- package/core/dist/runtime/internalization/artificer-intent-preflight.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-output.d.ts +0 -2
- package/core/dist/runtime/internalization/artificer-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-output.js +17 -0
- package/core/dist/runtime/internalization/artificer-output.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts +14 -3
- package/core/dist/runtime/internalization/artificer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/artificer-prompt-builder.js +13 -1
- package/core/dist/runtime/internalization/artificer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/artificer-run-correlation.d.ts +3 -2
- package/core/dist/runtime/internalization/artificer-run-correlation.d.ts.map +1 -1
- package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts +2 -1
- package/core/dist/runtime/internalization/consumer-evidence-preflight.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts +11 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.js +105 -1
- package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-output.d.ts +0 -9
- package/core/dist/runtime/internalization/dreamer-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-output.js +1 -1
- package/core/dist/runtime/internalization/dreamer-output.js.map +1 -1
- package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts +3 -2
- package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts +1 -1
- package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-output.d.ts +7 -17
- package/core/dist/runtime/internalization/evaluator-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-output.js +2 -2
- package/core/dist/runtime/internalization/evaluator-output.js.map +1 -1
- package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts +3 -9
- package/core/dist/runtime/internalization/evaluator-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/evaluator-prompt-builder.js +1 -1
- package/core/dist/runtime/internalization/evaluator-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/formation-context.d.ts +4 -6
- package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
- package/core/dist/runtime/internalization/formation-context.js +3 -3
- package/core/dist/runtime/internalization/formation-context.js.map +1 -1
- package/core/dist/runtime/internalization/index.d.ts +2 -4
- package/core/dist/runtime/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime/internalization/index.js +8 -1
- package/core/dist/runtime/internalization/index.js.map +1 -1
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +2 -1
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
- package/core/dist/runtime/internalization/intent-contract.d.ts +2 -1
- package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-job-graph.d.ts +1 -1
- package/core/dist/runtime/internalization/internalization-job-graph.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-route.d.ts +2 -1
- package/core/dist/runtime/internalization/internalization-route.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-decision-review.d.ts +3 -2
- package/core/dist/runtime/internalization/owner-decision-review.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-resolution-service.d.ts +2 -1
- package/core/dist/runtime/internalization/owner-resolution-service.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-retry.d.ts +2 -1
- package/core/dist/runtime/internalization/owner-retry.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-review.d.ts +2 -21
- package/core/dist/runtime/internalization/owner-review.d.ts.map +1 -1
- package/core/dist/runtime/internalization/owner-review.js +2 -2
- package/core/dist/runtime/internalization/owner-review.js.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts +2 -5
- package/core/dist/runtime/internalization/peer-runner-contracts.d.ts.map +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js +1 -1
- package/core/dist/runtime/internalization/peer-runner-contracts.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-output.d.ts +0 -8
- package/core/dist/runtime/internalization/philosopher-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/philosopher-output.js +1 -1
- package/core/dist/runtime/internalization/philosopher-output.js.map +1 -1
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts +3 -2
- package/core/dist/runtime/internalization/philosopher-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/pitask-metadata.d.ts +2 -2
- package/core/dist/runtime/internalization/pitask-metadata.d.ts.map +1 -1
- package/core/dist/runtime/internalization/repair-replay-resolver.d.ts +4 -3
- package/core/dist/runtime/internalization/repair-replay-resolver.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts +2 -3
- package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts +0 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js +1 -1
- package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/router-context-reconstruction.d.ts +3 -3
- package/core/dist/runtime/internalization/router-context-reconstruction.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-activation-contract.d.ts +3 -2
- package/core/dist/runtime/internalization/rule-activation-contract.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-reliability-validation.d.ts +13 -18
- package/core/dist/runtime/internalization/rule-reliability-validation.d.ts.map +1 -1
- package/core/dist/runtime/internalization/rule-reliability-validation.js +43 -1
- package/core/dist/runtime/internalization/rule-reliability-validation.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-output.d.ts +2 -15
- package/core/dist/runtime/internalization/scribe-output.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-output.js +2 -2
- package/core/dist/runtime/internalization/scribe-output.js.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +3 -3
- package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js +0 -1
- package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts +17 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js +98 -3
- package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime/internalization/textual-basis-anchor.d.ts +3 -6
- package/core/dist/runtime/internalization/textual-basis-anchor.d.ts.map +1 -1
- package/core/dist/runtime/internalization/textual-basis-anchor.js +2 -2
- package/core/dist/runtime/internalization/textual-basis-anchor.js.map +1 -1
- package/core/dist/runtime/language-directive.d.ts +2 -1
- package/core/dist/runtime/language-directive.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts +3 -29
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.js +4 -5
- package/core/dist/runtime/owner-decision/owner-decision-view-contract.js.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view.d.ts +0 -49
- package/core/dist/runtime/owner-decision/owner-decision-view.d.ts.map +1 -1
- package/core/dist/runtime/owner-decision/owner-decision-view.js +5 -5
- package/core/dist/runtime/owner-decision/owner-decision-view.js.map +1 -1
- package/core/dist/runtime/owner-decision/semantic-selector.d.ts +3 -2
- package/core/dist/runtime/owner-decision/semantic-selector.d.ts.map +1 -1
- package/core/dist/runtime/owner-identity.d.ts +12 -1
- package/core/dist/runtime/owner-identity.d.ts.map +1 -1
- package/core/dist/runtime/owner-identity.js +19 -1
- package/core/dist/runtime/owner-identity.js.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.d.ts +0 -39
- package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.js +4 -4
- package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
- package/core/dist/runtime/pain-ingress.d.ts +1 -1
- package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress.js.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts +0 -2
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +1 -1
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts +3 -3
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts +3 -2
- package/core/dist/runtime/principle-reuse/reuse-proposal.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts +0 -10
- package/core/dist/runtime/principle-reuse/reuse-retrieval.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-retrieval.js +1 -1
- package/core/dist/runtime/principle-reuse/reuse-retrieval.js.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts +1 -8
- package/core/dist/runtime/principle-reuse/reuse-shortlist.d.ts.map +1 -1
- package/core/dist/runtime/principle-reuse/reuse-shortlist.js +1 -1
- package/core/dist/runtime/principle-reuse/reuse-shortlist.js.map +1 -1
- package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts +3 -2
- package/core/dist/runtime/product-telemetry/snapshot-contract.d.ts.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.d.ts +7 -0
- package/core/dist/runtime/recovery-sweep-service.d.ts.map +1 -1
- package/core/dist/runtime/recovery-sweep-service.js +1 -0
- package/core/dist/runtime/recovery-sweep-service.js.map +1 -1
- package/core/dist/runtime/runner/base-peer-runner.d.ts +32 -0
- package/core/dist/runtime/runner/base-peer-runner.d.ts.map +1 -1
- package/core/dist/runtime/runner/base-peer-runner.js +168 -16
- package/core/dist/runtime/runner/base-peer-runner.js.map +1 -1
- package/core/dist/runtime/runner/default-validator.d.ts +0 -1
- package/core/dist/runtime/runner/default-validator.d.ts.map +1 -1
- package/core/dist/runtime/runner/default-validator.js +11 -3
- package/core/dist/runtime/runner/default-validator.js.map +1 -1
- package/core/dist/runtime/runner/peer-runner-types.d.ts +11 -0
- package/core/dist/runtime/runner/peer-runner-types.d.ts.map +1 -1
- package/core/dist/runtime/storage-paths.d.ts +15 -0
- package/core/dist/runtime/storage-paths.d.ts.map +1 -0
- package/core/dist/runtime/storage-paths.js +15 -0
- package/core/dist/runtime/storage-paths.js.map +1 -0
- package/core/dist/runtime/store/artifact/index.d.ts +1 -1
- package/core/dist/runtime/store/artifact/index.d.ts.map +1 -1
- package/core/dist/runtime/store/candidate/admission-document.d.ts +4 -3
- package/core/dist/runtime/store/candidate/admission-document.d.ts.map +1 -1
- package/core/dist/runtime/store/commit/index.d.ts +0 -1
- package/core/dist/runtime/store/commit/index.d.ts.map +1 -1
- package/core/dist/runtime/store/commit/index.js.map +1 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +59 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js +201 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -0
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.js +43 -2
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts +4 -3
- package/core/dist/runtime/store/design-gate/sqlite-design-gate-store.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +2 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +1 -2
- package/core/dist/runtime/store/runtime-state-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.js.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts +2 -1
- package/core/dist/runtime/store/sqlite-connection.d.ts.map +1 -1
- package/core/dist/runtime/store/sqlite-connection.js +96 -37
- package/core/dist/runtime/store/sqlite-connection.js.map +1 -1
- package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts +2 -1
- package/core/dist/runtime/store/task/sqlite-family-reopen.d.ts.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts +2 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime/story-a-demo.d.ts.map +1 -1
- package/core/dist/runtime/story-a-demo.js +4 -1
- package/core/dist/runtime/story-a-demo.js.map +1 -1
- package/core/dist/runtime/tools/agent-tool-contract.d.ts +1 -2
- package/core/dist/runtime/tools/agent-tool-contract.d.ts.map +1 -1
- package/core/dist/runtime/tools/agent-tool-contract.js +0 -2
- package/core/dist/runtime/tools/agent-tool-contract.js.map +1 -1
- package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts +0 -2
- package/core/dist/runtime/tools/artificer-l2-tool-contract.d.ts.map +1 -1
- package/core/dist/runtime/tools/artificer-l2-tool-contract.js +0 -2
- package/core/dist/runtime/tools/artificer-l2-tool-contract.js.map +1 -1
- package/core/dist/runtime/types/event-payload.d.ts +0 -2
- package/core/dist/runtime/types/event-payload.d.ts.map +1 -1
- package/core/dist/runtime/types/event-payload.js.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.d.ts +66 -2
- package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.js +69 -4
- package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
- package/core/dist/runtime/types/hygiene-types.d.ts +0 -6
- package/core/dist/runtime/types/hygiene-types.d.ts.map +1 -1
- package/core/dist/runtime/types/hygiene-types.js.map +1 -1
- package/core/dist/runtime/types/index.d.ts +1 -1
- package/core/dist/runtime/types/index.d.ts.map +1 -1
- package/core/dist/runtime/types/index.js.map +1 -1
- package/core/dist/runtime/types/intervention-evidence-contract.d.ts +5 -5
- package/core/dist/runtime/types/intervention-evidence-contract.d.ts.map +1 -1
- package/core/dist/runtime/types/intervention-evidence-contract.js +0 -2
- package/core/dist/runtime/types/intervention-evidence-contract.js.map +1 -1
- package/core/dist/runtime/types/principle-dependency.d.ts +0 -2
- package/core/dist/runtime/types/principle-dependency.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-dependency.js.map +1 -1
- package/core/dist/runtime/types/principle-lifecycle-event.d.ts +0 -2
- package/core/dist/runtime/types/principle-lifecycle-event.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-lifecycle-event.js.map +1 -1
- package/core/dist/runtime/types/principle-schema.d.ts +0 -26
- package/core/dist/runtime/types/principle-schema.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-schema.js +2 -2
- package/core/dist/runtime/types/principle-schema.js.map +1 -1
- package/core/dist/runtime/types/principle-tree-store.d.ts +0 -2
- package/core/dist/runtime/types/principle-tree-store.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-tree-store.js.map +1 -1
- package/core/dist/runtime/types/principle-value-metrics.d.ts +0 -2
- package/core/dist/runtime/types/principle-value-metrics.d.ts.map +1 -1
- package/core/dist/runtime/types/principle-value-metrics.js.map +1 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts +2 -1
- package/core/dist/runtime/types/rule-candidate-binding.d.ts.map +1 -1
- package/core/dist/telemetry-event.d.ts +2 -2
- package/core/dist/telemetry-event.d.ts.map +1 -1
- package/core/dist/telemetry-event.js +11 -0
- package/core/dist/telemetry-event.js.map +1 -1
- package/core/package.json +5 -1
- package/dist/installer.d.ts +14 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +36 -77
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +9 -0
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +35 -1
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/mvp-config.js +1 -1
- package/dist/mvp-config.js.map +1 -1
- package/dist/update/data-compatibility.d.ts.map +1 -1
- package/dist/update/data-compatibility.js +3 -1
- package/dist/update/data-compatibility.js.map +1 -1
- package/dist/update/product-identity.d.ts.map +1 -1
- package/dist/update/product-identity.js +5 -1
- package/dist/update/product-identity.js.map +1 -1
- package/dist/update/release-manager.d.ts +5 -0
- package/dist/update/release-manager.d.ts.map +1 -1
- package/dist/update/release-manager.js +11 -1
- package/dist/update/release-manager.js.map +1 -1
- package/host-runtime/dist/active-principle-prompt.d.ts +7 -2
- package/host-runtime/dist/active-principle-prompt.js +80 -13
- package/host-runtime/dist/adaptive-decision-protocol.d.ts +36 -21
- package/host-runtime/dist/adaptive-decision-protocol.js +79 -34
- package/host-runtime/dist/adaptive-priority-provider.d.ts +2 -1
- package/host-runtime/dist/adaptive-priority-provider.js +6 -5
- package/host-runtime/dist/adaptive-selection.d.ts +4 -0
- package/host-runtime/dist/adaptive-selection.js +12 -4
- package/host-runtime/dist/cli-recovery-probe.d.ts +42 -1
- package/host-runtime/dist/cli-recovery-probe.js +16 -3
- package/host-runtime/dist/codex-disclosure.d.ts +12 -7
- package/host-runtime/dist/codex-disclosure.js +12 -7
- package/host-runtime/dist/conversation-ingestion/pipeline.d.ts +8 -29
- package/host-runtime/dist/conversation-ingestion/pipeline.js +45 -3
- package/host-runtime/dist/conversation-ingestion/text-policy.d.ts +3 -4
- package/host-runtime/dist/conversation-ingestion/text-policy.js +3 -4
- package/host-runtime/dist/governance-observation-store.d.ts +38 -5
- package/host-runtime/dist/governance-observation-store.js +63 -5
- package/host-runtime/dist/index.js +5 -2
- package/host-runtime/dist/production-rulehost-gate.d.ts +36 -1
- package/host-runtime/dist/production-rulehost-gate.js +91 -1
- package/host-runtime/package.json +1 -1
- package/package.json +2 -2
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +117 -3
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/console.d.ts +0 -4
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +4 -67
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +1 -1
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-ingestion.d.ts +96 -0
- package/pd-cli/dist/commands/health-ingestion.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-ingestion.js +473 -0
- package/pd-cli/dist/commands/health-ingestion.js.map +1 -0
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +10 -0
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-activation.js +4 -8
- package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js +114 -63
- package/pd-cli/dist/commands/runtime-recovery-failed-tasks.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +0 -8
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +1 -18
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +4 -92
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js +1 -1
- package/pd-cli/dist/services/demo-story-a-runner.js.map +1 -1
- package/pd-cli/dist/services/version-report.d.ts.map +1 -1
- package/pd-cli/dist/services/version-report.js +5 -1
- package/pd-cli/dist/services/version-report.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +562 -534
- package/plugin/dist/core/experiment-workspace-guard.d.ts +25 -0
- package/plugin/dist/index.d.ts +1 -1
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +36 -77
- package/release-manager/dist/installers/codex-host-installer.js +35 -1
- package/release-manager/dist/mvp-config.js +1 -1
- package/release-manager/dist/update/product-identity.js +5 -1
- package/release-manager/dist/update/release-manager.js +11 -1
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/dist/index.d.ts +1 -1
- package/workbuddy-adapter/dist/index.js +1 -1
- package/workbuddy-adapter/dist/ingestion/catch-up.d.ts +11 -0
- package/workbuddy-adapter/dist/ingestion/catch-up.js +7 -2
- package/workbuddy-adapter/dist/ingestion/index.d.ts +1 -1
- package/workbuddy-adapter/dist/ingestion/index.js +1 -1
- package/workbuddy-adapter/package.json +1 -1
- package/console/dist/server/config/AuthConfig.d.ts +0 -14
- package/console/dist/server/config/AuthConfig.js +0 -42
|
@@ -5,9 +5,9 @@ import { fileURLToPath, pathToFileURL } from 'url';
|
|
|
5
5
|
import { resolveApplyFullTimeoutMs, resolveCheckTimeoutMs } from './update-timeout.js';
|
|
6
6
|
import { loadPdConfig, computeFlagsFromLoadResult, getFeedbackMaintainerEmail, getFeedbackChannelConfig, } from './config/pd-config-store.js';
|
|
7
7
|
import { resolveOwnerIdentity, defaultOwnerIdentityHomeDir } from '@principles/core/runtime';
|
|
8
|
-
import { createProductTelemetryService, scheduleProductTelemetryExport } from '@principles/host-runtime';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { createProductTelemetryService, scheduleProductTelemetryExport, CONSOLE_REQUEST_BUDGET_MS } from '@principles/host-runtime';
|
|
9
|
+
import { assertLoopbackBind } from './bind-guard.js';
|
|
10
|
+
import { guardConsoleApiRequest } from './utils/request-guard.js';
|
|
11
11
|
import { WorkspaceConfigStore } from './config/WorkspaceConfigStore.js';
|
|
12
12
|
import { getPdHome, PdHomeConfigurationError } from './utils/pd-home.js';
|
|
13
13
|
import { EXPERIMENT_CONSOLE_PORT, defaultConsolePort } from './console-ports.js';
|
|
@@ -16,7 +16,7 @@ import { handleFeedbackReportsRoute, handleFeedbackChannelsRoute, disposeFeedbac
|
|
|
16
16
|
import { handleFailedTasksRoute, disposeFailedTasksModels } from './routes/failed-tasks.js';
|
|
17
17
|
import { handleDiagnosticianRoute } from './routes/diagnostician.js';
|
|
18
18
|
import { handleApprovalsRoute, disposeApprovalsModels } from './routes/approvals.js';
|
|
19
|
-
import { handleHealthRoute, disposeHealthModels } from './routes/health.js';
|
|
19
|
+
import { handleHealthRoute, handleIngestionHealthRoute, disposeHealthModels } from './routes/health.js';
|
|
20
20
|
import { handlePrinciplesRoute, handleCorePrinciplesRoute, disposePrinciplesModels } from './routes/principles.js';
|
|
21
21
|
import { handleLifecycleRoute, disposeLifecycleModels } from './routes/lifecycle.js';
|
|
22
22
|
import { handleExaminerRoute } from './routes/examiner.js';
|
|
@@ -40,7 +40,7 @@ import { handleUpdateRoute } from './routes/update.js';
|
|
|
40
40
|
import { handleUpdateHistoryRoute, reconcileUpdateHistoryFromJournals } from './routes/update-history.js';
|
|
41
41
|
import { handleUpdateTransactionRoute } from './routes/update-transaction.js';
|
|
42
42
|
import { handleConfigRoute } from './routes/config.js';
|
|
43
|
-
import { sendJson, sendNotFound,
|
|
43
|
+
import { sendJson, sendNotFound, sendError } from './utils/response.js';
|
|
44
44
|
import { migrateLegacyExtensionBackups, resolvePdBackupsRoot } from './utils/pd-backups.js';
|
|
45
45
|
const __filename = fileURLToPath(import.meta.url);
|
|
46
46
|
const __dirname = path.dirname(__filename);
|
|
@@ -104,8 +104,6 @@ function parseArgs(argv, mode = 'production') {
|
|
|
104
104
|
// 13100 so a bare dev start cannot grab the production port. --port wins.
|
|
105
105
|
let port = defaultConsolePort(mode);
|
|
106
106
|
let host = '127.0.0.1';
|
|
107
|
-
let noAuth = false;
|
|
108
|
-
let token = undefined;
|
|
109
107
|
for (let i = 0; i < args.length; i++) {
|
|
110
108
|
if (args[i] === '--port' && i + 1 < args.length) {
|
|
111
109
|
const portStr = args[i + 1];
|
|
@@ -126,22 +124,26 @@ function parseArgs(argv, mode = 'production') {
|
|
|
126
124
|
i++;
|
|
127
125
|
}
|
|
128
126
|
}
|
|
129
|
-
else if (args[i] === '--no-auth') {
|
|
130
|
-
noAuth = true;
|
|
131
|
-
}
|
|
132
|
-
else if (args[i] === '--token' && i + 1 < args.length) {
|
|
133
|
-
const next = args[i + 1];
|
|
134
|
-
if (next !== undefined) {
|
|
135
|
-
token = next;
|
|
136
|
-
i++;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
127
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
128
|
+
return { workspace, port, host };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The Console has no application-level credential any more. Old launchers,
|
|
132
|
+
* shell profiles and scripts may still pass `--token` / `--no-auth`; they are
|
|
133
|
+
* ignored (unknown args never failed parsing) but the operator gets one line
|
|
134
|
+
* explaining why their secret no longer does anything.
|
|
135
|
+
*/
|
|
136
|
+
export function warnAboutLegacyAuthArgs(argv) {
|
|
137
|
+
const args = argv.slice(2);
|
|
138
|
+
if (args.includes('--token')) {
|
|
139
|
+
console.warn('[pd-console] --token is no longer used: the Console has no token authentication. The value is ignored.');
|
|
140
|
+
}
|
|
141
|
+
if (args.includes('--no-auth')) {
|
|
142
|
+
console.warn('[pd-console] --no-auth is no longer needed: the Console never requires authentication. The flag is ignored.');
|
|
143
|
+
}
|
|
144
|
+
if (process.env.PD_CONSOLE_TOKEN && process.env.PD_CONSOLE_TOKEN.length > 0) {
|
|
145
|
+
console.warn('[pd-console] PD_CONSOLE_TOKEN is no longer used: the Console has no token authentication. The value is ignored.');
|
|
143
146
|
}
|
|
144
|
-
return { workspace, port, host, noAuth, token };
|
|
145
147
|
}
|
|
146
148
|
// ── MIME type helpers ──────────────────────────────────────────────────────────────────────
|
|
147
149
|
const MIME_MAP = {
|
|
@@ -181,6 +183,10 @@ function serveFile(res, filePath) {
|
|
|
181
183
|
res.writeHead(200, {
|
|
182
184
|
'Content-Type': contentType,
|
|
183
185
|
'Content-Length': data.length,
|
|
186
|
+
// The Console is fully usable without a login now, so a hostile page
|
|
187
|
+
// must not be able to frame it and harvest clicks.
|
|
188
|
+
'X-Frame-Options': 'DENY',
|
|
189
|
+
'X-Content-Type-Options': 'nosniff',
|
|
184
190
|
});
|
|
185
191
|
res.end(data);
|
|
186
192
|
return true;
|
|
@@ -190,7 +196,10 @@ function serveFile(res, filePath) {
|
|
|
190
196
|
}
|
|
191
197
|
}
|
|
192
198
|
// ── Async handler wrapper ──────────────────────────────────────────────────────────────
|
|
193
|
-
|
|
199
|
+
// PRI-1202: this is the single budget authority. host-runtime derives the CLI
|
|
200
|
+
// recovery probe budget from the same constant (strictly smaller), so a probe
|
|
201
|
+
// can never outlive the request that awaits it.
|
|
202
|
+
export const REQUEST_TIMEOUT_MS = CONSOLE_REQUEST_BUDGET_MS;
|
|
194
203
|
const UPDATE_APPLY_TIMEOUT_MS = 120000;
|
|
195
204
|
// Full update downloads a tarball + copies files — allow 3 min for slow networks.
|
|
196
205
|
// PD_UPDATE_APPLY_FULL_TIMEOUT_MS (ms) overrides it for slow-disk machines:
|
|
@@ -239,7 +248,7 @@ function asyncHandler(fn, timeoutMs = REQUEST_TIMEOUT_MS) {
|
|
|
239
248
|
});
|
|
240
249
|
};
|
|
241
250
|
}
|
|
242
|
-
export async function initServices(workspaceDir
|
|
251
|
+
export async function initServices(workspaceDir) {
|
|
243
252
|
const configStore = new WorkspaceConfigStore();
|
|
244
253
|
const workspaceService = new WorkspaceService(configStore);
|
|
245
254
|
// Load feature flags from canonical .pd/config.yaml — fail-closed: on error, feedback_channel uses defaults
|
|
@@ -289,7 +298,6 @@ export async function initServices(workspaceDir, authConfig) {
|
|
|
289
298
|
const feedbackChannelConfig = getFeedbackChannelConfig(workspaceDir);
|
|
290
299
|
return {
|
|
291
300
|
workspaceDir,
|
|
292
|
-
authConfig,
|
|
293
301
|
configStore,
|
|
294
302
|
workspaceService,
|
|
295
303
|
feedbackFlags,
|
|
@@ -339,10 +347,13 @@ export function handleRequest(services) {
|
|
|
339
347
|
}
|
|
340
348
|
return;
|
|
341
349
|
}
|
|
342
|
-
//
|
|
350
|
+
// Origin/Host guard for all /api/* routes. The console has no credential;
|
|
351
|
+
// this is what keeps other browser origins (and DNS rebinding) out while
|
|
352
|
+
// letting local non-browser clients through.
|
|
343
353
|
if (urlPath.startsWith('/api/')) {
|
|
344
|
-
|
|
345
|
-
|
|
354
|
+
const rejection = guardConsoleApiRequest(req);
|
|
355
|
+
if (rejection !== null) {
|
|
356
|
+
sendError(res, rejection.status, rejection.error, rejection.message, { nextAction: rejection.nextAction });
|
|
346
357
|
return;
|
|
347
358
|
}
|
|
348
359
|
// ── API routes ──────────────────────────────────────────────────
|
|
@@ -496,8 +507,10 @@ export function handleRequest(services) {
|
|
|
496
507
|
const subPath = routePath.slice('/api/activations'.length);
|
|
497
508
|
// ADR-0022 (PRI-578): single resolver — env > ~/.pd/owner.json > none
|
|
498
509
|
const identity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
|
|
499
|
-
|
|
500
|
-
|
|
510
|
+
// The OS session is the credential now: a registered Owner identity is
|
|
511
|
+
// enough to act as the configured Owner from the local Console.
|
|
512
|
+
const ownerActor = identity.ownerId && identity.credentialId
|
|
513
|
+
? { principal: { kind: 'configured_owner', ownerId: identity.ownerId }, authentication: { method: 'local_owner_session', credentialId: identity.credentialId } }
|
|
501
514
|
: null;
|
|
502
515
|
asyncHandler(() => handleActivationsRoute(req, res, services.workspaceDir, subPath, {
|
|
503
516
|
ownerActor,
|
|
@@ -508,7 +521,7 @@ export function handleRequest(services) {
|
|
|
508
521
|
// ADR-0022 (PRI-578): /api/owner-identity — GET status, POST register, DELETE unregister
|
|
509
522
|
if (routePath === '/api/owner-identity' || routePath.startsWith('/api/owner-identity/')) {
|
|
510
523
|
const subPath = routePath.slice('/api/owner-identity'.length);
|
|
511
|
-
asyncHandler(() => handleOwnerIdentityRoute(req, res, defaultOwnerIdentityHomeDir(), subPath
|
|
524
|
+
asyncHandler(() => handleOwnerIdentityRoute(req, res, defaultOwnerIdentityHomeDir(), subPath))(req, res);
|
|
512
525
|
return;
|
|
513
526
|
}
|
|
514
527
|
// PRI-585: GET /api/governance/experience (flag-gated read-only snapshot)
|
|
@@ -516,7 +529,7 @@ export function handleRequest(services) {
|
|
|
516
529
|
asyncHandler(() => handleGovernanceExperienceRoute(req, res, {
|
|
517
530
|
workspaceDir: services.workspaceDir,
|
|
518
531
|
featureFlags: services.feedbackFlags,
|
|
519
|
-
ownerConfig: resolveOwnerConfigSnapshot(
|
|
532
|
+
ownerConfig: resolveOwnerConfigSnapshot(resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir())),
|
|
520
533
|
}))(req, res);
|
|
521
534
|
return;
|
|
522
535
|
}
|
|
@@ -530,7 +543,7 @@ export function handleRequest(services) {
|
|
|
530
543
|
asyncHandler(() => handleRuleCandidateBindingsRoute(req, res, {
|
|
531
544
|
workspaceDir: services.workspaceDir,
|
|
532
545
|
subPath: routePath.slice('/api/governance/rule-candidate-bindings'.length),
|
|
533
|
-
ownerIdentity:
|
|
546
|
+
ownerIdentity: ownerId !== null && credentialId !== null
|
|
534
547
|
? { ownerId, credentialId } : null,
|
|
535
548
|
}))(req, res);
|
|
536
549
|
return;
|
|
@@ -542,8 +555,7 @@ export function handleRequest(services) {
|
|
|
542
555
|
const subPath = routePath.slice('/api/governance/owner-decisions'.length);
|
|
543
556
|
const odIdentity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
|
|
544
557
|
const { ownerId, credentialId } = odIdentity;
|
|
545
|
-
const authEnabledForOwner =
|
|
546
|
-
&& ownerId !== null && credentialId !== null;
|
|
558
|
+
const authEnabledForOwner = ownerId !== null && credentialId !== null;
|
|
547
559
|
asyncHandler(() => handleOwnerDecisionsRoute(req, res, {
|
|
548
560
|
workspaceDir: services.workspaceDir,
|
|
549
561
|
subPath,
|
|
@@ -559,7 +571,7 @@ export function handleRequest(services) {
|
|
|
559
571
|
asyncHandler(() => handleDesignGateRoute(req, res, {
|
|
560
572
|
workspaceDir: services.workspaceDir,
|
|
561
573
|
subPath: routePath.slice('/api/governance/design-gate'.length),
|
|
562
|
-
ownerIdentity:
|
|
574
|
+
ownerIdentity: ownerId !== null && credentialId !== null
|
|
563
575
|
? { ownerId, credentialId } : null,
|
|
564
576
|
}))(req, res);
|
|
565
577
|
return;
|
|
@@ -584,7 +596,8 @@ export function handleRequest(services) {
|
|
|
584
596
|
return;
|
|
585
597
|
}
|
|
586
598
|
// PRI-331: GET /api/evidence-chain
|
|
587
|
-
|
|
599
|
+
// P1-2: GET /api/evidence-chain/assistant-turn?id=&session= (verbatim turn)
|
|
600
|
+
if (routePath === '/api/evidence-chain' || routePath === '/api/evidence-chain/assistant-turn') {
|
|
588
601
|
asyncHandler(() => handleEvidenceChainRoute(req, res, services.workspaceDir))(req, res);
|
|
589
602
|
return;
|
|
590
603
|
}
|
|
@@ -595,8 +608,7 @@ export function handleRequest(services) {
|
|
|
595
608
|
if (routePath === '/api/evidence/outcomes') {
|
|
596
609
|
const eoIdentity = resolveOwnerIdentity(process.env, defaultOwnerIdentityHomeDir());
|
|
597
610
|
const { ownerId, credentialId } = eoIdentity;
|
|
598
|
-
const authEnabledForOwner =
|
|
599
|
-
&& ownerId !== null && credentialId !== null;
|
|
611
|
+
const authEnabledForOwner = ownerId !== null && credentialId !== null;
|
|
600
612
|
asyncHandler(() => handleEvidenceOutcomesRoute(req, res, {
|
|
601
613
|
workspaceDir: services.workspaceDir,
|
|
602
614
|
ownerIdentity: authEnabledForOwner
|
|
@@ -609,10 +621,21 @@ export function handleRequest(services) {
|
|
|
609
621
|
if (routePath === '/api/health') {
|
|
610
622
|
asyncHandler(() => handleHealthRoute(req, res, {
|
|
611
623
|
workspaceDir: services.workspaceDir,
|
|
612
|
-
authenticationMode:
|
|
624
|
+
authenticationMode: 'no_auth',
|
|
613
625
|
}))(req, res);
|
|
614
626
|
return;
|
|
615
627
|
}
|
|
628
|
+
// GET /api/health/ingestion — PRI-1171 ticket ⑦: unified three-host
|
|
629
|
+
// conversation-ingestion health (verbatim CLI passthrough, read-only
|
|
630
|
+
// status, never trajectory browsing). The route budget must COVER the
|
|
631
|
+
// model's 30s CLI subprocess timeout — a 504 from the default timeout
|
|
632
|
+
// would render "unable to determine" while the CLI is still working.
|
|
633
|
+
if (routePath === '/api/health/ingestion') {
|
|
634
|
+
asyncHandler(() => handleIngestionHealthRoute(req, res, {
|
|
635
|
+
workspaceDir: services.workspaceDir,
|
|
636
|
+
}), 45_000)(req, res);
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
616
639
|
// 404 fallback for API routes
|
|
617
640
|
sendNotFound(res, `Route ${routePath} not found`);
|
|
618
641
|
return;
|
|
@@ -643,7 +666,8 @@ export async function main() {
|
|
|
643
666
|
}
|
|
644
667
|
throw error;
|
|
645
668
|
}
|
|
646
|
-
const { workspace, port, host
|
|
669
|
+
const { workspace, port, host } = parseArgs(process.argv, pdHome.mode);
|
|
670
|
+
warnAboutLegacyAuthArgs(process.argv);
|
|
647
671
|
if (pdHome.mode === 'experiment') {
|
|
648
672
|
console.log(`[pd-console] Environment: experiment (PD_EXPERIMENT_ROOT=${pdHome.experimentRoot ?? ''})`);
|
|
649
673
|
console.log(`[pd-console] PD home: ${pdHome.pdHome}`);
|
|
@@ -653,20 +677,10 @@ export async function main() {
|
|
|
653
677
|
else {
|
|
654
678
|
console.log(`[pd-console] Environment: production (PD home: ${pdHome.pdHome})`);
|
|
655
679
|
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
});
|
|
661
|
-
if (!authConfig.isEnabled() && !noAuth) {
|
|
662
|
-
console.warn('[pd-console] No auth token configured. Running without authentication. Use --token or PD_CONSOLE_TOKEN to enable.');
|
|
663
|
-
}
|
|
664
|
-
// Authentication disabled (explicit --no-auth or the token-less default)
|
|
665
|
-
// must never bind a non-loopback interface: every /api/* route would be
|
|
666
|
-
// reachable by unauthenticated network peers. parseArgs already restricts
|
|
667
|
-
// the explicit --no-auth flag; this is the effective-auth-state guard.
|
|
668
|
-
assertLoopbackBindForUnauthenticatedServer(authConfig.isEnabled(), host);
|
|
669
|
-
const services = await initServices(workspace, authConfig);
|
|
680
|
+
// The OS session is the trust boundary: the Console never has an
|
|
681
|
+
// application-level credential, so it must never be reachable off-machine.
|
|
682
|
+
assertLoopbackBind(host);
|
|
683
|
+
const services = await initServices(workspace);
|
|
670
684
|
// One-time hygiene: move legacy PD backups out of ~/.openclaw/extensions so
|
|
671
685
|
// OpenClaw plugin discovery stops reporting a duplicate principles-disciple
|
|
672
686
|
// plugin on every gateway startup. Best-effort, never blocks startup.
|
|
@@ -715,7 +729,7 @@ export async function main() {
|
|
|
715
729
|
server.listen(port, host, () => {
|
|
716
730
|
console.log('[pd-console] Listening on http://' + host + ':' + port);
|
|
717
731
|
console.log('[pd-console] Workspace: ' + workspace);
|
|
718
|
-
console.log('[pd-console] Auth:
|
|
732
|
+
console.log('[pd-console] Auth: none (local OS session)');
|
|
719
733
|
});
|
|
720
734
|
}
|
|
721
735
|
// cli-7 / PRI-892 precedent: importing this module (a test driving
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SqliteConnection, SqliteActivationStateStore, SqlitePIArtifactStore, extractPrincipleId, extractEvidenceRefs, PromotionReadinessReader, RuleHostWriter, createProductionGateDeps, SqliteActivationSafetyStore, isFeatureEnabled, RuleCodeOwnerDecisionService, collectOpenClawPromotionChecks, summarizeRuleCodeShadowEvents, buildPromotionEvidenceSnapshot, createRuntimeStateHandle, PrincipleTreeLedgerAdapter, previewApprovedRuleRevision, reviseApprovedRuleOnce, } from '@principles/core/runtime';
|
|
2
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
2
3
|
import { resolvePromotionHostLiveness, resolveWorkspaceHostToolSemantics, readPromptActivationInjectionStatuses, operatorDeclaredBudgetResolution, runtimeBudgetObservationToResolution, selectConsoleRuntimeBudgetFacts, productionRouteRotationState, RUNTIME_BUDGET_OBSERVATION_STALE_REASON, RUNTIME_EVENT_LOG_CANDIDATE_DIRS, collectRuleCodeEventEntries } from '@principles/host-runtime';
|
|
3
4
|
import { PROMPT_BUDGET_HOST_KINDS } from '@principles/core/runtime';
|
|
4
5
|
import { loadPdConfig, computeFlagsFromLoadResult } from '../config/pd-config-store.js';
|
|
@@ -155,7 +156,7 @@ export class ActivationsConsoleModel {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
async getActivations(targetHost) {
|
|
158
|
-
const stateDbPath =
|
|
159
|
+
const stateDbPath = resolveStateDbPath(this.workspaceDir);
|
|
159
160
|
if (!fs.existsSync(stateDbPath)) {
|
|
160
161
|
return { activations: [], status: 'degraded', reason: 'state.db not found — workspace may not be initialized', nextAction: 'Run pd runtime diagnostics to check workspace state' };
|
|
161
162
|
}
|
|
@@ -705,7 +706,8 @@ export class ActivationsConsoleModel {
|
|
|
705
706
|
}
|
|
706
707
|
}
|
|
707
708
|
async promoteRuleCode(activationId, expected, input) {
|
|
708
|
-
const review = await this.getOwnerReview(activationId, input.actor.principal.kind === 'configured_owner'
|
|
709
|
+
const review = await this.getOwnerReview(activationId, input.actor.principal.kind === 'configured_owner'
|
|
710
|
+
&& (input.actor.authentication.method === 'console_token' || input.actor.authentication.method === 'local_owner_session'), { ownerActor: input.actor, routeContext: input.routeContext });
|
|
709
711
|
const flags = computeFlagsFromLoadResult(loadPdConfig(this.workspaceDir));
|
|
710
712
|
const conn = new SqliteConnection({ workspaceDir: this.workspaceDir, readonly: false });
|
|
711
713
|
try {
|
|
@@ -809,7 +811,7 @@ export class ActivationsConsoleModel {
|
|
|
809
811
|
throw new Error('feature_not_enabled: enable rulecode_owner_live_decision only after the rollout gate passes');
|
|
810
812
|
}
|
|
811
813
|
async deactivateActivation(activationId) {
|
|
812
|
-
const stateDbPath =
|
|
814
|
+
const stateDbPath = resolveStateDbPath(this.workspaceDir);
|
|
813
815
|
if (!fs.existsSync(stateDbPath)) {
|
|
814
816
|
return { ok: false, reason: 'state.db not found — workspace may not be initialized', nextAction: 'Ensure the workspace has been initialized with PD before disabling activations.' };
|
|
815
817
|
}
|
|
@@ -3,6 +3,7 @@ import { approvalReviewMaterial } from './approval-review-material.js';
|
|
|
3
3
|
import * as fs from 'node:fs';
|
|
4
4
|
import * as path from 'node:path';
|
|
5
5
|
import { SqliteConnection, SqliteApprovalQueueStore, SqliteActivationStateStore, SqlitePIArtifactStore, ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, createProductionGateDeps, ApprovalCompletionService, ApprovalQueue, mapConfidenceToLabel, isArtifactRevisionOf, detectPromptReplacementTarget, detectRuleReplacementTarget, buildOwnerRevisionArtifact, PrincipleTreeLedgerAdapter, MVP_CHANNELS, computeArtifactDigest, } from '@principles/core/runtime';
|
|
6
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
6
7
|
import { resolveLedgerPrincipleId } from './principle-id-resolution.js';
|
|
7
8
|
import { createArtifactPrincipleResolutionDeps } from './artifact-principle-resolver.js';
|
|
8
9
|
import { loadPdConfig, computeFlagsFromLoadResult } from '../config/pd-config-store.js';
|
|
@@ -49,7 +50,7 @@ function describeBudgetBasis(hostKind, facts, declared) {
|
|
|
49
50
|
return `budget basis=fixed_fallback (no runtime budget observation for ${hostKind})`;
|
|
50
51
|
}
|
|
51
52
|
function stateDbExists(workspaceDir) {
|
|
52
|
-
return fs.existsSync(
|
|
53
|
+
return fs.existsSync(resolveStateDbPath(workspaceDir));
|
|
53
54
|
}
|
|
54
55
|
export class ApprovalsConsoleModel {
|
|
55
56
|
workspaceDir;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, RUNTIME_PRINCIPLE_BUDGET, detectPromptReplacementTarget, computeArtifactDigest, SqliteActivationStateStore, } from '@principles/core/runtime';
|
|
2
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
2
3
|
import { checkPromptArtifactDeliverability, hostRotationCapability, operatorDeclaredBudgetResolution, resolveLivePromptInjectionProjection, RUNTIME_BUDGET_OBSERVATION_STALE_REASON, runtimeBudgetObservationToResolution, selectConsoleRuntimeBudgetFacts, } from '@principles/host-runtime';
|
|
3
4
|
import { PROMPT_BUDGET_HOST_KINDS } from '@principles/core/runtime';
|
|
4
5
|
import { loadLedger } from '@principles/core/principle-tree-ledger';
|
|
@@ -167,7 +168,7 @@ export class ApprovalsGroupedConsoleModel {
|
|
|
167
168
|
this.workspaceDir = workspaceDir;
|
|
168
169
|
}
|
|
169
170
|
async getApprovalsGrouped(targetHost) {
|
|
170
|
-
const stateDbPath =
|
|
171
|
+
const stateDbPath = resolveStateDbPath(this.workspaceDir);
|
|
171
172
|
if (!fs.existsSync(stateDbPath)) {
|
|
172
173
|
return { groups: [], generatedAt: new Date().toISOString(), note: 'state.db not found — workspace may not be initialized' };
|
|
173
174
|
}
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
* - All summaries go through sanitizeString from evidence-sanitizer
|
|
16
16
|
* - Degraded paths include structured reason + nextAction (ERR-002)
|
|
17
17
|
*
|
|
18
|
+
* P1-2 exception: `getAssistantTurn()` returns ONE referenced assistant turn
|
|
19
|
+
* verbatim, on purpose — the Owner must be able to compare the recorded
|
|
20
|
+
* correction against exactly what the agent said. It is bounded to the turn id
|
|
21
|
+
* recorded in correction evidence and pinned to that turn's session.
|
|
22
|
+
*
|
|
18
23
|
* ERR checklist:
|
|
19
24
|
* - ERR-001/005: All DB rows treated as unknown, runtime validation with typeof guards
|
|
20
25
|
* - ERR-002: Degraded paths include reason + nextAction, never silent fallback
|
|
@@ -24,9 +29,50 @@
|
|
|
24
29
|
*/
|
|
25
30
|
import type { EvidenceChainState, EvidenceChainRecord, EvidenceChainResponse } from '@principles/core/runtime';
|
|
26
31
|
export type { EvidenceChainState, EvidenceChainRecord, EvidenceChainResponse, };
|
|
32
|
+
/**
|
|
33
|
+
* P1-2: verbatim assistant output referenced by a correction record.
|
|
34
|
+
*
|
|
35
|
+
* This is the ONE place raw assistant text is returned to the Owner. It is not
|
|
36
|
+
* sanitized on purpose: the Owner must be able to compare the correction text
|
|
37
|
+
* with exactly what the agent said. Access is by turn id, optionally pinned to
|
|
38
|
+
* the session id recorded in the correction evidence, so a record can never
|
|
39
|
+
* pull an unrelated conversation.
|
|
40
|
+
*/
|
|
41
|
+
export interface AssistantTurnLookup {
|
|
42
|
+
ok: true;
|
|
43
|
+
turn: {
|
|
44
|
+
id: number;
|
|
45
|
+
sessionId: string;
|
|
46
|
+
/** Verbatim assistant output (newlines, spaces and markdown preserved). */
|
|
47
|
+
text: string;
|
|
48
|
+
/**
|
|
49
|
+
* `raw` when the original text was persisted inline or in the overflow
|
|
50
|
+
* blob; `sanitized` when only the redacted copy survives (retention or
|
|
51
|
+
* write-path policy). The UI must label which one the Owner is reading.
|
|
52
|
+
*/
|
|
53
|
+
textSource: 'raw' | 'sanitized';
|
|
54
|
+
createdAt: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface AssistantTurnLookupFailure {
|
|
58
|
+
ok: false;
|
|
59
|
+
reason: string;
|
|
60
|
+
nextAction: string;
|
|
61
|
+
}
|
|
27
62
|
export declare class EvidenceChainConsoleModel {
|
|
28
63
|
private readonly workspaceDir;
|
|
29
64
|
constructor(workspaceDir: string);
|
|
30
65
|
getEvidenceChain(): Promise<EvidenceChainResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* P1-2: read the raw assistant turn referenced by correction evidence.
|
|
68
|
+
* Verbatim by contract — no sanitization, no markdown rendering.
|
|
69
|
+
*
|
|
70
|
+
* Uses the registered trajectory-store seam (`openTrajectoryDbReadonly`) so
|
|
71
|
+
* the read-only + path-contract rules have a single owner. The overflow blob
|
|
72
|
+
* directory is derived from the trajectory database location, never
|
|
73
|
+
* hardcoded, and a blob reference is confined to that directory before it is
|
|
74
|
+
* read.
|
|
75
|
+
*/
|
|
76
|
+
getAssistantTurn(turnId: number, expectedSessionId?: string): Promise<AssistantTurnLookup | AssistantTurnLookupFailure>;
|
|
31
77
|
dispose(): void;
|
|
32
78
|
}
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
* - All summaries go through sanitizeString from evidence-sanitizer
|
|
16
16
|
* - Degraded paths include structured reason + nextAction (ERR-002)
|
|
17
17
|
*
|
|
18
|
+
* P1-2 exception: `getAssistantTurn()` returns ONE referenced assistant turn
|
|
19
|
+
* verbatim, on purpose — the Owner must be able to compare the recorded
|
|
20
|
+
* correction against exactly what the agent said. It is bounded to the turn id
|
|
21
|
+
* recorded in correction evidence and pinned to that turn's session.
|
|
22
|
+
*
|
|
18
23
|
* ERR checklist:
|
|
19
24
|
* - ERR-001/005: All DB rows treated as unknown, runtime validation with typeof guards
|
|
20
25
|
* - ERR-002: Degraded paths include reason + nextAction, never silent fallback
|
|
@@ -23,10 +28,46 @@
|
|
|
23
28
|
* - ERR-013: Use Object.hasOwn() for untrusted object keys
|
|
24
29
|
*/
|
|
25
30
|
import { SqliteConnection, sanitizeString, assembleEvidenceChain, } from '@principles/core/runtime';
|
|
31
|
+
import { openTrajectoryDbReadonly } from '@principles/core/trajectory-store';
|
|
32
|
+
import { resolveStateDbPath, resolveTrajectoryDbPath } from '@principles/core/runtime/storage-paths';
|
|
26
33
|
import * as fs from 'node:fs';
|
|
27
34
|
import * as path from 'node:path';
|
|
28
35
|
import Database from 'better-sqlite3';
|
|
29
36
|
import { errorMessage } from '../utils/response.js';
|
|
37
|
+
/**
|
|
38
|
+
* P1-2: restore the assistant turn text for verbatim display.
|
|
39
|
+
*
|
|
40
|
+
* Order of preference: inline `raw_text` → overflow blob (`blob_ref`) →
|
|
41
|
+
* `sanitized_text` (kept for retention cases where raw text was purged). The
|
|
42
|
+
* blob path is treated as untrusted: it must resolve inside `<state>/blobs`,
|
|
43
|
+
* otherwise it is ignored (rc-1 / rc-2).
|
|
44
|
+
*/
|
|
45
|
+
function readVerbatimTurnText(row, stateDir) {
|
|
46
|
+
const inlineRaw = typeof row.raw_text === 'string' ? row.raw_text : '';
|
|
47
|
+
if (inlineRaw !== '')
|
|
48
|
+
return { text: inlineRaw, source: 'raw' };
|
|
49
|
+
const blobRef = typeof row.blob_ref === 'string' ? row.blob_ref : '';
|
|
50
|
+
if (blobRef !== '') {
|
|
51
|
+
const blobsDir = path.resolve(stateDir, 'blobs');
|
|
52
|
+
const blobPath = path.resolve(blobsDir, blobRef);
|
|
53
|
+
const relativeToBlobs = path.relative(blobsDir, blobPath);
|
|
54
|
+
const escapes = relativeToBlobs === '' || relativeToBlobs.startsWith('..') || path.isAbsolute(relativeToBlobs);
|
|
55
|
+
if (!escapes && fs.existsSync(blobPath)) {
|
|
56
|
+
try {
|
|
57
|
+
const blobText = fs.readFileSync(blobPath, 'utf8');
|
|
58
|
+
if (blobText !== '')
|
|
59
|
+
return { text: blobText, source: 'raw' };
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// Unreadable blob: fall through to the sanitized copy below.
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const sanitized = typeof row.sanitized_text === 'string' ? row.sanitized_text : '';
|
|
67
|
+
if (sanitized !== '')
|
|
68
|
+
return { text: sanitized, source: 'sanitized' };
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
30
71
|
// ── Helpers ────────────────────────────────────────────────────────────────────
|
|
31
72
|
function isRecord(value) {
|
|
32
73
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
@@ -136,7 +177,7 @@ export class EvidenceChainConsoleModel {
|
|
|
136
177
|
const degradedReasons = [];
|
|
137
178
|
const degradedNextActions = [];
|
|
138
179
|
// ── 1. Read pain_events from trajectory.db ────────────────────────────
|
|
139
|
-
const trajectoryDbPath =
|
|
180
|
+
const trajectoryDbPath = resolveTrajectoryDbPath(this.workspaceDir);
|
|
140
181
|
let painEvents = [];
|
|
141
182
|
let trajectoryDbAvailable = false;
|
|
142
183
|
if (fs.existsSync(trajectoryDbPath)) {
|
|
@@ -190,7 +231,7 @@ export class EvidenceChainConsoleModel {
|
|
|
190
231
|
degradedNextActions.push('PD has not recorded any pain signals in this workspace yet.');
|
|
191
232
|
}
|
|
192
233
|
// ── 2. Read tasks & candidates from state.db ──────────────────────
|
|
193
|
-
const stateDbPath =
|
|
234
|
+
const stateDbPath = resolveStateDbPath(this.workspaceDir);
|
|
194
235
|
let tasks = [];
|
|
195
236
|
let dreamerTasks = [];
|
|
196
237
|
let candidates = [];
|
|
@@ -340,6 +381,84 @@ export class EvidenceChainConsoleModel {
|
|
|
340
381
|
}
|
|
341
382
|
return response;
|
|
342
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* P1-2: read the raw assistant turn referenced by correction evidence.
|
|
386
|
+
* Verbatim by contract — no sanitization, no markdown rendering.
|
|
387
|
+
*
|
|
388
|
+
* Uses the registered trajectory-store seam (`openTrajectoryDbReadonly`) so
|
|
389
|
+
* the read-only + path-contract rules have a single owner. The overflow blob
|
|
390
|
+
* directory is derived from the trajectory database location, never
|
|
391
|
+
* hardcoded, and a blob reference is confined to that directory before it is
|
|
392
|
+
* read.
|
|
393
|
+
*/
|
|
394
|
+
async getAssistantTurn(turnId, expectedSessionId) {
|
|
395
|
+
if (!Number.isInteger(turnId) || turnId <= 0) {
|
|
396
|
+
return {
|
|
397
|
+
ok: false,
|
|
398
|
+
reason: 'Assistant turn id must be a positive integer',
|
|
399
|
+
nextAction: 'Reload the page and expand the original output again.',
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const trajectoryDbPath = resolveTrajectoryDbPath(this.workspaceDir);
|
|
403
|
+
if (!fs.existsSync(trajectoryDbPath)) {
|
|
404
|
+
return {
|
|
405
|
+
ok: false,
|
|
406
|
+
reason: 'Trajectory database not found for this workspace',
|
|
407
|
+
nextAction: 'PD has not recorded any turns in this workspace yet.',
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
let db = null;
|
|
411
|
+
try {
|
|
412
|
+
db = openTrajectoryDbReadonly(this.workspaceDir);
|
|
413
|
+
// Untrusted DB row: narrow with a guard instead of an `as` cast (rc-2).
|
|
414
|
+
const row = db.prepare('SELECT id, session_id, raw_text, sanitized_text, blob_ref, created_at FROM assistant_turns WHERE id = ?').get(turnId);
|
|
415
|
+
if (!isRecord(row)) {
|
|
416
|
+
return {
|
|
417
|
+
ok: false,
|
|
418
|
+
reason: `Assistant turn ${turnId} was not found`,
|
|
419
|
+
nextAction: 'The trajectory database may have been rotated; the correction text is still shown above.',
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
const sessionId = typeof row.session_id === 'string' ? row.session_id : '';
|
|
423
|
+
if (expectedSessionId && sessionId !== expectedSessionId) {
|
|
424
|
+
// Safety: never expose a turn from a different session than the one the
|
|
425
|
+
// correction evidence recorded.
|
|
426
|
+
return {
|
|
427
|
+
ok: false,
|
|
428
|
+
reason: 'Assistant turn does not belong to the recorded session',
|
|
429
|
+
nextAction: 'The evidence link is inconsistent; treat the original output as unavailable.',
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
const restored = readVerbatimTurnText(row, path.dirname(trajectoryDbPath));
|
|
433
|
+
if (restored === null) {
|
|
434
|
+
return {
|
|
435
|
+
ok: false,
|
|
436
|
+
reason: 'Assistant turn has no recorded output',
|
|
437
|
+
nextAction: 'The turn exists but its text was not persisted.',
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
return {
|
|
441
|
+
ok: true,
|
|
442
|
+
turn: {
|
|
443
|
+
id: turnId,
|
|
444
|
+
sessionId,
|
|
445
|
+
text: restored.text,
|
|
446
|
+
textSource: restored.source,
|
|
447
|
+
createdAt: typeof row.created_at === 'string' ? row.created_at : '',
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
catch (err) {
|
|
452
|
+
return {
|
|
453
|
+
ok: false,
|
|
454
|
+
reason: `Failed to read assistant turn: ${errorMessage(err)}`,
|
|
455
|
+
nextAction: 'Check trajectory database integrity in the workspace .state directory.',
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
finally {
|
|
459
|
+
db?.close();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
343
462
|
// eslint-disable-next-line @typescript-eslint/class-methods-use-this -- lifecycle interface; connections are request-scoped
|
|
344
463
|
dispose() {
|
|
345
464
|
// Connections are opened and closed per-request; no persistent state.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SqliteConnection, SqliteApprovalQueueStore, SqlitePIArtifactStore, ApprovalQueue, } from '@principles/core/runtime';
|
|
2
|
+
import { resolveStateDbPath, resolveTrajectoryDbPath } from '@principles/core/runtime/storage-paths';
|
|
2
3
|
import * as fs from 'node:fs';
|
|
3
4
|
import * as path from 'node:path';
|
|
4
5
|
import { errorMessage } from '../utils/response.js';
|
|
@@ -51,7 +52,7 @@ export class GovernanceConsoleModel {
|
|
|
51
52
|
this.workspaceDir = workspaceDir;
|
|
52
53
|
}
|
|
53
54
|
async getGovernanceQueue() {
|
|
54
|
-
const stateDbPath =
|
|
55
|
+
const stateDbPath = resolveStateDbPath(this.workspaceDir);
|
|
55
56
|
if (!fs.existsSync(stateDbPath)) {
|
|
56
57
|
// Security audit run-1 (gate-failopen-allow-on-state-corruption): the
|
|
57
58
|
// governed agent can delete state.db, and the gate then fails open —
|
|
@@ -293,7 +294,7 @@ export class GovernanceConsoleModel {
|
|
|
293
294
|
}
|
|
294
295
|
// PRI-380: Query trajectory.db for behavior evidence count
|
|
295
296
|
let evidenceInProgressCount = 0;
|
|
296
|
-
const trajectoryDbPath =
|
|
297
|
+
const trajectoryDbPath = resolveTrajectoryDbPath(this.workspaceDir);
|
|
297
298
|
if (fs.existsSync(trajectoryDbPath)) {
|
|
298
299
|
try {
|
|
299
300
|
const Database = (await import('better-sqlite3')).default;
|
|
@@ -16,6 +16,7 @@ import * as path from 'node:path';
|
|
|
16
16
|
import { createHash } from 'node:crypto';
|
|
17
17
|
import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
|
|
18
18
|
import { deriveGovernanceExperienceSnapshot, deriveOwnerGovernanceView, } from '@principles/core/runtime';
|
|
19
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
19
20
|
import { GovernanceProjectionCollector, isRecord, readOwnString, } from './GovernanceProjectionCollector.js';
|
|
20
21
|
import { loadPdConfig } from '../config/pd-config-store.js';
|
|
21
22
|
const EMPTY_TABLES = { artifactRows: [], taskRows: [], approvalRows: [], activationRows: [] };
|
|
@@ -59,7 +60,7 @@ export class GovernanceExperienceCollector {
|
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
// ── state.db: existence check + one batched table read ───────────────────
|
|
62
|
-
const dbPath =
|
|
63
|
+
const dbPath = resolveStateDbPath(this.workspaceDir);
|
|
63
64
|
let tables = EMPTY_TABLES;
|
|
64
65
|
let stateDbAvailable = true;
|
|
65
66
|
let stateDbReasonCode;
|
|
@@ -3,6 +3,7 @@ import * as path from 'node:path';
|
|
|
3
3
|
import { RUNTIME_CONTRACT_SCHEMA_VERSION } from '@principles/core/runtime';
|
|
4
4
|
import { Value } from '@sinclair/typebox/value';
|
|
5
5
|
import { GovernanceFactsSchema, SqliteConnection, isPDErrorCategory, parsePITaskMetadata, PD_TASK_STATUSES, PRINCIPLE_STATUSES, isPDTaskStatus, } from '@principles/core/runtime';
|
|
6
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
6
7
|
export const GOVERNANCE_TASK_KINDS = new Set([
|
|
7
8
|
'dreamer', 'philosopher', 'scribe', 'artificer', 'evaluator', 'rollout_reviewer',
|
|
8
9
|
]);
|
|
@@ -55,7 +56,7 @@ export class GovernanceProjectionCollector {
|
|
|
55
56
|
}
|
|
56
57
|
const collectionIssues = [];
|
|
57
58
|
const principle = this.readPrinciple(principleId, collectionIssues);
|
|
58
|
-
const dbPath =
|
|
59
|
+
const dbPath = resolveStateDbPath(this.workspaceDir);
|
|
59
60
|
if (!fs.existsSync(dbPath)) {
|
|
60
61
|
return GovernanceProjectionCollector.factsForUnavailableSource({ principleId, asOf, principle, collectionIssues });
|
|
61
62
|
}
|