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
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
// contract and further validated by SqliteTaskStore's row readers (rc-1 at the
|
|
22
22
|
// DB boundary).
|
|
23
23
|
import * as fs from 'node:fs';
|
|
24
|
-
import * as path from 'node:path';
|
|
25
24
|
import { SqliteConnection, SqliteTaskStore, PDRuntimeError, createRecoverySweepService, appendRecoveryAction, } from '@principles/core/runtime';
|
|
25
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
26
26
|
import { sendSuccess, sendError, sendNotFound, sendMethodNotAllowed, sendBadRequest, errorMessage, } from '../utils/response.js';
|
|
27
27
|
import { readBody } from '../utils/request.js';
|
|
28
28
|
import { OwnerDecisionConsoleModel } from '../models/OwnerDecisionConsoleModel.js';
|
|
29
29
|
const entries = new Map();
|
|
30
30
|
function stateDbExists(workspaceDir) {
|
|
31
|
-
return fs.existsSync(
|
|
31
|
+
return fs.existsSync(resolveStateDbPath(workspaceDir));
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Decode a percent-encoded path segment into the raw task id (PRI-747 F22
|
|
@@ -316,7 +316,7 @@ async function dispatchRecovery(workspaceDir, taskId, force) {
|
|
|
316
316
|
httpStatus: 409,
|
|
317
317
|
errorCode: 'owner_decision_required',
|
|
318
318
|
message: 'This task awaits an Owner decision (accept current / revise once / reject). Recover is not a governance exit and was refused.',
|
|
319
|
-
nextAction: 'Open the Console governance
|
|
319
|
+
nextAction: 'Open the Console governance workbench (#/workbench) and resolve the decision there.',
|
|
320
320
|
},
|
|
321
321
|
};
|
|
322
322
|
}
|
|
@@ -365,6 +365,77 @@ async function dispatchRecovery(workspaceDir, taskId, force) {
|
|
|
365
365
|
await close();
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
|
+
function asRecord(value) {
|
|
369
|
+
return isRecord(value) ? value : null;
|
|
370
|
+
}
|
|
371
|
+
function toStringArray(value) {
|
|
372
|
+
if (!Array.isArray(value))
|
|
373
|
+
return [];
|
|
374
|
+
return value.filter((entry) => typeof entry === 'string');
|
|
375
|
+
}
|
|
376
|
+
function optionalString(obj, key) {
|
|
377
|
+
if (!Object.hasOwn(obj, key))
|
|
378
|
+
return null;
|
|
379
|
+
const value = obj[key];
|
|
380
|
+
return typeof value === 'string' ? value : null;
|
|
381
|
+
}
|
|
382
|
+
function projectionFromFailure(failed) {
|
|
383
|
+
const { attemptCount } = failed;
|
|
384
|
+
const { maxAttempts } = failed;
|
|
385
|
+
if (typeof failed.stageTaskId !== 'string' || typeof failed.stageTaskKind !== 'string')
|
|
386
|
+
return null;
|
|
387
|
+
if (typeof attemptCount !== 'number' || !Number.isFinite(attemptCount))
|
|
388
|
+
return null;
|
|
389
|
+
if (typeof maxAttempts !== 'number' || !Number.isFinite(maxAttempts))
|
|
390
|
+
return null;
|
|
391
|
+
return {
|
|
392
|
+
stageTaskId: failed.stageTaskId,
|
|
393
|
+
stageTaskKind: failed.stageTaskKind,
|
|
394
|
+
errorCategory: optionalString(failed, 'errorCategory'),
|
|
395
|
+
terminalReason: optionalString(failed, 'terminalReason'),
|
|
396
|
+
attemptCount,
|
|
397
|
+
maxAttempts,
|
|
398
|
+
validatorErrors: toStringArray(failed.validatorErrors),
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function projectFailureDiagnostics(diagnosticJson) {
|
|
402
|
+
if (!diagnosticJson)
|
|
403
|
+
return null;
|
|
404
|
+
let parsed;
|
|
405
|
+
try {
|
|
406
|
+
parsed = JSON.parse(diagnosticJson);
|
|
407
|
+
}
|
|
408
|
+
catch {
|
|
409
|
+
return null;
|
|
410
|
+
}
|
|
411
|
+
const envelope = asRecord(parsed);
|
|
412
|
+
if (!envelope)
|
|
413
|
+
return null;
|
|
414
|
+
const terminal = Object.hasOwn(envelope, 'terminal_failure') ? asRecord(envelope.terminal_failure) : null;
|
|
415
|
+
const lastValidator = Object.hasOwn(envelope, 'lastValidatorErrors') ? asRecord(envelope.lastValidatorErrors) : null;
|
|
416
|
+
const outputFailure = Object.hasOwn(envelope, 'output_failure_details') ? asRecord(envelope.output_failure_details) : null;
|
|
417
|
+
const failedStage = Object.hasOwn(envelope, 'failed_stage') ? asRecord(envelope.failed_stage) : null;
|
|
418
|
+
const validatorErrors = lastValidator ? toStringArray(lastValidator.errors) : [];
|
|
419
|
+
const effectiveValidatorErrors = validatorErrors.length > 0
|
|
420
|
+
? validatorErrors
|
|
421
|
+
: outputFailure
|
|
422
|
+
? toStringArray(outputFailure.validatorErrors)
|
|
423
|
+
: [];
|
|
424
|
+
const projection = {
|
|
425
|
+
terminalReason: terminal ? optionalString(terminal, 'reason') : null,
|
|
426
|
+
terminalErrorCategory: terminal ? optionalString(terminal, 'errorCategory') : null,
|
|
427
|
+
validatorErrors: effectiveValidatorErrors,
|
|
428
|
+
failedStage: failedStage ? projectionFromFailure(failedStage) : null,
|
|
429
|
+
};
|
|
430
|
+
// Nothing to say: behave as if the server never sent the block.
|
|
431
|
+
if (projection.terminalReason === null
|
|
432
|
+
&& projection.terminalErrorCategory === null
|
|
433
|
+
&& projection.validatorErrors.length === 0
|
|
434
|
+
&& projection.failedStage === null) {
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
return projection;
|
|
438
|
+
}
|
|
368
439
|
/**
|
|
369
440
|
* Handle requests to `/api/failed-tasks*`.
|
|
370
441
|
*
|
|
@@ -595,10 +666,15 @@ export async function handleFailedTasksRoute(req, res, ctx) {
|
|
|
595
666
|
sendNotFound(res, `Task ${id} not found (or it is not in 'failed' / 'needs_human_review' status)`);
|
|
596
667
|
return;
|
|
597
668
|
}
|
|
669
|
+
const projection = projectFailureDiagnostics(detail.task.diagnosticJson);
|
|
598
670
|
sendSuccess(res, {
|
|
599
671
|
task: detail.task,
|
|
600
672
|
runs: detail.runs,
|
|
601
673
|
lastError: detail.lastError,
|
|
674
|
+
// P1-3: structured failure facts (terminal reason + newest validator
|
|
675
|
+
// errors + failed-stage projection). Omitted entirely when nothing
|
|
676
|
+
// structured is persisted, so older rows keep the previous payload shape.
|
|
677
|
+
...(projection !== null ? { diagnostics: projection } : {}),
|
|
602
678
|
pendingAgentDraft: detail.pendingAgentDraft,
|
|
603
679
|
});
|
|
604
680
|
}
|
|
@@ -9,13 +9,16 @@ export interface GovernanceExperienceContext {
|
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Owner identity evidence for the governance experience snapshot. Mirrors the
|
|
12
|
-
* activations authority wiring in server/index.ts (
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* activations authority wiring in server/index.ts (PD_OWNER_ID +
|
|
13
|
+
* PD_OWNER_CREDENTIAL_ID) — the two must stay in sync; the route tests lock
|
|
14
|
+
* the mapping.
|
|
15
|
+
*
|
|
16
|
+
* The wire enum keeps both historical values (D2), but the Console has no
|
|
17
|
+
* application-level credential any more, so `authenticationMode` is always
|
|
18
|
+
* `no_auth`. Readiness now depends only on whether an Owner identity is
|
|
19
|
+
* registered.
|
|
15
20
|
*/
|
|
16
|
-
export declare function resolveOwnerConfigSnapshot(
|
|
17
|
-
isEnabled(): boolean;
|
|
18
|
-
}, identity: OwnerIdentityResolved): OwnerConfigSnapshot;
|
|
21
|
+
export declare function resolveOwnerConfigSnapshot(identity: OwnerIdentityResolved): OwnerConfigSnapshot;
|
|
19
22
|
/**
|
|
20
23
|
* GET /api/governance/experience — read-only Governance Experience Snapshot
|
|
21
24
|
* v1.5.1 (PRI-585).
|
|
@@ -21,19 +21,23 @@ function getExperienceCollector(workspaceDir) {
|
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* Owner identity evidence for the governance experience snapshot. Mirrors the
|
|
24
|
-
* activations authority wiring in server/index.ts (
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* activations authority wiring in server/index.ts (PD_OWNER_ID +
|
|
25
|
+
* PD_OWNER_CREDENTIAL_ID) — the two must stay in sync; the route tests lock
|
|
26
|
+
* the mapping.
|
|
27
|
+
*
|
|
28
|
+
* The wire enum keeps both historical values (D2), but the Console has no
|
|
29
|
+
* application-level credential any more, so `authenticationMode` is always
|
|
30
|
+
* `no_auth`. Readiness now depends only on whether an Owner identity is
|
|
31
|
+
* registered.
|
|
27
32
|
*/
|
|
28
|
-
export function resolveOwnerConfigSnapshot(
|
|
29
|
-
const authEnabled = authConfig.isEnabled();
|
|
33
|
+
export function resolveOwnerConfigSnapshot(identity) {
|
|
30
34
|
const ownerIdentityConfiguration = identity.source === 'invalid_env' || identity.error !== undefined
|
|
31
35
|
? 'invalid'
|
|
32
36
|
: (identity.source === 'env' || identity.source === 'file') && identity.ownerId && identity.credentialId
|
|
33
37
|
? 'configured'
|
|
34
38
|
: 'missing';
|
|
35
39
|
return {
|
|
36
|
-
authenticationMode:
|
|
40
|
+
authenticationMode: 'no_auth',
|
|
37
41
|
ownerIdentityConfiguration,
|
|
38
42
|
};
|
|
39
43
|
}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
/**
|
|
3
|
+
* GET /api/health/ingestion — the unified three-host conversation-ingestion
|
|
4
|
+
* health section, verbatim from the CLI authority. A collection failure is
|
|
5
|
+
* the explicit unknown block (rc-9), never an empty-but-healthy row.
|
|
6
|
+
*/
|
|
7
|
+
export declare function handleIngestionHealthRoute(req: IncomingMessage, res: ServerResponse, options: {
|
|
8
|
+
workspaceDir: string;
|
|
9
|
+
}): Promise<void>;
|
|
2
10
|
export declare function handleHealthRoute(req: IncomingMessage, res: ServerResponse, options: {
|
|
3
11
|
workspaceDir: string;
|
|
4
12
|
authenticationMode: 'authenticated' | 'no_auth';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HealthCheckModel } from '../models/HealthCheckModel.js';
|
|
2
2
|
import { CodexGovernanceHealthModel } from '../models/CodexGovernanceHealthModel.js';
|
|
3
|
+
import { IngestionHealthModel } from '../models/IngestionHealthModel.js';
|
|
3
4
|
import { sendSuccess, sendError, errorMessage } from '../utils/response.js';
|
|
4
5
|
const MODEL_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
5
6
|
/**
|
|
@@ -39,6 +40,75 @@ function getCodexModel(workspaceDir) {
|
|
|
39
40
|
codexModels.set(workspaceDir, { model, cachedAt: Date.now() });
|
|
40
41
|
return model;
|
|
41
42
|
}
|
|
43
|
+
// PRI-1171 ticket ⑦: unified three-host ingestion health — SAME authority
|
|
44
|
+
// discipline as the codex block above (the CLI report is the one truth; the
|
|
45
|
+
// Console executes it and renders verbatim). Cached per workspace.
|
|
46
|
+
const INGESTION_WORKSPACE_CACHE_TTL_MS = MODEL_CACHE_TTL_MS;
|
|
47
|
+
const ingestionModels = new Map();
|
|
48
|
+
const ingestionCache = new Map();
|
|
49
|
+
function getIngestionModel(workspaceDir) {
|
|
50
|
+
const cached = ingestionModels.get(workspaceDir);
|
|
51
|
+
if (cached !== undefined && Date.now() - cached.cachedAt < INGESTION_WORKSPACE_CACHE_TTL_MS) {
|
|
52
|
+
return cached.model;
|
|
53
|
+
}
|
|
54
|
+
const model = new IngestionHealthModel(workspaceDir);
|
|
55
|
+
ingestionModels.set(workspaceDir, { model, cachedAt: Date.now() });
|
|
56
|
+
return model;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* `?refresh=1` is the page's explicit Refresh button path: bypass the
|
|
60
|
+
* 5-minute cache so the operator actually gets a fresh CLI report instead
|
|
61
|
+
* of the same snapshot with a spinning icon (PR #2563 review).
|
|
62
|
+
*/
|
|
63
|
+
function isIngestionRefresh(req) {
|
|
64
|
+
try {
|
|
65
|
+
return new URL(req.url ?? '', 'http://localhost').searchParams.has('refresh');
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* GET /api/health/ingestion — the unified three-host conversation-ingestion
|
|
73
|
+
* health section, verbatim from the CLI authority. A collection failure is
|
|
74
|
+
* the explicit unknown block (rc-9), never an empty-but-healthy row.
|
|
75
|
+
*/
|
|
76
|
+
export async function handleIngestionHealthRoute(req, res, options) {
|
|
77
|
+
if (req.method !== 'GET') {
|
|
78
|
+
sendError(res, 405, 'method_not_allowed', 'Only GET method is allowed');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const cached = isIngestionRefresh(req) ? undefined : ingestionCache.get(options.workspaceDir);
|
|
82
|
+
if (cached !== undefined && Date.now() - cached.cachedAt < INGESTION_WORKSPACE_CACHE_TTL_MS) {
|
|
83
|
+
sendSuccess(res, cached.result);
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
let result;
|
|
87
|
+
try {
|
|
88
|
+
result = await getIngestionModel(options.workspaceDir).collect();
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
result = {
|
|
92
|
+
status: 'unknown',
|
|
93
|
+
reason: 'health_collection_failed',
|
|
94
|
+
nextAction: `Run \`pd health --workspace <dir> --json\` manually to see the structured ingestion section. (${errorMessage(error).slice(0, 160)})`,
|
|
95
|
+
productClaim: 'degraded',
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// An unknown result is NEVER cached: a transient CLI outage must not pin
|
|
99
|
+
// the panel to "unable to determine" for five minutes — the next request
|
|
100
|
+
// retries the collection immediately (a recovered CLI refreshes the page).
|
|
101
|
+
// A FAILED forced refresh must also EVICT a previous successful snapshot:
|
|
102
|
+
// otherwise the next plain GET keeps serving stale "healthy" data for the
|
|
103
|
+
// rest of the TTL (PR #2563 re-review 4546345447).
|
|
104
|
+
if (result.status === 'ok') {
|
|
105
|
+
ingestionCache.set(options.workspaceDir, { result, cachedAt: Date.now() });
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
ingestionCache.delete(options.workspaceDir);
|
|
109
|
+
}
|
|
110
|
+
sendSuccess(res, result);
|
|
111
|
+
}
|
|
42
112
|
export async function handleHealthRoute(req, res, options) {
|
|
43
113
|
if (req.method !== 'GET') {
|
|
44
114
|
sendError(res, 405, 'method_not_allowed', 'Only GET method is allowed');
|
|
@@ -103,4 +173,6 @@ export function disposeHealthModels() {
|
|
|
103
173
|
models.clear();
|
|
104
174
|
codexModels.clear();
|
|
105
175
|
codexCache.clear();
|
|
176
|
+
ingestionModels.clear();
|
|
177
|
+
ingestionCache.clear();
|
|
106
178
|
}
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* POST /api/governance/owner-decisions/:taskId/resolve — Owner 裁决
|
|
6
6
|
*
|
|
7
7
|
* 安全模型(SPEC §28/§29):
|
|
8
|
-
* -
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* - 来源守卫(Host/Origin/Sec-Fetch-Site/JSON Content-Type)由
|
|
9
|
+
* server/index.ts 统一强制;
|
|
10
|
+
* - 身份从服务端身份解析结果推导,body 里的身份字段一律不信任;
|
|
11
11
|
* - effectiveDecision / eligibility 全部服务端重读 durable facts 判定;
|
|
12
12
|
* - stale 防护: reviewKey + expected* 事实快照逐字段比对(409)。
|
|
13
13
|
*/
|
|
@@ -183,7 +183,7 @@ export async function handleOwnerDecisionsRoute(req, res, ctx) {
|
|
|
183
183
|
}
|
|
184
184
|
if (!ownerIdentity) {
|
|
185
185
|
sendError(res, 403, 'owner_authentication_required', 'Owner decisions require an authenticated Console and a configured Owner identity.', {
|
|
186
|
-
nextAction: 'Configure the
|
|
186
|
+
nextAction: 'Configure the Owner identity, then retry from Governance Focus.',
|
|
187
187
|
});
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Registration (where the identity comes from) and governance readiness
|
|
11
11
|
* (whether Owner governance actions can execute) are DIFFERENT facts: the
|
|
12
|
-
* latter
|
|
13
|
-
* ONLY by resolveOwnerConfigSnapshot — never
|
|
12
|
+
* latter requires a registered identity (the local OS session is the
|
|
13
|
+
* credential) and is derived ONLY by resolveOwnerConfigSnapshot — never
|
|
14
|
+
* re-derived in the UI.
|
|
14
15
|
*
|
|
15
16
|
* Env vars remain the highest-priority source; file registration is the
|
|
16
17
|
* install-level fallback; a partial env pair is invalid and fails closed
|
|
@@ -23,9 +24,13 @@ export interface OwnerIdentityRouteView {
|
|
|
23
24
|
resolved: OwnerIdentityResolved;
|
|
24
25
|
fileRecord: OwnerIdentityRecord | null;
|
|
25
26
|
fileError?: string;
|
|
27
|
+
/**
|
|
28
|
+
* P0-2: set when the file record was deliberately NOT read because the
|
|
29
|
+
* identity comes from env. Reading `<home>/.pd/owner.json` in that case would
|
|
30
|
+
* touch the production registration file just to enrich the view.
|
|
31
|
+
*/
|
|
32
|
+
fileRecordSkipped?: 'env_identity';
|
|
26
33
|
/** Canonical governance readiness — the same derivation the governance experience uses. */
|
|
27
34
|
governance: OwnerConfigSnapshot;
|
|
28
35
|
}
|
|
29
|
-
export declare function handleOwnerIdentityRoute(req: IncomingMessage, res: ServerResponse, homeDir: string, subPath: string
|
|
30
|
-
isEnabled(): boolean;
|
|
31
|
-
}): Promise<void>;
|
|
36
|
+
export declare function handleOwnerIdentityRoute(req: IncomingMessage, res: ServerResponse, homeDir: string, subPath: string): Promise<void>;
|
|
@@ -15,20 +15,24 @@ async function readJson(req) {
|
|
|
15
15
|
return JSON.parse(Buffer.concat(chunks).toString('utf-8'));
|
|
16
16
|
}
|
|
17
17
|
/* eslint-disable @typescript-eslint/max-params */
|
|
18
|
-
export async function handleOwnerIdentityRoute(req, res, homeDir, subPath
|
|
18
|
+
export async function handleOwnerIdentityRoute(req, res, homeDir, subPath) {
|
|
19
19
|
if (subPath !== '' && subPath !== '/') {
|
|
20
20
|
sendError(res, 404, 'not_found', 'Unknown owner identity endpoint.', { nextAction: 'Use GET / POST / DELETE /api/owner-identity.' });
|
|
21
21
|
return;
|
|
22
22
|
}
|
|
23
23
|
const method = req.method ?? 'GET';
|
|
24
24
|
if (method === 'GET') {
|
|
25
|
-
const file = readOwnerIdentityFile(homeDir);
|
|
26
25
|
const resolved = resolveOwnerIdentity(process.env, homeDir);
|
|
26
|
+
// P0-2: an env-provided identity is authoritative. Do not read the file at
|
|
27
|
+
// all in that case — not even to fill `fileRecord`.
|
|
28
|
+
const envIdentityActive = resolved.source === 'env';
|
|
29
|
+
const file = envIdentityActive ? null : readOwnerIdentityFile(homeDir);
|
|
27
30
|
const view = {
|
|
28
31
|
resolved,
|
|
29
|
-
fileRecord: file
|
|
30
|
-
...(file
|
|
31
|
-
|
|
32
|
+
fileRecord: file?.record ?? null,
|
|
33
|
+
...(file?.error === undefined ? {} : { fileError: file.error }),
|
|
34
|
+
...(envIdentityActive ? { fileRecordSkipped: 'env_identity' } : {}),
|
|
35
|
+
governance: resolveOwnerConfigSnapshot(resolved),
|
|
32
36
|
};
|
|
33
37
|
sendSuccess(res, view);
|
|
34
38
|
return;
|
|
@@ -54,7 +58,7 @@ export async function handleOwnerIdentityRoute(req, res, homeDir, subPath, authC
|
|
|
54
58
|
sendSuccess(res, {
|
|
55
59
|
record: result.record,
|
|
56
60
|
source: 'file',
|
|
57
|
-
governance: resolveOwnerConfigSnapshot(
|
|
61
|
+
governance: resolveOwnerConfigSnapshot(resolved),
|
|
58
62
|
});
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
@@ -68,7 +72,7 @@ export async function handleOwnerIdentityRoute(req, res, homeDir, subPath, authC
|
|
|
68
72
|
sendSuccess(res, {
|
|
69
73
|
ok: true,
|
|
70
74
|
source: 'none',
|
|
71
|
-
governance: resolveOwnerConfigSnapshot(
|
|
75
|
+
governance: resolveOwnerConfigSnapshot(resolved),
|
|
72
76
|
});
|
|
73
77
|
return;
|
|
74
78
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
1
|
import * as fs from 'fs';
|
|
3
2
|
import { PrinciplesConsoleModel, ImmutableCorePrincipleError, CorePrincipleNotGovernedError, } from '../models/PrinciplesConsoleModel.js';
|
|
4
3
|
import { PrincipleTrajectoryModel } from '../models/PrincipleTrajectoryModel.js';
|
|
5
4
|
import { GovernanceProjectionCollector, GovernanceProjectionCollectionError } from '../models/GovernanceProjectionCollector.js';
|
|
6
5
|
import { CORE_PRINCIPLES, OwnerGovernanceViewSchema, deriveOwnerGovernanceView } from '@principles/core/runtime';
|
|
7
6
|
import { Value } from '@sinclair/typebox/value';
|
|
7
|
+
import { resolveStateDbPath } from '@principles/core/runtime/storage-paths';
|
|
8
8
|
import { sendSuccess, sendError, sendNotFound, errorMessage } from '../utils/response.js';
|
|
9
9
|
const models = new Map();
|
|
10
10
|
const trajectoryModels = new Map();
|
|
@@ -68,7 +68,7 @@ function getOwnStringField(obj, key) {
|
|
|
68
68
|
*/
|
|
69
69
|
async function getDecidedPrincipleIds(workspaceDir) {
|
|
70
70
|
// Runtime uses <workspace>/.pd/state.db (NOT .state/state.db)
|
|
71
|
-
const dbPath =
|
|
71
|
+
const dbPath = resolveStateDbPath(workspaceDir);
|
|
72
72
|
if (!fs.existsSync(dbPath)) {
|
|
73
73
|
return { ids: new Set(), pendingIds: new Set(), unavailableReason: 'approval_db_not_found' };
|
|
74
74
|
}
|
|
@@ -136,7 +136,7 @@ async function getDecidedPrincipleIds(workspaceDir) {
|
|
|
136
136
|
* and must not default to either active or revoked).
|
|
137
137
|
*/
|
|
138
138
|
async function getDeactivatedPrincipleIds(workspaceDir) {
|
|
139
|
-
const dbPath =
|
|
139
|
+
const dbPath = resolveStateDbPath(workspaceDir);
|
|
140
140
|
if (!fs.existsSync(dbPath)) {
|
|
141
141
|
return { ids: new Set(), unavailableReason: 'activation_db_not_found' };
|
|
142
142
|
}
|
|
@@ -39,7 +39,7 @@ function failure(res, result) {
|
|
|
39
39
|
export async function handleRuleCandidateBindingsRoute(req, res, ctx) {
|
|
40
40
|
// Auth precedes model construction and body parsing: a refused caller cannot create state.
|
|
41
41
|
if (!ctx.ownerIdentity) {
|
|
42
|
-
sendError(res, 403, 'owner_authentication_required', '
|
|
42
|
+
sendError(res, 403, 'owner_authentication_required', '请先配置 Owner 身份。', { nextAction: '在设置中确认 Owner 身份后重试。' });
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
const model = new RuleCandidateBindingConsoleModel(ctx.workspaceDir);
|
|
@@ -138,26 +138,44 @@ async function applyFullUpdate(authority, res, workspaceDir) {
|
|
|
138
138
|
parsed.message = val;
|
|
139
139
|
else if (key === 'nextAction' && typeof val === 'string')
|
|
140
140
|
parsed.nextAction = val;
|
|
141
|
+
else if (key === 'result' && typeof val === 'object' && val !== null && !Array.isArray(val)) {
|
|
142
|
+
const nested = val;
|
|
143
|
+
parsed.result = {
|
|
144
|
+
...(typeof nested.kind === 'string' ? { kind: nested.kind } : {}),
|
|
145
|
+
...(typeof nested.reason === 'string' ? { reason: nested.reason } : {}),
|
|
146
|
+
...(typeof nested.note === 'string' ? { note: nested.note } : {}),
|
|
147
|
+
...(typeof nested.nextAction === 'string' ? { nextAction: nested.nextAction } : {}),
|
|
148
|
+
};
|
|
149
|
+
}
|
|
141
150
|
}
|
|
142
151
|
}
|
|
143
152
|
}
|
|
144
153
|
catch {
|
|
145
154
|
// keep the empty shape; the message below stays generic
|
|
146
155
|
}
|
|
147
|
-
|
|
156
|
+
const isNoUpdate = parsed.result?.kind === 'no_update';
|
|
157
|
+
if (parsed.ok === false || isNoUpdate) {
|
|
158
|
+
const refusalReason = isNoUpdate
|
|
159
|
+
? parsed.result?.reason ?? 'update_refused'
|
|
160
|
+
: parsed.reason ?? 'bootstrap_executor_refused';
|
|
161
|
+
const refusalMessage = isNoUpdate
|
|
162
|
+
? parsed.result?.note ?? 'The update was refused without a runtime change.'
|
|
163
|
+
: parsed.message ?? 'The bootstrap executor refused the update.';
|
|
164
|
+
const refusalNextAction = (isNoUpdate ? parsed.result?.nextAction : parsed.nextAction)
|
|
165
|
+
?? 'No runtime change was made. Resolve the reported cause, then retry.';
|
|
148
166
|
appendGovernedUpdateHistory(workspaceDir, {
|
|
149
167
|
fromVersion, toVersion: fromVersion, success: false, kind: 'refusal',
|
|
150
|
-
reason:
|
|
151
|
-
nextAction:
|
|
168
|
+
reason: refusalReason, authority: 'release-manager',
|
|
169
|
+
nextAction: refusalNextAction,
|
|
152
170
|
});
|
|
153
171
|
sendSuccess(res, {
|
|
154
172
|
success: false,
|
|
155
173
|
refusal: true,
|
|
156
174
|
state: 'update_blocked',
|
|
157
|
-
reason:
|
|
158
|
-
message:
|
|
175
|
+
reason: refusalReason,
|
|
176
|
+
message: refusalMessage,
|
|
159
177
|
requiresRestart: false,
|
|
160
|
-
nextAction:
|
|
178
|
+
nextAction: refusalNextAction,
|
|
161
179
|
});
|
|
162
180
|
return;
|
|
163
181
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request-origin guard for the credential-less console.
|
|
3
|
+
*
|
|
4
|
+
* The OS session is the trust boundary for *local* clients, but a browser page
|
|
5
|
+
* served from another origin can still reach `127.0.0.1:<port>`:
|
|
6
|
+
*
|
|
7
|
+
* - cross-site `fetch`/form POSTs are "simple requests" and reach the server
|
|
8
|
+
* even though the response is unreadable (CSRF);
|
|
9
|
+
* - DNS rebinding makes an attacker origin look same-origin, which also lets
|
|
10
|
+
* it read responses.
|
|
11
|
+
*
|
|
12
|
+
* The guard therefore enforces two independent facts and lets non-browser
|
|
13
|
+
* clients through unchanged:
|
|
14
|
+
*
|
|
15
|
+
* - `Host` must be a loopback literal (defeats rebinding);
|
|
16
|
+
* - when the browser tells us the provenance (`Origin` / `Sec-Fetch-Site`), it
|
|
17
|
+
* must be this console's own origin (defeats cross-site CSRF);
|
|
18
|
+
* - no `Origin` and no `Sec-Fetch-Site` means a non-browser client and is
|
|
19
|
+
* allowed — that is how the CLI, installer probes and scripts keep working.
|
|
20
|
+
*
|
|
21
|
+
* State-changing requests with a body must also be JSON: that keeps the
|
|
22
|
+
* "simple request" form/text submission path closed even if a future browser
|
|
23
|
+
* omits the provenance headers.
|
|
24
|
+
*/
|
|
25
|
+
import type { IncomingMessage } from 'node:http';
|
|
26
|
+
export interface RequestGuardRejection {
|
|
27
|
+
status: number;
|
|
28
|
+
error: string;
|
|
29
|
+
message: string;
|
|
30
|
+
nextAction: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns `null` when the request may proceed, or a structured rejection.
|
|
34
|
+
*/
|
|
35
|
+
export declare function guardConsoleApiRequest(req: IncomingMessage): RequestGuardRejection | null;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const LOOPBACK_HOSTNAMES = new Set(['127.0.0.1', 'localhost', '::1']);
|
|
2
|
+
const MUTATING_METHODS = new Set(['POST', 'PUT', 'PATCH']);
|
|
3
|
+
function stripBrackets(hostname) {
|
|
4
|
+
return hostname.replace(/^\[(.+)\]$/, '$1');
|
|
5
|
+
}
|
|
6
|
+
function loopbackHostOf(url) {
|
|
7
|
+
const hostname = stripBrackets(url.hostname.toLowerCase());
|
|
8
|
+
return LOOPBACK_HOSTNAMES.has(hostname) ? hostname : null;
|
|
9
|
+
}
|
|
10
|
+
function forbidden(reason) {
|
|
11
|
+
return {
|
|
12
|
+
status: 403,
|
|
13
|
+
error: reason,
|
|
14
|
+
message: 'Cross-origin requests are not accepted by the local Console.',
|
|
15
|
+
nextAction: 'Open the Console from its own address; browser extensions and remote pages cannot drive it.',
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns `null` when the request may proceed, or a structured rejection.
|
|
20
|
+
*/
|
|
21
|
+
export function guardConsoleApiRequest(req) {
|
|
22
|
+
const hostHeader = typeof req.headers.host === 'string' ? req.headers.host : '';
|
|
23
|
+
if (hostHeader.length > 0) {
|
|
24
|
+
try {
|
|
25
|
+
if (loopbackHostOf(new URL(`http://${hostHeader}`)) === null) {
|
|
26
|
+
return {
|
|
27
|
+
status: 403,
|
|
28
|
+
error: 'forbidden_host',
|
|
29
|
+
message: 'Requests must target the local Console address.',
|
|
30
|
+
nextAction: 'Use the loopback address the Console printed at startup (127.0.0.1 or localhost).',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return {
|
|
36
|
+
status: 403,
|
|
37
|
+
error: 'forbidden_host',
|
|
38
|
+
message: 'Requests must target the local Console address.',
|
|
39
|
+
nextAction: 'Use the loopback address the Console printed at startup (127.0.0.1 or localhost).',
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const { origin } = req.headers;
|
|
44
|
+
if (typeof origin === 'string' && origin.length > 0) {
|
|
45
|
+
let parsed;
|
|
46
|
+
try {
|
|
47
|
+
parsed = new URL(origin);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return forbidden('forbidden_origin');
|
|
51
|
+
}
|
|
52
|
+
if (loopbackHostOf(parsed) === null) {
|
|
53
|
+
return forbidden('forbidden_origin');
|
|
54
|
+
}
|
|
55
|
+
// Same-origin means the browser's page and this request share host:port.
|
|
56
|
+
// `Origin: null` (file:, sandboxed frames) never reaches here as a match.
|
|
57
|
+
if (hostHeader.length > 0 && parsed.host.toLowerCase() !== hostHeader.toLowerCase()) {
|
|
58
|
+
return forbidden('forbidden_origin');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const secFetchSite = req.headers['sec-fetch-site'];
|
|
62
|
+
if (typeof secFetchSite === 'string' && secFetchSite.length > 0) {
|
|
63
|
+
if (secFetchSite !== 'same-origin' && secFetchSite !== 'none') {
|
|
64
|
+
return forbidden('forbidden_origin');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const method = (req.method ?? 'GET').toUpperCase();
|
|
68
|
+
if (MUTATING_METHODS.has(method)) {
|
|
69
|
+
const contentLength = Number(req.headers['content-length'] ?? '0');
|
|
70
|
+
const contentType = String(req.headers['content-type'] ?? '').toLowerCase();
|
|
71
|
+
if (contentLength > 0 && !contentType.startsWith('application/json')) {
|
|
72
|
+
return {
|
|
73
|
+
status: 415,
|
|
74
|
+
error: 'unsupported_media_type',
|
|
75
|
+
message: 'Console write endpoints require an application/json request body.',
|
|
76
|
+
nextAction: 'Send the request body as JSON with Content-Type: application/json.',
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
@@ -13,6 +13,5 @@ export declare function sendJson(res: ServerResponse, statusCode: number, payloa
|
|
|
13
13
|
export declare function sendSuccess<T>(res: ServerResponse, data: T): void;
|
|
14
14
|
export declare function sendError(res: ServerResponse, statusCode: number, error: string, message?: string, extras?: Record<string, unknown>): void;
|
|
15
15
|
export declare function sendNotFound(res: ServerResponse, message?: string): void;
|
|
16
|
-
export declare function sendUnauthorized(res: ServerResponse, message?: string): void;
|
|
17
16
|
export declare function sendMethodNotAllowed(res: ServerResponse): void;
|
|
18
17
|
export declare function sendBadRequest(res: ServerResponse, message: string): void;
|
|
@@ -50,9 +50,6 @@ export function sendError(res, statusCode, error, message, extras) {
|
|
|
50
50
|
export function sendNotFound(res, message = 'Not found') {
|
|
51
51
|
sendError(res, 404, 'not_found', message);
|
|
52
52
|
}
|
|
53
|
-
export function sendUnauthorized(res, message = 'Unauthorized') {
|
|
54
|
-
sendError(res, 401, 'unauthorized', message);
|
|
55
|
-
}
|
|
56
53
|
export function sendMethodNotAllowed(res) {
|
|
57
54
|
sendError(res, 405, 'method_not_allowed', 'Method not allowed');
|
|
58
55
|
}
|