@kadi.build/deploy-ability 0.0.1

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 (198) hide show
  1. package/README.md +523 -0
  2. package/dist/constants.d.ts +82 -0
  3. package/dist/constants.d.ts.map +1 -0
  4. package/dist/constants.js +82 -0
  5. package/dist/constants.js.map +1 -0
  6. package/dist/errors/certificate-error.d.ts +95 -0
  7. package/dist/errors/certificate-error.d.ts.map +1 -0
  8. package/dist/errors/certificate-error.js +111 -0
  9. package/dist/errors/certificate-error.js.map +1 -0
  10. package/dist/errors/deployment-error.d.ts +122 -0
  11. package/dist/errors/deployment-error.d.ts.map +1 -0
  12. package/dist/errors/deployment-error.js +185 -0
  13. package/dist/errors/deployment-error.js.map +1 -0
  14. package/dist/errors/index.d.ts +13 -0
  15. package/dist/errors/index.d.ts.map +1 -0
  16. package/dist/errors/index.js +18 -0
  17. package/dist/errors/index.js.map +1 -0
  18. package/dist/errors/profile-error.d.ts +106 -0
  19. package/dist/errors/profile-error.d.ts.map +1 -0
  20. package/dist/errors/profile-error.js +127 -0
  21. package/dist/errors/profile-error.js.map +1 -0
  22. package/dist/errors/provider-error.d.ts +104 -0
  23. package/dist/errors/provider-error.d.ts.map +1 -0
  24. package/dist/errors/provider-error.js +120 -0
  25. package/dist/errors/provider-error.js.map +1 -0
  26. package/dist/errors/wallet-error.d.ts +131 -0
  27. package/dist/errors/wallet-error.d.ts.map +1 -0
  28. package/dist/errors/wallet-error.js +154 -0
  29. package/dist/errors/wallet-error.js.map +1 -0
  30. package/dist/index.d.ts +49 -0
  31. package/dist/index.d.ts.map +1 -0
  32. package/dist/index.js +53 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/targets/akash/bid-selectors.d.ts +251 -0
  35. package/dist/targets/akash/bid-selectors.d.ts.map +1 -0
  36. package/dist/targets/akash/bid-selectors.js +322 -0
  37. package/dist/targets/akash/bid-selectors.js.map +1 -0
  38. package/dist/targets/akash/bid-types.d.ts +297 -0
  39. package/dist/targets/akash/bid-types.d.ts.map +1 -0
  40. package/dist/targets/akash/bid-types.js +89 -0
  41. package/dist/targets/akash/bid-types.js.map +1 -0
  42. package/dist/targets/akash/blockchain-client.d.ts +577 -0
  43. package/dist/targets/akash/blockchain-client.d.ts.map +1 -0
  44. package/dist/targets/akash/blockchain-client.js +803 -0
  45. package/dist/targets/akash/blockchain-client.js.map +1 -0
  46. package/dist/targets/akash/certificate-manager.d.ts +228 -0
  47. package/dist/targets/akash/certificate-manager.d.ts.map +1 -0
  48. package/dist/targets/akash/certificate-manager.js +395 -0
  49. package/dist/targets/akash/certificate-manager.js.map +1 -0
  50. package/dist/targets/akash/constants.d.ts +231 -0
  51. package/dist/targets/akash/constants.d.ts.map +1 -0
  52. package/dist/targets/akash/constants.js +225 -0
  53. package/dist/targets/akash/constants.js.map +1 -0
  54. package/dist/targets/akash/deployer.d.ts +136 -0
  55. package/dist/targets/akash/deployer.d.ts.map +1 -0
  56. package/dist/targets/akash/deployer.js +599 -0
  57. package/dist/targets/akash/deployer.js.map +1 -0
  58. package/dist/targets/akash/environment.d.ts +241 -0
  59. package/dist/targets/akash/environment.d.ts.map +1 -0
  60. package/dist/targets/akash/environment.js +245 -0
  61. package/dist/targets/akash/environment.js.map +1 -0
  62. package/dist/targets/akash/index.d.ts +1113 -0
  63. package/dist/targets/akash/index.d.ts.map +1 -0
  64. package/dist/targets/akash/index.js +909 -0
  65. package/dist/targets/akash/index.js.map +1 -0
  66. package/dist/targets/akash/lease-monitor.d.ts +51 -0
  67. package/dist/targets/akash/lease-monitor.d.ts.map +1 -0
  68. package/dist/targets/akash/lease-monitor.js +110 -0
  69. package/dist/targets/akash/lease-monitor.js.map +1 -0
  70. package/dist/targets/akash/logs.d.ts +71 -0
  71. package/dist/targets/akash/logs.d.ts.map +1 -0
  72. package/dist/targets/akash/logs.js +311 -0
  73. package/dist/targets/akash/logs.js.map +1 -0
  74. package/dist/targets/akash/logs.types.d.ts +102 -0
  75. package/dist/targets/akash/logs.types.d.ts.map +1 -0
  76. package/dist/targets/akash/logs.types.js +9 -0
  77. package/dist/targets/akash/logs.types.js.map +1 -0
  78. package/dist/targets/akash/pricing.d.ts +247 -0
  79. package/dist/targets/akash/pricing.d.ts.map +1 -0
  80. package/dist/targets/akash/pricing.js +246 -0
  81. package/dist/targets/akash/pricing.js.map +1 -0
  82. package/dist/targets/akash/provider-client.d.ts +114 -0
  83. package/dist/targets/akash/provider-client.d.ts.map +1 -0
  84. package/dist/targets/akash/provider-client.js +318 -0
  85. package/dist/targets/akash/provider-client.js.map +1 -0
  86. package/dist/targets/akash/provider-metadata.d.ts +228 -0
  87. package/dist/targets/akash/provider-metadata.d.ts.map +1 -0
  88. package/dist/targets/akash/provider-metadata.js +14 -0
  89. package/dist/targets/akash/provider-metadata.js.map +1 -0
  90. package/dist/targets/akash/provider-service.d.ts +133 -0
  91. package/dist/targets/akash/provider-service.d.ts.map +1 -0
  92. package/dist/targets/akash/provider-service.js +391 -0
  93. package/dist/targets/akash/provider-service.js.map +1 -0
  94. package/dist/targets/akash/query-client.d.ts +125 -0
  95. package/dist/targets/akash/query-client.d.ts.map +1 -0
  96. package/dist/targets/akash/query-client.js +332 -0
  97. package/dist/targets/akash/query-client.js.map +1 -0
  98. package/dist/targets/akash/sdl-generator.d.ts +31 -0
  99. package/dist/targets/akash/sdl-generator.d.ts.map +1 -0
  100. package/dist/targets/akash/sdl-generator.js +279 -0
  101. package/dist/targets/akash/sdl-generator.js.map +1 -0
  102. package/dist/targets/akash/types.d.ts +285 -0
  103. package/dist/targets/akash/types.d.ts.map +1 -0
  104. package/dist/targets/akash/types.js +54 -0
  105. package/dist/targets/akash/types.js.map +1 -0
  106. package/dist/targets/akash/wallet-manager.d.ts +526 -0
  107. package/dist/targets/akash/wallet-manager.d.ts.map +1 -0
  108. package/dist/targets/akash/wallet-manager.js +953 -0
  109. package/dist/targets/akash/wallet-manager.js.map +1 -0
  110. package/dist/targets/local/compose-generator.d.ts +244 -0
  111. package/dist/targets/local/compose-generator.d.ts.map +1 -0
  112. package/dist/targets/local/compose-generator.js +324 -0
  113. package/dist/targets/local/compose-generator.js.map +1 -0
  114. package/dist/targets/local/deployer.d.ts +82 -0
  115. package/dist/targets/local/deployer.d.ts.map +1 -0
  116. package/dist/targets/local/deployer.js +367 -0
  117. package/dist/targets/local/deployer.js.map +1 -0
  118. package/dist/targets/local/engine-manager.d.ts +155 -0
  119. package/dist/targets/local/engine-manager.d.ts.map +1 -0
  120. package/dist/targets/local/engine-manager.js +250 -0
  121. package/dist/targets/local/engine-manager.js.map +1 -0
  122. package/dist/targets/local/index.d.ts +40 -0
  123. package/dist/targets/local/index.d.ts.map +1 -0
  124. package/dist/targets/local/index.js +43 -0
  125. package/dist/targets/local/index.js.map +1 -0
  126. package/dist/targets/local/network-manager.d.ts +160 -0
  127. package/dist/targets/local/network-manager.d.ts.map +1 -0
  128. package/dist/targets/local/network-manager.js +337 -0
  129. package/dist/targets/local/network-manager.js.map +1 -0
  130. package/dist/targets/local/types.d.ts +327 -0
  131. package/dist/targets/local/types.d.ts.map +1 -0
  132. package/dist/targets/local/types.js +9 -0
  133. package/dist/targets/local/types.js.map +1 -0
  134. package/dist/types/common.d.ts +585 -0
  135. package/dist/types/common.d.ts.map +1 -0
  136. package/dist/types/common.js +13 -0
  137. package/dist/types/common.js.map +1 -0
  138. package/dist/types/index.d.ts +15 -0
  139. package/dist/types/index.d.ts.map +1 -0
  140. package/dist/types/index.js +12 -0
  141. package/dist/types/index.js.map +1 -0
  142. package/dist/types/options.d.ts +329 -0
  143. package/dist/types/options.d.ts.map +1 -0
  144. package/dist/types/options.js +10 -0
  145. package/dist/types/options.js.map +1 -0
  146. package/dist/types/profiles.d.ts +329 -0
  147. package/dist/types/profiles.d.ts.map +1 -0
  148. package/dist/types/profiles.js +27 -0
  149. package/dist/types/profiles.js.map +1 -0
  150. package/dist/types/results.d.ts +443 -0
  151. package/dist/types/results.d.ts.map +1 -0
  152. package/dist/types/results.js +64 -0
  153. package/dist/types/results.js.map +1 -0
  154. package/dist/types/validators.d.ts +118 -0
  155. package/dist/types/validators.d.ts.map +1 -0
  156. package/dist/types/validators.js +198 -0
  157. package/dist/types/validators.js.map +1 -0
  158. package/dist/utils/command-runner.d.ts +128 -0
  159. package/dist/utils/command-runner.d.ts.map +1 -0
  160. package/dist/utils/command-runner.js +210 -0
  161. package/dist/utils/command-runner.js.map +1 -0
  162. package/dist/utils/index.d.ts +10 -0
  163. package/dist/utils/index.d.ts.map +1 -0
  164. package/dist/utils/index.js +10 -0
  165. package/dist/utils/index.js.map +1 -0
  166. package/dist/utils/logger.d.ts +68 -0
  167. package/dist/utils/logger.d.ts.map +1 -0
  168. package/dist/utils/logger.js +93 -0
  169. package/dist/utils/logger.js.map +1 -0
  170. package/dist/utils/profile-loader.d.ts +76 -0
  171. package/dist/utils/profile-loader.d.ts.map +1 -0
  172. package/dist/utils/profile-loader.js +194 -0
  173. package/dist/utils/profile-loader.js.map +1 -0
  174. package/dist/utils/registry/index.d.ts +27 -0
  175. package/dist/utils/registry/index.d.ts.map +1 -0
  176. package/dist/utils/registry/index.js +29 -0
  177. package/dist/utils/registry/index.js.map +1 -0
  178. package/dist/utils/registry/manager.d.ts +319 -0
  179. package/dist/utils/registry/manager.d.ts.map +1 -0
  180. package/dist/utils/registry/manager.js +671 -0
  181. package/dist/utils/registry/manager.js.map +1 -0
  182. package/dist/utils/registry/setup.d.ts +135 -0
  183. package/dist/utils/registry/setup.d.ts.map +1 -0
  184. package/dist/utils/registry/setup.js +207 -0
  185. package/dist/utils/registry/setup.js.map +1 -0
  186. package/dist/utils/registry/transformer.d.ts +92 -0
  187. package/dist/utils/registry/transformer.d.ts.map +1 -0
  188. package/dist/utils/registry/transformer.js +131 -0
  189. package/dist/utils/registry/transformer.js.map +1 -0
  190. package/dist/utils/registry/types.d.ts +241 -0
  191. package/dist/utils/registry/types.d.ts.map +1 -0
  192. package/dist/utils/registry/types.js +10 -0
  193. package/dist/utils/registry/types.js.map +1 -0
  194. package/docs/EXAMPLES.md +293 -0
  195. package/docs/PLACEMENT.md +433 -0
  196. package/docs/STORAGE.md +318 -0
  197. package/docs/building-provider-reliability-tracker.md +2581 -0
  198. package/package.json +109 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Logger utilities
