@narumitw/pi-sync 0.51.1 → 0.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +30 -5
  2. package/dist/chunks/{chunk-7KHKWL3Q.ts → chunk-2CBF6SMT.ts} +8 -7
  3. package/dist/chunks/chunk-2CBF6SMT.ts.map +7 -0
  4. package/dist/chunks/{chunk-YFADF5ZQ.ts → chunk-2DI6PDZV.ts} +5 -1
  5. package/dist/chunks/chunk-2DI6PDZV.ts.map +7 -0
  6. package/dist/chunks/chunk-2GUXI2XT.ts +1702 -0
  7. package/dist/chunks/chunk-2GUXI2XT.ts.map +7 -0
  8. package/dist/chunks/{chunk-4MPIH46N.ts → chunk-3B4Z2SKV.ts} +40 -6
  9. package/dist/chunks/chunk-3B4Z2SKV.ts.map +7 -0
  10. package/dist/chunks/{chunk-YPXGU5OR.ts → chunk-4QVPTIZB.ts} +16 -6
  11. package/dist/chunks/{chunk-YPXGU5OR.ts.map → chunk-4QVPTIZB.ts.map} +2 -2
  12. package/dist/chunks/{chunk-UA7RXOIT.ts → chunk-4SBTAVFL.ts} +6 -6
  13. package/dist/chunks/{chunk-6546TS54.ts → chunk-5RZPINUQ.ts} +7 -4
  14. package/dist/chunks/{chunk-6546TS54.ts.map → chunk-5RZPINUQ.ts.map} +2 -2
  15. package/dist/chunks/chunk-76NB4R7U.ts +107 -0
  16. package/dist/chunks/chunk-76NB4R7U.ts.map +7 -0
  17. package/dist/chunks/{chunk-DM4X4FIA.ts → chunk-7D6RDCVC.ts} +8 -10
  18. package/dist/chunks/{chunk-DM4X4FIA.ts.map → chunk-7D6RDCVC.ts.map} +2 -2
  19. package/dist/chunks/chunk-A6HU4ERM.ts +124 -0
  20. package/dist/chunks/chunk-A6HU4ERM.ts.map +7 -0
  21. package/dist/chunks/chunk-AMJRUXFT.ts +17 -0
  22. package/dist/chunks/chunk-AMJRUXFT.ts.map +7 -0
  23. package/dist/chunks/chunk-ANWNQIR7.ts +1013 -0
  24. package/dist/chunks/chunk-ANWNQIR7.ts.map +7 -0
  25. package/dist/chunks/{chunk-T56RNRZJ.ts → chunk-BDB4IDM3.ts} +19 -10
  26. package/dist/chunks/chunk-BDB4IDM3.ts.map +7 -0
  27. package/dist/chunks/{chunk-2RZSQWBH.ts → chunk-CHSIAC4N.ts} +5 -5
  28. package/dist/chunks/{chunk-2RZSQWBH.ts.map → chunk-CHSIAC4N.ts.map} +2 -2
  29. package/dist/chunks/chunk-HUZ5CR4W.ts +110 -0
  30. package/dist/chunks/chunk-HUZ5CR4W.ts.map +7 -0
  31. package/dist/chunks/{chunk-QLSN7AGX.ts → chunk-IJ6VV6FN.ts} +81 -19
  32. package/dist/chunks/chunk-IJ6VV6FN.ts.map +7 -0
  33. package/dist/chunks/chunk-ORQRHEEO.ts +362 -0
  34. package/dist/chunks/chunk-ORQRHEEO.ts.map +7 -0
  35. package/dist/chunks/chunk-QE7NZZWT.ts +380 -0
  36. package/dist/chunks/chunk-QE7NZZWT.ts.map +7 -0
  37. package/dist/chunks/{chunk-HGJH56KR.ts → chunk-QHSQCK7L.ts} +4 -4
  38. package/dist/chunks/chunk-QOFMXPM5.ts +735 -0
  39. package/dist/chunks/chunk-QOFMXPM5.ts.map +7 -0
  40. package/dist/chunks/{chunk-DZUSTGQV.ts → chunk-UQ3ALBIB.ts} +4 -4
  41. package/dist/chunks/{chunk-Q32CQWPM.ts → chunk-V6VZ5TLG.ts} +13 -6
  42. package/dist/chunks/chunk-V6VZ5TLG.ts.map +7 -0
  43. package/dist/chunks/{chunk-E42GXD6D.ts → chunk-WKPX2SIC.ts} +4 -4
  44. package/dist/chunks/chunk-ZW5ZLGBI.ts +154 -0
  45. package/dist/chunks/chunk-ZW5ZLGBI.ts.map +7 -0
  46. package/dist/chunks/{chunk-6NT3YFGY.ts → chunk-ZX2Q6THB.ts} +8 -3
  47. package/dist/chunks/{chunk-6NT3YFGY.ts.map → chunk-ZX2Q6THB.ts.map} +2 -2
  48. package/dist/chunks/conflict-artifacts-BB2FZMIE.ts +27 -0
  49. package/dist/chunks/conflict-review-T3PB7ZSD.ts +175 -0
  50. package/dist/chunks/conflict-review-T3PB7ZSD.ts.map +7 -0
  51. package/dist/chunks/{file-selection-RAVHRYFG.ts → file-selection-WZX7HAY2.ts} +8 -7
  52. package/dist/chunks/{file-selection-RAVHRYFG.ts.map → file-selection-WZX7HAY2.ts.map} +1 -1
  53. package/dist/chunks/{git-backend-IAANDL3K.ts → git-backend-HLGKUQJT.ts} +19 -7
  54. package/dist/chunks/git-backend-HLGKUQJT.ts.map +7 -0
  55. package/dist/chunks/local-fields-6DGYOOIK.ts +22 -0
  56. package/dist/chunks/manager-result-dispatcher-VIDT3QBU.ts +23 -0
  57. package/dist/chunks/{manager-ui-763NEKJY.ts → manager-ui-HSMHS3OK.ts} +236 -57
  58. package/dist/chunks/manager-ui-HSMHS3OK.ts.map +7 -0
  59. package/dist/chunks/merge-baseline-store-EVQAAML6.ts +22 -0
  60. package/dist/chunks/remote-selection-ui-SMF5CLFO.ts +22 -0
  61. package/dist/chunks/{s3-backend-XGXUOPUN.ts → s3-backend-DJ2NT3SZ.ts} +16 -9
  62. package/dist/chunks/s3-backend-DJ2NT3SZ.ts.map +7 -0
  63. package/dist/chunks/{setup-switch-5G2VNJHL.ts → setup-switch-KTUWL6DE.ts} +9 -6
  64. package/dist/chunks/{setup-wizard-YIEWGX32.ts → setup-wizard-GSDPDFC4.ts} +10 -7
  65. package/dist/chunks/{setup-wizard-YIEWGX32.ts.map → setup-wizard-GSDPDFC4.ts.map} +1 -1
  66. package/dist/chunks/{snapshot-JL5DFSXI.ts → snapshot-THS5EY2L.ts} +6 -9
  67. package/dist/chunks/snapshot-THS5EY2L.ts.map +7 -0
  68. package/dist/chunks/{sync-inspection-P3ENJLNF.ts → sync-inspection-VBJF2FWC.ts} +10 -10
  69. package/dist/chunks/sync-inspection-VBJF2FWC.ts.map +7 -0
  70. package/dist/chunks/{sync-operations-AR76EB6C.ts → sync-operations-27VQUDH2.ts} +309 -508
  71. package/dist/chunks/sync-operations-27VQUDH2.ts.map +7 -0
  72. package/dist/chunks/{sync-state-VHJUZ4YG.ts → sync-state-CFL4RRRB.ts} +6 -6
  73. package/dist/chunks/sync-state-CFL4RRRB.ts.map +7 -0
  74. package/dist/chunks/{webdav-backend-3EGUONAT.ts → webdav-backend-ETQGSI6I.ts} +13 -7
  75. package/dist/chunks/webdav-backend-ETQGSI6I.ts.map +7 -0
  76. package/dist/index.ts +142 -43
  77. package/dist/index.ts.map +2 -2
  78. package/docs/content-merge-audit.md +156 -0
  79. package/docs/merge-implementation-audit.md +312 -0
  80. package/docs/settings-merge-audit.md +153 -0
  81. package/docs/settings.md +36 -0
  82. package/package.json +5 -5
  83. package/src/backends/git/git-backend.ts +2 -0
  84. package/src/backends/git/git-storage.ts +8 -3
  85. package/src/backends/s3/s3-backend.ts +2 -1
  86. package/src/backends/webdav/webdav-backend.ts +2 -1
  87. package/src/commands/command-execution.ts +10 -0
  88. package/src/commands/command.ts +4 -0
  89. package/src/settings/config.ts +12 -0
  90. package/src/settings/settings-management.ts +2 -2
  91. package/src/settings/settings-types.ts +14 -1
  92. package/src/settings/settings-validation.ts +24 -3
  93. package/src/snapshot/session-paths.ts +34 -7
  94. package/src/snapshot/snapshot-apply.ts +81 -32
  95. package/src/snapshot/snapshot-case-replacement.ts +80 -0
  96. package/src/snapshot/snapshot-codec.ts +6 -1
  97. package/src/snapshot/snapshot-root-transition.ts +154 -0
  98. package/src/snapshot/snapshot-transaction-plan.ts +72 -0
  99. package/src/snapshot/snapshot-transaction.ts +844 -102
  100. package/src/snapshot/snapshot-types.ts +5 -0
  101. package/src/state/json-file.ts +32 -5
  102. package/src/state/merge-baseline-store.ts +182 -0
  103. package/src/state/mutation-directory-sync.ts +34 -0
  104. package/src/state/state-types.ts +4 -0
  105. package/src/state/sync-state-store.ts +14 -1
  106. package/src/sync/automatic-sync.ts +11 -3
  107. package/src/sync/conflict-artifact-ownership.ts +63 -0
  108. package/src/sync/conflict-artifacts.ts +195 -0
  109. package/src/sync/conflict-groups.ts +68 -0
  110. package/src/sync/conflict-preview.ts +56 -0
  111. package/src/sync/conflict-resolution.ts +93 -0
  112. package/src/sync/conflict-retention.ts +72 -0
  113. package/src/sync/conflict-review.ts +95 -0
  114. package/src/sync/content-conflicts.ts +73 -0
  115. package/src/sync/field-migration.ts +39 -0
  116. package/src/sync/file-merge-planner.ts +143 -0
  117. package/src/sync/json-document.ts +184 -0
  118. package/src/sync/local-fields.ts +134 -0
  119. package/src/sync/merge-apply.ts +380 -0
  120. package/src/sync/merge-journal.ts +219 -0
  121. package/src/sync/merged-sync.ts +723 -0
  122. package/src/sync/partial-progress.ts +54 -0
  123. package/src/sync/remote-snapshot.ts +6 -0
  124. package/src/sync/session-merge.ts +194 -0
  125. package/src/sync/settings-conflicts.ts +52 -0
  126. package/src/sync/settings-merge.ts +57 -0
  127. package/src/sync/startup-check.ts +90 -5
  128. package/src/sync/sync-inspection.ts +1 -0
  129. package/src/sync/sync-local.ts +61 -0
  130. package/src/sync/sync-mutations.ts +256 -114
  131. package/src/sync/sync-queries.ts +6 -2
  132. package/src/sync/sync-state.ts +14 -5
  133. package/src/sync/text-merge.ts +133 -0
  134. package/src/sync-extension.ts +8 -0
  135. package/src/ui/manager-state.ts +12 -1
  136. package/src/ui/manager-ui.ts +10 -0
  137. package/src/ui/merge-review.ts +28 -0
  138. package/src/ui/remote-selection-ui.ts +1 -0
  139. package/src/ui/settings-ui.ts +183 -2
  140. package/src/ui/setup/setup-actions.ts +2 -2
  141. package/src/ui/setup/setup-switcher.ts +2 -1
  142. package/src/ui/storage-connections-ui.ts +11 -7
  143. package/src/ui/sync-attention.ts +3 -0
  144. package/src/ui/sync-format.ts +16 -12
  145. package/src/ui/sync-setups-ui.ts +1 -0
  146. package/src/ui/terminal-text.ts +9 -2
  147. package/dist/chunks/chunk-4AIHXRKE.ts +0 -197
  148. package/dist/chunks/chunk-4AIHXRKE.ts.map +0 -7
  149. package/dist/chunks/chunk-4MPIH46N.ts.map +0 -7
  150. package/dist/chunks/chunk-7KHKWL3Q.ts.map +0 -7
  151. package/dist/chunks/chunk-EEJPYTWE.ts +0 -348
  152. package/dist/chunks/chunk-EEJPYTWE.ts.map +0 -7
  153. package/dist/chunks/chunk-IVXEDPAD.ts +0 -370
  154. package/dist/chunks/chunk-IVXEDPAD.ts.map +0 -7
  155. package/dist/chunks/chunk-MSSW6F3R.ts +0 -12
  156. package/dist/chunks/chunk-MSSW6F3R.ts.map +0 -7
  157. package/dist/chunks/chunk-OVDTF5CH.ts +0 -90
  158. package/dist/chunks/chunk-OVDTF5CH.ts.map +0 -7
  159. package/dist/chunks/chunk-Q32CQWPM.ts.map +0 -7
  160. package/dist/chunks/chunk-QLSN7AGX.ts.map +0 -7
  161. package/dist/chunks/chunk-SWUXA3MH.ts +0 -18
  162. package/dist/chunks/chunk-SWUXA3MH.ts.map +0 -7
  163. package/dist/chunks/chunk-T56RNRZJ.ts.map +0 -7
  164. package/dist/chunks/chunk-YFADF5ZQ.ts.map +0 -7
  165. package/dist/chunks/git-backend-IAANDL3K.ts.map +0 -7
  166. package/dist/chunks/manager-result-dispatcher-OTUMQM26.ts +0 -23
  167. package/dist/chunks/manager-ui-763NEKJY.ts.map +0 -7
  168. package/dist/chunks/remote-selection-ui-TZTJF32Y.ts +0 -22
  169. package/dist/chunks/s3-backend-XGXUOPUN.ts.map +0 -7
  170. package/dist/chunks/sync-operations-AR76EB6C.ts.map +0 -7
  171. package/dist/chunks/webdav-backend-3EGUONAT.ts.map +0 -7
  172. /package/dist/chunks/{chunk-UA7RXOIT.ts.map → chunk-4SBTAVFL.ts.map} +0 -0
  173. /package/dist/chunks/{chunk-HGJH56KR.ts.map → chunk-QHSQCK7L.ts.map} +0 -0
  174. /package/dist/chunks/{chunk-DZUSTGQV.ts.map → chunk-UQ3ALBIB.ts.map} +0 -0
  175. /package/dist/chunks/{chunk-E42GXD6D.ts.map → chunk-WKPX2SIC.ts.map} +0 -0
  176. /package/dist/chunks/{manager-result-dispatcher-OTUMQM26.ts.map → conflict-artifacts-BB2FZMIE.ts.map} +0 -0
  177. /package/dist/chunks/{remote-selection-ui-TZTJF32Y.ts.map → local-fields-6DGYOOIK.ts.map} +0 -0
  178. /package/dist/chunks/{setup-switch-5G2VNJHL.ts.map → manager-result-dispatcher-VIDT3QBU.ts.map} +0 -0
  179. /package/dist/chunks/{snapshot-JL5DFSXI.ts.map → merge-baseline-store-EVQAAML6.ts.map} +0 -0
  180. /package/dist/chunks/{sync-inspection-P3ENJLNF.ts.map → remote-selection-ui-SMF5CLFO.ts.map} +0 -0
  181. /package/dist/chunks/{sync-state-VHJUZ4YG.ts.map → setup-switch-KTUWL6DE.ts.map} +0 -0
