@narumitw/pi-sync 0.70.7 → 0.71.1
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/CHANGELOG.md +16 -0
- package/README.md +33 -106
- package/dist/chunks/agent-plan-A6CS3XXA.ts +337 -0
- package/dist/chunks/agent-plan-A6CS3XXA.ts.map +7 -0
- package/dist/chunks/chunk-2BMTS5OW.ts +229 -0
- package/dist/chunks/chunk-2BMTS5OW.ts.map +7 -0
- package/dist/chunks/chunk-2G6GTIWW.ts +188 -0
- package/dist/chunks/chunk-2G6GTIWW.ts.map +7 -0
- package/dist/chunks/chunk-2YHXXWUF.ts +18 -0
- package/dist/chunks/chunk-2YHXXWUF.ts.map +7 -0
- package/dist/chunks/chunk-3GL7LBNB.ts +3 -0
- package/dist/chunks/chunk-3M3KQFSQ.ts +215 -0
- package/dist/chunks/chunk-3M3KQFSQ.ts.map +7 -0
- package/dist/chunks/chunk-3PFWVSV3.ts +3 -0
- package/dist/chunks/chunk-4S5CGN4M.ts +54 -0
- package/dist/chunks/chunk-4S5CGN4M.ts.map +7 -0
- package/dist/chunks/{chunk-H7VOTY5N.ts → chunk-53AFFVTT.ts} +2 -24
- package/dist/chunks/{chunk-H7VOTY5N.ts.map → chunk-53AFFVTT.ts.map} +1 -1
- package/dist/chunks/chunk-53IKSWLZ.ts +3 -0
- package/dist/chunks/{chunk-ZWP6HAYV.ts → chunk-5ERTMRNE.ts} +1 -1
- package/dist/chunks/chunk-5ERTMRNE.ts.map +7 -0
- package/dist/chunks/chunk-5WUWHDCJ.ts +12 -0
- package/dist/chunks/chunk-5WUWHDCJ.ts.map +7 -0
- package/dist/chunks/{chunk-WRS3SUNZ.ts → chunk-6VGQ6THO.ts} +8 -10
- package/dist/chunks/{chunk-WRS3SUNZ.ts.map → chunk-6VGQ6THO.ts.map} +1 -1
- package/dist/chunks/chunk-6WVJIIXQ.ts +154 -0
- package/dist/chunks/chunk-6WVJIIXQ.ts.map +7 -0
- package/dist/chunks/chunk-A3NEEVNA.ts +3 -0
- package/dist/chunks/chunk-A7KJUFLX.ts +2120 -0
- package/dist/chunks/chunk-A7KJUFLX.ts.map +7 -0
- package/dist/chunks/{chunk-4A34OGXY.ts → chunk-AA2G3HTW.ts} +12 -16
- package/dist/chunks/{chunk-4A34OGXY.ts.map → chunk-AA2G3HTW.ts.map} +1 -1
- package/dist/chunks/chunk-AITZUACB.ts +3 -0
- package/dist/chunks/chunk-AVLYLWA7.ts +1414 -0
- package/dist/chunks/chunk-AVLYLWA7.ts.map +7 -0
- package/dist/chunks/chunk-B4JNUYZ2.ts +12 -0
- package/dist/chunks/chunk-B4JNUYZ2.ts.map +7 -0
- package/dist/chunks/chunk-BEO3THWZ.ts +3 -0
- package/dist/chunks/chunk-BEO3THWZ.ts.map +7 -0
- package/dist/chunks/chunk-C2YD64T6.ts +167 -0
- package/dist/chunks/chunk-C2YD64T6.ts.map +7 -0
- package/dist/chunks/chunk-C66HLRRZ.ts +72 -0
- package/dist/chunks/chunk-C66HLRRZ.ts.map +7 -0
- package/dist/chunks/chunk-CFXAA65U.ts +53 -0
- package/dist/chunks/chunk-CFXAA65U.ts.map +7 -0
- package/dist/chunks/chunk-D34Y5JSL.ts +152 -0
- package/dist/chunks/chunk-D34Y5JSL.ts.map +7 -0
- package/dist/chunks/chunk-D3DMJSFU.ts +125 -0
- package/dist/chunks/chunk-D3DMJSFU.ts.map +7 -0
- package/dist/chunks/chunk-DFC3WJP5.ts +3 -0
- package/dist/chunks/chunk-DFC3WJP5.ts.map +7 -0
- package/dist/chunks/chunk-DH52CVRD.ts +2499 -0
- package/dist/chunks/chunk-DH52CVRD.ts.map +7 -0
- package/dist/chunks/chunk-DLA5RPFP.ts +50 -0
- package/dist/chunks/chunk-DLA5RPFP.ts.map +7 -0
- package/dist/chunks/chunk-ES4FIIHZ.ts +50 -0
- package/dist/chunks/chunk-ES4FIIHZ.ts.map +7 -0
- package/dist/chunks/chunk-ESUMO4TW.ts +55 -0
- package/dist/chunks/chunk-ESUMO4TW.ts.map +7 -0
- package/dist/chunks/chunk-FIEW5453.ts +77 -0
- package/dist/chunks/chunk-FIEW5453.ts.map +7 -0
- package/dist/chunks/chunk-FT45DX6E.ts +163 -0
- package/dist/chunks/chunk-FT45DX6E.ts.map +7 -0
- package/dist/chunks/chunk-G7U6BPP4.ts +137 -0
- package/dist/chunks/chunk-G7U6BPP4.ts.map +7 -0
- package/dist/chunks/{chunk-5BE6LBDC.ts → chunk-GC5XDUVA.ts} +25 -34
- package/dist/chunks/{chunk-5BE6LBDC.ts.map → chunk-GC5XDUVA.ts.map} +3 -3
- package/dist/chunks/{chunk-VERMBZGL.ts → chunk-GDA35HWZ.ts} +12 -14
- package/dist/chunks/{chunk-VERMBZGL.ts.map → chunk-GDA35HWZ.ts.map} +1 -1
- package/dist/chunks/chunk-HOFEC5FH.ts +54 -0
- package/dist/chunks/chunk-HOFEC5FH.ts.map +7 -0
- package/dist/chunks/{chunk-WE3KJ7JS.ts → chunk-IFJXUHHC.ts} +7 -7
- package/dist/chunks/chunk-INUH2UXN.ts +53 -0
- package/dist/chunks/chunk-INUH2UXN.ts.map +7 -0
- package/dist/chunks/chunk-JPLT2DG6.ts +122 -0
- package/dist/chunks/chunk-JPLT2DG6.ts.map +7 -0
- package/dist/chunks/chunk-KDTDGAOM.ts +76 -0
- package/dist/chunks/chunk-KDTDGAOM.ts.map +7 -0
- package/dist/chunks/chunk-LBDUDSHD.ts +3 -0
- package/dist/chunks/chunk-LBDUDSHD.ts.map +7 -0
- package/dist/chunks/{chunk-VQTYTUBU.ts → chunk-LHQIQIWL.ts} +4 -22
- package/dist/chunks/chunk-LHQIQIWL.ts.map +7 -0
- package/dist/chunks/chunk-MHERAG42.ts +150 -0
- package/dist/chunks/chunk-MHERAG42.ts.map +7 -0
- package/dist/chunks/chunk-MS6HLJFR.ts +61 -0
- package/dist/chunks/chunk-MS6HLJFR.ts.map +7 -0
- package/dist/chunks/{chunk-AXN3B5KC.ts → chunk-MTUR4H7S.ts} +31 -41
- package/dist/chunks/chunk-MTUR4H7S.ts.map +7 -0
- package/dist/chunks/chunk-NFW5HLKA.ts +84 -0
- package/dist/chunks/chunk-NFW5HLKA.ts.map +7 -0
- package/dist/chunks/chunk-NFZMKZ2D.ts +345 -0
- package/dist/chunks/chunk-NFZMKZ2D.ts.map +7 -0
- package/dist/chunks/chunk-OTI4XVCS.ts +618 -0
- package/dist/chunks/chunk-OTI4XVCS.ts.map +7 -0
- package/dist/chunks/chunk-QIL27OLJ.ts +28 -0
- package/dist/chunks/chunk-QIL27OLJ.ts.map +7 -0
- package/dist/chunks/chunk-QJTU5SCJ.ts +27 -0
- package/dist/chunks/chunk-QJTU5SCJ.ts.map +7 -0
- package/dist/chunks/chunk-QNU4RFCN.ts +225 -0
- package/dist/chunks/chunk-QNU4RFCN.ts.map +7 -0
- package/dist/chunks/chunk-QRSESWT2.ts +26 -0
- package/dist/chunks/chunk-QRSESWT2.ts.map +7 -0
- package/dist/chunks/chunk-RFJWUIV5.ts +1622 -0
- package/dist/chunks/chunk-RFJWUIV5.ts.map +7 -0
- package/dist/chunks/chunk-RRFW2UAD.ts +347 -0
- package/dist/chunks/chunk-RRFW2UAD.ts.map +7 -0
- package/dist/chunks/chunk-SD3D6BTF.ts +3 -0
- package/dist/chunks/chunk-SD3D6BTF.ts.map +7 -0
- package/dist/chunks/chunk-SPRHJBJC.ts +17 -0
- package/dist/chunks/chunk-SPRHJBJC.ts.map +7 -0
- package/dist/chunks/chunk-T22OVZSI.ts +347 -0
- package/dist/chunks/chunk-T22OVZSI.ts.map +7 -0
- package/dist/chunks/chunk-TAOYC2YG.ts +113 -0
- package/dist/chunks/chunk-TAOYC2YG.ts.map +7 -0
- package/dist/chunks/chunk-U6CORBHU.ts +205 -0
- package/dist/chunks/chunk-U6CORBHU.ts.map +7 -0
- package/dist/chunks/chunk-ULNEZ53E.ts +105 -0
- package/dist/chunks/chunk-ULNEZ53E.ts.map +7 -0
- package/dist/chunks/chunk-UPP54ATP.ts +3 -0
- package/dist/chunks/chunk-UPP54ATP.ts.map +7 -0
- package/dist/chunks/chunk-V66NV2HZ.ts +70 -0
- package/dist/chunks/chunk-V66NV2HZ.ts.map +7 -0
- package/dist/chunks/chunk-W3YS4Y2Q.ts +545 -0
- package/dist/chunks/chunk-W3YS4Y2Q.ts.map +7 -0
- package/dist/chunks/chunk-WETDHZAD.ts +815 -0
- package/dist/chunks/chunk-WETDHZAD.ts.map +7 -0
- package/dist/chunks/chunk-WT2722L4.ts +61 -0
- package/dist/chunks/chunk-WT2722L4.ts.map +7 -0
- package/dist/chunks/chunk-XHJ3AVIT.ts +12 -0
- package/dist/chunks/chunk-XHJ3AVIT.ts.map +7 -0
- package/dist/chunks/{chunk-HFMGK6A6.ts → chunk-YLVRV6NM.ts} +5 -5
- package/dist/chunks/chunk-YV776ZPN.ts +49 -0
- package/dist/chunks/chunk-YV776ZPN.ts.map +7 -0
- package/dist/chunks/chunk-YVHXQZIH.ts +411 -0
- package/dist/chunks/chunk-YVHXQZIH.ts.map +7 -0
- package/dist/chunks/chunk-ZWJMVLQ3.ts +3 -0
- package/dist/chunks/chunk-ZWJMVLQ3.ts.map +7 -0
- package/dist/chunks/chunk-ZWOKNJDT.ts +25 -0
- package/dist/chunks/chunk-ZWOKNJDT.ts.map +7 -0
- package/dist/chunks/{command-handler-DWWFIXSC.ts → command-handler-SMARANCT.ts} +128 -155
- package/dist/chunks/command-handler-SMARANCT.ts.map +7 -0
- package/dist/chunks/{chunk-LNZRNXNQ.ts → config-PUZS2ZBP.ts} +15 -6
- package/dist/chunks/config-PUZS2ZBP.ts.map +7 -0
- package/dist/chunks/conflict-artifacts-77PI6IXK.ts +33 -0
- package/dist/chunks/conflict-artifacts-77PI6IXK.ts.map +7 -0
- package/dist/chunks/conflict-review-HHGVL5TP.ts +188 -0
- package/dist/chunks/conflict-review-HHGVL5TP.ts.map +7 -0
- package/dist/chunks/conflict-review-OO57TGMR.ts +40 -0
- package/dist/chunks/conflict-review-OO57TGMR.ts.map +7 -0
- package/dist/chunks/continuous-record-QIIFQNKP.ts +277 -0
- package/dist/chunks/continuous-record-QIIFQNKP.ts.map +7 -0
- package/dist/chunks/debug-check-ETFFIDW5.ts +14 -0
- package/dist/chunks/debug-check-ETFFIDW5.ts.map +7 -0
- package/dist/chunks/debug-log-QGBO6XHF.ts +17 -0
- package/dist/chunks/debug-log-QGBO6XHF.ts.map +7 -0
- package/dist/chunks/debug-tool-execution-AIQAGPMJ.ts +95 -0
- package/dist/chunks/debug-tool-execution-AIQAGPMJ.ts.map +7 -0
- package/dist/chunks/{diff-review-GB4NO53B.ts → diff-review-QRHOHG5C.ts} +12 -5
- package/dist/chunks/diff-review-QRHOHG5C.ts.map +7 -0
- package/dist/chunks/{file-selection-DGC5UJVI.ts → file-selection-ZEBPDRHG.ts} +33 -16
- package/dist/chunks/{file-selection-DGC5UJVI.ts.map → file-selection-ZEBPDRHG.ts.map} +1 -1
- package/dist/chunks/git-backend-I2IJ5ULJ.ts +1151 -0
- package/dist/chunks/git-backend-I2IJ5ULJ.ts.map +7 -0
- package/dist/chunks/initialization-XGYWRNPQ.ts +106 -0
- package/dist/chunks/initialization-XGYWRNPQ.ts.map +7 -0
- package/dist/chunks/local-diff-review-OGZM3TA7.ts +525 -0
- package/dist/chunks/local-diff-review-OGZM3TA7.ts.map +7 -0
- package/dist/chunks/local-fields-PIKOEXWR.ts +31 -0
- package/dist/chunks/local-fields-PIKOEXWR.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-72YGSLHL.ts +42 -0
- package/dist/chunks/manager-result-dispatcher-72YGSLHL.ts.map +7 -0
- package/dist/chunks/{manager-ui-3CQU37XY.ts → manager-ui-5SXPS4SE.ts} +130 -92
- package/dist/chunks/manager-ui-5SXPS4SE.ts.map +7 -0
- package/dist/chunks/merge-baseline-store-MI7SHGDH.ts +26 -0
- package/dist/chunks/merge-baseline-store-MI7SHGDH.ts.map +7 -0
- package/dist/chunks/merge-journal-46QC5N7D.ts +38 -0
- package/dist/chunks/merge-journal-46QC5N7D.ts.map +7 -0
- package/dist/chunks/{merge-review-DXSERTCK.ts → merge-review-RMDYVNBK.ts} +2 -2
- package/dist/chunks/remote-selection-ui-4BXJAZUD.ts +41 -0
- package/dist/chunks/remote-selection-ui-4BXJAZUD.ts.map +7 -0
- package/dist/chunks/s3-backend-ZRMOWH5R.ts +866 -0
- package/dist/chunks/s3-backend-ZRMOWH5R.ts.map +7 -0
- package/dist/chunks/session-push-55IV4IW3.ts +101 -0
- package/dist/chunks/session-push-55IV4IW3.ts.map +7 -0
- package/dist/chunks/setup-switch-DXDUBDQI.ts +43 -0
- package/dist/chunks/setup-switch-DXDUBDQI.ts.map +7 -0
- package/dist/chunks/{setup-wizard-FRIR2EOR.ts → setup-wizard-ICPQERAE.ts} +34 -18
- package/dist/chunks/{setup-wizard-FRIR2EOR.ts.map → setup-wizard-ICPQERAE.ts.map} +1 -1
- package/dist/chunks/{snapshot-ZUJJZCFW.ts → snapshot-HDARHOQZ.ts} +14 -8
- package/dist/chunks/snapshot-HDARHOQZ.ts.map +7 -0
- package/dist/chunks/snapshot-LZ6XKFA4.ts +63 -0
- package/dist/chunks/snapshot-LZ6XKFA4.ts.map +7 -0
- package/dist/chunks/snapshot-transaction-LYR5OFLR.ts +27 -0
- package/dist/chunks/snapshot-transaction-LYR5OFLR.ts.map +7 -0
- package/dist/chunks/sync-inspection-N6TELULU.ts +29 -0
- package/dist/chunks/sync-inspection-N6TELULU.ts.map +7 -0
- package/dist/chunks/sync-inspection-PMEXXLDK.ts +26 -0
- package/dist/chunks/sync-inspection-PMEXXLDK.ts.map +7 -0
- package/dist/chunks/sync-operations-KKSIS2CI.ts +69 -0
- package/dist/chunks/sync-operations-KKSIS2CI.ts.map +7 -0
- package/dist/chunks/sync-operations-VSMA5GSA.ts +47 -0
- package/dist/chunks/sync-operations-VSMA5GSA.ts.map +7 -0
- package/dist/chunks/{sync-state-QIT64TKV.ts → sync-state-72ZDKUQW.ts} +13 -5
- package/dist/chunks/sync-state-72ZDKUQW.ts.map +7 -0
- package/dist/chunks/{sync-state-store-TZE7XDV5.ts → sync-state-store-YTMAZQ3Z.ts} +8 -2
- package/dist/chunks/sync-state-store-YTMAZQ3Z.ts.map +7 -0
- package/dist/chunks/webdav-backend-3AZOECVQ.ts +948 -0
- package/dist/chunks/webdav-backend-3AZOECVQ.ts.map +7 -0
- package/dist/index.ts +271 -478
- package/dist/index.ts.map +4 -4
- package/docs/agent-continuous-hardening.md +3 -1
- package/docs/agent-quality-verification.md +3 -1
- package/docs/continuous-sync-verification.md +1 -1
- package/docs/daemon-migration.md +3 -1
- package/docs/daemon-retirement.md +15 -0
- package/docs/merge-implementation-audit.md +2 -0
- package/docs/settings-merge-audit.md +1 -1
- package/docs/tui-contract.md +12 -14
- package/package.json +5 -7
- package/skills/configure-pi-sync/SKILL.md +14 -60
- package/skills/configure-pi-sync/references/configuration.md +38 -46
- package/src/backends/backend-factory.ts +2 -2
- package/src/backends/backend-identity.ts +2 -2
- package/src/backends/backend-types.ts +1 -1
- package/src/backends/git/git-backend.ts +2 -2
- package/src/backends/git/git-config.ts +2 -2
- package/src/backends/git/git-runner.ts +2 -2
- package/src/backends/git/git-storage.ts +2 -2
- package/src/backends/s3/s3-backend.ts +2 -2
- package/src/backends/s3/s3-client.ts +2 -2
- package/src/backends/s3/s3-conditions.ts +2 -2
- package/src/backends/snapshot-pointer.ts +2 -2
- package/src/backends/sync-backend.ts +2 -2
- package/src/backends/webdav/webdav-backend.ts +2 -2
- package/src/backends/webdav/webdav-client.ts +2 -2
- package/src/backends/webdav/webdav-config.ts +2 -2
- package/src/commands/command-execution.ts +66 -62
- package/src/commands/command-handler.ts +3 -10
- package/src/commands/command-types.ts +1 -0
- package/src/commands/command.ts +3 -24
- package/src/engine/backends/backend-factory.ts +23 -0
- package/src/engine/backends/backend-identity.ts +40 -0
- package/src/engine/backends/backend-types.ts +75 -0
- package/src/engine/backends/git/git-backend.ts +863 -0
- package/src/engine/backends/git/git-config.ts +130 -0
- package/src/engine/backends/git/git-runner.ts +260 -0
- package/src/engine/backends/git/git-storage.ts +295 -0
- package/src/engine/backends/publication-encoding.ts +19 -0
- package/src/engine/backends/s3/s3-backend.ts +528 -0
- package/src/engine/backends/s3/s3-client.ts +398 -0
- package/src/engine/backends/s3/s3-conditions.ts +64 -0
- package/src/engine/backends/snapshot-pointer.ts +26 -0
- package/src/engine/backends/sync-backend.ts +133 -0
- package/src/engine/backends/webdav/webdav-backend.ts +691 -0
- package/src/engine/backends/webdav/webdav-client.ts +390 -0
- package/src/engine/backends/webdav/webdav-config.ts +82 -0
- package/src/engine/commands/command-types.ts +37 -0
- package/src/engine/debug-check.ts +83 -0
- package/src/engine/debug-log.ts +272 -0
- package/src/engine/diff-review-types.ts +16 -0
- package/src/engine/foreground-transfer.ts +15 -0
- package/src/engine/host.ts +95 -0
- package/src/engine/paths.ts +90 -0
- package/src/engine/record.ts +3 -0
- package/src/engine/settings/config-errors.ts +6 -0
- package/src/engine/settings/config-file.ts +907 -0
- package/src/engine/settings/config.ts +315 -0
- package/src/engine/settings/retired-ignore-policy.ts +15 -0
- package/src/engine/settings/retired-ignore-recovery.ts +18 -0
- package/src/engine/settings/settings-management.ts +261 -0
- package/src/engine/settings/settings-store.ts +48 -0
- package/src/engine/settings/settings-types.ts +164 -0
- package/src/engine/settings/settings-validation.ts +472 -0
- package/src/engine/snapshot/session-paths.ts +179 -0
- package/src/engine/snapshot/snapshot-apply.ts +443 -0
- package/src/engine/snapshot/snapshot-bounds.ts +23 -0
- package/src/engine/snapshot/snapshot-capture-limit.ts +110 -0
- package/src/engine/snapshot/snapshot-case-replacement.ts +77 -0
- package/src/engine/snapshot/snapshot-codec.ts +69 -0
- package/src/engine/snapshot/snapshot-difference.ts +25 -0
- package/src/engine/snapshot/snapshot-entry-projection.ts +101 -0
- package/src/engine/snapshot/snapshot-exclude-safety.ts +203 -0
- package/src/engine/snapshot/snapshot-mutation-queues.ts +152 -0
- package/src/engine/snapshot/snapshot-paths.ts +11 -0
- package/src/engine/snapshot/snapshot-payload.ts +50 -0
- package/src/engine/snapshot/snapshot-reviewed-preimages.ts +68 -0
- package/src/engine/snapshot/snapshot-root-transition.ts +170 -0
- package/src/engine/snapshot/snapshot-transaction-directory.ts +16 -0
- package/src/engine/snapshot/snapshot-transaction-images.ts +424 -0
- package/src/engine/snapshot/snapshot-transaction-plan.ts +69 -0
- package/src/engine/snapshot/snapshot-transaction-policy.ts +278 -0
- package/src/engine/snapshot/snapshot-transaction-stage.ts +342 -0
- package/src/engine/snapshot/snapshot-transaction-verification.ts +109 -0
- package/src/engine/snapshot/snapshot-transaction.ts +961 -0
- package/src/engine/snapshot/snapshot-types.ts +67 -0
- package/src/engine/snapshot/snapshot.ts +847 -0
- package/src/engine/state/json-file.ts +46 -0
- package/src/engine/state/lock.ts +421 -0
- package/src/engine/state/lockfile-fs.ts +25 -0
- package/src/engine/state/merge-baseline-store.ts +213 -0
- package/src/engine/state/mutation-directory-sync.ts +33 -0
- package/src/engine/state/operation-availability.ts +59 -0
- package/src/engine/state/state-directory.ts +245 -0
- package/src/engine/state/state-types.ts +26 -0
- package/src/engine/state/sync-state-store.ts +77 -0
- package/src/engine/sync/agent-candidate.ts +252 -0
- package/src/engine/sync/agent-plan.ts +114 -0
- package/{dist/daemon/dist/engine/sync/agent-policy.js → src/engine/sync/agent-policy.ts} +5 -3
- package/src/engine/sync/agent-refusal-retry.ts +53 -0
- package/src/engine/sync/agent-request.ts +17 -0
- package/src/engine/sync/agent-runner.ts +208 -0
- package/src/engine/sync/agent-store.ts +175 -0
- package/src/engine/sync/agent-sync.ts +145 -0
- package/src/engine/sync/apply-review.ts +63 -0
- package/src/engine/sync/conflict-artifact-ownership.ts +58 -0
- package/src/engine/sync/conflict-artifacts.ts +193 -0
- package/src/engine/sync/conflict-groups.ts +67 -0
- package/src/engine/sync/conflict-preview.ts +54 -0
- package/src/engine/sync/conflict-resolution.ts +93 -0
- package/src/engine/sync/conflict-retention.ts +71 -0
- package/src/engine/sync/conflict-review.ts +95 -0
- package/src/engine/sync/content-conflicts.ts +73 -0
- package/src/engine/sync/continuous-errors.ts +91 -0
- package/src/engine/sync/continuous-lease.ts +213 -0
- package/src/engine/sync/continuous-record.ts +255 -0
- package/src/engine/sync/continuous-storage.ts +63 -0
- package/src/engine/sync/continuous-sync.ts +646 -0
- package/src/engine/sync/continuous-watch.ts +123 -0
- package/src/engine/sync/diff-review-capture.ts +259 -0
- package/src/engine/sync/diff-review-preview.ts +111 -0
- package/src/engine/sync/diff-review-store.ts +72 -0
- package/src/engine/sync/directional-action.ts +169 -0
- package/src/engine/sync/directional-conflict.ts +53 -0
- package/src/engine/sync/exclude-policy.ts +88 -0
- package/src/engine/sync/field-migration.ts +39 -0
- package/src/engine/sync/file-merge-planner.ts +138 -0
- package/src/engine/sync/initialization.ts +81 -0
- package/src/engine/sync/json-document.ts +179 -0
- package/src/engine/sync/local-field-policy.ts +28 -0
- package/src/engine/sync/local-fields.ts +171 -0
- package/src/engine/sync/merge-acceptance.ts +56 -0
- package/src/engine/sync/merge-apply.ts +585 -0
- package/src/engine/sync/merge-journal.ts +259 -0
- package/src/engine/sync/merge-transfer-error.ts +68 -0
- package/src/engine/sync/merged-sync.ts +912 -0
- package/src/engine/sync/mutation-owner.ts +22 -0
- package/src/engine/sync/package-merge.ts +81 -0
- package/src/engine/sync/partial-progress.ts +56 -0
- package/src/engine/sync/pull-outcome.ts +16 -0
- package/src/engine/sync/push-review.ts +47 -0
- package/src/engine/sync/remote-snapshot.ts +185 -0
- package/src/engine/sync/resolver-stream.ts +34 -0
- package/src/engine/sync/session-merge.ts +192 -0
- package/src/engine/sync/session-push.ts +68 -0
- package/src/engine/sync/settings-conflicts.ts +64 -0
- package/src/engine/sync/settings-merge.ts +118 -0
- package/src/engine/sync/signals.ts +8 -0
- package/src/engine/sync/startup-recovery-evidence.ts +37 -0
- package/src/engine/sync/startup-timings.ts +135 -0
- package/src/engine/sync/sync-decision.ts +134 -0
- package/src/engine/sync/sync-error-guidance.ts +56 -0
- package/src/engine/sync/sync-errors.ts +50 -0
- package/src/engine/sync/sync-inspection.ts +61 -0
- package/src/engine/sync/sync-loaders.ts +14 -0
- package/src/engine/sync/sync-local.ts +117 -0
- package/src/engine/sync/sync-mutations.ts +940 -0
- package/src/engine/sync/sync-operations.ts +10 -0
- package/src/engine/sync/sync-policy.ts +695 -0
- package/src/engine/sync/sync-queries.ts +404 -0
- package/src/engine/sync/sync-rollback.ts +245 -0
- package/src/engine/sync/sync-state.ts +197 -0
- package/src/engine/sync/text-merge.ts +132 -0
- package/src/engine/sync/transfer-freshness.ts +151 -0
- package/src/engine/sync/transfer-size-limits.ts +100 -0
- package/src/engine/types.ts +45 -0
- package/src/engine/ui/merge-review.ts +14 -0
- package/src/engine/ui/merged-sync-summary.ts +111 -0
- package/src/engine/ui/sync-format.ts +222 -0
- package/src/engine/ui/sync-status.ts +29 -0
- package/src/engine/ui/terminal-text.ts +9 -0
- package/src/engine/ui/transfer-changes.ts +32 -0
- package/src/engine/ui/transfer-review.ts +28 -0
- package/src/paths.ts +2 -2
- package/src/runtime/identity.ts +152 -0
- package/src/runtime/legacy-owner.ts +223 -0
- package/src/runtime/lifecycle.ts +17 -0
- package/src/runtime/local-host.ts +157 -0
- package/src/{daemon/session-presence.ts → runtime/session-presence-binding.ts} +1 -2
- package/src/runtime/session-presence.ts +258 -0
- package/src/settings/config-errors.ts +2 -2
- package/src/settings/config-file.ts +2 -2
- package/src/settings/config.ts +2 -2
- package/src/settings/settings-management.ts +2 -2
- package/src/settings/settings-store.ts +2 -2
- package/src/settings/settings-types.ts +1 -1
- package/src/settings/settings-validation.ts +2 -2
- package/src/snapshot/session-paths.ts +2 -2
- package/src/snapshot/snapshot-apply.ts +2 -2
- package/src/snapshot/snapshot-case-replacement.ts +2 -2
- package/src/snapshot/snapshot-codec.ts +2 -2
- package/src/snapshot/snapshot-exclude-safety.ts +2 -2
- package/src/snapshot/snapshot-mutation-queues.ts +2 -2
- package/src/snapshot/snapshot-paths.ts +2 -2
- package/src/snapshot/snapshot-root-transition.ts +2 -2
- package/src/snapshot/snapshot-transaction-directory.ts +2 -2
- package/src/snapshot/snapshot-transaction-plan.ts +2 -2
- package/src/snapshot/snapshot-transaction.ts +2 -2
- package/src/snapshot/snapshot-types.ts +1 -1
- package/src/snapshot/snapshot.ts +2 -2
- package/src/state/json-file.ts +2 -2
- package/src/state/lock-policy.ts +2 -2
- package/src/state/lock.ts +2 -2
- package/src/state/lockfile-fs.ts +2 -2
- package/src/state/merge-baseline-store.ts +2 -2
- package/src/state/mutation-directory-sync.ts +2 -2
- package/src/state/operation-availability.ts +2 -2
- package/src/state/state-directory.ts +2 -2
- package/src/state/state-types.ts +1 -1
- package/src/state/sync-state-store.ts +2 -2
- package/src/sync/agent-candidate.ts +2 -2
- package/src/sync/agent-plan.ts +2 -2
- package/src/sync/agent-policy.ts +2 -2
- package/src/sync/agent-refusal-retry.ts +2 -2
- package/src/sync/agent-request.ts +2 -2
- package/src/sync/agent-runner.ts +2 -2
- package/src/sync/agent-store.ts +2 -2
- package/src/sync/agent-sync.ts +2 -2
- package/src/sync/apply-review.ts +2 -2
- package/src/sync/automatic-sync.ts +58 -120
- package/src/sync/conflict-artifact-ownership.ts +2 -2
- package/src/sync/conflict-artifacts.ts +2 -2
- package/src/sync/conflict-groups.ts +2 -2
- package/src/sync/conflict-preview.ts +2 -2
- package/src/sync/conflict-resolution.ts +2 -2
- package/src/sync/conflict-retention.ts +2 -2
- package/src/sync/conflict-review.ts +5 -2
- package/src/sync/content-conflicts.ts +2 -2
- package/src/sync/continuous-errors.ts +2 -2
- package/src/sync/continuous-lease.ts +2 -2
- package/src/sync/continuous-record.ts +2 -2
- package/src/sync/continuous-storage.ts +2 -2
- package/src/sync/continuous-sync.ts +2 -2
- package/src/sync/continuous-watch.ts +2 -2
- package/src/sync/debug-tool-execution.ts +21 -22
- package/src/sync/debug-tool.ts +10 -12
- package/src/sync/exclude-policy.ts +2 -2
- package/src/sync/field-migration.ts +2 -2
- package/src/sync/file-merge-planner.ts +2 -2
- package/src/sync/json-document.ts +2 -2
- package/src/sync/local-diff-review.ts +115 -0
- package/src/sync/local-field-policy.ts +2 -2
- package/src/sync/local-fields.ts +2 -2
- package/src/sync/local-recovery.ts +53 -0
- package/src/sync/merge-apply.ts +2 -2
- package/src/sync/merge-journal.ts +2 -2
- package/src/sync/merge-transfer-error.ts +2 -2
- package/src/sync/merged-sync.ts +2 -2
- package/src/sync/mutation-owner.ts +2 -2
- package/src/sync/package-merge.ts +2 -2
- package/src/sync/partial-progress.ts +2 -2
- package/src/sync/remote-snapshot.ts +2 -2
- package/src/sync/session-merge.ts +2 -2
- package/src/sync/settings-conflicts.ts +2 -2
- package/src/sync/settings-merge.ts +2 -2
- package/src/sync/signals.ts +2 -2
- package/src/sync/startup-timings.ts +2 -2
- package/src/sync/sync-decision.ts +2 -2
- package/src/sync/sync-error-guidance.ts +2 -2
- package/src/sync/sync-errors.ts +2 -2
- package/src/sync/sync-inspection.ts +46 -11
- package/src/sync/sync-local.ts +2 -2
- package/src/sync/sync-mutations.ts +2 -2
- package/src/sync/sync-operations.ts +143 -33
- package/src/sync/sync-policy.ts +2 -2
- package/src/sync/sync-queries.ts +2 -2
- package/src/sync/sync-state.ts +2 -2
- package/src/sync/text-merge.ts +2 -2
- package/src/sync-extension.ts +170 -340
- package/src/ui/cancellable-operation.ts +1 -1
- package/src/ui/diff-review.ts +4 -3
- package/src/ui/manager-ui.ts +2 -22
- package/dist/chunks/chunk-6YKOHBSC.ts +0 -18
- package/dist/chunks/chunk-6YKOHBSC.ts.map +0 -7
- package/dist/chunks/chunk-A43CJYG4.ts +0 -26
- package/dist/chunks/chunk-A43CJYG4.ts.map +0 -7
- package/dist/chunks/chunk-APZVJAEW.ts +0 -34
- package/dist/chunks/chunk-APZVJAEW.ts.map +0 -7
- package/dist/chunks/chunk-AXN3B5KC.ts.map +0 -7
- package/dist/chunks/chunk-GELYN4UC.ts +0 -14
- package/dist/chunks/chunk-GELYN4UC.ts.map +0 -7
- package/dist/chunks/chunk-HCXPNKPU.ts +0 -1553
- package/dist/chunks/chunk-HCXPNKPU.ts.map +0 -7
- package/dist/chunks/chunk-IBXEM35O.ts +0 -34
- package/dist/chunks/chunk-IBXEM35O.ts.map +0 -7
- package/dist/chunks/chunk-LNZRNXNQ.ts.map +0 -7
- package/dist/chunks/chunk-NXWHPVXR.ts +0 -26
- package/dist/chunks/chunk-NXWHPVXR.ts.map +0 -7
- package/dist/chunks/chunk-P4GI7LTT.ts +0 -20
- package/dist/chunks/chunk-P4GI7LTT.ts.map +0 -7
- package/dist/chunks/chunk-R3SAMXB6.ts +0 -60
- package/dist/chunks/chunk-R3SAMXB6.ts.map +0 -7
- package/dist/chunks/chunk-R7PN3KIY.ts +0 -22
- package/dist/chunks/chunk-R7PN3KIY.ts.map +0 -7
- package/dist/chunks/chunk-T3LABNHF.ts +0 -20
- package/dist/chunks/chunk-T3LABNHF.ts.map +0 -7
- package/dist/chunks/chunk-UMPA5S7X.ts +0 -11
- package/dist/chunks/chunk-UMPA5S7X.ts.map +0 -7
- package/dist/chunks/chunk-VQTYTUBU.ts.map +0 -7
- package/dist/chunks/chunk-ZO52JM4H.ts +0 -15
- package/dist/chunks/chunk-ZO52JM4H.ts.map +0 -7
- package/dist/chunks/chunk-ZWP6HAYV.ts.map +0 -7
- package/dist/chunks/client-debug-F4WFP2YJ.ts +0 -40
- package/dist/chunks/client-debug-F4WFP2YJ.ts.map +0 -7
- package/dist/chunks/command-handler-DWWFIXSC.ts.map +0 -7
- package/dist/chunks/conflict-review-HSERM245.ts +0 -18
- package/dist/chunks/conflict-review-HSERM245.ts.map +0 -7
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts +0 -67
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts.map +0 -7
- package/dist/chunks/diff-review-6IUIOYST.ts +0 -68
- package/dist/chunks/diff-review-6IUIOYST.ts.map +0 -7
- package/dist/chunks/diff-review-GB4NO53B.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-6MOJPLIS.ts +0 -20
- package/dist/chunks/manager-ui-3CQU37XY.ts.map +0 -7
- package/dist/chunks/ownership-recovery-5KXAMFSL.ts +0 -59
- package/dist/chunks/ownership-recovery-5KXAMFSL.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-2V53UBHM.ts +0 -19
- package/dist/chunks/setup-switch-WSKVGW7L.ts +0 -27
- package/dist/chunks/snapshot-ZUJJZCFW.ts.map +0 -7
- package/dist/chunks/snapshot-transaction-directory-F46JWRAU.ts +0 -13
- package/dist/chunks/snapshot-transaction-directory-F46JWRAU.ts.map +0 -7
- package/dist/chunks/state-directory-CMAIF34J.ts +0 -17
- package/dist/chunks/sync-inspection-CQDNC542.ts +0 -23
- package/dist/chunks/sync-inspection-CQDNC542.ts.map +0 -7
- package/dist/chunks/sync-operations-IF7LMWK6.ts +0 -52
- package/dist/chunks/sync-operations-IF7LMWK6.ts.map +0 -7
- package/dist/chunks/sync-state-QIT64TKV.ts.map +0 -7
- package/dist/daemon/LICENSE +0 -21
- package/dist/daemon/dist/build-id.json +0 -1
- package/dist/daemon/dist/build-version.js +0 -28
- package/dist/daemon/dist/child-sdk.mjs +0 -17
- package/dist/daemon/dist/cli.js +0 -156
- package/dist/daemon/dist/client-transport.js +0 -77
- package/dist/daemon/dist/client.js +0 -950
- package/dist/daemon/dist/consent.js +0 -304
- package/dist/daemon/dist/daemon-debug.js +0 -40
- package/dist/daemon/dist/daemon-recovery.js +0 -160
- package/dist/daemon/dist/daemon-startup.js +0 -350
- package/dist/daemon/dist/daemon-status.js +0 -57
- package/dist/daemon/dist/daemon-upgrade-error.js +0 -14
- package/dist/daemon/dist/diff-review-binding.js +0 -11
- package/dist/daemon/dist/diff-review-protocol.js +0 -85
- package/dist/daemon/dist/diff-review-rpc.js +0 -37
- package/dist/daemon/dist/diff-review-store.js +0 -89
- package/dist/daemon/dist/document.js +0 -6
- package/dist/daemon/dist/endpoint.js +0 -91
- package/dist/daemon/dist/engine/backends/backend-factory.js +0 -16
- package/dist/daemon/dist/engine/backends/backend-identity.js +0 -38
- package/dist/daemon/dist/engine/backends/backend-types.js +0 -1
- package/dist/daemon/dist/engine/backends/git/git-backend.js +0 -775
- package/dist/daemon/dist/engine/backends/git/git-config.js +0 -118
- package/dist/daemon/dist/engine/backends/git/git-runner.js +0 -237
- package/dist/daemon/dist/engine/backends/git/git-storage.js +0 -227
- package/dist/daemon/dist/engine/backends/publication-encoding.js +0 -19
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +0 -453
- package/dist/daemon/dist/engine/backends/s3/s3-client.js +0 -362
- package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +0 -66
- package/dist/daemon/dist/engine/backends/snapshot-pointer.js +0 -22
- package/dist/daemon/dist/engine/backends/sync-backend.js +0 -39
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +0 -605
- package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +0 -349
- package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +0 -73
- package/dist/daemon/dist/engine/commands/command-types.js +0 -1
- package/dist/daemon/dist/engine/debug-check.js +0 -59
- package/dist/daemon/dist/engine/debug-log.js +0 -252
- package/dist/daemon/dist/engine/host.js +0 -20
- package/dist/daemon/dist/engine/paths.js +0 -77
- package/dist/daemon/dist/engine/settings/config-errors.js +0 -4
- package/dist/daemon/dist/engine/settings/config-file.js +0 -784
- package/dist/daemon/dist/engine/settings/config.js +0 -246
- package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +0 -16
- package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +0 -14
- package/dist/daemon/dist/engine/settings/settings-management.js +0 -196
- package/dist/daemon/dist/engine/settings/settings-store.js +0 -41
- package/dist/daemon/dist/engine/settings/settings-types.js +0 -1
- package/dist/daemon/dist/engine/settings/settings-validation.js +0 -390
- package/dist/daemon/dist/engine/snapshot/session-paths.js +0 -146
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +0 -347
- package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +0 -20
- package/dist/daemon/dist/engine/snapshot/snapshot-capture-limit.js +0 -99
- package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +0 -82
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +0 -62
- package/dist/daemon/dist/engine/snapshot/snapshot-difference.js +0 -13
- package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +0 -78
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +0 -205
- package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +0 -153
- package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +0 -11
- package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +0 -42
- package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +0 -60
- package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +0 -138
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +0 -16
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +0 -415
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +0 -68
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +0 -202
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +0 -303
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +0 -78
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +0 -830
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +0 -3
- package/dist/daemon/dist/engine/snapshot/snapshot.js +0 -695
- package/dist/daemon/dist/engine/state/json-file.js +0 -49
- package/dist/daemon/dist/engine/state/lock.js +0 -399
- package/dist/daemon/dist/engine/state/lockfile-fs.js +0 -13
- package/dist/daemon/dist/engine/state/merge-baseline-store.js +0 -198
- package/dist/daemon/dist/engine/state/mutation-directory-sync.js +0 -34
- package/dist/daemon/dist/engine/state/operation-availability.js +0 -40
- package/dist/daemon/dist/engine/state/state-directory.js +0 -227
- package/dist/daemon/dist/engine/state/state-types.js +0 -1
- package/dist/daemon/dist/engine/state/sync-state-store.js +0 -58
- package/dist/daemon/dist/engine/sync/agent-candidate.js +0 -207
- package/dist/daemon/dist/engine/sync/agent-plan.js +0 -84
- package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +0 -39
- package/dist/daemon/dist/engine/sync/agent-request.js +0 -13
- package/dist/daemon/dist/engine/sync/agent-runner.js +0 -183
- package/dist/daemon/dist/engine/sync/agent-store.js +0 -177
- package/dist/daemon/dist/engine/sync/agent-sync.js +0 -139
- package/dist/daemon/dist/engine/sync/apply-review.js +0 -52
- package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +0 -53
- package/dist/daemon/dist/engine/sync/conflict-artifacts.js +0 -158
- package/dist/daemon/dist/engine/sync/conflict-groups.js +0 -76
- package/dist/daemon/dist/engine/sync/conflict-preview.js +0 -53
- package/dist/daemon/dist/engine/sync/conflict-resolution.js +0 -53
- package/dist/daemon/dist/engine/sync/conflict-retention.js +0 -61
- package/dist/daemon/dist/engine/sync/conflict-review.js +0 -73
- package/dist/daemon/dist/engine/sync/content-conflicts.js +0 -70
- package/dist/daemon/dist/engine/sync/continuous-errors.js +0 -72
- package/dist/daemon/dist/engine/sync/continuous-lease.js +0 -206
- package/dist/daemon/dist/engine/sync/continuous-record.js +0 -199
- package/dist/daemon/dist/engine/sync/continuous-storage.js +0 -59
- package/dist/daemon/dist/engine/sync/continuous-sync.js +0 -549
- package/dist/daemon/dist/engine/sync/continuous-watch.js +0 -137
- package/dist/daemon/dist/engine/sync/diff-review-capture.js +0 -210
- package/dist/daemon/dist/engine/sync/diff-review-preview.js +0 -114
- package/dist/daemon/dist/engine/sync/directional-action.js +0 -101
- package/dist/daemon/dist/engine/sync/directional-conflict.js +0 -29
- package/dist/daemon/dist/engine/sync/exclude-policy.js +0 -86
- package/dist/daemon/dist/engine/sync/field-migration.js +0 -20
- package/dist/daemon/dist/engine/sync/file-merge-planner.js +0 -123
- package/dist/daemon/dist/engine/sync/initialization.js +0 -81
- package/dist/daemon/dist/engine/sync/json-document.js +0 -172
- package/dist/daemon/dist/engine/sync/local-field-policy.js +0 -26
- package/dist/daemon/dist/engine/sync/local-fields.js +0 -161
- package/dist/daemon/dist/engine/sync/merge-acceptance.js +0 -29
- package/dist/daemon/dist/engine/sync/merge-apply.js +0 -530
- package/dist/daemon/dist/engine/sync/merge-journal.js +0 -204
- package/dist/daemon/dist/engine/sync/merge-transfer-error.js +0 -64
- package/dist/daemon/dist/engine/sync/merged-sync.js +0 -655
- package/dist/daemon/dist/engine/sync/mutation-owner.js +0 -18
- package/dist/daemon/dist/engine/sync/package-merge.js +0 -82
- package/dist/daemon/dist/engine/sync/partial-progress.js +0 -41
- package/dist/daemon/dist/engine/sync/push-review.js +0 -18
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +0 -119
- package/dist/daemon/dist/engine/sync/resolver-stream.js +0 -34
- package/dist/daemon/dist/engine/sync/session-merge.js +0 -178
- package/dist/daemon/dist/engine/sync/session-push.js +0 -56
- package/dist/daemon/dist/engine/sync/settings-conflicts.js +0 -56
- package/dist/daemon/dist/engine/sync/settings-merge.js +0 -93
- package/dist/daemon/dist/engine/sync/signals.js +0 -8
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +0 -105
- package/dist/daemon/dist/engine/sync/startup-recovery-evidence.js +0 -37
- package/dist/daemon/dist/engine/sync/startup-timings.js +0 -116
- package/dist/daemon/dist/engine/sync/sync-decision.js +0 -81
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +0 -74
- package/dist/daemon/dist/engine/sync/sync-errors.js +0 -38
- package/dist/daemon/dist/engine/sync/sync-inspection.js +0 -42
- package/dist/daemon/dist/engine/sync/sync-loaders.js +0 -8
- package/dist/daemon/dist/engine/sync/sync-local.js +0 -96
- package/dist/daemon/dist/engine/sync/sync-mutations.js +0 -723
- package/dist/daemon/dist/engine/sync/sync-operations.js +0 -3
- package/dist/daemon/dist/engine/sync/sync-policy.js +0 -530
- package/dist/daemon/dist/engine/sync/sync-queries.js +0 -316
- package/dist/daemon/dist/engine/sync/sync-rollback.js +0 -180
- package/dist/daemon/dist/engine/sync/sync-state.js +0 -119
- package/dist/daemon/dist/engine/sync/text-merge.js +0 -124
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +0 -79
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +0 -88
- package/dist/daemon/dist/engine/types.js +0 -2
- package/dist/daemon/dist/engine/ui/merge-review.js +0 -7
- package/dist/daemon/dist/engine/ui/merged-sync-summary.js +0 -86
- package/dist/daemon/dist/engine/ui/sync-format.js +0 -123
- package/dist/daemon/dist/engine/ui/sync-status.js +0 -30
- package/dist/daemon/dist/engine/ui/terminal-text.js +0 -9
- package/dist/daemon/dist/engine/ui/transfer-changes.js +0 -24
- package/dist/daemon/dist/engine/ui/transfer-review.js +0 -18
- package/dist/daemon/dist/engine-service.js +0 -506
- package/dist/daemon/dist/foreground-queue-outcome.js +0 -9
- package/dist/daemon/dist/foreground-transfer.js +0 -10
- package/dist/daemon/dist/identity.js +0 -275
- package/dist/daemon/dist/idle-exit.js +0 -77
- package/dist/daemon/dist/index.js +0 -27
- package/dist/daemon/dist/legacy-consent-guard.js +0 -34
- package/dist/daemon/dist/lifecycle-log.js +0 -54
- package/dist/daemon/dist/lifecycle.js +0 -21
- package/dist/daemon/dist/model-signature.js +0 -7
- package/dist/daemon/dist/paged-review.js +0 -177
- package/dist/daemon/dist/participant-admission.js +0 -30
- package/dist/daemon/dist/participant-ledger.js +0 -149
- package/dist/daemon/dist/protocol.js +0 -108
- package/dist/daemon/dist/resolver-host.js +0 -78
- package/dist/daemon/dist/server.js +0 -1374
- package/dist/daemon/dist/service-host.js +0 -260
- package/dist/daemon/dist/session-presence.js +0 -207
- package/dist/daemon/dist/state-wait-jobs.js +0 -23
- package/dist/daemon/dist/state-wait.js +0 -34
- package/dist/daemon/dist/upgrade-repair.js +0 -55
- package/dist/daemon/package.json +0 -3
- package/dist/package.json +0 -6
- package/src/daemon/apply-gate.ts +0 -146
- package/src/daemon/client-debug.ts +0 -50
- package/src/daemon/daemon-status-ui.ts +0 -64
- package/src/daemon/diff-review.ts +0 -68
- package/src/daemon/directional-recovery.ts +0 -106
- package/src/daemon/ownership-recovery.ts +0 -50
- package/src/daemon/pi-client.ts +0 -1330
- package/src/daemon/queue-release-ui.ts +0 -88
- package/src/daemon/recovery.ts +0 -103
- package/src/daemon/startup-bootstrap-client.ts +0 -26
- /package/dist/chunks/{manager-result-dispatcher-6MOJPLIS.ts.map → chunk-3GL7LBNB.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-2V53UBHM.ts.map → chunk-3PFWVSV3.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-WSKVGW7L.ts.map → chunk-53IKSWLZ.ts.map} +0 -0
- /package/dist/chunks/{state-directory-CMAIF34J.ts.map → chunk-A3NEEVNA.ts.map} +0 -0
- /package/dist/chunks/{sync-state-store-TZE7XDV5.ts.map → chunk-AITZUACB.ts.map} +0 -0
- /package/dist/chunks/{chunk-WE3KJ7JS.ts.map → chunk-IFJXUHHC.ts.map} +0 -0
- /package/dist/chunks/{chunk-HFMGK6A6.ts.map → chunk-YLVRV6NM.ts.map} +0 -0
- /package/dist/chunks/{merge-review-DXSERTCK.ts.map → merge-review-RMDYVNBK.ts.map} +0 -0
- /package/{dist/daemon/dist/engine/state/lock-policy.js → src/engine/state/lock-policy.ts} +0 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
canonicalRootGuard
|
|
5
|
+
} from "./chunk-G7U6BPP4.ts";
|
|
6
|
+
import {
|
|
7
|
+
ensureStateDir,
|
|
8
|
+
lockPath
|
|
9
|
+
} from "./chunk-NFW5HLKA.ts";
|
|
10
|
+
import {
|
|
11
|
+
throwIfAborted
|
|
12
|
+
} from "./chunk-SPRHJBJC.ts";
|
|
13
|
+
import {
|
|
14
|
+
LOCKFILE_FS_ADAPTER,
|
|
15
|
+
LOCK_GUARD_STALE_MS,
|
|
16
|
+
LOCK_GUARD_UPDATE_MS,
|
|
17
|
+
stateDir
|
|
18
|
+
} from "./chunk-NFZMKZ2D.ts";
|
|
19
|
+
import {
|
|
20
|
+
getEngineRoot
|
|
21
|
+
} from "./chunk-ES4FIIHZ.ts";
|
|
22
|
+
|
|
23
|
+
// src/engine/state/lock.ts
|
|
24
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
25
|
+
import { randomUUID } from "node:crypto";
|
|
26
|
+
import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, realpathSync } from "node:fs";
|
|
27
|
+
import fs from "node:fs/promises";
|
|
28
|
+
import path from "node:path";
|
|
29
|
+
import lockfile from "proper-lockfile";
|
|
30
|
+
var LOCK_STALE_MS = 30 * 60 * 1e3;
|
|
31
|
+
var MAX_PROCESS_ID = 2147483647;
|
|
32
|
+
var activeLock = new AsyncLocalStorage();
|
|
33
|
+
async function withLock(command, fn, options = {}) {
|
|
34
|
+
await ensureStateDir();
|
|
35
|
+
const configuredRoot = getEngineRoot();
|
|
36
|
+
const root = realpathSync(configuredRoot);
|
|
37
|
+
const assertRoot = canonicalRootGuard(root);
|
|
38
|
+
const directory = stateDir(root);
|
|
39
|
+
const file = path.join(directory, "lock");
|
|
40
|
+
const original = lstatSync(directory);
|
|
41
|
+
const assertLocation = () => {
|
|
42
|
+
assertRoot();
|
|
43
|
+
if (realpathSync(configuredRoot) !== root || stateDir(root) !== directory)
|
|
44
|
+
throw new Error("Pi Sync operation lock directory changed.");
|
|
45
|
+
const current = lstatSync(directory);
|
|
46
|
+
if (!current.isDirectory() || current.dev !== original.dev || current.ino !== original.ino)
|
|
47
|
+
throw new Error("Pi Sync operation lock directory changed.");
|
|
48
|
+
};
|
|
49
|
+
assertLocation();
|
|
50
|
+
const lock = {
|
|
51
|
+
id: randomUUID(),
|
|
52
|
+
pid: process.pid,
|
|
53
|
+
command,
|
|
54
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
55
|
+
};
|
|
56
|
+
let guard;
|
|
57
|
+
let written = false;
|
|
58
|
+
let result;
|
|
59
|
+
let failed = false;
|
|
60
|
+
let failure;
|
|
61
|
+
try {
|
|
62
|
+
try {
|
|
63
|
+
guard = await acquireGuard(file, assertLocation);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
if (!isLockHeldError(error)) throw error;
|
|
66
|
+
assertLocation();
|
|
67
|
+
throw await describeHeldLock(file);
|
|
68
|
+
}
|
|
69
|
+
assertLocation();
|
|
70
|
+
let inspection = await inspectLockAt(file);
|
|
71
|
+
if (inspection.status === "valid" && isStaleLock(inspection.lock)) {
|
|
72
|
+
if (!options.reclaimStale) {
|
|
73
|
+
throw new Error(`pi-sync lock is stale (pid ${inspection.lock.pid}). Run /sync unlock --stale, then retry.`);
|
|
74
|
+
}
|
|
75
|
+
guard.throwIfCompromised();
|
|
76
|
+
const rechecked = await inspectLockAt(file);
|
|
77
|
+
if (rechecked.status !== "valid" || rechecked.lock.id !== inspection.lock.id || !isStaleLock(rechecked.lock)) {
|
|
78
|
+
throw new Error("pi-sync lock changed while preparing transaction recovery; retry.");
|
|
79
|
+
}
|
|
80
|
+
assertLocation();
|
|
81
|
+
guard.throwIfCompromised();
|
|
82
|
+
await fs.rm(file, { force: true });
|
|
83
|
+
inspection = { status: "missing" };
|
|
84
|
+
}
|
|
85
|
+
if (inspection.status === "valid") {
|
|
86
|
+
throw Object.assign(
|
|
87
|
+
new Error(
|
|
88
|
+
`pi-sync is already running (${inspection.lock.command}, pid ${inspection.lock.pid}, started ${inspection.lock.startedAt}).`
|
|
89
|
+
),
|
|
90
|
+
{ code: "ELOCKED" }
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
if (inspection.status === "unreadable") {
|
|
94
|
+
throw new Error(
|
|
95
|
+
"pi-sync lock metadata is unreadable. Run /sync unlock --stale after verifying no sync is running."
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
assertLocation();
|
|
99
|
+
guard.throwIfCompromised();
|
|
100
|
+
const contents = Buffer.from(JSON.stringify(lock, null, " "));
|
|
101
|
+
await fs.writeFile(file, contents, { flag: "wx" });
|
|
102
|
+
written = true;
|
|
103
|
+
guard.throwIfCompromised();
|
|
104
|
+
const held = guard;
|
|
105
|
+
let active = true;
|
|
106
|
+
const ownsLock = () => {
|
|
107
|
+
if (!active || held.isCompromised()) return false;
|
|
108
|
+
try {
|
|
109
|
+
assertLocation();
|
|
110
|
+
return true;
|
|
111
|
+
} catch {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
result = await activeLock.run({ path: file, contents, active: ownsLock }, fn);
|
|
117
|
+
guard.throwIfCompromised();
|
|
118
|
+
} finally {
|
|
119
|
+
active = false;
|
|
120
|
+
}
|
|
121
|
+
} catch (error) {
|
|
122
|
+
failed = true;
|
|
123
|
+
failure = error;
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
if (written && guard) {
|
|
127
|
+
assertLocation();
|
|
128
|
+
guard.throwIfCompromised();
|
|
129
|
+
const current = await inspectLockAt(file);
|
|
130
|
+
if (current.status === "valid" && current.lock.id === lock.id) {
|
|
131
|
+
assertLocation();
|
|
132
|
+
guard.throwIfCompromised();
|
|
133
|
+
await fs.rm(file, { force: true });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (!failed) {
|
|
138
|
+
failed = true;
|
|
139
|
+
failure = error;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (guard) {
|
|
143
|
+
const releaseError = await releaseGuard(guard);
|
|
144
|
+
if (releaseError && !failed) {
|
|
145
|
+
failed = true;
|
|
146
|
+
failure = releaseError;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (failed) throw failure;
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
async function inspectLock() {
|
|
153
|
+
return inspectLockAt(lockPath());
|
|
154
|
+
}
|
|
155
|
+
async function inspectLockAt(file) {
|
|
156
|
+
try {
|
|
157
|
+
const text = await fs.readFile(file, "utf8");
|
|
158
|
+
if (text.trim().length === 0) return { status: "unreadable" };
|
|
159
|
+
const parsed = JSON.parse(text);
|
|
160
|
+
return isLockFile(parsed) ? { status: "valid", lock: parsed } : { status: "unreadable" };
|
|
161
|
+
} catch (error) {
|
|
162
|
+
if (error.code === "ENOENT") return { status: "missing" };
|
|
163
|
+
if (error instanceof SyntaxError) return { status: "unreadable" };
|
|
164
|
+
throw error;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function isLockGuardHeld() {
|
|
168
|
+
return lockfile.check(lockPath(), {
|
|
169
|
+
fs: LOCKFILE_FS_ADAPTER,
|
|
170
|
+
lockfilePath: `${lockPath()}.guard`,
|
|
171
|
+
realpath: false,
|
|
172
|
+
stale: LOCK_GUARD_STALE_MS
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function isStaleLock(lock) {
|
|
176
|
+
try {
|
|
177
|
+
process.kill(lock.pid, 0);
|
|
178
|
+
return false;
|
|
179
|
+
} catch (error) {
|
|
180
|
+
if (error.code === "ESRCH") return true;
|
|
181
|
+
return Date.now() - Date.parse(lock.startedAt) > LOCK_STALE_MS;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
async function unlock(ctx, options) {
|
|
185
|
+
throwIfAborted(options.signal);
|
|
186
|
+
await ensureStateDir();
|
|
187
|
+
throwIfAborted(options.signal);
|
|
188
|
+
let guard;
|
|
189
|
+
try {
|
|
190
|
+
guard = await acquireGuard();
|
|
191
|
+
} catch (error) {
|
|
192
|
+
if (!isLockHeldError(error)) throw error;
|
|
193
|
+
ctx.ui.notify((await describeHeldLock()).message, "warning");
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
let failed = false;
|
|
197
|
+
let failure;
|
|
198
|
+
try {
|
|
199
|
+
await unlockGuarded(ctx, options);
|
|
200
|
+
} catch (error) {
|
|
201
|
+
failed = true;
|
|
202
|
+
failure = error;
|
|
203
|
+
}
|
|
204
|
+
const releaseError = await releaseGuard(guard);
|
|
205
|
+
if (releaseError && !failed) {
|
|
206
|
+
failed = true;
|
|
207
|
+
failure = releaseError;
|
|
208
|
+
}
|
|
209
|
+
if (failed) throw failure;
|
|
210
|
+
}
|
|
211
|
+
async function unlockGuarded(ctx, options) {
|
|
212
|
+
throwIfAborted(options.signal);
|
|
213
|
+
let inspection = await inspectLock();
|
|
214
|
+
throwIfAborted(options.signal);
|
|
215
|
+
if (inspection.status === "missing") {
|
|
216
|
+
ctx.ui.notify("No pi-sync lock is present.", "info");
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (inspection.status === "unreadable") {
|
|
220
|
+
if (!options.stale) {
|
|
221
|
+
ctx.ui.notify(
|
|
222
|
+
"Pi-sync lock metadata is unreadable. Use /sync unlock --stale only after verifying no sync is running.",
|
|
223
|
+
"warning"
|
|
224
|
+
);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
inspection = await inspectLock();
|
|
228
|
+
throwIfAborted(options.signal);
|
|
229
|
+
if (inspection.status === "unreadable") {
|
|
230
|
+
throwIfAborted(options.signal);
|
|
231
|
+
await fs.rm(lockPath(), { force: true });
|
|
232
|
+
if (!options.signal?.aborted) {
|
|
233
|
+
ctx.ui.notify(
|
|
234
|
+
"Removed unreadable pi-sync lock. No settings, files, sync state, or remote data were changed.",
|
|
235
|
+
"info"
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (inspection.status === "missing") {
|
|
241
|
+
ctx.ui.notify("No pi-sync lock is present.", "info");
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (!isStaleLock(inspection.lock)) {
|
|
246
|
+
ctx.ui.notify("Lock owner is still live; refusing to remove it.", "warning");
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
throwIfAborted(options.signal);
|
|
250
|
+
await fs.rm(lockPath(), { force: true });
|
|
251
|
+
if (!options.signal?.aborted) {
|
|
252
|
+
ctx.ui.notify("Removed stale pi-sync lock. No settings, files, sync state, or remote data were changed.", "info");
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
async function releaseGuard(guard) {
|
|
256
|
+
try {
|
|
257
|
+
await guard.release();
|
|
258
|
+
return void 0;
|
|
259
|
+
} catch (error) {
|
|
260
|
+
return guard.isCompromised() ? void 0 : error;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function guardFilesystem(assertLocation) {
|
|
264
|
+
const { mkdir, rmdir, rmdirSync, stat, utimes } = LOCKFILE_FS_ADAPTER;
|
|
265
|
+
function check(callback) {
|
|
266
|
+
try {
|
|
267
|
+
assertLocation();
|
|
268
|
+
return true;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
callback(error);
|
|
271
|
+
return false;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
...LOCKFILE_FS_ADAPTER,
|
|
276
|
+
mkdir: (file, callback) => {
|
|
277
|
+
if (check(callback)) mkdir(file, callback);
|
|
278
|
+
},
|
|
279
|
+
rmdir: (...args) => {
|
|
280
|
+
if (check(args[1])) rmdir(...args);
|
|
281
|
+
},
|
|
282
|
+
rmdirSync: (...args) => {
|
|
283
|
+
assertLocation();
|
|
284
|
+
return rmdirSync(...args);
|
|
285
|
+
},
|
|
286
|
+
stat: (file, callback) => {
|
|
287
|
+
if (check(callback)) stat(file, callback);
|
|
288
|
+
},
|
|
289
|
+
utimes: (...args) => {
|
|
290
|
+
if (check(args[3])) utimes(...args);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
async function acquireGuard(file = lockPath(), assertLocation) {
|
|
295
|
+
let compromisedError;
|
|
296
|
+
const release = await lockfile.lock(file, {
|
|
297
|
+
fs: assertLocation ? guardFilesystem(assertLocation) : LOCKFILE_FS_ADAPTER,
|
|
298
|
+
lockfilePath: `${file}.guard`,
|
|
299
|
+
realpath: false,
|
|
300
|
+
stale: LOCK_GUARD_STALE_MS,
|
|
301
|
+
update: LOCK_GUARD_UPDATE_MS,
|
|
302
|
+
onCompromised: (error) => {
|
|
303
|
+
compromisedError = error;
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
return {
|
|
307
|
+
release,
|
|
308
|
+
throwIfCompromised: () => {
|
|
309
|
+
if (compromisedError) throw compromisedError;
|
|
310
|
+
},
|
|
311
|
+
isCompromised: () => compromisedError !== void 0
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
async function describeHeldLock(file = lockPath()) {
|
|
315
|
+
const inspection = await inspectLockAt(file);
|
|
316
|
+
const current = inspection.status === "valid" ? inspection.lock : void 0;
|
|
317
|
+
if (current && isStaleLock(current)) {
|
|
318
|
+
return new Error("pi-sync lock owner exited; retry shortly while the lock guard expires.");
|
|
319
|
+
}
|
|
320
|
+
if (current) {
|
|
321
|
+
return Object.assign(
|
|
322
|
+
new Error(`Pi-sync is currently running (${current.command}, pid ${current.pid}, started ${current.startedAt}).`),
|
|
323
|
+
{ code: "ELOCKED" }
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
return Object.assign(
|
|
327
|
+
new Error("Pi-sync is currently running (lock metadata is unreadable or still being written)."),
|
|
328
|
+
{ code: "ELOCKED" }
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
function isLockHeldError(error) {
|
|
332
|
+
return error.code === "ELOCKED";
|
|
333
|
+
}
|
|
334
|
+
function isLockFile(value) {
|
|
335
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
336
|
+
const lock = value;
|
|
337
|
+
return typeof lock.id === "string" && lock.id.length > 0 && Number.isInteger(lock.pid) && (lock.pid ?? 0) > 0 && (lock.pid ?? 0) <= MAX_PROCESS_ID && typeof lock.command === "string" && lock.command.length > 0 && typeof lock.startedAt === "string" && Number.isFinite(Date.parse(lock.startedAt));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
export {
|
|
341
|
+
withLock,
|
|
342
|
+
inspectLock,
|
|
343
|
+
isLockGuardHeld,
|
|
344
|
+
isStaleLock,
|
|
345
|
+
unlock
|
|
346
|
+
};
|
|
347
|
+
//# sourceMappingURL=chunk-T22OVZSI.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/engine/state/lock.ts"],
|
|
4
|
+
"sourcesContent": ["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport { closeSync, constants, fstatSync, lstatSync, openSync, readSync, realpathSync, type Stats } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport lockfile from \"proper-lockfile\";\nimport { canonicalRootGuard } from \"../../runtime/identity.js\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport { type EngineContext as ExtensionCommandContext, getEngineRoot } from \"../host.js\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { LOCK_GUARD_STALE_MS, LOCK_GUARD_UPDATE_MS } from \"./lock-policy.js\";\nimport { LOCKFILE_FS_ADAPTER } from \"./lockfile-fs.js\";\nimport { stateDir } from \"./state-directory.js\";\nimport type { LockFile } from \"./state-types.js\";\nimport { ensureStateDir, lockPath } from \"./sync-state-store.js\";\n\nconst LOCK_STALE_MS = 30 * 60 * 1000;\nconst MAX_PROCESS_ID = 2_147_483_647;\n\ninterface Guard {\n release: () => Promise<void>;\n throwIfCompromised: () => void;\n isCompromised: () => boolean;\n}\n\nexport type LockInspection = { status: \"missing\" } | { status: \"unreadable\" } | { status: \"valid\"; lock: LockFile };\n\nconst activeLock = new AsyncLocalStorage<{ path: string; contents: Buffer; active(): boolean }>();\n\nexport function captureStartupReviewLock(): (() => boolean) | undefined {\n const owner = activeLock.getStore();\n if (!owner?.active()) return;\n const guardPath = `${owner.path}.guard`;\n const originalGuard = lstatSync(guardPath, { bigint: true, throwIfNoEntry: false });\n const originalLock = lstatSync(owner.path, { bigint: true, throwIfNoEntry: false });\n if (!originalGuard?.isDirectory() || !originalLock?.isFile()) return;\n const validate = () => {\n if (!owner.active() || owner.path !== lockPath()) return false;\n const guard = lstatSync(guardPath, { bigint: true, throwIfNoEntry: false });\n const candidate = lstatSync(owner.path, { bigint: true, throwIfNoEntry: false });\n if (\n !guard?.isDirectory() ||\n guard.dev !== originalGuard.dev ||\n guard.ino !== originalGuard.ino ||\n Number(guard.mtimeMs) < Date.now() - LOCK_GUARD_STALE_MS ||\n !candidate?.isFile() ||\n candidate.dev !== originalLock.dev ||\n candidate.ino !== originalLock.ino ||\n candidate.size !== BigInt(owner.contents.length)\n )\n return false;\n const fd = openSync(owner.path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));\n try {\n const opened = fstatSync(fd, { bigint: true });\n if (!opened.isFile() || opened.dev !== candidate.dev || opened.ino !== candidate.ino) return false;\n const current = Buffer.alloc(owner.contents.length + 1);\n let offset = 0;\n while (offset < current.length) {\n const count = readSync(fd, current, offset, current.length - offset, offset);\n if (!count) break;\n offset += count;\n }\n return current.subarray(0, offset).equals(owner.contents);\n } finally {\n closeSync(fd);\n }\n };\n return validate() ? validate : undefined;\n}\n\nexport async function withLock<T>(\n command: string,\n fn: () => Promise<T>,\n options: { reclaimStale?: boolean } = {},\n): Promise<T> {\n await ensureStateDir();\n const configuredRoot = getEngineRoot();\n const root = realpathSync(configuredRoot);\n const assertRoot = canonicalRootGuard(root);\n const directory = stateDir(root);\n const file = path.join(directory, \"lock\");\n const original = lstatSync(directory);\n const assertLocation = () => {\n assertRoot();\n if (realpathSync(configuredRoot) !== root || stateDir(root) !== directory)\n throw new Error(\"Pi Sync operation lock directory changed.\");\n const current = lstatSync(directory);\n if (!current.isDirectory() || current.dev !== original.dev || current.ino !== original.ino)\n throw new Error(\"Pi Sync operation lock directory changed.\");\n };\n assertLocation();\n const lock: LockFile = {\n id: randomUUID(),\n pid: process.pid,\n command,\n startedAt: new Date().toISOString(),\n };\n let guard: Guard | undefined;\n let written = false;\n let result: T | undefined;\n let failed = false;\n let failure: unknown;\n try {\n try {\n guard = await acquireGuard(file, assertLocation);\n } catch (error) {\n if (!isLockHeldError(error)) throw error;\n assertLocation();\n throw await describeHeldLock(file);\n }\n\n assertLocation();\n let inspection = await inspectLockAt(file);\n if (inspection.status === \"valid\" && isStaleLock(inspection.lock)) {\n if (!options.reclaimStale) {\n throw new Error(`pi-sync lock is stale (pid ${inspection.lock.pid}). Run /sync unlock --stale, then retry.`);\n }\n guard.throwIfCompromised();\n const rechecked = await inspectLockAt(file);\n if (rechecked.status !== \"valid\" || rechecked.lock.id !== inspection.lock.id || !isStaleLock(rechecked.lock)) {\n throw new Error(\"pi-sync lock changed while preparing transaction recovery; retry.\");\n }\n assertLocation();\n guard.throwIfCompromised();\n await fs.rm(file, { force: true });\n inspection = { status: \"missing\" };\n }\n if (inspection.status === \"valid\") {\n throw Object.assign(\n new Error(\n `pi-sync is already running (${inspection.lock.command}, pid ${inspection.lock.pid}, started ${inspection.lock.startedAt}).`,\n ),\n { code: \"ELOCKED\" },\n );\n }\n if (inspection.status === \"unreadable\") {\n throw new Error(\n \"pi-sync lock metadata is unreadable. Run /sync unlock --stale after verifying no sync is running.\",\n );\n }\n\n assertLocation();\n guard.throwIfCompromised();\n const contents = Buffer.from(JSON.stringify(lock, null, \"\\t\"));\n await fs.writeFile(file, contents, { flag: \"wx\" });\n written = true;\n guard.throwIfCompromised();\n const held = guard;\n let active = true;\n const ownsLock = () => {\n if (!active || held.isCompromised()) return false;\n try {\n assertLocation();\n return true;\n } catch {\n return false;\n }\n };\n try {\n result = await activeLock.run({ path: file, contents, active: ownsLock }, fn);\n guard.throwIfCompromised();\n } finally {\n active = false;\n }\n } catch (error) {\n failed = true;\n failure = error;\n }\n\n try {\n if (written && guard) {\n assertLocation();\n guard.throwIfCompromised();\n const current = await inspectLockAt(file);\n if (current.status === \"valid\" && current.lock.id === lock.id) {\n assertLocation();\n guard.throwIfCompromised();\n await fs.rm(file, { force: true });\n }\n }\n } catch (error) {\n if (!failed) {\n failed = true;\n failure = error;\n }\n }\n if (guard) {\n const releaseError = await releaseGuard(guard);\n if (releaseError && !failed) {\n failed = true;\n failure = releaseError;\n }\n }\n if (failed) throw failure;\n return result as T;\n}\n\nexport async function inspectLock(): Promise<LockInspection> {\n return inspectLockAt(lockPath());\n}\n\nasync function inspectLockAt(file: string): Promise<LockInspection> {\n try {\n const text = await fs.readFile(file, \"utf8\");\n if (text.trim().length === 0) return { status: \"unreadable\" };\n const parsed = JSON.parse(text) as unknown;\n return isLockFile(parsed) ? { status: \"valid\", lock: parsed } : { status: \"unreadable\" };\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return { status: \"missing\" };\n if (error instanceof SyntaxError) return { status: \"unreadable\" };\n throw error;\n }\n}\n\nexport async function readLock(): Promise<LockFile | undefined> {\n const inspection = await inspectLock();\n return inspection.status === \"valid\" ? inspection.lock : undefined;\n}\n\nexport async function lockFileExists(): Promise<boolean> {\n try {\n await fs.stat(lockPath());\n return true;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return false;\n throw error;\n }\n}\n\nexport function isLockGuardHeld() {\n return lockfile.check(lockPath(), {\n fs: LOCKFILE_FS_ADAPTER,\n lockfilePath: `${lockPath()}.guard`,\n realpath: false,\n stale: LOCK_GUARD_STALE_MS,\n });\n}\n\nexport function isStaleLock(lock: LockFile) {\n try {\n process.kill(lock.pid, 0);\n return false;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ESRCH\") return true;\n return Date.now() - Date.parse(lock.startedAt) > LOCK_STALE_MS;\n }\n}\n\nexport async function unlock(ctx: ExtensionCommandContext, options: CommandOptions) {\n throwIfAborted(options.signal);\n await ensureStateDir();\n throwIfAborted(options.signal);\n let guard: Guard;\n try {\n guard = await acquireGuard();\n } catch (error) {\n if (!isLockHeldError(error)) throw error;\n ctx.ui.notify((await describeHeldLock()).message, \"warning\");\n return;\n }\n\n let failed = false;\n let failure: unknown;\n try {\n await unlockGuarded(ctx, options);\n } catch (error) {\n failed = true;\n failure = error;\n }\n const releaseError = await releaseGuard(guard);\n if (releaseError && !failed) {\n failed = true;\n failure = releaseError;\n }\n if (failed) throw failure;\n}\n\nasync function unlockGuarded(ctx: ExtensionCommandContext, options: CommandOptions) {\n throwIfAborted(options.signal);\n let inspection = await inspectLock();\n throwIfAborted(options.signal);\n if (inspection.status === \"missing\") {\n ctx.ui.notify(\"No pi-sync lock is present.\", \"info\");\n return;\n }\n if (inspection.status === \"unreadable\") {\n if (!options.stale) {\n ctx.ui.notify(\n \"Pi-sync lock metadata is unreadable. Use /sync unlock --stale only after verifying no sync is running.\",\n \"warning\",\n );\n return;\n }\n inspection = await inspectLock();\n throwIfAborted(options.signal);\n if (inspection.status === \"unreadable\") {\n throwIfAborted(options.signal);\n await fs.rm(lockPath(), { force: true });\n if (!options.signal?.aborted) {\n ctx.ui.notify(\n \"Removed unreadable pi-sync lock. No settings, files, sync state, or remote data were changed.\",\n \"info\",\n );\n }\n return;\n }\n if (inspection.status === \"missing\") {\n ctx.ui.notify(\"No pi-sync lock is present.\", \"info\");\n return;\n }\n }\n if (!isStaleLock(inspection.lock)) {\n ctx.ui.notify(\"Lock owner is still live; refusing to remove it.\", \"warning\");\n return;\n }\n throwIfAborted(options.signal);\n await fs.rm(lockPath(), { force: true });\n if (!options.signal?.aborted) {\n ctx.ui.notify(\"Removed stale pi-sync lock. No settings, files, sync state, or remote data were changed.\", \"info\");\n }\n}\n\nasync function releaseGuard(guard: Guard) {\n try {\n await guard.release();\n return undefined;\n } catch (error) {\n return guard.isCompromised() ? undefined : error;\n }\n}\n\nfunction guardFilesystem(assertLocation: () => void) {\n const { mkdir, rmdir, rmdirSync, stat, utimes } = LOCKFILE_FS_ADAPTER;\n function check(callback: (error: NodeJS.ErrnoException) => void) {\n try {\n assertLocation();\n return true;\n } catch (error) {\n callback(error as NodeJS.ErrnoException);\n return false;\n }\n }\n return {\n ...LOCKFILE_FS_ADAPTER,\n mkdir: (file: string, callback: (error: NodeJS.ErrnoException | null) => void) => {\n if (check(callback)) mkdir(file, callback);\n },\n rmdir: (...args: Parameters<typeof rmdir>) => {\n if (check(args[1])) rmdir(...args);\n },\n rmdirSync: (...args: Parameters<typeof rmdirSync>) => {\n assertLocation();\n return rmdirSync(...args);\n },\n stat: (file: string, callback: (error: NodeJS.ErrnoException | null, stats?: Stats) => void) => {\n if (check(callback)) stat(file, callback);\n },\n utimes: (...args: Parameters<typeof utimes>) => {\n if (check(args[3])) utimes(...args);\n },\n };\n}\n\nasync function acquireGuard(file = lockPath(), assertLocation?: () => void): Promise<Guard> {\n let compromisedError: Error | undefined;\n const release = await lockfile.lock(file, {\n fs: assertLocation ? guardFilesystem(assertLocation) : LOCKFILE_FS_ADAPTER,\n lockfilePath: `${file}.guard`,\n realpath: false,\n stale: LOCK_GUARD_STALE_MS,\n update: LOCK_GUARD_UPDATE_MS,\n onCompromised: (error) => {\n compromisedError = error;\n },\n });\n return {\n release,\n throwIfCompromised: () => {\n if (compromisedError) throw compromisedError;\n },\n isCompromised: () => compromisedError !== undefined,\n };\n}\n\nasync function describeHeldLock(file = lockPath()) {\n const inspection = await inspectLockAt(file);\n const current = inspection.status === \"valid\" ? inspection.lock : undefined;\n if (current && isStaleLock(current)) {\n return new Error(\"pi-sync lock owner exited; retry shortly while the lock guard expires.\");\n }\n if (current) {\n return Object.assign(\n new Error(`Pi-sync is currently running (${current.command}, pid ${current.pid}, started ${current.startedAt}).`),\n { code: \"ELOCKED\" },\n );\n }\n return Object.assign(\n new Error(\"Pi-sync is currently running (lock metadata is unreadable or still being written).\"),\n { code: \"ELOCKED\" },\n );\n}\n\nfunction isLockHeldError(error: unknown) {\n return (error as NodeJS.ErrnoException).code === \"ELOCKED\";\n}\n\nfunction isLockFile(value: unknown): value is LockFile {\n if (!value || typeof value !== \"object\" || Array.isArray(value)) return false;\n const lock = value as Partial<LockFile>;\n return (\n typeof lock.id === \"string\" &&\n lock.id.length > 0 &&\n Number.isInteger(lock.pid) &&\n (lock.pid ?? 0) > 0 &&\n (lock.pid ?? 0) <= MAX_PROCESS_ID &&\n typeof lock.command === \"string\" &&\n lock.command.length > 0 &&\n typeof lock.startedAt === \"string\" &&\n Number.isFinite(Date.parse(lock.startedAt))\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,WAAW,WAAW,WAAW,WAAW,UAAU,UAAU,oBAAgC;AACzG,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,cAAc;AAWrB,IAAM,gBAAgB,KAAK,KAAK;AAChC,IAAM,iBAAiB;AAUvB,IAAM,aAAa,IAAI,kBAAyE;AA2ChG,eAAsB,SACpB,SACA,IACA,UAAsC,CAAC,GAC3B;AACZ,QAAM,eAAe;AACrB,QAAM,iBAAiB,cAAc;AACrC,QAAM,OAAO,aAAa,cAAc;AACxC,QAAM,aAAa,mBAAmB,IAAI;AAC1C,QAAM,YAAY,SAAS,IAAI;AAC/B,QAAM,OAAO,KAAK,KAAK,WAAW,MAAM;AACxC,QAAM,WAAW,UAAU,SAAS;AACpC,QAAM,iBAAiB,MAAM;AAC3B,eAAW;AACX,QAAI,aAAa,cAAc,MAAM,QAAQ,SAAS,IAAI,MAAM;AAC9D,YAAM,IAAI,MAAM,2CAA2C;AAC7D,UAAM,UAAU,UAAU,SAAS;AACnC,QAAI,CAAC,QAAQ,YAAY,KAAK,QAAQ,QAAQ,SAAS,OAAO,QAAQ,QAAQ,SAAS;AACrF,YAAM,IAAI,MAAM,2CAA2C;AAAA,EAC/D;AACA,iBAAe;AACf,QAAM,OAAiB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QAAM,aAAa,MAAM,cAAc,IAAI;AAC3C,QAAM,UAAU,WAAW,WAAW,UAAU,WAAW,OAAO;AAClE,MAAI,WAAW,YAAY,OAAO,GAAG;AACnC,WAAO,IAAI,MAAM,wEAAwE;AAAA,EAC3F;AACA,MAAI,SAAS;AACX,WAAO,OAAO;AAAA,MACZ,IAAI,MAAM,iCAAiC,QAAQ,OAAO,SAAS,QAAQ,GAAG,aAAa,QAAQ,SAAS,IAAI;AAAA,MAChH,EAAE,MAAM,UAAU;AAAA,IACpB;AAAA,EACF;AACA,SAAO,OAAO;AAAA,IACZ,IAAI,MAAM,oFAAoF;AAAA,IAC9F,EAAE,MAAM,UAAU;AAAA,EACpB;AACF;AAEA,SAAS,gBAAgB,OAAgB;AACvC,SAAQ,MAAgC,SAAS;AACnD;AAEA,SAAS,WAAW,OAAmC;AACrD,MAAI,CAAC,SAAS,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,EAAG,QAAO;AACxE,QAAM,OAAO;AACb,SACE,OAAO,KAAK,OAAO,YACnB,KAAK,GAAG,SAAS,KACjB,OAAO,UAAU,KAAK,GAAG,MACxB,KAAK,OAAO,KAAK,MACjB,KAAK,OAAO,MAAM,kBACnB,OAAO,KAAK,YAAY,YACxB,KAAK,QAAQ,SAAS,KACtB,OAAO,KAAK,cAAc,YAC1B,OAAO,SAAS,KAAK,MAAM,KAAK,SAAS,CAAC;AAE9C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
normalizeGitRemoteIdentity
|
|
5
|
+
} from "./chunk-NFZMKZ2D.ts";
|
|
6
|
+
|
|
7
|
+
// src/engine/backends/webdav/webdav-config.ts
|
|
8
|
+
var DEFAULT_PATH = "pi-sync";
|
|
9
|
+
function normalizeWebDavIdentityUrl(value) {
|
|
10
|
+
try {
|
|
11
|
+
const url = new URL(value.trim());
|
|
12
|
+
url.username = "";
|
|
13
|
+
url.password = "";
|
|
14
|
+
url.search = "";
|
|
15
|
+
url.hash = "";
|
|
16
|
+
url.pathname = `${url.pathname.replace(/\/+$/u, "")}/`;
|
|
17
|
+
return url.toString();
|
|
18
|
+
} catch {
|
|
19
|
+
return value.trim();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function normalizeWebDavUrl(value) {
|
|
23
|
+
const normalized = normalizeOptionalString(value);
|
|
24
|
+
if (!normalized) return void 0;
|
|
25
|
+
let url;
|
|
26
|
+
try {
|
|
27
|
+
url = new URL(normalized);
|
|
28
|
+
} catch {
|
|
29
|
+
throw new Error("Invalid pi-sync WebDAV URL.");
|
|
30
|
+
}
|
|
31
|
+
if (url.username || url.password || url.search || url.hash) {
|
|
32
|
+
throw new Error("Invalid pi-sync WebDAV URL: credentials, query, and fragment are not allowed.");
|
|
33
|
+
}
|
|
34
|
+
const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]" || url.hostname === "::1";
|
|
35
|
+
if (url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) {
|
|
36
|
+
throw new Error("Invalid pi-sync WebDAV URL: HTTPS is required except for loopback.");
|
|
37
|
+
}
|
|
38
|
+
url.pathname = `${url.pathname.replace(/\/+$/u, "")}/`;
|
|
39
|
+
return url.toString();
|
|
40
|
+
}
|
|
41
|
+
function normalizeWebDavPath(value) {
|
|
42
|
+
if (value?.trim() === "." || value?.trim() === "./") return "./";
|
|
43
|
+
const normalized = trimSlashes(normalizeOptionalString(value) ?? DEFAULT_PATH);
|
|
44
|
+
if (!normalized || normalized.includes("\\") || hasControlCharacter(normalized) || normalized.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
|
|
45
|
+
throw new Error("Invalid pi-sync WebDAV path.");
|
|
46
|
+
}
|
|
47
|
+
return normalized;
|
|
48
|
+
}
|
|
49
|
+
function validateWebDavCredentials(username, password) {
|
|
50
|
+
if (username.includes(":") || hasControlCharacter(username) || password !== void 0 && hasControlCharacter(password)) {
|
|
51
|
+
throw new Error("Invalid pi-sync WebDAV credentials.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function normalizeOptionalString(value) {
|
|
55
|
+
const normalized = value?.trim();
|
|
56
|
+
return normalized || void 0;
|
|
57
|
+
}
|
|
58
|
+
function trimSlashes(value) {
|
|
59
|
+
return value.replace(/^\/+|\/+$/gu, "");
|
|
60
|
+
}
|
|
61
|
+
function hasControlCharacter(value) {
|
|
62
|
+
return [...value].some((character) => {
|
|
63
|
+
const code = character.codePointAt(0) ?? 0;
|
|
64
|
+
return code < 32 || code >= 127 && code <= 159;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/engine/backends/backend-identity.ts
|
|
69
|
+
function backendIdentityCoordinates(config) {
|
|
70
|
+
switch (config.backend.type) {
|
|
71
|
+
case "s3":
|
|
72
|
+
return JSON.stringify([
|
|
73
|
+
"s3",
|
|
74
|
+
normalizeEndpointIdentity(config.backend.profile.endpoint),
|
|
75
|
+
config.backend.destination.bucket,
|
|
76
|
+
config.storagePath
|
|
77
|
+
]);
|
|
78
|
+
case "git":
|
|
79
|
+
return JSON.stringify([
|
|
80
|
+
"git",
|
|
81
|
+
normalizeGitRemoteIdentity(config.backend.profile.remote),
|
|
82
|
+
config.backend.destination.branch,
|
|
83
|
+
config.storagePath
|
|
84
|
+
]);
|
|
85
|
+
case "webdav":
|
|
86
|
+
return JSON.stringify([
|
|
87
|
+
"webdav",
|
|
88
|
+
normalizeWebDavIdentityUrl(config.backend.profile.url),
|
|
89
|
+
config.backend.profile.username,
|
|
90
|
+
config.storagePath
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function normalizeEndpointIdentity(endpoint) {
|
|
95
|
+
try {
|
|
96
|
+
const url = new URL(endpoint.trim());
|
|
97
|
+
url.hostname = url.hostname.toLowerCase();
|
|
98
|
+
url.pathname = url.pathname.replace(/\/+$/gu, "");
|
|
99
|
+
return url.toString().replace(/\/$/u, "");
|
|
100
|
+
} catch {
|
|
101
|
+
return endpoint.trim();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
normalizeWebDavIdentityUrl,
|
|
107
|
+
normalizeWebDavUrl,
|
|
108
|
+
normalizeWebDavPath,
|
|
109
|
+
validateWebDavCredentials,
|
|
110
|
+
backendIdentityCoordinates,
|
|
111
|
+
normalizeEndpointIdentity
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=chunk-TAOYC2YG.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/engine/backends/webdav/webdav-config.ts", "../../src/engine/backends/backend-identity.ts"],
|
|
4
|
+
"sourcesContent": ["const DEFAULT_PATH = \"pi-sync\";\n\nexport function normalizeWebDavIdentityUrl(value: string) {\n try {\n const url = new URL(value.trim());\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n url.pathname = `${url.pathname.replace(/\\/+$/u, \"\")}/`;\n return url.toString();\n } catch {\n return value.trim();\n }\n}\n\nexport function normalizeWebDavUrl(value: string | undefined) {\n const normalized = normalizeOptionalString(value);\n if (!normalized) return undefined;\n let url: URL;\n try {\n url = new URL(normalized);\n } catch {\n throw new Error(\"Invalid pi-sync WebDAV URL.\");\n }\n if (url.username || url.password || url.search || url.hash) {\n throw new Error(\"Invalid pi-sync WebDAV URL: credentials, query, and fragment are not allowed.\");\n }\n const loopback =\n url.hostname === \"127.0.0.1\" || url.hostname === \"localhost\" || url.hostname === \"[::1]\" || url.hostname === \"::1\";\n if (url.protocol !== \"https:\" && !(url.protocol === \"http:\" && loopback)) {\n throw new Error(\"Invalid pi-sync WebDAV URL: HTTPS is required except for loopback.\");\n }\n url.pathname = `${url.pathname.replace(/\\/+$/u, \"\")}/`;\n return url.toString();\n}\n\nexport function normalizeWebDavPath(value: string | undefined) {\n if (value?.trim() === \".\" || value?.trim() === \"./\") return \"./\";\n const normalized = trimSlashes(normalizeOptionalString(value) ?? DEFAULT_PATH);\n if (\n !normalized ||\n normalized.includes(\"\\\\\") ||\n hasControlCharacter(normalized) ||\n normalized.split(\"/\").some((segment) => !segment || segment === \".\" || segment === \"..\")\n ) {\n throw new Error(\"Invalid pi-sync WebDAV path.\");\n }\n return normalized;\n}\n\nexport function validateWebDavNamespace(value: string) {\n if (value === \".\" || value === \"..\" || value.includes(\"/\") || value.includes(\"\\\\\") || hasControlCharacter(value)) {\n throw new Error(\"Invalid pi-sync WebDAV namespace.\");\n }\n}\n\nexport function validateWebDavCredentials(username: string, password?: string) {\n if (\n username.includes(\":\") ||\n hasControlCharacter(username) ||\n (password !== undefined && hasControlCharacter(password))\n ) {\n throw new Error(\"Invalid pi-sync WebDAV credentials.\");\n }\n}\n\nfunction normalizeOptionalString(value: string | undefined) {\n const normalized = value?.trim();\n return normalized || undefined;\n}\n\nfunction trimSlashes(value: string) {\n return value.replace(/^\\/+|\\/+$/gu, \"\");\n}\n\nfunction hasControlCharacter(value: string) {\n return [...value].some((character) => {\n const code = character.codePointAt(0) ?? 0;\n return code < 0x20 || (code >= 0x7f && code <= 0x9f);\n });\n}\n", "import type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { normalizeGitRemoteIdentity } from \"./git/git-config.js\";\nimport { normalizeWebDavIdentityUrl } from \"./webdav/webdav-config.js\";\n\nexport function backendIdentityCoordinates(config: AnySyncConfig) {\n switch (config.backend.type) {\n case \"s3\":\n return JSON.stringify([\n \"s3\",\n normalizeEndpointIdentity(config.backend.profile.endpoint),\n config.backend.destination.bucket,\n config.storagePath,\n ]);\n case \"git\":\n return JSON.stringify([\n \"git\",\n normalizeGitRemoteIdentity(config.backend.profile.remote),\n config.backend.destination.branch,\n config.storagePath,\n ]);\n case \"webdav\":\n return JSON.stringify([\n \"webdav\",\n normalizeWebDavIdentityUrl(config.backend.profile.url),\n config.backend.profile.username,\n config.storagePath,\n ]);\n }\n}\n\nexport function normalizeEndpointIdentity(endpoint: string) {\n try {\n const url = new URL(endpoint.trim());\n url.hostname = url.hostname.toLowerCase();\n url.pathname = url.pathname.replace(/\\/+$/gu, \"\");\n return url.toString().replace(/\\/$/u, \"\");\n } catch {\n return endpoint.trim();\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAAA,IAAM,eAAe;AAEd,SAAS,2BAA2B,OAAe;AACxD,MAAI;AACF,UAAM,MAAM,IAAI,IAAI,MAAM,KAAK,CAAC;AAChC,QAAI,WAAW;AACf,QAAI,WAAW;AACf,QAAI,SAAS;AACb,QAAI,OAAO;AACX,QAAI,WAAW,GAAG,IAAI,SAAS,QAAQ,SAAS,EAAE,CAAC;AACnD,WAAO,IAAI,SAAS;AAAA,EACtB,QAAQ;AACN,WAAO,MAAM,KAAK;AAAA,EACpB;AACF;AAEO,SAAS,mBAAmB,OAA2B;AAC5D,QAAM,aAAa,wBAAwB,KAAK;AAChD,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI;AACJ,MAAI;AACF,UAAM,IAAI,IAAI,UAAU;AAAA,EAC1B,QAAQ;AACN,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AACA,MAAI,IAAI,YAAY,IAAI,YAAY,IAAI,UAAU,IAAI,MAAM;AAC1D,UAAM,IAAI,MAAM,+EAA+E;AAAA,EACjG;AACA,QAAM,WACJ,IAAI,aAAa,eAAe,IAAI,aAAa,eAAe,IAAI,aAAa,WAAW,IAAI,aAAa;AAC/G,MAAI,IAAI,aAAa,YAAY,EAAE,IAAI,aAAa,WAAW,WAAW;AACxE,UAAM,IAAI,MAAM,oEAAoE;AAAA,EACtF;AACA,MAAI,WAAW,GAAG,IAAI,SAAS,QAAQ,SAAS,EAAE,CAAC;AACnD,SAAO,IAAI,SAAS;AACtB;AAEO,SAAS,oBAAoB,OAA2B;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