create-principles-disciple 1.154.5 → 1.155.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +2 -2
- package/codex-adapter/dist/codec/input-decoder.d.ts +17 -0
- package/codex-adapter/dist/codec/input-decoder.js +39 -0
- package/codex-adapter/dist/ingestion/explicit-owner-statement.js +125 -1
- package/codex-adapter/dist/ingestion/pain-receipt-fallback.d.ts +46 -0
- package/codex-adapter/dist/ingestion/pain-receipt-fallback.js +193 -0
- package/codex-adapter/dist/ingestion/turn-context.d.ts +10 -15
- package/codex-adapter/dist/ingestion/turn-context.js +35 -9
- package/codex-adapter/dist/pd-hook.js +57 -1
- package/codex-adapter/dist/worker/workspace-worker.d.ts +15 -0
- package/codex-adapter/dist/worker/workspace-worker.js +91 -12
- package/codex-adapter/package.json +1 -1
- package/console/dist/server/index.js +11 -0
- package/console/dist/server/models/EvidenceChainConsoleModel.js +31 -0
- package/console/dist/server/routes/health.d.ts +1 -0
- package/console/dist/server/routes/health.js +12 -0
- package/console/dist/server/routes/service-host.d.ts +19 -0
- package/console/dist/server/routes/service-host.js +129 -0
- package/console/dist/web/assets/app.js +39 -39
- package/console/package.json +1 -1
- package/core/dist/runtime/adapter/pi-ai-http-transport.d.ts.map +1 -1
- package/core/dist/runtime/adapter/pi-ai-http-transport.js.map +1 -1
- package/core/dist/runtime/context-payload.d.ts +48 -0
- package/core/dist/runtime/context-payload.d.ts.map +1 -1
- package/core/dist/runtime/context-payload.js +12 -0
- package/core/dist/runtime/context-payload.js.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js +18 -0
- package/core/dist/runtime/diagnostician/rootcause-prompt-builder.js.map +1 -1
- package/core/dist/runtime/diagnostician-candidate.d.ts.map +1 -1
- package/core/dist/runtime/diagnostician-candidate.js +18 -2
- package/core/dist/runtime/diagnostician-candidate.js.map +1 -1
- package/core/dist/runtime/evidence-guards.d.ts +7 -3
- package/core/dist/runtime/evidence-guards.d.ts.map +1 -1
- package/core/dist/runtime/evidence-guards.js +9 -7
- package/core/dist/runtime/evidence-guards.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-contract.js +14 -0
- package/core/dist/runtime/feature-flags/feature-flag-contract.js.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +8 -0
- package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
- package/core/dist/runtime/host-submission-context.d.ts +83 -0
- package/core/dist/runtime/host-submission-context.d.ts.map +1 -0
- package/core/dist/runtime/host-submission-context.js +183 -0
- package/core/dist/runtime/host-submission-context.js.map +1 -0
- package/core/dist/runtime/index.d.ts +9 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +29 -2
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
- package/core/dist/runtime/intent/intent-doc.js +29 -5
- package/core/dist/runtime/intent/intent-doc.js.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts +9 -0
- package/core/dist/runtime/internalization/diag-distiller-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-distiller-runner.js +13 -0
- package/core/dist/runtime/internalization/diag-distiller-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +11 -0
- package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-rootcause-runner.js +10 -0
- package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.d.ts +9 -0
- package/core/dist/runtime/internalization/diag-router-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/diag-router-runner.js +13 -0
- package/core/dist/runtime/internalization/diag-router-runner.js.map +1 -1
- package/core/dist/runtime/internalization/index.d.ts +1 -1
- package/core/dist/runtime/internalization/index.d.ts.map +1 -1
- package/core/dist/runtime/internalization/index.js +1 -1
- package/core/dist/runtime/internalization/index.js.map +1 -1
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts +19 -0
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.d.ts.map +1 -1
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.js +24 -0
- package/core/dist/runtime/internalization/intake-to-internalization-bridge.js.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts +8 -0
- package/core/dist/runtime/internalization/internalization-orchestrator.d.ts.map +1 -1
- package/core/dist/runtime/internalization/internalization-orchestrator.js +36 -4
- package/core/dist/runtime/internalization/internalization-orchestrator.js.map +1 -1
- package/core/dist/runtime/internalization/source-authorization-boundary.d.ts +39 -0
- package/core/dist/runtime/internalization/source-authorization-boundary.d.ts.map +1 -0
- package/core/dist/runtime/internalization/source-authorization-boundary.js +57 -0
- package/core/dist/runtime/internalization/source-authorization-boundary.js.map +1 -0
- package/core/dist/runtime/internalization/split-diagnostician-runner.d.ts.map +1 -1
- package/core/dist/runtime/internalization/split-diagnostician-runner.js +72 -5
- package/core/dist/runtime/internalization/split-diagnostician-runner.js.map +1 -1
- package/core/dist/runtime/pain-admission-disposition.d.ts +60 -0
- package/core/dist/runtime/pain-admission-disposition.d.ts.map +1 -0
- package/core/dist/runtime/pain-admission-disposition.js +37 -0
- package/core/dist/runtime/pain-admission-disposition.js.map +1 -0
- package/core/dist/runtime/pain-ingress-payload.d.ts +36 -2
- package/core/dist/runtime/pain-ingress-payload.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress-payload.js +63 -6
- package/core/dist/runtime/pain-ingress-payload.js.map +1 -1
- package/core/dist/runtime/pain-ingress.d.ts.map +1 -1
- package/core/dist/runtime/pain-ingress.js +28 -0
- package/core/dist/runtime/pain-ingress.js.map +1 -1
- package/core/dist/runtime/pain-recall-read-model.d.ts +13 -1
- package/core/dist/runtime/pain-recall-read-model.d.ts.map +1 -1
- package/core/dist/runtime/pain-recall-read-model.js +50 -7
- package/core/dist/runtime/pain-recall-read-model.js.map +1 -1
- package/core/dist/runtime/pain-receipt-recovery.d.ts +147 -0
- package/core/dist/runtime/pain-receipt-recovery.d.ts.map +1 -0
- package/core/dist/runtime/pain-receipt-recovery.js +475 -0
- package/core/dist/runtime/pain-receipt-recovery.js.map +1 -0
- package/core/dist/runtime/pain-signal-bridge.d.ts +13 -1
- package/core/dist/runtime/pain-signal-bridge.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-bridge.js +174 -0
- package/core/dist/runtime/pain-signal-bridge.js.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts +9 -0
- package/core/dist/runtime/pain-signal-runtime-factory.d.ts.map +1 -1
- package/core/dist/runtime/pain-signal-runtime-factory.js +8 -3
- package/core/dist/runtime/pain-signal-runtime-factory.js.map +1 -1
- package/core/dist/runtime/pain-submit-capability.d.ts +11 -0
- package/core/dist/runtime/pain-submit-capability.d.ts.map +1 -1
- package/core/dist/runtime/pain-submit-capability.js +77 -3
- package/core/dist/runtime/pain-submit-capability.js.map +1 -1
- package/core/dist/runtime/pain-target-evidence-reconcile.d.ts +55 -0
- package/core/dist/runtime/pain-target-evidence-reconcile.d.ts.map +1 -0
- package/core/dist/runtime/pain-target-evidence-reconcile.js +164 -0
- package/core/dist/runtime/pain-target-evidence-reconcile.js.map +1 -0
- package/core/dist/runtime/pain-to-principle-service.d.ts +8 -0
- package/core/dist/runtime/pain-to-principle-service.d.ts.map +1 -1
- package/core/dist/runtime/pain-to-principle-service.js +1 -0
- package/core/dist/runtime/pain-to-principle-service.js.map +1 -1
- package/core/dist/runtime/source-material-authorization.d.ts +166 -0
- package/core/dist/runtime/source-material-authorization.d.ts.map +1 -0
- package/core/dist/runtime/source-material-authorization.js +250 -0
- package/core/dist/runtime/source-material-authorization.js.map +1 -0
- package/core/dist/runtime/store/context/index.d.ts +1 -0
- package/core/dist/runtime/store/context/index.d.ts.map +1 -1
- package/core/dist/runtime/store/context/index.js +1 -0
- package/core/dist/runtime/store/context/index.js.map +1 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts +8 -0
- package/core/dist/runtime/store/context/promoted-evidence-reader.d.ts.map +1 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.js +15 -1
- package/core/dist/runtime/store/context/promoted-evidence-reader.js.map +1 -1
- package/core/dist/runtime/store/context/sqlite-context-assembler.d.ts +22 -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 +153 -3
- package/core/dist/runtime/store/context/sqlite-context-assembler.js.map +1 -1
- package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts +13 -0
- package/core/dist/runtime/store/context/trajectory-turn-reader.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts +15 -0
- package/core/dist/runtime/store/lifecycle/lease-manager.d.ts.map +1 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.js +16 -1
- package/core/dist/runtime/store/lifecycle/lease-manager.js.map +1 -1
- package/core/dist/runtime/store/runtime-state-manager.d.ts +2 -0
- 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/task/memory-task-store.d.ts +1 -0
- package/core/dist/runtime/store/task/memory-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/memory-task-store.js +37 -0
- package/core/dist/runtime/store/task/memory-task-store.js.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts +10 -0
- package/core/dist/runtime/store/task/sqlite-task-store.d.ts.map +1 -1
- package/core/dist/runtime/store/task/sqlite-task-store.js +20 -0
- package/core/dist/runtime/store/task/sqlite-task-store.js.map +1 -1
- package/core/dist/runtime/store/task/task-store.d.ts +16 -0
- package/core/dist/runtime/store/task/task-store.d.ts.map +1 -1
- package/core/dist/runtime/task-status.d.ts +13 -0
- package/core/dist/runtime/task-status.d.ts.map +1 -1
- package/core/dist/runtime/task-status.js +9 -0
- package/core/dist/runtime/task-status.js.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.d.ts +10 -0
- package/core/dist/runtime/types/evidence-chain-contract.d.ts.map +1 -1
- package/core/dist/runtime/types/evidence-chain-contract.js +7 -0
- package/core/dist/runtime/types/evidence-chain-contract.js.map +1 -1
- package/core/package.json +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +77 -30
- package/dist/installer.js.map +1 -1
- package/dist/installers/mcp-registration-conflict.d.ts +8 -0
- package/dist/installers/mcp-registration-conflict.d.ts.map +1 -1
- package/dist/installers/mcp-registration-conflict.js +34 -1
- package/dist/installers/mcp-registration-conflict.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts +45 -13
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +284 -21
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/dist/prompts.d.ts +11 -0
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +4 -0
- package/dist/prompts.js.map +1 -1
- package/dist/service-host-bridge.d.ts +67 -0
- package/dist/service-host-bridge.d.ts.map +1 -0
- package/dist/service-host-bridge.js +292 -0
- package/dist/service-host-bridge.js.map +1 -0
- package/dist/uninstaller.d.ts.map +1 -1
- package/dist/uninstaller.js +26 -0
- package/dist/uninstaller.js.map +1 -1
- package/dist/update/install-layout.d.ts +0 -12
- package/dist/update/install-layout.d.ts.map +1 -1
- package/dist/update/install-layout.js +42 -15
- package/dist/update/install-layout.js.map +1 -1
- package/host-runtime/dist/diagnostician-auto-run.js +4 -1
- package/host-runtime/dist/governance-observation-store.d.ts +7 -0
- package/host-runtime/dist/governance-observation-store.js +15 -4
- package/host-runtime/dist/governance-signal-admission.d.ts +49 -0
- package/host-runtime/dist/governance-signal-admission.js +355 -94
- package/host-runtime/dist/governance-trajectory-turn-reader.d.ts +20 -4
- package/host-runtime/dist/governance-trajectory-turn-reader.js +77 -5
- package/host-runtime/dist/index.d.ts +2 -0
- package/host-runtime/dist/index.js +5 -0
- package/host-runtime/dist/internalization-consumer-cycle.js +4 -1
- package/host-runtime/dist/pd-config.d.ts +10 -0
- package/host-runtime/dist/pd-config.js +37 -0
- package/host-runtime/dist/signal-stage2-cycle.js +28 -1
- package/host-runtime/dist/source-material-authorization.d.ts +53 -0
- package/host-runtime/dist/source-material-authorization.js +67 -0
- package/host-runtime/dist/source-revocation-sweep.d.ts +172 -0
- package/host-runtime/dist/source-revocation-sweep.js +928 -0
- package/host-runtime/package.json +5 -1
- package/install-layout/dist/background-execution-transition.d.ts +258 -0
- package/install-layout/dist/background-execution-transition.js +836 -0
- package/install-layout/dist/index.d.ts +8 -0
- package/install-layout/dist/index.js +8 -0
- package/install-layout/package.json +6 -2
- package/package.json +7 -6
- package/pd-cli/dist/commands/candidate.d.ts.map +1 -1
- package/pd-cli/dist/commands/candidate.js +16 -5
- package/pd-cli/dist/commands/candidate.js.map +1 -1
- package/pd-cli/dist/commands/codex-setup.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-setup.js +17 -1
- package/pd-cli/dist/commands/codex-setup.js.map +1 -1
- package/pd-cli/dist/commands/codex-worker.d.ts.map +1 -1
- package/pd-cli/dist/commands/codex-worker.js +8 -4
- package/pd-cli/dist/commands/codex-worker.js.map +1 -1
- package/pd-cli/dist/commands/consent-sweep-revoked.d.ts +20 -0
- package/pd-cli/dist/commands/consent-sweep-revoked.d.ts.map +1 -0
- package/pd-cli/dist/commands/consent-sweep-revoked.js +85 -0
- package/pd-cli/dist/commands/consent-sweep-revoked.js.map +1 -0
- package/pd-cli/dist/commands/console.d.ts.map +1 -1
- package/pd-cli/dist/commands/console.js +9 -0
- package/pd-cli/dist/commands/console.js.map +1 -1
- package/pd-cli/dist/commands/context.d.ts.map +1 -1
- package/pd-cli/dist/commands/context.js +9 -1
- package/pd-cli/dist/commands/context.js.map +1 -1
- package/pd-cli/dist/commands/diagnose.d.ts.map +1 -1
- package/pd-cli/dist/commands/diagnose.js +12 -6
- package/pd-cli/dist/commands/diagnose.js.map +1 -1
- package/pd-cli/dist/commands/health-console.d.ts +1 -1
- package/pd-cli/dist/commands/health-console.d.ts.map +1 -1
- package/pd-cli/dist/commands/health-console.js +15 -1
- package/pd-cli/dist/commands/health-console.js.map +1 -1
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +7 -1
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/openclaw-worker.d.ts +11 -0
- package/pd-cli/dist/commands/openclaw-worker.d.ts.map +1 -0
- package/pd-cli/dist/commands/openclaw-worker.js +199 -0
- package/pd-cli/dist/commands/openclaw-worker.js.map +1 -0
- package/pd-cli/dist/commands/pain-explicit.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-explicit.js +1 -0
- package/pd-cli/dist/commands/pain-explicit.js.map +1 -1
- package/pd-cli/dist/commands/pain-recall.d.ts +2 -2
- package/pd-cli/dist/commands/pain-recall.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-recall.js +7 -1
- package/pd-cli/dist/commands/pain-recall.js.map +1 -1
- package/pd-cli/dist/commands/pain-retry.d.ts.map +1 -1
- package/pd-cli/dist/commands/pain-retry.js +12 -6
- package/pd-cli/dist/commands/pain-retry.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js +2 -1
- package/pd-cli/dist/commands/runtime-internalization-enqueue-successors.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts +1 -0
- package/pd-cli/dist/commands/runtime-internalization-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-run-once.js +32 -8
- package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-wake-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/runtime-internalization-wake-once.js +2 -1
- package/pd-cli/dist/commands/runtime-internalization-wake-once.js.map +1 -1
- package/pd-cli/dist/commands/service-handover.d.ts +12 -0
- package/pd-cli/dist/commands/service-handover.d.ts.map +1 -0
- package/pd-cli/dist/commands/service-handover.js +117 -0
- package/pd-cli/dist/commands/service-handover.js.map +1 -0
- package/pd-cli/dist/commands/service-lifecycle.d.ts +31 -0
- package/pd-cli/dist/commands/service-lifecycle.d.ts.map +1 -0
- package/pd-cli/dist/commands/service-lifecycle.js +207 -0
- package/pd-cli/dist/commands/service-lifecycle.js.map +1 -0
- package/pd-cli/dist/commands/service-run-once.d.ts +96 -0
- package/pd-cli/dist/commands/service-run-once.d.ts.map +1 -1
- package/pd-cli/dist/commands/service-run-once.js +432 -13
- package/pd-cli/dist/commands/service-run-once.js.map +1 -1
- package/pd-cli/dist/commands/workbuddy-setup.d.ts.map +1 -1
- package/pd-cli/dist/commands/workbuddy-setup.js +22 -2
- package/pd-cli/dist/commands/workbuddy-setup.js.map +1 -1
- package/pd-cli/dist/program.d.ts.map +1 -1
- package/pd-cli/dist/program.js +167 -9
- package/pd-cli/dist/program.js.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts +3 -1
- package/pd-cli/dist/services/admission-write-gate.d.ts.map +1 -1
- package/pd-cli/dist/services/admission-write-gate.js +1 -0
- package/pd-cli/dist/services/admission-write-gate.js.map +1 -1
- package/pd-cli/dist/services/console-launcher.d.ts +93 -1
- package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
- package/pd-cli/dist/services/console-launcher.js +375 -10
- package/pd-cli/dist/services/console-launcher.js.map +1 -1
- package/pd-cli/dist/services/service-host/coordinator-common.d.ts +49 -0
- package/pd-cli/dist/services/service-host/coordinator-common.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/coordinator-common.js +158 -0
- package/pd-cli/dist/services/service-host/coordinator-common.js.map +1 -0
- package/pd-cli/dist/services/service-host/handover-claims.d.ts +14 -0
- package/pd-cli/dist/services/service-host/handover-claims.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/handover-claims.js +50 -0
- package/pd-cli/dist/services/service-host/handover-claims.js.map +1 -0
- package/pd-cli/dist/services/service-host/index.d.ts +19 -3
- package/pd-cli/dist/services/service-host/index.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/index.js +21 -3
- package/pd-cli/dist/services/service-host/index.js.map +1 -1
- package/pd-cli/dist/services/service-host/install-identity.d.ts +23 -3
- package/pd-cli/dist/services/service-host/install-identity.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/install-identity.js +15 -5
- package/pd-cli/dist/services/service-host/install-identity.js.map +1 -1
- package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts +130 -9
- package/pd-cli/dist/services/service-host/locking/service-run-lock.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/locking/service-run-lock.js +99 -19
- package/pd-cli/dist/services/service-host/locking/service-run-lock.js.map +1 -1
- package/pd-cli/dist/services/service-host/managed-run.d.ts +75 -0
- package/pd-cli/dist/services/service-host/managed-run.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/managed-run.js +550 -0
- package/pd-cli/dist/services/service-host/managed-run.js.map +1 -0
- package/pd-cli/dist/services/service-host/progress-evidence.d.ts +38 -0
- package/pd-cli/dist/services/service-host/progress-evidence.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/progress-evidence.js +155 -0
- package/pd-cli/dist/services/service-host/progress-evidence.js.map +1 -0
- package/pd-cli/dist/services/service-host/run-once.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/run-once.js +4 -136
- package/pd-cli/dist/services/service-host/run-once.js.map +1 -1
- package/pd-cli/dist/services/service-host/scheduler/contract.d.ts +184 -0
- package/pd-cli/dist/services/service-host/scheduler/contract.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/contract.js +86 -0
- package/pd-cli/dist/services/service-host/scheduler/contract.js.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/index.d.ts +76 -0
- package/pd-cli/dist/services/service-host/scheduler/index.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/index.js +128 -0
- package/pd-cli/dist/services/service-host/scheduler/index.js.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/linux.d.ts +27 -0
- package/pd-cli/dist/services/service-host/scheduler/linux.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/linux.js +1010 -0
- package/pd-cli/dist/services/service-host/scheduler/linux.js.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/macos.d.ts +13 -0
- package/pd-cli/dist/services/service-host/scheduler/macos.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/macos.js +819 -0
- package/pd-cli/dist/services/service-host/scheduler/macos.js.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts +13 -0
- package/pd-cli/dist/services/service-host/scheduler/runtime-io.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/runtime-io.js +141 -0
- package/pd-cli/dist/services/service-host/scheduler/runtime-io.js.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts +99 -0
- package/pd-cli/dist/services/service-host/scheduler/service-status.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/service-status.js +202 -0
- package/pd-cli/dist/services/service-host/scheduler/service-status.js.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/windows.d.ts +40 -0
- package/pd-cli/dist/services/service-host/scheduler/windows.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/scheduler/windows.js +688 -0
- package/pd-cli/dist/services/service-host/scheduler/windows.js.map +1 -0
- package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts +43 -0
- package/pd-cli/dist/services/service-host/shadow-progress-store.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/shadow-progress-store.js +156 -0
- package/pd-cli/dist/services/service-host/shadow-progress-store.js.map +1 -0
- package/pd-cli/dist/services/service-host/shadow-run.d.ts +87 -0
- package/pd-cli/dist/services/service-host/shadow-run.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/shadow-run.js +549 -0
- package/pd-cli/dist/services/service-host/shadow-run.js.map +1 -0
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts +114 -4
- package/pd-cli/dist/services/service-host/status/service-run-status.d.ts.map +1 -1
- package/pd-cli/dist/services/service-host/status/service-run-status.js +37 -0
- package/pd-cli/dist/services/service-host/status/service-run-status.js.map +1 -1
- package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts +2 -0
- package/pd-cli/dist/services/service-host/worker-adapter-codex.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter-codex.js +76 -0
- package/pd-cli/dist/services/service-host/worker-adapter-codex.js.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts +2 -0
- package/pd-cli/dist/services/service-host/worker-adapter-openclaw.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js +49 -0
- package/pd-cli/dist/services/service-host/worker-adapter-openclaw.js.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts +2 -0
- package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js +36 -0
- package/pd-cli/dist/services/service-host/worker-adapter-workbuddy.js.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter.d.ts +187 -0
- package/pd-cli/dist/services/service-host/worker-adapter.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/worker-adapter.js +609 -0
- package/pd-cli/dist/services/service-host/worker-adapter.js.map +1 -0
- package/pd-cli/dist/services/service-host/worker-env.d.ts +84 -0
- package/pd-cli/dist/services/service-host/worker-env.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/worker-env.js +195 -0
- package/pd-cli/dist/services/service-host/worker-env.js.map +1 -0
- package/pd-cli/dist/services/service-host/worker-process.d.ts +75 -0
- package/pd-cli/dist/services/service-host/worker-process.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/worker-process.js +225 -0
- package/pd-cli/dist/services/service-host/worker-process.js.map +1 -0
- package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts +61 -0
- package/pd-cli/dist/services/service-host/workspace-dispatch.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/workspace-dispatch.js +105 -0
- package/pd-cli/dist/services/service-host/workspace-dispatch.js.map +1 -0
- package/pd-cli/dist/services/service-host/workspace-handover.d.ts +190 -0
- package/pd-cli/dist/services/service-host/workspace-handover.d.ts.map +1 -0
- package/pd-cli/dist/services/service-host/workspace-handover.js +1393 -0
- package/pd-cli/dist/services/service-host/workspace-handover.js.map +1 -0
- package/pd-cli/package.json +6 -5
- package/pd-mcp-server/dist/submit-assembly.js +159 -42
- package/pd-mcp-server/dist/version.d.ts +1 -1
- package/pd-mcp-server/dist/version.js +1 -1
- package/pd-mcp-server/package.json +1 -1
- package/plugin/dist/bundle.js +662 -637
- package/plugin/dist/openclaw-worker.d.ts +92 -0
- package/plugin/dist/openclaw-worker.js +2446 -0
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/service/gateway-consumer-lease.d.ts +142 -0
- package/plugin/dist/service/gateway-quiesce-ack.d.ts +40 -0
- package/plugin/dist/service/internalization-auto-consumer-service.d.ts +68 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +5 -1
- package/release-manager/dist/installer.js +77 -30
- package/release-manager/dist/installers/mcp-registration-conflict.js +34 -1
- package/release-manager/dist/installers/workbuddy-host-installer.js +284 -21
- package/release-manager/dist/service-host-bridge.js +292 -0
- package/release-manager/dist/update/install-layout.js +42 -15
- package/release-manager/package.json +5 -4
- package/workbuddy-adapter/dist/index.d.ts +1 -1
- package/workbuddy-adapter/dist/index.js +1 -1
- package/workbuddy-adapter/dist/worker/workspace-worker.d.ts +7 -0
- package/workbuddy-adapter/dist/worker/workspace-worker.js +179 -10
- package/workbuddy-adapter/package.json +1 -1
- package/workbuddy-adapter/plugin/.codebuddy-plugin/plugin.json +2 -2
|
@@ -13,6 +13,8 @@ import { CodexHooksHostAdapter } from './host-adapter.js';
|
|
|
13
13
|
import { CodexDecoderError, CodexEncoderError } from './codec/index.js';
|
|
14
14
|
import { ingestCodexConversation } from './ingestion/ingestion.js';
|
|
15
15
|
import { runGovernanceAdmission } from './ingestion/admission.js';
|
|
16
|
+
import { attemptPainReceiptFallback, painReceiptFallbackDiagnostic } from './ingestion/pain-receipt-fallback.js';
|
|
17
|
+
import { isPainSubmitPostToolUseToolName } from './codec/input-decoder.js';
|
|
16
18
|
import { parseOwnerStatementPrefix, recordExplicitOwnerStatement } from './ingestion/explicit-owner-statement.js';
|
|
17
19
|
import { writeCurrentTurnContext, clearCurrentTurnContext } from './ingestion/turn-context.js';
|
|
18
20
|
import { recordCodexPromptDeliveryEvidence, recordCodexDenyEvidence } from './codex-evidence-recorder.js';
|
|
@@ -912,7 +914,61 @@ export async function processHookInvocation(rawStdin, _env = process.env, cwd =
|
|
|
912
914
|
evidenceDiagnostics.push(diagnostic(`codex_evidence_deny_failed:${errorMessage(error)}`, 'The deny decision was already encoded; evidence replay from the durable source is safe.'));
|
|
913
915
|
}
|
|
914
916
|
}
|
|
915
|
-
|
|
917
|
+
// PRI-1274 (B1): PostToolUse structured-receipt fallback. When a
|
|
918
|
+
// pd_submit_pain MCP request carried no trusted host `_meta`, its
|
|
919
|
+
// original Pain/Task was legally persisted unbound; the host completion
|
|
920
|
+
// event's own structured receipt + host-authoritative identity now
|
|
921
|
+
// restores the SAME task via the Core CAS recovery. P1-1: the tool name
|
|
922
|
+
// arrives in Codex's MCP namespace (`mcp__pd_recall__pd_submit_pain`) and
|
|
923
|
+
// is gated by the exact codec parser — a bare or foreign-server name
|
|
924
|
+
// never enters. Independent of codex_conversation_ingestion (no
|
|
925
|
+
// transcript read; ids only), gated by the Workspace-level
|
|
926
|
+
// host_identity_minimal_metadata authorization. Fail-open: a fallback
|
|
927
|
+
// failure never changes the host decision.
|
|
928
|
+
const receiptDiagnostics = [];
|
|
929
|
+
if (event.kind === 'after_tool_call'
|
|
930
|
+
&& event.context.toolName !== undefined
|
|
931
|
+
&& isPainSubmitPostToolUseToolName(event.context.toolName)
|
|
932
|
+
&& event.context.toolCallId !== undefined) {
|
|
933
|
+
try {
|
|
934
|
+
const fallback = await attemptPainReceiptFallback({
|
|
935
|
+
workspaceDir: resolution.workspaceDir,
|
|
936
|
+
toolName: event.context.toolName,
|
|
937
|
+
toolResponse: event.context.toolOutput,
|
|
938
|
+
identity: {
|
|
939
|
+
sessionId: event.context.sessionId,
|
|
940
|
+
...(event.context.turnId !== undefined ? { turnId: event.context.turnId } : {}),
|
|
941
|
+
toolCallId: event.context.toolCallId,
|
|
942
|
+
},
|
|
943
|
+
minimalMetadataGranted: flags.host_identity_minimal_metadata?.enabled === true,
|
|
944
|
+
});
|
|
945
|
+
const line = painReceiptFallbackDiagnostic(fallback);
|
|
946
|
+
if (line !== null) {
|
|
947
|
+
// P1-5 (option B): the nextAction states EXACTLY what happened —
|
|
948
|
+
// only `recovered`/`already_bound` mean the task carries the
|
|
949
|
+
// identity; a refusal left the submission legally unbound and is
|
|
950
|
+
// NOT retried by any worker cycle.
|
|
951
|
+
const nextAction = fallback.status === 'not_applicable'
|
|
952
|
+
? undefined
|
|
953
|
+
: fallback.outcome.status === 'recovered'
|
|
954
|
+
? 'The submission identity was restored on the original task; no resubmission is needed.'
|
|
955
|
+
: fallback.outcome.status === 'already_bound'
|
|
956
|
+
? 'The original task already carries this identity; nothing to do.'
|
|
957
|
+
: fallback.outcome.reasonCode === 'blocked_by_consent'
|
|
958
|
+
? 'The Workspace has not granted minimal identity-metadata collection; enable host_identity_minimal_metadata in .pd/config.yaml if binding is wanted.'
|
|
959
|
+
: 'The recovery was refused and is not retried automatically; the submission stays legally unbound. Resubmit pd_submit_pain only if the binding is needed.';
|
|
960
|
+
receiptDiagnostics.push(nextAction === undefined
|
|
961
|
+
? diagnostic(line, 'The receipt fallback outcome was recorded.')
|
|
962
|
+
: diagnostic(line, nextAction));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
catch (error) {
|
|
966
|
+
// P1-5 (option B): no next-cycle retry exists for receipt recovery —
|
|
967
|
+
// the promise is removed rather than kept false.
|
|
968
|
+
receiptDiagnostics.push(diagnostic(`pain_receipt_fallback_failed:${errorMessage(error)}`, 'The hook decision is unaffected; identity recovery for this call did not complete and is not retried automatically — the submission stays legally unbound.'));
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
const stderr = [...(result.warnings ?? []).slice(0, 16).map((warning) => diagnostic(warning, 'Inspect PD Workspace state and retry; the hook failed open.')), ...evaluationDiagnostics, ...evidenceDiagnostics, ...ingestionDiagnostics, ...explicitDiagnostics, ...adaptiveDiagnostics, ...toolSemanticsDiagnostics, ...backgroundDiagnostics, ...receiptDiagnostics];
|
|
916
972
|
return { stdout: encoded, exitCode: 0, stderr };
|
|
917
973
|
}
|
|
918
974
|
catch (error) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TargetEvidenceReconcileReport } from '@principles/core/runtime';
|
|
1
2
|
import { type InternalizationConsumerCycleOutcome, type ConsumerCycleLogger, type ReconcileGovernanceContinuationResult, type SignalLlmClassifier, type Stage2CorrectionCycleReport } from '@principles/host-runtime';
|
|
2
3
|
import { type CodexCatchUpResult } from '../ingestion/catch-up.js';
|
|
3
4
|
import type { TranscriptPort } from '../ingestion/transcript-decoder.js';
|
|
@@ -34,6 +35,13 @@ export interface CodexWorkerCycleStepReport {
|
|
|
34
35
|
readonly reuseReviewRequiredCandidateIds?: readonly string[];
|
|
35
36
|
} | null;
|
|
36
37
|
readonly downstream: InternalizationConsumerCycleOutcome | null;
|
|
38
|
+
/**
|
|
39
|
+
* PRI-1274 (B1 / P1-3): bounded waiting-task reconcile — flips
|
|
40
|
+
* `waiting_for_target_evidence` dispositions to `ready_for_diagnosis`
|
|
41
|
+
* once the authorized store holds the exact target turn's text. Present
|
|
42
|
+
* only on cycles that reached the diagnostician step.
|
|
43
|
+
*/
|
|
44
|
+
readonly targetEvidenceReconcile?: TargetEvidenceReconcileReport;
|
|
37
45
|
/**
|
|
38
46
|
* Phase B Stage-2 review step. Always the LAST step so it can never starve
|
|
39
47
|
* the Diagnostician (bounded to ≤2 candidates / ≤60s aggregate).
|
|
@@ -66,6 +74,13 @@ export interface CodexWorkerCycleOptions {
|
|
|
66
74
|
readonly stage2Classifier?: SignalLlmClassifier | null;
|
|
67
75
|
readonly stage2AggregateBudgetMs?: number;
|
|
68
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* WHO drove this cycle (PRI-1264 attribution, Phase 2 extension). The
|
|
79
|
+
* Service Host sets `PD_INVOCATION_SOURCE=service_host` on its Worker
|
|
80
|
+
* children (shadow mode); without the third value the stall attribution
|
|
81
|
+
* would misreport service-driven cycles as manual (TD §5.2).
|
|
82
|
+
*/
|
|
83
|
+
export declare function codexWorkerCycleDriver(): 'companion' | 'service_host' | 'manual';
|
|
69
84
|
export declare function readCodexWorkerLiveness(workspaceDir: string): Record<string, unknown> | null;
|
|
70
85
|
/**
|
|
71
86
|
* SPEC §9.1 fair-share pick (review P1): pending and due-retry are both
|
|
@@ -27,9 +27,10 @@
|
|
|
27
27
|
*/
|
|
28
28
|
import fs from 'node:fs';
|
|
29
29
|
import path from 'node:path';
|
|
30
|
-
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
|
|
31
|
-
import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createGovernanceTrajectoryTurnReader, createHostIntentDocReader, isAutomaticPainSubmissionAuthorized, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
30
|
+
import { computeFeatureFlagsFromConfig, createRuntimeStateHandle, createPainSignalBridge, isRetryWaitBackoffElapsed, pickDiagnosticianCandidate, reconcileWaitingTargetEvidenceTasks, PrincipleTreeLedgerAdapter, resolveDiagnosticianCapability, } from '@principles/core/runtime';
|
|
31
|
+
import { createWorkspaceBehaviorEvidencePort, createCodexArtificerTrustedFactsPort, loadPdConfigForPlugin, loadFeatureFlagFromConfig, reconcileGovernanceContinuation, runInternalizationConsumerCycle, runStage2CorrectionCycle, createSignalClassifierForWorkspace, createGovernanceTrajectoryTurnReader, createConsentLedgerSourceMaterialAuthorization, createHostIntentDocReader, isAutomaticPainSubmissionAuthorized, saveHostToolDeclaration, HOST_TOOL_DECLARATION_VERSION, } from '@principles/host-runtime';
|
|
32
32
|
import { catchUpCodexIngestion } from '../ingestion/catch-up.js';
|
|
33
|
+
import { codexTargetTurnTextAvailable } from '../ingestion/pain-receipt-fallback.js';
|
|
33
34
|
import { CODEX_TOOL_SEMANTIC_MAPPINGS, CODEX_TOOL_SEMANTICS } from '../tool-semantics.js';
|
|
34
35
|
const WORKER_OWNER = 'companion-worker';
|
|
35
36
|
const DEFAULT_DIAG_CANDIDATE_LIMIT = 5;
|
|
@@ -47,6 +48,34 @@ const LIVENESS_STAGE_DEADLINE_MS = {
|
|
|
47
48
|
post_processing: 5 * 60_000,
|
|
48
49
|
downstream_cycle: 10 * 60_000,
|
|
49
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* WHO drove this cycle (PRI-1264 attribution, Phase 2 extension). The
|
|
53
|
+
* Service Host sets `PD_INVOCATION_SOURCE=service_host` on its Worker
|
|
54
|
+
* children (shadow mode); without the third value the stall attribution
|
|
55
|
+
* would misreport service-driven cycles as manual (TD §5.2).
|
|
56
|
+
*/
|
|
57
|
+
export function codexWorkerCycleDriver() {
|
|
58
|
+
const source = process.env.PD_INVOCATION_SOURCE;
|
|
59
|
+
if (source === 'companion')
|
|
60
|
+
return 'companion';
|
|
61
|
+
if (source === 'service_host')
|
|
62
|
+
return 'service_host';
|
|
63
|
+
return 'manual';
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* F13 (TD §5.2): the coordinator passes a unique invocation id; when
|
|
67
|
+
* present it lands in the liveness record so the shared per-workspace file
|
|
68
|
+
* can be correlated back to the exact Service Host invocation.
|
|
69
|
+
* R5 review fix: a manual/companion cycle carries NO invocation id, so the
|
|
70
|
+
* patch must CLEAR the field — otherwise a completed manual run would keep
|
|
71
|
+
* masquerading under the previous shadow run's id.
|
|
72
|
+
*/
|
|
73
|
+
function invocationIdLivenessPatch() {
|
|
74
|
+
const invocationId = process.env.PD_INVOCATION_ID;
|
|
75
|
+
return typeof invocationId === 'string' && invocationId.length > 0
|
|
76
|
+
? { lastInvocationId: invocationId }
|
|
77
|
+
: { lastInvocationId: null };
|
|
78
|
+
}
|
|
50
79
|
export function readCodexWorkerLiveness(workspaceDir) {
|
|
51
80
|
try {
|
|
52
81
|
const parsed = JSON.parse(fs.readFileSync(path.join(path.resolve(workspaceDir), '.state', LIVENESS_FILE), 'utf8'));
|
|
@@ -111,6 +140,25 @@ function writeLiveness(workspaceDir, patch) {
|
|
|
111
140
|
// itself remains the observable degradation channel)
|
|
112
141
|
}
|
|
113
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* F9 review fix: finalize the liveness record for EARLY returns (consumer
|
|
145
|
+
* pause, structured degradations). Without this, a cycle that stopped after
|
|
146
|
+
* the `catch_up`/`post_processing` stage write leaves a stale
|
|
147
|
+
* `runningStage` + deadline behind and liveness readers report the
|
|
148
|
+
* finished cycle as still mid-stage.
|
|
149
|
+
*/
|
|
150
|
+
function finalizeLiveness(workspaceDir, cycleStartedAt, settlement) {
|
|
151
|
+
writeLiveness(workspaceDir, {
|
|
152
|
+
runningStage: null,
|
|
153
|
+
stageDeadline: null,
|
|
154
|
+
lastCycleCompletedAt: new Date().toISOString(),
|
|
155
|
+
lastCycleDurationMs: Date.now() - cycleStartedAt.getTime(),
|
|
156
|
+
lastCycleMode: settlement.mode,
|
|
157
|
+
lastCycleDriver: codexWorkerCycleDriver(),
|
|
158
|
+
...(settlement.reason !== undefined ? { lastDegradedReason: settlement.reason } : {}),
|
|
159
|
+
...invocationIdLivenessPatch(),
|
|
160
|
+
});
|
|
161
|
+
}
|
|
114
162
|
/**
|
|
115
163
|
* SPEC §9.1 fair-share pick (review P1): pending and due-retry are both
|
|
116
164
|
* continuously-eligible classes; neither may starve the other while new
|
|
@@ -161,7 +209,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
161
209
|
// must not leave the PRE-pause cycle's deadline behind.
|
|
162
210
|
stageDeadline: null,
|
|
163
211
|
lastCycleStartedAt: cycleStartedAt.toISOString(),
|
|
164
|
-
lastCycleDriver:
|
|
212
|
+
lastCycleDriver: codexWorkerCycleDriver(),
|
|
165
213
|
});
|
|
166
214
|
// PRI-1063 (review fix): single-line flow mapping — see catch-up.ts.
|
|
167
215
|
return { ...base, mode: 'paused', reason: 'host.codex_disabled', nextAction: 'Enable Codex PD behavior in the Workspace .pd/config.yaml — in the existing "features:" block set host.codex: {enabled: true} (one flat key, not nested).' };
|
|
@@ -176,7 +224,7 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
176
224
|
// the marker so the Owner can tell a companion-driven (resident, should
|
|
177
225
|
// keep cycling) worker from a manual one-shot — "registered" alone said
|
|
178
226
|
// nothing about whether a driver is actually alive.
|
|
179
|
-
lastCycleDriver:
|
|
227
|
+
lastCycleDriver: codexWorkerCycleDriver(),
|
|
180
228
|
});
|
|
181
229
|
const consumerFlag = loadFeatureFlagFromConfig(workspaceDir, 'internalization_auto_consumer', { info: (m) => logger.info(m), warn: (m) => logger.warn(m) });
|
|
182
230
|
// PRI-638 P1-C: the Diagnostician capability gate is resolved from the same
|
|
@@ -206,6 +254,8 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
206
254
|
});
|
|
207
255
|
// Steps 4–6 — execution authority: internalization_auto_consumer.
|
|
208
256
|
let diagnostician = null;
|
|
257
|
+
// PRI-1274 (B1 / P1-3): filled by the waiting-task reconcile below.
|
|
258
|
+
let targetEvidenceReconcile = null;
|
|
209
259
|
if (diagnosticianDisabled) {
|
|
210
260
|
// PRI-638 P1-C: intentional governance pause. No candidate picking, no
|
|
211
261
|
// provider call, no degraded mode. The rest of the cycle (downstream)
|
|
@@ -220,6 +270,9 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
220
270
|
else if (!consumerFlag.enabled) {
|
|
221
271
|
// paused: execution pause, NOT evidence freeze. Catch-up + reconcile
|
|
222
272
|
// already ran above; manual CLI remains allowed (SPEC §13).
|
|
273
|
+
// F9: settle the liveness record — the cycle ENDED here (paused), so the
|
|
274
|
+
// in-flight `catch_up` stage and its deadline must not survive it.
|
|
275
|
+
finalizeLiveness(workspaceDir, cycleStartedAt, { mode: 'paused' });
|
|
223
276
|
return {
|
|
224
277
|
...base,
|
|
225
278
|
mode: 'paused',
|
|
@@ -241,6 +294,19 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
241
294
|
if (sweep.recovered > 0 || sweep.errors.length > 0) {
|
|
242
295
|
emitEvent('CODEX_WORKER_RECOVERY_SWEEP', JSON.stringify({ recovered: sweep.recovered, failed: sweep.errors.length }));
|
|
243
296
|
}
|
|
297
|
+
// PRI-1274 (B1 / P1-3): bounded waiting-task reconcile BEFORE picking
|
|
298
|
+
// — catch-up (step 2) may have just delivered the target turn text,
|
|
299
|
+
// and the picker's SQL excludes anything still waiting. Bounded work
|
|
300
|
+
// over the existing task rows + the shared authorized-store probe;
|
|
301
|
+
// no new queue, no scheduler, no scanning of general history.
|
|
302
|
+
targetEvidenceReconcile = await reconcileWaitingTargetEvidenceTasks({
|
|
303
|
+
stateManager: handle.stateManager,
|
|
304
|
+
targetTurnTextAvailable: (sessionId, turnId) => codexTargetTurnTextAvailable(path.resolve(workspaceDir), sessionId, turnId),
|
|
305
|
+
nowIso: new Date().toISOString(),
|
|
306
|
+
});
|
|
307
|
+
if (targetEvidenceReconcile.flipped > 0 || targetEvidenceReconcile.errors.length > 0) {
|
|
308
|
+
emitEvent('CODEX_WORKER_TARGET_EVIDENCE_RECONCILE', JSON.stringify(targetEvidenceReconcile));
|
|
309
|
+
}
|
|
244
310
|
const candidate = await pickDiagnosticianCandidate(handle.stateManager, options.diagnosticianCandidateLimit ?? DEFAULT_DIAG_CANDIDATE_LIMIT, new Date().toISOString());
|
|
245
311
|
if (candidate !== null) {
|
|
246
312
|
const stateDir = path.join(workspaceDir, '.state');
|
|
@@ -257,7 +323,9 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
257
323
|
intentDocReader: createHostIntentDocReader({ workspaceDir, effectiveConfig: config.effective }),
|
|
258
324
|
// PRI-1265: the worker's Stage A gets the bound session's ORIGINAL
|
|
259
325
|
// turns from the workspace's own consent-tiered governance store.
|
|
260
|
-
trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir }),
|
|
326
|
+
trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir, sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir) }),
|
|
327
|
+
// PRI-1283 R2: latest-consent gate consulted per assembly / model call.
|
|
328
|
+
sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir),
|
|
261
329
|
// SPEC §9.6: lazy probe — a revoked flag stops persisted
|
|
262
330
|
// automatic_hook tasks at the bridge's execution boundary.
|
|
263
331
|
isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
|
|
@@ -298,10 +366,14 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
298
366
|
}
|
|
299
367
|
catch (error) {
|
|
300
368
|
const detail = error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200);
|
|
369
|
+
const reason = `diagnostician_execution_failed:${detail}`;
|
|
370
|
+
// F9: settle the liveness record — a degraded early return must not
|
|
371
|
+
// leave a stale mid-stage runningStage behind.
|
|
372
|
+
finalizeLiveness(workspaceDir, cycleStartedAt, { mode: 'degraded', reason });
|
|
301
373
|
return {
|
|
302
374
|
...base,
|
|
303
375
|
mode: 'degraded',
|
|
304
|
-
reason
|
|
376
|
+
reason,
|
|
305
377
|
nextAction: 'Inspect the Workspace runtime profile and provider configuration; the task keeps its pending/retry state and no evidence was mutated.',
|
|
306
378
|
report: { catchUp, reconcile, postProcessing: null, diagnostician: null, downstream: null },
|
|
307
379
|
};
|
|
@@ -342,7 +414,9 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
342
414
|
getEnvVar: (name) => process.env[name],
|
|
343
415
|
// PRI-1265: post-processing resumes see the same authorized
|
|
344
416
|
// trajectory context as the initial diagnosis run.
|
|
345
|
-
trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir }),
|
|
417
|
+
trajectoryTurnReader: createGovernanceTrajectoryTurnReader({ workspaceDir, sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir) }),
|
|
418
|
+
// PRI-1283 R2: latest-consent gate consulted per assembly / model call.
|
|
419
|
+
sourceMaterialAuthorization: createConsentLedgerSourceMaterialAuthorization(workspaceDir),
|
|
346
420
|
// SPEC §9.6: lazy probe — automatic_hook backlog resumes honor
|
|
347
421
|
// the Workspace authorization too.
|
|
348
422
|
isAutoPainSubmissionAuthorized: () => isAutomaticPainSubmissionAuthorized(workspaceDir),
|
|
@@ -379,12 +453,14 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
379
453
|
}
|
|
380
454
|
catch (error) {
|
|
381
455
|
const detail = error instanceof Error ? error.message.slice(0, 200) : String(error).slice(0, 200);
|
|
456
|
+
const reason = `post_processing_continuation_failed:${detail}`;
|
|
457
|
+
finalizeLiveness(workspaceDir, cycleStartedAt, { mode: 'degraded', reason });
|
|
382
458
|
return {
|
|
383
459
|
...base,
|
|
384
460
|
mode: 'degraded',
|
|
385
|
-
reason
|
|
461
|
+
reason,
|
|
386
462
|
nextAction: 'Inspect the workspace state.db principle_candidates/tasks; the worker retries automatically on the next cycle.',
|
|
387
|
-
report: { catchUp, reconcile, postProcessing: null, diagnostician, downstream: null },
|
|
463
|
+
report: { catchUp, reconcile, postProcessing: null, diagnostician, downstream: null, ...(targetEvidenceReconcile !== null ? { targetEvidenceReconcile } : {}) },
|
|
388
464
|
};
|
|
389
465
|
}
|
|
390
466
|
}
|
|
@@ -406,10 +482,12 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
406
482
|
// liveness contract (host_tool_declaration_missing → OpenClaw default)
|
|
407
483
|
// and falsely pass host-liveness checks for a Codex activation. Degrade
|
|
408
484
|
// this cycle instead; the next cycle retries the declaration first.
|
|
485
|
+
const reason = `host_tool_declaration_persist_failed:${declared.reason}`;
|
|
486
|
+
finalizeLiveness(workspaceDir, cycleStartedAt, { mode: 'degraded', reason });
|
|
409
487
|
return {
|
|
410
488
|
...base,
|
|
411
489
|
mode: 'degraded',
|
|
412
|
-
reason
|
|
490
|
+
reason,
|
|
413
491
|
nextAction: 'Repair Codex host declaration persistence (.pd/host-tool-semantics/codex.json) before running the downstream internalization cycle; the worker retries automatically on the next cycle.',
|
|
414
492
|
report: { catchUp, reconcile, postProcessing: null, diagnostician, downstream: null },
|
|
415
493
|
};
|
|
@@ -471,14 +549,15 @@ export async function runCodexWorkspaceWorkerCycle(options) {
|
|
|
471
549
|
lastCycleMode: degradedReason !== undefined ? 'degraded' : 'ready',
|
|
472
550
|
// PRI-1264: driver of the last COMPLETED cycle — the stall verdict reads
|
|
473
551
|
// this so a no_recent_cycle report names WHO stopped driving.
|
|
474
|
-
lastCycleDriver:
|
|
552
|
+
lastCycleDriver: codexWorkerCycleDriver(),
|
|
475
553
|
...(degradedReason !== undefined ? { lastDegradedReason: degradedReason } : {}),
|
|
554
|
+
...invocationIdLivenessPatch(),
|
|
476
555
|
});
|
|
477
556
|
return {
|
|
478
557
|
...base,
|
|
479
558
|
mode: degradedReason !== undefined ? 'degraded' : 'ready',
|
|
480
559
|
...(degradedReason !== undefined ? { reason: degradedReason, nextAction: 'Inspect the Workspace .pd/config.yaml runtime profile and the per-step report above; the worker retries automatically on the next cycle.' } : {}),
|
|
481
|
-
report: { catchUp, reconcile, postProcessing, diagnostician, downstream, stage2 },
|
|
560
|
+
report: { catchUp, reconcile, postProcessing, diagnostician, downstream, ...(targetEvidenceReconcile !== null ? { targetEvidenceReconcile } : {}), stage2 },
|
|
482
561
|
};
|
|
483
562
|
}
|
|
484
563
|
// Slice D (PRI-625): the mode authority moved to host-runtime so the CLI and
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/codex-adapter",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Codex CLI host adapter for Principles Disciple — implements HostAdapter interface for OpenAI Codex CLI's stdin/stdout JSON hook model (ADR-0020).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -16,6 +16,7 @@ import { handleFeedbackReportsRoute, handleFeedbackChannelsRoute, disposeFeedbac
|
|
|
16
16
|
import { handleFailedTasksRoute, disposeFailedTasksModels } from './routes/failed-tasks.js';
|
|
17
17
|
import { handlePipelineHealthRoute, disposePipelineHealthModels } from './routes/pipeline-health.js';
|
|
18
18
|
import { handleDiagnosticianRoute } from './routes/diagnostician.js';
|
|
19
|
+
import { handleServiceHostRoute } from './routes/service-host.js';
|
|
19
20
|
import { handleApprovalsRoute, disposeApprovalsModels } from './routes/approvals.js';
|
|
20
21
|
import { handleHealthRoute, handleIngestionHealthRoute, disposeHealthModels } from './routes/health.js';
|
|
21
22
|
import { handlePrinciplesRoute, handleCorePrinciplesRoute, disposePrinciplesModels } from './routes/principles.js';
|
|
@@ -399,6 +400,15 @@ export function handleRequest(services) {
|
|
|
399
400
|
asyncHandler(() => handleDiagnosticianRoute(req, res, { workspaceDir: services.workspaceDir, subPath, featureFlags: services.feedbackFlags }))(req, res);
|
|
400
401
|
return;
|
|
401
402
|
}
|
|
403
|
+
// SPEC-PD-SERVICE-HOST-001 §7/§8.2 (PRI-1281 Phase 3): READ-ONLY
|
|
404
|
+
// Service Host status — the Console never owns scheduler lifecycle;
|
|
405
|
+
// the route spawns `pd service status --json` (the same single
|
|
406
|
+
// implementation the CLI uses).
|
|
407
|
+
if (routePath === '/api/service-host' || routePath.startsWith('/api/service-host/')) {
|
|
408
|
+
const subPath = routePath.slice('/api/service-host'.length);
|
|
409
|
+
asyncHandler(() => handleServiceHostRoute(req, res, { subPath }))(req, res);
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
402
412
|
// SPEC-PD-PIPELINE-RELIABILITY-AND-EFFICIENCY-001 §3.4: read-only
|
|
403
413
|
// pipeline metrics (queue/latency/reliability/provider) derived from
|
|
404
414
|
// state.db. Registered before the failed-tasks mount (different prefix).
|
|
@@ -648,6 +658,7 @@ export function handleRequest(services) {
|
|
|
648
658
|
asyncHandler(() => handleHealthRoute(req, res, {
|
|
649
659
|
workspaceDir: services.workspaceDir,
|
|
650
660
|
authenticationMode: 'no_auth',
|
|
661
|
+
webIndexExists: fs.existsSync(path.join(WEB_ROOT, 'index.html')),
|
|
651
662
|
}))(req, res);
|
|
652
663
|
return;
|
|
653
664
|
}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
*/
|
|
30
30
|
import { SqliteConnection, sanitizeString, assembleEvidenceChain, } from '@principles/core/runtime';
|
|
31
31
|
import { openTrajectoryDbReadonly } from '@principles/core/trajectory-store';
|
|
32
|
+
import { readSourceMaterialAuthorization } from '@principles/host-runtime';
|
|
32
33
|
import { resolveStateDbPath, resolveTrajectoryDbPath } from '@principles/core/runtime/storage-paths';
|
|
33
34
|
import * as fs from 'node:fs';
|
|
34
35
|
import * as path from 'node:path';
|
|
@@ -378,6 +379,36 @@ export class EvidenceChainConsoleModel {
|
|
|
378
379
|
}
|
|
379
380
|
}
|
|
380
381
|
}
|
|
382
|
+
// ── 6. PRI-1283 R2: source-material authorization redaction ────────
|
|
383
|
+
// Console read models must not re-serve conversation-derived excerpts of
|
|
384
|
+
// a host whose conversation-ingestion consent is not granted — UI hiding
|
|
385
|
+
// is NOT cleanup (R3 owns the persisted copies), but the READ path must
|
|
386
|
+
// still refuse them. IDs, states, timestamps and model-authored fields
|
|
387
|
+
// survive; conversation-derived text is replaced with a visible marker.
|
|
388
|
+
// Review round 2 (directive B): an EXPLICIT Owner submission (explicit
|
|
389
|
+
// correction channel or the explicit reason marker in the summary) is an
|
|
390
|
+
// Owner act, not conversation ingestion — it stays fully visible.
|
|
391
|
+
const blockedHosts = new Set(['codex', 'workbuddy']
|
|
392
|
+
.filter((host) => readSourceMaterialAuthorization({ workspaceDir: this.workspaceDir, hostKind: host }).status === 'blocked'));
|
|
393
|
+
if (blockedHosts.size > 0) {
|
|
394
|
+
for (const record of response.records) {
|
|
395
|
+
if (record.hostKind !== undefined && blockedHosts.has(record.hostKind)) {
|
|
396
|
+
// `ownerManual` is the verdict the shared judgment computed at
|
|
397
|
+
// assembly time over the PERSISTED evidence (channel + bound
|
|
398
|
+
// confirmation) before the public projection stripped those fields
|
|
399
|
+
// — neither the projected record nor the spoofable summary marker
|
|
400
|
+
// can stand in for it. Agent-derived submissions (no bound Owner
|
|
401
|
+
// confirmation) are withheld the same way as any other governed
|
|
402
|
+
// material.
|
|
403
|
+
if (record.correctionEvidence?.ownerManual === true)
|
|
404
|
+
continue;
|
|
405
|
+
record.summary = `[source consent not granted — conversation-derived excerpt withheld (PRI-1283 R2)]`;
|
|
406
|
+
if (record.correctionEvidence !== undefined) {
|
|
407
|
+
record.correctionEvidence = undefined;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
381
412
|
return response;
|
|
382
413
|
}
|
|
383
414
|
/**
|
|
@@ -10,5 +10,6 @@ export declare function handleIngestionHealthRoute(req: IncomingMessage, res: Se
|
|
|
10
10
|
export declare function handleHealthRoute(req: IncomingMessage, res: ServerResponse, options: {
|
|
11
11
|
workspaceDir: string;
|
|
12
12
|
authenticationMode: 'authenticated' | 'no_auth';
|
|
13
|
+
webIndexExists: boolean;
|
|
13
14
|
}): Promise<void>;
|
|
14
15
|
export declare function disposeHealthModels(): void;
|
|
@@ -156,6 +156,18 @@ export async function handleHealthRoute(req, res, options) {
|
|
|
156
156
|
// machine-local, never logged here, and absent entirely for consoles
|
|
157
157
|
// launched without it (normal user launches), keeping the legacy shape.
|
|
158
158
|
...(VERIFY_NONCE !== null ? { verifyNonce: VERIFY_NONCE } : {}),
|
|
159
|
+
// Instance identity for launcher-side stale-process detection: a
|
|
160
|
+
// leftover console whose files were deleted underneath it (test
|
|
161
|
+
// fixture cleanup, interrupted update) still answers /api/health from
|
|
162
|
+
// memory but can only 404 the UI. Reporting pid + entry path + whether
|
|
163
|
+
// the web bundle still exists lets `pd console open` prove the
|
|
164
|
+
// responder is a PD console that can never serve, and replace it
|
|
165
|
+
// instead of reusing it forever.
|
|
166
|
+
instance: {
|
|
167
|
+
pid: process.pid,
|
|
168
|
+
serverEntry: typeof process.argv[1] === 'string' ? process.argv[1] : null,
|
|
169
|
+
webIndexExists: options.webIndexExists,
|
|
170
|
+
},
|
|
159
171
|
});
|
|
160
172
|
}
|
|
161
173
|
catch (error) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'http';
|
|
2
|
+
/** Injectable CLI boundary so tests never spawn a real process. */
|
|
3
|
+
export interface ServiceHostStatusRuntime {
|
|
4
|
+
readStatus(): Promise<{
|
|
5
|
+
ok: true;
|
|
6
|
+
document: unknown;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
reason: string;
|
|
10
|
+
nextAction: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/** Production runtime: spawn the installed pd CLI's status command. */
|
|
14
|
+
export declare function createCliServiceHostStatusRuntime(): ServiceHostStatusRuntime;
|
|
15
|
+
export interface ServiceHostRouteOptions {
|
|
16
|
+
readonly subPath: string;
|
|
17
|
+
readonly runtime?: ServiceHostStatusRuntime;
|
|
18
|
+
}
|
|
19
|
+
export declare function handleServiceHostRoute(req: IncomingMessage, res: ServerResponse, options: ServiceHostRouteOptions): Promise<void>;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SPEC-PD-SERVICE-HOST-001 §7/§8.2 (PRI-1281 Phase 3) — Console read-only
|
|
3
|
+
* Service Host status.
|
|
4
|
+
*
|
|
5
|
+
* GET /api/service-host/status
|
|
6
|
+
*
|
|
7
|
+
* The Console NEVER owns scheduler lifecycle (§7): this route only READS the
|
|
8
|
+
* unified status contract by spawning `pd service status --json` — the same
|
|
9
|
+
* single implementation the CLI/Companion use (P4). It does not re-detect
|
|
10
|
+
* the OS scheduler in-process, does not start Workers and writes nothing.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from 'child_process';
|
|
13
|
+
import { resolvePdCliInvocation } from './diagnostician.js';
|
|
14
|
+
import { sendError, sendJson } from '../utils/response.js';
|
|
15
|
+
const STATUS_TIMEOUT_MS = 30_000;
|
|
16
|
+
/** Production runtime: spawn the installed pd CLI's status command. */
|
|
17
|
+
export function createCliServiceHostStatusRuntime() {
|
|
18
|
+
return {
|
|
19
|
+
async readStatus() {
|
|
20
|
+
const { entryPath } = resolvePdCliInvocation();
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
let stdout = '';
|
|
23
|
+
let stderr = '';
|
|
24
|
+
let settled = false;
|
|
25
|
+
let timer;
|
|
26
|
+
const settle = (value) => {
|
|
27
|
+
if (settled)
|
|
28
|
+
return;
|
|
29
|
+
settled = true;
|
|
30
|
+
if (timer !== undefined)
|
|
31
|
+
clearTimeout(timer);
|
|
32
|
+
resolve(value);
|
|
33
|
+
};
|
|
34
|
+
let child;
|
|
35
|
+
timer = setTimeout(() => {
|
|
36
|
+
try {
|
|
37
|
+
child.kill();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
// close handler settles
|
|
41
|
+
}
|
|
42
|
+
settle({ ok: false, reason: 'service_host_status_timeout', nextAction: `pd service status did not finish in ${STATUS_TIMEOUT_MS / 1000}s; retry the request.` });
|
|
43
|
+
}, STATUS_TIMEOUT_MS);
|
|
44
|
+
try {
|
|
45
|
+
child = spawn(process.execPath, [entryPath, 'service', 'status', '--json'], {
|
|
46
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
47
|
+
windowsHide: true,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
52
|
+
settle({ ok: false, reason: `service_host_status_spawn_failed:${message.slice(0, 120)}`, nextAction: 'The pd CLI could not be started; check the installed runtime and retry.' });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
child.on('error', (error) => {
|
|
56
|
+
settle({ ok: false, reason: `service_host_status_spawn_failed:${error.code ?? error.message}`, nextAction: 'The pd CLI could not be started; check the installed runtime and retry.' });
|
|
57
|
+
});
|
|
58
|
+
child.stdout?.on('data', (chunk) => {
|
|
59
|
+
if (stdout.length < 1024 * 1024)
|
|
60
|
+
stdout += chunk.toString('utf8');
|
|
61
|
+
});
|
|
62
|
+
child.stderr?.on('data', (chunk) => {
|
|
63
|
+
if (stderr.length < 16 * 1024)
|
|
64
|
+
stderr += chunk.toString('utf8');
|
|
65
|
+
});
|
|
66
|
+
child.on('close', (code) => {
|
|
67
|
+
// cli-1 (task §1 review): stdout must be EXACTLY ONE JSON
|
|
68
|
+
// document — the whole trimmed stdout is parsed. A log line
|
|
69
|
+
// before/after the JSON, an empty stdout, or a truncated document
|
|
70
|
+
// all fail closed and are never reported as a status document.
|
|
71
|
+
const stdoutDoc = stdout.trim();
|
|
72
|
+
if (stdoutDoc === '') {
|
|
73
|
+
settle({
|
|
74
|
+
ok: false,
|
|
75
|
+
reason: `service_host_status_no_json:exit_${code ?? 'null'}${stderr.trim() !== '' ? `:${stderr.trim().slice(0, 160)}` : ''}`,
|
|
76
|
+
nextAction: 'pd service status produced no machine-readable output. The Console stays read-only — run it in a terminal for the full output.',
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
let document;
|
|
81
|
+
try {
|
|
82
|
+
document = JSON.parse(stdoutDoc);
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
settle({ ok: false, reason: 'service_host_status_unparsable', nextAction: 'pd service status stdout was not a single JSON document (log-mixed or truncated output is refused); run it in a terminal to inspect.' });
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (typeof document !== 'object' || document === null || Array.isArray(document)) {
|
|
89
|
+
settle({ ok: false, reason: 'service_host_status_schema_violation', nextAction: 'pd service status emitted JSON that is not a status object; run it in a terminal to inspect.' });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (code === 0) {
|
|
93
|
+
const { schemaVersion } = document;
|
|
94
|
+
if (schemaVersion !== 'pd.service-status.v1') {
|
|
95
|
+
settle({ ok: false, reason: 'service_host_status_schema_violation:schema_version', nextAction: 'pd service status emitted a document with an unknown schemaVersion; the Console refused it rather than guess its shape.' });
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
settle({ ok: true, document });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
settle({
|
|
102
|
+
ok: false,
|
|
103
|
+
reason: `service_host_status_failed:exit_${code ?? 'null'}${stderr.trim() !== '' ? `:${stderr.trim().slice(0, 160)}` : ''}`,
|
|
104
|
+
nextAction: 'pd service status did not succeed. The Console stays read-only — run it in a terminal for the full output.',
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
export async function handleServiceHostRoute(req, res, options) {
|
|
112
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
113
|
+
// The Console NEVER owns Service Host lifecycle (SPEC §7) — the route
|
|
114
|
+
// surface is GET-only by construction.
|
|
115
|
+
sendError(res, 405, 'method_not_allowed', 'GET only — the Console never owns Service Host lifecycle (SPEC §7)');
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (options.subPath !== '/status') {
|
|
119
|
+
sendError(res, 404, 'not_found', `Unknown service-host path: ${options.subPath}. Only /api/service-host/status exists (read-only).`);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const runtime = options.runtime ?? createCliServiceHostStatusRuntime();
|
|
123
|
+
const result = await runtime.readStatus();
|
|
124
|
+
if (result.ok) {
|
|
125
|
+
sendJson(res, 200, result.document);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
sendError(res, 503, result.reason, result.nextAction);
|
|
129
|
+
}
|