@agentxm/workspace-state 0.28.4-bootstrap.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.
- package/LICENSE +110 -0
- package/README.md +11 -0
- package/dist/src/index.d.ts +72 -0
- package/dist/src/index.js +88 -0
- package/dist/src/knowledge/discovery-config.d.ts +12 -0
- package/dist/src/knowledge/discovery-config.js +9 -0
- package/dist/src/lockfile/accepted-registry-version.d.ts +12 -0
- package/dist/src/lockfile/accepted-registry-version.js +13 -0
- package/dist/src/lockfile/entry-fields.d.ts +189 -0
- package/dist/src/lockfile/entry-fields.js +89 -0
- package/dist/src/lockfile/errors.d.ts +48 -0
- package/dist/src/lockfile/errors.js +27 -0
- package/dist/src/lockfile/index.d.ts +18 -0
- package/dist/src/lockfile/index.js +16 -0
- package/dist/src/lockfile/lockfile.d.ts +2255 -0
- package/dist/src/lockfile/lockfile.js +235 -0
- package/dist/src/lockfile/resolved-version.d.ts +4 -0
- package/dist/src/lockfile/resolved-version.js +7 -0
- package/dist/src/lockfile/schema.d.ts +3062 -0
- package/dist/src/lockfile/schema.js +406 -0
- package/dist/src/schema/index.d.ts +3 -0
- package/dist/src/schema/index.js +2 -0
- package/dist/src/schema/read-and-validate-json-file.d.ts +20 -0
- package/dist/src/schema/read-and-validate-json-file.js +85 -0
- package/dist/src/schema/types.d.ts +26 -0
- package/dist/src/schema/types.js +2 -0
- package/dist/src/settings/errors.d.ts +22 -0
- package/dist/src/settings/errors.js +15 -0
- package/dist/src/settings/format-preserving-json.d.ts +40 -0
- package/dist/src/settings/format-preserving-json.js +80 -0
- package/dist/src/settings/index.d.ts +15 -0
- package/dist/src/settings/index.js +14 -0
- package/dist/src/settings/schema.d.ts +687 -0
- package/dist/src/settings/schema.js +977 -0
- package/dist/src/settings/settings.d.ts +38 -0
- package/dist/src/settings/settings.js +213 -0
- package/dist/src/testing.d.ts +17 -0
- package/dist/src/testing.js +17 -0
- package/dist/src/utils/atomic-write.d.ts +67 -0
- package/dist/src/utils/atomic-write.js +71 -0
- package/dist/src/utils/environment.d.ts +16 -0
- package/dist/src/utils/environment.js +19 -0
- package/dist/src/utils/path-safety.d.ts +25 -0
- package/dist/src/utils/path-safety.js +34 -0
- package/dist/src/utils/resolve-parent-symlinks.d.ts +16 -0
- package/dist/src/utils/resolve-parent-symlinks.js +36 -0
- package/dist/src/workspace/accepted-canonical-ref.d.ts +58 -0
- package/dist/src/workspace/accepted-canonical-ref.js +229 -0
- package/dist/src/workspace/artifact-change.d.ts +14 -0
- package/dist/src/workspace/artifact-change.js +18 -0
- package/dist/src/workspace/canonical-observation.d.ts +39 -0
- package/dist/src/workspace/canonical-observation.js +307 -0
- package/dist/src/workspace/configured-agent-outcome.d.ts +22 -0
- package/dist/src/workspace/configured-agent-outcome.js +33 -0
- package/dist/src/workspace/configured-agent-outcomes-provider.d.ts +50 -0
- package/dist/src/workspace/configured-agent-outcomes-provider.js +26 -0
- package/dist/src/workspace/configured-agent-outcomes.d.ts +48 -0
- package/dist/src/workspace/configured-agent-outcomes.js +113 -0
- package/dist/src/workspace/configured-entry-resolution/types.d.ts +32 -0
- package/dist/src/workspace/configured-entry-resolution/types.js +2 -0
- package/dist/src/workspace/configured-entry-resolution/workspace-ref.d.ts +32 -0
- package/dist/src/workspace/configured-entry-resolution/workspace-ref.js +176 -0
- package/dist/src/workspace/constants.d.ts +6 -0
- package/dist/src/workspace/constants.js +6 -0
- package/dist/src/workspace/create-symlink.d.ts +26 -0
- package/dist/src/workspace/create-symlink.js +87 -0
- package/dist/src/workspace/desired-pack-lock.d.ts +18 -0
- package/dist/src/workspace/desired-pack-lock.js +132 -0
- package/dist/src/workspace/desired-state-enabled.d.ts +18 -0
- package/dist/src/workspace/desired-state-enabled.js +16 -0
- package/dist/src/workspace/desired-state-graph.d.ts +114 -0
- package/dist/src/workspace/desired-state-graph.js +384 -0
- package/dist/src/workspace/desired-state-problem-text.d.ts +6 -0
- package/dist/src/workspace/desired-state-problem-text.js +27 -0
- package/dist/src/workspace/errors.d.ts +184 -0
- package/dist/src/workspace/errors.js +79 -0
- package/dist/src/workspace/extension-name.d.ts +28 -0
- package/dist/src/workspace/extension-name.js +66 -0
- package/dist/src/workspace/extension-paths.d.ts +82 -0
- package/dist/src/workspace/extension-paths.js +172 -0
- package/dist/src/workspace/footprint-recorder.d.ts +30 -0
- package/dist/src/workspace/footprint-recorder.js +32 -0
- package/dist/src/workspace/layout.d.ts +43 -0
- package/dist/src/workspace/layout.js +164 -0
- package/dist/src/workspace/lock-entry-to-ref.d.ts +40 -0
- package/dist/src/workspace/lock-entry-to-ref.js +433 -0
- package/dist/src/workspace/lock-entry-to-source-params.d.ts +26 -0
- package/dist/src/workspace/lock-entry-to-source-params.js +81 -0
- package/dist/src/workspace/locked-entries.d.ts +30 -0
- package/dist/src/workspace/locked-entries.js +34 -0
- package/dist/src/workspace/materialized-file-target.d.ts +14 -0
- package/dist/src/workspace/materialized-file-target.js +14 -0
- package/dist/src/workspace/materialized-tree.d.ts +23 -0
- package/dist/src/workspace/materialized-tree.js +90 -0
- package/dist/src/workspace/mcp-entry-semantics.d.ts +31 -0
- package/dist/src/workspace/mcp-entry-semantics.js +60 -0
- package/dist/src/workspace/observed-installed.d.ts +9 -0
- package/dist/src/workspace/observed-installed.js +9 -0
- package/dist/src/workspace/pack-manifest-content-identity.d.ts +12 -0
- package/dist/src/workspace/pack-manifest-content-identity.js +20 -0
- package/dist/src/workspace/pack-paths.d.ts +24 -0
- package/dist/src/workspace/pack-paths.js +16 -0
- package/dist/src/workspace/package-hash.d.ts +25 -0
- package/dist/src/workspace/package-hash.js +45 -0
- package/dist/src/workspace/paths.d.ts +24 -0
- package/dist/src/workspace/paths.js +52 -0
- package/dist/src/workspace/read-model/__fixtures__/builder.d.ts +199 -0
- package/dist/src/workspace/read-model/__fixtures__/builder.js +588 -0
- package/dist/src/workspace/read-model/__fixtures__/decoders.d.ts +15 -0
- package/dist/src/workspace/read-model/__fixtures__/decoders.js +15 -0
- package/dist/src/workspace/read-model/__fixtures__/occurrences.d.ts +72 -0
- package/dist/src/workspace/read-model/__fixtures__/occurrences.js +134 -0
- package/dist/src/workspace/read-model/__fixtures__/scenario-harness.d.ts +99 -0
- package/dist/src/workspace/read-model/__fixtures__/scenario-harness.js +142 -0
- package/dist/src/workspace/read-model/__fixtures__/test-layer.d.ts +60 -0
- package/dist/src/workspace/read-model/__fixtures__/test-layer.js +57 -0
- package/dist/src/workspace/read-model/agent-presence.d.ts +32 -0
- package/dist/src/workspace/read-model/agent-presence.js +21 -0
- package/dist/src/workspace/read-model/agent-root-resolver.d.ts +38 -0
- package/dist/src/workspace/read-model/agent-root-resolver.js +35 -0
- package/dist/src/workspace/read-model/agents/index.d.ts +38 -0
- package/dist/src/workspace/read-model/agents/index.js +45 -0
- package/dist/src/workspace/read-model/agents/shared.d.ts +27 -0
- package/dist/src/workspace/read-model/agents/shared.js +63 -0
- package/dist/src/workspace/read-model/agents/types.d.ts +133 -0
- package/dist/src/workspace/read-model/agents/types.js +51 -0
- package/dist/src/workspace/read-model/diagnostics.d.ts +18 -0
- package/dist/src/workspace/read-model/diagnostics.js +14 -0
- package/dist/src/workspace/read-model/discovery/index.d.ts +5 -0
- package/dist/src/workspace/read-model/discovery/index.js +5 -0
- package/dist/src/workspace/read-model/discovery/plugin-manifests.d.ts +16 -0
- package/dist/src/workspace/read-model/discovery/plugin-manifests.js +168 -0
- package/dist/src/workspace/read-model/discovery/skills.d.ts +58 -0
- package/dist/src/workspace/read-model/discovery/skills.js +263 -0
- package/dist/src/workspace/read-model/discovery/subagents.d.ts +37 -0
- package/dist/src/workspace/read-model/discovery/subagents.js +48 -0
- package/dist/src/workspace/read-model/errors.d.ts +93 -0
- package/dist/src/workspace/read-model/errors.js +30 -0
- package/dist/src/workspace/read-model/extensions/actual-helpers.d.ts +4 -0
- package/dist/src/workspace/read-model/extensions/actual-helpers.js +4 -0
- package/dist/src/workspace/read-model/extensions/hook.d.ts +104 -0
- package/dist/src/workspace/read-model/extensions/hook.js +119 -0
- package/dist/src/workspace/read-model/extensions/index.d.ts +19 -0
- package/dist/src/workspace/read-model/extensions/index.js +43 -0
- package/dist/src/workspace/read-model/extensions/indexByName.d.ts +31 -0
- package/dist/src/workspace/read-model/extensions/indexByName.js +30 -0
- package/dist/src/workspace/read-model/extensions/inventory.d.ts +99 -0
- package/dist/src/workspace/read-model/extensions/inventory.js +111 -0
- package/dist/src/workspace/read-model/extensions/knowledge.d.ts +101 -0
- package/dist/src/workspace/read-model/extensions/knowledge.js +121 -0
- package/dist/src/workspace/read-model/extensions/mcp-server.d.ts +106 -0
- package/dist/src/workspace/read-model/extensions/mcp-server.js +122 -0
- package/dist/src/workspace/read-model/extensions/pack.d.ts +104 -0
- package/dist/src/workspace/read-model/extensions/pack.js +123 -0
- package/dist/src/workspace/read-model/extensions/package-root.d.ts +39 -0
- package/dist/src/workspace/read-model/extensions/package-root.js +48 -0
- package/dist/src/workspace/read-model/extensions/projection.d.ts +137 -0
- package/dist/src/workspace/read-model/extensions/projection.js +180 -0
- package/dist/src/workspace/read-model/extensions/rule.d.ts +104 -0
- package/dist/src/workspace/read-model/extensions/rule.js +113 -0
- package/dist/src/workspace/read-model/extensions/skill.d.ts +170 -0
- package/dist/src/workspace/read-model/extensions/skill.js +148 -0
- package/dist/src/workspace/read-model/extensions/subagent.d.ts +97 -0
- package/dist/src/workspace/read-model/extensions/subagent.js +120 -0
- package/dist/src/workspace/read-model/scanners/agent-dir.d.ts +49 -0
- package/dist/src/workspace/read-model/scanners/agent-dir.js +180 -0
- package/dist/src/workspace/read-model/scanners/agent-root.d.ts +73 -0
- package/dist/src/workspace/read-model/scanners/agent-root.js +148 -0
- package/dist/src/workspace/read-model/scanners/agent-settings.d.ts +43 -0
- package/dist/src/workspace/read-model/scanners/agent-settings.js +54 -0
- package/dist/src/workspace/read-model/scanners/canonical-extensions.d.ts +48 -0
- package/dist/src/workspace/read-model/scanners/canonical-extensions.js +237 -0
- package/dist/src/workspace/read-model/scanners/fs-helpers.d.ts +63 -0
- package/dist/src/workspace/read-model/scanners/fs-helpers.js +106 -0
- package/dist/src/workspace/read-model/scanners/index.d.ts +15 -0
- package/dist/src/workspace/read-model/scanners/index.js +34 -0
- package/dist/src/workspace/read-model/scanners/mcp-config.d.ts +47 -0
- package/dist/src/workspace/read-model/scanners/mcp-config.js +212 -0
- package/dist/src/workspace/read-model/scanners/types.d.ts +170 -0
- package/dist/src/workspace/read-model/scanners/types.js +86 -0
- package/dist/src/workspace/read-model/service.d.ts +103 -0
- package/dist/src/workspace/read-model/service.js +391 -0
- package/dist/src/workspace/read-model/state.d.ts +35 -0
- package/dist/src/workspace/read-model/state.js +97 -0
- package/dist/src/workspace/read-model/types.d.ts +75 -0
- package/dist/src/workspace/read-model/types.js +26 -0
- package/dist/src/workspace/read-model-record-readers.d.ts +34 -0
- package/dist/src/workspace/read-model-record-readers.js +467 -0
- package/dist/src/workspace/read-model-record-rows.d.ts +45 -0
- package/dist/src/workspace/read-model-record-rows.js +33 -0
- package/dist/src/workspace/read-model-record-types.d.ts +45 -0
- package/dist/src/workspace/read-model-record-types.js +13 -0
- package/dist/src/workspace/remove-if-exists.d.ts +13 -0
- package/dist/src/workspace/remove-if-exists.js +26 -0
- package/dist/src/workspace/rendered-files.d.ts +53 -0
- package/dist/src/workspace/rendered-files.js +50 -0
- package/dist/src/workspace/scope-refusal.d.ts +26 -0
- package/dist/src/workspace/scope-refusal.js +29 -0
- package/dist/src/workspace/service-interface.d.ts +479 -0
- package/dist/src/workspace/service-interface.js +27 -0
- package/dist/src/workspace/service.d.ts +1665 -0
- package/dist/src/workspace/service.js +1263 -0
- package/dist/src/workspace/setup-scope-support.d.ts +27 -0
- package/dist/src/workspace/setup-scope-support.js +299 -0
- package/dist/src/workspace/skill-paths.d.ts +33 -0
- package/dist/src/workspace/skill-paths.js +14 -0
- package/dist/src/workspace/source-metadata.d.ts +7 -0
- package/dist/src/workspace/source-metadata.js +10 -0
- package/dist/src/workspace/source-to-lock-entry.d.ts +32 -0
- package/dist/src/workspace/source-to-lock-entry.js +68 -0
- package/dist/src/workspace/test-stubs.d.ts +144 -0
- package/dist/src/workspace/test-stubs.js +412 -0
- package/dist/src/workspace/transaction.d.ts +218 -0
- package/dist/src/workspace/transaction.js +177 -0
- package/package.json +57 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workspace transaction state: the ambient authority context, the write
|
|
3
|
+
* registration primitives every workspace writer calls, and the typed
|
|
4
|
+
* failure vocabulary of the transaction and transition-lock machinery.
|
|
5
|
+
*
|
|
6
|
+
* This module owns the ambient transaction/closure references and the
|
|
7
|
+
* protection primitives (`protectWorkspacePath`, `protectCreatedAncestors`)
|
|
8
|
+
* that snapshot a path before its first mutation. The transaction runner and
|
|
9
|
+
* closure settlement mechanics that consume this context live in
|
|
10
|
+
* `./operations/transaction.ts`; the application error boundary owns the
|
|
11
|
+
* rendering, codes, and suggestions for every failure declared here.
|
|
12
|
+
*
|
|
13
|
+
* @experimental This API is unstable and may change without notice.
|
|
14
|
+
*/
|
|
15
|
+
import * as ServiceMap from "effect/Context";
|
|
16
|
+
import * as Data from "effect/Data";
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
|
+
import * as FileSystem from "effect/FileSystem";
|
|
19
|
+
import * as Option from "effect/Option";
|
|
20
|
+
import * as Path from "effect/Path";
|
|
21
|
+
import * as Semaphore from "effect/Semaphore";
|
|
22
|
+
export const CurrentWorkspaceTransaction = ServiceMap.Reference("@agentxm/workspace-state/workspace/transaction/CurrentWorkspaceTransaction", {
|
|
23
|
+
defaultValue: () => Option.none(),
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* The semantic closure whose mutations are currently executing. Snapshots
|
|
27
|
+
* taken while a closure is active belong to it: they are dropped when the
|
|
28
|
+
* closure settles and restored when it — and only it — rolls back. Snapshots
|
|
29
|
+
* taken outside any closure belong to the operation closure and are restored
|
|
30
|
+
* by the transaction's own failure handling.
|
|
31
|
+
*/
|
|
32
|
+
export const CurrentWorkspaceClosure = ServiceMap.Reference("@agentxm/workspace-state/workspace/transaction/CurrentWorkspaceClosure", { defaultValue: () => undefined });
|
|
33
|
+
/**
|
|
34
|
+
* Restoration did not complete: the typed fact the terminal resolution
|
|
35
|
+
* derives outcome, disposition, and exit status from. The pre-change
|
|
36
|
+
* snapshots survive in the OS-temporary snapshot directory; nothing about
|
|
37
|
+
* this failure persists in the workspace, and the next mutation converges
|
|
38
|
+
* from the current workspace state.
|
|
39
|
+
*/
|
|
40
|
+
export class WorkspaceRestorationIncomplete extends Data.TaggedError("WorkspaceRestorationIncomplete") {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Registering a path with the active transaction failed: the pre-mutation
|
|
44
|
+
* preimage could not be taken, so the path was never mutated. `target` is the
|
|
45
|
+
* path being protected; the `create-store` step's message interpolates
|
|
46
|
+
* nothing.
|
|
47
|
+
*/
|
|
48
|
+
export class WorkspaceSnapshotError extends Data.TaggedError("WorkspaceSnapshotError") {
|
|
49
|
+
}
|
|
50
|
+
/** Preparing the workspace state directory for a transition failed. */
|
|
51
|
+
export class WorkspaceDirectoryError extends Data.TaggedError("WorkspaceDirectoryError") {
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Workspace transition-lock mechanics failed. `path` carries the fact each
|
|
55
|
+
* step's message interpolates: the scratch directory for `create-scratch`,
|
|
56
|
+
* the lock path otherwise. `missing-timestamp` has no underlying cause.
|
|
57
|
+
*/
|
|
58
|
+
export class TransitionLockError extends Data.TaggedError("TransitionLockError") {
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The bounded contention wait elapsed while another invocation held the
|
|
62
|
+
* workspace transition.
|
|
63
|
+
*/
|
|
64
|
+
export class TransitionLockUnavailable extends Data.TaggedError("TransitionLockUnavailable") {
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The hold is no longer provably owned: ownership could not be confirmed
|
|
68
|
+
* within the staleness window, so a contender may already have reclaimed the
|
|
69
|
+
* lock. Any further durable write by the original owner — mutation and
|
|
70
|
+
* restoration alike — could overwrite a successor's work.
|
|
71
|
+
*/
|
|
72
|
+
export class WorkspaceTransitionCompromised extends Data.TaggedError("WorkspaceTransitionCompromised") {
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One restoration step did not complete or verify. Never a channel failure:
|
|
76
|
+
* it travels as the `restorationCause` inside
|
|
77
|
+
* {@link WorkspaceRestorationIncomplete} and the pending closure records.
|
|
78
|
+
*/
|
|
79
|
+
export class WorkspaceRestorationError extends Data.TaggedError("WorkspaceRestorationError") {
|
|
80
|
+
}
|
|
81
|
+
const closureKey = (closure) => closure ?? "";
|
|
82
|
+
/**
|
|
83
|
+
* Snapshot one target into the active transaction context, deduplicating on
|
|
84
|
+
* first touch per closure. Shared by the registration primitives below and by
|
|
85
|
+
* the transaction runner claiming its declared targets.
|
|
86
|
+
*/
|
|
87
|
+
export const protectInContext = (context, target, closure) => context.snapshotSemaphore.withPermits(1)(Effect.gen(function* () {
|
|
88
|
+
const { fs, path } = context;
|
|
89
|
+
const normalized = path.resolve(target);
|
|
90
|
+
// First-touch dedupe is per closure: a later closure touching a target
|
|
91
|
+
// an earlier closure already committed needs its own — post-commit —
|
|
92
|
+
// preimage, so restoring it undoes only that closure's work.
|
|
93
|
+
const key = closureKey(closure);
|
|
94
|
+
const protectedForClosure = context.protectedTargets.get(key) ?? new Set();
|
|
95
|
+
if (protectedForClosure.has(normalized))
|
|
96
|
+
return;
|
|
97
|
+
const link = yield* fs.readLink(normalized).pipe(Effect.option);
|
|
98
|
+
let snapshot;
|
|
99
|
+
if (Option.isSome(link)) {
|
|
100
|
+
snapshot = { closure, target: normalized, state: "symlink", linkTarget: link.value };
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const exists = yield* fs
|
|
104
|
+
.exists(normalized)
|
|
105
|
+
.pipe(Effect.mapError((cause) => new WorkspaceSnapshotError({ target: normalized, step: "inspect-target", cause })));
|
|
106
|
+
if (!exists) {
|
|
107
|
+
snapshot = { closure, target: normalized, state: "absent" };
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
if (context.snapshotStore.dir === undefined) {
|
|
111
|
+
context.snapshotStore.dir = yield* fs
|
|
112
|
+
.makeTempDirectory({ prefix: "axm-rollback-" })
|
|
113
|
+
.pipe(Effect.mapError((cause) => new WorkspaceSnapshotError({ target: normalized, step: "create-store", cause })));
|
|
114
|
+
}
|
|
115
|
+
const backup = path.join(context.snapshotStore.dir, `${context.snapshotSequence.value++}.snap`);
|
|
116
|
+
// The pre-change bytes are preserved before the path is first
|
|
117
|
+
// mutated; a path that cannot be snapshotted is never mutated.
|
|
118
|
+
yield* fs
|
|
119
|
+
.copy(normalized, backup, { preserveTimestamps: true })
|
|
120
|
+
.pipe(Effect.mapError((cause) => new WorkspaceSnapshotError({ target: normalized, step: "copy", cause })));
|
|
121
|
+
snapshot = { closure, target: normalized, state: "copied", backup };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
protectedForClosure.add(normalized);
|
|
125
|
+
context.protectedTargets.set(key, protectedForClosure);
|
|
126
|
+
context.snapshots.push(snapshot);
|
|
127
|
+
}));
|
|
128
|
+
/** Snapshot a path before its first mutation when a workspace transaction is active. */
|
|
129
|
+
export const protectWorkspacePath = (target) => Effect.gen(function* () {
|
|
130
|
+
const current = yield* CurrentWorkspaceTransaction;
|
|
131
|
+
if (Option.isNone(current))
|
|
132
|
+
return;
|
|
133
|
+
const closure = yield* CurrentWorkspaceClosure;
|
|
134
|
+
yield* protectInContext(current.value, target, closure);
|
|
135
|
+
});
|
|
136
|
+
/**
|
|
137
|
+
* Closure rollbacks that could not complete and verify, with the snapshot
|
|
138
|
+
* store that still preserves their pre-change bytes. Read at the end of a
|
|
139
|
+
* plan apply so the terminal resolution derives retained state from the
|
|
140
|
+
* in-memory facts alone. `None` outside a transaction.
|
|
141
|
+
*/
|
|
142
|
+
export const readPendingClosureRestorationFailures = CurrentWorkspaceTransaction.pipe(Effect.map(Option.map((context) => ({
|
|
143
|
+
failures: [...context.pendingRestorationFailures],
|
|
144
|
+
snapshotDir: context.snapshotStore.dir,
|
|
145
|
+
}))));
|
|
146
|
+
/**
|
|
147
|
+
* Protect the first ancestor a recursive directory creation is about to
|
|
148
|
+
* create, so restoration removes the created directory chain instead of
|
|
149
|
+
* leaving empty parents behind. No-op outside a transaction or when the
|
|
150
|
+
* directory already exists.
|
|
151
|
+
*/
|
|
152
|
+
export const protectCreatedAncestors = (fs, path, directory) => CurrentWorkspaceTransaction.pipe(Effect.flatMap(Option.match({
|
|
153
|
+
onNone: () => Effect.void,
|
|
154
|
+
onSome: (context) => Effect.gen(function* () {
|
|
155
|
+
let firstMissing;
|
|
156
|
+
let current = path.resolve(directory);
|
|
157
|
+
while (true) {
|
|
158
|
+
const exists = yield* fs.exists(current).pipe(Effect.mapError((cause) => new WorkspaceSnapshotError({
|
|
159
|
+
target: current,
|
|
160
|
+
step: "inspect-ancestor",
|
|
161
|
+
cause,
|
|
162
|
+
})));
|
|
163
|
+
if (exists)
|
|
164
|
+
break;
|
|
165
|
+
firstMissing = current;
|
|
166
|
+
const parent = path.dirname(current);
|
|
167
|
+
if (parent === current)
|
|
168
|
+
break;
|
|
169
|
+
current = parent;
|
|
170
|
+
}
|
|
171
|
+
if (firstMissing !== undefined) {
|
|
172
|
+
const closure = yield* CurrentWorkspaceClosure;
|
|
173
|
+
yield* protectInContext(context, firstMissing, closure);
|
|
174
|
+
}
|
|
175
|
+
}),
|
|
176
|
+
})));
|
|
177
|
+
//# sourceMappingURL=transaction.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agentxm/workspace-state",
|
|
3
|
+
"version": "0.28.4-bootstrap.0",
|
|
4
|
+
"description": "AXM workspace state kernel: settings, lockfile, read model, and desired-state vocabulary for the axm CLI. Unstable and unsupported — use the axm.sh CLI.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "FSL-1.1-MIT",
|
|
7
|
+
"homepage": "https://axm.sh",
|
|
8
|
+
"bugs": {
|
|
9
|
+
"url": "https://github.com/agentxm/axm/issues"
|
|
10
|
+
},
|
|
11
|
+
"author": "AgentXM <hello@agentxm.ai> (https://agentxm.ai)",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/agentxm/axm.git",
|
|
15
|
+
"directory": "packages/workspace-state"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/src/index.d.ts",
|
|
21
|
+
"default": "./dist/src/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./testing": {
|
|
24
|
+
"types": "./dist/src/testing.d.ts",
|
|
25
|
+
"default": "./dist/src/testing.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/src/",
|
|
30
|
+
"!**/*.map"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22.19.0"
|
|
37
|
+
},
|
|
38
|
+
"nx": {
|
|
39
|
+
"includedScripts": []
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"effect": "4.0.0-rc.112",
|
|
43
|
+
"jsonc-parser": "^3.3.1",
|
|
44
|
+
"semver": "^7.8.5",
|
|
45
|
+
"yaml": "^2.9.0",
|
|
46
|
+
"@agentxm/registry-protocol": "^0.28.4-bootstrap.0",
|
|
47
|
+
"@agentxm/extension-model": "^0.28.4-bootstrap.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@effect/platform-node": "4.0.0-rc.112",
|
|
51
|
+
"@effect/vitest": "4.0.0-rc.112",
|
|
52
|
+
"@types/semver": "^7.5.8",
|
|
53
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
54
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
55
|
+
"vitest": "^4.1.10"
|
|
56
|
+
}
|
|
57
|
+
}
|