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
|
@@ -0,0 +1,688 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Windows scheduler adapter — current-user Task Scheduler task via the
|
|
3
|
+
* ScheduledTasks PowerShell module (SPEC-PD-SERVICE-HOST-001 §10.1, task §3.2).
|
|
4
|
+
*
|
|
5
|
+
* Protocol: every operation is ONE `powershell.exe -Command` script that
|
|
6
|
+
* - forces UTF-8 console output (ConvertTo-Json must not mojibake);
|
|
7
|
+
* - reports either a structured JSON body or `{ok:false, errorId, message}`
|
|
8
|
+
* from a single catch — the FullyQualifiedErrorId is a stable English
|
|
9
|
+
* identifier, so permission denial (AccessDenied) is NEVER confused with
|
|
10
|
+
* "task not found" (ScheduledTaskNotFound); localized stderr prose is
|
|
11
|
+
* never parsed;
|
|
12
|
+
* - receives file paths through environment variables — nothing is
|
|
13
|
+
* interpolated into the script except task names, which this package
|
|
14
|
+
* generates from [A-Za-z0-9-] only.
|
|
15
|
+
*
|
|
16
|
+
* Security shape (task §3.2): LogonTrigger + repeating TimeTrigger,
|
|
17
|
+
* InteractiveToken principal ("run only when user is logged on"), RunLevel
|
|
18
|
+
* LeastPrivilege (no elevation), absolute node/entry paths, no credentials,
|
|
19
|
+
* MultipleInstancesPolicy=IgnoreNew (OS-level overlap convergence that
|
|
20
|
+
* complements the install-level run lock).
|
|
21
|
+
*/
|
|
22
|
+
import * as path from 'node:path';
|
|
23
|
+
import { schedulerInvocationArgs } from './contract.js';
|
|
24
|
+
const POWERSHELL_ARGS_PREFIX = ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command'];
|
|
25
|
+
/** ISO-8601 duration for the Task XML repetition interval. */
|
|
26
|
+
export function windowsRepetitionDuration(intervalMs) {
|
|
27
|
+
if (intervalMs % 60_000 === 0)
|
|
28
|
+
return `PT${Math.round(intervalMs / 60_000)}M`;
|
|
29
|
+
return `PT${Math.round(intervalMs / 1000)}S`;
|
|
30
|
+
}
|
|
31
|
+
function escapeXml(value) {
|
|
32
|
+
return value.replace(/[&<>"']/g, (c) => {
|
|
33
|
+
switch (c) {
|
|
34
|
+
case '&': return '&';
|
|
35
|
+
case '<': return '<';
|
|
36
|
+
case '>': return '>';
|
|
37
|
+
case '"': return '"';
|
|
38
|
+
default: return ''';
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Max one run-once coordinator may legitimately take (own bounds are tighter). */
|
|
43
|
+
const EXECUTION_TIME_LIMIT = 'PT8H';
|
|
44
|
+
/**
|
|
45
|
+
* Serialize ONE argument the way CommandLineToArgvW parses it back
|
|
46
|
+
* (task §3.2 review): an argument containing whitespace, a quote, or the
|
|
47
|
+
* empty string is wrapped in double quotes; a run of `n` backslashes
|
|
48
|
+
* immediately before a quote or the closing quote is doubled, and an
|
|
49
|
+
* embedded `"` is emitted as `\"`. Exported for the round-trip tests —
|
|
50
|
+
* quoting only the CLI path while joining the rest raw let a spaced
|
|
51
|
+
* `--pd-home` root split into extra argv entries on the OS side.
|
|
52
|
+
*/
|
|
53
|
+
export function windowsSerializeArg(arg) {
|
|
54
|
+
if (arg.length > 0 && !/[\s"]/.test(arg))
|
|
55
|
+
return arg;
|
|
56
|
+
let out = '"';
|
|
57
|
+
let backslashes = 0;
|
|
58
|
+
for (const ch of arg) {
|
|
59
|
+
if (ch === '\\') {
|
|
60
|
+
backslashes += 1;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (ch === '"') {
|
|
64
|
+
out += '\\'.repeat(backslashes * 2 + 1) + '"';
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
out += '\\'.repeat(backslashes) + ch;
|
|
68
|
+
}
|
|
69
|
+
backslashes = 0;
|
|
70
|
+
}
|
|
71
|
+
out += '\\'.repeat(backslashes * 2) + '"';
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
/** Serialize a full argv to the single command-line string the task's Exec uses. */
|
|
75
|
+
export function windowsSerializeCommandLine(argv) {
|
|
76
|
+
return argv.map(windowsSerializeArg).join(' ');
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* CommandLineToArgvW-faithful command-line parser (the same algorithm the
|
|
80
|
+
* Windows process startup applies): `2n` backslashes + quote = `n` literal
|
|
81
|
+
* backslashes + delimiter; `2n+1` + quote = `n` backslashes + a literal
|
|
82
|
+
* quote; unquoted whitespace splits. Ownership verification and the
|
|
83
|
+
* serialization tests both go through this — never a string-contains
|
|
84
|
+
* shortcut (task §3.2/§5).
|
|
85
|
+
*/
|
|
86
|
+
export function windowsParseCommandLine(commandLine) {
|
|
87
|
+
const args = [];
|
|
88
|
+
let current = '';
|
|
89
|
+
let tokenStarted = false;
|
|
90
|
+
let inQuotes = false;
|
|
91
|
+
let i = 0;
|
|
92
|
+
while (i < commandLine.length) {
|
|
93
|
+
const ch = commandLine[i];
|
|
94
|
+
if (ch === ' ' || ch === '\t') {
|
|
95
|
+
if (inQuotes) {
|
|
96
|
+
current += ch;
|
|
97
|
+
}
|
|
98
|
+
else if (tokenStarted) {
|
|
99
|
+
args.push(current);
|
|
100
|
+
current = '';
|
|
101
|
+
tokenStarted = false;
|
|
102
|
+
}
|
|
103
|
+
i += 1;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (ch === '\\') {
|
|
107
|
+
let backslashes = 0;
|
|
108
|
+
while (commandLine[i] === '\\') {
|
|
109
|
+
backslashes += 1;
|
|
110
|
+
i += 1;
|
|
111
|
+
}
|
|
112
|
+
if (commandLine[i] === '"') {
|
|
113
|
+
if (backslashes % 2 === 0) {
|
|
114
|
+
current += '\\'.repeat(backslashes / 2);
|
|
115
|
+
inQuotes = !inQuotes;
|
|
116
|
+
tokenStarted = true;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
current += '\\'.repeat((backslashes - 1) / 2) + '"';
|
|
120
|
+
tokenStarted = true;
|
|
121
|
+
}
|
|
122
|
+
i += 1;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
current += '\\'.repeat(backslashes);
|
|
126
|
+
tokenStarted = true;
|
|
127
|
+
}
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (ch === '"') {
|
|
131
|
+
// A `""` inside a quoted run is an escaped quote for MSVC argv rules;
|
|
132
|
+
// outside it toggles quoting. Two adjacent quotes mid-token collapse.
|
|
133
|
+
if (inQuotes && commandLine[i + 1] === '"') {
|
|
134
|
+
current += '"';
|
|
135
|
+
i += 2;
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
inQuotes = !inQuotes;
|
|
139
|
+
tokenStarted = true;
|
|
140
|
+
i += 1;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
current += ch;
|
|
144
|
+
tokenStarted = true;
|
|
145
|
+
i += 1;
|
|
146
|
+
}
|
|
147
|
+
if (tokenStarted)
|
|
148
|
+
args.push(current);
|
|
149
|
+
return args;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Task Scheduler StartBoundary with an EXPLICIT timezone (task §8 review):
|
|
153
|
+
* `YYYY-MM-DDTHH:MM:SS±HH:MM`. UTC input keeps a real offset marker —
|
|
154
|
+
* stripping `Z` used to pass a UTC instant off as local time and shifted
|
|
155
|
+
* the first trigger by the host's UTC offset.
|
|
156
|
+
*/
|
|
157
|
+
export function formatWindowsStartBoundary(epochMs, offsetMinutesEast) {
|
|
158
|
+
const local = new Date(epochMs + offsetMinutesEast * 60_000);
|
|
159
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
160
|
+
const sign = offsetMinutesEast >= 0 ? '+' : '-';
|
|
161
|
+
const abs = Math.abs(offsetMinutesEast);
|
|
162
|
+
return (`${local.getUTCFullYear()}-${pad(local.getUTCMonth() + 1)}-${pad(local.getUTCDate())}` +
|
|
163
|
+
`T${pad(local.getUTCHours())}:${pad(local.getUTCMinutes())}:${pad(local.getUTCSeconds())}` +
|
|
164
|
+
`${sign}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`);
|
|
165
|
+
}
|
|
166
|
+
/** The Arguments element: EVERY argument is serialized independently per the Win32 argv rules. */
|
|
167
|
+
function schedulerArgumentsString(registration) {
|
|
168
|
+
return windowsSerializeCommandLine(schedulerInvocationArgs(registration));
|
|
169
|
+
}
|
|
170
|
+
export function buildWindowsTaskXml(registration, now = new Date(), enabled = false) {
|
|
171
|
+
const { nodePath, pdHome, intervalMs } = registration;
|
|
172
|
+
const startBoundary = formatWindowsStartBoundary(now.getTime(), -now.getTimezoneOffset());
|
|
173
|
+
const args = schedulerArgumentsString(registration);
|
|
174
|
+
return [
|
|
175
|
+
// No encoding declaration: Task Scheduler's MSXML rejects a UTF-8
|
|
176
|
+
// declaration on a string-sourced document with "cannot switch
|
|
177
|
+
// encoding" (HRESULT 0x8004131a, verified on a real zh-CN host).
|
|
178
|
+
'<?xml version="1.0"?>',
|
|
179
|
+
'<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">',
|
|
180
|
+
' <RegistrationInfo>',
|
|
181
|
+
` <Description>PD Service Host managed run-once trigger for pdHome ${escapeXml(pdHome)}. Installed by pd service install; remove with pd service uninstall.</Description>`,
|
|
182
|
+
' </RegistrationInfo>',
|
|
183
|
+
' <Triggers>',
|
|
184
|
+
' <LogonTrigger>',
|
|
185
|
+
' <Enabled>true</Enabled>',
|
|
186
|
+
' <UserId>__PD_TASK_USER__</UserId>',
|
|
187
|
+
' </LogonTrigger>',
|
|
188
|
+
' <TimeTrigger>',
|
|
189
|
+
` <StartBoundary>${startBoundary}</StartBoundary>`,
|
|
190
|
+
' <Enabled>true</Enabled>',
|
|
191
|
+
' <Repetition>',
|
|
192
|
+
` <Interval>${windowsRepetitionDuration(intervalMs)}</Interval>`,
|
|
193
|
+
' <StopAtDurationEnd>false</StopAtDurationEnd>',
|
|
194
|
+
' </Repetition>',
|
|
195
|
+
' </TimeTrigger>',
|
|
196
|
+
' </Triggers>',
|
|
197
|
+
' <Settings>',
|
|
198
|
+
' <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>',
|
|
199
|
+
' <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>',
|
|
200
|
+
' <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>',
|
|
201
|
+
' <AllowHardTerminate>true</AllowHardTerminate>',
|
|
202
|
+
' <StartWhenAvailable>true</StartWhenAvailable>',
|
|
203
|
+
' <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>',
|
|
204
|
+
' <AllowStartOnDemand>true</AllowStartOnDemand>',
|
|
205
|
+
// installed_disabled: a FRESH registration never fires until
|
|
206
|
+
// `pd service enable` flips it (task §5). On refresh the caller passes
|
|
207
|
+
// the preserved OS enabled state (task §15).
|
|
208
|
+
` <Enabled>${enabled ? 'true' : 'false'}</Enabled>`,
|
|
209
|
+
' <Hidden>false</Hidden>',
|
|
210
|
+
' <RunOnlyIfIdle>false</RunOnlyIfIdle>',
|
|
211
|
+
' <WakeToRun>false</WakeToRun>',
|
|
212
|
+
` <ExecutionTimeLimit>${EXECUTION_TIME_LIMIT}</ExecutionTimeLimit>`,
|
|
213
|
+
' <Priority>7</Priority>',
|
|
214
|
+
' </Settings>',
|
|
215
|
+
' <Actions Context="Author">',
|
|
216
|
+
' <Exec>',
|
|
217
|
+
` <Command>${escapeXml(nodePath)}</Command>`,
|
|
218
|
+
` <Arguments>${escapeXml(args)}</Arguments>`,
|
|
219
|
+
` <WorkingDirectory>${escapeXml(pdHome)}</WorkingDirectory>`,
|
|
220
|
+
' </Exec>',
|
|
221
|
+
' </Actions>',
|
|
222
|
+
'</Task>',
|
|
223
|
+
'',
|
|
224
|
+
].join('\r\n');
|
|
225
|
+
}
|
|
226
|
+
/** XML-unescape a scalar element's text content. */
|
|
227
|
+
function unescapeXml(value) {
|
|
228
|
+
return value
|
|
229
|
+
.replace(/</g, '<')
|
|
230
|
+
.replace(/>/g, '>')
|
|
231
|
+
.replace(/"/g, '"')
|
|
232
|
+
.replace(/'/g, "'")
|
|
233
|
+
.replace(/&/g, '&');
|
|
234
|
+
}
|
|
235
|
+
/** First `<tag>text</tag>` inside a scope fragment, or null. */
|
|
236
|
+
function xmlElement(scope, tag) {
|
|
237
|
+
const match = new RegExp(`<${tag}>([\\s\\S]*?)</${tag}>`, 'i').exec(scope);
|
|
238
|
+
return match === null ? null : unescapeXml(match[1] ?? '');
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Actions completeness (task review §4): parse the WHOLE `<Actions>`
|
|
242
|
+
* block. Our task declares exactly ONE `<Exec>` action — a matching first
|
|
243
|
+
* Exec plus extra `<Exec>`s or any non-Exec action (ComHandler,
|
|
244
|
+
* ShowMessage, SendEmail) is a FOREIGN task. Every action tag anywhere
|
|
245
|
+
* inside Actions counts; forged content in comments still trips the
|
|
246
|
+
* count (conservative refusal).
|
|
247
|
+
*/
|
|
248
|
+
function taskActionsExec(xml) {
|
|
249
|
+
const actionsMatch = /<Actions\b[^>]*>([\s\S]*?)<\/Actions>/i.exec(xml);
|
|
250
|
+
if (actionsMatch === null)
|
|
251
|
+
return { ok: false, detail: 'no_actions_block' };
|
|
252
|
+
const scope = actionsMatch[1] ?? '';
|
|
253
|
+
const actionTags = [...scope.matchAll(/<(Exec|ComHandler|ShowMessage|SendEmail)\b/gi)].map((m) => m[1] ?? '');
|
|
254
|
+
const execBlocks = [...scope.matchAll(/<Exec\b[^>]*>([\s\S]*?)<\/Exec>/gi)].map((m) => m[1] ?? '');
|
|
255
|
+
if (execBlocks.length !== 1 || actionTags.length !== 1 || actionTags[0]?.toLowerCase() !== 'exec') {
|
|
256
|
+
return { ok: false, detail: `unexpected_actions:${actionTags.join('+') || 'none'}` };
|
|
257
|
+
}
|
|
258
|
+
return { ok: true, exec: execBlocks[0] ?? '' };
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* `<UserId>` values inside `<LogonTrigger>` blocks only. PD declares the
|
|
262
|
+
* interactive principal in the LogonTrigger; a REAL Task Scheduler
|
|
263
|
+
* export ALSO carries a `<Principal><UserId>` (SID form) outside the
|
|
264
|
+
* trigger, so counting every UserId in the document wrongly rejects our
|
|
265
|
+
* own tasks (real-CI evidence: principal_mismatch count=2). Foreign
|
|
266
|
+
* ambiguity = zero or several UserIds *inside* the trigger.
|
|
267
|
+
*/
|
|
268
|
+
function taskPrincipalUsers(xml) {
|
|
269
|
+
const users = [];
|
|
270
|
+
for (const trigger of xml.matchAll(/<LogonTrigger\b[^>]*>([\s\S]*?)<\/LogonTrigger>/gi)) {
|
|
271
|
+
for (const user of (trigger[1] ?? '').matchAll(/<UserId>([\s\S]*?)<\/UserId>/gi)) {
|
|
272
|
+
users.push(unescapeXml(user[1] ?? '').trim());
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return users;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* `<UserId>` values inside `<Principal>` blocks — the task's RUN-AS
|
|
279
|
+
* account (exported in SID form). PD registers with
|
|
280
|
+
* TASK_LOGON_INTERACTIVE_TOKEN for the registering user, so our own task
|
|
281
|
+
* declares exactly ONE Principal whose UserId is that user's SID. An
|
|
282
|
+
* admin may retarget a same-named task to another account while leaving
|
|
283
|
+
* the Exec/WorkingDirectory/LogonTrigger intact (real-review evidence):
|
|
284
|
+
* such a task is FOREIGN and must never be modified or deleted. Zero or
|
|
285
|
+
* several Principal UserIds is likewise a definition PD did not write.
|
|
286
|
+
*/
|
|
287
|
+
function taskRunAsUsers(xml) {
|
|
288
|
+
const users = [];
|
|
289
|
+
for (const principal of xml.matchAll(/<Principal\b[^>]*>([\s\S]*?)<\/Principal>/gi)) {
|
|
290
|
+
for (const user of (principal[1] ?? '').matchAll(/<UserId>([\s\S]*?)<\/UserId>/gi)) {
|
|
291
|
+
users.push(unescapeXml(user[1] ?? '').trim());
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return users;
|
|
295
|
+
}
|
|
296
|
+
/** Runtime guard for the error envelope (untrusted parsed JSON, rc-1/rc-3). */
|
|
297
|
+
function isPowerShellError(body) {
|
|
298
|
+
if (typeof body !== 'object' || body === null)
|
|
299
|
+
return false;
|
|
300
|
+
// `=== false` is own-property safe: an inherited `ok` reads undefined.
|
|
301
|
+
return body.ok === false;
|
|
302
|
+
}
|
|
303
|
+
function isPowerShellQueryBody(value) {
|
|
304
|
+
if (typeof value !== 'object' || value === null || !Object.hasOwn(value, 'found'))
|
|
305
|
+
return false;
|
|
306
|
+
return typeof value.found === 'boolean';
|
|
307
|
+
}
|
|
308
|
+
function isPowerShellErrorBodyValue(value) {
|
|
309
|
+
if (typeof value !== 'object' || value === null)
|
|
310
|
+
return false;
|
|
311
|
+
return value.ok === false && typeof value.errorId === 'string';
|
|
312
|
+
}
|
|
313
|
+
function isPowerShellMutationAck(value) {
|
|
314
|
+
if (typeof value !== 'object' || value === null || !Object.hasOwn(value, 'done'))
|
|
315
|
+
return false;
|
|
316
|
+
return typeof value.done === 'boolean';
|
|
317
|
+
}
|
|
318
|
+
function parsePowerShellJson(stdout) {
|
|
319
|
+
const cleaned = stdout.replace(/^\uFEFF/, '').trim();
|
|
320
|
+
if (cleaned === '')
|
|
321
|
+
return { ok: false, reason: 'powershell_empty_output' };
|
|
322
|
+
try {
|
|
323
|
+
const parsed = JSON.parse(cleaned);
|
|
324
|
+
if (isPowerShellQueryBody(parsed) || isPowerShellErrorBodyValue(parsed) || isPowerShellMutationAck(parsed)) {
|
|
325
|
+
return { ok: true, body: parsed };
|
|
326
|
+
}
|
|
327
|
+
return { ok: false, reason: 'powershell_unexpected_output_shape' };
|
|
328
|
+
}
|
|
329
|
+
catch (error) {
|
|
330
|
+
return { ok: false, reason: `powershell_unparsable_output:${error instanceof Error ? error.message.slice(0, 80) : 'unknown'}` };
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/** PowerShell's "never run" sentinel timestamp — report null instead. */
|
|
334
|
+
const NEVER_RUN_YEAR_PREFIX = '1899';
|
|
335
|
+
/** Parse `<Interval>PT2M</Interval>` / `PT30S` from the exported task XML. */
|
|
336
|
+
export function parseWindowsIntervalMs(xml) {
|
|
337
|
+
const match = /<Interval>PT(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?<\/Interval>/i.exec(xml);
|
|
338
|
+
if (match === null)
|
|
339
|
+
return null;
|
|
340
|
+
const minutes = match[1] !== undefined ? Number(match[1]) : 0;
|
|
341
|
+
const seconds = match[2] !== undefined ? Number(match[2]) : 0;
|
|
342
|
+
const ms = Math.round((minutes * 60 + seconds) * 1000);
|
|
343
|
+
return ms > 0 ? ms : null;
|
|
344
|
+
}
|
|
345
|
+
function factsFromQuery(identity, body) {
|
|
346
|
+
if (!body.found) {
|
|
347
|
+
return { platform: 'win32', taskName: identity.windowsTaskName, registered: false, enabled: false, triggerIntervalMs: null, lastRunAt: null, lastResult: null };
|
|
348
|
+
}
|
|
349
|
+
const state = typeof body.state === 'string' ? body.state : '';
|
|
350
|
+
// 267011 (0x41303) = SCHED_S_TASK_HAS_NOT_RUN — the never-run signal that
|
|
351
|
+
// survives locale-dependent timestamp sentinels (real hosts observed with
|
|
352
|
+
// both 1899- and 1999-dated sentinels).
|
|
353
|
+
const neverRan = String(body.lastResult ?? '') === '267011';
|
|
354
|
+
const lastRunAt = !neverRan && typeof body.lastRunAt === 'string' && !body.lastRunAt.startsWith(NEVER_RUN_YEAR_PREFIX)
|
|
355
|
+
? body.lastRunAt
|
|
356
|
+
: null;
|
|
357
|
+
return {
|
|
358
|
+
platform: 'win32',
|
|
359
|
+
taskName: identity.windowsTaskName,
|
|
360
|
+
registered: true,
|
|
361
|
+
enabled: state === '' ? null : state !== 'Disabled',
|
|
362
|
+
active: state === '' ? null : state === 'Running',
|
|
363
|
+
triggerIntervalMs: typeof body.xml === 'string' ? parseWindowsIntervalMs(body.xml) : null,
|
|
364
|
+
lastRunAt,
|
|
365
|
+
lastResult: body.lastResult === undefined ? null : String(body.lastResult),
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
function queryScript(taskName) {
|
|
369
|
+
return `
|
|
370
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
371
|
+
$ErrorActionPreference = 'Stop'
|
|
372
|
+
try {
|
|
373
|
+
$task = $null
|
|
374
|
+
try { $task = Get-ScheduledTask -TaskName '${taskName}' -ErrorAction Stop } catch { if ($_.FullyQualifiedErrorId -notmatch 'NotFound') { throw } }
|
|
375
|
+
if ($null -eq $task) {
|
|
376
|
+
[PSCustomObject]@{ found = $false } | ConvertTo-Json -Compress
|
|
377
|
+
} else {
|
|
378
|
+
$info = Get-ScheduledTaskInfo -TaskName '${taskName}'
|
|
379
|
+
$xml = Export-ScheduledTask -TaskName '${taskName}'
|
|
380
|
+
$lastRun = $null
|
|
381
|
+
# 267011 (0x41303) = SCHED_S_TASK_HAS_NOT_RUN — the RELIABLE never-run
|
|
382
|
+
# signal; the timestamp sentinel alone varies by locale/host (observed
|
|
383
|
+
# 1899- AND 1999-dated sentinons on real hosts).
|
|
384
|
+
if ($info.LastRunTime -and $info.LastTaskResult -ne 267011 -and $info.LastRunTime.Year -gt 1899) { $lastRun = $info.LastRunTime.ToString('o') }
|
|
385
|
+
$lastResult = $null
|
|
386
|
+
if ($null -ne $info.LastTaskResult) { $lastResult = [int64]$info.LastTaskResult }
|
|
387
|
+
$nextRun = $null
|
|
388
|
+
if ($info.NextRunTime -and $info.NextRunTime.Year -gt 1899) { $nextRun = $info.NextRunTime.ToString('o') }
|
|
389
|
+
# The run-as ownership witness: the SID of the account this query
|
|
390
|
+
# runs under, compared against the task's <Principal><UserId>.
|
|
391
|
+
$currentUserSid = $null
|
|
392
|
+
try { $currentUserSid = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value } catch { $currentUserSid = $null }
|
|
393
|
+
[PSCustomObject]@{ found = $true; state = [string]$task.State; xml = [string]$xml; lastRunAt = $lastRun; lastResult = $lastResult; nextRunTime = $nextRun; currentUserSid = $currentUserSid } | ConvertTo-Json -Compress
|
|
394
|
+
}
|
|
395
|
+
} catch {
|
|
396
|
+
[PSCustomObject]@{ ok = $false; errorId = $_.FullyQualifiedErrorId; message = $_.Exception.Message } | ConvertTo-Json -Compress
|
|
397
|
+
}
|
|
398
|
+
`.trim();
|
|
399
|
+
}
|
|
400
|
+
function mutationScript(body) {
|
|
401
|
+
return `
|
|
402
|
+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
403
|
+
$ErrorActionPreference = 'Stop'
|
|
404
|
+
try {
|
|
405
|
+
${body}
|
|
406
|
+
} catch {
|
|
407
|
+
[PSCustomObject]@{ ok = $false; errorId = $_.FullyQualifiedErrorId; message = $_.Exception.Message } | ConvertTo-Json -Compress
|
|
408
|
+
}
|
|
409
|
+
`.trim();
|
|
410
|
+
}
|
|
411
|
+
export function createWindowsSchedulerAdapter(deps) {
|
|
412
|
+
const { runner, fileIo } = deps;
|
|
413
|
+
async function runPowerShell(script, extraEnv) {
|
|
414
|
+
return runner.run('powershell.exe', [...POWERSHELL_ARGS_PREFIX, script], extraEnv);
|
|
415
|
+
}
|
|
416
|
+
/** Query the OS task. `not-found` is a normal verdict, everything else is structured. */
|
|
417
|
+
async function queryTask(taskName) {
|
|
418
|
+
const result = await runPowerShell(queryScript(taskName));
|
|
419
|
+
if (result.timedOut === true) {
|
|
420
|
+
return { ok: false, kind: 'command_failed', reason: 'powershell_timeout', nextAction: 'The Task Scheduler query did not return in time; check powershell.exe availability and machine load, then retry.' };
|
|
421
|
+
}
|
|
422
|
+
if (result.spawnError !== undefined) {
|
|
423
|
+
return { ok: false, kind: 'unavailable', reason: `powershell_unavailable:${result.spawnError.slice(0, 80)}`, nextAction: 'powershell.exe could not be started; the Windows scheduler adapter needs PowerShell (built into Windows).' };
|
|
424
|
+
}
|
|
425
|
+
const parsed = parsePowerShellJson(result.stdout);
|
|
426
|
+
if (!parsed.ok) {
|
|
427
|
+
return { ok: false, kind: 'command_failed', reason: parsed.reason, nextAction: 'The Task Scheduler PowerShell query returned unparsable output; re-run pd service status to see whether it is transient.' };
|
|
428
|
+
}
|
|
429
|
+
if (isPowerShellError(parsed.body)) {
|
|
430
|
+
const errorId = parsed.body.errorId ?? 'unknown';
|
|
431
|
+
// Permission denial must NEVER be reported as "not installed" (task §5).
|
|
432
|
+
return {
|
|
433
|
+
ok: false,
|
|
434
|
+
kind: 'command_failed',
|
|
435
|
+
reason: `scheduler_query_failed:${errorId}`,
|
|
436
|
+
nextAction: `The Task Scheduler query failed (${errorId}: ${parsed.body.message ?? ''}). If this is an access-denied error, the task exists but this process may not read it — do not treat the install as unregistered.`,
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
if (!isPowerShellQueryBody(parsed.body)) {
|
|
440
|
+
return { ok: false, kind: 'command_failed', reason: 'powershell_unexpected_output_shape', nextAction: 'The Task Scheduler query returned an unexpected document shape; re-run pd service status to see whether it is transient.' };
|
|
441
|
+
}
|
|
442
|
+
return { ok: true, body: parsed.body };
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Fail-closed ownership check (task §5 review): the exported Task XML is
|
|
446
|
+
* PARSED — Exec Command, Exec Arguments (decoded per the Win32 argv
|
|
447
|
+
* rules), WorkingDirectory and the LogonTrigger principal are each
|
|
448
|
+
* verified. A task whose definition merely CONTAINS our path strings
|
|
449
|
+
* (foreign content with matching substrings) is foreign; a task whose
|
|
450
|
+
* definition cannot be parsed at all is foreign too — PD never modifies
|
|
451
|
+
* or deletes what it cannot prove is its own.
|
|
452
|
+
*/
|
|
453
|
+
function ownershipVerdict(body, registration) {
|
|
454
|
+
if (!body.found || typeof body.xml !== 'string')
|
|
455
|
+
return { ours: false, conflict: 'external', detail: 'no_exported_xml' };
|
|
456
|
+
const exec = taskActionsExec(body.xml);
|
|
457
|
+
if (!exec.ok) {
|
|
458
|
+
return { ours: false, conflict: 'external', detail: `unparsable_exec:${exec.detail}` };
|
|
459
|
+
}
|
|
460
|
+
const command = xmlElement(exec.exec, 'Command');
|
|
461
|
+
const argsText = xmlElement(exec.exec, 'Arguments');
|
|
462
|
+
const workDir = xmlElement(exec.exec, 'WorkingDirectory');
|
|
463
|
+
const principals = taskPrincipalUsers(body.xml);
|
|
464
|
+
if (command === null || argsText === null || workDir === null) {
|
|
465
|
+
const missing = [command === null ? 'Command' : '', argsText === null ? 'Arguments' : '', workDir === null ? 'WorkingDirectory' : ''].filter(Boolean).join('+');
|
|
466
|
+
return { ours: false, conflict: 'external', detail: `unparsable_exec:${missing}` };
|
|
467
|
+
}
|
|
468
|
+
const execArgv = [command, ...windowsParseCommandLine(argsText)];
|
|
469
|
+
const expectedArgv = [registration.nodePath, ...schedulerInvocationArgs(registration)];
|
|
470
|
+
const execMatches = execArgv.length === expectedArgv.length
|
|
471
|
+
&& execArgv.every((token, index) => token.toLowerCase() === expectedArgv[index]?.toLowerCase());
|
|
472
|
+
const workDirMatches = workDir.toLowerCase() === registration.pdHome.toLowerCase();
|
|
473
|
+
// The task must declare exactly ONE non-empty interactive user
|
|
474
|
+
// principal on its logon trigger — zero or several inside the
|
|
475
|
+
// trigger means a definition PD did not write.
|
|
476
|
+
const principalMatches = principals.length === 1 && (principals[0] ?? '') !== '';
|
|
477
|
+
// The run-as principal must be exactly ONE <Principal><UserId> and
|
|
478
|
+
// equal the SID of the account this process runs under — otherwise
|
|
479
|
+
// the task was retargeted to a foreign account (or the SID could not
|
|
480
|
+
// be resolved) and the registration is not provably PD's.
|
|
481
|
+
const runAs = taskRunAsUsers(body.xml);
|
|
482
|
+
const sid = typeof body.currentUserSid === 'string' && body.currentUserSid !== '' ? body.currentUserSid : null;
|
|
483
|
+
const runAsMatches = runAs.length === 1 && (runAs[0] ?? '') !== ''
|
|
484
|
+
&& sid !== null && (runAs[0] ?? '').toLowerCase() === sid.toLowerCase();
|
|
485
|
+
if (execMatches && workDirMatches && principalMatches && runAsMatches)
|
|
486
|
+
return { ours: true };
|
|
487
|
+
const detail = [
|
|
488
|
+
execMatches ? '' : `argv_mismatch(expected ${expectedArgv.length} got ${execArgv.length})`,
|
|
489
|
+
workDirMatches ? '' : 'workdir_mismatch',
|
|
490
|
+
principalMatches ? '' : `principal_mismatch(count=${principals.length})`,
|
|
491
|
+
runAsMatches ? '' : `runas_mismatch(count=${runAs.length}${sid === null ? ',sid_unresolved' : ''})`,
|
|
492
|
+
].filter(Boolean).join('+');
|
|
493
|
+
return { ours: false, conflict: 'external', detail };
|
|
494
|
+
}
|
|
495
|
+
async function status(registration) {
|
|
496
|
+
const query = await queryTask(registration.identity.windowsTaskName);
|
|
497
|
+
if (!query.ok) {
|
|
498
|
+
return { ok: false, kind: query.kind, reason: query.reason, nextAction: query.nextAction };
|
|
499
|
+
}
|
|
500
|
+
return { ok: true, changed: false, facts: factsFromQuery(registration.identity, query.body) };
|
|
501
|
+
}
|
|
502
|
+
async function runMutation(registration, scriptBody, options) {
|
|
503
|
+
const taskName = registration.identity.windowsTaskName;
|
|
504
|
+
const result = await runPowerShell(mutationScript(scriptBody(taskName)), options?.extraEnv);
|
|
505
|
+
if (result.timedOut === true) {
|
|
506
|
+
return { ok: false, kind: 'command_failed', reason: 'powershell_timeout', nextAction: 'The Task Scheduler mutation did not finish in time; re-run the command — operations are idempotent.' };
|
|
507
|
+
}
|
|
508
|
+
if (result.spawnError !== undefined) {
|
|
509
|
+
return { ok: false, kind: 'unavailable', reason: `powershell_unavailable:${result.spawnError.slice(0, 80)}`, nextAction: 'powershell.exe could not be started; the Windows scheduler adapter needs PowerShell (built into Windows).' };
|
|
510
|
+
}
|
|
511
|
+
const parsed = parsePowerShellJson(result.stdout);
|
|
512
|
+
if (!parsed.ok) {
|
|
513
|
+
return { ok: false, kind: 'command_failed', reason: parsed.reason, nextAction: 'The Task Scheduler PowerShell mutation returned unparsable output; re-run the command and inspect the task with pd service status.' };
|
|
514
|
+
}
|
|
515
|
+
if (isPowerShellError(parsed.body)) {
|
|
516
|
+
const errorId = parsed.body.errorId ?? 'unknown';
|
|
517
|
+
return {
|
|
518
|
+
ok: false,
|
|
519
|
+
kind: 'command_failed',
|
|
520
|
+
reason: `scheduler_mutation_failed:${errorId}`,
|
|
521
|
+
nextAction: `The Task Scheduler operation failed (${errorId}: ${parsed.body.message ?? ''}). Nothing was silently skipped — re-run after fixing the cause; the operation is idempotent.`,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
const statusNow = await status(registration);
|
|
525
|
+
if (!statusNow.ok)
|
|
526
|
+
return statusNow;
|
|
527
|
+
return { ...statusNow, changed: true };
|
|
528
|
+
}
|
|
529
|
+
/** Write the task XML under <pdHome>/service and Register-ScheduledTask it. */
|
|
530
|
+
async function writeAndRegisterXml(registration, xml, mode) {
|
|
531
|
+
const xmlDir = path.join(registration.pdHome, 'service');
|
|
532
|
+
const xmlFile = path.join(xmlDir, 'scheduler-registration-win.xml');
|
|
533
|
+
const mkdir = fileIo.mkdirs(xmlDir);
|
|
534
|
+
if (!mkdir.ok) {
|
|
535
|
+
return { ok: false, kind: 'command_failed', reason: `scheduler_xml_dir_unwritable:${mkdir.reason.slice(0, 80)}`, nextAction: `Could not prepare ${xmlDir}; check permissions and retry pd service install.` };
|
|
536
|
+
}
|
|
537
|
+
const written = fileIo.writeAtomic(xmlFile, xml);
|
|
538
|
+
if (!written.ok) {
|
|
539
|
+
return { ok: false, kind: 'command_failed', reason: `scheduler_xml_write_failed:${written.reason.slice(0, 80)}`, nextAction: `Could not write the task definition to ${xmlFile}; retry pd service install after fixing the filesystem issue.` };
|
|
540
|
+
}
|
|
541
|
+
// ITaskFolder::RegisterTask flags: TASK_CREATE(2) refuses an existing
|
|
542
|
+
// task; TASK_UPDATE(4) rewrites the registration IN PLACE — a failed
|
|
543
|
+
// update leaves the old task and its enabled state intact, unlike
|
|
544
|
+
// Unregister→Register which deletes first (Register-ScheduledTask has
|
|
545
|
+
// no overwrite flag — it fails with HRESULT 0x800700b7, and the
|
|
546
|
+
// delete-first workaround risked losing the registration on failure).
|
|
547
|
+
const taskFlags = mode === 'update' ? 4 : 2;
|
|
548
|
+
const body = (name) => `
|
|
549
|
+
# -Encoding UTF8: the definition is written UTF-8 without BOM; Windows
|
|
550
|
+
# PowerShell 5.1 would otherwise decode it with the ANSI codepage and
|
|
551
|
+
# corrupt CJK/special characters in install paths (task §3.2).
|
|
552
|
+
$xmlText = Get-Content -LiteralPath $env:PD_TASK_XML -Raw -Encoding UTF8
|
|
553
|
+
$user = "$env:USERDOMAIN\\$env:USERNAME" -replace '&','&'
|
|
554
|
+
$xmlText = $xmlText.Replace('__PD_TASK_USER__', $user)
|
|
555
|
+
$ts = New-Object -ComObject Schedule.Service
|
|
556
|
+
$ts.Connect()
|
|
557
|
+
# LogonType 3 = TASK_LOGON_INTERACTIVE_TOKEN (run as the registering
|
|
558
|
+
# user, matching the XML's LogonTrigger principal).
|
|
559
|
+
$ts.GetFolder('\\').RegisterTask('${name}', $xmlText, ${taskFlags}, $null, $null, 3, $null) | Out-Null
|
|
560
|
+
[PSCustomObject]@{ done = $true } | ConvertTo-Json -Compress`;
|
|
561
|
+
return runMutation(registration, body, { extraEnv: { PD_TASK_XML: xmlFile } });
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
platform: 'win32',
|
|
565
|
+
async install(registration) {
|
|
566
|
+
const taskName = registration.identity.windowsTaskName;
|
|
567
|
+
const query = await queryTask(taskName);
|
|
568
|
+
if (!query.ok) {
|
|
569
|
+
return { ok: false, kind: query.kind, reason: query.reason, nextAction: query.nextAction };
|
|
570
|
+
}
|
|
571
|
+
if (query.body.found) {
|
|
572
|
+
const ownership = ownershipVerdict(query.body, registration);
|
|
573
|
+
if (!ownership.ours) {
|
|
574
|
+
return {
|
|
575
|
+
ok: false,
|
|
576
|
+
kind: 'external_conflict',
|
|
577
|
+
reason: 'scheduler_task_name_conflict_foreign_task',
|
|
578
|
+
nextAction: `A Task Scheduler task named ${taskName} already exists but does not reference this PD install (${registration.pdHome}; verdict: ${ownership.detail}). PD never overwrites or deletes foreign registrations — remove or rename it manually, or inspect it with Export-ScheduledTask.`,
|
|
579
|
+
facts: factsFromQuery(registration.identity, query.body),
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
// Refresh our own registration (task §15 review): rewrite the
|
|
583
|
+
// definition from the CURRENT OS state — interval + enabled
|
|
584
|
+
// preserved, only the CLI entry/node path move forward — unless
|
|
585
|
+
// the caller explicitly passed a new --interval-ms.
|
|
586
|
+
const preservedInterval = typeof query.body.xml === 'string' && registration.intervalExplicit !== true
|
|
587
|
+
? parseWindowsIntervalMs(query.body.xml)
|
|
588
|
+
: null;
|
|
589
|
+
const effective = preservedInterval !== null
|
|
590
|
+
? { ...registration, intervalMs: preservedInterval }
|
|
591
|
+
: registration;
|
|
592
|
+
const wasEnabled = query.body.state !== '' && query.body.state !== 'Disabled';
|
|
593
|
+
return writeAndRegisterXml(registration, buildWindowsTaskXml(effective, new Date(), wasEnabled), 'update');
|
|
594
|
+
}
|
|
595
|
+
return writeAndRegisterXml(registration, buildWindowsTaskXml(registration), 'create');
|
|
596
|
+
},
|
|
597
|
+
async enable(registration) {
|
|
598
|
+
const taskName = registration.identity.windowsTaskName;
|
|
599
|
+
const query = await queryTask(taskName);
|
|
600
|
+
if (!query.ok) {
|
|
601
|
+
return { ok: false, kind: query.kind, reason: query.reason, nextAction: query.nextAction };
|
|
602
|
+
}
|
|
603
|
+
if (!query.body.found) {
|
|
604
|
+
return {
|
|
605
|
+
ok: false,
|
|
606
|
+
kind: 'unsafe_state',
|
|
607
|
+
reason: 'scheduler_not_registered',
|
|
608
|
+
nextAction: 'No scheduler registration exists for this install. Run pd service install first — enable never creates one.',
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
const ownership = ownershipVerdict(query.body, registration);
|
|
612
|
+
if (!ownership.ours) {
|
|
613
|
+
return {
|
|
614
|
+
ok: false,
|
|
615
|
+
kind: 'external_conflict',
|
|
616
|
+
reason: 'scheduler_task_name_conflict_foreign_task',
|
|
617
|
+
nextAction: `The task named ${taskName} is not PD's own registration (verdict: ${ownership.detail}); PD refuses to modify it. Remove it manually if you own it.`,
|
|
618
|
+
facts: factsFromQuery(registration.identity, query.body),
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
if (query.body.state === 'Ready' || query.body.state === 'Running' || query.body.state === 'Queued') {
|
|
622
|
+
return { ok: true, changed: false, facts: factsFromQuery(registration.identity, query.body) };
|
|
623
|
+
}
|
|
624
|
+
return runMutation(registration, (name) => `
|
|
625
|
+
Enable-ScheduledTask -TaskName '${name}' | Out-Null
|
|
626
|
+
[PSCustomObject]@{ done = $true } | ConvertTo-Json -Compress`);
|
|
627
|
+
},
|
|
628
|
+
async disable(registration) {
|
|
629
|
+
const taskName = registration.identity.windowsTaskName;
|
|
630
|
+
const query = await queryTask(taskName);
|
|
631
|
+
if (!query.ok) {
|
|
632
|
+
return { ok: false, kind: query.kind, reason: query.reason, nextAction: query.nextAction };
|
|
633
|
+
}
|
|
634
|
+
if (!query.body.found) {
|
|
635
|
+
return {
|
|
636
|
+
ok: false,
|
|
637
|
+
kind: 'unsafe_state',
|
|
638
|
+
reason: 'scheduler_not_registered',
|
|
639
|
+
nextAction: 'No scheduler registration exists for this install; nothing to disable. Run pd service install first if you expected one.',
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
const ownership = ownershipVerdict(query.body, registration);
|
|
643
|
+
if (!ownership.ours) {
|
|
644
|
+
return {
|
|
645
|
+
ok: false,
|
|
646
|
+
kind: 'external_conflict',
|
|
647
|
+
reason: 'scheduler_task_name_conflict_foreign_task',
|
|
648
|
+
nextAction: `The task named ${taskName} is not PD's own registration (verdict: ${ownership.detail}); PD refuses to modify it.`,
|
|
649
|
+
facts: factsFromQuery(registration.identity, query.body),
|
|
650
|
+
};
|
|
651
|
+
}
|
|
652
|
+
if (query.body.state === 'Disabled') {
|
|
653
|
+
return { ok: true, changed: false, facts: factsFromQuery(registration.identity, query.body) };
|
|
654
|
+
}
|
|
655
|
+
return runMutation(registration, (name) => `
|
|
656
|
+
Disable-ScheduledTask -TaskName '${name}' | Out-Null
|
|
657
|
+
[PSCustomObject]@{ done = $true } | ConvertTo-Json -Compress`);
|
|
658
|
+
},
|
|
659
|
+
status,
|
|
660
|
+
async uninstall(registration) {
|
|
661
|
+
const taskName = registration.identity.windowsTaskName;
|
|
662
|
+
const query = await queryTask(taskName);
|
|
663
|
+
if (!query.ok) {
|
|
664
|
+
return { ok: false, kind: query.kind, reason: query.reason, nextAction: query.nextAction };
|
|
665
|
+
}
|
|
666
|
+
if (!query.body.found) {
|
|
667
|
+
// Idempotent no-op: nothing registered, nothing to remove.
|
|
668
|
+
return { ok: true, changed: false, facts: factsFromQuery(registration.identity, query.body) };
|
|
669
|
+
}
|
|
670
|
+
const ownership = ownershipVerdict(query.body, registration);
|
|
671
|
+
if (!ownership.ours) {
|
|
672
|
+
return {
|
|
673
|
+
ok: false,
|
|
674
|
+
kind: 'external_conflict',
|
|
675
|
+
reason: 'scheduler_task_name_conflict_foreign_task',
|
|
676
|
+
nextAction: `A task named ${taskName} exists but does not reference this PD install (verdict: ${ownership.detail}); PD never deletes foreign registrations. Inspect it with Export-ScheduledTask and remove it manually if you own it.`,
|
|
677
|
+
facts: factsFromQuery(registration.identity, query.body),
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
// Stop future triggers first, then remove the registration (task §5).
|
|
681
|
+
return runMutation(registration, (name) => `
|
|
682
|
+
Disable-ScheduledTask -TaskName '${name}' -ErrorAction SilentlyContinue | Out-Null
|
|
683
|
+
Unregister-ScheduledTask -TaskName '${name}' -Confirm:$false
|
|
684
|
+
[PSCustomObject]@{ done = $true } | ConvertTo-Json -Compress`);
|
|
685
|
+
},
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
//# sourceMappingURL=windows.js.map
|