@narumitw/pi-sync 0.67.1 → 0.67.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +7 -5
- package/dist/chunks/{chunk-JNTDIVP6.ts → chunk-33EDXDLC.ts} +2 -2
- package/dist/chunks/{chunk-W7DSN33J.ts → chunk-AVTW6WNP.ts} +3 -3
- package/dist/chunks/{chunk-XPKHWTGT.ts → chunk-CQ4DMLH3.ts} +61 -11
- package/dist/chunks/chunk-CQ4DMLH3.ts.map +7 -0
- package/dist/chunks/{chunk-CQXGMESM.ts → chunk-HLJIRWFL.ts} +2 -2
- package/dist/chunks/{chunk-3CO7QIYB.ts → chunk-X344HTVV.ts} +2 -2
- package/dist/chunks/{command-handler-H5X3BX5D.ts → command-handler-WF2TDDRZ.ts} +59 -16
- package/dist/chunks/command-handler-WF2TDDRZ.ts.map +7 -0
- package/dist/chunks/{conflict-review-SSY37F4P.ts → conflict-review-GWEL4S6C.ts} +2 -2
- package/dist/chunks/{ignore-file-ui-UY2TEK4C.ts → ignore-file-ui-BEZZZIEE.ts} +3 -3
- package/dist/chunks/{manager-result-dispatcher-PEVIGLOS.ts → manager-result-dispatcher-BXN46NRC.ts} +3 -3
- package/dist/chunks/{manager-ui-R5XHYRXK.ts → manager-ui-FS4QIKRA.ts} +9 -9
- package/dist/chunks/{remote-selection-ui-WFLX6MAJ.ts → remote-selection-ui-DOYKUMER.ts} +2 -2
- package/dist/chunks/{setup-wizard-5OMFSFPJ.ts → setup-wizard-PI45SF2C.ts} +4 -4
- package/dist/chunks/{sync-inspection-S2GHDBAD.ts → sync-inspection-DI5J6EUH.ts} +2 -2
- package/dist/chunks/{sync-operations-LQ63CU2T.ts → sync-operations-AGNL7QXA.ts} +2 -2
- package/dist/daemon/dist/build-id.json +1 -0
- package/dist/daemon/dist/build-version.js +24 -4
- package/dist/daemon/dist/cli.js +30 -65
- package/dist/daemon/dist/client-transport.js +13 -5
- package/dist/daemon/dist/consent.js +25 -16
- package/dist/daemon/dist/daemon-startup.js +135 -30
- package/dist/daemon/dist/daemon-status.js +56 -0
- package/dist/daemon/dist/engine/debug-log.js +19 -0
- package/dist/daemon/dist/engine/sync/merged-sync.js +1 -0
- package/dist/daemon/dist/engine/sync/sync-mutations.js +1 -0
- package/dist/daemon/dist/engine-service.js +20 -4
- package/dist/daemon/dist/index.js +2 -0
- package/dist/daemon/dist/server.js +97 -5
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +8 -7
- package/dist/index.ts.map +2 -2
- package/docs/agent-continuous-hardening.md +2 -0
- package/docs/daemon-migration.md +12 -12
- package/package.json +2 -2
- package/skills/configure-pi-sync/SKILL.md +6 -2
- package/skills/configure-pi-sync/references/configuration.md +3 -1
- package/src/commands/command-execution.ts +2 -9
- package/src/daemon/client-debug.ts +6 -3
- package/src/daemon/daemon-status-ui.ts +64 -0
- package/src/daemon/pi-client.ts +69 -9
- package/src/sync-extension.ts +4 -3
- package/dist/chunks/chunk-XPKHWTGT.ts.map +0 -7
- package/dist/chunks/command-handler-H5X3BX5D.ts.map +0 -7
- /package/dist/chunks/{chunk-JNTDIVP6.ts.map → chunk-33EDXDLC.ts.map} +0 -0
- /package/dist/chunks/{chunk-W7DSN33J.ts.map → chunk-AVTW6WNP.ts.map} +0 -0
- /package/dist/chunks/{chunk-CQXGMESM.ts.map → chunk-HLJIRWFL.ts.map} +0 -0
- /package/dist/chunks/{chunk-3CO7QIYB.ts.map → chunk-X344HTVV.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-SSY37F4P.ts.map → conflict-review-GWEL4S6C.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-UY2TEK4C.ts.map → ignore-file-ui-BEZZZIEE.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-PEVIGLOS.ts.map → manager-result-dispatcher-BXN46NRC.ts.map} +0 -0
- /package/dist/chunks/{manager-ui-R5XHYRXK.ts.map → manager-ui-FS4QIKRA.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-WFLX6MAJ.ts.map → remote-selection-ui-DOYKUMER.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-5OMFSFPJ.ts.map → setup-wizard-PI45SF2C.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-S2GHDBAD.ts.map → sync-inspection-DI5J6EUH.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-LQ63CU2T.ts.map → sync-operations-AGNL7QXA.ts.map} +0 -0
|
@@ -160,7 +160,7 @@ async function showRemoteSelectionReview(ctx, setupName, signal, factory = creat
|
|
|
160
160
|
async function showSelectionDifference(ctx, initialDecision, origin, runRoute, sessionSignal, factory, options, validateOwner) {
|
|
161
161
|
const isCurrent = () => isReviewOwnerCurrent(validateOwner);
|
|
162
162
|
const canReviewPull = Boolean(
|
|
163
|
-
runRoute && !options.readOnly && initialDecision.ignorePolicyComparison === "mismatch" && await (await import("./ignore-file-ui-
|
|
163
|
+
runRoute && !options.readOnly && initialDecision.ignorePolicyComparison === "mismatch" && await (await import("./ignore-file-ui-BEZZZIEE.ts")).portableIgnoreRulesAvailable(ctx, sessionSignal)
|
|
164
164
|
);
|
|
165
165
|
if (!isCurrent()) return { kind: "stale" };
|
|
166
166
|
let flowState = { decision: initialDecision, saved: false };
|
|
@@ -768,4 +768,4 @@ function combineSignals(sessionSignal, actionSignal) {
|
|
|
768
768
|
export {
|
|
769
769
|
showRemoteSelectionReview
|
|
770
770
|
};
|
|
771
|
-
//# sourceMappingURL=chunk-
|
|
771
|
+
//# sourceMappingURL=chunk-X344HTVV.ts.map
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
currentPiDaemonClient,
|
|
22
22
|
piDaemonClient,
|
|
23
23
|
remoteOperation
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-CQ4DMLH3.ts";
|
|
25
25
|
import {
|
|
26
26
|
combineSignals,
|
|
27
27
|
throwIfAborted
|
|
@@ -67,6 +67,58 @@ import {
|
|
|
67
67
|
safeTerminalText
|
|
68
68
|
} from "./chunk-2JNFEZ3V.ts";
|
|
69
69
|
|
|
70
|
+
// src/daemon/daemon-status-ui.ts
|
|
71
|
+
import { inspectDaemonStatus } from "#pi-sync-daemon";
|
|
72
|
+
async function showDaemonStatus(ctx, client, signal) {
|
|
73
|
+
let attachedInstance;
|
|
74
|
+
let connectionError;
|
|
75
|
+
try {
|
|
76
|
+
attachedInstance = (await client.verifyConnection(signal))?.identity.instance;
|
|
77
|
+
} catch (error) {
|
|
78
|
+
connectionError = safeTerminalText(errorMessage(error).slice(0, 1200));
|
|
79
|
+
}
|
|
80
|
+
signal?.throwIfAborted();
|
|
81
|
+
client.validate();
|
|
82
|
+
const status = await inspectDaemonStatus(client.root, signal);
|
|
83
|
+
signal?.throwIfAborted();
|
|
84
|
+
client.validate();
|
|
85
|
+
if (!ctx.hasUI) return;
|
|
86
|
+
const connected = status.running === true && status.instance === attachedInstance;
|
|
87
|
+
const recovery = client.ownershipCleanupRequired || status.pendingUpgradePid !== void 0;
|
|
88
|
+
const state = connected ? "connected" : status.running ? "running; not connected" : status.running === null ? "owner could not be verified" : "not running";
|
|
89
|
+
const lines = [`pi-sync-daemon: ${state}${recovery ? "; recovery required" : ""}`];
|
|
90
|
+
if (status.running) {
|
|
91
|
+
lines.push(`PID: ${status.pid}`, `Instance: ${status.instance}`);
|
|
92
|
+
lines.push(`Running build: ${formatBuild(status.buildVersion, status.buildId)}`);
|
|
93
|
+
}
|
|
94
|
+
lines.push(`Expected build: ${formatBuild(status.expectedBuildVersion, status.expectedBuildId)}`);
|
|
95
|
+
if (status.pendingUpgradePid !== void 0) lines.push(`Pending replacement PID: ${status.pendingUpgradePid}`);
|
|
96
|
+
const blocked = status.running ? client.blockedUpgradeReason(status.instance) : void 0;
|
|
97
|
+
if (blocked) lines.push(`Upgrade blocked: ${blocked.slice(0, 1200)}`);
|
|
98
|
+
else if (connectionError) lines.push(`Connection: ${connectionError}`);
|
|
99
|
+
if (client.ownershipCleanupRequired) lines.push("Use /sync daemon recover to review and stop the daemon.");
|
|
100
|
+
else if (recovery || status.running === null)
|
|
101
|
+
lines.push("Check daemon CLI status and follow daemon recovery. Do not force a restart.");
|
|
102
|
+
else if (status.running && (status.buildComparison === "older" || status.buildComparison === "unversioned")) {
|
|
103
|
+
if (!blocked)
|
|
104
|
+
lines.push(
|
|
105
|
+
status.guardedUpgrade ? "Daemon upgrade is required. Use /reload when sync work is idle." : "This owner does not support guarded upgrades. When sync work is idle, use the intended daemon CLI restart, then /reload."
|
|
106
|
+
);
|
|
107
|
+
} else if (status.running && status.buildComparison === "different")
|
|
108
|
+
lines.push("Same version, different build. Use the intended build's daemon CLI restart, then /reload.");
|
|
109
|
+
else if (status.running && status.buildComparison === "unverified")
|
|
110
|
+
lines.push(
|
|
111
|
+
"Build match is unverified. Use the intended build's daemon CLI to inspect or explicitly restart, then /reload."
|
|
112
|
+
);
|
|
113
|
+
else if (status.running && status.buildComparison === "newer")
|
|
114
|
+
lines.push("The running daemon is newer than the loaded build. It was left unchanged.");
|
|
115
|
+
else lines.push("Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.");
|
|
116
|
+
ctx.ui.notify(lines.join("\n"), connected && !recovery ? "info" : "warning");
|
|
117
|
+
}
|
|
118
|
+
function formatBuild(version, id) {
|
|
119
|
+
return `${version ?? "unknown version"} (${id?.slice(0, 12) ?? "unknown build ID"})`;
|
|
120
|
+
}
|
|
121
|
+
|
|
70
122
|
// src/commands/command-execution.ts
|
|
71
123
|
async function executeRecoveryCommand(rawArgs, ctx, signal, loaders, onCommit, setup) {
|
|
72
124
|
try {
|
|
@@ -157,16 +209,7 @@ async function executeCommand(rawArgs, ctx, signal, loaders, onCommit, setup, on
|
|
|
157
209
|
options.signal
|
|
158
210
|
);
|
|
159
211
|
} else if (action === "status") {
|
|
160
|
-
|
|
161
|
-
const guidance = client.ownershipCleanupRequired ? "Use /sync daemon recover to review and stop the daemon." : "Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.";
|
|
162
|
-
const state = client.ownershipCleanupRequired ? "connected; recovery required" : "connected";
|
|
163
|
-
ctx.ui.notify(
|
|
164
|
-
`pi-sync-daemon: ${state}
|
|
165
|
-
PID: ${connection.identity.pid}
|
|
166
|
-
Instance: ${connection.identity.instance}
|
|
167
|
-
${guidance}`,
|
|
168
|
-
"info"
|
|
169
|
-
);
|
|
212
|
+
await showDaemonStatus(ctx, client, options.signal);
|
|
170
213
|
} else throw new Error("Use /sync daemon status|recover|handover|allow-after-exit|revoke-after-exit.");
|
|
171
214
|
return { kind: "completed" };
|
|
172
215
|
}
|
|
@@ -214,7 +257,7 @@ ${guidance}`,
|
|
|
214
257
|
return { kind: "completed" };
|
|
215
258
|
}
|
|
216
259
|
case "conflicts": {
|
|
217
|
-
const { showConflicts } = await import("./conflict-review-
|
|
260
|
+
const { showConflicts } = await import("./conflict-review-GWEL4S6C.ts");
|
|
218
261
|
throwIfAborted(options.signal);
|
|
219
262
|
await showConflicts(ctx, options);
|
|
220
263
|
return { kind: "completed" };
|
|
@@ -325,7 +368,7 @@ async function initConfig(ctx, signal) {
|
|
|
325
368
|
return;
|
|
326
369
|
}
|
|
327
370
|
if (ctx.mode === "tui") {
|
|
328
|
-
const { showSetupWizard } = await import("./setup-wizard-
|
|
371
|
+
const { showSetupWizard } = await import("./setup-wizard-PI45SF2C.ts");
|
|
329
372
|
throwIfAborted(signal);
|
|
330
373
|
await showSetupWizard(ctx, signal);
|
|
331
374
|
return;
|
|
@@ -457,7 +500,7 @@ async function handleCommand(rawArgs, ctx, sessionSignal, loaders, attention, on
|
|
|
457
500
|
if (!rawArgs.trim()) {
|
|
458
501
|
attention.expand();
|
|
459
502
|
try {
|
|
460
|
-
const { showSyncManager } = await import("./manager-ui-
|
|
503
|
+
const { showSyncManager } = await import("./manager-ui-FS4QIKRA.ts");
|
|
461
504
|
if (sessionSignal.aborted) return;
|
|
462
505
|
await showSyncManager(ctx, run, sessionSignal, {
|
|
463
506
|
needsDaemonRecovery,
|
|
@@ -561,7 +604,7 @@ function directSelectionOrigin(rawArgs) {
|
|
|
561
604
|
async function resolveSelectionAttention(ctx, attention, signal, loaders, options = {}) {
|
|
562
605
|
const current = attention.current();
|
|
563
606
|
if (!current || signal.aborted) return;
|
|
564
|
-
const { dispatchManagerResult } = await import("./manager-result-dispatcher-
|
|
607
|
+
const { dispatchManagerResult } = await import("./manager-result-dispatcher-BXN46NRC.ts");
|
|
565
608
|
if (signal.aborted || attention.current() !== current) return;
|
|
566
609
|
await dispatchManagerResult(
|
|
567
610
|
ctx,
|
|
@@ -592,4 +635,4 @@ export {
|
|
|
592
635
|
handleCommand,
|
|
593
636
|
resolveSelectionAttention
|
|
594
637
|
};
|
|
595
|
-
//# sourceMappingURL=command-handler-
|
|
638
|
+
//# sourceMappingURL=command-handler-WF2TDDRZ.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/daemon/daemon-status-ui.ts", "../../src/commands/command-execution.ts", "../../src/commands/command-handler.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { inspectDaemonStatus } from \"@narumitw/pi-sync-daemon\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport type { PiDaemonClient } from \"./pi-client.js\";\n\nexport async function showDaemonStatus(ctx: ExtensionContext, client: PiDaemonClient, signal?: AbortSignal) {\n let attachedInstance: string | undefined;\n let connectionError: string | undefined;\n try {\n attachedInstance = (await client.verifyConnection(signal))?.identity.instance;\n } catch (error) {\n connectionError = safeTerminalText(errorMessage(error).slice(0, 1200));\n }\n signal?.throwIfAborted();\n client.validate();\n const status = await inspectDaemonStatus(client.root, signal);\n signal?.throwIfAborted();\n client.validate();\n if (!ctx.hasUI) return;\n const connected = status.running === true && status.instance === attachedInstance;\n const recovery = client.ownershipCleanupRequired || status.pendingUpgradePid !== undefined;\n const state = connected\n ? \"connected\"\n : status.running\n ? \"running; not connected\"\n : status.running === null\n ? \"owner could not be verified\"\n : \"not running\";\n const lines = [`pi-sync-daemon: ${state}${recovery ? \"; recovery required\" : \"\"}`];\n if (status.running) {\n lines.push(`PID: ${status.pid}`, `Instance: ${status.instance}`);\n lines.push(`Running build: ${formatBuild(status.buildVersion, status.buildId)}`);\n }\n lines.push(`Expected build: ${formatBuild(status.expectedBuildVersion, status.expectedBuildId)}`);\n if (status.pendingUpgradePid !== undefined) lines.push(`Pending replacement PID: ${status.pendingUpgradePid}`);\n const blocked = status.running ? client.blockedUpgradeReason(status.instance) : undefined;\n if (blocked) lines.push(`Upgrade blocked: ${blocked.slice(0, 1200)}`);\n else if (connectionError) lines.push(`Connection: ${connectionError}`);\n if (client.ownershipCleanupRequired) lines.push(\"Use /sync daemon recover to review and stop the daemon.\");\n else if (recovery || status.running === null)\n lines.push(\"Check daemon CLI status and follow daemon recovery. Do not force a restart.\");\n else if (status.running && (status.buildComparison === \"older\" || status.buildComparison === \"unversioned\")) {\n if (!blocked)\n lines.push(\n status.guardedUpgrade\n ? \"Daemon upgrade is required. Use /reload when sync work is idle.\"\n : \"This owner does not support guarded upgrades. When sync work is idle, use the intended daemon CLI restart, then /reload.\",\n );\n } else if (status.running && status.buildComparison === \"different\")\n lines.push(\"Same version, different build. Use the intended build's daemon CLI restart, then /reload.\");\n else if (status.running && status.buildComparison === \"unverified\")\n lines.push(\n \"Build match is unverified. Use the intended build's daemon CLI to inspect or explicitly restart, then /reload.\",\n );\n else if (status.running && status.buildComparison === \"newer\")\n lines.push(\"The running daemon is newer than the loaded build. It was left unchanged.\");\n else lines.push(\"Use pi-sync-daemon status/stop/restart --root <agent-directory> for explicit lifecycle control.\");\n ctx.ui.notify(lines.join(\"\\n\"), connected && !recovery ? \"info\" : \"warning\");\n}\n\nfunction formatBuild(version?: string, id?: string) {\n return `${version ?? \"unknown version\"} (${id?.slice(0, 12) ?? \"unknown build ID\"})`;\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { showDaemonStatus } from \"../daemon/daemon-status-ui.js\";\nimport { CompletedDirectionalRecoveryError } from \"../daemon/directional-recovery.js\";\nimport { type PiDaemonClient, piDaemonClient, remoteOperation } from \"../daemon/pi-client.js\";\nimport { loadSettingsConfig, sessionTokenWarnings, syncSessionsWarnings } from \"../settings/config.js\";\nimport { activeLocalConfigPath, createLocalConfigDocument, localConfigPath } from \"../settings/config-file.js\";\nimport { localConfigTemplate, readLocalConfigObject } from \"../settings/settings-store.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { syncErrorGuidance } from \"../sync/sync-error-guidance.js\";\nimport { errorMessage, isSyncDecisionRequiredError, SetupPullRequiresUiError } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { RemoteSelectionMismatchError, syncSessionsSelected } from \"../sync/sync-policy.js\";\nimport { automaticSyncSummary } from \"../ui/automatic-sync-summary.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport { manualIgnoreFileGuidance } from \"../ui/ignore-file-guidance.js\";\nimport { trackOperationDialogs } from \"../ui/operation-dialogs.js\";\nimport { startupTransferSummary } from \"../ui/sync-behavior.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { parseOptions, resolveSyncCommand, splitArgs, usage, validateCommandOptions } from \"./command.js\";\nimport type { CommandOptions } from \"./command-types.js\";\n\nexport async function executeRecoveryCommand(\n rawArgs: string,\n ctx: ExtensionContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n): Promise<RunRouteResult> {\n try {\n const [subcommand, ...rest] = splitArgs(rawArgs);\n if (subcommand !== \"sync\" && subcommand !== \"pull\" && subcommand !== \"push\") {\n throw new Error(`Unsupported sync recovery route: ${subcommand ?? \"missing\"}`);\n }\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n options.reload = false;\n options.auto = false;\n validateCommandOptions(subcommand, options);\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n if (subcommand === \"push\") {\n const outcome = await operations.push(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n if (subcommand === \"pull\") {\n const outcome = await operations.pull(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n await operations.syncBoth(ctx, options);\n return { kind: \"completed\" };\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nexport async function executeCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n directionalFingerprint?: string,\n requirePendingAdoption?: boolean,\n): Promise<RunRouteResult> {\n ctx = trackOperationDialogs(ctx, onDialog);\n try {\n const directionalClient = directionalFingerprint === undefined ? undefined : piDaemonClient(ctx);\n const command = await resolveSyncCommand(rawArgs, ctx);\n if (signal?.aborted || !command) return { kind: \"completed\" };\n const { subcommand, rest } = command;\n if (requirePendingAdoption && (!directionalClient || subcommand !== \"pull\"))\n throw new Error(\"Pull recovery requires the original directional action.\");\n if (directionalClient && directionalFingerprint !== undefined) {\n if ((subcommand !== \"push\" && subcommand !== \"pull\") || rest.length || !setup || retryRefusal)\n throw new Error(\"Invalid directional action.\");\n return await runDirectionalAction(\n directionalClient,\n ctx,\n subcommand,\n setup,\n directionalFingerprint,\n signal,\n onCommit,\n requirePendingAdoption,\n );\n }\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n validateCommandOptions(subcommand, options);\n if (retryRefusal) {\n if (subcommand !== \"sync\") throw new Error(\"A refused-model retry is available only for merged sync.\");\n options.agentRetryRefusal = true;\n }\n\n switch (subcommand) {\n case \"daemon\": {\n const client = piDaemonClient(ctx);\n const action = options.args[0] ?? \"status\";\n if (action === \"recover\") {\n if (rest.length !== 1) throw new Error(\"Usage: /sync daemon recover\");\n const { recoverDaemonOwnership } = await import(\"../daemon/ownership-recovery.js\");\n await recoverDaemonOwnership(ctx, client, signal);\n } else if (action === \"handover\") {\n await client.run(\"daemon.handover\", {}, options.signal);\n } else if (action === \"allow-after-exit\" || action === \"revoke-after-exit\") {\n await client.run(\"daemon.handover\", {}, options.signal);\n const policy = (await client.run(\"daemon.policy\", {}, options.signal)) as { fingerprint: string };\n await client.run(\n \"daemon.authorize\",\n { fingerprint: policy.fingerprint, afterExit: action === \"allow-after-exit\" },\n options.signal,\n );\n } else if (action === \"status\") {\n await showDaemonStatus(ctx, client, options.signal);\n } else throw new Error(\"Use /sync daemon status|recover|handover|allow-after-exit|revoke-after-exit.\");\n return { kind: \"completed\" };\n }\n case \"help\":\n ctx.ui.notify(usage(), \"info\");\n return { kind: \"completed\" };\n case \"use\": {\n const { useSyncSetup } = await loaders.setupSwitch();\n throwIfAborted(options.signal);\n await useSyncSetup(\n ctx,\n options.args[0] ?? \"\",\n async (selectedSetup) => {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n return operations.pull(ctx, { ...options, setup: selectedSetup });\n },\n undefined,\n options.signal,\n );\n return { kind: \"completed\" };\n }\n case \"init\":\n await initConfig(ctx, signal);\n return { kind: \"completed\" };\n case \"config\":\n await showConfig(ctx, options);\n return { kind: \"completed\" };\n case \"files\": {\n const { showFileSelection } = await import(\"../ui/file-selection.js\");\n throwIfAborted(options.signal);\n await showFileSelection(ctx, options.setup, options.signal);\n return { kind: \"completed\" };\n }\n case \"status\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.status(ctx, options);\n return { kind: \"completed\" };\n }\n case \"diff\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.diff(ctx, options);\n return { kind: \"completed\" };\n }\n case \"conflicts\": {\n const { showConflicts } = await import(\"../sync/conflict-review.js\");\n throwIfAborted(options.signal);\n await showConflicts(ctx, options);\n return { kind: \"completed\" };\n }\n case \"doctor\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.doctor(ctx, options);\n return { kind: \"completed\" };\n }\n case \"push\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await operations.push(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"pull\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await operations.pull(ctx, options);\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"sync\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await operations.syncBoth(ctx, options);\n return { kind: \"completed\", ...(retryRefusal && outcome && outcome !== \"archived\" ? { outcome } : {}) };\n }\n case \"history\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.history(ctx, options);\n return { kind: \"completed\" };\n }\n case \"rollback\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.rollback(ctx, options);\n return { kind: \"completed\" };\n }\n case \"migrate-state\":\n await migrateStateDirectory(ctx, options);\n return { kind: \"completed\" };\n case \"unlock\":\n await remoteOperation(ctx, \"unlock\", options);\n return { kind: \"completed\" };\n default:\n ctx.ui.notify(`Unknown /sync command: ${subcommand}\\n\\n${usage()}`, \"warning\");\n return { kind: \"failed\" };\n }\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (directionalFingerprint !== undefined) {\n ctx.ui.notify(safeTerminalText(errorMessage(error)).slice(0, 1200), \"error\");\n return { kind: \"failed\" };\n }\n if (error instanceof SetupPullRequiresUiError) throw error;\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nasync function runDirectionalAction(\n client: PiDaemonClient,\n ctx: ExtensionCommandContext,\n direction: \"push\" | \"pull\",\n setup: string,\n fingerprint: string,\n signal: AbortSignal | undefined,\n onCommit: (() => void) | undefined,\n requirePendingAdoption?: boolean,\n): Promise<RunRouteResult> {\n try {\n const operation = `${direction}.foreground`;\n const intent = { setup, fingerprint };\n const result = (await (requirePendingAdoption\n ? client.run(operation, intent, signal, ctx, onCommit, undefined, true)\n : client.run(operation, intent, signal, ctx, onCommit))) as\n | { outcome?: \"applied\" | \"cancelled\"; message?: string }\n | undefined;\n if (!client.canReportDirectionalResult() || (signal?.aborted && result?.outcome !== \"applied\"))\n return { kind: \"failed\" };\n if (\n !result ||\n (result.outcome !== \"applied\" && result.outcome !== \"cancelled\") ||\n (result.message !== undefined && typeof result.message !== \"string\")\n ) {\n throw new Error(\"Invalid result from directional synchronization.\");\n }\n if (result.message) ctx.ui.notify(safeTerminalText(result.message), \"info\");\n return signal?.aborted ? { kind: \"failed\" } : { kind: \"completed\", outcome: result.outcome };\n } catch (error) {\n const completed = error instanceof CompletedDirectionalRecoveryError;\n if (!client.canReportDirectionalResult() || (signal?.aborted && !completed)) return { kind: \"failed\" };\n if (!signal?.aborted) setSyncStatus(ctx, undefined);\n const message = safeTerminalText(errorMessage(error));\n ctx.ui.notify(completed ? message : message.slice(0, 1200), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nasync function migrateStateDirectory(ctx: ExtensionCommandContext, options: CommandOptions) {\n const result = (await remoteOperation(ctx, \"migrate-state\", options)) as\n | { status: string; message?: string }\n | undefined;\n throwIfAborted(options.signal);\n ctx.ui.notify(\n result?.message ?? \"pi-sync already uses the canonical pi-sync/ state directory.\",\n result?.status === \"deferred\" ? \"warning\" : \"info\",\n );\n}\n\nasync function initConfig(ctx: ExtensionCommandContext, signal?: AbortSignal) {\n const configPath = localConfigPath();\n const existing = await readLocalConfigObject();\n throwIfAborted(signal);\n if (existing) {\n const activePath = await activeLocalConfigPath();\n throwIfAborted(signal);\n ctx.ui.notify(`Config already exists: ${activePath}`, \"info\");\n return;\n }\n\n if (ctx.mode === \"tui\") {\n const { showSetupWizard } = await import(\"../ui/setup/setup-wizard.js\");\n throwIfAborted(signal);\n await showSetupWizard(ctx, signal);\n return;\n }\n await createLocalConfigDocument(localConfigTemplate(), signal);\n throwIfAborted(signal);\n ctx.ui.notify(`Created ${configPath}. Add a storage connection and sync setup before syncing.`, \"info\");\n}\n\nasync function showConfig(ctx: ExtensionCommandContext, options: CommandOptions) {\n const config = await loadSettingsConfig(options.setup);\n throwIfAborted(options.signal);\n const warnings = [\n ...(config.backend.type === \"s3\" ? sessionTokenWarnings(config.backend.profile) : []),\n ...syncSessionsWarnings(config),\n ];\n const storageLines = configStorageLines(config);\n ctx.ui.notify(\n [\n \"pi-sync config:\",\n `sync setup: ${config.setupName}`,\n `storage connection: ${config.connectionName}`,\n ...storageLines,\n `storage path: ${config.storagePath}`,\n `automatic sync: ${automaticSyncSummary(config.automatic)}`,\n `settings field merge: ${config.mergeSettings ? \"On\" : \"Off\"}`,\n `machine-local settings.json fields: ${(config.localFields ?? []).map(safeTerminalText).join(\", \") || \"none\"}`,\n `startup transfer: ${startupTransferSummary(config)}`,\n `autonomous sync: ${config.agentMode ? \"On\" : \"Off\"}`,\n `continuous sync: ${config.continuous ? (config.agentMode ? \"On\" : \"paused; Autonomous sync is Off\") : \"Off\"}`,\n config.scope ? \"sync scope: Pi agent directory\" : `included content: ${config.include.join(\", \") || \"none\"}`,\n ...(config.pathPolicy === \"ignore-file\"\n ? [\"path policy: local ignore file\", manualIgnoreFileGuidance(config.ignoreFile ?? \".syncignore\")]\n : config.scope\n ? [\n `excluded paths: ${config.exclude?.map(safeTerminalText).join(\", \") || \"none\"}`,\n `re-included paths: ${config.reinclude?.map(safeTerminalText).join(\", \") || \"none\"}`,\n ]\n : []),\n `sessions: ${syncSessionsSelected(config) ? \"included\" : \"not included\"}`,\n `settings file: ${localConfigPath()}`,\n ...warnings,\n ].join(\"\\n\"),\n warnings.length > 0 ? \"warning\" : \"info\",\n );\n}\n\nfunction configStorageLines(config: AnySyncConfig) {\n switch (config.backend.type) {\n case \"git\":\n return [\n \"kind: git\",\n `remote: ${displayGitRemote(config.backend.profile.remote)}`,\n \"authentication: existing Git/SSH credentials (not stored)\",\n `branch: ${config.backend.destination.branch}`,\n ];\n case \"webdav\":\n return [\n \"kind: webdav\",\n `url: ${displayWebDavUrl(config.backend.profile.url, config.backend.profile.username)}`,\n \"username: configured (value hidden)\",\n \"password: configured\",\n ];\n case \"s3\":\n return [\n \"kind: s3\",\n `endpoint: ${config.backend.profile.endpoint}`,\n `bucket: ${config.backend.destination.bucket}`,\n `region: ${config.backend.profile.region}`,\n \"access key id: configured\",\n \"secret access key: configured\",\n `session token: ${config.backend.profile.sessionToken ? \"configured\" : \"not configured\"}`,\n ];\n }\n}\n\nfunction displayGitRemote(value: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n } catch {\n return value.replace(/^(?:[^@\\s]+@)?(?<host>[^:]+):.+$/u, \"$<host>:\u2026\");\n }\n}\n\nfunction displayWebDavUrl(value: string | undefined, username: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return username ? `${url.origin}/\u2026` : `${url.origin}${url.pathname}`;\n } catch {\n return \"invalid (value hidden)\";\n }\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { currentPiDaemonClient } from \"../daemon/pi-client.js\";\nimport { loadConfig } from \"../settings/config.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { combineSignals } from \"../sync/signals.js\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { formatRemoteSelectionMismatch } from \"../sync/sync-policy.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport {\n observationMatchesConfig,\n type SyncAttentionController,\n type SyncAttentionOrigin,\n syncAttentionMatchesConfig,\n} from \"../ui/sync-attention.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { parseOptions, splitArgs, validateCommandOptions } from \"./command.js\";\nimport { executeCommand, executeRecoveryCommand } from \"./command-execution.js\";\n\nexport async function handleCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n sessionSignal: AbortSignal,\n loaders: SyncLoaders,\n attention: SyncAttentionController,\n onExplicitSync?: (setup?: string) => void,\n needsDaemonRecovery?: () => boolean,\n) {\n const args = splitArgs(rawArgs);\n if (args[0] === \"daemon\" && args[1] === \"recover\") {\n await executeCommand(rawArgs, ctx, sessionSignal, loaders);\n return;\n }\n if (!needsDaemonRecovery?.()) await reconcileObservation(attention, sessionSignal);\n if (sessionSignal.aborted) return;\n const run = (\n route: string,\n signal?: AbortSignal,\n onCommit?: () => void,\n target?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n directionalFingerprint?: string,\n requirePendingAdoption?: boolean,\n ) => {\n const [command, ...args] = splitArgs(route);\n if (command === \"sync\" && !retryRefusal) {\n try {\n const options = parseOptions(args);\n validateCommandOptions(\"sync\", options);\n onExplicitSync?.(target ?? options.setup);\n } catch {\n /* Invalid routes do not request an automatic retry. */\n }\n }\n return executeCommand(\n route,\n ctx,\n combineSignals(sessionSignal, signal),\n loaders,\n observationCommitCallback(attention, sessionSignal, onCommit),\n target,\n onDialog,\n retryRefusal,\n directionalFingerprint,\n requirePendingAdoption,\n );\n };\n if (!rawArgs.trim()) {\n attention.expand();\n try {\n const { showSyncManager } = await import(\"../ui/manager-ui.js\");\n if (sessionSignal.aborted) return;\n await showSyncManager(ctx, run, sessionSignal, {\n needsDaemonRecovery,\n getPendingPullReview: () => currentPiDaemonClient()?.pendingPullReview,\n getAttention: () => attention.current(),\n getObservation: () => attention.observation(),\n onObservationInvalidated: () => attention.clearObservation(),\n onSelectionResolved: (expected) => {\n if (attention.current() === expected) attention.clear(ctx);\n },\n });\n } catch (error) {\n if (sessionSignal.aborted) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(errorMessage(error), \"error\");\n }\n if (sessionSignal.aborted || needsDaemonRecovery?.()) return;\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n return;\n }\n const result = await run(rawArgs);\n if (sessionSignal.aborted || needsDaemonRecovery?.()) return;\n if (result.kind === \"decision-required\") {\n ctx.ui.notify(result.decision.directMessage, \"error\");\n } else if (result.kind === \"remote-selection-required\") {\n const origin = directSelectionOrigin(rawArgs);\n if (origin) attention.set(result.decision, origin);\n const deterministic = splitArgs(rawArgs).some((arg) => arg === \"--yes\" || arg === \"-y\");\n if (origin && ctx.mode === \"tui\" && !deterministic) {\n await resolveSelectionAttention(ctx, attention, sessionSignal, loaders);\n } else {\n ctx.ui.notify(\n formatRemoteSelectionMismatch(\n result.decision.setupName,\n result.decision.localInclude,\n result.decision.remoteInclude,\n ),\n \"error\",\n );\n }\n }\n await clearAttentionAfterCompletedOperation(rawArgs, result, ctx, attention, sessionSignal);\n await reconcileSelectionAttention(ctx, attention, sessionSignal);\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n}\n\nfunction observationCommitCallback(\n attention: SyncAttentionController,\n sessionSignal: AbortSignal,\n onCommit?: () => void,\n) {\n const observed = attention.observation();\n return () => {\n // Opening or cancelling a review changes nothing. A commit may change data\n // even if later publication/baseline cleanup fails; never restore old hints.\n if (!sessionSignal.aborted && attention.observation() === observed) attention.clearObservation();\n onCommit?.();\n };\n}\n\nasync function reconcileObservation(attention: SyncAttentionController, signal: AbortSignal) {\n const observed = attention.observation();\n if (!observed || signal.aborted) return;\n try {\n const config = await loadConfig();\n if (signal.aborted || attention.observation() !== observed) return;\n if (!observationMatchesConfig(observed, config)) {\n attention.clearObservation();\n return;\n }\n const state = await readStateForConfig(config);\n if (signal.aborted || attention.observation() !== observed) return;\n if (syncStateFingerprint(state) !== observed.inspection.stateIdentity) attention.clearObservation();\n } catch {\n if (!signal.aborted && attention.observation() === observed) attention.clearObservation();\n }\n}\n\nasync function clearAttentionAfterCompletedOperation(\n rawArgs: string,\n result: RunRouteResult,\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n if (result.kind !== \"completed\" || result.outcome === \"cancelled\" || signal.aborted) return;\n const [command, ...rest] = splitArgs(rawArgs);\n if (command !== \"sync\" && command !== \"pull\" && command !== \"push\") return;\n const current = attention.current();\n if (!current) return;\n try {\n const options = parseOptions(rest);\n const setupName = options.setup ?? (await loadConfig()).setupName;\n if (signal.aborted || attention.current() !== current) return;\n if (current.decision.setupName === setupName) attention.clear(ctx);\n } catch {\n // Attention reconciliation below owns malformed or concurrently changed settings.\n }\n}\n\nasync function reconcileSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n try {\n const config = await loadConfig(current.decision.setupName);\n if (signal.aborted || attention.current() !== current) return;\n if (!syncAttentionMatchesConfig(current, config)) attention.clear(ctx);\n } catch {\n if (!signal.aborted && attention.current() === current) attention.clear(ctx);\n }\n}\n\nfunction directSelectionOrigin(rawArgs: string): SyncAttentionOrigin | undefined {\n const command = splitArgs(rawArgs)[0];\n return command === \"sync\" || command === \"pull\" || command === \"push\" ? command : undefined;\n}\n\nexport async function resolveSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n loaders: SyncLoaders,\n options: {\n cancelLabel?: string;\n withStateAccess?: <T>(task: () => Promise<T>) => Promise<T>;\n } = {},\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n const { dispatchManagerResult } = await import(\"../ui/manager-result-dispatcher.js\");\n if (signal.aborted || attention.current() !== current) return;\n await dispatchManagerResult(\n ctx,\n { kind: \"remote-selection-required\", decision: current.decision },\n current.origin,\n (route, actionSignal, onCommit, target) => {\n const execute = () =>\n executeRecoveryCommand(\n route,\n ctx,\n combineSignals(signal, actionSignal),\n loaders,\n observationCommitCallback(attention, signal, onCommit),\n target,\n );\n return options.withStateAccess ? options.withStateAccess(execute) : execute();\n },\n signal,\n {\n cancelLabel: options.cancelLabel,\n withStateAccess: options.withStateAccess,\n onSelectionResolved: () => {\n if (attention.current() === current) attention.clear(ctx);\n },\n },\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,2BAA2B;AAKpC,eAAsB,iBAAiB,KAAuB,QAAwB,QAAsB;AAC1G,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,wBAAoB,MAAM,OAAO,iBAAiB,MAAM,IAAI,SAAS;AAAA,EACvE,SAAS,OAAO;AACd,sBAAkB,iBAAiB,aAAa,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;AAAA,EACvE;AACA,UAAQ,eAAe;AACvB,SAAO,SAAS;AAChB,QAAM,SAAS,MAAM,oBAAoB,OAAO,MAAM,MAAM;AAC5D,UAAQ,eAAe;AACvB,SAAO,SAAS;AAChB,MAAI,CAAC,IAAI,MAAO;AAChB,QAAM,YAAY,OAAO,YAAY,QAAQ,OAAO,aAAa;AACjE,QAAM,WAAW,OA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AQ;AACN,QAAI,CAAC,OAAO,WAAW,UAAU,QAAQ,MAAM,QAAS,WAAU,MAAM,GAAG;AAAA,EAC7E;AACF;AAEA,SAAS,sBAAsB,SAAkD;AAC/E,QAAM,UAAU,UAAU,OAAO,EAAE,CAAC;AACpC,SAAO,YAAY,UAAU,YAAY,UAAU,YAAY,SAAS,UAAU;AACpF;AAEA,eAAsB,0BACpB,KACA,WACA,QACA,SACA,UAGI,CAAC,GACL;AACA,QAAM,UAAU,UAAU,QAAQ;AAClC,MAAI,CAAC,WAAW,OAAO,QAAS;AAChC,QAAM,EAAE,sBAAsB,IAAI,MAAM,OAAO,yCAAoC;AACnF,MAAI,OAAO,WAAW,UAAU,QAAQ,MAAM,QAAS;AACvD,QAAM;AAAA,IACJ;AAAA,IACA,EAAE,MAAM,6BAA6B,UAAU,QAAQ,SAAS;AAAA,IAChE,QAAQ;AAAA,IACR,CAAC,OAAO,cAAc,UAAU,WAAW;AACzC,YAAM,UAAU,MACd;AAAA,QACE;AAAA,QACA;AAAA,QACA,eAAe,QAAQ,YAAY;AAAA,QACnC;AAAA,QACA,0BAA0B,WAAW,QAAQ,QAAQ;AAAA,QACrD;AAAA,MACF;AACF,aAAO,QAAQ,kBAAkB,QAAQ,gBAAgB,OAAO,IAAI,QAAQ;AAAA,IAC9E;AAAA,IACA;AAAA,IACA;AAAA,MACE,aAAa,QAAQ;AAAA,MACrB,iBAAiB,QAAQ;AAAA,MACzB,qBAAqB,MAAM;AACzB,YAAI,UAAU,QAAQ,MAAM,QAAS,WAAU,MAAM,GAAG;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["args"]
|
|
7
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
remoteOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CQ4DMLH3.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -15,4 +15,4 @@ async function showConflicts(ctx, options) {
|
|
|
15
15
|
export {
|
|
16
16
|
showConflicts
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=conflict-review-
|
|
18
|
+
//# sourceMappingURL=conflict-review-GWEL4S6C.ts.map
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
ignoreFileSettingsAvailable,
|
|
5
5
|
portableIgnoreRulesAvailable,
|
|
6
6
|
showIgnoreFileAction
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-33EDXDLC.ts";
|
|
8
8
|
import "./chunk-KNEUL4XN.ts";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-CQ4DMLH3.ts";
|
|
10
10
|
import "./chunk-H7VOTY5N.ts";
|
|
11
11
|
import "./chunk-PUSMSKIM.ts";
|
|
12
12
|
import "./chunk-6YKOHBSC.ts";
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
portableIgnoreRulesAvailable,
|
|
19
19
|
showIgnoreFileAction
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=ignore-file-ui-
|
|
21
|
+
//# sourceMappingURL=ignore-file-ui-BEZZZIEE.ts.map
|
package/dist/chunks/{manager-result-dispatcher-PEVIGLOS.ts → manager-result-dispatcher-BXN46NRC.ts}
RENAMED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
dispatchManagerResult
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-HLJIRWFL.ts";
|
|
6
|
+
import "./chunk-X344HTVV.ts";
|
|
7
7
|
import "./chunk-UMPA5S7X.ts";
|
|
8
8
|
import "./chunk-H7VOTY5N.ts";
|
|
9
9
|
import "./chunk-PUSMSKIM.ts";
|
|
@@ -17,4 +17,4 @@ import "./chunk-2JNFEZ3V.ts";
|
|
|
17
17
|
export {
|
|
18
18
|
dispatchManagerResult
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=manager-result-dispatcher-
|
|
20
|
+
//# sourceMappingURL=manager-result-dispatcher-BXN46NRC.ts.map
|
|
@@ -18,19 +18,19 @@ import {
|
|
|
18
18
|
showEditS3Target,
|
|
19
19
|
showEditWebDavStorageProfile,
|
|
20
20
|
showEditWebDavTarget
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-AVTW6WNP.ts";
|
|
22
22
|
import {
|
|
23
23
|
automaticSyncSummary
|
|
24
24
|
} from "./chunk-ECYCNZOE.ts";
|
|
25
25
|
import {
|
|
26
26
|
ignoreFileSettingsAvailable,
|
|
27
27
|
showIgnoreFileAction
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-33EDXDLC.ts";
|
|
29
29
|
import "./chunk-KNEUL4XN.ts";
|
|
30
30
|
import {
|
|
31
31
|
dispatchManagerResult
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-HLJIRWFL.ts";
|
|
33
|
+
import "./chunk-X344HTVV.ts";
|
|
34
34
|
import {
|
|
35
35
|
SETUP_SWITCH_ACTION_OPTIONS,
|
|
36
36
|
saveOnSwitch,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
} from "./chunk-3Q3DMMID.ts";
|
|
63
63
|
import {
|
|
64
64
|
piDaemonClient
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-CQ4DMLH3.ts";
|
|
66
66
|
import {
|
|
67
67
|
throwIfAborted
|
|
68
68
|
} from "./chunk-UMPA5S7X.ts";
|
|
@@ -224,7 +224,7 @@ function blockedSyncMenuItem(label, manager) {
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
|
|
227
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
227
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-DOYKUMER.ts");
|
|
228
228
|
if (signal?.aborted) return "close";
|
|
229
229
|
const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
|
|
230
230
|
decision: attention.decision,
|
|
@@ -2072,7 +2072,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
2072
2072
|
"remote-include": async ({ state, signal: actionSignal }) => {
|
|
2073
2073
|
if (state.reservedIgnoreNames !== void 0 && !ignoreAvailable) return { kind: "rejected" };
|
|
2074
2074
|
const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
2075
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
2075
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-DOYKUMER.ts");
|
|
2076
2076
|
if (reviewSignal.aborted) return { kind: "rejected" };
|
|
2077
2077
|
const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
|
|
2078
2078
|
origin: "settings",
|
|
@@ -2330,7 +2330,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
|
|
|
2330
2330
|
if (!attention) {
|
|
2331
2331
|
const observation = state.manager.observation;
|
|
2332
2332
|
if (!observation) return { kind: "stay" };
|
|
2333
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
2333
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-DOYKUMER.ts");
|
|
2334
2334
|
if (sessionSignal?.aborted) return { kind: "close" };
|
|
2335
2335
|
const config = await loadConfig();
|
|
2336
2336
|
if (sessionSignal?.aborted) return { kind: "close" };
|
|
@@ -2681,4 +2681,4 @@ function syncMainMenuItem(label) {
|
|
|
2681
2681
|
export {
|
|
2682
2682
|
showSyncManager
|
|
2683
2683
|
};
|
|
2684
|
-
//# sourceMappingURL=manager-ui-
|
|
2684
|
+
//# sourceMappingURL=manager-ui-FS4QIKRA.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
showRemoteSelectionReview
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-X344HTVV.ts";
|
|
6
6
|
import "./chunk-UMPA5S7X.ts";
|
|
7
7
|
import "./chunk-H7VOTY5N.ts";
|
|
8
8
|
import "./chunk-PUSMSKIM.ts";
|
|
@@ -16,4 +16,4 @@ import "./chunk-2JNFEZ3V.ts";
|
|
|
16
16
|
export {
|
|
17
17
|
showRemoteSelectionReview
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=remote-selection-ui-
|
|
19
|
+
//# sourceMappingURL=remote-selection-ui-DOYKUMER.ts.map
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
showGitSetup,
|
|
6
6
|
showS3Setup,
|
|
7
7
|
showWebDavSetup
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AVTW6WNP.ts";
|
|
9
9
|
import "./chunk-ECYCNZOE.ts";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-33EDXDLC.ts";
|
|
11
11
|
import "./chunk-KNEUL4XN.ts";
|
|
12
12
|
import {
|
|
13
13
|
validateConfigName
|
|
14
14
|
} from "./chunk-APZVJAEW.ts";
|
|
15
15
|
import "./chunk-WBIOSK76.ts";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-CQ4DMLH3.ts";
|
|
17
17
|
import {
|
|
18
18
|
throwIfAborted
|
|
19
19
|
} from "./chunk-UMPA5S7X.ts";
|
|
@@ -95,4 +95,4 @@ async function showSetupWizard(ctx, signal) {
|
|
|
95
95
|
export {
|
|
96
96
|
showSetupWizard
|
|
97
97
|
};
|
|
98
|
-
//# sourceMappingURL=setup-wizard-
|
|
98
|
+
//# sourceMappingURL=setup-wizard-PI45SF2C.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
currentPiDaemonClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CQ4DMLH3.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -20,4 +20,4 @@ var inspectSync = async (config, _options, signal) => await currentPiDaemonClien
|
|
|
20
20
|
export {
|
|
21
21
|
inspectSync
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=sync-inspection-
|
|
23
|
+
//# sourceMappingURL=sync-inspection-DI5J6EUH.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
remoteOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CQ4DMLH3.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -46,4 +46,4 @@ export {
|
|
|
46
46
|
status,
|
|
47
47
|
syncBoth
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=sync-operations-
|
|
49
|
+
//# sourceMappingURL=sync-operations-AGNL7QXA.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"57fb4c8aea5d92010ee8ed2f1c4cb06efef255187074c7c1ddb67f28e6a6641c"
|
|
@@ -2,7 +2,27 @@ import { readFileSync } from "node:fs";
|
|
|
2
2
|
import { valid } from "semver";
|
|
3
3
|
// Capture the installed build at module load. A later package update must not
|
|
4
4
|
// change the version advertised by an already running process.
|
|
5
|
-
const { version } =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export const { version: DAEMON_BUILD_VERSION, id: DAEMON_BUILD_ID } = readInstalledDaemonBuild();
|
|
6
|
+
export function readInstalledDaemonBuild() {
|
|
7
|
+
const { version } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
8
|
+
if (typeof version !== "string" || valid(version) !== version)
|
|
9
|
+
throw new Error("Invalid Pi Sync daemon build version.");
|
|
10
|
+
return { version, id: readBuildId() };
|
|
11
|
+
}
|
|
12
|
+
export function isDaemonBuildId(value) {
|
|
13
|
+
return typeof value === "string" && /^[a-f0-9]{64}$/u.test(value);
|
|
14
|
+
}
|
|
15
|
+
function readBuildId() {
|
|
16
|
+
let value;
|
|
17
|
+
try {
|
|
18
|
+
value = JSON.parse(readFileSync(new URL("./build-id.json", import.meta.url), "utf8"));
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === "ENOENT")
|
|
22
|
+
return undefined;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
if (!isDaemonBuildId(value))
|
|
26
|
+
throw new Error("Invalid Pi Sync daemon build identifier.");
|
|
27
|
+
return value;
|
|
28
|
+
}
|
package/dist/daemon/dist/cli.js
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import "./child-sdk.mjs";
|
|
3
|
-
import path from "node:path";
|
|
4
3
|
import { setTimeout as delay } from "node:timers/promises";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { DAEMON_BUILD_ID, DAEMON_BUILD_VERSION } from "./build-version.js";
|
|
5
|
+
import { requestDaemon } from "./client-transport.js";
|
|
6
|
+
import { DaemonUpgradeBlockedError, ensureDaemon, restartDaemon } from "./daemon-startup.js";
|
|
7
|
+
import { inspectDaemonStatus } from "./daemon-status.js";
|
|
8
|
+
import { privateDirectory, readIdentity, runtimePaths } from "./identity.js";
|
|
8
9
|
import { openLifecycleLog } from "./lifecycle-log.js";
|
|
9
|
-
|
|
10
|
+
function reportLaunch(message) {
|
|
11
|
+
if (process.connected)
|
|
12
|
+
process.send?.(message, () => { });
|
|
13
|
+
}
|
|
10
14
|
export async function main(args) {
|
|
11
15
|
const [command = "help", flag, root, ...extra] = args;
|
|
12
16
|
if (["help", "--help", "-h"].includes(command)) {
|
|
13
17
|
console.log("pi-sync-daemon <start|status|stop|restart|repair-upgrade|serve> --root <canonical-agent-directory>\nLocal synchronization owner; no OS service registration. status/stop/repair-upgrade never start a service.\nrepair-upgrade revokes all retained unattended grants after verified exit and archives the pending upgrade records.");
|
|
14
18
|
return;
|
|
15
19
|
}
|
|
20
|
+
const expectedBuild = command === "serve" && extra[0] === "--expect-build" && extra.length === 3;
|
|
16
21
|
if (!["start", "status", "stop", "restart", "repair-upgrade", "serve"].includes(command) ||
|
|
17
22
|
flag !== "--root" ||
|
|
18
23
|
!root ||
|
|
19
|
-
extra.length)
|
|
24
|
+
(extra.length && !expectedBuild))
|
|
20
25
|
throw new Error("Use pi-sync-daemon --help for the supported commands.");
|
|
21
26
|
if (command === "repair-upgrade") {
|
|
22
27
|
const { repairUpgrade } = await import("./upgrade-repair.js");
|
|
@@ -24,7 +29,9 @@ export async function main(args) {
|
|
|
24
29
|
return;
|
|
25
30
|
}
|
|
26
31
|
if (command === "serve") {
|
|
27
|
-
|
|
32
|
+
if (expectedBuild && (extra[1] !== DAEMON_BUILD_VERSION || extra[2] !== (DAEMON_BUILD_ID ?? "")))
|
|
33
|
+
throw new Error("Installed daemon build does not match the launch request.");
|
|
34
|
+
reportLaunch({ type: "booting" });
|
|
28
35
|
const { createEngineService } = await import("./engine-service.js");
|
|
29
36
|
const { startServer } = await import("./server.js");
|
|
30
37
|
const paths = await runtimePaths(root);
|
|
@@ -83,59 +90,22 @@ export async function main(args) {
|
|
|
83
90
|
process.on("SIGTERM", stop);
|
|
84
91
|
process.on("SIGINT", stop);
|
|
85
92
|
// Parent disconnect means readiness IPC ended, not service shutdown.
|
|
86
|
-
|
|
93
|
+
reportLaunch({ type: "ready", identity: server.identity });
|
|
87
94
|
process.channel?.unref();
|
|
88
95
|
return;
|
|
89
96
|
}
|
|
90
|
-
if (command === "start") {
|
|
91
|
-
const { identity } = await ensureDaemon(root);
|
|
97
|
+
if (command === "start" || command === "restart") {
|
|
98
|
+
const { identity } = await (command === "start" ? ensureDaemon(root) : restartDaemon(root));
|
|
92
99
|
console.log(JSON.stringify({ running: true, root: identity.root, instance: identity.instance, pid: identity.pid }));
|
|
93
100
|
return;
|
|
94
101
|
}
|
|
95
|
-
const paths = await runtimePaths(root);
|
|
96
|
-
const identity = await readIdentity(paths);
|
|
97
102
|
if (command === "status") {
|
|
98
|
-
|
|
99
|
-
const summary = {
|
|
100
|
-
root: paths.root,
|
|
101
|
-
...(identity && { recordedPid: identity.pid }),
|
|
102
|
-
...(pending && { pendingUpgradePid: pending.pid }),
|
|
103
|
-
};
|
|
104
|
-
if (!identity ||
|
|
105
|
-
(pending?.instance === identity.instance && pending.pid === identity.pid && (await processExited(pending)))) {
|
|
106
|
-
console.log(JSON.stringify({ running: false, ...summary }));
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
try {
|
|
110
|
-
const status = await requestDaemon(paths, identity, "hello", {});
|
|
111
|
-
if (!record(status) ||
|
|
112
|
-
status.version !== 1 ||
|
|
113
|
-
status.root !== paths.root ||
|
|
114
|
-
status.instance !== identity.instance ||
|
|
115
|
-
status.pid !== identity.pid)
|
|
116
|
-
throw new Error("Daemon identity mismatch; no replacement was attempted.");
|
|
117
|
-
const build = typeof status.buildVersion === "string" ? valid(status.buildVersion) : null;
|
|
118
|
-
console.log(JSON.stringify({
|
|
119
|
-
running: true,
|
|
120
|
-
...summary,
|
|
121
|
-
version: status.version,
|
|
122
|
-
instance: identity.instance,
|
|
123
|
-
pid: identity.pid,
|
|
124
|
-
...(build && { buildVersion: build }),
|
|
125
|
-
lifecycleLog: path.join(paths.directory, "lifecycle.log"),
|
|
126
|
-
}));
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
// A failed hello does not prove the recorded owner exited.
|
|
130
|
-
console.log(JSON.stringify({ running: null, ...summary }));
|
|
131
|
-
}
|
|
103
|
+
console.log(JSON.stringify(await inspectDaemonStatus(root)));
|
|
132
104
|
return;
|
|
133
105
|
}
|
|
106
|
+
const paths = await runtimePaths(root);
|
|
107
|
+
const identity = await readIdentity(paths);
|
|
134
108
|
if (!identity) {
|
|
135
|
-
if (command === "restart") {
|
|
136
|
-
await main(["start", "--root", root]);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
109
|
console.log(JSON.stringify({ running: false, root: paths.root }));
|
|
140
110
|
return;
|
|
141
111
|
}
|
|
@@ -146,26 +116,21 @@ export async function main(args) {
|
|
|
146
116
|
throw new Error("Daemon did not drain; state retained. Do not force a second owner.");
|
|
147
117
|
await delay(25);
|
|
148
118
|
}
|
|
149
|
-
|
|
150
|
-
while (processExists(identity.pid)) {
|
|
151
|
-
if (Date.now() >= deadline)
|
|
152
|
-
throw new Error("Previous daemon is still exiting; restart was not attempted.");
|
|
153
|
-
await delay(25);
|
|
154
|
-
}
|
|
155
|
-
await main(["start", "--root", root]);
|
|
156
|
-
}
|
|
157
|
-
else
|
|
158
|
-
console.log(JSON.stringify({ stopped: true, root: paths.root }));
|
|
119
|
+
console.log(JSON.stringify({ stopped: true, root: paths.root }));
|
|
159
120
|
}
|
|
160
121
|
if (import.meta.main) {
|
|
161
|
-
void main(process.argv.slice(2)).catch(() => {
|
|
162
|
-
|
|
122
|
+
void main(process.argv.slice(2)).catch((error) => {
|
|
123
|
+
reportLaunch({
|
|
163
124
|
type: "error",
|
|
164
125
|
message: "Daemon initialization failed; private state retained. Check endpoint ownership and compatible versions.",
|
|
165
126
|
});
|
|
166
|
-
console.error(
|
|
167
|
-
?
|
|
168
|
-
:
|
|
127
|
+
console.error(error instanceof DaemonUpgradeBlockedError
|
|
128
|
+
? error.message
|
|
129
|
+
: process.argv[2] === "repair-upgrade"
|
|
130
|
+
? "Pi Sync upgrade repair failed. Check the pending PID, wait for confirmed exit, and check consent storage. Do not delete recovery files."
|
|
131
|
+
: process.argv[2] === "restart"
|
|
132
|
+
? "Pi Sync restart failed; private state retained. Check status, version compatibility, and retained unattended permission. Do not force a restart."
|
|
133
|
+
: "pi-sync-daemon failed; private state retained. Check root, endpoint ownership, and version compatibility.");
|
|
169
134
|
process.exitCode = 1;
|
|
170
135
|
});
|
|
171
136
|
}
|