@agentxm/extension-lifecycle 0.28.12 → 0.28.13

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 (207) hide show
  1. package/dist/src/activation/display-paths.d.ts +25 -0
  2. package/dist/src/activation/display-paths.js +25 -0
  3. package/dist/src/activation/errors.d.ts +16 -0
  4. package/dist/src/activation/errors.js +7 -0
  5. package/dist/src/activation/set-activation.d.ts +134 -0
  6. package/dist/src/activation/set-activation.js +772 -0
  7. package/dist/src/demote/demote-to-external-source.d.ts +82 -0
  8. package/dist/src/demote/demote-to-external-source.js +233 -0
  9. package/dist/src/errors.d.ts +0 -8
  10. package/dist/src/errors.js +0 -8
  11. package/dist/src/glob.d.ts +35 -0
  12. package/dist/src/glob.js +75 -0
  13. package/dist/src/hooks/configured-agent-outcomes-provider.d.ts +7 -3
  14. package/dist/src/hooks/configured-agent-outcomes-provider.js +11 -4
  15. package/dist/src/hooks/install/plan.d.ts +45 -0
  16. package/dist/src/hooks/install/plan.js +224 -0
  17. package/dist/src/hooks/uninstall/plan.d.ts +20 -0
  18. package/dist/src/hooks/uninstall/plan.js +77 -0
  19. package/dist/src/index.d.ts +48 -16
  20. package/dist/src/index.js +60 -17
  21. package/dist/src/install/aggregate-projection-step.d.ts +16 -0
  22. package/dist/src/install/aggregate-projection-step.js +49 -0
  23. package/dist/src/install/configured.d.ts +65 -0
  24. package/dist/src/install/configured.js +406 -0
  25. package/dist/src/install/inline-mcp-operation.d.ts +4 -0
  26. package/dist/src/install/inline-mcp-operation.js +25 -0
  27. package/dist/src/install/install-extensions.d.ts +110 -0
  28. package/dist/src/install/install-extensions.js +282 -0
  29. package/dist/src/install/per-type-install.d.ts +12 -0
  30. package/dist/src/install/per-type-install.js +12 -0
  31. package/dist/src/install/registry-install-target.d.ts +35 -0
  32. package/dist/src/install/registry-install-target.js +66 -0
  33. package/dist/src/install/registry-login-suggestion.d.ts +21 -0
  34. package/dist/src/install/registry-login-suggestion.js +34 -0
  35. package/dist/src/install/registry-source-resolution.d.ts +54 -0
  36. package/dist/src/install/registry-source-resolution.js +216 -0
  37. package/dist/src/install/root-intent.d.ts +19 -0
  38. package/dist/src/install/root-intent.js +122 -0
  39. package/dist/src/install/selection-interaction.d.ts +46 -0
  40. package/dist/src/install/selection-interaction.js +22 -0
  41. package/dist/src/install/vocabulary.d.ts +143 -0
  42. package/dist/src/install/vocabulary.js +29 -0
  43. package/dist/src/knowledge/install/plan.d.ts +35 -0
  44. package/dist/src/knowledge/install/plan.js +128 -0
  45. package/dist/src/knowledge/uninstall/plan.d.ts +23 -0
  46. package/dist/src/knowledge/uninstall/plan.js +140 -0
  47. package/dist/src/live.d.ts +4 -11
  48. package/dist/src/live.js +4 -11
  49. package/dist/src/mcps/install/plan.d.ts +65 -0
  50. package/dist/src/mcps/install/plan.js +301 -0
  51. package/dist/src/mcps/operations/disable.d.ts +5 -3
  52. package/dist/src/mcps/operations/disable.js +6 -4
  53. package/dist/src/mcps/operations/enable.d.ts +5 -3
  54. package/dist/src/mcps/operations/enable.js +8 -6
  55. package/dist/src/mcps/operations/sync-outcome.d.ts +1 -1
  56. package/dist/src/mcps/operations/uninstall.d.ts +5 -3
  57. package/dist/src/mcps/operations/uninstall.js +4 -4
  58. package/dist/src/mcps/uninstall/plan.d.ts +24 -0
  59. package/dist/src/mcps/uninstall/plan.js +109 -0
  60. package/dist/src/packs/artifact.d.ts +21 -0
  61. package/dist/src/packs/artifact.js +32 -0
  62. package/dist/src/packs/constraint-gate.d.ts +30 -0
  63. package/dist/src/packs/constraint-gate.js +76 -0
  64. package/dist/src/packs/expansion.d.ts +13 -14
  65. package/dist/src/packs/expansion.js +1 -2
  66. package/dist/src/packs/graph-transition.d.ts +64 -0
  67. package/dist/src/packs/graph-transition.js +219 -0
  68. package/dist/src/packs/install/plan.d.ts +95 -0
  69. package/dist/src/packs/install/plan.js +845 -0
  70. package/dist/src/packs/member-install-step.d.ts +29 -0
  71. package/dist/src/packs/member-install-step.js +156 -0
  72. package/dist/src/packs/operations/install.d.ts +3 -3
  73. package/dist/src/packs/operations/install.js +5 -5
  74. package/dist/src/packs/promote-authored-pack.d.ts +86 -0
  75. package/dist/src/packs/promote-authored-pack.js +239 -0
  76. package/dist/src/packs/resolved-dependency.d.ts +9 -26
  77. package/dist/src/packs/resolved-dependency.js +8 -20
  78. package/dist/src/packs/uninstall/plan.d.ts +66 -0
  79. package/dist/src/packs/uninstall/plan.js +344 -0
  80. package/dist/src/packs/uninstall/readiness.d.ts +50 -0
  81. package/dist/src/packs/uninstall/readiness.js +130 -0
  82. package/dist/src/publisher-binding.d.ts +8 -40
  83. package/dist/src/publisher-binding.js +8 -46
  84. package/dist/src/rules/install/plan.d.ts +35 -0
  85. package/dist/src/rules/install/plan.js +133 -0
  86. package/dist/src/rules/uninstall/plan.d.ts +19 -0
  87. package/dist/src/rules/uninstall/plan.js +54 -0
  88. package/dist/src/skills/install/bundled.d.ts +73 -0
  89. package/dist/src/skills/install/bundled.js +244 -0
  90. package/dist/src/skills/install/plan.d.ts +72 -0
  91. package/dist/src/skills/install/plan.js +429 -0
  92. package/dist/src/skills/install/selection.d.ts +26 -0
  93. package/dist/src/skills/install/selection.js +41 -0
  94. package/dist/src/skills/install/source.d.ts +21 -0
  95. package/dist/src/skills/install/source.js +76 -0
  96. package/dist/src/skills/operations/disable.d.ts +3 -2
  97. package/dist/src/skills/operations/disable.js +7 -11
  98. package/dist/src/skills/operations/enable.d.ts +3 -2
  99. package/dist/src/skills/operations/enable.js +6 -8
  100. package/dist/src/skills/operations/install.d.ts +4 -4
  101. package/dist/src/skills/operations/install.js +13 -12
  102. package/dist/src/skills/uninstall/plan.d.ts +23 -0
  103. package/dist/src/skills/uninstall/plan.js +165 -0
  104. package/dist/src/skills/utils.js +1 -1
  105. package/dist/src/step-failure-conversion.d.ts +44 -0
  106. package/dist/src/step-failure-conversion.js +26 -0
  107. package/dist/src/step-failure.d.ts +29 -0
  108. package/dist/src/step-failure.js +130 -0
  109. package/dist/src/subagents/install/plan.d.ts +49 -0
  110. package/dist/src/subagents/install/plan.js +270 -0
  111. package/dist/src/subagents/install/selection.d.ts +26 -0
  112. package/dist/src/subagents/install/selection.js +37 -0
  113. package/dist/src/subagents/install/source.d.ts +18 -0
  114. package/dist/src/subagents/install/source.js +72 -0
  115. package/dist/src/subagents/operations/disable.d.ts +5 -3
  116. package/dist/src/subagents/operations/disable.js +5 -3
  117. package/dist/src/subagents/operations/enable.d.ts +5 -3
  118. package/dist/src/subagents/operations/enable.js +17 -12
  119. package/dist/src/subagents/uninstall/plan.d.ts +20 -0
  120. package/dist/src/subagents/uninstall/plan.js +142 -0
  121. package/dist/src/test-packages.d.ts +34 -0
  122. package/dist/src/test-packages.js +111 -0
  123. package/dist/src/test-registry.d.ts +78 -0
  124. package/dist/src/test-registry.js +223 -0
  125. package/dist/src/testing.d.ts +108 -0
  126. package/dist/src/testing.js +241 -0
  127. package/dist/src/uninstall/retention-policy.d.ts +21 -0
  128. package/dist/src/uninstall/retention-policy.js +28 -0
  129. package/dist/src/uninstall/root-intent.d.ts +17 -0
  130. package/dist/src/uninstall/root-intent.js +101 -0
  131. package/dist/src/uninstall/uninstall-extensions.d.ts +61 -0
  132. package/dist/src/uninstall/uninstall-extensions.js +127 -0
  133. package/dist/src/uninstall/vocabulary.d.ts +40 -0
  134. package/dist/src/uninstall/vocabulary.js +14 -0
  135. package/dist/src/update/atomicity.d.ts +22 -0
  136. package/dist/src/update/atomicity.js +23 -0
  137. package/dist/src/update/blockers.d.ts +31 -0
  138. package/dist/src/update/blockers.js +78 -0
  139. package/dist/src/update/configured.d.ts +78 -0
  140. package/dist/src/update/configured.js +546 -0
  141. package/dist/src/update/root-request.d.ts +39 -0
  142. package/dist/src/update/root-request.js +117 -0
  143. package/dist/src/update/selective/plan.d.ts +45 -0
  144. package/dist/src/update/selective/plan.js +61 -0
  145. package/dist/src/update/selective/requirements.d.ts +17 -0
  146. package/dist/src/update/selective/requirements.js +14 -0
  147. package/dist/src/update/selective/selection.d.ts +63 -0
  148. package/dist/src/update/selective/selection.js +85 -0
  149. package/dist/src/update/selective/skills.d.ts +55 -0
  150. package/dist/src/update/selective/skills.js +596 -0
  151. package/dist/src/update/selective/subagents.d.ts +52 -0
  152. package/dist/src/update/selective/subagents.js +331 -0
  153. package/dist/src/update/selective/use-case.d.ts +121 -0
  154. package/dist/src/update/selective/use-case.js +28 -0
  155. package/dist/src/update/selective/vocabulary.d.ts +43 -0
  156. package/dist/src/update/selective/vocabulary.js +28 -0
  157. package/dist/src/update/selector.d.ts +72 -0
  158. package/dist/src/update/selector.js +120 -0
  159. package/dist/src/update/targeted-plan.d.ts +30 -0
  160. package/dist/src/update/targeted-plan.js +113 -0
  161. package/dist/src/update/update-extensions.d.ts +164 -0
  162. package/dist/src/update/update-extensions.js +579 -0
  163. package/dist/src/workspace-paths.d.ts +31 -0
  164. package/dist/src/workspace-paths.js +46 -0
  165. package/package.json +22 -12
  166. package/dist/src/configured-entry-resolution.d.ts +0 -111
  167. package/dist/src/configured-entry-resolution.js +0 -731
  168. package/dist/src/failure-adapter.d.ts +0 -35
  169. package/dist/src/failure-adapter.js +0 -23
  170. package/dist/src/hooks/manager.d.ts +0 -15
  171. package/dist/src/hooks/manager.js +0 -769
  172. package/dist/src/internal/fs-helpers.d.ts +0 -12
  173. package/dist/src/internal/fs-helpers.js +0 -13
  174. package/dist/src/internal/integrity.d.ts +0 -13
  175. package/dist/src/internal/integrity.js +0 -17
  176. package/dist/src/knowledge/manager.d.ts +0 -11
  177. package/dist/src/knowledge/manager.js +0 -711
  178. package/dist/src/mcps/manager.d.ts +0 -16
  179. package/dist/src/mcps/manager.js +0 -247
  180. package/dist/src/mcps/operations/artifact.d.ts +0 -24
  181. package/dist/src/mcps/operations/artifact.js +0 -74
  182. package/dist/src/mcps/operations/install.d.ts +0 -78
  183. package/dist/src/mcps/operations/install.js +0 -596
  184. package/dist/src/packs/dependency-resolution.d.ts +0 -65
  185. package/dist/src/packs/dependency-resolution.js +0 -414
  186. package/dist/src/packs/manager.d.ts +0 -16
  187. package/dist/src/packs/manager.js +0 -181
  188. package/dist/src/registry-materialization.d.ts +0 -52
  189. package/dist/src/registry-materialization.js +0 -72
  190. package/dist/src/release-age-posture.d.ts +0 -23
  191. package/dist/src/release-age-posture.js +0 -15
  192. package/dist/src/resolution-timeout.d.ts +0 -5
  193. package/dist/src/resolution-timeout.js +0 -11
  194. package/dist/src/rules/manager.d.ts +0 -20
  195. package/dist/src/rules/manager.js +0 -480
  196. package/dist/src/skills/manager.d.ts +0 -18
  197. package/dist/src/skills/manager.js +0 -346
  198. package/dist/src/skills/materialization.d.ts +0 -54
  199. package/dist/src/skills/materialization.js +0 -158
  200. package/dist/src/skills/operations/source-hash.d.ts +0 -2
  201. package/dist/src/skills/operations/source-hash.js +0 -6
  202. package/dist/src/subagents/manager.d.ts +0 -18
  203. package/dist/src/subagents/manager.js +0 -722
  204. package/dist/src/workflows/install-command/workflow.d.ts +0 -56
  205. package/dist/src/workflows/install-command/workflow.js +0 -46
  206. package/dist/src/workflows/uninstall-command/workflow.d.ts +0 -42
  207. package/dist/src/workflows/uninstall-command/workflow.js +0 -29
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Where a pack member's acquired package sits, and what an install changed
3
+ * about it. Both the member step and the pack planner report the same
4
+ * artifact for the same ref, so a preview and its apply name one path.
5
+ *
6
+ * @experimental This API is unstable and may change without notice.
7
+ */
8
+ import { toExtensionTypePlural, } from "@agentxm/extension-model/unstable/extensions";
9
+ import { ACQUIRED_EXTENSIONS_DIR, acquiredExtensionDisplayPath } from "@agentxm/workspace-state";
10
+ const USER_SCOPE_ACQUIRED_ROOT = ".axm/workspace/agent_extensions";
11
+ /** The registry directory segment a type's acquired packages live under. */
12
+ export const registryPluralSegment = (type) => toExtensionTypePlural(type);
13
+ /** Workspace-relative path of a ref's acquired (or authored) package. */
14
+ export const registrySourcePath = (ref, scope) => ref.refType === "workspace"
15
+ ? ref.location
16
+ : acquiredExtensionDisplayPath(scope === "project" ? ACQUIRED_EXTENSIONS_DIR : USER_SCOPE_ACQUIRED_ROOT, ref, registryPluralSegment(ref.type), ref.name);
17
+ /** The artifact one acquired pack member reports. */
18
+ export const registrySourceArtifact = (args) => {
19
+ const change = args.ref.refType === "workspace" ? "unchanged" : args.installedBefore ? "updated" : "created";
20
+ const sourcePath = registrySourcePath(args.ref, args.scope);
21
+ return {
22
+ path: sourcePath,
23
+ scope: args.scope,
24
+ ...(args.ref.refType === "registry" || args.ref.refType === "workspace"
25
+ ? { version: args.ref.version }
26
+ : {}),
27
+ change,
28
+ fileCount: 1,
29
+ targets: [{ path: sourcePath, change }],
30
+ };
31
+ };
32
+ //# sourceMappingURL=artifact.js.map
@@ -0,0 +1,30 @@
1
+ import * as Effect from "effect/Effect";
2
+ import { type PackRef } from "@agentxm/extension-model/unstable/extensions/refs/pack";
3
+ import { type DesiredStateGraph, type DesiredStateProblem, type WorkspaceMutationsService } from "@agentxm/workspace-state";
4
+ import { type Plan } from "@agentxm/workspace-operations";
5
+ import type { InstallStepRequirements } from "../install/vocabulary.js";
6
+ export declare const relevantPackConstraintProblems: (args: {
7
+ readonly graph: DesiredStateGraph;
8
+ readonly prospectivePacks: ReadonlyArray<PackRef>;
9
+ readonly selectedNames?: ReadonlySet<string>;
10
+ }) => ReadonlyArray<Extract<DesiredStateProblem, {
11
+ readonly type: "constraint-conflict";
12
+ }>>;
13
+ export declare const prospectivePackConstraintProblems: (args: {
14
+ readonly workspace: WorkspaceMutationsService;
15
+ readonly prospectivePacks: ReadonlyArray<PackRef>;
16
+ readonly selectedNames?: ReadonlySet<string>;
17
+ }) => Effect.Effect<readonly {
18
+ readonly type: "constraint-conflict";
19
+ readonly extensionType: import("@agentxm/extension-model/unstable/extensions").ExtensionType;
20
+ readonly name: string;
21
+ readonly constraints: ReadonlyArray<string>;
22
+ readonly contributors: ReadonlyArray<import("@agentxm/workspace-state").DesiredConstraintContributor>;
23
+ }[], import("@agentxm/workspace-state").WorkspaceStateReadFailure, never>;
24
+ export declare const configuredPackConstraintBlockPlan: (args: {
25
+ readonly operation: "install" | "update";
26
+ readonly problems: ReadonlyArray<Extract<DesiredStateProblem, {
27
+ readonly type: "constraint-conflict";
28
+ }>>;
29
+ }) => Plan<InstallStepRequirements>;
30
+ //# sourceMappingURL=constraint-gate.d.ts.map
@@ -0,0 +1,76 @@
1
+ import * as Effect from "effect/Effect";
2
+ import * as Option from "effect/Option";
3
+ import {} from "@agentxm/extension-model/unstable/extensions/refs/pack";
4
+ import { desiredStateProblemsText, } from "@agentxm/workspace-state";
5
+ import { operationPresentation } from "@agentxm/workspace-operations";
6
+ const normalizedPackIdentity = (identity) => identity.replace(/^workspace:/u, "");
7
+ const packOrigins = (origins) => origins.flatMap((origin) => origin.type === "pack" ? [normalizedPackIdentity(origin.pack)] : []);
8
+ const selectedPackClosure = (graph, prospectivePacks, selectedNames) => {
9
+ const selected = new Set(prospectivePacks.map((pack) => `${pack.owner}/packs/${pack.pack.name}`));
10
+ for (const node of graph.nodes) {
11
+ if (node.type === "pack" && (selectedNames === undefined || selectedNames.has(node.name))) {
12
+ selected.add(normalizedPackIdentity(node.identity));
13
+ }
14
+ }
15
+ const adjacent = new Map();
16
+ for (const node of graph.nodes) {
17
+ const packs = packOrigins(node.origins);
18
+ for (const pack of packs) {
19
+ const neighbors = adjacent.get(pack) ?? new Set();
20
+ for (const peer of packs) {
21
+ if (peer !== pack)
22
+ neighbors.add(peer);
23
+ }
24
+ adjacent.set(pack, neighbors);
25
+ }
26
+ }
27
+ const closure = new Set(selected);
28
+ const pending = [...selected];
29
+ for (let index = 0; index < pending.length; index += 1) {
30
+ const pack = pending[index];
31
+ if (pack === undefined)
32
+ continue;
33
+ for (const neighbor of adjacent.get(pack) ?? []) {
34
+ if (closure.has(neighbor))
35
+ continue;
36
+ closure.add(neighbor);
37
+ pending.push(neighbor);
38
+ }
39
+ }
40
+ return closure;
41
+ };
42
+ export const relevantPackConstraintProblems = (args) => {
43
+ const closure = selectedPackClosure(args.graph, args.prospectivePacks, args.selectedNames);
44
+ return args.graph.problems.filter((problem) => problem.type === "constraint-conflict" &&
45
+ problem.contributors.some((contributor) => contributor.dependingPack !== undefined &&
46
+ closure.has(normalizedPackIdentity(contributor.dependingPack))));
47
+ };
48
+ export const prospectivePackConstraintProblems = (args) => args.workspace.getDesiredStateGraph({ prospectivePacks: args.prospectivePacks }).pipe(Effect.map((graph) => relevantPackConstraintProblems({
49
+ graph,
50
+ prospectivePacks: args.prospectivePacks,
51
+ ...(args.selectedNames === undefined ? {} : { selectedNames: args.selectedNames }),
52
+ })));
53
+ export const configuredPackConstraintBlockPlan = (args) => ({
54
+ _tag: "Plan",
55
+ name: `Block configured Pack ${args.operation}`,
56
+ description: Option.some("Configured Pack constraints cannot be satisfied together"),
57
+ presentation: operationPresentation({
58
+ imperative: args.operation,
59
+ past: args.operation === "install" ? "Installed" : "Updated",
60
+ gerund: args.operation === "install" ? "Installing" : "Updating",
61
+ }, "pack"),
62
+ jobs: [
63
+ {
64
+ concurrency: 1,
65
+ steps: [
66
+ {
67
+ key: "pack:constraint-gate",
68
+ readiness: "error",
69
+ label: "configured Pack constraint gate",
70
+ errorMessage: `Configured Pack constraints are unsatisfiable: ${desiredStateProblemsText(args.problems)}`,
71
+ },
72
+ ],
73
+ },
74
+ ],
75
+ });
76
+ //# sourceMappingURL=constraint-gate.js.map
@@ -6,17 +6,16 @@
6
6
  * @experimental This API is unstable and may change without notice.
