@agentxm/extension-materialization 0.28.14-preview.1789139351.5cd4595aa

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 (89) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +16 -0
  3. package/dist/src/desired-state/errors.d.ts +22 -0
  4. package/dist/src/desired-state/errors.js +22 -0
  5. package/dist/src/desired-state/retained-materialization.d.ts +58 -0
  6. package/dist/src/desired-state/retained-materialization.js +119 -0
  7. package/dist/src/errors.d.ts +42 -0
  8. package/dist/src/errors.js +14 -0
  9. package/dist/src/extensions/canonical-directory.d.ts +106 -0
  10. package/dist/src/extensions/canonical-directory.js +210 -0
  11. package/dist/src/extensions/canonical-reuse.d.ts +43 -0
  12. package/dist/src/extensions/canonical-reuse.js +38 -0
  13. package/dist/src/extensions/copy-directory.d.ts +50 -0
  14. package/dist/src/extensions/copy-directory.js +78 -0
  15. package/dist/src/extensions/errors.d.ts +97 -0
  16. package/dist/src/extensions/errors.js +42 -0
  17. package/dist/src/extensions/materializable-from-disk.d.ts +37 -0
  18. package/dist/src/extensions/materializable-from-disk.js +89 -0
  19. package/dist/src/extensions/operations.d.ts +252 -0
  20. package/dist/src/extensions/operations.js +631 -0
  21. package/dist/src/hooks/errors.d.ts +33 -0
  22. package/dist/src/hooks/errors.js +18 -0
  23. package/dist/src/hooks/manager.d.ts +13 -0
  24. package/dist/src/hooks/manager.js +778 -0
  25. package/dist/src/index.d.ts +44 -0
  26. package/dist/src/index.js +56 -0
  27. package/dist/src/knowledge/errors.d.ts +75 -0
  28. package/dist/src/knowledge/errors.js +36 -0
  29. package/dist/src/knowledge/manager.d.ts +9 -0
  30. package/dist/src/knowledge/manager.js +709 -0
  31. package/dist/src/live.d.ts +20 -0
  32. package/dist/src/live.js +20 -0
  33. package/dist/src/manager-contract.d.ts +136 -0
  34. package/dist/src/manager-contract.js +19 -0
  35. package/dist/src/manager-registry-live.d.ts +11 -0
  36. package/dist/src/manager-registry-live.js +23 -0
  37. package/dist/src/manager-registry.d.ts +37 -0
  38. package/dist/src/manager-registry.js +22 -0
  39. package/dist/src/managers.d.ts +147 -0
  40. package/dist/src/managers.js +32 -0
  41. package/dist/src/mcps/artifact.d.ts +24 -0
  42. package/dist/src/mcps/artifact.js +74 -0
  43. package/dist/src/mcps/authored-materialization.d.ts +28 -0
  44. package/dist/src/mcps/authored-materialization.js +34 -0
  45. package/dist/src/mcps/errors.d.ts +105 -0
  46. package/dist/src/mcps/errors.js +40 -0
  47. package/dist/src/mcps/install-operation.d.ts +92 -0
  48. package/dist/src/mcps/install-operation.js +557 -0
  49. package/dist/src/mcps/manager.d.ts +15 -0
  50. package/dist/src/mcps/manager.js +253 -0
  51. package/dist/src/mcps/native-entry.d.ts +51 -0
  52. package/dist/src/mcps/native-entry.js +100 -0
  53. package/dist/src/mcps/secret-store-live.d.ts +14 -0
  54. package/dist/src/mcps/secret-store-live.js +58 -0
  55. package/dist/src/mcps/secret-store.d.ts +55 -0
  56. package/dist/src/mcps/secret-store.js +33 -0
  57. package/dist/src/packs/errors.d.ts +50 -0
  58. package/dist/src/packs/errors.js +24 -0
  59. package/dist/src/packs/manager.d.ts +16 -0
  60. package/dist/src/packs/manager.js +189 -0
  61. package/dist/src/projection-participants-live.d.ts +17 -0
  62. package/dist/src/projection-participants-live.js +66 -0
  63. package/dist/src/projection-step-failure.d.ts +19 -0
  64. package/dist/src/projection-step-failure.js +76 -0
  65. package/dist/src/registry-materialization.d.ts +52 -0
  66. package/dist/src/registry-materialization.js +67 -0
  67. package/dist/src/rules/errors.d.ts +31 -0
  68. package/dist/src/rules/errors.js +17 -0
  69. package/dist/src/rules/manager.d.ts +18 -0
  70. package/dist/src/rules/manager.js +492 -0
  71. package/dist/src/skills/errors.d.ts +42 -0
  72. package/dist/src/skills/errors.js +21 -0
  73. package/dist/src/skills/manager.d.ts +17 -0
  74. package/dist/src/skills/manager.js +339 -0
  75. package/dist/src/skills/materialization.d.ts +52 -0
  76. package/dist/src/skills/materialization.js +168 -0
  77. package/dist/src/skills/skill-artifact.d.ts +38 -0
  78. package/dist/src/skills/skill-artifact.js +70 -0
  79. package/dist/src/skills/source-hash.d.ts +2 -0
  80. package/dist/src/skills/source-hash.js +6 -0
  81. package/dist/src/subagents/errors.d.ts +43 -0
  82. package/dist/src/subagents/errors.js +20 -0
  83. package/dist/src/subagents/lock-entry-builder.d.ts +20 -0
  84. package/dist/src/subagents/lock-entry-builder.js +63 -0
  85. package/dist/src/subagents/manager.d.ts +17 -0
  86. package/dist/src/subagents/manager.js +736 -0
  87. package/dist/src/testing.d.ts +87 -0
  88. package/dist/src/testing.js +116 -0
  89. package/package.json +70 -0