3
+ *
4
+ * Provides default logger implementation and logger factory functions
5
+ *
6
+ * @module utils/logger
7
+ */
8
+ /**
9
+ * Default console-based logger implementation
10
+ *
11
+ * Uses console methods for output with timestamps and level prefixes
12
+ */
13
+ export class ConsoleLogger {
14
+ verbose;
15
+ constructor(verbose = false) {
16
+ this.verbose = verbose;
17
+ }
18
+ /**
19
+ * Log informational message
20
+ */
21
+ log(message, ...args) {
22
+ console.log(`[${this.getTimestamp()}] ${message}`, ...args);
23
+ }
24
+ /**
25
+ * Log error message
26
+ */
27
+ error(message, ...args) {
28
+ console.error(`[${this.getTimestamp()}] ERROR: ${message}`, ...args);
29
+ }
30
+ /**
31
+ * Log warning message
32
+ */
33
+ warn(message, ...args) {
34
+ console.warn(`[${this.getTimestamp()}] WARN: ${message}`, ...args);
35
+ }
36
+ /**
37
+ * Log debug message (only if verbose mode enabled)
38
+ */
39
+ debug(message, ...args) {
40
+ if (this.verbose) {
41
+ console.debug(`[${this.getTimestamp()}] DEBUG: ${message}`, ...args);
42
+ }
43
+ }
44
+ /**
45
+ * Get current timestamp for log messages
46
+ */
47
+ getTimestamp() {
48
+ return new Date().toISOString();
49
+ }
50
+ }
51
+ /**
52
+ * Silent logger that discards all output
53
+ *
54
+ * Useful for testing or when logging is not desired
55
+ */
56
+ export class SilentLogger {
57
+ log(_message, ..._args) {
58
+ // Silent - no output
59
+ }
60
+ error(_message, ..._args) {
61
+ // Silent - no output
62
+ }
63
+ warn(_message, ..._args) {
64
+ // Silent - no output
65
+ }
66
+ debug(_message, ..._args) {
67
+ // Silent - no output
68
+ }
69
+ }
70
+ /**
71
+ * Create a logger instance
72
+ *
73
+ * @param options - Logger configuration options
74
+ * @returns Logger instance
75
+ *
76
+ * @example
77
+ * const logger = createLogger({ verbose: true });
78
+ * logger.log('Deployment started');
79
+ */
80
+ export function createLogger(options) {
81
+ if (options.custom) {
82
+ return options.custom;
83
+ }
84
+ if (options.silent) {
85
+ return new SilentLogger();
86
+ }
87
+ return new ConsoleLogger(options.verbose ?? false);
88
+ }
89
+ /**
90
+ * Default logger instance (console-based, non-verbose)
91
+ */
92
+ export const defaultLogger = new ConsoleLogger(false);
93
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,CAAU;IAElC,YAAY,UAAmB,KAAK;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,OAAe,EAAE,GAAG,IAAe;QACrC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9D,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,YAAY,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,OAAe,EAAE,GAAG,IAAe;QACtC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACrE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAe,EAAE,GAAG,IAAe;QACvC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,YAAY,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IAED;;OAEG;IACK,YAAY;QAClB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAClC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACvB,GAAG,CAAC,QAAgB,EAAE,GAAG,KAAgB;QACvC,qBAAqB;IACvB,CAAC;IAED,KAAK,CAAC,QAAgB,EAAE,GAAG,KAAgB;QACzC,qBAAqB;IACvB,CAAC;IAED,IAAI,CAAC,QAAgB,EAAE,GAAG,KAAgB;QACxC,qBAAqB;IACvB,CAAC;IAED,KAAK,CAAC,QAAgB,EAAE,GAAG,KAAgB;QACzC,qBAAqB;IACvB,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,YAAY,CAAC,OAI5B;IACC,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,IAAI,YAAY,EAAE,CAAC;IAC5B,CAAC;IAED,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;AACrD,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAqB,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Profile loading and validation utilities
3
+ *
4
+ * Functions for loading deployment profiles from agent.json
5
+ *
6
+ * @module utils/profile-loader
7
+ */
8
+ import type { AgentConfig, DeploymentProfile, LoadedProfile, DeploymentLogger } from '../types/index.js';
9
+ /**
10
+ * Load agent.json from a project root directory
11
+ *
12
+ * @param projectRoot - Path to project root
13
+ * @param logger - Optional logger
14
+ * @returns Parsed agent configuration
15
+ * @throws {ProfileError} If agent.json not found or invalid
16
+ *
17
+ * @example
18
+ * const config = await loadAgentConfig('/path/to/project');
19
+ */
20
+ export declare function loadAgentConfig(projectRoot: string, logger?: DeploymentLogger): Promise<AgentConfig>;
21
+ /**
22
+ * Get all available deployment profile names from agent config
23
+ *
24
+ * @param config - Agent configuration
25
+ * @returns Array of profile names
26
+ *
27
+ * @example
28
+ * const profiles = getAvailableProfiles(config);
29
+ * console.log(profiles); // ['local-dev', 'production', 'staging']
30
+ */
31
+ export declare function getAvailableProfiles(config: AgentConfig): readonly string[];
32
+ /**
33
+ * Load a specific deployment profile from agent config
34
+ *
35
+ * @param config - Agent configuration
36
+ * @param profileName - Name of profile to load
37
+ * @param projectRoot - Project root path
38
+ * @param logger - Optional logger
39
+ * @returns Loaded profile with metadata
40
+ * @throws {ProfileError} If profile not found or invalid
41
+ *
42
+ * @example
43
+ * const profile = await loadDeploymentProfile(config, 'production', '/path/to/project');
44
+ */
45
+ export declare function loadDeploymentProfile(config: AgentConfig, profileName: string, projectRoot: string, logger?: DeploymentLogger): Promise<LoadedProfile<DeploymentProfile>>;
46
+ /**
47
+ * Load the first available deployment profile
48
+ *
49
+ * Useful when no specific profile is requested
50
+ *
51
+ * @param config - Agent configuration
52
+ * @param projectRoot - Project root path
53
+ * @param logger - Optional logger
54
+ * @returns Loaded profile with metadata
55
+ * @throws {ProfileError} If no profiles are defined
56
+ *
57
+ * @example
58
+ * const profile = await loadFirstProfile(config, '/path/to/project');
59
+ */
60
+ export declare function loadFirstProfile(config: AgentConfig, projectRoot: string, logger?: DeploymentLogger): Promise<LoadedProfile<DeploymentProfile>>;
61
+ /**
62
+ * Load profile from project root by name or use first available
63
+ *
64
+ * Convenience function that combines loading agent.json and profile
65
+ *
66
+ * @param projectRoot - Path to project root
67
+ * @param profileName - Optional profile name (uses first if not specified)
68
+ * @param logger - Optional logger
69
+ * @returns Loaded profile with metadata
70
+ * @throws {ProfileError} If agent.json or profile invalid
71
+ *
72
+ * @example
73
+ * const profile = await loadProfile('/path/to/project', 'production');
74
+ */
75
+ export declare function loadProfile(projectRoot: string, profileName?: string, logger?: DeploymentLogger): Promise<LoadedProfile<DeploymentProfile>>;
76
+ //# sourceMappingURL=profile-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-loader.d.ts","sourceRoot":"","sources":["../../src/utils/profile-loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAU3B;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,gBAAgC,GACvC,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,MAAM,EAAE,CAM3E;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,gBAAgC,GACvC,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CA2B3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,WAAW,EACnB,WAAW,EAAE,MAAM,EACnB,MAAM,GAAE,gBAAgC,GACvC,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAe3C;AA+GD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,WAAW,CAC/B,WAAW,EAAE,MAAM,EACnB,WAAW,CAAC,EAAE,MAAM,EACpB,MAAM,GAAE,gBAAgC,GACvC,OAAO,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC,CAQ3C"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Profile loading and validation utilities
3
+ *
4
+ * Functions for loading deployment profiles from agent.json
5
+ *
6
+ * @module utils/profile-loader
7
+ */
8
+ import { readFile } from 'node:fs/promises';
9
+ import { join } from 'node:path';
10
+ import { agentJsonNotFoundError, agentJsonParseError, profileNotFoundError, noProfilesDefinedError, profileInvalidError, } from '../errors/index.js';
11
+ import { defaultLogger } from './logger.js';
12
+ /**
13
+ * Load agent.json from a project root directory
14
+ *
15
+ * @param projectRoot - Path to project root
16
+ * @param logger - Optional logger
17
+ * @returns Parsed agent configuration
18
+ * @throws {ProfileError} If agent.json not found or invalid
19
+ *
20
+ * @example
21
+ * const config = await loadAgentConfig('/path/to/project');
22
+ */
23
+ export async function loadAgentConfig(projectRoot, logger = defaultLogger) {
24
+ const agentJsonPath = join(projectRoot, 'agent.json');
25
+ logger.debug(`Loading agent.json from ${agentJsonPath}`);
26
+ let content;
27
+ try {
28
+ content = await readFile(agentJsonPath, 'utf-8');
29
+ }
30
+ catch (error) {
31
+ throw agentJsonNotFoundError(projectRoot);
32
+ }
33
+ try {
34
+ const config = JSON.parse(content);
35
+ logger.debug(`Loaded agent config: ${config.name} v${config.version}`);
36
+ return config;
37
+ }
38
+ catch (error) {
39
+ throw agentJsonParseError(agentJsonPath, error);
40
+ }
41
+ }
42
+ /**
43
+ * Get all available deployment profile names from agent config
44
+ *
45
+ * @param config - Agent configuration
46
+ * @returns Array of profile names
47
+ *
48
+ * @example
49
+ * const profiles = getAvailableProfiles(config);
50
+ * console.log(profiles); // ['local-dev', 'production', 'staging']
51
+ */
52
+ export function getAvailableProfiles(config) {
53
+ if (!config.deploy) {
54
+ return [];
55
+ }
56
+ return Object.keys(config.deploy);
57
+ }
58
+ /**
59
+ * Load a specific deployment profile from agent config
60
+ *
61
+ * @param config - Agent configuration
62
+ * @param profileName - Name of profile to load
63
+ * @param projectRoot - Project root path
64
+ * @param logger - Optional logger
65
+ * @returns Loaded profile with metadata
66
+ * @throws {ProfileError} If profile not found or invalid
67
+ *
68
+ * @example
69
+ * const profile = await loadDeploymentProfile(config, 'production', '/path/to/project');
70
+ */
71
+ export async function loadDeploymentProfile(config, profileName, projectRoot, logger = defaultLogger) {
72
+ logger.debug(`Loading deployment profile: ${profileName}`);
73
+ // Check if deploy section exists
74
+ if (!config.deploy) {
75
+ throw noProfilesDefinedError(join(projectRoot, 'agent.json'));
76
+ }
77
+ // Check if profile exists
78
+ const availableProfiles = getAvailableProfiles(config);
79
+ const profile = config.deploy[profileName];
80
+ if (!profile) {
81
+ throw profileNotFoundError(profileName, availableProfiles);
82
+ }
83
+ // Validate profile has required fields
84
+ validateProfile(profileName, profile);
85
+ logger.debug(`Loaded profile: ${profileName} (target: ${profile.target})`);
86
+ return {
87
+ name: profileName,
88
+ profile: profile,
89
+ agent: config,
90
+ projectRoot,
91
+ };
92
+ }
93
+ /**
94
+ * Load the first available deployment profile
95
+ *
96
+ * Useful when no specific profile is requested
97
+ *
98
+ * @param config - Agent configuration
99
+ * @param projectRoot - Project root path
100
+ * @param logger - Optional logger
101
+ * @returns Loaded profile with metadata
102
+ * @throws {ProfileError} If no profiles are defined
103
+ *
104
+ * @example
105
+ * const profile = await loadFirstProfile(config, '/path/to/project');
106
+ */
107
+ export async function loadFirstProfile(config, projectRoot, logger = defaultLogger) {
108
+ const availableProfiles = getAvailableProfiles(config);
109
+ if (availableProfiles.length === 0) {
110
+ throw noProfilesDefinedError(join(projectRoot, 'agent.json'));
111
+ }
112
+ const firstProfileName = availableProfiles[0];
113
+ if (!firstProfileName) {
114
+ throw noProfilesDefinedError(join(projectRoot, 'agent.json'));
115
+ }
116
+ logger.log(`No profile specified, using first available: ${firstProfileName}`);
117
+ return loadDeploymentProfile(config, firstProfileName, projectRoot, logger);
118
+ }
119
+ /**
120
+ * Validate a deployment profile has required fields
121
+ *
122
+ * @param profileName - Name of profile being validated
123
+ * @param profile - Profile to validate
124
+ * @throws {ProfileError} If profile is invalid
125
+ *
126
+ * @internal
127
+ */
128
+ function validateProfile(profileName, profile) {
129
+ if (typeof profile !== 'object' || profile === null) {
130
+ throw profileInvalidError(profileName, 'Profile must be an object');
131
+ }
132
+ const p = profile;
133
+ // Check required fields
134
+ if (!p.target) {
135
+ throw profileInvalidError(profileName, 'Missing required field: target', 'target');
136
+ }
137
+ if (typeof p.target !== 'string') {
138
+ throw profileInvalidError(profileName, 'Field "target" must be a string', 'target');
139
+ }
140
+ if (!['local', 'akash'].includes(p.target)) {
141
+ throw profileInvalidError(profileName, `Invalid target: ${p.target}. Must be "local" or "akash"`, 'target');
142
+ }
143
+ // Check services exist
144
+ if (!p.services) {
145
+ throw profileInvalidError(profileName, 'Missing required field: services', 'services');
146
+ }
147
+ if (typeof p.services !== 'object' || p.services === null) {
148
+ throw profileInvalidError(profileName, 'Field "services" must be an object', 'services');
149
+ }
150
+ // Check at least one service is defined
151
+ const serviceCount = Object.keys(p.services).length;
152
+ if (serviceCount === 0) {
153
+ throw profileInvalidError(profileName, 'At least one service must be defined', 'services');
154
+ }
155
+ // Target-specific validation
156
+ if (p.target === 'local') {
157
+ if (!p.engine) {
158
+ throw profileInvalidError(profileName, 'Local profiles must specify an engine (docker or podman)', 'engine');
159
+ }
160
+ if (!['docker', 'podman'].includes(p.engine)) {
161
+ throw profileInvalidError(profileName, `Invalid engine: ${p.engine}. Must be "docker" or "podman"`, 'engine');
162
+ }
163
+ }
164
+ if (p.target === 'akash') {
165
+ if (!p.network) {
166
+ throw profileInvalidError(profileName, 'Akash profiles must specify a network (mainnet, testnet, or sandbox)', 'network');
167
+ }
168
+ if (!['mainnet', 'testnet', 'sandbox'].includes(p.network)) {
169
+ throw profileInvalidError(profileName, `Invalid network: ${p.network}. Must be "mainnet", "testnet", or "sandbox"`, 'network');
170
+ }
171
+ }
172
+ }
173
+ /**
174
+ * Load profile from project root by name or use first available
175
+ *
176
+ * Convenience function that combines loading agent.json and profile
177
+ *
178
+ * @param projectRoot - Path to project root
179
+ * @param profileName - Optional profile name (uses first if not specified)
180
+ * @param logger - Optional logger
181
+ * @returns Loaded profile with metadata
182
+ * @throws {ProfileError} If agent.json or profile invalid
183
+ *
184
+ * @example
185
+ * const profile = await loadProfile('/path/to/project', 'production');
186
+ */
187
+ export async function loadProfile(projectRoot, profileName, logger = defaultLogger) {
188
+ const config = await loadAgentConfig(projectRoot, logger);
189
+ if (profileName) {
190
+ return loadDeploymentProfile(config, profileName, projectRoot, logger);
191
+ }
192
+ return loadFirstProfile(config, projectRoot, logger);
193
+ }
194
+ //# sourceMappingURL=profile-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-loader.js","sourceRoot":"","sources":["../../src/utils/profile-loader.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,WAAmB,EACnB,SAA2B,aAAa;IAExC,MAAM,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;IAEtD,MAAM,CAAC,KAAK,CAAC,2BAA2B,aAAa,EAAE,CAAC,CAAC;IAEzD,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACH,OAAO,GAAG,MAAM,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAC5C,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAgB,CAAC;QAClD,MAAM,CAAC,KAAK,CAAC,wBAAwB,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACvE,OAAO,MAAM,CAAC;IAChB,CAAC;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sE,EACtE,SAAS,CACV,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAiB,CAAC,EAAE,CAAC;YACrE,MAAM,mBAAmB,CACvB,WAAW,EACX,oBAAoB,CAAC,CAAC,OAAO,8CAA8C,EAC3E,SAAS,CACV,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,WAAmB,EACnB,WAAoB,EACpB,SAA2B,aAAa;IAExC,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IAE1D,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,qBAAqB,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;AACvD,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Registry Infrastructure
3
+ *
4
+ * Temporary container registry for making local images accessible to Akash providers.
5
+ *
6
+ * **Quick Start:**
7
+ * ```typescript
8
+ * import { setupRegistryIfNeeded } from 'deploy-ability/registry';
9
+ *
10
+ * const ctx = await setupRegistryIfNeeded(profile, logger);
11
+ *
12
+ * try {
13
+ * await deployToAkash({
14
+ * loadedProfile: { profile: ctx.deployableProfile }
15
+ * });
16
+ * } finally {
17
+ * await ctx.cleanup();
18
+ * }
19
+ * ```
20
+ *
21
+ * @module utils/registry
22
+ */
23
+ export { setupRegistryIfNeeded, hasLocalImages } from './setup.js';
24
+ export { TemporaryContainerRegistryManager } from './manager.js';
25
+ export { transformProfileWithRegistry, isLocalImagePattern } from './transformer.js';
26
+ export type { RegistryContext, RegistryOptions, ContainerMapping, RegistryCredentials, RegistryInfo, RegistryUrls, ContainerInfo } from './types.js';
27
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGrF,YAAY,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,YAAY,EACZ,YAAY,EACZ,aAAa,EACd,MAAM,YAAY,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Registry Infrastructure
3
+ *
4
+ * Temporary container registry for making local images accessible to Akash providers.
5
+ *
6
+ * **Quick Start:**
7
+ * ```typescript
8
+ * import { setupRegistryIfNeeded } from 'deploy-ability/registry';
9
+ *
10
+ * const ctx = await setupRegistryIfNeeded(profile, logger);
11
+ *
12
+ * try {
13
+ * await deployToAkash({
14
+ * loadedProfile: { profile: ctx.deployableProfile }
15
+ * });
16
+ * } finally {
17
+ * await ctx.cleanup();
18
+ * }
19
+ * ```
20
+ *
21
+ * @module utils/registry
22
+ */
23
+ // Main API
24
+ export { setupRegistryIfNeeded, hasLocalImages } from './setup.js';
25
+ // Manager class (for advanced use cases)
26
+ export { TemporaryContainerRegistryManager } from './manager.js';
27
+ // Utilities
28
+ export { transformProfileWithRegistry, isLocalImagePattern } from './transformer.js';
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,WAAW;AACX,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEnE,yCAAyC;AACzC,OAAO,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAEjE,YAAY;AACZ,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC"}