7
7
  */
8
8
  import * as Effect from "effect/Effect";
9
+ import type * as Duration from "effect/Duration";
9
10
  import type * as Option from "effect/Option";
10
- import type { SourceAuthorityBlocked, PackManagerError } from "@agentxm/extension-workspace";
11
- /** Failures pack expansion can surface. */
12
- type PackExpansionError = SourceResolutionFailure | PackManagerError | SourceAuthorityBlocked;
13
11
  import { type ExtensionType } from "@agentxm/extension-model/unstable/extensions";
14
12
  import type { ExtensionRef } from "@agentxm/extension-model/unstable/extensions/refs/extension-ref";
15
13
  import type { PackRef } from "@agentxm/extension-model/unstable/extensions/refs/pack";
16
- import type { SourceHostProvidersService, SourceResolutionFailure } from "@agentxm/extension-sources";
17
- import type * as Duration from "effect/Duration";
18
- import { type PackDependencyRefResolver, type ReleaseAgeAwarePackDependencyResolution, type WorkspacePackDependencyResolver } from "./dependency-resolution.js";
19
14
  import type { ReleaseAgeEvaluation } from "@agentxm/extension-model/unstable/extensions/release-age";
15
+ import type { SourceHostProvidersService, SourceResolutionFailure } from "@agentxm/extension-sources";
16
+ import { type PackDependencyRefResolver, type PackDependencyResolutionFailure, type ReleaseAgeAwarePackDependencyResolution, type SourceAuthorityBlocked, type WorkspacePackDependencyResolver } from "@agentxm/extension-resolution";
17
+ /** Failures pack expansion can surface. */
18
+ type PackExpansionError = SourceResolutionFailure | PackDependencyResolutionFailure | SourceAuthorityBlocked;
20
19
  /**
21
20
  * Expand a pack ref into its cross-type dependency refs.
22
21
  *
@@ -27,14 +26,14 @@ import type { ReleaseAgeEvaluation } from "@agentxm/extension-model/unstable/ext
27
26
  * Dependency refs use the pack's registry source and empty integrity
28
27
  * (integrity is resolved during materialization, not at expansion time).
29
28
  */
