@narumitw/pi-sync 0.60.0 → 0.60.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +11 -12
- package/dist/chunks/{chunk-7AC2RX4M.ts → chunk-277VHM2P.ts} +2 -2
- package/dist/chunks/chunk-277VHM2P.ts.map +7 -0
- package/dist/chunks/{chunk-4RNCZZY7.ts → chunk-3YXBG7BQ.ts} +14 -10
- package/dist/chunks/{chunk-4RNCZZY7.ts.map → chunk-3YXBG7BQ.ts.map} +2 -2
- package/dist/chunks/{chunk-UBE6XWOM.ts → chunk-6W2SNZ5P.ts} +2 -2
- package/dist/chunks/chunk-6W2SNZ5P.ts.map +7 -0
- package/dist/chunks/{chunk-UZUUUY7C.ts → chunk-B53FS4RW.ts} +4 -4
- package/dist/chunks/{chunk-MIXZVHFR.ts → chunk-E7UJHMNW.ts} +11 -42
- package/dist/chunks/chunk-E7UJHMNW.ts.map +7 -0
- package/dist/chunks/{chunk-JZKCOM62.ts → chunk-EMRFVLZM.ts} +2 -2
- package/dist/chunks/chunk-EMRFVLZM.ts.map +7 -0
- package/dist/chunks/{chunk-BWWTOQOW.ts → chunk-FOMZEZER.ts} +100 -53
- package/dist/chunks/chunk-FOMZEZER.ts.map +7 -0
- package/dist/chunks/{chunk-NPT2G4FU.ts → chunk-HEB6YT64.ts} +2 -2
- package/dist/chunks/chunk-HEB6YT64.ts.map +7 -0
- package/dist/chunks/{chunk-J5COV5TY.ts → chunk-HLCML3OW.ts} +2 -2
- package/dist/chunks/{chunk-J5COV5TY.ts.map → chunk-HLCML3OW.ts.map} +1 -1
- package/dist/chunks/{chunk-ZMNVNECV.ts → chunk-KPWZNMKM.ts} +2 -2
- package/dist/chunks/chunk-KPWZNMKM.ts.map +7 -0
- package/dist/chunks/{chunk-YWEYRRQI.ts → chunk-LAXTCSX4.ts} +11 -11
- package/dist/chunks/chunk-LAXTCSX4.ts.map +7 -0
- package/dist/chunks/{chunk-BGGKHHO4.ts → chunk-MCUZFUHY.ts} +7 -7
- package/dist/chunks/{chunk-M7RHV3H6.ts → chunk-OA4NZLSL.ts} +2 -2
- package/dist/chunks/chunk-OA4NZLSL.ts.map +7 -0
- package/dist/chunks/{chunk-CEMFCWIU.ts → chunk-RNIEVDTR.ts} +2 -2
- package/dist/chunks/chunk-RNIEVDTR.ts.map +7 -0
- package/dist/chunks/{chunk-PDBTD2K6.ts → chunk-S3R3W3KF.ts} +2 -2
- package/dist/chunks/chunk-S3R3W3KF.ts.map +7 -0
- package/dist/chunks/{chunk-CZNBKIM5.ts → chunk-SMVKMYLK.ts} +2 -2
- package/dist/chunks/chunk-SMVKMYLK.ts.map +7 -0
- package/dist/chunks/{chunk-JKBUYCPC.ts → chunk-V4AMI3VL.ts} +2 -2
- package/dist/chunks/chunk-V4AMI3VL.ts.map +7 -0
- package/dist/chunks/{chunk-VZCWYXRS.ts → chunk-WP2M67XZ.ts} +2 -2
- package/dist/chunks/chunk-WP2M67XZ.ts.map +7 -0
- package/dist/chunks/{chunk-HNKLBM3U.ts → chunk-ZIL6PW5L.ts} +2 -2
- package/dist/chunks/chunk-ZIL6PW5L.ts.map +7 -0
- package/dist/chunks/{command-handler-3O76V7Q5.ts → command-handler-RTBEFZUX.ts} +19 -19
- package/dist/chunks/{command-handler-3O76V7Q5.ts.map → command-handler-RTBEFZUX.ts.map} +2 -2
- package/dist/chunks/{conflict-review-XBSME2ER.ts → conflict-review-YXROU42F.ts} +4 -4
- package/dist/chunks/{continuous-record-ZHUXVO4E.ts → continuous-record-3XDXDOMV.ts} +2 -2
- package/dist/chunks/continuous-record-3XDXDOMV.ts.map +7 -0
- package/dist/chunks/continuous-storage-HLKCHF6Z.ts +27 -0
- package/dist/chunks/continuous-storage-HLKCHF6Z.ts.map +7 -0
- package/dist/chunks/{file-selection-S6CNNNQI.ts → file-selection-DD6X4J2K.ts} +6 -6
- package/dist/chunks/manager-result-dispatcher-4PEUHK7F.ts +18 -0
- package/dist/chunks/{manager-ui-SJOBTJLY.ts → manager-ui-TNAMQNEU.ts} +123 -64
- package/dist/chunks/manager-ui-TNAMQNEU.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-GZHPDQ4L.ts → remote-selection-ui-47H7V62F.ts} +8 -8
- package/dist/chunks/{setup-switch-M3BAFGJM.ts → setup-switch-SPZE7HIQ.ts} +8 -8
- package/dist/chunks/{setup-wizard-NFAWP4KF.ts → setup-wizard-5JYKAEIT.ts} +11 -11
- package/dist/chunks/{snapshot-D4SFDP5J.ts → snapshot-5HY3M2NL.ts} +2 -2
- package/dist/chunks/snapshot-5HY3M2NL.ts.map +7 -0
- package/dist/chunks/{snapshot-transaction-directory-TNKBQ3UQ.ts → snapshot-transaction-directory-OU2D7R7A.ts} +2 -2
- package/dist/chunks/snapshot-transaction-directory-OU2D7R7A.ts.map +7 -0
- package/dist/chunks/{state-directory-JZSZVVPX.ts → state-directory-XXHU73Z3.ts} +2 -2
- package/dist/chunks/{sync-inspection-BJ4KPPNO.ts → sync-inspection-5GQEB62G.ts} +5 -5
- package/dist/chunks/sync-inspection-5GQEB62G.ts.map +7 -0
- package/dist/chunks/{sync-operations-TLWER2TT.ts → sync-operations-65HDA67O.ts} +5 -5
- package/dist/chunks/{sync-operations-TLWER2TT.ts.map → sync-operations-65HDA67O.ts.map} +2 -2
- package/dist/chunks/{sync-state-FVCJJ7MY.ts → sync-state-2LMIXJ2C.ts} +2 -2
- package/dist/chunks/sync-state-2LMIXJ2C.ts.map +7 -0
- package/dist/index.ts +22 -22
- package/dist/index.ts.map +1 -1
- package/docs/daemon-migration.md +10 -6
- package/docs/tui-contract.md +12 -0
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +8 -4
- 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 +6 -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 +1 -1
- package/src/commands/command.ts +1 -1
- package/src/daemon/apply-gate.ts +1 -1
- package/src/daemon/pi-client.ts +105 -54
- package/src/daemon/recovery.ts +1 -1
- package/src/paths.ts +2 -2
- 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/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/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/exclude-policy.ts +2 -2
- package/src/sync/field-migration.ts +2 -2
- package/src/sync/file-merge-planner.ts +6 -2
- package/src/sync/json-document.ts +2 -2
- package/src/sync/local-field-policy.ts +2 -2
- package/src/sync/local-fields.ts +2 -2
- 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 +2 -2
- package/src/sync/sync-local.ts +6 -2
- package/src/sync/sync-mutations.ts +2 -2
- package/src/sync/sync-operations.ts +1 -1
- 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/ui/manager-state.ts +35 -23
- package/src/ui/manager-ui.ts +80 -36
- package/src/ui/sync-attention.ts +7 -49
- package/dist/chunks/chunk-7AC2RX4M.ts.map +0 -7
- package/dist/chunks/chunk-BWWTOQOW.ts.map +0 -7
- package/dist/chunks/chunk-CEMFCWIU.ts.map +0 -7
- package/dist/chunks/chunk-CZNBKIM5.ts.map +0 -7
- package/dist/chunks/chunk-HNKLBM3U.ts.map +0 -7
- package/dist/chunks/chunk-JKBUYCPC.ts.map +0 -7
- package/dist/chunks/chunk-JZKCOM62.ts.map +0 -7
- package/dist/chunks/chunk-M7RHV3H6.ts.map +0 -7
- package/dist/chunks/chunk-MIXZVHFR.ts.map +0 -7
- package/dist/chunks/chunk-NPT2G4FU.ts.map +0 -7
- package/dist/chunks/chunk-PDBTD2K6.ts.map +0 -7
- package/dist/chunks/chunk-UBE6XWOM.ts.map +0 -7
- package/dist/chunks/chunk-VZCWYXRS.ts.map +0 -7
- package/dist/chunks/chunk-YWEYRRQI.ts.map +0 -7
- package/dist/chunks/chunk-ZMNVNECV.ts.map +0 -7
- package/dist/chunks/continuous-record-ZHUXVO4E.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-I2AMCCE7.ts +0 -18
- package/dist/chunks/manager-ui-SJOBTJLY.ts.map +0 -7
- package/dist/chunks/snapshot-D4SFDP5J.ts.map +0 -7
- package/dist/chunks/snapshot-transaction-directory-TNKBQ3UQ.ts.map +0 -7
- package/dist/chunks/sync-inspection-BJ4KPPNO.ts.map +0 -7
- package/dist/chunks/sync-state-FVCJJ7MY.ts.map +0 -7
- /package/dist/chunks/{chunk-UZUUUY7C.ts.map → chunk-B53FS4RW.ts.map} +0 -0
- /package/dist/chunks/{chunk-BGGKHHO4.ts.map → chunk-MCUZFUHY.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-XBSME2ER.ts.map → conflict-review-YXROU42F.ts.map} +0 -0
- /package/dist/chunks/{file-selection-S6CNNNQI.ts.map → file-selection-DD6X4J2K.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-I2AMCCE7.ts.map → manager-result-dispatcher-4PEUHK7F.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-GZHPDQ4L.ts.map → remote-selection-ui-47H7V62F.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-M3BAFGJM.ts.map → setup-switch-SPZE7HIQ.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-NFAWP4KF.ts.map → setup-wizard-5JYKAEIT.ts.map} +0 -0
- /package/dist/chunks/{state-directory-JZSZVVPX.ts.map → state-directory-XXHU73Z3.ts.map} +0 -0
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
sameSyncExclude
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HEB6YT64.ts";
|
|
6
6
|
import {
|
|
7
7
|
syncCheckConfigFingerprint,
|
|
8
8
|
syncConfigReviewFingerprint
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-277VHM2P.ts";
|
|
10
10
|
import {
|
|
11
11
|
setSyncStatus
|
|
12
12
|
} from "./chunk-ENFHHB5O.ts";
|
|
@@ -14,9 +14,8 @@ import {
|
|
|
14
14
|
safeTerminalText
|
|
15
15
|
} from "./chunk-2JNFEZ3V.ts";
|
|
16
16
|
import {
|
|
17
|
-
compareSyncInclude,
|
|
18
17
|
sameSyncInclude
|
|
19
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-V4AMI3VL.ts";
|
|
20
19
|
|
|
21
20
|
// src/state/sync-state-store.ts
|
|
22
21
|
import {
|
|
@@ -28,7 +27,7 @@ import {
|
|
|
28
27
|
syncStateFingerprint,
|
|
29
28
|
writeState,
|
|
30
29
|
writeStateForConfig
|
|
31
|
-
} from "@narumitw/sync-daemon/engine/state/sync-state-store";
|
|
30
|
+
} from "@narumitw/pi-sync-daemon/engine/state/sync-state-store";
|
|
32
31
|
|
|
33
32
|
// src/ui/sync-attention.ts
|
|
34
33
|
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
@@ -100,10 +99,10 @@ function createSyncAttentionController() {
|
|
|
100
99
|
});
|
|
101
100
|
return;
|
|
102
101
|
}
|
|
103
|
-
const
|
|
102
|
+
const setupName = safeTerminalText(state?.decision.setupName ?? observation?.setupName ?? "");
|
|
104
103
|
if (ctx.mode !== "tui") {
|
|
105
104
|
ctx.ui.setWidget(WIDGET_KEY, void 0);
|
|
106
|
-
setSyncStatus(ctx,
|
|
105
|
+
setSyncStatus(ctx, "sync \u21D5", { activity: "review" });
|
|
107
106
|
return;
|
|
108
107
|
}
|
|
109
108
|
const { EditorStatusWidget } = await import("./attention-widget-Z7G3SYYJ.ts").catch((error) => {
|
|
@@ -111,7 +110,7 @@ function createSyncAttentionController() {
|
|
|
111
110
|
throw error;
|
|
112
111
|
});
|
|
113
112
|
if (generation !== currentGeneration || signal?.aborted) return;
|
|
114
|
-
setSyncStatus(ctx,
|
|
113
|
+
setSyncStatus(ctx, "sync \u21D5", { activity: "review" });
|
|
115
114
|
const presentationState = widgetState;
|
|
116
115
|
ctx.ui.setWidget(
|
|
117
116
|
WIDGET_KEY,
|
|
@@ -120,44 +119,14 @@ function createSyncAttentionController() {
|
|
|
120
119
|
name: "Sync",
|
|
121
120
|
summary: "Needs review",
|
|
122
121
|
state: presentationState,
|
|
123
|
-
renderBody: (width) =>
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
renderBody: (width) => [
|
|
123
|
+
width === 0 ? "" : truncateToWidth(theme.fg("muted", `Open /sync to review \xB7 ${setupName}`), width, "\u2026")
|
|
124
|
+
]
|
|
126
125
|
})
|
|
127
126
|
);
|
|
128
127
|
}
|
|
129
128
|
};
|
|
130
129
|
}
|
|
131
|
-
function attentionPresentation(decision) {
|
|
132
|
-
const setupName = safeTerminalText(decision.setupName);
|
|
133
|
-
const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude);
|
|
134
|
-
return {
|
|
135
|
-
status: "sync \u21D5",
|
|
136
|
-
lines: [
|
|
137
|
-
`Setup: ${setupName}`,
|
|
138
|
-
selectionDifference({
|
|
139
|
-
...comparison,
|
|
140
|
-
excludeChanged: !sameSyncExclude(decision.localExclude, decision.remoteExclude)
|
|
141
|
-
}),
|
|
142
|
-
"No transfer performed \xB7 Run /sync to review"
|
|
143
|
-
]
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
function selectionDifference(comparison) {
|
|
147
|
-
if (comparison.excludeChanged) return "Selection: excluded paths differ; review needed";
|
|
148
|
-
return comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0 ? "Selection: only list order differs" : `Selection: ${comparison.remoteOnly.length} remote-only \xB7 ${comparison.localOnly.length} device-only`;
|
|
149
|
-
}
|
|
150
|
-
function observationPresentation(observation) {
|
|
151
|
-
const selection = observation.inspection.selectionState;
|
|
152
|
-
return {
|
|
153
|
-
status: "sync \u21D5",
|
|
154
|
-
lines: [
|
|
155
|
-
`Setup: ${safeTerminalText(observation.setupName)}`,
|
|
156
|
-
selection?.kind === "different" ? selectionDifference(selection) : observationSummary(observation),
|
|
157
|
-
"No transfer performed \xB7 Run /sync to review"
|
|
158
|
-
]
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
130
|
function observationMatchesConfig(observation, config) {
|
|
162
131
|
return observation.configIdentity === syncCheckConfigFingerprint(config);
|
|
163
132
|
}
|
|
@@ -210,4 +179,4 @@ export {
|
|
|
210
179
|
observationMatchesConfig,
|
|
211
180
|
observationSummary
|
|
212
181
|
};
|
|
213
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-E7UJHMNW.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/state/sync-state-store.ts", "../../src/ui/sync-attention.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", "import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { truncateToWidth } from \"@earendil-works/pi-tui\";\nimport type { EditorStatusWidgetState } from \"@narumitw/pi-tui-kit/editor-status-widget\";\nimport { syncCheckConfigFingerprint, syncConfigReviewFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { sameSyncExclude } from \"../sync/exclude-policy.js\";\nimport type { StartupObservation } from \"../sync/sync-inspection.js\";\nimport { type RemoteSelectionDecision, sameSyncInclude } from \"../sync/sync-policy.js\";\nimport { setSyncStatus } from \"./sync-status.js\";\nimport { safeTerminalText } from \"./terminal-text.js\";\n\nconst WIDGET_KEY = \"sync:attention\";\n\nexport type SyncAttentionOrigin = \"sync\" | \"pull\" | \"push\";\n\nexport interface SyncAttentionState {\n decision: RemoteSelectionDecision;\n origin: SyncAttentionOrigin;\n offered: boolean;\n}\n\nexport function syncAttentionMatchesConfig(attention: SyncAttentionState, config: AnySyncConfig) {\n return (\n attention.decision.setupName === config.setupName &&\n attention.decision.configIdentity === syncConfigReviewFingerprint(config) &&\n sameSyncInclude(attention.decision.localInclude, config.include) &&\n sameSyncExclude(attention.decision.localExclude, config.exclude)\n );\n}\n\nexport interface SyncAttentionController {\n observe(observation: StartupObservation): void;\n observation(): StartupObservation | undefined;\n clearObservation(): void;\n notifyObservation(ctx: ExtensionContext): void;\n set(decision: RemoteSelectionDecision, origin: SyncAttentionOrigin): void;\n current(): SyncAttentionState | undefined;\n markOffered(): boolean;\n clear(ctx: ExtensionContext): void;\n reset(ctx: ExtensionContext): void;\n expand(): void;\n publish(ctx: ExtensionContext, signal?: AbortSignal): Promise<void>;\n}\n\nexport function createSyncAttentionController(): SyncAttentionController {\n let state: SyncAttentionState | undefined;\n let observation: StartupObservation | undefined;\n let generation = 0;\n let widgetState: EditorStatusWidgetState = { collapsed: false };\n\n return {\n observe(value) {\n generation++;\n observation = value;\n },\n observation() {\n return observation;\n },\n clearObservation() {\n generation++;\n observation = undefined;\n },\n notifyObservation(ctx) {\n if (ctx.hasUI && observation && observationNeedsAttention(observation)) {\n ctx.ui.notify(observationLines(observation).join(\"\\n\"), \"warning\");\n }\n },\n set(decision, origin) {\n generation++;\n state = { decision, origin, offered: false };\n },\n current() {\n return state;\n },\n markOffered() {\n if (!state || state.offered) return false;\n state = { ...state, offered: true };\n return true;\n },\n clear(ctx) {\n generation++;\n state = undefined;\n clearAttentionPresentation(ctx);\n },\n reset(ctx) {\n generation++;\n state = undefined;\n observation = undefined;\n widgetState = { collapsed: false };\n clearAttentionPresentation(ctx);\n },\n expand() {\n widgetState.collapsed = false;\n },\n async publish(ctx, signal) {\n const currentGeneration = ++generation;\n if (signal?.aborted || !ctx.hasUI) return;\n const classification = observation ? classifyObservation(observation) : \"none\";\n if (!state && (classification === \"none\" || classification === \"guidance\")) {\n clearAttentionPresentation(ctx);\n return;\n }\n if (!state && classification === \"status\") {\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n setSyncStatus(ctx, observation?.inspection.remoteChanged ? \"sync \u21E3\" : \"sync \u21E1\", {\n activity: observation?.inspection.remoteChanged ? \"remote-change\" : \"local-change\",\n });\n return;\n }\n const setupName = safeTerminalText(state?.decision.setupName ?? observation?.setupName ?? \"\");\n if (ctx.mode !== \"tui\") {\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n setSyncStatus(ctx, \"sync \u21D5\", { activity: \"review\" });\n return;\n }\n // Keep Kit outside the eager startup graph; module loading owns no cancellable resources.\n const { EditorStatusWidget } = await import(\"./attention-widget.js\").catch((error) => {\n if (generation === currentGeneration && !signal?.aborted) clearAttentionPresentation(ctx);\n throw error;\n });\n if (generation !== currentGeneration || signal?.aborted) return;\n setSyncStatus(ctx, \"sync \u21D5\", { activity: \"review\" });\n const presentationState = widgetState;\n ctx.ui.setWidget(\n WIDGET_KEY,\n (_tui, theme) =>\n new EditorStatusWidget({\n theme,\n name: \"Sync\",\n summary: \"Needs review\",\n state: presentationState,\n renderBody: (width) => [\n width === 0 ? \"\" : truncateToWidth(theme.fg(\"muted\", `Open /sync to review \u00B7 ${setupName}`), width, \"\u2026\"),\n ],\n }),\n );\n },\n };\n}\n\nexport function observationMatchesConfig(observation: StartupObservation, config: AnySyncConfig) {\n return observation.configIdentity === syncCheckConfigFingerprint(config);\n}\n\nexport function observationSummary(observation: StartupObservation) {\n const result = observation.inspection;\n if (result.emptyInclude) return \"No included content selected\";\n if (result.selectionState?.kind === \"different\") return \"Synced-content list differs; review needed\";\n if (result.firstSync)\n return result.head ? \"No sync baseline; review remote and local content\" : \"Remote empty; no sync baseline\";\n if (!result.head) return \"Remote snapshot missing; review needed\";\n if (observation.automaticTransfer && result.selectionState?.kind === \"legacy\")\n return \"Legacy remote has no authoritative content list; review /sync and choose an explicit direction to adopt policy\";\n if (result.localChanged && result.remoteChanged) return \"Local and remote changed since last sync; review needed\";\n if (result.remoteChanged) return \"Remote changed since last sync\";\n if (result.localChanged) return \"Local content changed since last sync\";\n if (result.selectionState?.kind === \"legacy\") return \"Legacy remote has no authoritative content list\";\n return \"No changes detected since last sync\";\n}\n\nexport type ObservationClassification = \"none\" | \"guidance\" | \"status\" | \"review\";\n\n/** Presentation only: never discard an observation or authorize a transfer here. */\nexport function classifyObservation(observation: StartupObservation): ObservationClassification {\n const result = observation.inspection;\n // Sync now exits before reading remote content when nothing is selected.\n if (result.emptyInclude) return \"guidance\";\n // Ordering is part of the existing transfer policy, not merely display order.\n if (result.selectionState?.kind === \"different\") return \"review\";\n if (result.firstSync) return result.head ? \"review\" : \"guidance\";\n if (!result.head || (result.localChanged && result.remoteChanged)) return \"review\";\n if (observation.automaticTransfer && result.selectionState?.kind === \"legacy\") return \"review\";\n if (result.localChanged || result.remoteChanged) return \"status\";\n // Legacy metadata alone requires no scope confirmation in transfer operations.\n return \"none\";\n}\n\nexport function observationNeedsAttention(observation: StartupObservation) {\n return classifyObservation(observation) === \"review\";\n}\n\nfunction observationLines(observation: StartupObservation) {\n return [\n `Pi Sync check \u00B7 ${safeTerminalText(observation.setupName)}`,\n observationSummary(observation),\n \"No startup transfer \u00B7 Run /sync to review\",\n ];\n}\n\nfunction clearAttentionPresentation(ctx: ExtensionContext) {\n if (!ctx.hasUI) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.setWidget(WIDGET_KEY, undefined);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;;;ACTP,SAAS,uBAAuB;AAUhC,IAAM,aAAa;AAUZ,SAAS,2BAA2B,WAA+B,QAAuB;AAC/F,SACE,UAAU,SAAS,cAAc,OAAO,aACxC,UAAU,SAAS,mBAAmB,4BAA4B,MAAM,KACxE,gBAAgB,UAAU,SAAS,cAAc,OAAO,OAAO,KAC/D,gBAAgB,UAAU,SAAS,cAAc,OAAO,OAAO;AAEnE;AAgBO,SAAS,gCAAyD;AACvE,MAAI;AACJ,MAAI;AACJ,MAAI,aAAa;AACjB,MAAI,cAAuC,EAAE,WAAW,MAAM;AAE9D,SAAO;AAAA,IACL,QAAQ,OAAO;AACb;AACA,oBAAc;AAAA,IAChB;AAAA,IACA,cAAc;AACZ,aAAO;AAAA,IACT;AAAA,IACA,mBAAmB;AACjB;AACA,oBAAc;AAAA,IAChB;AAAA,I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AS,YAAY;AAE3B,MAAI,OAAO,aAAc,QAAO;AAEhC,MAAI,OAAO,gBAAgB,SAAS,YAAa,QAAO;AACxD,MAAI,OAAO,UAAW,QAAO,OAAO,OAAO,WAAW;AACtD,MAAI,CAAC,OAAO,QAAS,OAAO,gBAAgB,OAAO,cAAgB,QAAO;AAC1E,MAAI,YAAY,qBAAqB,OAAO,gBAAgB,SAAS,SAAU,QAAO;AACtF,MAAI,OAAO,gBAAgB,OAAO,cAAe,QAAO;AAExD,SAAO;AACT;AAEO,SAAS,0BAA0B,aAAiC;AACzE,SAAO,oBAAoB,WAAW,MAAM;AAC9C;AAEA,SAAS,iBAAiB,aAAiC;AACzD,SAAO;AAAA,IACL,sBAAmB,iBAAiB,YAAY,SAAS,CAAC;AAAA,IAC1D,mBAAmB,WAAW;AAAA,IAC9B;AAAA,EACF;AACF;AAEA,SAAS,2BAA2B,KAAuB;AACzD,MAAI,CAAC,IAAI,MAAO;AAChB,gBAAc,KAAK,MAAS;AAC5B,MAAI,GAAG,UAAU,YAAY,MAAS;AACxC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
saveNewV3Settings,
|
|
12
12
|
updateStorageConnection,
|
|
13
13
|
updateSyncSetup
|
|
14
|
-
} from "@narumitw/sync-daemon/engine/settings/settings-management";
|
|
14
|
+
} from "@narumitw/pi-sync-daemon/engine/settings/settings-management";
|
|
15
15
|
|
|
16
16
|
export {
|
|
17
17
|
addStorageConnection,
|
|
@@ -23,4 +23,4 @@ export {
|
|
|
23
23
|
updateStorageConnection,
|
|
24
24
|
updateSyncSetup
|
|
25
25
|
};
|
|
26
|
-
//# sourceMappingURL=chunk-
|
|
26
|
+
//# sourceMappingURL=chunk-EMRFVLZM.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/settings/settings-management.ts"],
|
|
4
|
+
"sourcesContent": ["export type * from \"@narumitw/pi-sync-daemon/engine/settings/settings-management\";\nexport {\n addStorageConnection,\n addSyncSetup,\n removeStorageConnection,\n removeSyncSetup,\n SyncSetupReviewChangedError,\n saveNewV3Settings,\n updateStorageConnection,\n updateSyncSetup,\n} from \"@narumitw/pi-sync-daemon/engine/settings/settings-management\";\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
|
+
}
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
} from "./chunk-ENFHHB5O.ts";
|
|
6
6
|
import {
|
|
7
7
|
SyncDecisionRequiredError
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-ZIL6PW5L.ts";
|
|
9
9
|
import {
|
|
10
10
|
safeTerminalText
|
|
11
11
|
} from "./chunk-2JNFEZ3V.ts";
|
|
12
12
|
import {
|
|
13
13
|
RemoteSelectionMismatchError
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-V4AMI3VL.ts";
|
|
15
15
|
|
|
16
16
|
// src/daemon/pi-client.ts
|
|
17
17
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -27,18 +27,21 @@ import {
|
|
|
27
27
|
ensureDaemon,
|
|
28
28
|
findDaemon as findDaemon2,
|
|
29
29
|
MAX_SETTINGS_BYTES,
|
|
30
|
-
modelSignature
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
|
|
30
|
+
modelSignature,
|
|
31
|
+
waitForDaemonExit
|
|
32
|
+
} from "@narumitw/pi-sync-daemon";
|
|
33
|
+
import { configureEngineHost } from "@narumitw/pi-sync-daemon/engine/host";
|
|
34
|
+
import {
|
|
35
|
+
peekLocalConfigDocument
|
|
36
|
+
} from "@narumitw/pi-sync-daemon/engine/settings/config-file";
|
|
37
|
+
import { validateSettingsDocument } from "@narumitw/pi-sync-daemon/engine/settings/settings-validation";
|
|
38
|
+
import { sessionDirFromContext } from "@narumitw/pi-sync-daemon/engine/snapshot/session-paths";
|
|
36
39
|
|
|
37
40
|
// src/daemon/apply-gate.ts
|
|
38
41
|
import { randomUUID } from "node:crypto";
|
|
39
42
|
import path from "node:path";
|
|
40
43
|
import { withFileMutationQueue } from "@earendil-works/pi-coding-agent";
|
|
41
|
-
import { withTargetQueues } from "@narumitw/sync-daemon/engine/snapshot/snapshot-mutation-queues";
|
|
44
|
+
import { withTargetQueues } from "@narumitw/pi-sync-daemon/engine/snapshot/snapshot-mutation-queues";
|
|
42
45
|
var PiApplyGate = class {
|
|
43
46
|
constructor(validate) {
|
|
44
47
|
this.validate = validate;
|
|
@@ -162,7 +165,7 @@ var PiApplyGate = class {
|
|
|
162
165
|
};
|
|
163
166
|
|
|
164
167
|
// src/daemon/recovery.ts
|
|
165
|
-
import { DaemonConnection, findDaemon } from "@narumitw/sync-daemon";
|
|
168
|
+
import { DaemonConnection, findDaemon } from "@narumitw/pi-sync-daemon";
|
|
166
169
|
var recoveries = /* @__PURE__ */ new Set();
|
|
167
170
|
function alive(pid) {
|
|
168
171
|
try {
|
|
@@ -319,7 +322,7 @@ function installPiDaemonHost() {
|
|
|
319
322
|
root: () => scope.getStore()?.root ?? path2.resolve(getAgentDir()),
|
|
320
323
|
config: authority,
|
|
321
324
|
mutate: async () => {
|
|
322
|
-
throw new Error("File mutation belongs to sync-daemon; no in-process fallback is permitted.");
|
|
325
|
+
throw new Error("File mutation belongs to pi-sync-daemon; no in-process fallback is permitted.");
|
|
323
326
|
},
|
|
324
327
|
review: async () => {
|
|
325
328
|
throw new Error("Engine reviews must arrive through the daemon API.");
|
|
@@ -421,8 +424,13 @@ var PiDaemonClient = class {
|
|
|
421
424
|
busy = /* @__PURE__ */ new Set();
|
|
422
425
|
initialized = false;
|
|
423
426
|
startupDebug = false;
|
|
424
|
-
|
|
425
|
-
|
|
427
|
+
participantIdentity = { id: randomUUID2(), generation: randomUUID2() };
|
|
428
|
+
get id() {
|
|
429
|
+
return this.participantIdentity.id;
|
|
430
|
+
}
|
|
431
|
+
get generation() {
|
|
432
|
+
return this.participantIdentity.generation;
|
|
433
|
+
}
|
|
426
434
|
root;
|
|
427
435
|
rawRoot;
|
|
428
436
|
gate;
|
|
@@ -488,7 +496,15 @@ var PiDaemonClient = class {
|
|
|
488
496
|
this.validate();
|
|
489
497
|
const address = await findDaemon2(this.root);
|
|
490
498
|
this.validate();
|
|
491
|
-
if (address)
|
|
499
|
+
if (address) {
|
|
500
|
+
try {
|
|
501
|
+
await this.connect(address);
|
|
502
|
+
} catch (error) {
|
|
503
|
+
this.validate();
|
|
504
|
+
if (error instanceof DaemonError && error.remote.name === "DaemonStoppingError") return false;
|
|
505
|
+
throw error;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
492
508
|
this.validate();
|
|
493
509
|
return Boolean(address);
|
|
494
510
|
}
|
|
@@ -497,52 +513,83 @@ var PiDaemonClient = class {
|
|
|
497
513
|
if (this.connection) {
|
|
498
514
|
await recoverDetachedClients({ paths: this.connection.paths, identity: this.connection.identity });
|
|
499
515
|
this.validate();
|
|
500
|
-
await this.connection.attach();
|
|
516
|
+
await this.connection.attach(this.signal);
|
|
501
517
|
this.validate();
|
|
502
518
|
}
|
|
503
519
|
}
|
|
504
|
-
async connect(existing) {
|
|
505
|
-
this.
|
|
520
|
+
async connect(existing, requestSignal) {
|
|
521
|
+
const startupSignal = requestSignal ? AbortSignal.any([this.signal, requestSignal]) : this.signal;
|
|
522
|
+
const validateStartup = () => {
|
|
523
|
+
this.validate();
|
|
524
|
+
startupSignal.throwIfAborted();
|
|
525
|
+
};
|
|
526
|
+
validateStartup();
|
|
506
527
|
if (this.connection) return this.connection;
|
|
507
528
|
this.connecting ??= (async () => {
|
|
529
|
+
if (this.partialConnection) {
|
|
530
|
+
await this.partialConnection.dispose();
|
|
531
|
+
await this.gate.releaseAfterDrain();
|
|
532
|
+
validateStartup();
|
|
533
|
+
this.partialConnection = void 0;
|
|
534
|
+
this.participantIdentity = { id: randomUUID2(), generation: randomUUID2() };
|
|
535
|
+
}
|
|
508
536
|
if (!existing) await fs.mkdir(this.root, { recursive: true, mode: 448 });
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
this.
|
|
521
|
-
|
|
522
|
-
|
|
537
|
+
validateStartup();
|
|
538
|
+
let retried = false;
|
|
539
|
+
for (; ; ) {
|
|
540
|
+
validateStartup();
|
|
541
|
+
const daemon = existing ?? await ensureDaemon(this.root, startupSignal);
|
|
542
|
+
validateStartup();
|
|
543
|
+
if (daemon.paths.root !== this.root) throw new Error("Daemon root changed before attach.");
|
|
544
|
+
const connection = new DaemonConnection2(daemon.paths, daemon.identity, this.facts(), {
|
|
545
|
+
callback: (callback, signal) => this.callback(callback, signal),
|
|
546
|
+
event: (event) => {
|
|
547
|
+
if (event.kind === "commit") return;
|
|
548
|
+
if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;
|
|
549
|
+
const payload = event.payload;
|
|
550
|
+
if (event.kind === "notify" && typeof payload?.message === "string")
|
|
551
|
+
this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? "info");
|
|
552
|
+
if (event.kind === "timings" && typeof event.payload?.report === "string") {
|
|
553
|
+
this.publish?.(this.ctx, safeTerminalText(event.payload.report));
|
|
554
|
+
}
|
|
555
|
+
if (event.kind === "status")
|
|
556
|
+
setSyncStatus(
|
|
557
|
+
this.uiContext,
|
|
558
|
+
typeof payload?.value === "string" ? safeTerminalText(payload.value) : void 0,
|
|
559
|
+
payload.presentation
|
|
560
|
+
);
|
|
561
|
+
},
|
|
562
|
+
error: () => {
|
|
563
|
+
if (!this.signal.aborted && !this.disposed && !this.closing && clients.get(this.manager) === this)
|
|
564
|
+
setSyncStatus(this.ctx, "sync service unavailable", { activity: "blocked", reason: "repair" });
|
|
523
565
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
566
|
+
});
|
|
567
|
+
this.partialConnection = connection;
|
|
568
|
+
try {
|
|
569
|
+
await connection.attach(startupSignal);
|
|
570
|
+
} catch (error) {
|
|
571
|
+
if (!(error instanceof DaemonError) || error.remote.name !== "DaemonStoppingError") throw error;
|
|
572
|
+
await connection.dispose().catch(() => {
|
|
573
|
+
});
|
|
574
|
+
this.partialConnection = void 0;
|
|
575
|
+
validateStartup();
|
|
576
|
+
if (existing || retried) throw error;
|
|
577
|
+
retried = true;
|
|
578
|
+
await waitForDaemonExit(daemon.identity, startupSignal);
|
|
579
|
+
validateStartup();
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
this.validate();
|
|
583
|
+
await recoverDetachedClients(daemon);
|
|
584
|
+
if (this.signal.aborted || this.disposed || this.closing) {
|
|
585
|
+
await connection.dispose();
|
|
586
|
+
this.validate();
|
|
534
587
|
}
|
|
535
|
-
});
|
|
536
|
-
this.partialConnection = connection;
|
|
537
|
-
await connection.attach();
|
|
538
|
-
this.validate();
|
|
539
|
-
await recoverDetachedClients(daemon);
|
|
540
|
-
if (this.signal.aborted || this.disposed || this.closing) {
|
|
541
|
-
await connection.dispose();
|
|
542
588
|
this.validate();
|
|
589
|
+
this.connection = connection;
|
|
590
|
+
this.partialConnection = void 0;
|
|
591
|
+
return connection;
|
|
543
592
|
}
|
|
544
|
-
this.connection = connection;
|
|
545
|
-
return connection;
|
|
546
593
|
})().catch((error) => {
|
|
547
594
|
this.connecting = void 0;
|
|
548
595
|
throw error;
|
|
@@ -576,10 +623,10 @@ var PiDaemonClient = class {
|
|
|
576
623
|
signal?.throwIfAborted();
|
|
577
624
|
if (this.paused && operation !== "shutdown")
|
|
578
625
|
throw new Error("Synchronization is paused for a session change; if it was cancelled, use /reload to reattach.");
|
|
579
|
-
const connection = await this.connect();
|
|
626
|
+
const connection = await this.connect(void 0, signal);
|
|
580
627
|
if (this.paused && operation === "shutdown") {
|
|
581
628
|
Object.assign(connection.facts, { ...this.facts(), idle: false, ready: false });
|
|
582
|
-
await connection.attach();
|
|
629
|
+
await connection.attach(signal ? AbortSignal.any([signal, this.signal]) : this.signal);
|
|
583
630
|
this.validate();
|
|
584
631
|
}
|
|
585
632
|
this.validate();
|
|
@@ -734,4 +781,4 @@ export {
|
|
|
734
781
|
withPiDaemonClient,
|
|
735
782
|
remoteOperation
|
|
736
783
|
};
|
|
737
|
-
//# sourceMappingURL=chunk-
|
|
784
|
+
//# sourceMappingURL=chunk-FOMZEZER.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/daemon/pi-client.ts", "../../src/daemon/apply-gate.ts", "../../src/daemon/recovery.ts"],
|
|
4
|
+
"sourcesContent": ["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport { realpathSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type ExtensionContext, getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport {\n type Callback,\n type ClientFacts,\n type ClientHandoff,\n DaemonConnection,\n DaemonError,\n type DocumentView,\n documentFingerprint,\n ensureDaemon,\n findDaemon,\n MAX_SETTINGS_BYTES,\n modelSignature,\n waitForDaemonExit,\n} from \"@narumitw/pi-sync-daemon\";\nimport { type ConfigAuthority, configureEngineHost } from \"@narumitw/pi-sync-daemon/engine/host\";\nimport {\n type LocalConfigDocument,\n peekLocalConfigDocument,\n} from \"@narumitw/pi-sync-daemon/engine/settings/config-file\";\nimport { validateSettingsDocument } from \"@narumitw/pi-sync-daemon/engine/settings/settings-validation\";\nimport { sessionDirFromContext } from \"@narumitw/pi-sync-daemon/engine/snapshot/session-paths\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { StartupTimingPublisher } from \"../sync/startup-timings.js\";\nimport { SyncDecisionRequiredError } from \"../sync/sync-errors.js\";\nimport { RemoteSelectionMismatchError } from \"../sync/sync-policy.js\";\nimport { type SyncStatusPresentation, setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { PiApplyGate } from \"./apply-gate.js\";\nimport { quarantineClient, recoverDetachedClients } from \"./recovery.js\";\n\nconst scope = new AsyncLocalStorage<PiDaemonClient>();\nconst clients = new WeakMap<ExtensionContext[\"sessionManager\"], PiDaemonClient>();\nexport function currentPiDaemonClient() {\n return current();\n}\nfunction current() {\n const client = scope.getStore();\n if (!client) throw new Error(\"Pi synchronization requires a current session-bound daemon client.\");\n client.validate();\n return client;\n}\nfunction canonicalPath(value: string | undefined): string | undefined {\n if (value === undefined) return undefined;\n if (!path.isAbsolute(value)) throw new Error(\"Pi session paths must be absolute.\");\n const parts: string[] = [];\n let cursor = path.resolve(value);\n for (;;) {\n try {\n return path.join(realpathSync(cursor), ...parts.toReversed());\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\" || path.dirname(cursor) === cursor) throw error;\n parts.push(path.basename(cursor));\n cursor = path.dirname(cursor);\n }\n }\n}\nfunction decode(value: unknown): LocalConfigDocument | undefined {\n if (value === null) return undefined;\n const document = value as DocumentView;\n if (\n !document ||\n typeof document.path !== \"string\" ||\n typeof document.bytes !== \"string\" ||\n !document.identity ||\n !document.parsed\n )\n throw new Error(\"Invalid settings response.\");\n return { ...document, bytes: Buffer.from(document.bytes, \"base64\") };\n}\nfunction fingerprint(document: LocalConfigDocument | undefined) {\n return documentFingerprint(\n document ? { bytes: document.bytes.toString(\"base64\"), identity: document.identity } : undefined,\n );\n}\nlet settingsQueue = Promise.resolve();\nconst authority: ConfigAuthority = {\n read: (repair) => {\n const client = current();\n return settingsQueue.then(() => {\n client.validate();\n return client.readSettings(repair);\n });\n },\n update: <T extends Record<string, unknown>>(\n fallback: T,\n update: (value: T) => T,\n validate: (value: Record<string, unknown>) => void,\n signal?: AbortSignal,\n ): Promise<T> => {\n const client = current();\n // Capture ownership and invocation order before prerequisite awaits.\n const operation = settingsQueue.then(async () => {\n client.validate();\n signal?.throwIfAborted();\n const document = await client.readSettings(true);\n client.validate();\n signal?.throwIfAborted();\n const next = update(structuredClone(document?.parsed ?? fallback) as T);\n validate(next);\n await client.run(\"settings.cas\", { expected: fingerprint(document), next }, signal);\n client.validate();\n return next;\n });\n settingsQueue = operation.then(\n () => undefined,\n () => undefined,\n );\n return operation;\n },\n create: async (next, signal) => {\n await current().run(\"settings.cas\", { expected: null, next }, signal);\n },\n replace: async (document, next) => {\n await current().run(\"settings.cas\", { expected: fingerprint(document), next });\n },\n};\n/** Factory registration installs only adapters; it starts no process and performs no I/O. */\nexport function installPiDaemonHost() {\n configureEngineHost({\n root: () => scope.getStore()?.root ?? path.resolve(getAgentDir()),\n config: authority,\n mutate: async () => {\n throw new Error(\"File mutation belongs to pi-sync-daemon; no in-process fallback is permitted.\");\n },\n review: async () => {\n throw new Error(\"Engine reviews must arrive through the daemon API.\");\n },\n });\n}\nexport function bindPiDaemonClient(ctx: ExtensionContext, signal: AbortSignal, publish?: StartupTimingPublisher) {\n const client = new PiDaemonClient(ctx, signal, publish);\n clients.set(ctx.sessionManager, client);\n return client;\n}\nexport function piDaemonClient(ctx: ExtensionContext) {\n const client = clients.get(ctx.sessionManager);\n if (!client) throw new Error(\"The Pi synchronization client is not attached to this session.\");\n client.validate();\n return client;\n}\nexport function withPiDaemonClient<Context extends ExtensionContext, T>(\n ctx: Context,\n action: (owned: Context) => Promise<T>,\n) {\n const client = piDaemonClient(ctx);\n // TUI input arrives from Pi's event loop, outside the command's async call tree.\n // Bind public component methods so later menu actions retain this exact owner,\n // never a replacement session selected through a global fallback.\n const ui = new Proxy(ctx.ui, {\n get(target, property) {\n if (property !== \"custom\") return Reflect.get(target, property, target);\n return (...args: Parameters<ExtensionContext[\"ui\"][\"custom\"]>) => {\n const [factory, options] = args;\n const wrap = (component: Awaited<ReturnType<typeof factory>>) => {\n const methods = new Map<PropertyKey, { source: unknown; bound: unknown }>();\n return new Proxy(component, {\n get(original, key) {\n const value: unknown = Reflect.get(original, key, original);\n if (typeof value !== \"function\") return value;\n const saved = methods.get(key);\n if (saved?.source === value) return saved.bound;\n const bound = (...values: unknown[]) => scope.run(client, () => Reflect.apply(value, original, values));\n methods.set(key, { source: value, bound });\n return bound;\n },\n });\n };\n const invoke = (...provided: Parameters<typeof factory>) => {\n const component = scope.run(client, () => factory(...provided));\n return component instanceof Promise ? component.then(wrap) : wrap(component);\n };\n // Do not turn synchronous editors/reviews into asynchronous factories.\n return target.custom(\n factory.constructor.name === \"AsyncFunction\" ? async (...provided) => invoke(...provided) : invoke,\n options,\n );\n };\n },\n });\n const owned = new Proxy(ctx, {\n get(target, key) {\n return key === \"ui\" ? ui : Reflect.get(target, key, target);\n },\n });\n return scope.run(client, () => action(owned));\n}\nexport async function remoteOperation(ctx: ExtensionContext, operation: string, options: CommandOptions) {\n const client = piDaemonClient(ctx);\n const { signal, onCommit, args, setup } = options;\n const payload = {\n args,\n ...(setup === undefined ? {} : { setup }),\n yes: options.yes,\n force: options.force,\n stale: options.stale,\n silent: options.silent,\n reload: options.reload,\n ...(options.agentRetryRefusal ? { agentRetryRefusal: true } : {}),\n };\n return client.run(operation, payload, signal, ctx, onCommit);\n}\nexport class PiDaemonClient {\n private connection?: DaemonConnection;\n private partialConnection?: DaemonConnection;\n private work = Promise.resolve();\n private closing = false;\n private paused = false;\n private pausing?: Promise<void>;\n private connecting?: Promise<DaemonConnection>;\n private disposed = false;\n private disposing?: Promise<void>;\n private uiContext: ExtensionContext;\n private reloadRequested = false;\n private readonly busy = new Set<string>();\n private initialized = false;\n private startupDebug = false;\n private participantIdentity = { id: randomUUID(), generation: randomUUID() };\n get id() {\n return this.participantIdentity.id;\n }\n get generation() {\n return this.participantIdentity.generation;\n }\n readonly root: string;\n private readonly rawRoot: string;\n private readonly gate: PiApplyGate;\n private readonly manager: ExtensionContext[\"sessionManager\"];\n constructor(\n private readonly ctx: ExtensionContext,\n private readonly signal: AbortSignal,\n private readonly publish?: StartupTimingPublisher,\n ) {\n this.uiContext = ctx;\n this.manager = ctx.sessionManager;\n this.rawRoot = getAgentDir();\n const root = canonicalPath(path.resolve(this.rawRoot));\n if (!root) throw new Error(\"Agent directory is unavailable.\");\n this.root = root;\n this.gate = new PiApplyGate(() => this.validate());\n }\n validate() {\n this.signal.throwIfAborted();\n if (this.disposed || this.closing || clients.get(this.manager) !== this)\n throw new Error(\"Synchronization session was replaced.\");\n // Public context access verifies the SDK runner is still active after awaits.\n this.ctx.isIdle();\n if (getAgentDir() !== this.rawRoot || canonicalPath(path.resolve(this.rawRoot)) !== this.root)\n throw new Error(\"Agent directory changed; reload before synchronization.\");\n }\n private modelBinding(): ClientFacts[\"model\"] {\n const model = this.ctx.model;\n if (!model) return undefined;\n const registry = this.ctx.modelRegistry;\n if (registry.getRegisteredProviderIds().includes(model.provider)) return undefined;\n const source = registry.getProviderAuthStatus(model.provider).source;\n if (\n source !== \"stored\" &&\n source !== \"environment\" &&\n source !== \"models_json_key\" &&\n source !== \"models_json_command\"\n )\n return undefined;\n return { provider: model.provider, id: model.id, signature: modelSignature(model), authSource: source };\n }\n private facts(): ClientFacts {\n const manager = this.ctx.sessionManager;\n return {\n id: this.id,\n generation: this.generation,\n pid: process.pid,\n cwd: this.ctx.cwd,\n mode: this.ctx.mode,\n hasUI: this.ctx.hasUI,\n idle: !this.paused && !this.busy.size && this.ctx.isIdle(),\n ready: this.initialized,\n startupDebug: this.startupDebug,\n sessionFile: canonicalPath(manager.getSessionFile?.()),\n sessionId: manager.getSessionId?.(),\n sessionDir: canonicalPath(sessionDirFromContext(this.ctx)),\n model: this.modelBinding(),\n };\n }\n async configured() {\n this.validate();\n await settingsQueue;\n this.validate();\n const document = await peekLocalConfigDocument();\n this.validate();\n return Boolean(document && validateSettingsDocument(document.parsed).activeSyncSetup);\n }\n async pauseForSessionChange() {\n this.validate();\n this.paused = true;\n this.gate.cancelPending();\n this.pausing ??= (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n if (connection) {\n await connection.pause();\n await this.gate.releaseAfterDrain();\n }\n })();\n return this.pausing;\n }\n async attachExisting() {\n this.validate();\n const address = await findDaemon(this.root);\n this.validate();\n if (address) {\n try {\n await this.connect(address);\n } catch (error) {\n this.validate();\n if (error instanceof DaemonError && error.remote.name === \"DaemonStoppingError\") return false;\n throw error;\n }\n }\n this.validate();\n return Boolean(address);\n }\n async finishReattachment() {\n this.validate();\n if (this.connection) {\n await recoverDetachedClients({ paths: this.connection.paths, identity: this.connection.identity });\n this.validate();\n await this.connection.attach(this.signal);\n this.validate();\n }\n }\n async connect(existing?: Awaited<ReturnType<typeof ensureDaemon>>, requestSignal?: AbortSignal) {\n const startupSignal = requestSignal ? AbortSignal.any([this.signal, requestSignal]) : this.signal;\n const validateStartup = () => {\n this.validate();\n startupSignal.throwIfAborted();\n };\n validateStartup();\n if (this.connection) return this.connection;\n this.connecting ??= (async () => {\n if (this.partialConnection) {\n // A failed unpublished attempt may already be retired or own queue grants.\n // Confirm drain before replacing its identity; failed cleanup must block retry.\n await this.partialConnection.dispose();\n // Finish acknowledged cleanup even if this new startup was cancelled meanwhile.\n await this.gate.releaseAfterDrain();\n validateStartup();\n this.partialConnection = undefined;\n this.participantIdentity = { id: randomUUID(), generation: randomUUID() };\n }\n // Only explicit setup/command paths or a configured interactive session call connect.\n if (!existing) await fs.mkdir(this.root, { recursive: true, mode: 0o700 });\n validateStartup();\n let retried = false;\n for (;;) {\n validateStartup();\n const daemon = existing ?? (await ensureDaemon(this.root, startupSignal));\n validateStartup();\n if (daemon.paths.root !== this.root) throw new Error(\"Daemon root changed before attach.\");\n const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(), {\n callback: (callback, signal) => this.callback(callback, signal),\n event: (event) => {\n if (event.kind === \"commit\") return;\n if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;\n const payload = event.payload as {\n message?: string;\n level?: \"info\" | \"warning\" | \"error\";\n value?: string;\n presentation?: SyncStatusPresentation;\n };\n if (event.kind === \"notify\" && typeof payload?.message === \"string\")\n this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? \"info\");\n if (event.kind === \"timings\" && typeof (event.payload as { report?: unknown })?.report === \"string\") {\n this.publish?.(this.ctx, safeTerminalText((event.payload as { report: string }).report));\n }\n if (event.kind === \"status\")\n setSyncStatus(\n this.uiContext,\n typeof payload?.value === \"string\" ? safeTerminalText(payload.value) : undefined,\n payload.presentation,\n );\n },\n error: () => {\n if (!this.signal.aborted && !this.disposed && !this.closing && clients.get(this.manager) === this)\n setSyncStatus(this.ctx, \"sync service unavailable\", { activity: \"blocked\", reason: \"repair\" });\n },\n });\n this.partialConnection = connection;\n try {\n await connection.attach(startupSignal);\n } catch (error) {\n if (!(error instanceof DaemonError) || error.remote.name !== \"DaemonStoppingError\") throw error;\n // The final idle fence rejected publication, so this connection owns no queue grants.\n await connection.dispose().catch(() => {});\n this.partialConnection = undefined;\n validateStartup();\n if (existing || retried) throw error;\n retried = true;\n await waitForDaemonExit(daemon.identity, startupSignal);\n validateStartup();\n continue;\n }\n this.validate();\n await recoverDetachedClients(daemon);\n if (this.signal.aborted || this.disposed || this.closing) {\n await connection.dispose();\n this.validate();\n }\n this.validate();\n this.connection = connection;\n this.partialConnection = undefined;\n return connection;\n }\n })().catch((error) => {\n this.connecting = undefined;\n throw error;\n });\n return this.connecting;\n }\n async readSettings(repair = false) {\n this.validate();\n if (!this.connection || this.paused) {\n const document = await peekLocalConfigDocument();\n this.validate();\n if (document && document.bytes.length > MAX_SETTINGS_BYTES)\n throw new Error(\"Settings exceed the local API byte limit; the source document is unchanged.\");\n if (document && !repair) validateSettingsDocument(document.parsed);\n return document;\n }\n return decode(await this.run(repair ? \"settings.repair-read\" : \"settings.read\", {}));\n }\n run(operation: string, payload: unknown, signal?: AbortSignal, ctx = this.ctx, onCommit?: () => void) {\n const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit));\n this.work = result.then(\n () => {},\n () => {},\n );\n return result;\n }\n private async runCurrent(\n operation: string,\n payload: unknown,\n signal?: AbortSignal,\n ctx = this.ctx,\n onCommit?: () => void,\n ) {\n this.validate();\n signal?.throwIfAborted();\n if (this.paused && operation !== \"shutdown\")\n throw new Error(\"Synchronization is paused for a session change; if it was cancelled, use /reload to reattach.\");\n const connection = await this.connect(undefined, signal);\n if (this.paused && operation === \"shutdown\") {\n Object.assign(connection.facts, { ...this.facts(), idle: false, ready: false });\n await connection.attach(signal ? AbortSignal.any([signal, this.signal]) : this.signal);\n this.validate();\n }\n this.validate();\n signal?.throwIfAborted();\n await connection.update(this.facts());\n this.validate();\n signal?.throwIfAborted();\n this.uiContext = ctx;\n try {\n return await connection.run(\n operation,\n payload,\n signal ? AbortSignal.any([signal, this.signal]) : this.signal,\n onCommit,\n );\n } catch (error) {\n if (error instanceof DaemonError) {\n const prototype =\n error.name === \"RemoteSelectionMismatchError\"\n ? RemoteSelectionMismatchError.prototype\n : error.name === \"SyncDecisionRequiredError\"\n ? SyncDecisionRequiredError.prototype\n : undefined;\n if (prototype) {\n const restored = Object.create(prototype) as Error;\n Object.assign(restored, error.remote.properties, { name: error.name, message: error.message });\n throw restored;\n }\n Object.assign(error, error.remote.properties);\n }\n throw error;\n } finally {\n this.uiContext = this.ctx;\n if (\n this.reloadRequested &&\n !this.signal.aborted &&\n !this.disposed &&\n !this.closing &&\n clients.get(this.manager) === this\n ) {\n this.reloadRequested = false;\n if (\"reload\" in ctx && typeof ctx.reload === \"function\") await ctx.reload();\n }\n }\n }\n async markReady(debug: boolean) {\n this.validate();\n this.startupDebug = debug;\n this.initialized = true;\n await this.update();\n this.validate();\n }\n async setBusy(reason: string, busy: boolean) {\n this.validate();\n if (busy) this.busy.add(reason);\n else this.busy.delete(reason);\n await this.update();\n this.validate();\n }\n async update() {\n if (this.connection && !this.paused && !this.disposed && !this.signal.aborted)\n await this.connection.update(this.facts());\n }\n private async callback(callback: Callback, signal: AbortSignal) {\n const payload = callback.payload as {\n reservation?: string;\n targets?: string[];\n generation?: string;\n title?: string;\n message?: string;\n content?: string;\n confirmationLabel?: string;\n summaryLines?: string[];\n items?: string[];\n helpText?: string;\n background?: boolean;\n };\n if (callback.kind === \"queue-release\") {\n if (typeof payload?.reservation !== \"string\") throw new Error(\"Invalid queue release.\");\n await this.gate.releaseRequest(payload.reservation);\n return true;\n }\n this.validate();\n signal.throwIfAborted();\n if (this.paused) throw new Error(\"Pi session is changing; no new work is authorized.\");\n if (callback.kind === \"queue-acquire\") {\n if (payload.background && !this.facts().idle) throw new Error(\"Pi is busy; background apply was not granted.\");\n if (\n payload.generation !== this.generation ||\n typeof payload.reservation !== \"string\" ||\n !Array.isArray(payload.targets)\n )\n throw new Error(\"Stale file-queue request.\");\n return this.gate.acquire(payload.reservation, payload.targets, AbortSignal.any([signal, this.signal]));\n }\n const ctx = this.uiContext;\n const combined = AbortSignal.any([signal, this.signal]);\n if (callback.kind === \"model-binding\") {\n const facts = this.facts();\n const connection = this.connection ?? this.partialConnection;\n if (connection && JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)) {\n await connection.update(facts);\n this.validate();\n }\n return payload.background && !facts.idle ? null : (facts.model ?? null);\n }\n if (callback.kind === \"reload\") {\n this.reloadRequested = true;\n return true;\n }\n if (!ctx.hasUI || ![\"tui\", \"rpc\"].includes(ctx.mode)) throw new Error(\"This client cannot present safety reviews.\");\n let result: unknown;\n if (callback.kind === \"merge-review\" && typeof payload.title === \"string\" && typeof payload.content === \"string\") {\n const { confirmMergeReview } = await import(\"../ui/merge-review.js\");\n this.validate();\n combined.throwIfAborted();\n result = await confirmMergeReview(\n ctx,\n payload.title,\n payload.content,\n combined,\n () => !combined.aborted && !this.disposed,\n payload.confirmationLabel,\n payload.summaryLines,\n );\n } else if (\n callback.kind === \"confirm\" &&\n typeof payload.title === \"string\" &&\n typeof payload.message === \"string\"\n ) {\n result = await ctx.ui.confirm(safeTerminalText(payload.title), safeTerminalText(payload.message), {\n signal: combined,\n });\n } else if (\n callback.kind === \"select\" &&\n typeof payload.title === \"string\" &&\n Array.isArray(payload.items) &&\n payload.items.every((item) => typeof item === \"string\")\n ) {\n const labels = payload.items.map(safeTerminalText);\n if (new Set(labels).size !== labels.length) throw new Error(\"Daemon choices have ambiguous terminal labels.\");\n const selected = await ctx.ui.select(safeTerminalText(payload.title), labels, { signal: combined });\n const index = selected === undefined ? -1 : labels.indexOf(selected);\n result = index < 0 ? undefined : payload.items[index];\n } else throw new Error(\"Unsupported daemon UI callback.\");\n this.validate();\n combined.throwIfAborted();\n return result;\n }\n disposeForShutdown(reason: string | undefined, targetFile?: string) {\n const facts = this.connection?.facts ?? this.partialConnection?.facts;\n return this.dispose({\n kind: [\"new\", \"resume\", \"fork\", \"reload\"].includes(reason ?? \"\") ? \"replace\" : \"exit\",\n ...(targetFile !== undefined\n ? { file: canonicalPath(targetFile) }\n : reason === \"reload\"\n ? { file: facts?.sessionFile, sessionId: facts?.sessionId }\n : {}),\n cwd: facts?.cwd,\n });\n }\n async dispose(handoff?: ClientHandoff) {\n if (this.disposing) return this.disposing;\n this.closing = true;\n this.disposing = (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n let confirmed = false;\n try {\n await connection?.dispose(handoff);\n confirmed = Boolean(connection);\n } finally {\n this.disposed = true;\n if (clients.get(this.manager) === this) clients.delete(this.manager);\n const gate = this.gate;\n gate.detach();\n if (connection) {\n if (confirmed) await gate.releaseAfterDrain();\n else quarantineClient(gate, connection.paths.root, connection.identity, connection.facts);\n }\n await this.work;\n }\n })();\n return this.disposing;\n }\n}\n", "import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport { withTargetQueues } from \"@narumitw/pi-sync-daemon/engine/snapshot/snapshot-mutation-queues\";\n\ninterface Gate {\n token: string;\n paths: readonly string[];\n entered: Promise<string>;\n task: Promise<void>;\n granted: boolean;\n cancelled: boolean;\n reject(error: unknown): void;\n release(): void;\n}\n/**\n * Holds the running Pi's actual public file queues; it does not authorize filesystem writes.\n * The engine owns reviewed destinations, which can differ from every participant's current roots.\n */\nexport class PiApplyGate {\n private gates = new Map<string, Gate>();\n constructor(private validate: () => void) {}\n async acquire(requestId: string, targets: readonly string[], signal?: AbortSignal) {\n this.validate();\n signal?.throwIfAborted();\n if (\n !targets.length ||\n targets.length > 16_384 ||\n targets.some((target) => typeof target !== \"string\" || target.includes(\"\\0\") || !path.isAbsolute(target))\n )\n throw new Error(\"Invalid daemon mutation targets.\");\n const normalized = [...new Set(targets.map((target) => path.resolve(target)))].sort();\n const existing = this.gates.get(requestId);\n if (existing) {\n if (JSON.stringify(existing.paths) !== JSON.stringify(normalized)) throw new Error(\"File-queue request changed.\");\n return existing.entered;\n }\n const token = randomUUID();\n let entered!: (token: string) => void;\n let rejected!: (error: unknown) => void;\n const ready = new Promise<string>((resolve, reject) => {\n entered = resolve;\n rejected = reject;\n });\n let release!: () => void;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n const gate: Gate = {\n token,\n paths: normalized,\n entered: ready,\n task: Promise.resolve(),\n release,\n reject: rejected,\n granted: false,\n cancelled: false,\n };\n this.gates.set(requestId, gate);\n const validate = () => {\n if (gate.cancelled) throw new DOMException(\"File-queue reservation was cancelled\", \"AbortError\");\n this.validate();\n };\n gate.task = withTargetQueues(\n normalized,\n { signal, validateMutation: validate },\n async () => {\n validate();\n signal?.throwIfAborted();\n gate.granted = true;\n entered(token);\n // Prompt cancellation cannot revoke a grant while a remote writer may still run.\n await held;\n },\n { mutate: withFileMutationQueue },\n )\n .catch((error) => {\n rejected(error);\n })\n .finally(() => {\n if (this.gates.get(requestId) === gate) this.gates.delete(requestId);\n });\n const abort = () => {\n if (!gate.granted) {\n gate.cancelled = true;\n rejected(signal?.reason);\n release();\n }\n };\n signal?.addEventListener(\"abort\", abort, { once: true });\n void gate.task.finally(() => signal?.removeEventListener(\"abort\", abort));\n return ready;\n }\n async release(token: string) {\n const gate = [...this.gates.values()].find((value) => value.token === token);\n if (!gate) throw new Error(\"Unknown file-queue grant.\");\n await this.releaseGate(gate);\n }\n private async releaseGate(gate: Gate) {\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(new DOMException(\"File-queue reservation was released\", \"AbortError\"));\n }\n gate.release();\n // A queued, ungranted placeholder cannot write after cancellation and need not\n // wait for another Pi tool to finish before acknowledgement.\n if (gate.granted) await gate.task;\n }\n async releaseRequest(requestId: string) {\n const gate = this.gates.get(requestId);\n if (!gate) return;\n await this.releaseGate(gate);\n }\n detach() {\n const failure = new DOMException(\"Pi session detached\", \"AbortError\");\n this.validate = () => {\n throw failure;\n };\n this.cancelPending(failure);\n }\n cancelPending(failure: unknown = new DOMException(\"Pi session changing\", \"AbortError\")) {\n for (const gate of this.gates.values())\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(failure);\n gate.release();\n }\n }\n get size() {\n return [...this.gates.values()].filter((gate) => gate.granted || !gate.cancelled).length;\n }\n /** Release only after establishing that the associated service cannot still write. */\n async releaseAfterOwnerExit(pid: number) {\n try {\n process.kill(pid, 0);\n throw new Error(\"Daemon owner is still alive; grants remain held.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ESRCH\") throw error;\n }\n await this.releaseAfterDrain();\n }\n /** Caller must first receive an authenticated same-owner detach/drain acknowledgement. */\n async releaseAfterDrain() {\n await Promise.all([...this.gates.values()].map((gate) => this.releaseGate(gate)));\n }\n}\n", "import { type ClientFacts, DaemonConnection, findDaemon, type Identity } from \"@narumitw/pi-sync-daemon\";\nimport type { PiApplyGate } from \"./apply-gate.js\";\n\ntype Address = { paths: DaemonConnection[\"paths\"]; identity: Identity };\ninterface Recovery {\n gate: PiApplyGate;\n root: string;\n identity: Identity;\n facts: ClientFacts;\n timer?: ReturnType<typeof setInterval>;\n attempt?: Promise<boolean>;\n}\nconst recoveries = new Set<Recovery>();\nfunction alive(pid: number) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n }\n}\nfunction finish(record: Recovery) {\n if (record.timer) clearInterval(record.timer);\n recoveries.delete(record);\n}\nfunction attempt(record: Recovery, known?: Address): Promise<boolean> {\n record.attempt ??= (async () => {\n const exited = !alive(record.identity.pid);\n if (exited) await record.gate.releaseAfterOwnerExit(record.identity.pid);\n const address = known ?? (await findDaemon(record.root));\n if (!address || (!exited && address.identity.instance !== record.identity.instance)) return false;\n // Only plain closed-session facts and detached grants cross this recovery boundary.\n // Reclaim the obsolete participant on a compatible owner, reject all new work,\n // and service release callbacks until an authenticated detach confirms drain.\n const connection = new DaemonConnection(\n address.paths,\n address.identity,\n {\n ...record.facts,\n hasUI: false,\n idle: false,\n ready: false,\n },\n {\n callback: async (callback) => {\n const data = callback.payload;\n if (\n callback.kind === \"queue-release\" &&\n data !== null &&\n typeof data === \"object\" &&\n \"reservation\" in data &&\n typeof data.reservation === \"string\"\n ) {\n await record.gate.releaseRequest(data.reservation);\n return true;\n }\n throw new Error(\"Closed Pi participant cannot authorize new work.\");\n },\n },\n );\n try {\n // Cleanup polling does not attach or recreate a retired participant.\n await connection.dispose();\n await record.gate.releaseAfterDrain();\n finish(record);\n return true;\n } finally {\n await connection.dispose();\n }\n })()\n .catch(() => false)\n .finally(() => {\n record.attempt = undefined;\n });\n return record.attempt;\n}\n\n/** Intentionally shared cleanup may outlive a session, but never retains its ctx or UI. */\nexport function quarantineClient(gate: PiApplyGate, root: string, identity: Identity, facts: ClientFacts) {\n gate.detach();\n const record: Recovery = { gate, root, identity: structuredClone(identity), facts: structuredClone(facts) };\n recoveries.add(record);\n record.timer = setInterval(() => {\n void attempt(record);\n }, 1000);\n record.timer.unref();\n void attempt(record);\n}\n\n/** A newly attached client stays unready until obsolete local participants are retired. */\nexport async function recoverDetachedClients(address: Address) {\n const pending = [...recoveries].filter((record) => record.root === address.paths.root);\n const results = await Promise.all(\n pending.map(async (record) => {\n const done = await attempt(record, address);\n return done || !recoveries.has(record) || (await attempt(record, address));\n }),\n );\n if (results.some((done) => !done))\n throw new Error(\n \"Previous Pi cleanup is still uncertain; stop or repair the existing daemon before retrying /reload.\",\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;AAClC,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,oBAAoB;AAC7B,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,SAAgC,mBAAmB;AACnD;AAAA,EAIE,oBAAAC;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAA+B,2BAA2B;AAC1D;AAAA,EAEE;AAAA,OACK;AACP,SAAS,gCAAgC;AACzC,SAAS,6BAA6B;;;AC1BtC,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AACjB,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AAgB1B,IAAM,cAAN,MAAkB;AAAA,EAEvB,YAAoB,UAAsB;AAAtB;AAAA,EAAuB;AAAA,EAAvB;AAAA,EADZ,QAAQ,oBAAI,IAAkB;AAAA,EAEtC,MAAM,QAAQ,WAAmB,SAA4B,QAAsB;AACjF,SAAK,SAAS;AACd,YAAQ,eAAe;AACvB,QACE,CAAC,QAAQ,UACT,QAAQ,SAAS,SACjB,QAAQ,KAAK,CAAC,WAAW,OAAO,WAAW,YAAY,OAAO,SAAS,IAAI,KAAK,CAAC,KAAK,WAAW,MAAM,CAAC;AAExG,YAAM,IAAI,MAAM,kCAAkC;AACpD,UAAM,aAAa,CAAC,GAAG,IAAI,IAAI,QAAQ,IAAI,CAAC,WAAW,KAAK,QAAQ,M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ACvC,kBAAiB,MAAM,WAAW,MAAM,MAAM,WAAW,UAAU,WAAW,KAAK;AAAA,QAC1F;AACA,cAAM,KAAK;AAAA,MACb;AAAA,IACF,GAAG;AACH,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
|
+
"names": ["randomUUID", "path", "DaemonConnection", "findDaemon", "path", "randomUUID", "findDaemon", "DaemonConnection"]
|
|
7
|
+
}
|
|
@@ -6,10 +6,10 @@ import {
|
|
|
6
6
|
compileSyncExclude,
|
|
7
7
|
normalizeSyncExclude,
|
|
8
8
|
sameSyncExclude
|
|
9
|
-
} from "@narumitw/sync-daemon/engine/sync/exclude-policy";
|
|
9
|
+
} from "@narumitw/pi-sync-daemon/engine/sync/exclude-policy";
|
|
10
10
|
|
|
11
11
|
export {
|
|
12
12
|
normalizeSyncExclude,
|
|
13
13
|
sameSyncExclude
|
|
14
14
|
};
|
|
15
|
-
//# sourceMappingURL=chunk-
|
|
15
|
+
//# sourceMappingURL=chunk-HEB6YT64.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/exclude-policy.ts"],
|
|
4
|
+
"sourcesContent": ["export type * from \"@narumitw/pi-sync-daemon/engine/sync/exclude-policy\";\nexport {\n compileSyncExclude,\n normalizeSyncExclude,\n sameSyncExclude,\n} from \"@narumitw/pi-sync-daemon/engine/sync/exclude-policy\";\n"],
|
|
5
|
+
"mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -239,7 +239,7 @@ function usage() {
|
|
|
239
239
|
`Automatic sync: ${AUTOMATIC_SYNC_DESCRIPTION}`,
|
|
240
240
|
`Startup transfer: ${STARTUP_TRANSFER_DESCRIPTION}`,
|
|
241
241
|
"Automatic transfer at startup is a separate opt-in: one conflict-free established-baseline transfer at idle in TUI/RPC, with conditional/lease publication and no resource reload.",
|
|
242
|
-
"Continuous sync is a separate default-Off opt-in in Settings. It requires Autonomous sync and can incur recurring network/model costs.
|
|
242
|
+
"Continuous sync is a separate default-Off opt-in in Settings. It requires Autonomous sync and can incur recurring network/model costs. After the last Pi exits, the service closes after a 30-second grace period unless a valid /sync daemon allow-after-exit grant applies. Zero-client work still requires that separate review. Safety blocks and durable automatic request limits remain.",
|
|
243
243
|
"Settings: use /sync init or edit storage connections and sync setups in ~/.pi/agent/pi-sync.json (or the configured Pi agent directory). Version 1 and version 2 settings are unsupported and are never rewritten."
|
|
244
244
|
].join("\n");
|
|
245
245
|
}
|
|
@@ -256,4 +256,4 @@ export {
|
|
|
256
256
|
resolveSyncCommand,
|
|
257
257
|
usage
|
|
258
258
|
};
|
|
259
|
-
//# sourceMappingURL=chunk-
|
|
259
|
+
//# sourceMappingURL=chunk-HLCML3OW.ts.map
|