@abelxiaoxing/cadence 1.8.3 → 2.0.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 (208) hide show
  1. package/README.md +324 -111
  2. package/THIRD_PARTY_NOTICES.md +15 -0
  3. package/agents/design-explorer.md +14 -26
  4. package/agents/diagnosis-worker.md +14 -25
  5. package/agents/implementation-worker.md +16 -35
  6. package/config/.env.example +2 -5
  7. package/config/workflow-task.example.json +7 -0
  8. package/docs/remote-access.md +60 -0
  9. package/docs/reuse-and-distribution.md +44 -0
  10. package/docs/service-management.md +108 -0
  11. package/licenses/bundled-web.txt +6245 -0
  12. package/licenses/pi-web-ui-MIT.txt +21 -0
  13. package/licenses/pi-web-ui-reuse.md +22 -0
  14. package/package.json +94 -21
  15. package/src/index.ts +22 -1807
  16. package/src/native-build.ts +6 -0
  17. package/src/native-client.ts +103 -0
  18. package/src/native-export.ts +58 -0
  19. package/src/native-history.ts +359 -0
  20. package/src/operator-cli.mjs +453 -1937
  21. package/src/plan-proposal.ts +87 -0
  22. package/src/sdk-worker.mjs +549 -0
  23. package/src/service/contracts/active.ts +82 -0
  24. package/src/service/contracts/budget.ts +148 -0
  25. package/src/service/contracts/build.ts +67 -0
  26. package/src/service/contracts/capture.ts +48 -0
  27. package/src/service/contracts/core.ts +33 -0
  28. package/src/service/contracts/current.ts +261 -0
  29. package/src/service/contracts/domain.ts +68 -0
  30. package/src/service/contracts/history.ts +2245 -0
  31. package/src/service/contracts/models.ts +139 -0
  32. package/src/service/coordination.ts +862 -0
  33. package/src/service/private-files.ts +204 -0
  34. package/src/service-cli.mjs +5592 -0
  35. package/src/service-client.ts +747 -0
  36. package/src/service-contract.ts +245 -0
  37. package/src/service-host.mjs +22382 -0
  38. package/src/service-http-client.ts +425 -0
  39. package/src/service-wire.ts +372 -0
  40. package/src/task-shell.ts +1045 -0
  41. package/src/task-store.ts +479 -0
  42. package/src/task-types.ts +184 -0
  43. package/src/verification-diagnostics.ts +29 -72
  44. package/src/worker-capture.mjs +1197 -0
  45. package/src/worker-public.mjs +1753 -0
  46. package/src/worker-redaction.mjs +608 -0
  47. package/src/worker-tools.mjs +202 -0
  48. package/web/dist/assets/KaTeX_AMS-Regular.ttf +0 -0
  49. package/web/dist/assets/KaTeX_AMS-Regular.woff +0 -0
  50. package/web/dist/assets/KaTeX_AMS-Regular.woff2 +0 -0
  51. package/web/dist/assets/KaTeX_Caligraphic-Bold.ttf +0 -0
  52. package/web/dist/assets/KaTeX_Caligraphic-Bold.woff +0 -0
  53. package/web/dist/assets/KaTeX_Caligraphic-Bold.woff2 +0 -0
  54. package/web/dist/assets/KaTeX_Caligraphic-Regular.ttf +0 -0
  55. package/web/dist/assets/KaTeX_Caligraphic-Regular.woff +0 -0
  56. package/web/dist/assets/KaTeX_Caligraphic-Regular.woff2 +0 -0
  57. package/web/dist/assets/KaTeX_Fraktur-Bold.ttf +0 -0
  58. package/web/dist/assets/KaTeX_Fraktur-Bold.woff +0 -0
  59. package/web/dist/assets/KaTeX_Fraktur-Bold.woff2 +0 -0
  60. package/web/dist/assets/KaTeX_Fraktur-Regular.ttf +0 -0
  61. package/web/dist/assets/KaTeX_Fraktur-Regular.woff +0 -0
  62. package/web/dist/assets/KaTeX_Fraktur-Regular.woff2 +0 -0
  63. package/web/dist/assets/KaTeX_Main-Bold.ttf +0 -0
  64. package/web/dist/assets/KaTeX_Main-Bold.woff +0 -0
  65. package/web/dist/assets/KaTeX_Main-Bold.woff2 +0 -0
  66. package/web/dist/assets/KaTeX_Main-BoldItalic.ttf +0 -0
  67. package/web/dist/assets/KaTeX_Main-BoldItalic.woff +0 -0
  68. package/web/dist/assets/KaTeX_Main-BoldItalic.woff2 +0 -0
  69. package/web/dist/assets/KaTeX_Main-Italic.ttf +0 -0
  70. package/web/dist/assets/KaTeX_Main-Italic.woff +0 -0
  71. package/web/dist/assets/KaTeX_Main-Italic.woff2 +0 -0
  72. package/web/dist/assets/KaTeX_Main-Regular.ttf +0 -0
  73. package/web/dist/assets/KaTeX_Main-Regular.woff +0 -0
  74. package/web/dist/assets/KaTeX_Main-Regular.woff2 +0 -0
  75. package/web/dist/assets/KaTeX_Math-BoldItalic.ttf +0 -0
  76. package/web/dist/assets/KaTeX_Math-BoldItalic.woff +0 -0
  77. package/web/dist/assets/KaTeX_Math-BoldItalic.woff2 +0 -0
  78. package/web/dist/assets/KaTeX_Math-Italic.ttf +0 -0
  79. package/web/dist/assets/KaTeX_Math-Italic.woff +0 -0
  80. package/web/dist/assets/KaTeX_Math-Italic.woff2 +0 -0
  81. package/web/dist/assets/KaTeX_SansSerif-Bold.ttf +0 -0
  82. package/web/dist/assets/KaTeX_SansSerif-Bold.woff +0 -0
  83. package/web/dist/assets/KaTeX_SansSerif-Bold.woff2 +0 -0
  84. package/web/dist/assets/KaTeX_SansSerif-Italic.ttf +0 -0
  85. package/web/dist/assets/KaTeX_SansSerif-Italic.woff +0 -0
  86. package/web/dist/assets/KaTeX_SansSerif-Italic.woff2 +0 -0
  87. package/web/dist/assets/KaTeX_SansSerif-Regular.ttf +0 -0
  88. package/web/dist/assets/KaTeX_SansSerif-Regular.woff +0 -0
  89. package/web/dist/assets/KaTeX_SansSerif-Regular.woff2 +0 -0
  90. package/web/dist/assets/KaTeX_Script-Regular.ttf +0 -0
  91. package/web/dist/assets/KaTeX_Script-Regular.woff +0 -0
  92. package/web/dist/assets/KaTeX_Script-Regular.woff2 +0 -0
  93. package/web/dist/assets/KaTeX_Size1-Regular.ttf +0 -0
  94. package/web/dist/assets/KaTeX_Size1-Regular.woff +0 -0
  95. package/web/dist/assets/KaTeX_Size1-Regular.woff2 +0 -0
  96. package/web/dist/assets/KaTeX_Size2-Regular.ttf +0 -0
  97. package/web/dist/assets/KaTeX_Size2-Regular.woff +0 -0
  98. package/web/dist/assets/KaTeX_Size2-Regular.woff2 +0 -0
  99. package/web/dist/assets/KaTeX_Size3-Regular.ttf +0 -0
  100. package/web/dist/assets/KaTeX_Size3-Regular.woff +0 -0
  101. package/web/dist/assets/KaTeX_Size3-Regular.woff2 +0 -0
  102. package/web/dist/assets/KaTeX_Size4-Regular.ttf +0 -0
  103. package/web/dist/assets/KaTeX_Size4-Regular.woff +0 -0
  104. package/web/dist/assets/KaTeX_Size4-Regular.woff2 +0 -0
  105. package/web/dist/assets/KaTeX_Typewriter-Regular.ttf +0 -0
  106. package/web/dist/assets/KaTeX_Typewriter-Regular.woff +0 -0
  107. package/web/dist/assets/KaTeX_Typewriter-Regular.woff2 +0 -0
  108. package/web/dist/assets/cadence.css +2 -0
  109. package/web/dist/assets/cadence.js +7 -0
  110. package/web/dist/assets/markdown.js +296 -0
  111. package/web/dist/assets/react.js +9 -0
  112. package/web/dist/assets/rolldown-runtime.js +1 -0
  113. package/web/dist/assets/timeline-client.js +41 -0
  114. package/web/dist/assets/vis-timeline.css +1274 -0
  115. package/web/dist/assets/vis-timeline.js +32 -0
  116. package/web/dist/index.html +18 -0
  117. package/web/dist/manifest.json +505 -0
  118. package/config/plan-draft.example.json +0 -125
  119. package/config/plan-draft.multiple-tasks.example.json +0 -375
  120. package/config/plan-draft.quick.example.json +0 -78
  121. package/config/routes.example.json +0 -39
  122. package/prompts/abel-design.md +0 -382
  123. package/prompts/abel-diagnose.md +0 -71
  124. package/prompts/abel-implement.md +0 -284
  125. package/prompts/abel-init.md +0 -52
  126. package/src/activation.ts +0 -44
  127. package/src/activity-contracts.ts +0 -82
  128. package/src/agent-registry.ts +0 -53
  129. package/src/apply-transaction.ts +0 -1437
  130. package/src/artifact-store.ts +0 -213
  131. package/src/build-windows-job.mjs +0 -95
  132. package/src/candidate-artifact.ts +0 -143
  133. package/src/candidate-patch.ts +0 -271
  134. package/src/candidate-workspace.ts +0 -80
  135. package/src/canonical.ts +0 -16
  136. package/src/change-contract-schema.ts +0 -191
  137. package/src/change-contract.ts +0 -324
  138. package/src/change-verification.ts +0 -1617
  139. package/src/child-budget.ts +0 -58
  140. package/src/child-model.ts +0 -142
  141. package/src/child-session.ts +0 -640
  142. package/src/contracts.ts +0 -2476
  143. package/src/control-contracts.ts +0 -382
  144. package/src/delivery-compiler.ts +0 -1805
  145. package/src/delivery-revision.ts +0 -42
  146. package/src/design-control.ts +0 -1299
  147. package/src/design-diagnostics.ts +0 -181
  148. package/src/design-journal.ts +0 -1773
  149. package/src/directory-sync.ts +0 -36
  150. package/src/durable-contracts.ts +0 -231
  151. package/src/durable-workflow.ts +0 -978
  152. package/src/evidence-draft.ts +0 -122
  153. package/src/execution-profile.ts +0 -64
  154. package/src/execution-retention.ts +0 -77
  155. package/src/file-snapshot.ts +0 -163
  156. package/src/implement-continuation.ts +0 -559
  157. package/src/implement-graph.ts +0 -690
  158. package/src/implement-plan.ts +0 -72
  159. package/src/install-config.d.mts +0 -6
  160. package/src/isolation-backend.ts +0 -353
  161. package/src/model-source.ts +0 -22
  162. package/src/openspec-cli.ts +0 -494
  163. package/src/operator-cli-entry.mjs +0 -24
  164. package/src/operator-tools.ts +0 -309
  165. package/src/package-candidate.ts +0 -227
  166. package/src/package-delivery.ts +0 -486
  167. package/src/package-state.ts +0 -320
  168. package/src/package-verification.ts +0 -635
  169. package/src/package-workflow.ts +0 -342
  170. package/src/packet-runtime.ts +0 -570
  171. package/src/parent-provider.ts +0 -375
  172. package/src/phase-execution.ts +0 -2259
  173. package/src/pi-adapter.ts +0 -19
  174. package/src/plan-draft-summary.ts +0 -527
  175. package/src/plan-draft.ts +0 -502
  176. package/src/remove-path.ts +0 -32
  177. package/src/route-policy.ts +0 -545
  178. package/src/run-state.ts +0 -420
  179. package/src/run-store.ts +0 -1179
  180. package/src/safe-path.ts +0 -77
  181. package/src/scoped-grep-worker.mjs +0 -23
  182. package/src/scoped-tools.ts +0 -775
  183. package/src/single-task-draft.ts +0 -142
  184. package/src/sqlite-schema.ts +0 -171
  185. package/src/state-root.ts +0 -215
  186. package/src/storage-schema.ts +0 -360
  187. package/src/subagent-activity.ts +0 -1417
  188. package/src/submit-tool.ts +0 -950
  189. package/src/task-ledger.ts +0 -1338
  190. package/src/transport-budget.ts +0 -52
  191. package/src/verification-capability.ts +0 -1191
  192. package/src/verification-environment-io.ts +0 -389
  193. package/src/verification-environment.ts +0 -162
  194. package/src/verification-identity.ts +0 -77
  195. package/src/verification-scan.ts +0 -64
  196. package/src/windows-job-backend.ts +0 -419
  197. package/src/windows-job.c +0 -149
  198. package/src/worker-broker.ts +0 -806
  199. package/src/workflow-engine.ts +0 -28
  200. package/src/workflow-policy.ts +0 -1679
  201. package/src/workflow-recovery-policy.ts +0 -97
  202. package/src/workflow-scheduling.ts +0 -105
  203. package/src/workflow-state-machine.ts +0 -4355
  204. package/src/workflow-status.ts +0 -576
  205. package/src/workspace-io-entry.mjs +0 -76
  206. package/src/workspace-io-worker.mjs +0 -1312
  207. package/src/workspace-io.ts +0 -89
  208. package/src/workspace-store.ts +0 -634