30
- export declare const expandPackInstallRefs: <E = never>(args: {
29
+ export declare const expandPackInstallRefs: <E = never, R = never>(args: {
31
30
  readonly pack: PackRef;
32
31
  readonly supportedDependencyTypes: ReadonlyArray<ExtensionType>;
33
32
  readonly sources: SourceHostProvidersService;
34
33
  readonly minimumReleaseAge?: Option.Option<Duration.Duration>;
35
- readonly workspaceResolver?: WorkspacePackDependencyResolver<E>;
36
- readonly dependencyResolver?: PackDependencyRefResolver<E>;
37
- }) => Effect.Effect<ReadonlyArray<ExtensionRef>, PackExpansionError | E>;
34
+ readonly workspaceResolver?: WorkspacePackDependencyResolver<E, R>;
35
+ readonly dependencyResolver?: PackDependencyRefResolver<E, R>;
36
+ }) => Effect.Effect<ReadonlyArray<ExtensionRef>, PackExpansionError | E, R>;
38
37
  export type ReleaseAgeAwarePackExpansion = {
39
38
  readonly kind: "selected";
40
39
  readonly refs: ReadonlyArray<ExtensionRef>;
@@ -47,13 +46,13 @@ export type ReleaseAgeAwarePackExpansion = {
47
46
  } | Extract<ReleaseAgeAwarePackDependencyResolution, {
48
47
  kind: "policy_held";
49
48
  }>;
50
- export declare const expandPackInstallRefsWithReleaseAge: <E = never>(args: {
49
+ export declare const expandPackInstallRefsWithReleaseAge: <E = never, R = never>(args: {
51
50
  readonly pack: PackRef;
52
51
  readonly supportedDependencyTypes: ReadonlyArray<ExtensionType>;
53
52
  readonly sources: SourceHostProvidersService;
54
53
  readonly releaseAgeEvaluation: ReleaseAgeEvaluation;
55
- readonly workspaceResolver?: WorkspacePackDependencyResolver<E>;
56
- readonly dependencyResolver?: PackDependencyRefResolver<E>;
57
- }) => Effect.Effect<ReleaseAgeAwarePackExpansion, PackExpansionError | E>;
54
+ readonly workspaceResolver?: WorkspacePackDependencyResolver<E, R>;
55
+ readonly dependencyResolver?: PackDependencyRefResolver<E, R>;
56
+ }) => Effect.Effect<ReleaseAgeAwarePackExpansion, PackExpansionError | E, R>;
58
57
  export {};
59
58
  //# sourceMappingURL=expansion.d.ts.map
@@ -7,8 +7,7 @@
7
7
  */
8
8
  import * as Effect from "effect/Effect";
9
9
  import {} from "@agentxm/extension-model/unstable/extensions";
10
- import { resolvePackDependencies } from "./dependency-resolution.js";
11
- import { resolvePackDependenciesWithReleaseAge, } from "./dependency-resolution.js";
10
+ import { resolvePackDependencies, resolvePackDependenciesWithReleaseAge, } from "@agentxm/extension-resolution";
12
11
  // -----------------------------------------------------------------------------
13
12
  // expandPackInstallRefs
14
13
  // -----------------------------------------------------------------------------
@@ -0,0 +1,64 @@
1
+ /**
2
+ * The atomic pack graph transition.
3
+ *
4
+ * Installing or removing a pack changes the desired graph and every member's
5
+ * canonical content together. Either the whole transition holds or none of it
6
+ * does, so its children run inside one workspace transaction, a stale
7
+ * candidate is caught before the first write, and the resulting graph is
8
+ * checked against the predicate the planner declared.
9
+ *
10
+ * @experimental This API is unstable and may change without notice.
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import { WorkspaceMutations, type DesiredExtensionNode } from "@agentxm/workspace-state";
14
+ import { type JobStepArtifact, type PlannedJobStep } from "@agentxm/workspace-operations";
15
+ import type { ExtensionLifecycleFailed } from "../errors.js";
16
+ import { type LifecycleStepFailure } from "../step-failure.js";
17
+ import { type InstallStepRequirements } from "../install/vocabulary.js";
18
+ export interface AtomicPackGraphChild {
19
+ readonly step: PlannedJobStep<InstallStepRequirements>;
20
+ readonly coverage: "eligible" | "ineligible";
21
+ }
22
+ /**
23
+ * What a pack transition checks before it writes and after it commits. The
24
+ * checks are the planner's, so their failure family and their requirements
25
+ * travel with them rather than being fixed here.
26
+ */
27
+ export interface AtomicPackGraphStepArgs<E extends LifecycleStepFailure, R> {
28
+ readonly label: string;
29
+ readonly message: string;
30
+ readonly artifact: JobStepArtifact;
31
+ readonly children: ReadonlyArray<AtomicPackGraphChild>;
32
+ readonly reportUnchangedWhenChildrenUnchanged?: boolean;
33
+ /** A stale-candidate check that runs under the transition, before any write. */
34
+ readonly preTransition?: Effect.Effect<void, E, R>;
35
+ /** The desired-graph predicate the committed transition must satisfy. */
36
+ readonly validate: Effect.Effect<void, E, R>;
37
+ }
38
+ /** Wrap a pack transition's children in one workspace transaction. */
39
+ export declare const buildAtomicPackGraphStep: <E extends LifecycleStepFailure, R>(args: AtomicPackGraphStepArgs<E, R>) => Effect.Effect<PlannedJobStep<InstallStepRequirements | R>>;
40
+ interface RequiredPack {
41
+ readonly name: string;
42
+ readonly identity: string;
43
+ readonly enabled?: boolean;
44
+ }
45
+ interface RequiredMember {
46
+ readonly type: Exclude<DesiredExtensionNode["type"], "pack">;
47
+ readonly name: string;
48
+ readonly packIdentity?: string;
49
+ readonly direct?: boolean;
50
+ readonly enabled?: boolean;
51
+ }
52
+ interface AbsentNode {
53
+ readonly type: DesiredExtensionNode["type"];
54
+ readonly name: string;
55
+ }
56
+ /** The desired-graph predicate a completed pack transition must satisfy. */
57
+ export declare const validatePackGraphPostcondition: (args: {
58
+ readonly requiredPacks?: ReadonlyArray<RequiredPack>;
59
+ readonly requiredMembers?: ReadonlyArray<RequiredMember>;
60
+ readonly absent?: ReadonlyArray<AbsentNode>;
61
+ readonly inactive?: ReadonlyArray<AbsentNode>;
62
+ }) => Effect.Effect<void, ExtensionLifecycleFailed, WorkspaceMutations>;
63
+ export {};
64
+ //# sourceMappingURL=graph-transition.d.ts.map
@@ -0,0 +1,219 @@
1
+ /**
2
+ * The atomic pack graph transition.
3
+ *
4
+ * Installing or removing a pack changes the desired graph and every member's
5
+ * canonical content together. Either the whole transition holds or none of it
6
+ * does, so its children run inside one workspace transaction, a stale
7
+ * candidate is caught before the first write, and the resulting graph is
8
+ * checked against the predicate the planner declared.
9
+ *
10
+ * @experimental This API is unstable and may change without notice.
11
+ */
12
+ import * as Effect from "effect/Effect";
13
+ import { WorkspaceMutations, desiredStateProblemsText, } from "@agentxm/workspace-state";
14
+ import { runWorkspaceTransaction } from "@agentxm/workspace-transactions";
15
+ import { StepFailure, } from "@agentxm/workspace-operations";
16
+ import { lifecycleStepFailure } from "../step-failure.js";
17
+ import { installRefused } from "../install/vocabulary.js";
18
+ const normalizedIdentity = (identity) => identity.startsWith("workspace:") ? identity.slice("workspace:".length) : identity;
19
+ const failedStep = (label, result) => result.result === "error"
20
+ ? Effect.fail(result.error ??
21
+ lifecycleStepFailure(installRefused({
22
+ category: "internal",
23
+ detail: `${label} failed: ${result.message}`,
24
+ })))
25
+ : Effect.succeed(result);
26
+ const aggregatePackCoverage = (results, scope) => Effect.gen(function* () {
27
+ const applicableArtifacts = results.flatMap(({ result, coverage }) => coverage === "eligible" &&
28
+ result.result === "success" &&
29
+ result.artifact?.agents !== undefined
30
+ ? [result.artifact]
31
+ : []);
32
+ const agents = [];
33
+ for (const artifact of applicableArtifacts) {
34
+ if (artifact.scope !== scope) {
35
+ return yield* installRefused({
36
+ category: "internal",
37
+ detail: `Pack coverage spans ${scope} and ${artifact.scope} scopes`,
38
+ });
39
+ }
40
+ const artifactAgents = new Set(artifact.agents);
41
+ for (const target of artifact.targets ?? []) {
42
+ for (const agent of target.agentIds ?? []) {
43
+ if (!artifactAgents.has(agent)) {
44
+ return yield* installRefused({
45
+ category: "internal",
46
+ detail: `Pack child target agent ${agent} is absent from its artifact agents`,
47
+ });
48
+ }
49
+ }
50
+ }
51
+ for (const agent of artifact.agents ?? []) {
52
+ if (agent !== "universal" && !agents.includes(agent))
53
+ agents.push(agent);
54
+ }
55
+ }
56
+ return { applicable: applicableArtifacts.length > 0, agents };
57
+ });
58
+ /** Wrap a pack transition's children in one workspace transaction. */
59
+ export const buildAtomicPackGraphStep = (args) => Effect.sync(() => {
60
+ const readinessErrors = args.children.flatMap(({ step }) => step.readiness === "error" ? [step.errorMessage] : []);
61
+ if (readinessErrors.length > 0) {
62
+ const blockingConditionIds = args.children.flatMap(({ step }) => step.readiness === "error" ? (step.blockingConditionIds ?? []) : []);
63
+ return {
64
+ readiness: "error",
65
+ label: args.label,
66
+ errorMessage: readinessErrors.join("; "),
67
+ artifact: args.artifact,
68
+ ...(blockingConditionIds.length === 0 ? {} : { blockingConditionIds }),
69
+ };
70
+ }
71
+ const readinessWarnings = args.children.flatMap(({ step }) => step.readiness === "warn" ? [step.warnMessage] : []);
72
+ const runnableChildren = args.children.filter((child) => child.step.readiness !== "error");
73
+ let validatedCoverage = { applicable: false, agents: [] };
74
+ const run = runWorkspaceTransaction({
75
+ transition: Effect.gen(function* () {
76
+ if (args.preTransition !== undefined) {
77
+ yield* args.preTransition.pipe(Effect.mapError(lifecycleStepFailure));
78
+ }
79
+ return yield* Effect.forEach(runnableChildren, ({ step, coverage }) => step.run.pipe(Effect.flatMap((result) => failedStep(step.label, result)), Effect.map((result) => ({ result, coverage }))), { concurrency: 1 });
80
+ }),
81
+ validate: (results) => Effect.gen(function* () {
82
+ yield* args.validate;
83
+ validatedCoverage = yield* aggregatePackCoverage(results, args.artifact.scope);
84
+ }).pipe(Effect.mapError(lifecycleStepFailure)),
85
+ }).pipe(Effect.mapError(lifecycleStepFailure), Effect.map((results) => {
86
+ const warnings = results.flatMap(({ result }) => result.result === "success" ? (result.warnings ?? []) : []);
87
+ const allChildrenUnchanged = args.reportUnchangedWhenChildrenUnchanged === true &&
88
+ results.length > 0 &&
89
+ results.every(({ result }) => result.result === "success" && result.artifact?.change === "unchanged");
90
+ const artifact = allChildrenUnchanged
91
+ ? { ...args.artifact, change: "unchanged" }
92
+ : args.artifact;
93
+ return {
94
+ result: "success",
95
+ message: args.message,
96
+ artifact: !validatedCoverage.applicable
97
+ ? artifact
98
+ : { ...artifact, agents: validatedCoverage.agents },
99
+ ...(warnings.length === 0 ? {} : { warnings }),
100
+ };
101
+ }));
102
+ return readinessWarnings.length === 0
103
+ ? {
104
+ readiness: "ready",
105
+ label: args.label,
106
+ artifact: args.artifact,
107
+ run,
108
+ }
109
+ : {
110
+ readiness: "warn",
111
+ label: args.label,
112
+ warnMessage: readinessWarnings.join("; "),
113
+ artifact: args.artifact,
114
+ run,
115
+ };
116
+ });
117
+ /** The desired-graph predicate a completed pack transition must satisfy. */
118
+ export const validatePackGraphPostcondition = (args) => Effect.gen(function* () {
119
+ const ws = yield* WorkspaceMutations;
120
+ const graph = yield* ws.getDesiredStateGraph().pipe(Effect.mapError((cause) => installRefused({
121
+ category: "internal",
122
+ detail: "Desired state could not be read after the pack transition",
123
+ cause,
124
+ })));
125
+ const requiredPackIdentities = new Set((args.requiredPacks ?? []).map((pack) => normalizedIdentity(pack.identity)));
126
+ const requiredMemberKeys = new Set((args.requiredMembers ?? []).map((member) => `${member.type}:${member.name}`));
127
+ const relevantProblems = graph.problems.filter((problem) => {
128
+ switch (problem.type) {
129
+ case "pack-manifest-unavailable":
130
+ case "pack-manifest-invalid":
131
+ case "pack-identity-mismatch":
132
+ case "pack-resolution-unavailable":
133
+ case "pack-manifest-content-mismatch":
134
+ return requiredPackIdentities.has(normalizedIdentity(problem.pack));
135
+ case "projection-collision":
136
+ case "constraint-conflict":
137
+ case "workspace-owner-missing":
138
+ return requiredMemberKeys.has(`${problem.extensionType}:${problem.name}`);
139
+ }
140
+ });
141
+ if (relevantProblems.length > 0) {
142
+ return yield* installRefused({
143
+ category: "conflict",
144
+ detail: `Pack transition left its desired member graph incomplete: ${desiredStateProblemsText(relevantProblems)}`,
145
+ });
146
+ }
147
+ for (const expected of args.requiredPacks ?? []) {
148
+ const node = graph.nodes.find((candidate) => candidate.type === "pack" && candidate.name === expected.name);
149
+ if (node === undefined ||
150
+ normalizedIdentity(node.identity) !== normalizedIdentity(expected.identity) ||
151
+ (expected.enabled !== undefined && node.enabled !== expected.enabled)) {
152
+ const expectedPredicate = [
153
+ `identity ${normalizedIdentity(expected.identity)}`,
154
+ ...(expected.enabled === undefined
155
+ ? []
156
+ : [`activation ${expected.enabled ? "enabled" : "disabled"}`]),
157
+ ].join(", ");
158
+ const observedPredicate = node === undefined
159
+ ? "absent"
160
+ : `identity ${normalizedIdentity(node.identity)}, activation ${node.enabled ? "enabled" : "disabled"}`;
161
+ return yield* installRefused({
162
+ category: "internal",
163
+ detail: `Pack graph closure ${expected.identity} failed its desired-state predicate: expected ${expectedPredicate}; observed ${observedPredicate}`,
164
+ });
165
+ }
166
+ }
167
+ for (const expected of args.requiredMembers ?? []) {
168
+ const node = graph.nodes.find((candidate) => candidate.type === expected.type && candidate.name === expected.name);
169
+ const packIdentity = expected.packIdentity;
170
+ const hasPackOrigin = packIdentity === undefined ||
171
+ node?.origins.some((origin) => origin.type === "pack" &&
172
+ normalizedIdentity(origin.pack) === normalizedIdentity(packIdentity)) === true;
173
+ const hasDirectOrigin = expected.direct !== true ||
174
+ node?.origins.some((origin) => origin.type === "settings") === true;
175
+ if (node === undefined ||
176
+ !hasPackOrigin ||
177
+ !hasDirectOrigin ||
178
+ (expected.enabled !== undefined && node.enabled !== expected.enabled)) {
179
+ const expectedPredicate = [
180
+ ...(packIdentity === undefined
181
+ ? []
182
+ : [`Pack ownership ${normalizedIdentity(packIdentity)}`]),
183
+ ...(expected.direct === true ? ["direct ownership"] : []),
184
+ ...(expected.enabled === undefined
185
+ ? []
186
+ : [`activation ${expected.enabled ? "enabled" : "disabled"}`]),
187
+ ].join(", ");
188
+ const observedPredicate = node === undefined
189
+ ? "absent"
190
+ : `origins ${node.origins
191
+ .map((origin) => origin.type === "pack"
192
+ ? `Pack ${normalizedIdentity(origin.pack)}`
193
+ : "direct settings")
194
+ .join(", ") || "none"}, activation ${node.enabled ? "enabled" : "disabled"}`;
195
+ return yield* installRefused({
196
+ category: "internal",
197
+ detail: `Pack graph closure ${packIdentity ?? "unknown"} failed the ${expected.type} "${expected.name}" desired-state predicate: expected ${expectedPredicate || "reachable"}; observed ${observedPredicate}`,
198
+ });
199
+ }
200
+ }
201
+ for (const expected of args.absent ?? []) {
202
+ if (graph.nodes.some((candidate) => candidate.type === expected.type && candidate.name === expected.name)) {
203
+ return yield* installRefused({
204
+ category: "internal",
205
+ detail: `${expected.type} "${expected.name}" remained in the desired graph after the pack transition`,
206
+ });
207
+ }
208
+ }
209
+ for (const expected of args.inactive ?? []) {
210
+ const node = graph.nodes.find((candidate) => candidate.type === expected.type && candidate.name === expected.name);
211
+ if (node === undefined || node.enabled) {
212
+ return yield* installRefused({
213
+ category: "internal",
214
+ detail: `${expected.type} "${expected.name}" did not remain reachable and inactive after the Pack transition`,
215
+ });
216
+ }
217
+ }
218
+ });
219
+ //# sourceMappingURL=graph-transition.js.map
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Installing a pack.
3
+ *
4
+ * A pack install is a graph transition, not a package copy: the pack's own
5
+ * package, every member its manifest resolves to, and every member the
6
+ * previous graph owned and this one drops all change together. Workspace
7
+ * source authority decides whether a locally-authored package may stand in
8
+ * for a declared member, the minimum-release-age policy decides whether a
9
+ * held-back release preserves the current graph or blocks, and the transition
10
+ * is refused if the authority it was planned against changed underneath it.
11
+ *
12
+ * @experimental This API is unstable and may change without notice.
13
+ */
14
+ import * as Effect from "effect/Effect";
15
+ import * as Option from "effect/Option";
16
+ import * as Path from "effect/Path";
17
+ import { HookManager, KnowledgeManager, McpServerManager, PackManager, RuleManager, SkillManager, SubagentManager } from "@agentxm/extension-materialization";
18
+ import type { PackRef } from "@agentxm/extension-model/unstable/extensions/refs/pack";
19
+ import { type ExtensionName, type Handle } from "@agentxm/extension-model/unstable/extensions";
20
+ import type { ReleaseAgeEvaluation } from "@agentxm/extension-model/unstable/extensions/release-age";
21
+ import type { RegistrySource } from "@agentxm/extension-model/unstable/sources/types";
22
+ import { type VersionRange } from "@agentxm/extension-model/unstable/version-constraints";
23
+ import { type SourceAuthorityBlockedFact, type WorkspacePackDependencyResolver } from "@agentxm/extension-resolution";
24
+ import { SourceHostProviders } from "@agentxm/extension-sources";
25
+ import { type Plan } from "@agentxm/workspace-operations";
26
+ import { type DesiredStateGraph } from "@agentxm/workspace-state";
27
+ import type { ExtensionLifecycleFailed } from "../../errors.js";
28
+ import { type RegistryLookupProbe } from "../../install/registry-source-resolution.js";
29
+ import { type InstallStepRequirements, type PackInstallIntent, type ResolveInstallRequirements } from "../../install/vocabulary.js";
30
+ /** A pack install request after grammar parsing, before anything is discovered. */
31
+ export interface ParsedPackInstallRequest {
32
+ readonly owner: Handle;
33
+ readonly packName: ExtensionName;
34
+ readonly versionRange: Option.Option<VersionRange>;
35
+ readonly resolvedInput: string;
36
+ readonly inputKind: "name-input" | "name-input-with-version" | "registry-pattern-input";
37
+ readonly sourceResolution?: string;
38
+ readonly unattended: boolean;
39
+ readonly nonInteractive: boolean;
40
+ readonly releaseAgeEvaluation?: ReleaseAgeEvaluation;
41
+ readonly releaseAgeHoldbackBehavior?: "continue" | "preserve-or-block";
42
+ }
43
+ /** One pack registry lookup. */
44
+ export interface PackSourceRequest {
45
+ readonly source: RegistrySource;
46
+ readonly owner: Handle;
47
+ readonly packName: ExtensionName;
48
+ readonly versionRange: Option.Option<VersionRange>;
49
+ readonly sourceResolution?: string;
50
+ }
51
+ /** A discovered pack ref and the registry hosts that were consulted for it. */
52
+ export interface PackDiscovery {
53
+ readonly ref: PackRef;
54
+ readonly probes: ReadonlyArray<RegistryLookupProbe>;
55
+ readonly registrySourceLabel: string;
56
+ }
57
+ /**
58
+ * Which declared members a locally-authored workspace package may satisfy,
59
+ * and which configured sources refuse to be replaced by the registry. The
60
+ * fingerprint identifies the exact authority this plan was built against, so
61
+ * the transition can refuse a candidate that went stale.
62
+ */
63
+ export interface WorkspaceAuthorityScan {
64
+ readonly graph: DesiredStateGraph;
65
+ readonly blockers: ReadonlyArray<SourceAuthorityBlockedFact>;
66
+ readonly workspaceResolver: WorkspacePackDependencyResolver;
67
+ readonly fingerprint: string;
68
+ }
69
+ /** What a pack install command supplies before anything is parsed. */
70
+ export interface PackInstallArgs {
71
+ readonly source: string;
72
+ readonly unattended?: boolean;
73
+ readonly nonInteractive: boolean;
74
+ readonly releaseAgeEvaluation?: ReleaseAgeEvaluation;
75
+ readonly releaseAgeHoldbackBehavior?: "continue" | "preserve-or-block";
76
+ }
77
+ /** Read the pack source grammar: which owner, which pack, which range. */
78
+ export declare const parsePackInstallRequest: (args: PackInstallArgs) => Effect.Effect<ParsedPackInstallRequest, ExtensionLifecycleFailed, ResolveInstallRequirements>;
79
+ /** Resolve the registry the parsed pack request names. */
80
+ export declare const resolvePackSourceRequest: (request: ParsedPackInstallRequest) => Effect.Effect<PackSourceRequest, ExtensionLifecycleFailed, ResolveInstallRequirements>;
81
+ /**
82
+ * Find the pack. When the first host cannot answer because remote reads are
83
+ * unsupported, every configured `file://` registry is consulted in turn, and
84
+ * every probe is recorded so the operator can see what was tried.
85
+ */
86
+ export declare const discoverPackRef: (request: PackSourceRequest) => Effect.Effect<PackDiscovery, ExtensionLifecycleFailed, ResolveInstallRequirements>;
87
+ /** Render the probe evidence a discovery collected. */
88
+ export declare const packDiscoveryDiagnostics: (request: PackSourceRequest, discovery: PackDiscovery) => ReadonlyArray<string>;
89
+ /** Settle the pack this request installs. */
90
+ export declare const finalizePackInstallIntent: (request: ParsedPackInstallRequest, discovery: PackDiscovery) => PackInstallIntent;
91
+ /** Everything the pack graph transition reads and writes through. */
92
+ export type PackInstallRequirements = InstallStepRequirements | ResolveInstallRequirements | SourceHostProviders | Path.Path | HookManager | KnowledgeManager | McpServerManager | PackManager | RuleManager | SkillManager | SubagentManager;
93
+ /** The single atomic closure a settled pack intent becomes. */
94
+ export declare const planPackInstall: (intent: PackInstallIntent) => Effect.Effect<Plan<InstallStepRequirements>, ExtensionLifecycleFailed, PackInstallRequirements>;
95
+ //# sourceMappingURL=plan.d.ts.map