package/LICENSE ADDED
@@ -0,0 +1,110 @@
1
+ # Functional Source License, Version 1.1, MIT Future License
2
+
3
+ ## Abbreviation
4
+
5
+ FSL-1.1-MIT
6
+
7
+ ## Notice
8
+
9
+ Copyright 2025-2026 AgentXM, Inc.
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the MIT license that is effective on the second anniversary of the date we make
91
+ the Software available. On or after that date, you may use the Software under
92
+ the MIT license, in which case the following will apply:
93
+
94
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
95
+ this software and associated documentation files (the "Software"), to deal in
96
+ the Software without restriction, including without limitation the rights to
97
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98
+ of the Software, and to permit persons to whom the Software is furnished to do
99
+ so, subject to the following conditions:
100
+
101
+ The above copyright notice and this permission notice shall be included in all
102
+ copies or substantial portions of the Software.
103
+
104
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
105
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
106
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
107
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
108
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
109
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
110
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @agentxm/extension-materialization
2
+
3
+ The AXM extension materialization capability: the per-extension-type manager
4
+ contract and its seven implementations, canonical package staging with
5
+ interrupted-swap recovery, registry-backed package materialization, and the
6
+ install, uninstall, materialize, and authored-package closure recipes that
7
+ compose them into plan steps.
8
+
9
+ Managers keep their requirements explicit in `R`; a manager's materialization
10
+ facts travel forward as return values rather than through captured state.
11
+ `./live` composes the environment-backed manager layers and registers them as
12
+ `workspace-projection` participants; `./testing` carries in-memory managers for
13
+ feature tests. The surface is unsupported and may change in any release.
14
+ Ordinary users should use the [`axm` CLI](https://axm.sh) instead.
15
+
16
+ Part of the [AgentXM](https://agentxm.ai) toolchain.
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Failures deciding a retained re-materialization.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ declare const RetainedContentUnusable_base: Schema.Class<RetainedContentUnusable, Schema.TaggedStruct<"RetainedContentUnusable", {
8
+ readonly extensionType: Schema.String;
9
+ readonly name: Schema.String;
10
+ /** The canonical observation status that made restoration impossible. */
11
+ readonly status: Schema.String;
12
+ }>, import("effect/Cause").YieldableError>;
13
+ /**
14
+ * A retained transition asked to restore content the workspace accepted, and
15
+ * that content is not usable. The transition refuses rather than re-resolving
16
+ * the source, because re-acquiring is a different decision than restoring.
17
+ */
18
+ export declare class RetainedContentUnusable extends RetainedContentUnusable_base {
19
+ get detail(): string;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Failures deciding a retained re-materialization.
3
+ *
4
+ * @experimental This API is unstable and may change without notice.
5
+ */
6
+ import * as Schema from "effect/Schema";
7
+ /**
8
+ * A retained transition asked to restore content the workspace accepted, and
9
+ * that content is not usable. The transition refuses rather than re-resolving
10
+ * the source, because re-acquiring is a different decision than restoring.
11
+ */
12
+ export class RetainedContentUnusable extends Schema.TaggedError()("RetainedContentUnusable", {
13
+ extensionType: Schema.String,
14
+ name: Schema.String,
15
+ /** The canonical observation status that made restoration impossible. */
16
+ status: Schema.String,
17
+ }) {
18
+ get detail() {
19
+ return `Cannot rematerialize retained ${this.extensionType} ${this.name}: canonical content is ${this.status}`;
20
+ }
21
+ }
22
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Re-materializing what desired state already accepted.
3
+ *
4
+ * A retained transition — re-enabling a Pack whose members were left on disk
5
+ * — must never re-resolve a source. The accepted resolution and the canonical
6
+ * content it names are the only inputs: if that content is not usable the
7
+ * transition refuses rather than silently reaching for the network, because
8
+ * "enable what you already have" and "acquire something new" are different
9
+ * decisions with different risk.
10
+ *
11
+ * This lives in the materialization capability, not in a feature, because
12
+ * both the workspace sync sweep and Pack activation re-materialize accepted
13
+ * content, and a feature may not import a peer feature.
14
+ *
15
+ * @experimental This API is unstable and may change without notice.
16
+ */
17
+ import * as Effect from "effect/Effect";
18
+ import * as FileSystem from "effect/FileSystem";
19
+ import * as Path from "effect/Path";
20
+ import type { ExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/extension-ref";
21
+ import type { McpServerExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/mcp-server";
22
+ import { CodingAgentRepository, type ProjectionParticipantRequirements } from "@agentxm/workspace-projection";
23
+ import { WorkspaceMutations, type DesiredExtensionNode } from "@agentxm/workspace-state";
24
+ import type { JobStepResult, PlannedJobStep, StepFailure } from "@agentxm/workspace-operations";
25
+ import { RetainedContentUnusable } from "./errors.js";
26
+ import type { ExtensionManagerFailure } from "../errors.js";
27
+ import { ExtensionManagers } from "../manager-registry.js";
28
+ import type { ManagerRequirements } from "../manager-contract.js";
29
+ import { type RecipeRequirements, type StepFailureAdapter } from "../extensions/operations.js";
30
+ import { SubagentManager } from "../managers.js";
31
+ /** Services a retained materialize step needs when it runs. */
32
+ export type RetainedMaterializeRequirements = CodingAgentRepository | ExtensionManagers | ManagerRequirements | RecipeRequirements | SubagentManager | WorkspaceMutations;
33
+ /**
34
+ * How an MCP server member is re-projected. MCP servers are realized into
35
+ * each agent's native configuration rather than into a canonical tree, so the
36
+ * caller hands in the install operation it already owns.
37
+ */
38
+ export type RunRetainedMcpServerInstall<R> = (args: {
39
+ readonly ref: McpServerExtensionRef;
40
+ }) => Effect.Effect<JobStepResult, StepFailure, R>;
41
+ export interface RetainedMaterializeSteps<R> {
42
+ /** Every accepted ref the selection covers, whether or not it needs work. */
43
+ readonly refs: ReadonlyArray<ExtensionRef>;
44
+ readonly steps: ReadonlyArray<PlannedJobStep<R | RetainedMaterializeRequirements>>;
45
+ }
46
+ /** Every failure deciding retained re-materialization can surface. */
47
+ export type RetainedMaterializeFailure = RetainedContentUnusable | ExtensionManagerFailure;
48
+ /**
49
+ * Build the steps that bring the given desired nodes back to their accepted
50
+ * materialization. Nodes whose projections are already current contribute no
51
+ * step, so a retained transition that changes nothing plans nothing.
52
+ */
53
+ export declare const collectRetainedMaterializeSteps: <R = never>(args: {
54
+ readonly nodes: ReadonlyArray<DesiredExtensionNode>;
55
+ readonly runMcpServerInstall: RunRetainedMcpServerInstall<R>;
56
+ readonly adapter: StepFailureAdapter;
57
+ }) => Effect.Effect<RetainedMaterializeSteps<R>, RetainedMaterializeFailure, CodingAgentRepository | ExtensionManagers | FileSystem.FileSystem | Path.Path | ProjectionParticipantRequirements | SubagentManager | WorkspaceMutations>;
58
+ //# sourceMappingURL=retained-materialization.d.ts.map
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Re-materializing what desired state already accepted.
3
+ *
4
+ * A retained transition — re-enabling a Pack whose members were left on disk
5
+ * — must never re-resolve a source. The accepted resolution and the canonical
6
+ * content it names are the only inputs: if that content is not usable the
7
+ * transition refuses rather than silently reaching for the network, because
8
+ * "enable what you already have" and "acquire something new" are different
9
+ * decisions with different risk.
10
+ *
11
+ * This lives in the materialization capability, not in a feature, because
12
+ * both the workspace sync sweep and Pack activation re-materialize accepted
13
+ * content, and a feature may not import a peer feature.
14
+ *
15
+ * @experimental This API is unstable and may change without notice.
16
+ */
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 { CodingAgentRepository, isObservedMaterializationCurrent, } from "@agentxm/workspace-projection";
22
+ import { acceptedCanonicalObservation, acceptedResolutionRef, isSourcedDesiredExtension, usableAcceptedCanonical, WorkspaceMutations, } from "@agentxm/workspace-state";
23
+ import { RetainedContentUnusable } from "./errors.js";
24
+ import { ExtensionManagers } from "../manager-registry.js";
25
+ import { buildMaterializeOperation, targetFromRef, toStepKey, } from "../extensions/operations.js";
26
+ import { SubagentManager } from "../managers.js";
27
+ /**
28
+ * Build the steps that bring the given desired nodes back to their accepted
29
+ * materialization. Nodes whose projections are already current contribute no
30
+ * step, so a retained transition that changes nothing plans nothing.
31
+ */
32
+ export const collectRetainedMaterializeSteps = (args) => Effect.gen(function* () {
33
+ const ws = yield* WorkspaceMutations;
34
+ const fs = yield* FileSystem.FileSystem;
35
+ const path = yield* Path.Path;
36
+ const agentRepo = yield* CodingAgentRepository;
37
+ const managers = yield* ExtensionManagers;
38
+ const subagentManager = yield* SubagentManager;
39
+ const configuredAgentIds = yield* ws.getConfiguredAgents();
40
+ const selected = args.nodes
41
+ .filter(isSourcedDesiredExtension)
42
+ .filter((node) => node.enabled && node.type !== "pack");
43
+ const reconciled = yield* Effect.forEach(selected, (node) => Effect.gen(function* () {
44
+ const canonical = yield* acceptedCanonicalObservation({
45
+ workspace: ws,
46
+ type: node.type,
47
+ name: node.name,
48
+ });
49
+ const status = Option.isSome(canonical)
50
+ ? canonical.value.observation.status
51
+ : "missing-resolution";
52
+ const usable = status === "usable"
53
+ ? yield* usableAcceptedCanonical({
54
+ workspace: ws,
55
+ type: node.type,
56
+ name: node.name,
57
+ })
58
+ : Option.none();
59
+ const ref = Option.isSome(usable)
60
+ ? Option.some(usable.value.ref)
61
+ : yield* acceptedResolutionRef({
62
+ workspace: ws,
63
+ type: node.type,
64
+ name: node.name,
65
+ });
66
+ if (Option.isNone(ref)) {
67
+ return yield* new RetainedContentUnusable({
68
+ extensionType: node.type,
69
+ name: node.name,
70
+ status,
71
+ });
72
+ }
73
+ const current = yield* isObservedMaterializationCurrent({
74
+ workspace: ws,
75
+ node,
76
+ configuredAgentIds,
77
+ agents: agentRepo,
78
+ subagents: subagentManager,
79
+ resolvedRef: ref.value,
80
+ fs,
81
+ path,
82
+ });
83
+ return { node, ref: ref.value, materialize: status !== "usable" || !current };
84
+ }), { concurrency: "unbounded" });
85
+ const steps = reconciled
86
+ .filter(({ materialize }) => materialize)
87
+ .map(({ node, ref }) => {
88
+ if (ref.type === "mcp-server") {
89
+ const target = targetFromRef(ref);
90
+ return {
91
+ key: toStepKey(target),
92
+ label: `${node.type} ${node.name}`,
93
+ readiness: "ready",
94
+ run: args.runMcpServerInstall({ ref }),
95
+ };
96
+ }
97
+ const common = {
98
+ toStepFailure: args.adapter.toStepFailure,
99
+ label: `${node.type} ${node.name}`,
100
+ message: `Restored ${node.type} ${node.name}`,
101
+ };
102
+ switch (ref.type) {
103
+ case "skill":
104
+ return buildMaterializeOperation(managers.skill, { ...common, ref });
105
+ case "subagent":
106
+ return buildMaterializeOperation(managers.subagent, { ...common, ref });
107
+ case "rule":
108
+ return buildMaterializeOperation(managers.rule, { ...common, ref });
109
+ case "hook":
110
+ return buildMaterializeOperation(managers.hook, { ...common, ref });
111
+ case "knowledge":
112
+ return buildMaterializeOperation(managers.knowledge, { ...common, ref });
113
+ case "pack":
114
+ return buildMaterializeOperation(managers.pack, { ...common, ref });
115
+ }
116
+ });
117
+ return { refs: reconciled.map(({ ref }) => ref), steps };
118
+ });
119
+ //# sourceMappingURL=retained-materialization.js.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Failure vocabulary for extension materialization: the union of the per-type
3
+ * manager families, the canonical-materialization family, and the failures the
4
+ * managers surface from the capabilities underneath them — workspace state,
5
+ * transactions, projection, source resolution, and the registry client.
6
+ *
7
+ * Every member is typed. Nothing travels opaquely: a manager that calls a
8
+ * source host or the registry client keeps that integration's own failure in
9
+ * its channel, and the application boundary converts it once.
10
+ *
11
+ * @experimental This API is unstable and may change without notice.
12
+ */
13
+ import type { FqnInvalidError } from "@agentxm/extension-model/unstable/extensions/fqn";
14
+ import type { FrontmatterParseFailure, SubagentContentError } from "@agentxm/extension-content";
15
+ import type { MaterializationError } from "./extensions/errors.js";
16
+ import type { SourceAuthorityBlocked } from "@agentxm/extension-resolution";
17
+ import type { SourceResolutionFailure } from "@agentxm/extension-sources";
18
+ import type { RegistryClientFailure } from "@agentxm/registry-client";
19
+ import type { InstructionMaintenanceFailed, ProjectionError } from "@agentxm/workspace-projection";
20
+ import type { MaterializedTreeInvalid } from "@agentxm/workspace-state";
21
+ import type { WorkspaceTransactionFailure, WorkspaceRestorationIncomplete } from "@agentxm/workspace-transactions";
22
+ import type { WorkspaceStateMutationFailure, WorkspaceStateReadFailure } from "@agentxm/workspace-state";
23
+ import type { CodingAgentFailure } from "@agentxm/agent-integration";
24
+ import type { RuleManagerError } from "./rules/errors.js";
25
+ import type { HookManagerError } from "./hooks/errors.js";
26
+ import type { SubagentManagerError } from "./subagents/errors.js";
27
+ import type { McpManagerError } from "./mcps/errors.js";
28
+ import type { SkillManagerError } from "./skills/errors.js";
29
+ import type { PackManagerError } from "./packs/errors.js";
30
+ import type { KnowledgeManagerError } from "./knowledge/errors.js";
31
+ import type { AcceptedResolutionMissing, CanonicalPathRemovalError, DesiredPackGraphIncomplete, InlineExtensionSourceMissing, InvalidAgentId, LockedSkillMissing, LockEntryEndpointConflict, LockEntryNameInvalid, LockEntrySourceMissing, LockEntrySourceTypeConflict, LockEntryUrlInvalid, PackageContentHashFailed, SettingsEntryMissing, SupersededCanonicalRemovalFailed, SymlinkCreationError, WorkspaceLayoutError, WorkspaceNotInitialized, WorkspaceSourceInvalid } from "@agentxm/workspace-state";
32
+ import type { SkillDiscoveryRootInvalid, SubagentScanFailed } from "@agentxm/workspace-state";
33
+ import type { LockfileResolvedVersionInvalid } from "@agentxm/workspace-state";
34
+ /** Every typed failure the materialization modules construct themselves. */
35
+ export type ExtensionMaterializationError = MaterializationError | SourceAuthorityBlocked | ProjectionError | InstructionMaintenanceFailed | RuleManagerError | HookManagerError | SubagentManagerError | McpManagerError | SkillManagerError | PackManagerError | KnowledgeManagerError | MaterializedTreeInvalid;
36
+ /**
37
+ * Every failure an extension-type manager method may surface: the
38
+ * materialization families, the capability families underneath them, and the
39
+ * integration families their acquisition steps carry through.
40
+ */
41
+ export type ExtensionManagerFailure = CodingAgentFailure | ExtensionMaterializationError | SourceResolutionFailure | RegistryClientFailure | WorkspaceStateReadFailure | WorkspaceStateMutationFailure | WorkspaceTransactionFailure | WorkspaceRestorationIncomplete | WorkspaceLayoutError | WorkspaceNotInitialized | LockedSkillMissing | SettingsEntryMissing | InvalidAgentId | DesiredPackGraphIncomplete | CanonicalPathRemovalError | SymlinkCreationError | LockEntrySourceMissing | LockEntryUrlInvalid | LockEntryNameInvalid | LockEntryEndpointConflict | LockEntrySourceTypeConflict | AcceptedResolutionMissing | InlineExtensionSourceMissing | SupersededCanonicalRemovalFailed | PackageContentHashFailed | WorkspaceSourceInvalid | SkillDiscoveryRootInvalid | SubagentScanFailed | LockfileResolvedVersionInvalid | FqnInvalidError | FrontmatterParseFailure | SubagentContentError;
42
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Failure vocabulary for extension materialization: the union of the per-type
3
+ * manager families, the canonical-materialization family, and the failures the
4
+ * managers surface from the capabilities underneath them — workspace state,
5
+ * transactions, projection, source resolution, and the registry client.
6
+ *
7
+ * Every member is typed. Nothing travels opaquely: a manager that calls a
8
+ * source host or the registry client keeps that integration's own failure in
9
+ * its channel, and the application boundary converts it once.
10
+ *
11
+ * @experimental This API is unstable and may change without notice.
12
+ */
13
+ export {};
14
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Canonical package directory machinery: sibling staging/swap replacement,
3
+ * interrupted-swap recovery, create-only publication, reuse decisions, and
4
+ * external (non-registry) package materialization.
5
+ *
6
+ * @experimental This API is unstable and may change without notice.
7
+ */
8
+ import * as Effect from "effect/Effect";
9
+ import * as FileSystem from "effect/FileSystem";
10
+ import * as Path from "effect/Path";
11
+ import { type WorkspaceSnapshotError } from "@agentxm/workspace-transactions";
12
+ import { CanonicalPackageProbeFailed, CreateDestinationExists, PackageCopyFailed, PackageMaterializationFailed, StagedPackageInvalid } from "./errors.js";
13
+ import { PathTraversalDetected } from "@agentxm/workspace-state";
14
+ import { type MaterializedTreeInvalid, type TreeIntegrity } from "@agentxm/workspace-state";
15
+ export declare const canonicalMaterializationPaths: (canonicalPath: string) => {
16
+ stagingPath: string;
17
+ backupPath: string;
18
+ };
19
+ /** Failures the sibling staging/swap machinery itself can produce. */
20
+ export type CanonicalDirectoryReplacementError = PackageMaterializationFailed | PathTraversalDetected | WorkspaceSnapshotError;
21
+ export interface RecoverCanonicalDirectoryArgs {
22
+ readonly baseDir: string;
23
+ readonly canonicalPath: string;
24
+ }
25
+ /** Recover or clean sibling replacement state before any fallible source work. */
26
+ export declare const recoverCanonicalDirectory: (args: RecoverCanonicalDirectoryArgs) => Effect.Effect<void, PackageMaterializationFailed | PathTraversalDetected, FileSystem.FileSystem | Path.Path>;
27
+ export interface ReplaceCanonicalDirectoryArgs<E, R> {
28
+ readonly baseDir: string;
29
+ readonly canonicalPath: string;
30
+ readonly populate: (stagingPath: string) => Effect.Effect<void, E, R>;
31
+ readonly validate?: (stagingPath: string) => Effect.Effect<void, E, R>;
32
+ }
33
+ export interface ReplaceCanonicalDirectoryWithInspectionArgs<A, E, R> extends ReplaceCanonicalDirectoryArgs<E, R> {
34
+ readonly inspect: (stagingPath: string) => Effect.Effect<A, E, R>;
35
+ }
36
+ export interface CanonicalDirectoryInspection<A> {
37
+ readonly canonicalPath: string;
38
+ readonly inspection: A;
39
+ }
40
+ export interface CreateCanonicalDirectoryArgs<E, R> extends ReplaceCanonicalDirectoryArgs<E, R> {
41
+ /** Human-readable create-only subject used in collision diagnostics. */
42
+ readonly subject: string;
43
+ /** Type-defined files that must exist in the complete staged package. */
44
+ readonly requiredFiles?: ReadonlyArray<string>;
45
+ }
46
+ /**
47
+ * Publish a complete canonical tree from a sibling staging directory. Recovery
48
+ * restores a prior tree left in the sibling backup by abrupt process death;
49
+ * incomplete staging is never made eligible for reuse.
50
+ */
51
+ export declare const replaceCanonicalDirectoryWithInspection: <A, E, R>(args: ReplaceCanonicalDirectoryWithInspectionArgs<A, E, R>) => Effect.Effect<CanonicalDirectoryInspection<A>, E | CanonicalDirectoryReplacementError, FileSystem.FileSystem | Path.Path | R>;
52
+ export declare const replaceCanonicalDirectory: <E, R>(args: ReplaceCanonicalDirectoryArgs<E, R>) => Effect.Effect<string, E | CanonicalDirectoryReplacementError, FileSystem.FileSystem | Path.Path | R>;
53
+ /**
54
+ * Publish one create-only authored package without ever populating its
55
+ * canonical directory in place. Interrupted sibling state is resolved before
56
+ * the collision check while the caller holds the workspace mutation lock.
57
+ */
58
+ export declare const createCanonicalDirectory: <E, R>(args: CreateCanonicalDirectoryArgs<E, R>) => Effect.Effect<string, E | CanonicalDirectoryReplacementError | CreateDestinationExists | StagedPackageInvalid, FileSystem.FileSystem | Path.Path | R>;
59
+ export interface CanReuseInstalledPackageArgs {
60
+ /**
61
+ * Canonical installed tree for this extension. Always the workspace location
62
+ * the extension is installed to — never a staging destination, whose absence
63
+ * would make every install look like a first install.
64
+ */
65
+ readonly installedPath: string;
66
+ /** Caller demanded an unconditional re-materialization. */
67
+ readonly force: boolean;
68
+ /** Exact version requested by the ref being installed. */
69
+ readonly refVersion: string;
70
+ /** The ref carries a pinned archive integrity (registry-resolved). */
71
+ readonly hasIntegrity: boolean;
72
+ /** Resolved version recorded in the current lockfile entry, when any. */
73
+ readonly lockedVersion?: string;
74
+ readonly existsFailureDetail: (installedPath: string) => string;
75
+ }
76
+ export interface CanReuseExternalPackageArgs {
77
+ readonly installedPath: string;
78
+ readonly force: boolean;
79
+ readonly existsFailureDetail: (installedPath: string) => string;
80
+ }
81
+ /** Preserve an existing external canonical tree unless refresh was explicitly requested. */
82
+ export declare const canReuseExternalPackage: (args: CanReuseExternalPackageArgs) => Effect.Effect<boolean, PackageMaterializationFailed | CanonicalPackageProbeFailed, FileSystem.FileSystem>;
83
+ /**
84
+ * Decide whether the installed tree already satisfies the requested ref, so no
85
+ * archive needs to be fetched or written.
86
+ *
87
+ * Callers that stage into a temporary directory must call this against the
88
+ * canonical installed path before staging: the decision is about the installed
89
+ * tree, while the registry materialization only answers where bytes go.
90
+ */
91
+ export declare const canReuseInstalledPackage: (args: CanReuseInstalledPackageArgs) => Effect.Effect<boolean, PackageMaterializationFailed | CanonicalPackageProbeFailed, FileSystem.FileSystem>;
92
+ export interface MaterializedPackage {
93
+ readonly canonicalPath: string;
94
+ readonly treeIntegrity: TreeIntegrity;
95
+ }
96
+ export interface MaterializeExternalPackageArgs<E = never> {
97
+ readonly baseDir: string;
98
+ readonly canonicalPath: string;
99
+ readonly sourceLocation: string;
100
+ readonly copyFailureCode: "internal" | "validation";
101
+ readonly copyFailureDetail: (canonicalPath: string) => string;
102
+ readonly validate?: (stagingPath: string) => Effect.Effect<void, E, FileSystem.FileSystem | Path.Path>;
103
+ }
104
+ export declare const materializeExternalPackageWithTreeIntegrity: <E = never>(args: MaterializeExternalPackageArgs<E>) => Effect.Effect<MaterializedPackage, E | PackageCopyFailed | CanonicalDirectoryReplacementError | MaterializedTreeInvalid, FileSystem.FileSystem | Path.Path>;
105
+ export declare const materializeExternalPackage: <E = never>(args: MaterializeExternalPackageArgs<E>) => Effect.Effect<string, PackageCopyFailed | MaterializedTreeInvalid | CanonicalDirectoryReplacementError | E, FileSystem.FileSystem | Path.Path>;
106
+ //# sourceMappingURL=canonical-directory.d.ts.map