@kadi.build/deploy-ability 0.0.3 → 0.0.5

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 (110) hide show
  1. package/dist/targets/akash/bids.d.ts +183 -0
  2. package/dist/targets/akash/bids.d.ts.map +1 -0
  3. package/dist/targets/akash/bids.js +247 -0
  4. package/dist/targets/akash/bids.js.map +1 -0
  5. package/dist/targets/akash/certificate-manager.d.ts +89 -167
  6. package/dist/targets/akash/certificate-manager.d.ts.map +1 -1
  7. package/dist/targets/akash/certificate-manager.js +193 -301
  8. package/dist/targets/akash/certificate-manager.js.map +1 -1
  9. package/dist/targets/akash/client.d.ts +644 -0
  10. package/dist/targets/akash/client.d.ts.map +1 -0
  11. package/dist/targets/akash/client.js +972 -0
  12. package/dist/targets/akash/client.js.map +1 -0
  13. package/dist/targets/akash/constants.d.ts +12 -149
  14. package/dist/targets/akash/constants.d.ts.map +1 -1
  15. package/dist/targets/akash/constants.js +14 -136
  16. package/dist/targets/akash/constants.js.map +1 -1
  17. package/dist/targets/akash/deployer.d.ts +3 -82
  18. package/dist/targets/akash/deployer.d.ts.map +1 -1
  19. package/dist/targets/akash/deployer.js +122 -160
  20. package/dist/targets/akash/deployer.js.map +1 -1
  21. package/dist/targets/akash/environment.d.ts +16 -214
  22. package/dist/targets/akash/environment.d.ts.map +1 -1
  23. package/dist/targets/akash/environment.js +20 -210
  24. package/dist/targets/akash/environment.js.map +1 -1
  25. package/dist/targets/akash/index.d.ts +95 -189
  26. package/dist/targets/akash/index.d.ts.map +1 -1
  27. package/dist/targets/akash/index.js +69 -197
  28. package/dist/targets/akash/index.js.map +1 -1
  29. package/dist/targets/akash/lease-monitor.d.ts +3 -21
  30. package/dist/targets/akash/lease-monitor.d.ts.map +1 -1
  31. package/dist/targets/akash/lease-monitor.js +39 -56
  32. package/dist/targets/akash/lease-monitor.js.map +1 -1
  33. package/dist/targets/akash/logs.d.ts +103 -4
  34. package/dist/targets/akash/logs.d.ts.map +1 -1
  35. package/dist/targets/akash/logs.js +12 -3
  36. package/dist/targets/akash/logs.js.map +1 -1
  37. package/dist/targets/akash/pricing.d.ts +12 -191
  38. package/dist/targets/akash/pricing.d.ts.map +1 -1
  39. package/dist/targets/akash/pricing.js +12 -188
  40. package/dist/targets/akash/pricing.js.map +1 -1
  41. package/dist/targets/akash/provider-manager.d.ts +120 -0
  42. package/dist/targets/akash/provider-manager.d.ts.map +1 -0
  43. package/dist/targets/akash/provider-manager.js +574 -0
  44. package/dist/targets/akash/provider-manager.js.map +1 -0
  45. package/dist/targets/akash/sdl-generator.d.ts +2 -2
  46. package/dist/targets/akash/sdl-generator.d.ts.map +1 -1
  47. package/dist/targets/akash/sdl-generator.js +6 -39
  48. package/dist/targets/akash/sdl-generator.js.map +1 -1
  49. package/dist/targets/akash/types.d.ts +66 -243
  50. package/dist/targets/akash/types.d.ts.map +1 -1
  51. package/dist/targets/akash/types.js +4 -41
  52. package/dist/targets/akash/types.js.map +1 -1
  53. package/dist/targets/akash/wallet-manager.d.ts +35 -352
  54. package/dist/targets/akash/wallet-manager.d.ts.map +1 -1
  55. package/dist/targets/akash/wallet-manager.js +37 -439
  56. package/dist/targets/akash/wallet-manager.js.map +1 -1
  57. package/dist/targets/local/compose-generator.d.ts.map +1 -1
  58. package/dist/targets/local/compose-generator.js +1 -0
  59. package/dist/targets/local/compose-generator.js.map +1 -1
  60. package/dist/targets/local/deployer.js +4 -4
  61. package/dist/targets/local/deployer.js.map +1 -1
  62. package/dist/targets/local/types.d.ts +4 -0
  63. package/dist/targets/local/types.d.ts.map +1 -1
  64. package/dist/types/index.d.ts +1 -1
  65. package/dist/types/index.d.ts.map +1 -1
  66. package/dist/types/index.js.map +1 -1
  67. package/dist/types/options.d.ts +45 -4
  68. package/dist/types/options.d.ts.map +1 -1
  69. package/dist/utils/registry/manager.js +6 -6
  70. package/dist/utils/registry/manager.js.map +1 -1
  71. package/dist/utils/registry/setup.js +4 -4
  72. package/dist/utils/registry/setup.js.map +1 -1
  73. package/docs/KADI_ABILITY_CONVERSION.md +1365 -0
  74. package/docs/PIPELINE_BUILDER_DESIGN.md +1149 -0
  75. package/package.json +8 -11
  76. package/dist/targets/akash/bid-selectors.d.ts +0 -251
  77. package/dist/targets/akash/bid-selectors.d.ts.map +0 -1
  78. package/dist/targets/akash/bid-selectors.js +0 -322
  79. package/dist/targets/akash/bid-selectors.js.map +0 -1
  80. package/dist/targets/akash/bid-types.d.ts +0 -297
  81. package/dist/targets/akash/bid-types.d.ts.map +0 -1
  82. package/dist/targets/akash/bid-types.js +0 -89
  83. package/dist/targets/akash/bid-types.js.map +0 -1
  84. package/dist/targets/akash/blockchain-client.d.ts +0 -577
  85. package/dist/targets/akash/blockchain-client.d.ts.map +0 -1
  86. package/dist/targets/akash/blockchain-client.js +0 -803
  87. package/dist/targets/akash/blockchain-client.js.map +0 -1
  88. package/dist/targets/akash/logs.types.d.ts +0 -102
  89. package/dist/targets/akash/logs.types.d.ts.map +0 -1
  90. package/dist/targets/akash/logs.types.js +0 -9
  91. package/dist/targets/akash/logs.types.js.map +0 -1
  92. package/dist/targets/akash/provider-client.d.ts +0 -114
  93. package/dist/targets/akash/provider-client.d.ts.map +0 -1
  94. package/dist/targets/akash/provider-client.js +0 -318
  95. package/dist/targets/akash/provider-client.js.map +0 -1
  96. package/dist/targets/akash/provider-metadata.d.ts +0 -228
  97. package/dist/targets/akash/provider-metadata.d.ts.map +0 -1
  98. package/dist/targets/akash/provider-metadata.js +0 -14
  99. package/dist/targets/akash/provider-metadata.js.map +0 -1
  100. package/dist/targets/akash/provider-service.d.ts +0 -133
  101. package/dist/targets/akash/provider-service.d.ts.map +0 -1
  102. package/dist/targets/akash/provider-service.js +0 -391
  103. package/dist/targets/akash/provider-service.js.map +0 -1
  104. package/dist/targets/akash/query-client.d.ts +0 -125
  105. package/dist/targets/akash/query-client.d.ts.map +0 -1
  106. package/dist/targets/akash/query-client.js +0 -332
  107. package/dist/targets/akash/query-client.js.map +0 -1
  108. package/docs/EXAMPLES.md +0 -293
  109. package/docs/PLACEMENT.md +0 -433
  110. package/docs/STORAGE.md +0 -318
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kadi.build/deploy-ability",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Programmatic deployment library for KADI - deploy to Akash Network, local Docker, and other platforms without CLI dependencies",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -64,10 +64,11 @@
64
64
  "dependencies": {
65
65
  "axios": "^1.7.7",
66
66
  "@akashnetwork/akash-api": "^1.4.0",
67
- "@akashnetwork/akashjs": "^0.11.0",
68
- "@cosmjs/encoding": "^0.33.1",
69
- "@cosmjs/proto-signing": "^0.33.1",
70
- "@cosmjs/stargate": "^0.33.1",
67
+ "@akashnetwork/chain-sdk": "1.0.0-alpha.18",
68
+ "@cosmjs/amino": "^0.36.1",
69
+ "@cosmjs/encoding": "^0.36.1",
70
+ "@cosmjs/proto-signing": "^0.36.1",
71
+ "@cosmjs/stargate": "^0.36.1",
71
72
  "@kadi.build/container-registry-ability": "^0.0.3",
72
73
  "@keplr-wallet/wc-client": "^0.12.243",
73
74
  "@keplr-wallet/wc-qrcode-modal": "^0.12.247",
@@ -77,15 +78,11 @@
77
78
  "dockerode": "^4.0.7",
78
79
  "dotenv": "^16.5.0",
79
80
  "js-yaml": "^4.1.0",
81
+ "long": "^5.2.3",
80
82
  "strip-ansi": "^7.1.2",
81
83
  "ws": "^8.18.3",
82
84
  "yaml": "^2",
83
- "zod": "^4.1.12"
84
- },
85
- "overrides": {
86
- "@akashnetwork/akashjs": {
87
- "@cosmjs/stargate": "^0.33.1"
88
- }
85
+ "zod": "^3.24.1"
89
86
  },