@@ -1,348 +0,0 @@
1
- // @generated by scripts/build-runtime.mjs; do not edit.
2
- // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
- import {
4
- sessionStorageRoot
5
- } from "./chunk-SWUXA3MH.ts";
6
- import {
7
- agentDir,
8
- configuredSessionDir
9
- } from "./chunk-OVDTF5CH.ts";
10
- import {
11
- DEFAULT_SYNC_INCLUDE,
12
- canonicalSnapshotPathForConfig,
13
- customIncludePathsByLower,
14
- includeFromSelectionConfig,
15
- isConfiguredSnapshotPath,
16
- isDeniedPath,
17
- isPreservableUnmanagedSnapshotPath,
18
- normalizeExtraFiles,
19
- normalizeSyncFiles,
20
- posixJoin,
21
- safeJoin,
22
- selectionForSnapshot,
23
- snapshotSelectionInclude,
24
- syncIncludeSelection,
25
- toPosix
26
- } from "./chunk-IVXEDPAD.ts";
27
-
28
- // src/snapshot/snapshot.ts
29
- import { createHash, randomUUID } from "node:crypto";
30
- import fs from "node:fs/promises";
31
- import os from "node:os";
32
- import path from "node:path";
33
- var VERSION = 1;
34
- var TOP_LEVEL_FILES = DEFAULT_SYNC_INCLUDE.filter((name) => name.includes("."));
35
- var TOP_LEVEL_DIRS = new Set(DEFAULT_SYNC_INCLUDE.filter((name) => !name.includes(".")));
36
- var SECRET_PATTERNS = [
37
- /AWS_SECRET_ACCESS_KEY\s*[=:]\s*['"]?[A-Za-z0-9/+]{35,}/i,
38
- /(ANTHROPIC|OPENAI|GEMINI|GOOGLE|FIRECRAWL|GITHUB|CLOUDFLARE|R2|S3)_[A-Z0-9_]*(KEY|TOKEN|SECRET)\s*[=:]\s*['"]?[^\s'"]{12,}/i,
39
- /sk-ant-[A-Za-z0-9_-]{20,}/,
40
- /sk-[A-Za-z0-9]{20,}/,
41
- /gh[pousr]_[A-Za-z0-9_]{20,}/
42
- ];
43
- function selectTopLevelFileEntry(entries, fileName) {
44
- const exact = entries.find((entry) => entry.isFile() && entry.name === fileName);
45
- if (exact) return exact;
46
- const lower = fileName.toLowerCase();
47
- return entries.filter((entry) => entry.isFile() && entry.name.toLowerCase() === lower).sort((left, right) => left.name.localeCompare(right.name))[0];
48
- }
49
- function sha256(value) {
50
- return createHash("sha256").update(value).digest("hex");
51
- }
52
- function isSafeSnapshotPath(relativePath) {
53
- if (relativePath.includes("\\")) return false;
54
- const normalized = toPosix(relativePath);
55
- return Boolean(normalized) && normalized !== "." && normalized !== ".." && !normalized.startsWith("../") && !path.posix.isAbsolute(normalized) && path.posix.normalize(normalized) === normalized && !isDeniedPath(normalized);
56
- }
57
- function snapshotsMatch(left, right) {
58
- const leftHashes = new Map(left.files.map((file) => [file.path, file.sha256]));
59
- const rightHashes = new Map(right.files.map((file) => [file.path, file.sha256]));
60
- return left.syncSessions === right.syncSessions && sameOptionalInclude(snapshotSelectionInclude(left), snapshotSelectionInclude(right)) && leftHashes.size === rightHashes.size && [...leftHashes].every(([filePath, hash]) => rightHashes.get(filePath) === hash);
61
- }
62
- function snapshotId() {
63
- return `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${randomUUID().slice(0, 8)}`;
64
- }
65
- function regenerateSnapshotIdentity(snapshot) {
66
- return {
67
- ...snapshot,
68
- id: snapshotId(),
69
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
70
- machine: os.hostname()
71
- };
72
- }
73
- async function createSnapshot(profile, options = {}) {
74
- options.signal?.throwIfAborted();
75
- const include = effectiveInclude(options);
76
- const syncSessions = include.includes("sessions");
77
- const sessionDir = options.sessionDir ?? await configuredSessionDir();
78
- options.signal?.throwIfAborted();
79
- const files = await collectFiles(agentDir(), { include, sessionDir, signal: options.signal });
80
- options.signal?.throwIfAborted();
81
- return {
82
- version: VERSION,
83
- id: snapshotId(),
84
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
85
- machine: os.hostname(),
86
- profile,
87
- syncSessions,
88
- selection: selectionForSnapshot(include),
89
- files
90
- };
91
- }
92
- function effectiveInclude(options) {
93
- if (options.include) return options.include;
94
- return [
95
- ...normalizeSyncFiles(options.syncFiles),
96
- ...normalizeExtraFiles(options.extraFiles),
97
- ...options.syncSessions ? ["sessions"] : []
98
- ];
99
- }
100
- async function collectFiles(root, options = {}) {
101
- const signal = options.signal;
102
- signal?.throwIfAborted();
103
- const results = [];
104
- const entries = await fs.readdir(root, { withFileTypes: true });
105
- signal?.throwIfAborted();
106
- const selection = syncIncludeSelection(effectiveInclude(options));
107
- const selectedFiles = new Set(selection.builtIns);
108
- for (const entry of entries) {
109
- if (entry.isDirectory() && TOP_LEVEL_DIRS.has(entry.name) && selectedFiles.has(entry.name)) {
110
- await collectDirectory(results, root, entry.name, { signal });
111
- }
112
- }
113
- for (const fileName of TOP_LEVEL_FILES) {
114
- if (!selectedFiles.has(fileName)) continue;
115
- const entry = selectTopLevelFileEntry(entries, fileName);
116
- if (entry) await addFile(results, root, entry.name, fileName, signal);
117
- }
118
- for (const relativePath of selection.custom) {
119
- await collectIncludedPath(results, root, relativePath, signal);
120
- }
121
- if (selection.sessions) {
122
- try {
123
- await collectDirectory(results, sessionStorageRoot(root, options.sessionDir), "", {
124
- sessionsOnly: true,
125
- virtualPrefix: "sessions",
126
- signal
127
- });
128
- } catch (error) {
129
- if (error.code !== "ENOENT") throw error;
130
- }
131
- }
132
- signal?.throwIfAborted();
133
- return results.sort((left, right) => left.path.localeCompare(right.path));
134
- }
135
- async function collectIncludedPath(results, root, relativePath, signal) {
136
- signal?.throwIfAborted();
137
- const absolutePath = safeJoin(root, relativePath);
138
- try {
139
- const stat = await fs.lstat(absolutePath);
140
- signal?.throwIfAborted();
141
- if (stat.isFile()) await addFile(results, root, relativePath, relativePath, signal);
142
- else if (stat.isDirectory()) await collectDirectory(results, root, relativePath, { signal });
143
- } catch (error) {
144
- if (error.code !== "ENOENT") throw error;
145
- if (!relativePath.includes("/")) {
146
- const entries = await fs.readdir(root, { withFileTypes: true });
147
- signal?.throwIfAborted();
148
- const entry = selectTopLevelFileEntry(entries, relativePath);
149
- if (entry) await addFile(results, root, entry.name, relativePath, signal);
150
- }
151
- }
152
- }
153
- async function collectDirectory(results, root, relativeDirectory, options = {}) {
154
- options.signal?.throwIfAborted();
155
- const absoluteDirectory = path.join(root, relativeDirectory);
156
- for (const entry of await fs.readdir(absoluteDirectory, { withFileTypes: true })) {
157
- options.signal?.throwIfAborted();
158
- const relativePath = relativeDirectory ? posixJoin(relativeDirectory, entry.name) : entry.name;
159
- const snapshotPath = options.virtualPrefix ? posixJoin(options.virtualPrefix, relativePath) : relativePath;
160
- if (isDeniedPath(snapshotPath)) continue;
161
- if (entry.isDirectory()) {
162
- await collectDirectory(results, root, relativePath, options);
163
- } else if (entry.isFile() && (!options.sessionsOnly || isSessionFilePath(snapshotPath))) {
164
- await addFile(results, root, relativePath, snapshotPath, options.signal);
165
- }
166
- }
167
- }
168
- async function addFile(results, root, relativePath, snapshotPath = relativePath, signal) {
169
- signal?.throwIfAborted();
170
- if (!isSafeSnapshotPath(snapshotPath)) return;
171
- const absolutePath = safeJoin(root, relativePath);
172
- const content = await fs.readFile(absolutePath, { signal });
173
- signal?.throwIfAborted();
174
- results.push({
175
- path: snapshotPath,
176
- contentBase64: content.toString("base64"),
177
- sha256: sha256(content)
178
- });
179
- }
180
- function isSessionPath(relativePath) {
181
- return toPosix(relativePath).startsWith("sessions/");
182
- }
183
- function isSessionFilePath(relativePath) {
184
- const normalized = toPosix(relativePath);
185
- return isSessionPath(normalized) && normalized.endsWith(".jsonl");
186
- }
187
- function sessionSnapshotPathFromAbsolute(sessionFile, configuredSessionDir2) {
188
- const relativePath = toPosix(path.relative(sessionStorageRoot(agentDir(), configuredSessionDir2), sessionFile));
189
- if (!relativePath || relativePath.startsWith("../") || path.posix.isAbsolute(relativePath)) {
190
- return void 0;
191
- }
192
- const snapshotPath = posixJoin("sessions", relativePath);
193
- return isSessionFilePath(snapshotPath) ? snapshotPath : void 0;
194
- }
195
- function snapshotTarget(root, relativePath, configuredSessionDir2) {
196
- if (isSessionPath(relativePath)) {
197
- return safeJoin(sessionStorageRoot(root, configuredSessionDir2), relativePath.slice("sessions/".length));
198
- }
199
- return safeJoin(root, relativePath);
200
- }
201
- function snapshotIncludesSessions(snapshot) {
202
- return snapshot.syncSessions === true || snapshotSelectionInclude(snapshot)?.includes("sessions") === true || snapshot.files.some((file) => isSessionPath(file.path));
203
- }
204
- function filterSnapshotForConfigPolicy(snapshot, config, options = {}) {
205
- const include = includeFromSelectionConfig(config);
206
- const includePaths = customIncludePathsByLower(include);
207
- const filtered = {
208
- ...snapshot,
209
- syncSessions: include.includes("sessions") ? snapshot.syncSessions : false,
210
- selection: selectionForSnapshot(include),
211
- files: canonicalizeSnapshotFilesForConfig(snapshot.files, config, includePaths)
212
- };
213
- if (!options.regenerateId || snapshotsMatch(snapshot, filtered)) return filtered;
214
- return {
215
- ...filtered,
216
- id: snapshotId(),
217
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
218
- machine: os.hostname()
219
- };
220
- }
221
- function canonicalizeSnapshotFilesForConfig(files, config, includePaths) {
222
- const configuredFiles = [];
223
- const extraCandidates = /* @__PURE__ */ new Map();
224
- for (const file of files) {
225
- const normalized = toPosix(file.path);
226
- if (!isSafeSnapshotPath(file.path) || !isConfiguredSnapshotPath(normalized, config)) {
227
- continue;
228
- }
229
- if (normalized.includes("/")) {
230
- configuredFiles.push(normalized === file.path ? file : { ...file, path: normalized });
231
- continue;
232
- }
233
- const topLevelPath = canonicalSnapshotPathForConfig(normalized, includePaths);
234
- const candidate = {
235
- exact: normalized === topLevelPath,
236
- file: { ...file, path: topLevelPath },
237
- originalPath: normalized
238
- };
239
- const current = extraCandidates.get(topLevelPath.toLowerCase());
240
- if (!current || isPreferredExtraCandidate(candidate, current)) {
241
- extraCandidates.set(topLevelPath.toLowerCase(), candidate);
242
- }
243
- }
244
- return [...configuredFiles, ...[...extraCandidates.values()].map((candidate) => candidate.file)].sort(
245
- (left, right) => left.path.localeCompare(right.path)
246
- );
247
- }
248
- function isPreferredExtraCandidate(left, right) {
249
- if (left.exact !== right.exact) return left.exact;
250
- return left.originalPath.localeCompare(right.originalPath) < 0;
251
- }
252
- function snapshotWithoutSessions(snapshot) {
253
- const files = snapshot.files.filter((file) => !isSessionPath(file.path));
254
- const include = snapshotSelectionInclude(snapshot)?.filter((item) => item !== "sessions");
255
- if (files.length === snapshot.files.length && snapshot.syncSessions !== true && include?.length === snapshot.selection?.include.length) {
256
- return snapshot;
257
- }
258
- return {
259
- ...snapshot,
260
- id: snapshotId(),
261
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
262
- machine: os.hostname(),
263
- syncSessions: false,
264
- ...include ? { selection: selectionForSnapshot(include) } : {},
265
- files
266
- };
267
- }
268
- function scanSnapshot(snapshot) {
269
- const findings = [];
270
- for (const file of snapshot.files) {
271
- const content = Buffer.from(file.contentBase64, "base64");
272
- if (content.includes(0)) continue;
273
- const text = content.toString("utf8");
274
- for (const pattern of SECRET_PATTERNS) {
275
- if (pattern.test(text)) {
276
- findings.push(file.path);
277
- break;
278
- }
279
- }
280
- }
281
- return findings;
282
- }
283
- function mergeRemotePreservedFiles(local, remote, config) {
284
- const localPathNames = new Set(local.files.map((file) => file.path.toLowerCase()));
285
- const preservedPathNames = /* @__PURE__ */ new Set();
286
- const preserved = remote.files.filter((file) => {
287
- const normalized = toPosix(file.path);
288
- const lower = normalized.toLowerCase();
289
- if (localPathNames.has(lower) || preservedPathNames.has(lower) || !isSafeSnapshotPath(file.path) || isConfiguredSnapshotPath(normalized, config) || !isPreservableUnmanagedSnapshotPath(normalized)) {
290
- return false;
291
- }
292
- preservedPathNames.add(lower);
293
- return true;
294
- });
295
- if (preserved.length === 0) return local;
296
- return {
297
- ...local,
298
- id: snapshotId(),
299
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
300
- machine: os.hostname(),
301
- syncSessions: snapshotIncludesSessions(local) || snapshotIncludesSessions(remote),
302
- files: [...local.files, ...preserved].sort((left, right) => left.path.localeCompare(right.path))
303
- };
304
- }
305
- function mergeRemoteSessionFiles(local, remote) {
306
- const remoteSessions = remote.files.filter((file) => {
307
- const normalized = toPosix(file.path);
308
- return isSessionFilePath(normalized) && isSafeSnapshotPath(file.path);
309
- });
310
- if (remoteSessions.length === 0 && !snapshotIncludesSessions(remote)) return local;
311
- const localInclude = snapshotSelectionInclude(local);
312
- return {
313
- ...local,
314
- id: snapshotId(),
315
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
316
- machine: os.hostname(),
317
- syncSessions: true,
318
- ...localInclude ? {
319
- selection: selectionForSnapshot(
320
- localInclude.includes("sessions") ? localInclude : [...localInclude, "sessions"]
321
- )
322
- } : {},
323
- files: [...local.files.filter((file) => !isSessionPath(file.path)), ...remoteSessions].sort(
324
- (left, right) => left.path.localeCompare(right.path)
325
- )
326
- };
327
- }
328
- function sameOptionalInclude(left, right) {
329
- if (!left || !right) return left === right;
330
- return left.length === right.length && left.every((item, index) => item === right[index]);
331
- }
332
-
333
- export {
334
- regenerateSnapshotIdentity,
335
- createSnapshot,
336
- collectFiles,
337
- isSessionPath,
338
- isSessionFilePath,
339
- sessionSnapshotPathFromAbsolute,
340
- snapshotTarget,
341
- snapshotIncludesSessions,
342
- filterSnapshotForConfigPolicy,
343
- snapshotWithoutSessions,
344
- scanSnapshot,
345
- mergeRemotePreservedFiles,
346
- mergeRemoteSessionFiles
347
- };
348
- //# sourceMappingURL=chunk-EEJPYTWE.ts.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/snapshot/snapshot.ts"],
4
- "sourcesContent": ["import { createHash, randomUUID } from \"node:crypto\";\nimport type { Dirent } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { isDeniedPath, posixJoin, safeJoin, toPosix } from \"../paths.js\";\nimport { agentDir, configuredSessionDir } from \"./session-paths.js\";\nimport { sessionStorageRoot } from \"./snapshot-paths.js\";\n\nexport { isDeniedPath } from \"../paths.js\";\nexport { sessionStorageRoot } from \"./snapshot-paths.js\";\n\nimport {\n canonicalSnapshotPathForConfig,\n customIncludePathsByLower,\n DEFAULT_SYNC_INCLUDE,\n includeFromSelectionConfig,\n isConfiguredSnapshotPath,\n isPreservableUnmanagedSnapshotPath,\n normalizeExtraFiles,\n normalizeSyncFiles,\n type SyncSelectionConfig,\n selectionForSnapshot,\n snapshotSelectionInclude,\n syncIncludeSelection,\n} from \"../sync/sync-policy.js\";\nimport type { Snapshot, SnapshotFile, SnapshotOptions } from \"./snapshot-types.js\";\n\nexport { canonicalSnapshotPathForConfig, isConfiguredSnapshotPath } from \"../sync/sync-policy.js\";\n\nconst VERSION = 1;\nconst TOP_LEVEL_FILES: readonly string[] = DEFAULT_SYNC_INCLUDE.filter((name) => name.includes(\".\"));\nconst TOP_LEVEL_DIRS = new Set<string>(DEFAULT_SYNC_INCLUDE.filter((name) => !name.includes(\".\")));\nconst SECRET_PATTERNS = [\n /AWS_SECRET_ACCESS_KEY\\s*[=:]\\s*['\"]?[A-Za-z0-9/+]{35,}/i,\n /(ANTHROPIC|OPENAI|GEMINI|GOOGLE|FIRECRAWL|GITHUB|CLOUDFLARE|R2|S3)_[A-Z0-9_]*(KEY|TOKEN|SECRET)\\s*[=:]\\s*['\"]?[^\\s'\"]{12,}/i,\n /sk-ant-[A-Za-z0-9_-]{20,}/,\n /sk-[A-Za-z0-9]{20,}/,\n /gh[pousr]_[A-Za-z0-9_]{20,}/,\n];\n\nfunction selectTopLevelFileEntry(entries: Dirent[], fileName: string) {\n const exact = entries.find((entry) => entry.isFile() && entry.name === fileName);\n if (exact) return exact;\n const lower = fileName.toLowerCase();\n return entries\n .filter((entry) => entry.isFile() && entry.name.toLowerCase() === lower)\n .sort((left, right) => left.name.localeCompare(right.name))[0];\n}\n\nfunction sha256(value: Buffer) {\n return createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nfunction isSafeSnapshotPath(relativePath: string) {\n if (relativePath.includes(\"\\\\\")) return false;\n const normalized = toPosix(relativePath);\n return (\n Boolean(normalized) &&\n normalized !== \".\" &&\n normalized !== \"..\" &&\n !normalized.startsWith(\"../\") &&\n !path.posix.isAbsolute(normalized) &&\n path.posix.normalize(normalized) === normalized &&\n !isDeniedPath(normalized)\n );\n}\n\nfunction snapshotsMatch(left: Snapshot, right: Snapshot) {\n const leftHashes = new Map(left.files.map((file) => [file.path, file.sha256]));\n const rightHashes = new Map(right.files.map((file) => [file.path, file.sha256]));\n return (\n left.syncSessions === right.syncSessions &&\n sameOptionalInclude(snapshotSelectionInclude(left), snapshotSelectionInclude(right)) &&\n leftHashes.size === rightHashes.size &&\n [...leftHashes].every(([filePath, hash]) => rightHashes.get(filePath) === hash)\n );\n}\n\nfunction snapshotId() {\n return `${new Date().toISOString().replace(/[:.]/g, \"-\")}-${randomUUID().slice(0, 8)}`;\n}\n\nexport function regenerateSnapshotIdentity(snapshot: Snapshot): Snapshot {\n return {\n ...snapshot,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n };\n}\n\nexport async function createSnapshot(profile: string, options: SnapshotOptions = {}): Promise<Snapshot> {\n options.signal?.throwIfAborted();\n const include = effectiveInclude(options);\n const syncSessions = include.includes(\"sessions\");\n const sessionDir = options.sessionDir ?? (await configuredSessionDir());\n options.signal?.throwIfAborted();\n const files = await collectFiles(agentDir(), { include, sessionDir, signal: options.signal });\n options.signal?.throwIfAborted();\n return {\n version: VERSION,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n profile,\n syncSessions,\n selection: selectionForSnapshot(include),\n files,\n };\n}\n\nfunction effectiveInclude(options: SnapshotOptions) {\n if (options.include) return options.include;\n return [\n ...normalizeSyncFiles(options.syncFiles),\n ...normalizeExtraFiles(options.extraFiles),\n ...(options.syncSessions ? [\"sessions\"] : []),\n ];\n}\n\nexport async function collectFiles(root: string, options: SnapshotOptions = {}): Promise<SnapshotFile[]> {\n const signal = options.signal;\n signal?.throwIfAborted();\n const results: SnapshotFile[] = [];\n const entries = await fs.readdir(root, { withFileTypes: true });\n signal?.throwIfAborted();\n const selection = syncIncludeSelection(effectiveInclude(options));\n const selectedFiles = new Set<string>(selection.builtIns);\n for (const entry of entries) {\n if (entry.isDirectory() && TOP_LEVEL_DIRS.has(entry.name) && selectedFiles.has(entry.name)) {\n await collectDirectory(results, root, entry.name, { signal });\n }\n }\n for (const fileName of TOP_LEVEL_FILES) {\n if (!selectedFiles.has(fileName)) continue;\n const entry = selectTopLevelFileEntry(entries, fileName);\n if (entry) await addFile(results, root, entry.name, fileName, signal);\n }\n for (const relativePath of selection.custom) {\n await collectIncludedPath(results, root, relativePath, signal);\n }\n if (selection.sessions) {\n try {\n await collectDirectory(results, sessionStorageRoot(root, options.sessionDir), \"\", {\n sessionsOnly: true,\n virtualPrefix: \"sessions\",\n signal,\n });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n }\n signal?.throwIfAborted();\n return results.sort((left, right) => left.path.localeCompare(right.path));\n}\n\nasync function collectIncludedPath(results: SnapshotFile[], root: string, relativePath: string, signal?: AbortSignal) {\n signal?.throwIfAborted();\n const absolutePath = safeJoin(root, relativePath);\n try {\n const stat = await fs.lstat(absolutePath);\n signal?.throwIfAborted();\n if (stat.isFile()) await addFile(results, root, relativePath, relativePath, signal);\n else if (stat.isDirectory()) await collectDirectory(results, root, relativePath, { signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n if (!relativePath.includes(\"/\")) {\n const entries = await fs.readdir(root, { withFileTypes: true });\n signal?.throwIfAborted();\n const entry = selectTopLevelFileEntry(entries, relativePath);\n if (entry) await addFile(results, root, entry.name, relativePath, signal);\n }\n }\n}\n\nasync function collectDirectory(\n results: SnapshotFile[],\n root: string,\n relativeDirectory: string,\n options: { sessionsOnly?: boolean; virtualPrefix?: string; signal?: AbortSignal } = {},\n) {\n options.signal?.throwIfAborted();\n const absoluteDirectory = path.join(root, relativeDirectory);\n for (const entry of await fs.readdir(absoluteDirectory, { withFileTypes: true })) {\n options.signal?.throwIfAborted();\n const relativePath = relativeDirectory ? posixJoin(relativeDirectory, entry.name) : entry.name;\n const snapshotPath = options.virtualPrefix ? posixJoin(options.virtualPrefix, relativePath) : relativePath;\n if (isDeniedPath(snapshotPath)) continue;\n if (entry.isDirectory()) {\n await collectDirectory(results, root, relativePath, options);\n } else if (entry.isFile() && (!options.sessionsOnly || isSessionFilePath(snapshotPath))) {\n await addFile(results, root, relativePath, snapshotPath, options.signal);\n }\n }\n}\n\nasync function addFile(\n results: SnapshotFile[],\n root: string,\n relativePath: string,\n snapshotPath = relativePath,\n signal?: AbortSignal,\n) {\n signal?.throwIfAborted();\n if (!isSafeSnapshotPath(snapshotPath)) return;\n const absolutePath = safeJoin(root, relativePath);\n const content = await fs.readFile(absolutePath, { signal });\n signal?.throwIfAborted();\n results.push({\n path: snapshotPath,\n contentBase64: content.toString(\"base64\"),\n sha256: sha256(content),\n });\n}\n\nexport function isSessionPath(relativePath: string) {\n return toPosix(relativePath).startsWith(\"sessions/\");\n}\n\nexport function isSessionFilePath(relativePath: string) {\n const normalized = toPosix(relativePath);\n return isSessionPath(normalized) && normalized.endsWith(\".jsonl\");\n}\n\nexport function sessionSnapshotPathFromAbsolute(sessionFile: string, configuredSessionDir?: string) {\n const relativePath = toPosix(path.relative(sessionStorageRoot(agentDir(), configuredSessionDir), sessionFile));\n if (!relativePath || relativePath.startsWith(\"../\") || path.posix.isAbsolute(relativePath)) {\n return undefined;\n }\n const snapshotPath = posixJoin(\"sessions\", relativePath);\n return isSessionFilePath(snapshotPath) ? snapshotPath : undefined;\n}\n\nexport function snapshotTarget(root: string, relativePath: string, configuredSessionDir?: string) {\n if (isSessionPath(relativePath)) {\n return safeJoin(sessionStorageRoot(root, configuredSessionDir), relativePath.slice(\"sessions/\".length));\n }\n return safeJoin(root, relativePath);\n}\n\nexport function snapshotIncludesSessions(snapshot: Snapshot) {\n return (\n snapshot.syncSessions === true ||\n snapshotSelectionInclude(snapshot)?.includes(\"sessions\") === true ||\n snapshot.files.some((file) => isSessionPath(file.path))\n );\n}\n\nexport function filterSnapshotForConfigPolicy(\n snapshot: Snapshot,\n config: SyncSelectionConfig,\n options: { regenerateId?: boolean } = {},\n) {\n const include = includeFromSelectionConfig(config);\n const includePaths = customIncludePathsByLower(include);\n const filtered = {\n ...snapshot,\n syncSessions: include.includes(\"sessions\") ? snapshot.syncSessions : false,\n selection: selectionForSnapshot(include),\n files: canonicalizeSnapshotFilesForConfig(snapshot.files, config, includePaths),\n };\n if (!options.regenerateId || snapshotsMatch(snapshot, filtered)) return filtered;\n return {\n ...filtered,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n };\n}\n\nfunction canonicalizeSnapshotFilesForConfig(\n files: SnapshotFile[],\n config: SyncSelectionConfig,\n includePaths: Map<string, string>,\n) {\n const configuredFiles: SnapshotFile[] = [];\n const extraCandidates = new Map<string, { exact: boolean; file: SnapshotFile; originalPath: string }>();\n for (const file of files) {\n const normalized = toPosix(file.path);\n if (!isSafeSnapshotPath(file.path) || !isConfiguredSnapshotPath(normalized, config)) {\n continue;\n }\n if (normalized.includes(\"/\")) {\n configuredFiles.push(normalized === file.path ? file : { ...file, path: normalized });\n continue;\n }\n const topLevelPath = canonicalSnapshotPathForConfig(normalized, includePaths);\n const candidate = {\n exact: normalized === topLevelPath,\n file: { ...file, path: topLevelPath },\n originalPath: normalized,\n };\n const current = extraCandidates.get(topLevelPath.toLowerCase());\n if (!current || isPreferredExtraCandidate(candidate, current)) {\n extraCandidates.set(topLevelPath.toLowerCase(), candidate);\n }\n }\n return [...configuredFiles, ...[...extraCandidates.values()].map((candidate) => candidate.file)].sort((left, right) =>\n left.path.localeCompare(right.path),\n );\n}\n\nfunction isPreferredExtraCandidate(\n left: { exact: boolean; originalPath: string },\n right: { exact: boolean; originalPath: string },\n) {\n if (left.exact !== right.exact) return left.exact;\n return left.originalPath.localeCompare(right.originalPath) < 0;\n}\n\nexport function snapshotWithoutSessions(snapshot: Snapshot) {\n const files = snapshot.files.filter((file) => !isSessionPath(file.path));\n const include = snapshotSelectionInclude(snapshot)?.filter((item) => item !== \"sessions\");\n if (\n files.length === snapshot.files.length &&\n snapshot.syncSessions !== true &&\n include?.length === snapshot.selection?.include.length\n ) {\n return snapshot;\n }\n return {\n ...snapshot,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n syncSessions: false,\n ...(include ? { selection: selectionForSnapshot(include) } : {}),\n files,\n };\n}\n\nexport function scanSnapshot(snapshot: Snapshot) {\n const findings: string[] = [];\n for (const file of snapshot.files) {\n const content = Buffer.from(file.contentBase64, \"base64\");\n if (content.includes(0)) continue;\n const text = content.toString(\"utf8\");\n for (const pattern of SECRET_PATTERNS) {\n if (pattern.test(text)) {\n findings.push(file.path);\n break;\n }\n }\n }\n return findings;\n}\n\nexport function mergeRemotePreservedFiles(local: Snapshot, remote: Snapshot, config: SyncSelectionConfig) {\n const localPathNames = new Set(local.files.map((file) => file.path.toLowerCase()));\n const preservedPathNames = new Set<string>();\n const preserved = remote.files.filter((file) => {\n const normalized = toPosix(file.path);\n const lower = normalized.toLowerCase();\n if (\n localPathNames.has(lower) ||\n preservedPathNames.has(lower) ||\n !isSafeSnapshotPath(file.path) ||\n isConfiguredSnapshotPath(normalized, config) ||\n !isPreservableUnmanagedSnapshotPath(normalized)\n ) {\n return false;\n }\n preservedPathNames.add(lower);\n return true;\n });\n if (preserved.length === 0) return local;\n return {\n ...local,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n syncSessions: snapshotIncludesSessions(local) || snapshotIncludesSessions(remote),\n files: [...local.files, ...preserved].sort((left, right) => left.path.localeCompare(right.path)),\n };\n}\n\nexport function mergeRemoteSessionFiles(local: Snapshot, remote: Snapshot) {\n const remoteSessions = remote.files.filter((file) => {\n const normalized = toPosix(file.path);\n return isSessionFilePath(normalized) && isSafeSnapshotPath(file.path);\n });\n if (remoteSessions.length === 0 && !snapshotIncludesSessions(remote)) return local;\n const localInclude = snapshotSelectionInclude(local);\n return {\n ...local,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n syncSessions: true,\n ...(localInclude\n ? {\n selection: selectionForSnapshot(\n localInclude.includes(\"sessions\") ? localInclude : [...localInclude, \"sessions\"],\n ),\n }\n : {}),\n files: [...local.files.filter((file) => !isSessionPath(file.path)), ...remoteSessions].sort((left, right) =>\n left.path.localeCompare(right.path),\n ),\n };\n}\n\nfunction sameOptionalInclude(left: string[] | undefined, right: string[] | undefined) {\n if (!left || !right) return left === right;\n return left.length === right.length && left.every((item, index) => item === right[index]);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,kBAAkB;AAEvC,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AA0BjB,IAAM,UAAU;AAChB,IAAM,kBAAqC,qBAAqB,OAAO,CAAC,SAAS,KAAK,SAAS,GAAG,CAAC;AACnG,IAAM,iBAAiB,IAAI,IAAY,qBAAqB,OAAO,CAAC,SAAS,CAAC,KAAK,SAAS,GAAG,CAAC,CAAC;AACjG,IAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,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