@narumitw/pi-sync 0.61.0 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/README.md +46 -25
- package/dist/chunks/{chunk-277VHM2P.ts → chunk-27F5W7DX.ts} +7 -3
- package/dist/chunks/chunk-27F5W7DX.ts.map +7 -0
- package/dist/chunks/{chunk-ZIL6PW5L.ts → chunk-6YKOHBSC.ts} +2 -2
- package/dist/chunks/{chunk-OA4NZLSL.ts → chunk-APZVJAEW.ts} +4 -3
- package/dist/chunks/chunk-CKUGCBHP.ts +114 -0
- package/dist/chunks/chunk-CKUGCBHP.ts.map +7 -0
- package/dist/chunks/chunk-EJDDRS6O.ts +17 -0
- package/dist/chunks/chunk-EJDDRS6O.ts.map +7 -0
- package/dist/chunks/{chunk-JVFCVPPD.ts → chunk-EXDWEFIJ.ts} +87 -147
- package/dist/chunks/chunk-EXDWEFIJ.ts.map +7 -0
- package/dist/chunks/{chunk-4SR3ZYHA.ts → chunk-GELYN4UC.ts} +2 -2
- package/dist/chunks/{chunk-2ZGV5KNC.ts → chunk-HSCAFOT5.ts} +15 -12
- package/dist/chunks/chunk-HSCAFOT5.ts.map +7 -0
- package/dist/chunks/{chunk-YQSFJLJ3.ts → chunk-IBXEM35O.ts} +4 -3
- package/dist/chunks/{chunk-2JHAN3ZO.ts → chunk-JREGWM2B.ts} +3 -3
- package/dist/chunks/chunk-MANNB4WZ.ts +36 -0
- package/dist/chunks/chunk-MANNB4WZ.ts.map +7 -0
- package/dist/chunks/{chunk-EMRFVLZM.ts → chunk-NXWHPVXR.ts} +2 -2
- package/dist/chunks/{chunk-SMVKMYLK.ts → chunk-P4GI7LTT.ts} +2 -2
- package/dist/chunks/{chunk-ZVGRZD4C.ts → chunk-R3SAMXB6.ts} +2 -2
- package/dist/chunks/{chunk-4KTJLJSJ.ts → chunk-S6FUUWV5.ts} +148 -21
- package/dist/chunks/chunk-S6FUUWV5.ts.map +7 -0
- package/dist/chunks/{chunk-PJMM75W5.ts → chunk-SXCH4Q5O.ts} +41 -23
- package/dist/chunks/chunk-SXCH4Q5O.ts.map +7 -0
- package/dist/chunks/{chunk-RNIEVDTR.ts → chunk-T3LABNHF.ts} +2 -2
- package/dist/chunks/{chunk-E3YLRLJM.ts → chunk-UGS6RYDZ.ts} +14 -12
- package/dist/chunks/chunk-UGS6RYDZ.ts.map +7 -0
- package/dist/chunks/{chunk-S3R3W3KF.ts → chunk-UMPA5S7X.ts} +2 -2
- package/dist/chunks/{chunk-EMVZL4PH.ts → chunk-V76KCWHO.ts} +7 -5
- package/dist/chunks/{chunk-EMVZL4PH.ts.map → chunk-V76KCWHO.ts.map} +1 -1
- package/dist/chunks/{chunk-S7F4FOAS.ts → chunk-VQ47JBLF.ts} +5 -5
- package/dist/chunks/{chunk-WP2M67XZ.ts → chunk-WBIOSK76.ts} +2 -2
- package/dist/chunks/chunk-WFBHWYI6.ts +18 -0
- package/dist/chunks/chunk-WFBHWYI6.ts.map +7 -0
- package/dist/chunks/{chunk-HEB6YT64.ts → chunk-ZO52JM4H.ts} +2 -2
- package/dist/chunks/{command-handler-K4XJOGYC.ts → command-handler-VINMQ7ZM.ts} +26 -43
- package/dist/chunks/command-handler-VINMQ7ZM.ts.map +7 -0
- package/dist/chunks/{conflict-review-IGKY2TOJ.ts → conflict-review-PCDFRIVB.ts} +4 -4
- package/dist/chunks/{continuous-record-3XDXDOMV.ts → continuous-record-3SKJ6I3V.ts} +2 -2
- package/dist/chunks/{continuous-storage-HLKCHF6Z.ts → continuous-storage-3EU6I7Z3.ts} +2 -2
- package/dist/chunks/{file-selection-MGGVOKM7.ts → file-selection-KID23GAD.ts} +21 -14
- package/dist/chunks/file-selection-KID23GAD.ts.map +7 -0
- package/dist/chunks/manager-result-dispatcher-GDB74IOP.ts +20 -0
- package/dist/chunks/{manager-ui-KYQ5AZJS.ts → manager-ui-YHDECYKI.ts} +454 -167
- package/dist/chunks/manager-ui-YHDECYKI.ts.map +7 -0
- package/dist/chunks/remote-selection-ui-GPITNEBF.ts +19 -0
- package/dist/chunks/{setup-switch-D6K6PBPC.ts → setup-switch-L54X5U5I.ts} +7 -7
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts → setup-wizard-YO4MCPUF.ts} +15 -11
- package/dist/chunks/{setup-wizard-4DYUDHJR.ts.map → setup-wizard-YO4MCPUF.ts.map} +1 -1
- package/dist/chunks/{snapshot-5HY3M2NL.ts → snapshot-ZUJJZCFW.ts} +2 -2
- package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts → snapshot-transaction-directory-F46JWRAU.ts} +2 -2
- package/dist/chunks/{state-directory-XXHU73Z3.ts → state-directory-CMAIF34J.ts} +2 -2
- package/dist/chunks/{sync-inspection-J3CRBORL.ts → sync-inspection-H2WX5SUT.ts} +5 -5
- package/dist/chunks/{sync-operations-BVWYYKH3.ts → sync-operations-2MZAYHL2.ts} +13 -9
- package/dist/chunks/sync-operations-2MZAYHL2.ts.map +7 -0
- package/dist/chunks/{sync-state-2LMIXJ2C.ts → sync-state-QIT64TKV.ts} +2 -2
- package/dist/daemon/LICENSE +21 -0
- package/dist/daemon/dist/build-version.js +8 -0
- package/dist/daemon/dist/child-sdk.mjs +17 -0
- package/dist/daemon/dist/cli.js +169 -0
- package/dist/daemon/dist/client.js +909 -0
- package/dist/daemon/dist/consent.js +383 -0
- package/dist/daemon/dist/document.js +6 -0
- package/dist/daemon/dist/endpoint.js +91 -0
- package/dist/daemon/dist/engine/backends/backend-factory.js +16 -0
- package/dist/daemon/dist/engine/backends/backend-identity.js +38 -0
- package/dist/daemon/dist/engine/backends/backend-types.js +1 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +746 -0
- package/dist/daemon/dist/engine/backends/git/git-config.js +118 -0
- package/dist/daemon/dist/engine/backends/git/git-runner.js +232 -0
- package/dist/daemon/dist/engine/backends/git/git-storage.js +252 -0
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +444 -0
- package/dist/daemon/dist/engine/backends/s3/s3-client.js +352 -0
- package/dist/daemon/dist/engine/backends/s3/s3-conditions.js +66 -0
- package/dist/daemon/dist/engine/backends/snapshot-pointer.js +22 -0
- package/dist/daemon/dist/engine/backends/sync-backend.js +23 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +542 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-client.js +326 -0
- package/dist/daemon/dist/engine/backends/webdav/webdav-config.js +73 -0
- package/dist/daemon/dist/engine/commands/command-types.js +1 -0
- package/dist/daemon/dist/engine/host.js +16 -0
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +33 -0
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +102 -0
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +252 -0
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +139 -0
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +393 -0
- package/dist/daemon/dist/engine/ignore/ignore-source.js +250 -0
- package/dist/daemon/dist/engine/paths.js +71 -0
- package/dist/daemon/dist/engine/settings/config-errors.js +4 -0
- package/dist/daemon/dist/engine/settings/config-file.js +736 -0
- package/dist/daemon/dist/engine/settings/config.js +344 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +199 -0
- package/dist/daemon/dist/engine/settings/settings-store.js +41 -0
- package/dist/daemon/dist/engine/settings/settings-types.js +1 -0
- package/dist/daemon/dist/engine/settings/settings-validation.js +384 -0
- package/dist/daemon/dist/engine/snapshot/session-paths.js +165 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +348 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-bounds.js +20 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +61 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-entry-projection.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +262 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-paths.js +11 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-payload.js +10 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-reviewed-preimages.js +60 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-root-transition.js +138 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +387 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +296 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-stage.js +303 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-verification.js +78 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +855 -0
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +9 -0
- package/dist/daemon/dist/engine/snapshot/snapshot.js +678 -0
- package/dist/daemon/dist/engine/state/json-file.js +49 -0
- package/dist/daemon/dist/engine/state/lock-policy.js +2 -0
- package/dist/daemon/dist/engine/state/lock.js +259 -0
- package/dist/daemon/dist/engine/state/lockfile-fs.js +13 -0
- package/dist/daemon/dist/engine/state/merge-baseline-store.js +198 -0
- package/dist/daemon/dist/engine/state/mutation-directory-sync.js +34 -0
- package/dist/daemon/dist/engine/state/operation-availability.js +40 -0
- package/dist/daemon/dist/engine/state/state-directory.js +227 -0
- package/dist/daemon/dist/engine/state/state-types.js +1 -0
- package/dist/daemon/dist/engine/state/sync-state-store.js +54 -0
- package/dist/daemon/dist/engine/sync/agent-candidate.js +207 -0
- package/dist/daemon/dist/engine/sync/agent-plan.js +85 -0
- package/dist/daemon/dist/engine/sync/agent-policy.js +10 -0
- package/dist/daemon/dist/engine/sync/agent-refusal-retry.js +39 -0
- package/dist/daemon/dist/engine/sync/agent-request.js +13 -0
- package/dist/daemon/dist/engine/sync/agent-runner.js +183 -0
- package/dist/daemon/dist/engine/sync/agent-store.js +177 -0
- package/dist/daemon/dist/engine/sync/agent-sync.js +139 -0
- package/dist/daemon/dist/engine/sync/apply-review.js +52 -0
- package/dist/daemon/dist/engine/sync/conflict-artifact-ownership.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-artifacts.js +158 -0
- package/dist/daemon/dist/engine/sync/conflict-groups.js +76 -0
- package/dist/daemon/dist/engine/sync/conflict-preview.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-resolution.js +53 -0
- package/dist/daemon/dist/engine/sync/conflict-retention.js +61 -0
- package/dist/daemon/dist/engine/sync/conflict-review.js +73 -0
- package/dist/daemon/dist/engine/sync/content-conflicts.js +70 -0
- package/dist/daemon/dist/engine/sync/continuous-errors.js +66 -0
- package/dist/daemon/dist/engine/sync/continuous-lease.js +206 -0
- package/dist/daemon/dist/engine/sync/continuous-record.js +199 -0
- package/dist/daemon/dist/engine/sync/continuous-storage.js +59 -0
- package/dist/daemon/dist/engine/sync/continuous-sync.js +538 -0
- package/dist/daemon/dist/engine/sync/continuous-watch.js +140 -0
- package/dist/daemon/dist/engine/sync/exclude-policy.js +86 -0
- package/dist/daemon/dist/engine/sync/field-migration.js +20 -0
- package/dist/daemon/dist/engine/sync/file-merge-planner.js +123 -0
- package/dist/daemon/dist/engine/sync/initialization.js +80 -0
- package/dist/daemon/dist/engine/sync/json-document.js +172 -0
- package/dist/daemon/dist/engine/sync/local-field-policy.js +26 -0
- package/dist/daemon/dist/engine/sync/local-fields.js +196 -0
- package/dist/daemon/dist/engine/sync/merge-acceptance.js +29 -0
- package/dist/daemon/dist/engine/sync/merge-apply.js +532 -0
- package/dist/daemon/dist/engine/sync/merge-journal.js +314 -0
- package/dist/daemon/dist/engine/sync/merge-transfer-error.js +64 -0
- package/dist/daemon/dist/engine/sync/merged-sync.js +666 -0
- package/dist/daemon/dist/engine/sync/mutation-owner.js +18 -0
- package/dist/daemon/dist/engine/sync/package-merge.js +82 -0
- package/dist/daemon/dist/engine/sync/partial-progress.js +41 -0
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +119 -0
- package/dist/daemon/dist/engine/sync/resolver-stream.js +34 -0
- package/dist/daemon/dist/engine/sync/session-merge.js +178 -0
- package/dist/daemon/dist/engine/sync/session-push.js +47 -0
- package/dist/daemon/dist/engine/sync/settings-conflicts.js +56 -0
- package/dist/daemon/dist/engine/sync/settings-merge.js +93 -0
- package/dist/daemon/dist/engine/sync/signals.js +8 -0
- package/dist/daemon/dist/engine/sync/startup-timings.js +44 -0
- package/dist/daemon/dist/engine/sync/sync-decision.js +81 -0
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +55 -0
- package/dist/daemon/dist/engine/sync/sync-errors.js +18 -0
- package/dist/daemon/dist/engine/sync/sync-inspection.js +42 -0
- package/dist/daemon/dist/engine/sync/sync-loaders.js +8 -0
- package/dist/daemon/dist/engine/sync/sync-local.js +40 -0
- package/dist/daemon/dist/engine/sync/sync-mutations.js +754 -0
- package/dist/daemon/dist/engine/sync/sync-operations.js +3 -0
- package/dist/daemon/dist/engine/sync/sync-policy.js +646 -0
- package/dist/daemon/dist/engine/sync/sync-queries.js +212 -0
- package/dist/daemon/dist/engine/sync/sync-state.js +124 -0
- package/dist/daemon/dist/engine/sync/text-merge.js +124 -0
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +82 -0
- package/dist/daemon/dist/engine/types.js +2 -0
- package/dist/daemon/dist/engine/ui/merge-review.js +7 -0
- package/dist/daemon/dist/engine/ui/merged-sync-summary.js +86 -0
- package/dist/daemon/dist/engine/ui/sync-format.js +165 -0
- package/dist/daemon/dist/engine/ui/sync-status.js +30 -0
- package/dist/daemon/dist/engine/ui/terminal-text.js +9 -0
- package/dist/daemon/dist/engine/ui/transfer-changes.js +24 -0
- package/dist/daemon/dist/engine/ui/transfer-review.js +19 -0
- package/dist/daemon/dist/engine-service.js +441 -0
- package/dist/daemon/dist/identity.js +241 -0
- package/dist/daemon/dist/idle-exit.js +77 -0
- package/dist/daemon/dist/index.js +4 -0
- package/dist/daemon/dist/lifecycle-log.js +53 -0
- package/dist/daemon/dist/lifecycle.js +21 -0
- package/dist/daemon/dist/model-signature.js +7 -0
- package/dist/daemon/dist/monitor.js +324 -0
- package/dist/daemon/dist/participant-admission.js +30 -0
- package/dist/daemon/dist/protocol.js +104 -0
- package/dist/daemon/dist/resolver-host.js +78 -0
- package/dist/daemon/dist/server.js +994 -0
- package/dist/daemon/dist/service-host.js +175 -0
- package/dist/daemon/dist/upgrade-repair.js +55 -0
- package/dist/daemon/package.json +3 -0
- package/dist/index.ts +40 -37
- package/dist/index.ts.map +4 -4
- package/dist/package.json +6 -0
- package/docs/daemon-migration.md +27 -16
- package/package.json +9 -3
- package/skills/configure-pi-sync/SKILL.md +24 -46
- package/skills/configure-pi-sync/references/configuration.md +62 -22
- package/src/commands/command-execution.ts +13 -9
- package/src/commands/command-types.ts +1 -0
- package/src/daemon/pi-client.ts +4 -2
- package/src/settings/config.ts +2 -0
- package/src/sync/automatic-sync.ts +9 -2
- package/src/sync/setup-switch.ts +38 -15
- package/src/sync/startup-check.ts +7 -4
- package/src/sync/sync-operations.ts +18 -10
- package/src/ui/excluded-paths-ui.ts +6 -3
- package/src/ui/file-selection.ts +7 -2
- package/src/ui/ignore-file-guidance.ts +7 -0
- package/src/ui/ignore-file-ui.ts +97 -0
- package/src/ui/ignore-migration-prompt.ts +65 -0
- package/src/ui/manager-state.ts +40 -14
- package/src/ui/manager-ui.ts +41 -19
- package/src/ui/remote-selection-ui.ts +88 -28
- package/src/ui/settings-review.ts +26 -0
- package/src/ui/settings-ui.ts +378 -224
- package/src/ui/setup/setup-actions.ts +16 -4
- package/src/ui/setup/setup-prompts.ts +55 -9
- package/src/ui/setup/setup-switcher.ts +24 -11
- package/src/ui/storage-connections-ui.ts +50 -20
- package/src/ui/sync-setups-ui.ts +65 -30
- package/dist/chunks/chunk-277VHM2P.ts.map +0 -7
- package/dist/chunks/chunk-2ZGV5KNC.ts.map +0 -7
- package/dist/chunks/chunk-4KTJLJSJ.ts.map +0 -7
- package/dist/chunks/chunk-E3YLRLJM.ts.map +0 -7
- package/dist/chunks/chunk-ECYCNZOE.ts +0 -12
- package/dist/chunks/chunk-ECYCNZOE.ts.map +0 -7
- package/dist/chunks/chunk-JVFCVPPD.ts.map +0 -7
- package/dist/chunks/chunk-PJMM75W5.ts.map +0 -7
- package/dist/chunks/command-handler-K4XJOGYC.ts.map +0 -7
- package/dist/chunks/file-selection-MGGVOKM7.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-4VJVDEUD.ts +0 -19
- package/dist/chunks/manager-ui-KYQ5AZJS.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-W3KOZM3W.ts +0 -18
- package/dist/chunks/sync-operations-BVWYYKH3.ts.map +0 -7
- /package/dist/chunks/{chunk-ZIL6PW5L.ts.map → chunk-6YKOHBSC.ts.map} +0 -0
- /package/dist/chunks/{chunk-OA4NZLSL.ts.map → chunk-APZVJAEW.ts.map} +0 -0
- /package/dist/chunks/{chunk-4SR3ZYHA.ts.map → chunk-GELYN4UC.ts.map} +0 -0
- /package/dist/chunks/{chunk-YQSFJLJ3.ts.map → chunk-IBXEM35O.ts.map} +0 -0
- /package/dist/chunks/{chunk-2JHAN3ZO.ts.map → chunk-JREGWM2B.ts.map} +0 -0
- /package/dist/chunks/{chunk-EMRFVLZM.ts.map → chunk-NXWHPVXR.ts.map} +0 -0
- /package/dist/chunks/{chunk-SMVKMYLK.ts.map → chunk-P4GI7LTT.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZVGRZD4C.ts.map → chunk-R3SAMXB6.ts.map} +0 -0
- /package/dist/chunks/{chunk-RNIEVDTR.ts.map → chunk-T3LABNHF.ts.map} +0 -0
- /package/dist/chunks/{chunk-S3R3W3KF.ts.map → chunk-UMPA5S7X.ts.map} +0 -0
- /package/dist/chunks/{chunk-S7F4FOAS.ts.map → chunk-VQ47JBLF.ts.map} +0 -0
- /package/dist/chunks/{chunk-WP2M67XZ.ts.map → chunk-WBIOSK76.ts.map} +0 -0
- /package/dist/chunks/{chunk-HEB6YT64.ts.map → chunk-ZO52JM4H.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-IGKY2TOJ.ts.map → conflict-review-PCDFRIVB.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-3XDXDOMV.ts.map → continuous-record-3SKJ6I3V.ts.map} +0 -0
- /package/dist/chunks/{continuous-storage-HLKCHF6Z.ts.map → continuous-storage-3EU6I7Z3.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-4VJVDEUD.ts.map → manager-result-dispatcher-GDB74IOP.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-W3KOZM3W.ts.map → remote-selection-ui-GPITNEBF.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-D6K6PBPC.ts.map → setup-switch-L54X5U5I.ts.map} +0 -0
- /package/dist/chunks/{snapshot-5HY3M2NL.ts.map → snapshot-ZUJJZCFW.ts.map} +0 -0
- /package/dist/chunks/{snapshot-transaction-directory-OU2D7R7A.ts.map → snapshot-transaction-directory-F46JWRAU.ts.map} +0 -0
- /package/dist/chunks/{state-directory-XXHU73Z3.ts.map → state-directory-CMAIF34J.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-J3CRBORL.ts.map → sync-inspection-H2WX5SUT.ts.map} +0 -0
- /package/dist/chunks/{sync-state-2LMIXJ2C.ts.map → sync-state-QIT64TKV.ts.map} +0 -0
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ui/setup/setup-name-ui.ts", "../../src/ui/setup/setup-wizard.ts"],
|
|
4
4
|
"sourcesContent": ["import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { validateConfigName } from \"../../settings/settings-validation.js\";\nimport { throwIfAborted } from \"../../sync/signals.js\";\nimport { errorMessage } from \"../../sync/sync-errors.js\";\nimport { safeTerminalText } from \"../terminal-text.js\";\n\nexport async function promptInitialSetupName(ctx: ExtensionCommandContext, signal?: AbortSignal) {\n while (!signal?.aborted) {\n const hint = \"For example: home or work. Leave blank for default.\";\n // Pi styles the whole input title as accent; give only the guidance a muted role.\n const guidance = ctx.mode === \"tui\" ? ctx.ui.theme.fg(\"muted\", hint) : hint;\n // This compact prompt owns its default hint; the general helper would repeat it.\n const value = await ctx.ui.input(`Sync setup name\\n${guidance}`, undefined, { signal });\n throwIfAborted(signal);\n if (value === undefined) return undefined;\n const name = value.trim() || \"default\";\n try {\n if (name.includes(\"<\") || name.includes(\">\")) {\n throw new Error(\"Replace example placeholders with your own name.\");\n }\n validateConfigName(name, \"sync setup\");\n return name;\n } catch (error) {\n ctx.ui.notify(\n `This name cannot be used for the sync setup. ${safeTerminalText(errorMessage(error))} Enter another name (for example, default).`,\n \"warning\",\n );\n }\n }\n return undefined;\n}\n", "import type { ExtensionCommandContext } from \"@earendil-works/pi-coding-agent\";\nimport { refreshTargetCompletions } from \"../../commands/setup-completions.js\";\nimport { localConfigPath } from \"../../settings/config-file.js\";\nimport { safeTerminalText } from \"../terminal-text.js\";\nimport { showGitSetup } from \"./git-ui.js\";\nimport { showS3Setup } from \"./s3-ui.js\";\nimport { promptInitialSetupName } from \"./setup-name-ui.js\";\nimport { showWebDavSetup } from \"./webdav-ui.js\";\n\nexport async function showSetupWizard(ctx: ExtensionCommandContext, signal?: AbortSignal) {\n if (ctx.mode !== \"tui\") {\n if (ctx.hasUI)\n ctx.ui.notify(\n `Guided sync setup requires TUI mode for masked credential input. Create settings in ${safeTerminalText(localConfigPath())} (version 7 for agent-directory scope).`,\n \"warning\",\n );\n return false;\n }\n const preset = await ctx.ui.select(\n \"Set up sync\\n\\nWhere will Pi settings be stored?\",\n [\"Cloudflare R2\", \"Other S3-compatible storage\", \"WebDAV\", \"Git\", \"Cancel\"],\n { signal },\n );\n if (signal?.aborted || !preset || preset === \"Cancel\") return false;\n const targetName = await promptInitialSetupName(ctx, signal);\n if (!targetName) return false;\n if (preset === \"WebDAV\") {\n const saved = await showWebDavSetup(ctx, targetName, signal);\n if (signal?.aborted) return false;\n if (saved) await refreshTargetCompletions();\n return saved;\n }\n if (preset === \"Git\") {\n const saved = await showGitSetup(ctx, targetName, signal);\n if (signal?.aborted) return false;\n if (saved) await refreshTargetCompletions();\n return saved;\n }\n return showS3Setup(ctx, preset, targetName, signal);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,eAAsB,uBAAuB,KAA8B,QAAsB;AAC/F,SAAO,CAAC,QAAQ,SAAS;AACvB,UAAM,OAAO;AAEb,UAAM,WAAW,IAAI,SAAS,QAAQ,IAAI,GAAG,MAAM,GAAG,SAAS,IAAI,IAAI;AAEvE,UAAM,QAAQ,MAAM,IAAI,GAAG,MAAM;AAAA,EAAoB,QAAQ,IAAI,QAAW,EAAE,OAAO,CAAC;AACtF,mBAAe,MAAM;AACrB,QAAI,UAAU,OAAW,QAAO;AAChC,UAAM,OAAO,MAAM,KAAK,KAAK;AAC7B,QAAI;AACF,UAAI,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,GAAG,GAAG;AAC5C,cAAM,IAAI,MAAM,kDAAkD;AAAA,MACpE;AACA,yBAAmB,MAAM,YAAY;AACrC,aAAO;AAAA,IACT,SAAS,OAAO;AACd,UAAI,GAAG;AAAA,QACL,gDAAgD,iBAAiB,aAAa,KAAK,CAAC,CAAC;AAAA,QACrF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;ACrBA,eAAsB,gBAAgB,KAA8B,QAAsB;AACxF,MAAI,IAAI,SAAS,OAAO;AACtB,QAAI,IAAI;AACN,UAAI,GAAG;AAAA,QACL,uFAAuF,iBAAiB,gBAAgB,CAAC,CAAC;AAAA,QAC1H;AAAA,MACF;AACF,WAAO;AAAA,EACT;AACA,QAAM,SAAS,MAAM,IAAI,GAAG;AAAA,IAC1B;AAAA,IACA,CAAC,iBAAiB,+BAA+B,UAAU,OAAO,QAAQ;AAAA,IAC1E,EAAE,OAAO;AAAA,EACX;AACA,MAAI,QAAQ,WAAW,CAAC,UAAU,WAAW,SAAU,QAAO;AAC9D,QAAM,aAAa,MAAM,uBAAuB,KAAK,MAAM;AAC3D,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,UAAU;AACvB,UAAM,QAAQ,MAAM,gBAAgB,KAAK,YAAY,MAAM;AAC3D,QAAI,QAAQ,QAAS,QAAO;AAC5B,QAAI,MAAO,OAAM,yBAAyB;AAC1C,WAAO;AAAA,EACT;AACA,MAAI,WAAW,OAAO;AACpB,UAAM,QAAQ,MAAM,aAAa,KAAK,YAAY,MAAM;AACxD,QAAI,QAAQ,QAAS,QAAO;AAC5B,QAAI,MAAO,OAAM,yBAAyB;AAC1C,WAAO;AAAA,EACT;AACA,SAAO,YAAY,KAAK,QAAQ,YAAY,MAAM;AACpD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
snapshotIncludesSessions,
|
|
21
21
|
snapshotTarget,
|
|
22
22
|
snapshotWithoutSessions
|
|
23
|
-
} from "
|
|
23
|
+
} from "#pi-sync-daemon/engine/snapshot/snapshot";
|
|
24
24
|
export {
|
|
25
25
|
canonicalSnapshotPathForConfig,
|
|
26
26
|
collectFiles,
|
|
@@ -40,4 +40,4 @@ export {
|
|
|
40
40
|
snapshotTarget,
|
|
41
41
|
snapshotWithoutSessions
|
|
42
42
|
};
|
|
43
|
-
//# sourceMappingURL=snapshot-
|
|
43
|
+
//# sourceMappingURL=snapshot-ZUJJZCFW.ts.map
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import {
|
|
6
6
|
pendingTransactionEntries,
|
|
7
7
|
transactionRoot
|
|
8
|
-
} from "
|
|
8
|
+
} from "#pi-sync-daemon/engine/snapshot/snapshot-transaction-directory";
|
|
9
9
|
export {
|
|
10
10
|
pendingTransactionEntries,
|
|
11
11
|
transactionRoot
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=snapshot-transaction-directory-
|
|
13
|
+
//# sourceMappingURL=snapshot-transaction-directory-F46JWRAU.ts.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
stateDir,
|
|
7
7
|
stateDirectoryMigrationNotice,
|
|
8
8
|
withStateDirectoryAccess
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-T3LABNHF.ts";
|
|
10
10
|
export {
|
|
11
11
|
legacyStateDir,
|
|
12
12
|
migrateLegacyStateDirectory,
|
|
@@ -14,4 +14,4 @@ export {
|
|
|
14
14
|
stateDirectoryMigrationNotice,
|
|
15
15
|
withStateDirectoryAccess
|
|
16
16
|
};
|
|
17
|
-
//# sourceMappingURL=state-directory-
|
|
17
|
+
//# sourceMappingURL=state-directory-CMAIF34J.ts.map
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
currentPiDaemonClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UGS6RYDZ.ts";
|
|
6
6
|
import {
|
|
7
7
|
syncCheckConfigFingerprint
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-27F5W7DX.ts";
|
|
9
9
|
import "./chunk-H7VOTY5N.ts";
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-6YKOHBSC.ts";
|
|
11
|
+
import "./chunk-R3SAMXB6.ts";
|
|
12
12
|
import "./chunk-2JNFEZ3V.ts";
|
|
13
13
|
|
|
14
14
|
// src/sync/sync-inspection.ts
|
|
@@ -20,4 +20,4 @@ var inspectSync = async (config, _options, signal) => await currentPiDaemonClien
|
|
|
20
20
|
export {
|
|
21
21
|
inspectSync
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=sync-inspection-
|
|
23
|
+
//# sourceMappingURL=sync-inspection-H2WX5SUT.ts.map
|
|
@@ -2,21 +2,25 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
remoteOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UGS6RYDZ.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-6YKOHBSC.ts";
|
|
8
|
+
import "./chunk-R3SAMXB6.ts";
|
|
9
9
|
import "./chunk-2JNFEZ3V.ts";
|
|
10
10
|
|
|
11
11
|
// src/sync/sync-operations.ts
|
|
12
|
-
|
|
13
|
-
const result = await remoteOperation(ctx, operation, options);
|
|
12
|
+
function transferResult(result) {
|
|
14
13
|
if (result === void 0 || result === "applied" || result === "cancelled") return result;
|
|
15
14
|
throw new Error("Invalid transfer result from pi-sync-daemon.");
|
|
16
15
|
}
|
|
17
|
-
var push = (ctx, options) =>
|
|
18
|
-
var pull = (ctx, options) =>
|
|
19
|
-
|
|
16
|
+
var push = async (ctx, options) => transferResult(await remoteOperation(ctx, "push", options));
|
|
17
|
+
var pull = async (ctx, options) => transferResult(await remoteOperation(ctx, "pull", options));
|
|
18
|
+
async function syncBoth(ctx, options) {
|
|
19
|
+
const result = await remoteOperation(ctx, options.auto ? "startup-transfer" : "sync", options);
|
|
20
|
+
if (result === "archived" && !options.auto && !options.agentRetryRefusal && !options.yes && ctx.hasUI && (ctx.mode === "tui" || ctx.mode === "rpc"))
|
|
21
|
+
return result;
|
|
22
|
+
return transferResult(result);
|
|
23
|
+
}
|
|
20
24
|
async function rollback(ctx, options) {
|
|
21
25
|
await remoteOperation(ctx, "rollback", options);
|
|
22
26
|
}
|
|
@@ -42,4 +46,4 @@ export {
|
|
|
42
46
|
status,
|
|
43
47
|
syncBoth
|
|
44
48
|
};
|
|
45
|
-
//# sourceMappingURL=sync-operations-
|
|
49
|
+
//# sourceMappingURL=sync-operations-2MZAYHL2.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/sync-operations.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport { remoteOperation } from \"../daemon/pi-client.js\";\nimport type { SetupPullOutcome } from \"./setup-switch.js\";\n\nfunction transferResult(result: unknown): SetupPullOutcome | undefined {\n if (result === undefined || result === \"applied\" || result === \"cancelled\") return result;\n throw new Error(\"Invalid transfer result from pi-sync-daemon.\");\n}\nexport const push = async (ctx: ExtensionContext, options: CommandOptions) =>\n transferResult(await remoteOperation(ctx, \"push\", options));\nexport const pull = async (ctx: ExtensionContext, options: CommandOptions) =>\n transferResult(await remoteOperation(ctx, \"pull\", options));\nexport async function syncBoth(ctx: ExtensionContext, options: CommandOptions) {\n const result = await remoteOperation(ctx, options.auto ? \"startup-transfer\" : \"sync\", options);\n if (\n result === \"archived\" &&\n !options.auto &&\n !options.agentRetryRefusal &&\n !options.yes &&\n ctx.hasUI &&\n (ctx.mode === \"tui\" || ctx.mode === \"rpc\")\n )\n return result;\n return transferResult(result);\n}\nexport async function rollback(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"rollback\", options);\n}\nexport async function status(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"status\", options);\n}\nexport async function diff(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"diff\", options);\n}\nexport async function doctor(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"doctor\", options);\n}\nexport async function history(ctx: ExtensionContext, options: CommandOptions) {\n await remoteOperation(ctx, \"history\", options);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;AAKA,SAAS,eAAe,QAA+C;AACrE,MAAI,WAAW,UAAa,WAAW,aAAa,WAAW,YAAa,QAAO;AACnF,QAAM,IAAI,MAAM,8CAA8C;AAChE;AACO,IAAM,OAAO,OAAO,KAAuB,YAChD,eAAe,MAAM,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AACrD,IAAM,OAAO,OAAO,KAAuB,YAChD,eAAe,MAAM,gBAAgB,KAAK,QAAQ,OAAO,CAAC;AAC5D,eAAsB,SAAS,KAAuB,SAAyB;AAC7E,QAAM,SAAS,MAAM,gBAAgB,KAAK,QAAQ,OAAO,qBAAqB,QAAQ,OAAO;AAC7F,MACE,WAAW,cACX,CAAC,QAAQ,QACT,CAAC,QAAQ,qBACT,CAAC,QAAQ,OACT,IAAI,UACH,IAAI,SAAS,SAAS,IAAI,SAAS;AAEpC,WAAO;AACT,SAAO,eAAe,MAAM;AAC9B;AACA,eAAsB,SAAS,KAAuB,SAAyB;AAC7E,QAAM,gBAAgB,KAAK,YAAY,OAAO;AAChD;AACA,eAAsB,OAAO,KAAuB,SAAyB;AAC3E,QAAM,gBAAgB,KAAK,UAAU,OAAO;AAC9C;AACA,eAAsB,KAAK,KAAuB,SAAyB;AACzE,QAAM,gBAAgB,KAAK,QAAQ,OAAO;AAC5C;AACA,eAAsB,OAAO,KAAuB,SAAyB;AAC3E,QAAM,gBAAgB,KAAK,UAAU,OAAO;AAC9C;AACA,eAAsB,QAAQ,KAAuB,SAAyB;AAC5E,QAAM,gBAAgB,KAAK,WAAW,OAAO;AAC/C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
snapshotHashesMatchState,
|
|
19
19
|
snapshotsMatch,
|
|
20
20
|
syncPolicyChanged
|
|
21
|
-
} from "
|
|
21
|
+
} from "#pi-sync-daemon/engine/sync/sync-state";
|
|
22
22
|
export {
|
|
23
23
|
canPullRemoteSessionsOnFirstSync,
|
|
24
24
|
canPullRemoteSettingsOnFirstSync,
|
|
@@ -36,4 +36,4 @@ export {
|
|
|
36
36
|
snapshotsMatch,
|
|
37
37
|
syncPolicyChanged
|
|
38
38
|
};
|
|
39
|
-
//# sourceMappingURL=sync-state-
|
|
39
|
+
//# sourceMappingURL=sync-state-QIT64TKV.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 narumiruna
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { valid } from "semver";
|
|
3
|
+
// Capture the installed build at module load. A later package update must not
|
|
4
|
+
// change the version advertised by an already running process.
|
|
5
|
+
const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
6
|
+
if (typeof version !== "string" || valid(version) !== version)
|
|
7
|
+
throw new Error("Invalid Pi Sync daemon build version.");
|
|
8
|
+
export const DAEMON_BUILD_VERSION = version;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { registerHooks } from "node:module";
|
|
2
|
+
|
|
3
|
+
const scope = new URL("./", import.meta.url).href;
|
|
4
|
+
let sdk;
|
|
5
|
+
registerHooks({
|
|
6
|
+
resolve(specifier, context, nextResolve) {
|
|
7
|
+
if (context.parentURL?.startsWith(scope)) {
|
|
8
|
+
const codingAgent = specifier === "@earendil-works/pi-coding-agent";
|
|
9
|
+
if (codingAgent || specifier === "@earendil-works/pi-ai" || specifier === "@earendil-works/pi-tui") {
|
|
10
|
+
sdk ??= import.meta.resolve("@narumitw/sync-node-sdk");
|
|
11
|
+
if (codingAgent) return nextResolve(sdk, context);
|
|
12
|
+
return nextResolve(specifier, { ...context, parentURL: sdk });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return nextResolve(specifier, context);
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import "./child-sdk.mjs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
+
import { valid } from "semver";
|
|
6
|
+
import { ensureDaemon, requestDaemon } from "./client.js";
|
|
7
|
+
import { privateDirectory, processExists, processExited, readIdentity, readUpgradeOwner, runtimePaths, } from "./identity.js";
|
|
8
|
+
import { openLifecycleLog } from "./lifecycle-log.js";
|
|
9
|
+
import { record } from "./protocol.js";
|
|
10
|
+
export async function main(args) {
|
|
11
|
+
const [command = "help", flag, root, ...extra] = args;
|
|
12
|
+
if (["help", "--help", "-h"].includes(command)) {
|
|
13
|
+
console.log("pi-sync-daemon <start|status|stop|restart|repair-upgrade|serve> --root <canonical-agent-directory>\nLocal synchronization owner; no OS service registration. status/stop/repair-upgrade never start a service.\nrepair-upgrade revokes all retained unattended grants after verified exit and archives the pending upgrade records.");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!["start", "status", "stop", "restart", "repair-upgrade", "serve"].includes(command) ||
|
|
17
|
+
flag !== "--root" ||
|
|
18
|
+
!root ||
|
|
19
|
+
extra.length)
|
|
20
|
+
throw new Error("Use pi-sync-daemon --help for the supported commands.");
|
|
21
|
+
if (command === "repair-upgrade") {
|
|
22
|
+
const { repairUpgrade } = await import("./upgrade-repair.js");
|
|
23
|
+
console.log(JSON.stringify(await repairUpgrade(root)));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (command === "serve") {
|
|
27
|
+
process.send?.({ type: "booting" });
|
|
28
|
+
const { createEngineService } = await import("./engine-service.js");
|
|
29
|
+
const { startServer } = await import("./server.js");
|
|
30
|
+
const paths = await runtimePaths(root);
|
|
31
|
+
// Credential commands have one documented working directory, never a closed Pi context.
|
|
32
|
+
process.chdir(paths.root);
|
|
33
|
+
await privateDirectory(paths.directory);
|
|
34
|
+
let log;
|
|
35
|
+
const note = (phase) => {
|
|
36
|
+
try {
|
|
37
|
+
log?.write(phase);
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
log?.close(); /* Never follow a replaced diagnostic path. */
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const service = createEngineService(paths.root, true);
|
|
44
|
+
let server;
|
|
45
|
+
try {
|
|
46
|
+
server = await startServer(paths.root, service.execute, {
|
|
47
|
+
...service.hooks,
|
|
48
|
+
stopped: () => {
|
|
49
|
+
note("drained");
|
|
50
|
+
log?.close();
|
|
51
|
+
},
|
|
52
|
+
failure: () => {
|
|
53
|
+
service.hooks.failure();
|
|
54
|
+
note("failed");
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
// Only the published owner may open or modify its shared diagnostic file.
|
|
58
|
+
try {
|
|
59
|
+
log = openLifecycleLog(paths.directory);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
await server.close();
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
note("starting");
|
|
66
|
+
service.bind(server);
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
note("failed");
|
|
70
|
+
log?.close();
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
note("ready");
|
|
74
|
+
let stopping;
|
|
75
|
+
const stop = () => {
|
|
76
|
+
stopping ??= server.close().catch(() => {
|
|
77
|
+
process.exitCode = 1;
|
|
78
|
+
});
|
|
79
|
+
return stopping;
|
|
80
|
+
};
|
|
81
|
+
process.on("SIGTERM", stop);
|
|
82
|
+
process.on("SIGINT", stop);
|
|
83
|
+
// Parent disconnect means readiness IPC ended, not service shutdown.
|
|
84
|
+
process.send?.({ type: "ready", identity: server.identity });
|
|
85
|
+
process.channel?.unref();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if (command === "start") {
|
|
89
|
+
const { identity } = await ensureDaemon(root);
|
|
90
|
+
console.log(JSON.stringify({ running: true, root: identity.root, instance: identity.instance, pid: identity.pid }));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const paths = await runtimePaths(root);
|
|
94
|
+
const identity = await readIdentity(paths);
|
|
95
|
+
if (command === "status") {
|
|
96
|
+
const pending = await readUpgradeOwner(paths);
|
|
97
|
+
const summary = {
|
|
98
|
+
root: paths.root,
|
|
99
|
+
...(identity && { recordedPid: identity.pid }),
|
|
100
|
+
...(pending && { pendingUpgradePid: pending.pid }),
|
|
101
|
+
};
|
|
102
|
+
if (!identity ||
|
|
103
|
+
(pending?.instance === identity.instance && pending.pid === identity.pid && (await processExited(pending)))) {
|
|
104
|
+
console.log(JSON.stringify({ running: false, ...summary }));
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const status = await requestDaemon(paths, identity, "hello", {});
|
|
109
|
+
if (!record(status) ||
|
|
110
|
+
status.version !== 1 ||
|
|
111
|
+
status.root !== paths.root ||
|
|
112
|
+
status.instance !== identity.instance ||
|
|
113
|
+
status.pid !== identity.pid)
|
|
114
|
+
throw new Error("Daemon identity mismatch; no replacement was attempted.");
|
|
115
|
+
const build = typeof status.buildVersion === "string" ? valid(status.buildVersion) : null;
|
|
116
|
+
console.log(JSON.stringify({
|
|
117
|
+
running: true,
|
|
118
|
+
...summary,
|
|
119
|
+
version: status.version,
|
|
120
|
+
instance: identity.instance,
|
|
121
|
+
pid: identity.pid,
|
|
122
|
+
...(build && { buildVersion: build }),
|
|
123
|
+
lifecycleLog: path.join(paths.directory, "lifecycle.log"),
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// A failed hello does not prove the recorded owner exited.
|
|
128
|
+
console.log(JSON.stringify({ running: null, ...summary }));
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (!identity) {
|
|
133
|
+
if (command === "restart") {
|
|
134
|
+
await main(["start", "--root", root]);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
console.log(JSON.stringify({ running: false, root: paths.root }));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
await requestDaemon(paths, identity, "stop", {});
|
|
141
|
+
const deadline = Date.now() + 30_000;
|
|
142
|
+
while (await readIdentity(paths)) {
|
|
143
|
+
if (Date.now() >= deadline)
|
|
144
|
+
throw new Error("Daemon did not drain; state retained. Do not force a second owner.");
|
|
145
|
+
await delay(25);
|
|
146
|
+
}
|
|
147
|
+
if (command === "restart") {
|
|
148
|
+
while (processExists(identity.pid)) {
|
|
149
|
+
if (Date.now() >= deadline)
|
|
150
|
+
throw new Error("Previous daemon is still exiting; restart was not attempted.");
|
|
151
|
+
await delay(25);
|
|
152
|
+
}
|
|
153
|
+
await main(["start", "--root", root]);
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
console.log(JSON.stringify({ stopped: true, root: paths.root }));
|
|
157
|
+
}
|
|
158
|
+
if (import.meta.main) {
|
|
159
|
+
void main(process.argv.slice(2)).catch(() => {
|
|
160
|
+
process.send?.({
|
|
161
|
+
type: "error",
|
|
162
|
+
message: "Daemon initialization failed; private state retained. Check endpoint ownership and compatible versions.",
|
|
163
|
+
});
|
|
164
|
+
console.error(process.argv[2] === "repair-upgrade"
|
|
165
|
+
? "Pi Sync upgrade repair failed. Check the pending PID, wait for confirmed exit, and check consent storage. Do not delete recovery files."
|
|
166
|
+
: "pi-sync-daemon failed; private state retained. Check root, endpoint ownership, and version compatibility.");
|
|
167
|
+
process.exitCode = 1;
|
|
168
|
+
});
|
|
169
|
+
}
|