@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,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footprint recorder — observed durable changes.
|
|
3
|
+
*
|
|
4
|
+
* The layers that touch durable state record what they actually committed,
|
|
5
|
+
* removed, or restored here; the operation resolution's footprint is these
|
|
6
|
+
* observations, not planner-claimed artifact paths. Recording is a no-op when
|
|
7
|
+
* no recorder is provided, so the writers stay usable outside an operation
|
|
8
|
+
* boundary.
|
|
9
|
+
*
|
|
10
|
+
* @experimental This API is unstable and may change without notice.
|
|
11
|
+
*/
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Ref from "effect/Ref";
|
|
14
|
+
import * as ServiceMap from "effect/Context";
|
|
15
|
+
export interface FootprintObservation {
|
|
16
|
+
/** Absolute path of the durable change. */
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly change: "created" | "modified" | "removed" | "restored";
|
|
19
|
+
}
|
|
20
|
+
declare const FootprintRecorder_base: ServiceMap.ServiceClass<FootprintRecorder, "@agentxm/workspace-state/workspace/footprint-recorder/FootprintRecorder", {
|
|
21
|
+
readonly ref: Ref.Ref<ReadonlyArray<FootprintObservation>>;
|
|
22
|
+
}>;
|
|
23
|
+
export declare class FootprintRecorder extends FootprintRecorder_base {
|
|
24
|
+
}
|
|
25
|
+
/** Record one observed durable change. No-op without a recorder. */
|
|
26
|
+
export declare const recordFootprint: (observation: FootprintObservation) => Effect.Effect<void>;
|
|
27
|
+
export declare const readFootprint: Effect.Effect<ReadonlyArray<FootprintObservation>>;
|
|
28
|
+
export declare const makeFootprintRecorder: Effect.Effect<ServiceMap.Service.Shape<typeof FootprintRecorder>>;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=footprint-recorder.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Footprint recorder — observed durable changes.
|
|
3
|
+
*
|
|
4
|
+
* The layers that touch durable state record what they actually committed,
|
|
5
|
+
* removed, or restored here; the operation resolution's footprint is these
|
|
6
|
+
* observations, not planner-claimed artifact paths. Recording is a no-op when
|
|
7
|
+
* no recorder is provided, so the writers stay usable outside an operation
|
|
8
|
+
* boundary.
|
|
9
|
+
*
|
|
10
|
+
* @experimental This API is unstable and may change without notice.
|
|
11
|
+
*/
|
|
12
|
+
import * as Effect from "effect/Effect";
|
|
13
|
+
import * as Option from "effect/Option";
|
|
14
|
+
import * as Ref from "effect/Ref";
|
|
15
|
+
import * as ServiceMap from "effect/Context";
|
|
16
|
+
export class FootprintRecorder extends ServiceMap.Service()("@agentxm/workspace-state/workspace/footprint-recorder/FootprintRecorder") {
|
|
17
|
+
}
|
|
18
|
+
/** Record one observed durable change. No-op without a recorder. */
|
|
19
|
+
export const recordFootprint = (observation) => Effect.gen(function* () {
|
|
20
|
+
const service = yield* Effect.serviceOption(FootprintRecorder);
|
|
21
|
+
if (Option.isNone(service))
|
|
22
|
+
return;
|
|
23
|
+
yield* Ref.update(service.value.ref, (entries) => [...entries, observation]);
|
|
24
|
+
});
|
|
25
|
+
export const readFootprint = Effect.gen(function* () {
|
|
26
|
+
const service = yield* Effect.serviceOption(FootprintRecorder);
|
|
27
|
+
if (Option.isNone(service))
|
|
28
|
+
return [];
|
|
29
|
+
return yield* Ref.get(service.value.ref);
|
|
30
|
+
});
|
|
31
|
+
export const makeFootprintRecorder = Ref.make([]).pipe(Effect.map((ref) => ({ ref })));
|
|
32
|
+
//# sourceMappingURL=footprint-recorder.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as FileSystem from "effect/FileSystem";
|
|
3
|
+
import * as Path from "effect/Path";
|
|
4
|
+
import { WorkspaceLayoutError } from "./errors.js";
|
|
5
|
+
import type { ExtensionType } from "@agentxm/extension-model/unstable/extensions/common";
|
|
6
|
+
import type { Handle } from "@agentxm/extension-model/unstable/extensions/handle";
|
|
7
|
+
import type { Settings } from "../settings/schema.js";
|
|
8
|
+
import { type AbsolutePath } from "@agentxm/extension-model/unstable/path-types";
|
|
9
|
+
export { LOCK_FILENAME } from "./constants.js";
|
|
10
|
+
export declare const RUNTIME_DIRECTORY = ".axm";
|
|
11
|
+
export interface ProjectWorkspaceLayout {
|
|
12
|
+
readonly scope: "project";
|
|
13
|
+
readonly workspaceRoot: AbsolutePath;
|
|
14
|
+
readonly projectRoot: AbsolutePath;
|
|
15
|
+
readonly settingsPath: AbsolutePath;
|
|
16
|
+
readonly lockPath: AbsolutePath;
|
|
17
|
+
readonly runtimeDir: AbsolutePath;
|
|
18
|
+
readonly acquiredRoot: AbsolutePath;
|
|
19
|
+
readonly owner?: Handle;
|
|
20
|
+
readonly authoredRoot: (type: ExtensionType) => AbsolutePath;
|
|
21
|
+
}
|
|
22
|
+
export interface UserWorkspaceLayout {
|
|
23
|
+
readonly scope: "user";
|
|
24
|
+
readonly userHome: AbsolutePath;
|
|
25
|
+
readonly axmHome: AbsolutePath;
|
|
26
|
+
readonly workspaceRoot: AbsolutePath;
|
|
27
|
+
readonly settingsPath: AbsolutePath;
|
|
28
|
+
readonly lockPath: AbsolutePath;
|
|
29
|
+
readonly runtimeDir: AbsolutePath;
|
|
30
|
+
readonly acquiredRoot: AbsolutePath;
|
|
31
|
+
readonly owner?: Handle;
|
|
32
|
+
}
|
|
33
|
+
export type WorkspaceLayout = ProjectWorkspaceLayout | UserWorkspaceLayout;
|
|
34
|
+
export declare const resolveProjectWorkspaceStatePaths: (path: Path.Path, projectRoot: AbsolutePath) => {
|
|
35
|
+
settingsPath: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
36
|
+
lockPath: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
37
|
+
runtimeDir: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
38
|
+
acquiredRoot: string & import("effect/Brand").Brand<"AbsolutePath">;
|
|
39
|
+
};
|
|
40
|
+
export declare const configuredAuthoredDirectory: (settings: Settings, type: ExtensionType) => string;
|
|
41
|
+
export declare const resolveProjectWorkspaceLayout: (projectRoot: AbsolutePath, settings: Settings) => Effect.Effect<ProjectWorkspaceLayout, WorkspaceLayoutError, FileSystem.FileSystem | Path.Path>;
|
|
42
|
+
export declare const resolveUserWorkspaceLayout: (userHome: AbsolutePath, settings?: Settings) => Effect.Effect<UserWorkspaceLayout, never, Path.Path>;
|
|
43
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as FileSystem from "effect/FileSystem";
|
|
3
|
+
import * as Option from "effect/Option";
|
|
4
|
+
import * as Path from "effect/Path";
|
|
5
|
+
import { AGENTS } from "@agentxm/extension-model/unstable/agents/registry";
|
|
6
|
+
import { WorkspaceLayoutError } from "./errors.js";
|
|
7
|
+
import { ACQUIRED_EXTENSIONS_DIR, AXM_DIR_NAME, LOCK_FILENAME, USER_WORKSPACE_DIRECTORY, } from "./constants.js";
|
|
8
|
+
import { makeAbsolutePath } from "@agentxm/extension-model/unstable/path-types";
|
|
9
|
+
import { SETTINGS_FILENAME } from "@agentxm/extension-model/unstable/workspace-files";
|
|
10
|
+
export { LOCK_FILENAME } from "./constants.js";
|
|
11
|
+
export const RUNTIME_DIRECTORY = AXM_DIR_NAME;
|
|
12
|
+
const DEFAULT_AUTHORED_DIRECTORIES = {
|
|
13
|
+
skill: "skills",
|
|
14
|
+
"mcp-server": "mcps",
|
|
15
|
+
subagent: "subagents",
|
|
16
|
+
rule: "rules",
|
|
17
|
+
hook: "hooks",
|
|
18
|
+
knowledge: "knowledge",
|
|
19
|
+
pack: "packs",
|
|
20
|
+
};
|
|
21
|
+
const EXTENSION_TYPES = [
|
|
22
|
+
"skill",
|
|
23
|
+
"mcp-server",
|
|
24
|
+
"subagent",
|
|
25
|
+
"rule",
|
|
26
|
+
"hook",
|
|
27
|
+
"knowledge",
|
|
28
|
+
"pack",
|
|
29
|
+
];
|
|
30
|
+
export const resolveProjectWorkspaceStatePaths = (path, projectRoot) => ({
|
|
31
|
+
settingsPath: makeAbsolutePath(path, path.join(projectRoot, SETTINGS_FILENAME)),
|
|
32
|
+
lockPath: makeAbsolutePath(path, path.join(projectRoot, LOCK_FILENAME)),
|
|
33
|
+
runtimeDir: makeAbsolutePath(path, path.join(projectRoot, RUNTIME_DIRECTORY)),
|
|
34
|
+
acquiredRoot: makeAbsolutePath(path, path.join(projectRoot, ACQUIRED_EXTENSIONS_DIR)),
|
|
35
|
+
});
|
|
36
|
+
export const configuredAuthoredDirectory = (settings, type) => {
|
|
37
|
+
switch (type) {
|
|
38
|
+
case "skill":
|
|
39
|
+
return settings.skillsConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES.skill;
|
|
40
|
+
case "mcp-server":
|
|
41
|
+
return settings.mcpServersConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES["mcp-server"];
|
|
42
|
+
case "subagent":
|
|
43
|
+
return settings.subagentsConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES.subagent;
|
|
44
|
+
case "rule":
|
|
45
|
+
return settings.rulesConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES.rule;
|
|
46
|
+
case "hook":
|
|
47
|
+
return settings.hooksConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES.hook;
|
|
48
|
+
case "knowledge":
|
|
49
|
+
return settings.knowledgeConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES.knowledge;
|
|
50
|
+
case "pack":
|
|
51
|
+
return settings.packsConfig?.dir ?? DEFAULT_AUTHORED_DIRECTORIES.pack;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const layoutError = (detail, cause) => new WorkspaceLayoutError({ detail, ...(cause === undefined ? {} : { cause }) });
|
|
55
|
+
const overlaps = (path, left, right) => {
|
|
56
|
+
const relative = path.relative(left, right);
|
|
57
|
+
return relative === "" || (!relative.startsWith("..") && !path.isAbsolute(relative));
|
|
58
|
+
};
|
|
59
|
+
const validateLexicalDirectory = (path, projectRoot, type, configured, reservedRoots) => {
|
|
60
|
+
if (path.isAbsolute(configured) ||
|
|
61
|
+
configured === "." ||
|
|
62
|
+
path.normalize(configured) !== configured ||
|
|
63
|
+
configured.split(/[\\/]/u).some((segment) => segment === ".." || segment === ".")) {
|
|
64
|
+
return Effect.fail(layoutError(`Invalid ${type} authored directory "${configured}": expected a normalized workspace-relative path`));
|
|
65
|
+
}
|
|
66
|
+
const resolved = path.resolve(projectRoot, configured);
|
|
67
|
+
if (!overlaps(path, projectRoot, resolved)) {
|
|
68
|
+
return Effect.fail(layoutError(`Invalid ${type} authored directory "${configured}": path escapes the workspace`));
|
|
69
|
+
}
|
|
70
|
+
const collision = reservedRoots.find((reserved) => overlaps(path, reserved, resolved));
|
|
71
|
+
if (collision !== undefined) {
|
|
72
|
+
return Effect.fail(layoutError(`Invalid ${type} authored directory "${configured}": overlaps reserved path ${collision}`));
|
|
73
|
+
}
|
|
74
|
+
return Effect.succeed(makeAbsolutePath(path, resolved));
|
|
75
|
+
};
|
|
76
|
+
const validateExistingAuthoredRoot = (fs, path, projectRoot, type, root) => Effect.gen(function* () {
|
|
77
|
+
const exists = yield* fs
|
|
78
|
+
.exists(root)
|
|
79
|
+
.pipe(Effect.mapError((cause) => layoutError(`Failed to inspect ${type} authored root ${root}`, cause)));
|
|
80
|
+
if (!exists)
|
|
81
|
+
return;
|
|
82
|
+
const link = yield* fs.readLink(root).pipe(Effect.option);
|
|
83
|
+
if (Option.isSome(link)) {
|
|
84
|
+
return yield* layoutError(`Invalid ${type} authored root ${root}: authored roots cannot be symlinks`);
|
|
85
|
+
}
|
|
86
|
+
const info = yield* fs
|
|
87
|
+
.stat(root)
|
|
88
|
+
.pipe(Effect.mapError((cause) => layoutError(`Failed to inspect ${type} authored root ${root}`, cause)));
|
|
89
|
+
if (info.type !== "Directory") {
|
|
90
|
+
return yield* layoutError(`Invalid ${type} authored root ${root}: expected a directory`);
|
|
91
|
+
}
|
|
92
|
+
const realProjectRoot = yield* fs
|
|
93
|
+
.realPath(projectRoot)
|
|
94
|
+
.pipe(Effect.orElseSucceed(() => path.resolve(projectRoot)));
|
|
95
|
+
const realRoot = yield* fs
|
|
96
|
+
.realPath(root)
|
|
97
|
+
.pipe(Effect.mapError((cause) => layoutError(`Failed to resolve ${type} authored root ${root}`, cause)));
|
|
98
|
+
if (!overlaps(path, realProjectRoot, realRoot)) {
|
|
99
|
+
return yield* layoutError(`Invalid ${type} authored root ${root}: real path escapes the workspace`);
|
|
100
|
+
}
|
|
101
|
+
const children = yield* fs
|
|
102
|
+
.readDirectory(root)
|
|
103
|
+
.pipe(Effect.mapError((cause) => layoutError(`Failed to inspect ${type} authored root ${root}`, cause)));
|
|
104
|
+
for (const child of children) {
|
|
105
|
+
const childPath = path.join(root, child);
|
|
106
|
+
const childLink = yield* fs.readLink(childPath).pipe(Effect.option);
|
|
107
|
+
if (Option.isSome(childLink)) {
|
|
108
|
+
return yield* layoutError(`Invalid ${type} authored package ${childPath}: direct package directories cannot be symlinks`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
export const resolveProjectWorkspaceLayout = (projectRoot, settings) => Effect.gen(function* () {
|
|
113
|
+
const fs = yield* FileSystem.FileSystem;
|
|
114
|
+
const path = yield* Path.Path;
|
|
115
|
+
const statePaths = resolveProjectWorkspaceStatePaths(path, projectRoot);
|
|
116
|
+
const { runtimeDir, acquiredRoot } = statePaths;
|
|
117
|
+
const agentRoots = Object.values(AGENTS).flatMap((agent) => agent.rootDir === undefined ? [] : [path.join(projectRoot, agent.rootDir)]);
|
|
118
|
+
const reservedRoots = [runtimeDir, acquiredRoot, ...agentRoots];
|
|
119
|
+
const roots = new Map();
|
|
120
|
+
for (const extensionType of EXTENSION_TYPES) {
|
|
121
|
+
const root = yield* validateLexicalDirectory(path, projectRoot, extensionType, configuredAuthoredDirectory(settings, extensionType), reservedRoots);
|
|
122
|
+
for (const [otherType, otherRoot] of roots) {
|
|
123
|
+
if (overlaps(path, otherRoot, root) || overlaps(path, root, otherRoot)) {
|
|
124
|
+
return yield* layoutError(`Invalid ${extensionType} authored directory ${root}: overlaps ${otherType} authored root ${otherRoot}`);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
yield* validateExistingAuthoredRoot(fs, path, projectRoot, extensionType, root);
|
|
128
|
+
roots.set(extensionType, root);
|
|
129
|
+
}
|
|
130
|
+
const authoredRoot = (type) => {
|
|
131
|
+
const root = roots.get(type);
|
|
132
|
+
if (root !== undefined)
|
|
133
|
+
return root;
|
|
134
|
+
return makeAbsolutePath(path, path.join(projectRoot, DEFAULT_AUTHORED_DIRECTORIES[type]));
|
|
135
|
+
};
|
|
136
|
+
return {
|
|
137
|
+
scope: "project",
|
|
138
|
+
workspaceRoot: projectRoot,
|
|
139
|
+
projectRoot,
|
|
140
|
+
settingsPath: statePaths.settingsPath,
|
|
141
|
+
lockPath: statePaths.lockPath,
|
|
142
|
+
runtimeDir,
|
|
143
|
+
acquiredRoot,
|
|
144
|
+
...(settings.owner === undefined ? {} : { owner: settings.owner }),
|
|
145
|
+
authoredRoot,
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
export const resolveUserWorkspaceLayout = (userHome, settings = {}) => Effect.gen(function* () {
|
|
149
|
+
const path = yield* Path.Path;
|
|
150
|
+
const axmHome = makeAbsolutePath(path, path.join(userHome, AXM_DIR_NAME));
|
|
151
|
+
const workspaceRoot = makeAbsolutePath(path, path.join(axmHome, USER_WORKSPACE_DIRECTORY));
|
|
152
|
+
return {
|
|
153
|
+
scope: "user",
|
|
154
|
+
userHome,
|
|
155
|
+
axmHome,
|
|
156
|
+
workspaceRoot,
|
|
157
|
+
settingsPath: makeAbsolutePath(path, path.join(workspaceRoot, SETTINGS_FILENAME)),
|
|
158
|
+
lockPath: makeAbsolutePath(path, path.join(workspaceRoot, LOCK_FILENAME)),
|
|
159
|
+
runtimeDir: makeAbsolutePath(path, path.join(workspaceRoot, RUNTIME_DIRECTORY)),
|
|
160
|
+
acquiredRoot: makeAbsolutePath(path, path.join(workspaceRoot, ACQUIRED_EXTENSIONS_DIR)),
|
|
161
|
+
...(settings.owner === undefined ? {} : { owner: settings.owner }),
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
//# sourceMappingURL=layout.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reconstruct extension refs from lockfile entries.
|
|
3
|
+
*
|
|
4
|
+
* @experimental This API is unstable and may change without notice.
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
import * as Effect from "effect/Effect";
|
|
8
|
+
import * as Option from "effect/Option";
|
|
9
|
+
import type * as Path from "effect/Path";
|
|
10
|
+
import { LockEntryEndpointConflict, LockEntryNameInvalid, LockEntrySourceMissing, LockEntrySourceTypeConflict, LockEntryUrlInvalid } from "./errors.js";
|
|
11
|
+
import type { SettingsReadError, WorkspaceRootEscape } from "./read-model/errors.js";
|
|
12
|
+
import type { KnowledgeLockEntry, HookLockEntry, PackLockEntry, McpServerLockEntry, RuleLockEntry, SkillLockEntry, SubagentLockEntry } from "../lockfile/index.js";
|
|
13
|
+
import type { SourceHostConfig } from "../settings/index.js";
|
|
14
|
+
import type { PackRef } from "@agentxm/extension-model/unstable/extensions/refs/pack";
|
|
15
|
+
import type { McpServerExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/mcp-server";
|
|
16
|
+
import type { SkillExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/skill";
|
|
17
|
+
import type { SubagentExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/subagent";
|
|
18
|
+
import type { KnowledgeExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/knowledge";
|
|
19
|
+
import type { RuleExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/rule";
|
|
20
|
+
import type { HookExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/hook";
|
|
21
|
+
import type { WorkspaceScope } from "@agentxm/extension-model/unstable/workspace-scope";
|
|
22
|
+
/** Failure of the caller-supplied configured-source lookup. */
|
|
23
|
+
export type LockEntrySourceLookupError = SettingsReadError | WorkspaceRootEscape;
|
|
24
|
+
/** Every failure a lock-entry-to-ref translation can produce. */
|
|
25
|
+
export type LockEntryToRefError = LockEntrySourceMissing | LockEntryUrlInvalid | LockEntryNameInvalid | LockEntryEndpointConflict | LockEntrySourceTypeConflict | LockEntrySourceLookupError;
|
|
26
|
+
interface LockEntryToRefDeps {
|
|
27
|
+
readonly baseDir: string;
|
|
28
|
+
readonly path: Path.Path;
|
|
29
|
+
readonly scope: WorkspaceScope;
|
|
30
|
+
readonly getConfiguredSourceByName: (name: string) => Effect.Effect<Option.Option<SourceHostConfig>, LockEntrySourceLookupError>;
|
|
31
|
+
}
|
|
32
|
+
export declare const skillLockEntryToRef: (name: string, entry: SkillLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<SkillExtensionRef, LockEntryToRefError>;
|
|
33
|
+
export declare const mcpServerLockEntryToRef: (name: string, entry: McpServerLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<McpServerExtensionRef, LockEntryToRefError>;
|
|
34
|
+
export declare const subagentLockEntryToRef: (name: string, entry: SubagentLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<SubagentExtensionRef, LockEntryToRefError>;
|
|
35
|
+
export declare const ruleLockEntryToRef: (name: string, entry: RuleLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<RuleExtensionRef, LockEntryToRefError>;
|
|
36
|
+
export declare const hookLockEntryToRef: (name: string, entry: HookLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<HookExtensionRef, LockEntryToRefError>;
|
|
37
|
+
export declare const knowledgeLockEntryToRef: (name: string, entry: KnowledgeLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<KnowledgeExtensionRef, LockEntryToRefError>;
|
|
38
|
+
export declare const packLockEntryToRef: (name: string, entry: PackLockEntry, deps: LockEntryToRefDeps) => Effect.Effect<PackRef, LockEntryToRefError>;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=lock-entry-to-ref.d.ts.map
|