@narumitw/pi-sync 0.70.5 → 0.70.7
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 +12 -0
- package/README.md +2 -0
- package/dist/chunks/{chunk-3XN4FR72.ts → chunk-4A34OGXY.ts} +9 -9
- package/dist/chunks/{chunk-7NQ7SFZK.ts → chunk-5BE6LBDC.ts} +15 -15
- package/dist/chunks/chunk-A43CJYG4.ts +26 -0
- package/dist/chunks/chunk-A43CJYG4.ts.map +7 -0
- package/dist/chunks/{chunk-JPTI4HFC.ts → chunk-AXN3B5KC.ts} +22 -22
- package/dist/chunks/{chunk-SPXEDJ2G.ts → chunk-HCXPNKPU.ts} +61 -59
- package/dist/chunks/chunk-HCXPNKPU.ts.map +7 -0
- package/dist/chunks/{chunk-N24HEZSA.ts → chunk-VERMBZGL.ts} +7 -7
- package/dist/chunks/{chunk-LSIUAXE4.ts → chunk-WE3KJ7JS.ts} +8 -8
- package/dist/chunks/{chunk-5T4ZOHYF.ts → chunk-WRS3SUNZ.ts} +4 -18
- package/dist/chunks/chunk-WRS3SUNZ.ts.map +7 -0
- package/dist/chunks/client-debug-F4WFP2YJ.ts +40 -0
- package/dist/chunks/client-debug-F4WFP2YJ.ts.map +7 -0
- package/dist/chunks/{command-handler-PT2KVTLD.ts → command-handler-DWWFIXSC.ts} +34 -32
- package/dist/chunks/{command-handler-PT2KVTLD.ts.map → command-handler-DWWFIXSC.ts.map} +1 -1
- package/dist/chunks/{conflict-review-QI77P7KL.ts → conflict-review-HSERM245.ts} +3 -3
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts +67 -0
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts.map +7 -0
- package/dist/chunks/{diff-review-SOLP33TQ.ts → diff-review-6IUIOYST.ts} +3 -3
- package/dist/chunks/{diff-review-ILRZDQ4S.ts → diff-review-GB4NO53B.ts} +4 -4
- package/dist/chunks/{file-selection-2H3J2HTX.ts → file-selection-DGC5UJVI.ts} +9 -9
- package/dist/chunks/{manager-result-dispatcher-75FS46JP.ts → manager-result-dispatcher-6MOJPLIS.ts} +7 -7
- package/dist/chunks/{manager-ui-HW3ZAEVK.ts → manager-ui-3CQU37XY.ts} +52 -50
- package/dist/chunks/{manager-ui-HW3ZAEVK.ts.map → manager-ui-3CQU37XY.ts.map} +1 -1
- package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts → remote-selection-ui-2V53UBHM.ts} +6 -6
- package/dist/chunks/{setup-switch-LJPEZONY.ts → setup-switch-WSKVGW7L.ts} +4 -4
- package/dist/chunks/{setup-wizard-FBX7RTZ6.ts → setup-wizard-FRIR2EOR.ts} +9 -9
- package/dist/chunks/{sync-inspection-TZ4EMSBN.ts → sync-inspection-CQDNC542.ts} +6 -6
- package/dist/chunks/{sync-operations-QIQ3G66S.ts → sync-operations-IF7LMWK6.ts} +4 -4
- package/dist/chunks/sync-state-store-TZE7XDV5.ts +23 -0
- package/dist/chunks/sync-state-store-TZE7XDV5.ts.map +7 -0
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/cli.js +3 -2
- package/dist/daemon/dist/client.js +55 -14
- package/dist/daemon/dist/daemon-startup.js +2 -14
- package/dist/daemon/dist/daemon-upgrade-error.js +14 -0
- package/dist/daemon/dist/index.js +20 -3
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +278 -248
- package/dist/index.ts.map +2 -2
- package/docs/daemon-migration.md +2 -0
- package/package.json +2 -2
- package/src/daemon/client-debug.ts +2 -0
- package/src/daemon/pi-client.ts +60 -22
- package/src/sync/automatic-sync.ts +5 -3
- package/src/sync/debug-tool-execution.ts +66 -0
- package/src/sync/debug-tool.ts +8 -56
- package/src/sync/startup-check.ts +3 -1
- package/src/sync-extension.ts +252 -166
- package/dist/chunks/chunk-5T4ZOHYF.ts.map +0 -7
- package/dist/chunks/chunk-SPXEDJ2G.ts.map +0 -7
- /package/dist/chunks/{chunk-3XN4FR72.ts.map → chunk-4A34OGXY.ts.map} +0 -0
- /package/dist/chunks/{chunk-7NQ7SFZK.ts.map → chunk-5BE6LBDC.ts.map} +0 -0
- /package/dist/chunks/{chunk-JPTI4HFC.ts.map → chunk-AXN3B5KC.ts.map} +0 -0
- /package/dist/chunks/{chunk-N24HEZSA.ts.map → chunk-VERMBZGL.ts.map} +0 -0
- /package/dist/chunks/{chunk-LSIUAXE4.ts.map → chunk-WE3KJ7JS.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-QI77P7KL.ts.map → conflict-review-HSERM245.ts.map} +0 -0
- /package/dist/chunks/{diff-review-SOLP33TQ.ts.map → diff-review-6IUIOYST.ts.map} +0 -0
- /package/dist/chunks/{diff-review-ILRZDQ4S.ts.map → diff-review-GB4NO53B.ts.map} +0 -0
- /package/dist/chunks/{file-selection-2H3J2HTX.ts.map → file-selection-DGC5UJVI.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-75FS46JP.ts.map → manager-result-dispatcher-6MOJPLIS.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts.map → remote-selection-ui-2V53UBHM.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-LJPEZONY.ts.map → setup-switch-WSKVGW7L.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-FBX7RTZ6.ts.map → setup-wizard-FRIR2EOR.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-TZ4EMSBN.ts.map → sync-inspection-CQDNC542.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-QIQ3G66S.ts.map → sync-operations-IF7LMWK6.ts.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @narumitw/pi-sync
|
|
2
2
|
|
|
3
|
+
## 0.70.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2b1738d: Ignore lifecycle events for a retired Pi Sync client, and guide `/sync` and Debug mode users to reattach with `/reload` when the session binding is unavailable. Keep shutdown work separate from the active client binding.
|
|
8
|
+
|
|
9
|
+
## 0.70.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- a71f120: Reduce cold Pi Sync startup work by loading client diagnostics only when enabled or used, and loading the sync state reader only when a check or command needs it. Session protection, daemon admission, and recovery still finish at the same readiness boundaries.
|
|
14
|
+
|
|
3
15
|
## 0.70.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -119,6 +119,8 @@ Unresolved paths stay unchanged on each side. A backup and recovery journal prot
|
|
|
119
119
|
|
|
120
120
|
### Restore sync access
|
|
121
121
|
|
|
122
|
+
If `/sync` or `pi_sync_debug` reports an unavailable session binding, check for pending recovery before using `/reload` to reattach Pi Sync. Reload can run an already enabled [Startup transfer](#opt-in-automatic-transfer); it does not resolve uncertain writes. After reattaching, check `/sync daemon status` before retrying a transfer. If daemon ownership or cleanup is uncertain, follow the [daemon recovery guide](./docs/daemon-migration.md#recover-from-uncertain-daemon-cleanup) instead of retrying.
|
|
123
|
+
|
|
122
124
|
While an operation is running, the manager shows its command and process ID, disables sync and settings changes, and puts **Refresh operation status** first.
|
|
123
125
|
When an active guard still protects lock metadata, the manager asks you to wait because another Pi Sync process may be starting or finishing.
|
|
124
126
|
It never offers lock removal while an owner or guard may still be active.
|
|
@@ -7,12 +7,18 @@ import {
|
|
|
7
7
|
configuredSyncSetupNames,
|
|
8
8
|
updateLocalConfig
|
|
9
9
|
} from "./chunk-R7PN3KIY.ts";
|
|
10
|
+
import {
|
|
11
|
+
captureMutationOwner
|
|
12
|
+
} from "./chunk-GELYN4UC.ts";
|
|
10
13
|
import {
|
|
11
14
|
setSyncSetupCompletions
|
|
12
15
|
} from "./chunk-VQTYTUBU.ts";
|
|
13
16
|
import {
|
|
14
|
-
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
SetupPullRequiresUiError
|
|
18
|
+
} from "./chunk-6YKOHBSC.ts";
|
|
19
|
+
import {
|
|
20
|
+
safeTerminalText
|
|
21
|
+
} from "./chunk-AMJRUXFT.ts";
|
|
16
22
|
import {
|
|
17
23
|
configFromSettings,
|
|
18
24
|
loadConfigForCheck,
|
|
@@ -20,12 +26,6 @@ import {
|
|
|
20
26
|
syncCheckConfigFingerprint,
|
|
21
27
|
syncConfigReviewIdentity
|
|
22
28
|
} from "./chunk-LNZRNXNQ.ts";
|
|
23
|
-
import {
|
|
24
|
-
SetupPullRequiresUiError
|
|
25
|
-
} from "./chunk-6YKOHBSC.ts";
|
|
26
|
-
import {
|
|
27
|
-
safeTerminalText
|
|
28
|
-
} from "./chunk-AMJRUXFT.ts";
|
|
29
29
|
|
|
30
30
|
// src/sync/setup-switch.ts
|
|
31
31
|
var SETUP_SWITCH_ACTION_OPTIONS = [
|
|
@@ -143,4 +143,4 @@ export {
|
|
|
143
143
|
saveOnSwitch,
|
|
144
144
|
useSyncSetup
|
|
145
145
|
};
|
|
146
|
-
//# sourceMappingURL=chunk-
|
|
146
|
+
//# sourceMappingURL=chunk-4A34OGXY.ts.map
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
throwIfAborted
|
|
5
|
-
} from "./chunk-UMPA5S7X.ts";
|
|
6
|
-
import {
|
|
7
|
-
runCancellableOperation,
|
|
8
|
-
runCancellableTask
|
|
9
|
-
} from "./chunk-ZWP6HAYV.ts";
|
|
10
3
|
import {
|
|
11
4
|
SyncSetupReviewChangedError,
|
|
12
5
|
updateSyncSetup
|
|
@@ -17,26 +10,33 @@ import {
|
|
|
17
10
|
import {
|
|
18
11
|
sameSyncExclude
|
|
19
12
|
} from "./chunk-ZO52JM4H.ts";
|
|
20
|
-
import {
|
|
21
|
-
loadConfig,
|
|
22
|
-
syncCheckConfigFingerprint,
|
|
23
|
-
syncConfigReviewFingerprint
|
|
24
|
-
} from "./chunk-LNZRNXNQ.ts";
|
|
25
13
|
import {
|
|
26
14
|
setSyncStatus
|
|
27
15
|
} from "./chunk-H7VOTY5N.ts";
|
|
28
16
|
import {
|
|
29
|
-
|
|
30
|
-
} from "./chunk-
|
|
17
|
+
throwIfAborted
|
|
18
|
+
} from "./chunk-UMPA5S7X.ts";
|
|
31
19
|
import {
|
|
32
20
|
compareSyncInclude,
|
|
33
21
|
inspectRemoteSelection,
|
|
34
22
|
sameSyncInclude,
|
|
35
23
|
syncDirectoryPolicyKey
|
|
36
24
|
} from "./chunk-R3SAMXB6.ts";
|
|
25
|
+
import {
|
|
26
|
+
errorMessage
|
|
27
|
+
} from "./chunk-6YKOHBSC.ts";
|
|
28
|
+
import {
|
|
29
|
+
runCancellableOperation,
|
|
30
|
+
runCancellableTask
|
|
31
|
+
} from "./chunk-ZWP6HAYV.ts";
|
|
37
32
|
import {
|
|
38
33
|
safeTerminalText
|
|
39
34
|
} from "./chunk-AMJRUXFT.ts";
|
|
35
|
+
import {
|
|
36
|
+
loadConfig,
|
|
37
|
+
syncCheckConfigFingerprint,
|
|
38
|
+
syncConfigReviewFingerprint
|
|
39
|
+
} from "./chunk-LNZRNXNQ.ts";
|
|
40
40
|
|
|
41
41
|
// src/ui/remote-selection-ui.ts
|
|
42
42
|
import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
|
|
@@ -689,4 +689,4 @@ function combineSignals(sessionSignal, actionSignal) {
|
|
|
689
689
|
export {
|
|
690
690
|
showRemoteSelectionReview
|
|
691
691
|
};
|
|
692
|
-
//# sourceMappingURL=chunk-
|
|
692
|
+
//# sourceMappingURL=chunk-5BE6LBDC.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
|
|
4
|
+
// src/state/sync-state-store.ts
|
|
5
|
+
import {
|
|
6
|
+
ensureStateDir,
|
|
7
|
+
lockPath,
|
|
8
|
+
readState,
|
|
9
|
+
readStateForConfig,
|
|
10
|
+
statePathForConfig,
|
|
11
|
+
syncStateFingerprint,
|
|
12
|
+
writeState,
|
|
13
|
+
writeStateForConfig
|
|
14
|
+
} from "#pi-sync-daemon/engine/state/sync-state-store";
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
ensureStateDir,
|
|
18
|
+
lockPath,
|
|
19
|
+
readState,
|
|
20
|
+
readStateForConfig,
|
|
21
|
+
statePathForConfig,
|
|
22
|
+
syncStateFingerprint,
|
|
23
|
+
writeState,
|
|
24
|
+
writeStateForConfig
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=chunk-A43CJYG4.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/state/sync-state-store.ts"],
|
|
4
|
+
"sourcesContent": ["export type * from \"@narumitw/pi-sync-daemon/engine/state/sync-state-store\";\nexport {\n ensureStateDir,\n lockPath,\n readState,\n readStateForConfig,\n statePathForConfig,\n syncStateFingerprint,\n writeState,\n writeStateForConfig,\n} from \"@narumitw/pi-sync-daemon/engine/state/sync-state-store\";\n"],
|
|
5
|
+
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
acknowledgeSessions,
|
|
5
|
+
directoryScopeLines,
|
|
6
|
+
promptDirectoryRules,
|
|
7
|
+
saveReviewedDraft,
|
|
8
|
+
starterDirectoryRules
|
|
9
|
+
} from "./chunk-HFMGK6A6.ts";
|
|
10
|
+
import {
|
|
11
|
+
addStorageConnection,
|
|
12
|
+
addSyncSetup,
|
|
13
|
+
saveNewV3Settings,
|
|
14
|
+
updateStorageConnection,
|
|
15
|
+
updateSyncSetup
|
|
16
|
+
} from "./chunk-NXWHPVXR.ts";
|
|
3
17
|
import {
|
|
4
18
|
effectiveSyncSetupRemoteIdentity,
|
|
5
19
|
normalizeS3Bucket,
|
|
@@ -13,36 +27,22 @@ import {
|
|
|
13
27
|
configuredSyncSetupNames,
|
|
14
28
|
readLocalConfigObject
|
|
15
29
|
} from "./chunk-R7PN3KIY.ts";
|
|
30
|
+
import {
|
|
31
|
+
captureMutationOwner
|
|
32
|
+
} from "./chunk-GELYN4UC.ts";
|
|
16
33
|
import {
|
|
17
34
|
throwIfAborted
|
|
18
35
|
} from "./chunk-UMPA5S7X.ts";
|
|
36
|
+
import {
|
|
37
|
+
DEFAULT_SYNC_INCLUDE
|
|
38
|
+
} from "./chunk-R3SAMXB6.ts";
|
|
19
39
|
import {
|
|
20
40
|
AUTOMATIC_SYNC_DESCRIPTION,
|
|
21
41
|
setSyncSetupCompletions
|
|
22
42
|
} from "./chunk-VQTYTUBU.ts";
|
|
23
|
-
import {
|
|
24
|
-
acknowledgeSessions,
|
|
25
|
-
directoryScopeLines,
|
|
26
|
-
promptDirectoryRules,
|
|
27
|
-
saveReviewedDraft,
|
|
28
|
-
starterDirectoryRules
|
|
29
|
-
} from "./chunk-HFMGK6A6.ts";
|
|
30
|
-
import {
|
|
31
|
-
addStorageConnection,
|
|
32
|
-
addSyncSetup,
|
|
33
|
-
saveNewV3Settings,
|
|
34
|
-
updateStorageConnection,
|
|
35
|
-
updateSyncSetup
|
|
36
|
-
} from "./chunk-NXWHPVXR.ts";
|
|
37
|
-
import {
|
|
38
|
-
captureMutationOwner
|
|
39
|
-
} from "./chunk-GELYN4UC.ts";
|
|
40
43
|
import {
|
|
41
44
|
errorMessage
|
|
42
45
|
} from "./chunk-6YKOHBSC.ts";
|
|
43
|
-
import {
|
|
44
|
-
DEFAULT_SYNC_INCLUDE
|
|
45
|
-
} from "./chunk-R3SAMXB6.ts";
|
|
46
46
|
import {
|
|
47
47
|
safeTerminalText
|
|
48
48
|
} from "./chunk-AMJRUXFT.ts";
|
|
@@ -289,7 +289,7 @@ async function finishSetup(ctx, name, message, join, signal) {
|
|
|
289
289
|
if (signal?.aborted) return;
|
|
290
290
|
ctx.ui.notify(message, "info");
|
|
291
291
|
if (!join) return;
|
|
292
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
292
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-2V53UBHM.ts");
|
|
293
293
|
if (signal?.aborted) return;
|
|
294
294
|
await showRemoteSelectionReview(ctx, name, signal, void 0, { origin: "settings" });
|
|
295
295
|
}
|
|
@@ -1038,4 +1038,4 @@ export {
|
|
|
1038
1038
|
showAddWebDavStorageProfile,
|
|
1039
1039
|
showEditWebDavStorageProfile
|
|
1040
1040
|
};
|
|
1041
|
-
//# sourceMappingURL=chunk-
|
|
1041
|
+
//# sourceMappingURL=chunk-AXN3B5KC.ts.map
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
showSyncConnectionStatus,
|
|
6
6
|
showSyncQueueReleaseRecovery
|
|
7
7
|
} from "./chunk-H7VOTY5N.ts";
|
|
8
|
+
import {
|
|
9
|
+
RemoteSelectionMismatchError
|
|
10
|
+
} from "./chunk-R3SAMXB6.ts";
|
|
8
11
|
import {
|
|
9
12
|
SyncDecisionRequiredError,
|
|
10
13
|
errorMessage
|
|
11
14
|
} from "./chunk-6YKOHBSC.ts";
|
|
12
|
-
import {
|
|
13
|
-
RemoteSelectionMismatchError
|
|
14
|
-
} from "./chunk-R3SAMXB6.ts";
|
|
15
15
|
import {
|
|
16
16
|
safeTerminalText
|
|
17
17
|
} from "./chunk-AMJRUXFT.ts";
|
|
@@ -36,7 +36,6 @@ import {
|
|
|
36
36
|
requestDaemon as requestDaemon2,
|
|
37
37
|
waitForDaemonExit
|
|
38
38
|
} from "#pi-sync-daemon";
|
|
39
|
-
import { appendDebugEvent } from "#pi-sync-daemon/engine/debug-log";
|
|
40
39
|
import { configureEngineHost } from "#pi-sync-daemon/engine/host";
|
|
41
40
|
import {
|
|
42
41
|
peekLocalConfigDocument
|
|
@@ -171,38 +170,6 @@ var PiApplyGate = class {
|
|
|
171
170
|
}
|
|
172
171
|
};
|
|
173
172
|
|
|
174
|
-
// src/daemon/client-debug.ts
|
|
175
|
-
import { debugJobResult, debugOperation } from "#pi-sync-daemon/engine/debug-log";
|
|
176
|
-
function observeDebugJob(operation, append) {
|
|
177
|
-
const kind = debugOperation(operation);
|
|
178
|
-
if (!kind) return void 0;
|
|
179
|
-
let operationId;
|
|
180
|
-
const record = (outcome) => append({ event: "job", operation: kind, outcome, ...operationId ? { operationId } : {} });
|
|
181
|
-
return {
|
|
182
|
-
onSubmit(id) {
|
|
183
|
-
if (operationId && operationId !== id) record("blocked");
|
|
184
|
-
operationId = id;
|
|
185
|
-
record("started");
|
|
186
|
-
},
|
|
187
|
-
returned(result, interrupted = false) {
|
|
188
|
-
const outcome = debugJobResult(kind, result);
|
|
189
|
-
if (interrupted && outcome !== "completed") record("cancelled");
|
|
190
|
-
else if (outcome) record(outcome);
|
|
191
|
-
else if (result === "archived" || kind === "initialize" && typeof result === "object" && result !== null && "handoverRequired" in result && result.handoverRequired === true)
|
|
192
|
-
record("blocked");
|
|
193
|
-
else if (kind === "migrate-state" && typeof result === "object" && result !== null && "status" in result && result.status === "cancelled")
|
|
194
|
-
record("cancelled");
|
|
195
|
-
else record("completed");
|
|
196
|
-
},
|
|
197
|
-
rejected(error, cancelled) {
|
|
198
|
-
if (cancelled || error instanceof Error && error.name === "AbortError") record("cancelled");
|
|
199
|
-
else if (error instanceof Error && (error.name === "SyncDecisionRequiredError" || error.name === "RemoteSelectionMismatchError"))
|
|
200
|
-
record("blocked");
|
|
201
|
-
else record("failed");
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
|
|
206
173
|
// src/daemon/directional-recovery.ts
|
|
207
174
|
function isForegroundDirection(operation) {
|
|
208
175
|
return operation === "push.foreground" || operation === "pull.foreground";
|
|
@@ -468,6 +435,7 @@ async function requestStartupBootstrap(connection, fingerprint2, debug, signal)
|
|
|
468
435
|
}
|
|
469
436
|
|
|
470
437
|
// src/daemon/pi-client.ts
|
|
438
|
+
var PI_SYNC_BINDING_UNAVAILABLE = "Pi Sync session binding is unavailable. Use /reload to reattach, then check /sync daemon status before retrying.";
|
|
471
439
|
var PROTECTION_ONLY_GUIDANCE = "This session is only protecting its files on an incompatible Pi Sync daemon. Stop it safely, then use /reload with the matching build.";
|
|
472
440
|
var scope = new AsyncLocalStorage();
|
|
473
441
|
var clients = /* @__PURE__ */ new WeakMap();
|
|
@@ -557,18 +525,18 @@ function installPiDaemonHost() {
|
|
|
557
525
|
});
|
|
558
526
|
}
|
|
559
527
|
function bindPiDaemonClient(ctx, signal, publish) {
|
|
560
|
-
|
|
561
|
-
clients.set(ctx.sessionManager, client);
|
|
562
|
-
return client;
|
|
528
|
+
return PiDaemonClient.bind(ctx, signal, publish);
|
|
563
529
|
}
|
|
564
530
|
function piDaemonClient(ctx) {
|
|
565
|
-
const
|
|
566
|
-
|
|
531
|
+
const manager = ctx.sessionManager;
|
|
532
|
+
const client = scope.getStore()?.client ?? clients.get(manager);
|
|
533
|
+
if (!client?.isFor(manager)) throw new Error(PI_SYNC_BINDING_UNAVAILABLE);
|
|
567
534
|
client.validate();
|
|
568
535
|
return client;
|
|
569
536
|
}
|
|
570
|
-
function withPiDaemonClient(ctx, action, reload) {
|
|
571
|
-
|
|
537
|
+
function withPiDaemonClient(ctx, action, reload, client) {
|
|
538
|
+
client?.validate();
|
|
539
|
+
const owner = { client: client ?? piDaemonClient(ctx), reload };
|
|
572
540
|
const ui = new Proxy(ctx.ui, {
|
|
573
541
|
get(target, property) {
|
|
574
542
|
if (property !== "custom") return Reflect.get(target, property, target);
|
|
@@ -628,11 +596,12 @@ async function remoteOperation(ctx, operation, options) {
|
|
|
628
596
|
function remoteErrorNamed(error, name) {
|
|
629
597
|
return error instanceof DaemonError2 && error.remote.name === name;
|
|
630
598
|
}
|
|
631
|
-
var PiDaemonClient = class {
|
|
632
|
-
constructor(ctx, signal, publish) {
|
|
599
|
+
var PiDaemonClient = class _PiDaemonClient {
|
|
600
|
+
constructor(ctx, signal, publish, shutdownOwner) {
|
|
633
601
|
this.ctx = ctx;
|
|
634
|
-
this.signal = signal;
|
|
635
602
|
this.publish = publish;
|
|
603
|
+
this.shutdownOwner = shutdownOwner;
|
|
604
|
+
this.signal = AbortSignal.any([signal, this.replacementSignal]);
|
|
636
605
|
this.uiContext = ctx;
|
|
637
606
|
this.manager = ctx.sessionManager;
|
|
638
607
|
this.rawRoot = getAgentDir();
|
|
@@ -643,8 +612,8 @@ var PiDaemonClient = class {
|
|
|
643
612
|
this.signal.addEventListener("abort", this.stopReleaseUI, { once: true });
|
|
644
613
|
}
|
|
645
614
|
ctx;
|
|
646
|
-
signal;
|
|
647
615
|
publish;
|
|
616
|
+
shutdownOwner;
|
|
648
617
|
connection;
|
|
649
618
|
protectionOnly = false;
|
|
650
619
|
blockedUpgrade;
|
|
@@ -686,6 +655,7 @@ var PiDaemonClient = class {
|
|
|
686
655
|
initialized = false;
|
|
687
656
|
startupDebug = false;
|
|
688
657
|
debug = false;
|
|
658
|
+
diagnostics;
|
|
689
659
|
participantIdentity = { id: randomUUID2(), generation: randomUUID2() };
|
|
690
660
|
get id() {
|
|
691
661
|
return this.participantIdentity.id;
|
|
@@ -699,10 +669,36 @@ var PiDaemonClient = class {
|
|
|
699
669
|
rawRoot;
|
|
700
670
|
gate;
|
|
701
671
|
manager;
|
|
672
|
+
replacement = new AbortController();
|
|
673
|
+
signal;
|
|
674
|
+
static bind(ctx, signal, publish) {
|
|
675
|
+
const client = new _PiDaemonClient(ctx, signal, publish);
|
|
676
|
+
const previous = clients.get(client.manager);
|
|
677
|
+
clients.set(client.manager, client);
|
|
678
|
+
previous?.replacement.abort(new DOMException("Synchronization session was replaced.", "AbortError"));
|
|
679
|
+
return client;
|
|
680
|
+
}
|
|
681
|
+
get replacementSignal() {
|
|
682
|
+
return this.shutdownOwner?.replacementSignal ?? this.replacement.signal;
|
|
683
|
+
}
|
|
684
|
+
isFor(manager) {
|
|
685
|
+
return this.manager === manager;
|
|
686
|
+
}
|
|
687
|
+
ownsBinding() {
|
|
688
|
+
return clients.get(this.manager) === (this.shutdownOwner ?? this);
|
|
689
|
+
}
|
|
690
|
+
isCurrent() {
|
|
691
|
+
return !this.signal.aborted && !this.disposed && !this.closing && this.ownsBinding();
|
|
692
|
+
}
|
|
693
|
+
createShutdownClient(ctx, signal) {
|
|
694
|
+
signal.throwIfAborted();
|
|
695
|
+
if (!this.ownsBinding() || this.closing || !this.isFor(ctx.sessionManager))
|
|
696
|
+
throw new Error(PI_SYNC_BINDING_UNAVAILABLE);
|
|
697
|
+
return new _PiDaemonClient(ctx, signal, this.publish, this);
|
|
698
|
+
}
|
|
702
699
|
validate() {
|
|
703
700
|
this.signal.throwIfAborted();
|
|
704
|
-
if (this.
|
|
705
|
-
throw new Error("Synchronization session was replaced.");
|
|
701
|
+
if (!this.isCurrent()) throw new Error("Synchronization session was replaced.");
|
|
706
702
|
this.ctx.isIdle();
|
|
707
703
|
if (getAgentDir() !== this.rawRoot || canonicalPath(path2.resolve(this.rawRoot)) !== this.root)
|
|
708
704
|
throw new Error("Agent directory changed; reload before synchronization.");
|
|
@@ -715,14 +711,18 @@ var PiDaemonClient = class {
|
|
|
715
711
|
if (!this.debug || !this.ownsContactUI() || this.pendingReload)
|
|
716
712
|
throw new Error("Pi Sync debug is not available in this session.");
|
|
717
713
|
}
|
|
718
|
-
setDebugPreference(debug) {
|
|
714
|
+
async setDebugPreference(debug) {
|
|
719
715
|
this.debug = debug && this.ctx.hasUI && (this.ctx.mode === "tui" || this.ctx.mode === "rpc");
|
|
716
|
+
if (!this.debug || this.diagnostics) return;
|
|
717
|
+
const diagnostics = await import("./client-debug-F4WFP2YJ.ts").catch(() => void 0);
|
|
718
|
+
this.validate();
|
|
719
|
+
if (this.debug) this.diagnostics = diagnostics;
|
|
720
720
|
}
|
|
721
721
|
recordDebug(event) {
|
|
722
|
-
if (!this.debug || this.protectionOnly || this.pendingReload || !this.ownsContactUI()) return;
|
|
722
|
+
if (!this.debug || !this.diagnostics || this.protectionOnly || this.pendingReload || !this.ownsContactUI()) return;
|
|
723
723
|
try {
|
|
724
724
|
this.validate();
|
|
725
|
-
appendDebugEvent(this.root, "pi-sync", event);
|
|
725
|
+
this.diagnostics.appendDebugEvent(this.root, "pi-sync", event);
|
|
726
726
|
} catch {
|
|
727
727
|
}
|
|
728
728
|
}
|
|
@@ -911,7 +911,7 @@ var PiDaemonClient = class {
|
|
|
911
911
|
mergeReview: !protectionOnly && this.ctx.hasUI ? (callback, loadDetails, signal) => this.pagedMergeReview(connection2, callback, loadDetails, signal) : void 0,
|
|
912
912
|
event: (event) => {
|
|
913
913
|
if (event.kind === "commit") return;
|
|
914
|
-
if (this.
|
|
914
|
+
if (!this.isCurrent()) return;
|
|
915
915
|
const payload = event.payload;
|
|
916
916
|
if (event.kind === "notify" && typeof payload?.message === "string") {
|
|
917
917
|
const message = payload.layout === "report" ? payload.message.split("\n").map(safeTerminalText).join("\n") : safeTerminalText(payload.message);
|
|
@@ -951,7 +951,7 @@ var PiDaemonClient = class {
|
|
|
951
951
|
}
|
|
952
952
|
this.validate();
|
|
953
953
|
await recoverDetachedClients(daemon);
|
|
954
|
-
if (this.
|
|
954
|
+
if (!this.isCurrent()) {
|
|
955
955
|
await connection2.dispose();
|
|
956
956
|
this.validate();
|
|
957
957
|
}
|
|
@@ -983,10 +983,10 @@ var PiDaemonClient = class {
|
|
|
983
983
|
return connection;
|
|
984
984
|
}
|
|
985
985
|
ownsContactUI() {
|
|
986
|
-
return
|
|
986
|
+
return this.isCurrent() && !this.paused;
|
|
987
987
|
}
|
|
988
988
|
releaseContext(cleanup = false) {
|
|
989
|
-
if (
|
|
989
|
+
if (!this.ownsBinding()) return;
|
|
990
990
|
if (!cleanup && (!this.releaseUIEnabled || !this.ownsContactUI() || this.busy.has("shutdown"))) return;
|
|
991
991
|
try {
|
|
992
992
|
this.ctx.isIdle();
|
|
@@ -1176,7 +1176,7 @@ var PiDaemonClient = class {
|
|
|
1176
1176
|
this.cleanupRequired = true;
|
|
1177
1177
|
}
|
|
1178
1178
|
run(operation, payload, signal, ctx = this.ctx, onCommit, reload) {
|
|
1179
|
-
const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : void 0;
|
|
1179
|
+
const diagnostics = this.debug ? this.diagnostics?.observeDebugJob(operation, (event) => this.recordDebug(event)) : void 0;
|
|
1180
1180
|
const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics)).catch((error) => {
|
|
1181
1181
|
diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));
|
|
1182
1182
|
this.recordOwnershipFailure(error);
|
|
@@ -1382,9 +1382,10 @@ var PiDaemonClient = class {
|
|
|
1382
1382
|
});
|
|
1383
1383
|
}
|
|
1384
1384
|
async markReady(debug) {
|
|
1385
|
+
this.validate();
|
|
1386
|
+
await this.setDebugPreference(debug);
|
|
1385
1387
|
this.validate();
|
|
1386
1388
|
this.startupDebug = debug;
|
|
1387
|
-
this.setDebugPreference(debug);
|
|
1388
1389
|
this.initialized = true;
|
|
1389
1390
|
await this.update();
|
|
1390
1391
|
this.validate();
|
|
@@ -1541,6 +1542,7 @@ var PiDaemonClient = class {
|
|
|
1541
1542
|
|
|
1542
1543
|
export {
|
|
1543
1544
|
CompletedDirectionalRecoveryError,
|
|
1545
|
+
PI_SYNC_BINDING_UNAVAILABLE,
|
|
1544
1546
|
currentPiDaemonClient,
|
|
1545
1547
|
installPiDaemonHost,
|
|
1546
1548
|
bindPiDaemonClient,
|
|
@@ -1548,4 +1550,4 @@ export {
|
|
|
1548
1550
|
withPiDaemonClient,
|
|
1549
1551
|
remoteOperation
|
|
1550
1552
|
};
|
|
1551
|
-
//# sourceMappingURL=chunk-
|
|
1553
|
+
//# sourceMappingURL=chunk-HCXPNKPU.ts.map
|