90
87
  "devDependencies": {
91
88
  "@types/debug": "^4.1.12",
@@ -1,251 +0,0 @@
1
- /**
2
- * Bid Selection Helpers
3
- *
4
- * Provides pre-built selection strategies and filtering utilities for choosing
5
- * providers based on different criteria. These functions can be used directly
6
- * as bidSelectors in the deployment flow, or combined to create custom
7
- * selection logic.
8
- *
9
- * **Selection Strategies:**
10
- * - `selectCheapestBid` - Lowest price (perMonth basis)
11
- * - `selectMostReliableBid` - Highest uptime percentage
12
- * - `selectBalancedBid` - Weighted combination of price and reliability
13
- *
14
- * **Filtering:**
15
- * - `filterBids` - Apply multiple criteria to narrow down options
16
- *
17
- * @module targets/akash/bid-selectors
18
- */
19
- import type { EnhancedBid } from './bid-types.js';
20
- /**
21
- * Select the cheapest bid based on monthly price
22
- *
23
- * Compares all bids and returns the one with the lowest cost per month.
24
- * Useful when price is the primary concern and provider quality is
25
- * less critical (e.g., development/testing deployments).
26
- *
27
- * **Note:** This only considers price, not provider reliability, location,
28
- * or audit status. For production deployments, consider using `filterBids`
29
- * first to ensure minimum quality standards, then select the cheapest
30
- * from the filtered set.
31
- *
32
- * @param bids - Array of enhanced bids to choose from
33
- * @returns The cheapest bid, or null if array is empty
34
- *
35
- * @example
36
- * ```typescript
37
- * import { deployToAkash, selectCheapestBid } from '@kadi.build/deploy-ability/akash';
38
- *
39
- * const result = await deployToAkash({
40
- * wallet,
41
- * certificate,
42
- * projectRoot: './',
43
- * profile: 'dev',
44
- * bidSelector: selectCheapestBid
45
- * });
46
- * ```
47
- *
48
- * @example With quality filtering
49
- * ```typescript
50
- * const result = await deployToAkash({
51
- * wallet,
52
- * certificate,
53
- * projectRoot: './',
54
- * profile: 'prod',
55
- * bidSelector: (bids) => {
56
- * // Only consider audited providers with good uptime
57
- * const qualityBids = filterBids(bids, {
58
- * requireAudited: true,
59
- * minUptime: { value: 0.95, period: '7d' }
60
- * });
61
- * // Then pick cheapest among quality providers
62
- * return selectCheapestBid(qualityBids);
63
- * }
64
- * });
65
- * ```
66
- */
67
- export declare function selectCheapestBid(bids: EnhancedBid[]): EnhancedBid | null;
68
- /**
69
- * Select the most reliable provider based on uptime
70
- *
71
- * Chooses the provider with the highest uptime percentage for the specified
72
- * time period. Providers without reliability data are considered last.
73
- *
74
- * **Uptime Periods:**
75
- * - `1d`: Last 24 hours (most recent, but limited sample)
76
- * - `7d`: Last 7 days (good balance, recommended default)
77
- * - `30d`: Last 30 days (long-term stability indicator)
78
- *
79
- * **Fallback Behavior:**
80
- * If no providers have reliability data, returns the first bid from the
81
- * original array (maintains deterministic behavior).
82
- *
83
- * @param bids - Array of enhanced bids to choose from
84
- * @param period - Uptime period to evaluate (default: '7d')
85
- * @returns The most reliable bid, or null if array is empty
86
- *
87
- * @example
88
- * ```typescript
89
- * import { deployToAkash, selectMostReliableBid } from '@kadi.build/deploy-ability/akash';
90
- *
91
- * const result = await deployToAkash({
92
- * wallet,
93
- * certificate,
94
- * projectRoot: './',
95
- * profile: 'production',
96
- * bidSelector: selectMostReliableBid // Uses 7d default
97
- * });
98
- * ```
99
- *
100
- * @example With custom period
101
- * ```typescript
102
- * const result = await deployToAkash({
103
- * wallet,
104
- * certificate,
105
- * projectRoot: './',
106
- * profile: 'production',
107
- * bidSelector: (bids) => selectMostReliableBid(bids, '30d')
108
- * });
109
- * ```
110
- */
111
- export declare function selectMostReliableBid(bids: EnhancedBid[], period?: '1d' | '7d' | '30d'): EnhancedBid | null;
112
- /**
113
- * Select bid using balanced scoring (price + reliability)
114
- *
115
- * Calculates a composite score for each bid based on normalized price
116
- * and reliability metrics, then selects the highest-scoring option.
117
- *
118
- * **Scoring Methodology:**
119
- * - Price score: Normalized 0-1 (lower price = higher score)
120
- * - Reliability score: Uptime percentage (0-1)
121
- * - Total score = (price score × price weight) + (reliability score × reliability weight)
122
- *
123
- * **Default Weights:**
124
- * Equal balance (0.5 each) - adjust based on your priorities.
125
- *
126
- * **Use Cases:**
127
- * - Production deployments where both cost and reliability matter
128
- * - Finding "best value" providers (good balance of quality and price)
129
- * - Avoiding both the cheapest-but-unreliable and expensive-but-reliable extremes
130
- *
131
- * @param bids - Array of enhanced bids to choose from
132
- * @param weights - Scoring weights (default: equal balance)
133
- * @param weights.price - Weight for price score (0-1)
134
- * @param weights.reliability - Weight for reliability score (0-1)
135
- * @returns The best balanced bid, or null if array is empty
136
- *
137
- * @example Equal balance (default)
138
- * ```typescript
139
- * import { deployToAkash, selectBalancedBid } from '@kadi.build/deploy-ability/akash';
140
- *
141
- * const result = await deployToAkash({
142
- * wallet,
143
- * certificate,
144
- * projectRoot: './',
145
- * profile: 'production',
146
- * bidSelector: selectBalancedBid // 50/50 price/reliability
147
- * });
148
- * ```
149
- *
150
- * @example Prioritize reliability
151
- * ```typescript
152
- * const result = await deployToAkash({
153
- * wallet,
154
- * certificate,
155
- * projectRoot: './',
156
- * profile: 'critical-prod',
157
- * bidSelector: (bids) => selectBalancedBid(bids, {
158
- * price: 0.3,
159
- * reliability: 0.7
160
- * })
161
- * });
162
- * ```
163
- *
164
- * @example Prioritize cost
165
- * ```typescript
166
- * const result = await deployToAkash({
167
- * wallet,
168
- * certificate,
169
- * projectRoot: './',
170
- * profile: 'dev',
171
- * bidSelector: (bids) => selectBalancedBid(bids, {
172
- * price: 0.8,
173
- * reliability: 0.2
174
- * })
175
- * });
176
- * ```
177
- */
178
- export declare function selectBalancedBid(bids: EnhancedBid[], weights?: {
179
- price: number;
180
- reliability: number;
181
- }): EnhancedBid | null;
182
- /**
183
- * Filter bids by multiple criteria
184
- *
185
- * Apply various filters to narrow down bid options based on price,
186
- * reliability, audit status, location, and provider status.
187
- *
188
- * **All criteria are optional** - only specify the ones you care about.
189
- * Multiple criteria are combined with AND logic (all must match).
190
- *
191
- * **Filtering Philosophy:**
192
- * Use this to establish minimum quality standards, then apply a selection
193
- * strategy to the filtered results. This ensures you never select a provider
194
- * that doesn't meet your requirements, even if they're the cheapest.
195
- *
196
- * @param bids - Array of enhanced bids to filter
197
- * @param criteria - Filtering criteria (all optional)
198
- * @returns Filtered array of bids matching all specified criteria
199
- *
200
- * @example Filter by price and uptime
201
- * ```typescript
202
- * import { filterBids, selectCheapestBid } from '@kadi.build/deploy-ability/akash';
203
- *
204
- * const result = await deployToAkash({
205
- * wallet,
206
- * certificate,
207
- * projectRoot: './',
208
- * profile: 'prod',
209
- * bidSelector: (bids) => {
210
- * // Only providers under $50/month with >95% uptime
211
- * const filtered = filterBids(bids, {
212
- * maxPricePerMonth: { usd: 50, aktPrice: 0.45 },
213
- * minUptime: { value: 0.95, period: '7d' }
214
- * });
215
- * return selectCheapestBid(filtered);
216
- * }
217
- * });
218
- * ```
219
- *
220
- * @example Filter by audit status and location
221
- * ```typescript
222
- * const filtered = filterBids(bids, {
223
- * requireAudited: true,
224
- * preferredRegions: ['US', 'EU'], // Country codes
225
- * requireOnline: true
226
- * });
227
- * ```
228
- *
229
- * @example Price filtering in uAKT
230
- * ```typescript
231
- * const filtered = filterBids(bids, {
232
- * maxPricePerMonth: { uakt: 500_000_000 } // 500M uAKT/month
233
- * });
234
- * ```
235
- */
236
- export declare function filterBids(bids: EnhancedBid[], criteria: {
237
- readonly maxPricePerMonth?: {
238
- uakt: number;
239
- } | {
240
- usd: number;
241
- aktPrice: number;
242
- };
243
- readonly minUptime?: {
244
- value: number;
245
- period: '1d' | '7d' | '30d';
246
- };
247
- readonly requireAudited?: boolean;
248
- readonly preferredRegions?: string[];
249
- readonly requireOnline?: boolean;
250
- }): EnhancedBid[];
251
- //# sourceMappingURL=bid-selectors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bid-selectors.d.ts","sourceRoot":"","sources":["../../../src/targets/akash/bid-selectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,WAAW,GAAG,IAAI,CAQzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,WAAW,EAAE,EACnB,MAAM,GAAE,IAAI,GAAG,IAAI,GAAG,KAAY,GACjC,WAAW,GAAG,IAAI,CAsBpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,WAAW,EAAE,EACnB,OAAO,GAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAqC,GACjF,WAAW,GAAG,IAAI,CAiCpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AACH,wBAAgB,UAAU,CACxB,IAAI,EAAE,WAAW,EAAE,EACnB,QAAQ,EAAE;IACR,QAAQ,CAAC,gBAAgB,CAAC,EACtB;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,GAChB;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,KAAK,CAAA;KAAE,CAAC;IACpE,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,CAAC;CAClC,GACA,WAAW,EAAE,CA+Cf"}
@@ -1,322 +0,0 @@
1
- /**
2
- * Bid Selection Helpers
3
- *
4
- * Provides pre-built selection strategies and filtering utilities for choosing
5
- * providers based on different criteria. These functions can be used directly
6
- * as bidSelectors in the deployment flow, or combined to create custom
7
- * selection logic.
8
- *
9
- * **Selection Strategies:**
10
- * - `selectCheapestBid` - Lowest price (perMonth basis)
11
- * - `selectMostReliableBid` - Highest uptime percentage
12
- * - `selectBalancedBid` - Weighted combination of price and reliability
13
- *
14
- * **Filtering:**
15
- * - `filterBids` - Apply multiple criteria to narrow down options
16
- *
17
- * @module targets/akash/bid-selectors
18
- */
19
- /**
20
- * Select the cheapest bid based on monthly price
21
- *
22
- * Compares all bids and returns the one with the lowest cost per month.
23
- * Useful when price is the primary concern and provider quality is
24
- * less critical (e.g., development/testing deployments).
25
- *
26
- * **Note:** This only considers price, not provider reliability, location,
27
- * or audit status. For production deployments, consider using `filterBids`
28
- * first to ensure minimum quality standards, then select the cheapest
29
- * from the filtered set.
30
- *
31
- * @param bids - Array of enhanced bids to choose from
32
- * @returns The cheapest bid, or null if array is empty
33
- *
34
- * @example
35
- * ```typescript
36
- * import { deployToAkash, selectCheapestBid } from '@kadi.build/deploy-ability/akash';
37
- *
38
- * const result = await deployToAkash({
39
- * wallet,
40
- * certificate,
41
- * projectRoot: './',
42
- * profile: 'dev',
43
- * bidSelector: selectCheapestBid
44
- * });
45
- * ```
46
- *
47
- * @example With quality filtering
48
- * ```typescript
49
- * const result = await deployToAkash({
50
- * wallet,
51
- * certificate,
52
- * projectRoot: './',
53
- * profile: 'prod',
54
- * bidSelector: (bids) => {
55
- * // Only consider audited providers with good uptime
56
- * const qualityBids = filterBids(bids, {
57
- * requireAudited: true,
58
- * minUptime: { value: 0.95, period: '7d' }
59
- * });
60
- * // Then pick cheapest among quality providers
61
- * return selectCheapestBid(qualityBids);
62
- * }
63
- * });
64
- * ```
65
- */
66
- export function selectCheapestBid(bids) {
67
- if (bids.length === 0)
68
- return null;
69
- return bids.reduce((cheapest, current) => current.pricing.uakt.perMonth < cheapest.pricing.uakt.perMonth
70
- ? current
71
- : cheapest);
72
- }
73
- /**
74
- * Select the most reliable provider based on uptime
75
- *
76
- * Chooses the provider with the highest uptime percentage for the specified
77
- * time period. Providers without reliability data are considered last.
78
- *
79
- * **Uptime Periods:**
80
- * - `1d`: Last 24 hours (most recent, but limited sample)
81
- * - `7d`: Last 7 days (good balance, recommended default)
82
- * - `30d`: Last 30 days (long-term stability indicator)
83
- *
84
- * **Fallback Behavior:**
85
- * If no providers have reliability data, returns the first bid from the
86
- * original array (maintains deterministic behavior).
87
- *
88
- * @param bids - Array of enhanced bids to choose from
89
- * @param period - Uptime period to evaluate (default: '7d')
90
- * @returns The most reliable bid, or null if array is empty
91
- *
92
- * @example
93
- * ```typescript
94
- * import { deployToAkash, selectMostReliableBid } from '@kadi.build/deploy-ability/akash';
95
- *
96
- * const result = await deployToAkash({
97
- * wallet,
98
- * certificate,
99
- * projectRoot: './',
100
- * profile: 'production',
101
- * bidSelector: selectMostReliableBid // Uses 7d default
102
- * });
103
- * ```
104
- *
105
- * @example With custom period
106
- * ```typescript
107
- * const result = await deployToAkash({
108
- * wallet,
109
- * certificate,
110
- * projectRoot: './',
111
- * profile: 'production',
112
- * bidSelector: (bids) => selectMostReliableBid(bids, '30d')
113
- * });
114
- * ```
115
- */
116
- export function selectMostReliableBid(bids, period = '7d') {
117
- if (bids.length === 0)
118
- return null;
119
- // Filter bids that have reliability data
120
- const withReliability = bids.filter((bid) => bid.provider.reliability !== undefined);
121
- // If no providers have reliability data, return first bid
122
- if (withReliability.length === 0) {
123
- return bids[0] ?? null;
124
- }
125
- // Determine uptime key based on period
126
- const uptimeKey = `uptime${period}`;
127
- // Find provider with highest uptime
128
- return withReliability.reduce((best, current) => {
129
- const bestUptime = best.provider.reliability[uptimeKey];
130
- const currentUptime = current.provider.reliability[uptimeKey];
131
- return currentUptime > bestUptime ? current : best;
132
- });
133
- }
134
- /**
135
- * Select bid using balanced scoring (price + reliability)
136
- *
137
- * Calculates a composite score for each bid based on normalized price
138
- * and reliability metrics, then selects the highest-scoring option.
139
- *
140
- * **Scoring Methodology:**
141
- * - Price score: Normalized 0-1 (lower price = higher score)
142
- * - Reliability score: Uptime percentage (0-1)
143
- * - Total score = (price score × price weight) + (reliability score × reliability weight)
144
- *
145
- * **Default Weights:**
146
- * Equal balance (0.5 each) - adjust based on your priorities.
147
- *
148
- * **Use Cases:**
149
- * - Production deployments where both cost and reliability matter
150
- * - Finding "best value" providers (good balance of quality and price)
151
- * - Avoiding both the cheapest-but-unreliable and expensive-but-reliable extremes
152
- *
153
- * @param bids - Array of enhanced bids to choose from
154
- * @param weights - Scoring weights (default: equal balance)
155
- * @param weights.price - Weight for price score (0-1)
156
- * @param weights.reliability - Weight for reliability score (0-1)
157
- * @returns The best balanced bid, or null if array is empty
158
- *
159
- * @example Equal balance (default)
160
- * ```typescript
161
- * import { deployToAkash, selectBalancedBid } from '@kadi.build/deploy-ability/akash';
162
- *
163
- * const result = await deployToAkash({
164
- * wallet,
165
- * certificate,
166
- * projectRoot: './',
167
- * profile: 'production',
168
- * bidSelector: selectBalancedBid // 50/50 price/reliability
169
- * });
170
- * ```
171
- *
172
- * @example Prioritize reliability
173
- * ```typescript
174
- * const result = await deployToAkash({
175
- * wallet,
176
- * certificate,
177
- * projectRoot: './',
178
- * profile: 'critical-prod',
179
- * bidSelector: (bids) => selectBalancedBid(bids, {
180
- * price: 0.3,
181
- * reliability: 0.7
182
- * })
183
- * });
184
- * ```
185
- *
186
- * @example Prioritize cost
187
- * ```typescript
188
- * const result = await deployToAkash({
189
- * wallet,
190
- * certificate,
191
- * projectRoot: './',
192
- * profile: 'dev',
193
- * bidSelector: (bids) => selectBalancedBid(bids, {
194
- * price: 0.8,
195
- * reliability: 0.2
196
- * })
197
- * });
198
- * ```
199
- */
200
- export function selectBalancedBid(bids, weights = { price: 0.5, reliability: 0.5 }) {
201
- if (bids.length === 0)
202
- return null;
203
- // Calculate price range for normalization
204
- const prices = bids.map((bid) => bid.pricing.uakt.perMonth);
205
- const minPrice = Math.min(...prices);
206
- const maxPrice = Math.max(...prices);
207
- const priceRange = maxPrice - minPrice;
208
- // Calculate scores for each bid
209
- const scored = bids.map((bid) => {
210
- // Price score: 1.0 for cheapest, 0.0 for most expensive
211
- // Handle case where all bids have same price
212
- const priceScore = priceRange === 0
213
- ? 1.0
214
- : 1.0 - (bid.pricing.uakt.perMonth - minPrice) / priceRange;
215
- // Reliability score: uptime7d (0.0 to 1.0)
216
- // Default to 0.5 if no reliability data available
217
- const reliabilityScore = bid.provider.reliability?.uptime7d ?? 0.5;
218
- // Weighted total score
219
- const totalScore = priceScore * weights.price + reliabilityScore * weights.reliability;
220
- return { bid, score: totalScore };
221
- });
222
- // Return bid with highest score
223
- return scored.reduce((best, current) => current.score > best.score ? current : best).bid;
224
- }
225
- /**
226
- * Filter bids by multiple criteria
227
- *
228
- * Apply various filters to narrow down bid options based on price,
229
- * reliability, audit status, location, and provider status.
230
- *
231
- * **All criteria are optional** - only specify the ones you care about.
232
- * Multiple criteria are combined with AND logic (all must match).
233
- *
234
- * **Filtering Philosophy:**
235
- * Use this to establish minimum quality standards, then apply a selection
236
- * strategy to the filtered results. This ensures you never select a provider
237
- * that doesn't meet your requirements, even if they're the cheapest.
238
- *
239
- * @param bids - Array of enhanced bids to filter
240
- * @param criteria - Filtering criteria (all optional)
241
- * @returns Filtered array of bids matching all specified criteria
242
- *
243
- * @example Filter by price and uptime
244
- * ```typescript
245
- * import { filterBids, selectCheapestBid } from '@kadi.build/deploy-ability/akash';
246
- *
247
- * const result = await deployToAkash({
248
- * wallet,
249
- * certificate,
250
- * projectRoot: './',
251
- * profile: 'prod',
252
- * bidSelector: (bids) => {
253
- * // Only providers under $50/month with >95% uptime
254
- * const filtered = filterBids(bids, {
255
- * maxPricePerMonth: { usd: 50, aktPrice: 0.45 },
256
- * minUptime: { value: 0.95, period: '7d' }
257
- * });
258
- * return selectCheapestBid(filtered);
259
- * }
260
- * });
261
- * ```
262
- *
263
- * @example Filter by audit status and location
264
- * ```typescript
265
- * const filtered = filterBids(bids, {
266
- * requireAudited: true,
267
- * preferredRegions: ['US', 'EU'], // Country codes
268
- * requireOnline: true
269
- * });
270
- * ```
271
- *
272
- * @example Price filtering in uAKT
273
- * ```typescript
274
- * const filtered = filterBids(bids, {
275
- * maxPricePerMonth: { uakt: 500_000_000 } // 500M uAKT/month
276
- * });
277
- * ```
278
- */
279
- export function filterBids(bids, criteria) {
280
- return bids.filter((bid) => {
281
- // Price filter
282
- if (criteria.maxPricePerMonth) {
283
- const maxPrice = 'uakt' in criteria.maxPricePerMonth
284
- ? criteria.maxPricePerMonth.uakt
285
- : bid.pricing.toUSD(criteria.maxPricePerMonth.aktPrice).perMonth;
286
- const bidPrice = 'uakt' in criteria.maxPricePerMonth
287
- ? bid.pricing.uakt.perMonth
288
- : bid.pricing.toUSD(criteria.maxPricePerMonth.aktPrice).perMonth;
289
- if (bidPrice > maxPrice)
290
- return false;
291
- }
292
- // Uptime filter
293
- if (criteria.minUptime) {
294
- const { value, period } = criteria.minUptime;
295
- const uptimeKey = `uptime${period}`;
296
- const uptime = bid.provider.reliability?.[uptimeKey];
297
- // If no reliability data, exclude this bid
298
- if (uptime === undefined || uptime < value)
299
- return false;
300
- }
301
- // Audit status filter
302
- if (criteria.requireAudited && !bid.provider.isAudited) {
303
- return false;
304
- }
305
- // Region filter
306
- if (criteria.preferredRegions && criteria.preferredRegions.length > 0) {
307
- const countryCode = bid.provider.location?.countryCode;
308
- if (!countryCode || !criteria.preferredRegions.includes(countryCode)) {
309
- return false;
310
- }
311
- }
312
- // Online status filter
313
- if (criteria.requireOnline) {
314
- const isOnline = bid.provider.reliability?.isOnline;
315
- if (isOnline !== true)
316
- return false;
317
- }
318
- // All filters passed
319
- return true;
320
- });
321
- }
322
- //# sourceMappingURL=bid-selectors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bid-selectors.js","sourceRoot":"","sources":["../../../src/targets/akash/bid-selectors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAmB;IACnD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAEnC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,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