@@ -1,320 +0,0 @@
1
- import { randomUUID } from "node:crypto";
2
- import {
3
- closeSync,
4
- existsSync,
5
- fsyncSync,
6
- lstatSync,
7
- mkdirSync,
8
- openSync,
9
- readdirSync,
10
- readFileSync,
11
- renameSync,
12
- unlinkSync,
13
- writeFileSync,
14
- } from "node:fs";
15
- import path from "node:path";
16
- import { DatabaseSync } from "node:sqlite";
17
- import { syncDirectory } from "./directory-sync.ts";
18
- import { assertExecutionsSettled } from "./execution-retention.ts";
19
- import { RunStore } from "./run-store.ts";
20
- import { prepareStateRoot, type ResolvedStateRoot } from "./state-root.ts";
21
-
22
- export class PackageStateError extends Error {
23
- readonly code: string;
24
- constructor(code: string) {
25
- super(code);
26
- this.code = code;
27
- }
28
- }
29
- export interface PackageStateNotice {
30
- reason:
31
- | "package-upgrade"
32
- | "unversioned-store"
33
- | "unreadable-store"
34
- | "missing-store";
35
- previousVersion: string | null;
36
- currentVersion: string;
37
- backupPath: string;
38
- oldRunsAbandoned: true;
39
- workspaceRestored: false;
40
- warning: string;
41
- }
42
- interface ResetIntent
43
- extends Omit<
44
- PackageStateNotice,
45
- "oldRunsAbandoned" | "workspaceRestored" | "warning"
46
- > {
47
- backupName: string;
48
- }
49
- const fail = (code: string): never => {
50
- throw new PackageStateError(code);
51
- };
52
- const versionParts = (version: string): number[] => {
53
- if (!/^\d+\.\d+\.\d+$/u.test(version)) fail("package-state-version-invalid");
54
- const parts = version.split(".").map(Number);
55
- if (parts.some((part) => !Number.isSafeInteger(part)))
56
- fail("package-state-version-invalid");
57
- return parts;
58
- };
59
- function compareVersions(left: string, right: string): number {
60
- const a = versionParts(left),
61
- b = versionParts(right);
62
- for (let i = 0; i < 3; i++) if (a[i] !== b[i]) return a[i] > b[i] ? 1 : -1;
63
- return 0;
64
- }
65
- function regular(file: string): boolean {
66
- const stat = lstatSync(file, { throwIfNoEntry: false });
67
- if (!stat) return false;
68
- if (!stat.isFile() || stat.isSymbolicLink())
69
- fail("package-state-path-unsafe");
70
- return true;
71
- }
72
- function table(db: DatabaseSync, name: string): boolean {
73
- return !!db
74
- .prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?")
75
- .get(name);
76
- }
77
- function storedVersion(db: DatabaseSync): string | null {
78
- if (!table(db, "cadence_package_version")) return null;
79
- const rows = db.prepare("SELECT version FROM cadence_package_version").all();
80
- if (rows.length !== 1 || typeof rows[0].version !== "string")
81
- fail("package-state-version-invalid");
82
- const version = String(rows[0].version);
83
- versionParts(version);
84
- return version;
85
- }
86
- // Only inspect the version. Old task/lease/apply records are deliberately not
87
- // interpreted: this policy abandons them, including malformed or unreadable facts.
88
- function inspectVersion(file: string): {
89
- version: string | null;
90
- unreadable: boolean;
91
- } {
92
- let db: DatabaseSync | undefined;
93
- try {
94
- db = new DatabaseSync(file, { readOnly: true });
95
- return { version: storedVersion(db), unreadable: false };
96
- } catch (error) {
97
- const failure = error as { errcode?: number; code?: string };
98
- // An actual SQLite lock is not a stale durable lease record. Do not move
99
- // storage while an uncoordinated old opener is observably using it.
100
- if (failure.errcode !== undefined && [5, 6].includes(failure.errcode & 255))
101
- fail("package-state-in-use");
102
- if (
103
- (error instanceof PackageStateError &&
104
- error.code === "package-state-version-invalid") ||
105
- (failure.errcode !== undefined &&
106
- [1, 11, 26].includes(failure.errcode & 255))
107
- )
108
- return { version: null, unreadable: true };
109
- // Schema errors / SQLITE_CORRUPT / SQLITE_NOTADB mean opaque old bytes.
110
- // Permissions, disk I/O, resource exhaustion and unknown errors do not.
111
- return fail("package-state-reset-unavailable");
112
- } finally {
113
- db?.close();
114
- }
115
- }
116
-
117
- function hasOldResources(state: ResolvedStateRoot): boolean {
118
- // Cover the production run-data layout and unknown historical resources.
119
- // Never descend through resource links; the whole root is renamed as-is.
120
- const emptyScaffolds = new Set(["artifacts", "workspaces", "transactions"]);
121
- return readdirSync(state.rootDir).some((name) => {
122
- const file = path.join(state.rootDir, name);
123
- const stat = lstatSync(file);
124
- return (
125
- !emptyScaffolds.has(name) ||
126
- !stat.isDirectory() ||
127
- stat.isSymbolicLink() ||
128
- readdirSync(file).length > 0
129
- );
130
- });
131
- }
132
-
133
- const RESET_WARNING =
134
- "Old runs and approval evidence are abandoned, not resumed. Stop all old hosts and execution processes before resetting; the lock cannot fence older versions or detached descendants. The main workspace is not restored: interrupted apply may have left partial changes. Inspect Git diff before starting new work.";
135
-
136
- function persistIntent(file: string, intent: ResetIntent): void {
137
- const temp = `${file}.tmp`;
138
- regular(temp);
139
- const fd = openSync(temp, "w", 0o600);
140
- try {
141
- writeFileSync(fd, JSON.stringify(intent));
142
- fsyncSync(fd);
143
- } finally {
144
- closeSync(fd);
145
- }
146
- renameSync(temp, file);
147
- syncDirectory(path.dirname(file));
148
- }
149
-
150
- /** Package boundary only: low-level storage and read-only operator inspection never reset state.
151
- * The external SQLite write lock is held until every service connection has closed.
152
- * SQLite releases it on process death; no PID guessing or stale-lock deletion is used.
153
- */
154
- export function acquirePackageState(
155
- unresolved: ResolvedStateRoot,
156
- version = String(
157
- JSON.parse(
158
- readFileSync(new URL("../package.json", import.meta.url), "utf8"),
159
- ).version,
160
- ),
161
- ): { notice?: PackageStateNotice; close(): void } {
162
- versionParts(version);
163
- const state = prepareStateRoot(unresolved);
164
- try {
165
- assertExecutionsSettled(state.rootDir);
166
- } catch (error) {
167
- if (
168
- error instanceof Error &&
169
- error.message === "isolation-termination-unconfirmed"
170
- )
171
- fail(error.message);
172
- throw error;
173
- }
174
- for (const suffix of ["-wal", "-shm", "-journal"])
175
- regular(state.databasePath + suffix);
176
- const coordinator = path.join(
177
- state.rootsDir,
178
- `${state.consumerRootHash}.package-state`,
179
- );
180
- const stat = lstatSync(coordinator, { throwIfNoEntry: false });
181
- if (stat && (!stat.isDirectory() || stat.isSymbolicLink()))
182
- fail("package-state-path-unsafe");
183
- mkdirSync(coordinator, { recursive: true, mode: 0o700 });
184
- const lockFile = path.join(coordinator, "lock.sqlite3");
185
- for (const suffix of ["", "-journal", "-wal", "-shm"])
186
- regular(lockFile + suffix);
187
- if (!existsSync(lockFile)) {
188
- try {
189
- closeSync(openSync(lockFile, "wx", 0o600));
190
- } catch (error) {
191
- if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
192
- }
193
- }
194
- const lock = new DatabaseSync(lockFile);
195
- let closed = false;
196
- const close = () => {
197
- if (!closed) {
198
- closed = true;
199
- lock.close();
200
- }
201
- };
202
- try {
203
- lock.exec("PRAGMA busy_timeout = 1; BEGIN IMMEDIATE");
204
- } catch {
205
- close();
206
- fail("package-state-in-use");
207
- }
208
- try {
209
- const intentFile = path.join(coordinator, "reset.json");
210
- let intent: ResetIntent | undefined;
211
- if (regular(intentFile)) {
212
- intent = JSON.parse(readFileSync(intentFile, "utf8")) as ResetIntent;
213
- if (
214
- !intent ||
215
- !/^backup-[a-f0-9-]{36}$/u.test(intent.backupName) ||
216
- intent.backupPath !== path.join(coordinator, intent.backupName) ||
217
- ![
218
- "package-upgrade",
219
- "unversioned-store",
220
- "unreadable-store",
221
- "missing-store",
222
- ].includes(intent.reason) ||
223
- (intent.previousVersion !== null &&
224
- typeof intent.previousVersion !== "string")
225
- )
226
- fail("package-state-reset-intent-invalid");
227
- if (intent.currentVersion !== version)
228
- fail("package-state-reset-version-mismatch");
229
- }
230
- let fresh = !regular(state.databasePath);
231
- if (!intent) {
232
- const observed = fresh
233
- ? { version: null, unreadable: false }
234
- : inspectVersion(state.databasePath);
235
- if (observed.version === version) return { close };
236
- if (
237
- observed.version !== null &&
238
- compareVersions(observed.version, version) > 0
239
- )
240
- fail("package-state-downgrade-blocked");
241
- if (!fresh || hasOldResources(state)) {
242
- const backupName = `backup-${randomUUID()}`;
243
- intent = {
244
- backupName,
245
- backupPath: path.join(coordinator, backupName),
246
- previousVersion: observed.version,
247
- currentVersion: version,
248
- reason: fresh
249
- ? "missing-store"
250
- : observed.unreadable
251
- ? "unreadable-store"
252
- : observed.version === null
253
- ? "unversioned-store"
254
- : "package-upgrade",
255
- };
256
- persistIntent(intentFile, intent);
257
- }
258
- }
259
- if (intent) {
260
- const backup = lstatSync(intent.backupPath, { throwIfNoEntry: false });
261
- if (backup && (!backup.isDirectory() || backup.isSymbolicLink()))
262
- fail("package-state-path-unsafe");
263
- if (!backup) {
264
- // Abandon the old namespace as opaque bytes, including run-data and
265
- // SQLite sidecars. No transaction replay or main-workspace rollback.
266
- renameSync(state.rootDir, intent.backupPath);
267
- syncDirectory(coordinator);
268
- syncDirectory(state.rootsDir);
269
- }
270
- prepareStateRoot(state);
271
- fresh = true;
272
- }
273
- if (fresh) {
274
- RunStore.open(state).close();
275
- const db = new DatabaseSync(state.databasePath);
276
- try {
277
- db.exec(
278
- "PRAGMA synchronous = FULL; BEGIN IMMEDIATE; CREATE TABLE IF NOT EXISTS cadence_package_version (version TEXT NOT NULL) STRICT",
279
- );
280
- const existing = db
281
- .prepare("SELECT version FROM cadence_package_version")
282
- .all();
283
- if (existing.length === 0)
284
- db.prepare("INSERT INTO cadence_package_version VALUES (?)").run(
285
- version,
286
- );
287
- else if (existing.length !== 1 || existing[0].version !== version)
288
- fail("package-state-reset-version-mismatch");
289
- db.exec("COMMIT");
290
- } finally {
291
- db.close();
292
- }
293
- syncDirectory(state.rootDir);
294
- }
295
- if (intent) {
296
- unlinkSync(intentFile);
297
- syncDirectory(coordinator);
298
- }
299
- return {
300
- close,
301
- ...(intent
302
- ? {
303
- notice: {
304
- reason: intent.reason,
305
- previousVersion: intent.previousVersion,
306
- currentVersion: version,
307
- backupPath: intent.backupPath,
308
- oldRunsAbandoned: true,
309
- workspaceRestored: false,
310
- warning: RESET_WARNING,
311
- },
312
- }
313
- : {}),
314
- };
315
- } catch (error) {
316
- close();
317
- if (error instanceof PackageStateError) throw error;
318
- throw new PackageStateError("package-state-reset-unavailable");
319
- }
320
- }