@le-space/core 0.6.42 → 0.6.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +13 -1
- package/index.js +29 -1
- package/package.json +3 -3
package/index.d.ts
CHANGED
|
@@ -899,7 +899,19 @@ declare function waitForVmBootstrapConfigSignal(args: {
|
|
|
899
899
|
attempts?: number;
|
|
900
900
|
delayMs?: number;
|
|
901
901
|
sleep?: (ms: number) => Promise<void>;
|
|
902
|
+
shouldAbort?: () => Promise<boolean>;
|
|
902
903
|
}): Promise<VmBootstrapConfigSignalRecord | null>;
|
|
904
|
+
/**
|
|
905
|
+
* True when the CRN's execution list does NOT contain the instance —
|
|
906
|
+
* i.e. the CRN accepted the allocation but never scheduled the VM
|
|
907
|
+
* (relay-button#83, the ~9-minute silent-failure mode). "unknown" errors
|
|
908
|
+
* (endpoint unreachable, schema surprises) never count as absent.
|
|
909
|
+
*/
|
|
910
|
+
declare function crnExecutionAbsent(args: {
|
|
911
|
+
crnUrl: string | null | undefined;
|
|
912
|
+
itemHash: string;
|
|
913
|
+
fetch: JsonFetchLike$1;
|
|
914
|
+
}): Promise<boolean>;
|
|
903
915
|
|
|
904
916
|
type JsonFetchLike = FetchLike;
|
|
905
917
|
type RelayMetadataShape = {
|
|
@@ -967,4 +979,4 @@ declare function reconcileOwnerRelayBootstrapRegistrations(args: {
|
|
|
967
979
|
} | null;
|
|
968
980
|
}): Promise<OwnerRelayBootstrapReconcileResult>;
|
|
969
981
|
|
|
970
|
-
export { type CrnCapacitySpec, type CrnEraseResult, type CrnResolutionResult, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike$1 as JsonFetchLike, type JsonFetchLikeResponse, type OwnerRelayBootstrapReconcileResult, type PaymentQuote, type RelayBootstrapPublicationResult, type RelayBootstrapVisibilityResult, type RelayMetadataShape, type RetentionRecord, SSH_PUBLIC_KEY_PATTERN, SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY, type TcpProbeResult, type TierSpec, VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY, VM_BOOTSTRAP_CONFIG_HISTORY_RETENTION_MS, VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE, VM_BOOTSTRAP_CONFIG_SIGNAL_REF, appendDeploymentTokenToSshPublicKey, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, configureOrbitdbRelaySetup, configureUcGoPeer, configureUcanStore, createDeploymentIntent, createDeploymentToken, createInstanceContent, createPortForwardAggregateContent, createRelayBootstrapRegistrationId, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, createVmBootstrapConfigAggregateContent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, eraseInstanceOnCrn, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmBootstrapConfigSignals, fetchVmRuntime, filterDeployableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isTransientMessageLookupError, isValidSshPublicKey, listGeocodedCrns, listStaleVmBootstrapConfigAggregateMessageHashes, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, publishRelayBootstrapRegistration, publishVmBootstrapConfig, quoteRequiredBudgetUnits, rankCandidateCrns, reconcileOwnerRelayBootstrapRegistrations, requestedPortFlags, requiredInstancePortForwards, resolveInstanceCrn, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForRelayBootstrapRegistration, waitForSetupEndpoint, waitForVmBootstrapConfigSignal, waitForVmRuntime };
|
|
982
|
+
export { type CrnCapacitySpec, type CrnEraseResult, type CrnResolutionResult, DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike$1 as JsonFetchLike, type JsonFetchLikeResponse, type OwnerRelayBootstrapReconcileResult, type PaymentQuote, type RelayBootstrapPublicationResult, type RelayBootstrapVisibilityResult, type RelayMetadataShape, type RetentionRecord, SSH_PUBLIC_KEY_PATTERN, SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY, type TcpProbeResult, type TierSpec, VM_BOOTSTRAP_CONFIG_AGGREGATE_KEY, VM_BOOTSTRAP_CONFIG_HISTORY_RETENTION_MS, VM_BOOTSTRAP_CONFIG_SIGNAL_POST_TYPE, VM_BOOTSTRAP_CONFIG_SIGNAL_REF, appendDeploymentTokenToSshPublicKey, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, configureOrbitdbRelaySetup, configureUcGoPeer, configureUcanStore, createDeploymentIntent, createDeploymentToken, createInstanceContent, createPortForwardAggregateContent, createRelayBootstrapRegistrationId, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, createVmBootstrapConfigAggregateContent, crnExecutionAbsent, deleteVmBootstrapConfig, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, eraseInstanceOnCrn, extractInsufficientBalanceMessage, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchRelayMetadataForRuntime, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmBootstrapConfigAggregate, fetchVmBootstrapConfigSignals, fetchVmRuntime, filterDeployableCrns, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isTransientMessageLookupError, isValidSshPublicKey, listGeocodedCrns, listStaleVmBootstrapConfigAggregateMessageHashes, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, notifyCrnAllocationWithRetry, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, publishRelayBootstrapRegistration, publishVmBootstrapConfig, quoteRequiredBudgetUnits, rankCandidateCrns, reconcileOwnerRelayBootstrapRegistrations, requestedPortFlags, requiredInstancePortForwards, resolveInstanceCrn, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForRelayBootstrapRegistration, waitForSetupEndpoint, waitForVmBootstrapConfigSignal, waitForVmRuntime };
|
package/index.js
CHANGED
|
@@ -256,6 +256,15 @@ function scoreSortedCrns(crns) {
|
|
|
256
256
|
return leftName.localeCompare(rightName);
|
|
257
257
|
});
|
|
258
258
|
}
|
|
259
|
+
var TOP_CRN_POOL_SIZE = 5;
|
|
260
|
+
function shuffleTopPool(sorted, poolSize = TOP_CRN_POOL_SIZE) {
|
|
261
|
+
const pool = sorted.slice(0, poolSize);
|
|
262
|
+
for (let i = pool.length - 1; i > 0; i--) {
|
|
263
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
264
|
+
[pool[i], pool[j]] = [pool[j], pool[i]];
|
|
265
|
+
}
|
|
266
|
+
return [...pool, ...sorted.slice(poolSize)];
|
|
267
|
+
}
|
|
259
268
|
function filterDeployableCrns(crns, options = {}) {
|
|
260
269
|
return scoreSortedCrns(
|
|
261
270
|
compatibleCrns(crns, options.excludedHashes).filter((crn) => hasCrnCapacity(crn, options.spec))
|
|
@@ -368,7 +377,7 @@ async function rankCandidateCrns(crns, options) {
|
|
|
368
377
|
excludedHashes: options.excludedHashes
|
|
369
378
|
});
|
|
370
379
|
if (!preferredCountryCode || sortedCrns.length === 0) {
|
|
371
|
-
return sortedCrns;
|
|
380
|
+
return shuffleTopPool(sortedCrns);
|
|
372
381
|
}
|
|
373
382
|
const enrichedTopCrns = await enrichCrnsWithGeo(sortedCrns.slice(0, geoLimit), options);
|
|
374
383
|
const mergedByHash = new Map(enrichedTopCrns.map((crn) => [crn.hash, crn]));
|
|
@@ -3368,12 +3377,30 @@ async function waitForVmBootstrapConfigSignal(args) {
|
|
|
3368
3377
|
}).catch(() => []);
|
|
3369
3378
|
const match = signals.find((entry) => entry.status === expectedStatus) ?? null;
|
|
3370
3379
|
if (match) return match;
|
|
3380
|
+
if (args.shouldAbort && await args.shouldAbort().catch(() => false)) {
|
|
3381
|
+
return null;
|
|
3382
|
+
}
|
|
3371
3383
|
if (attempt < attempts - 1) {
|
|
3372
3384
|
await sleep2(delayMs);
|
|
3373
3385
|
}
|
|
3374
3386
|
}
|
|
3375
3387
|
return null;
|
|
3376
3388
|
}
|
|
3389
|
+
async function crnExecutionAbsent(args) {
|
|
3390
|
+
const base = String(args.crnUrl ?? "").trim();
|
|
3391
|
+
if (!base) return false;
|
|
3392
|
+
try {
|
|
3393
|
+
const response = await args.fetch(new URL("/about/executions/list", base).toString(), {
|
|
3394
|
+
cache: "no-store"
|
|
3395
|
+
});
|
|
3396
|
+
if (!response.ok) return false;
|
|
3397
|
+
const payload = await response.json();
|
|
3398
|
+
if (!payload || typeof payload !== "object") return false;
|
|
3399
|
+
return !(args.itemHash in payload);
|
|
3400
|
+
} catch {
|
|
3401
|
+
return false;
|
|
3402
|
+
}
|
|
3403
|
+
}
|
|
3377
3404
|
|
|
3378
3405
|
// src/bootstrap-reconcile.ts
|
|
3379
3406
|
function createRelayBootstrapRegistrationId(profile, instanceName, itemHash) {
|
|
@@ -3598,6 +3625,7 @@ export {
|
|
|
3598
3625
|
createUnsignedForgetMessage,
|
|
3599
3626
|
createUnsignedInstanceMessage,
|
|
3600
3627
|
createVmBootstrapConfigAggregateContent,
|
|
3628
|
+
crnExecutionAbsent,
|
|
3601
3629
|
deleteVmBootstrapConfig,
|
|
3602
3630
|
deployInstance,
|
|
3603
3631
|
describeRejectedDeployment,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.44",
|
|
4
4
|
"description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"url": "https://github.com/NiKrause/relay-button/issues"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@le-space/aleph-bootstrap": "0.6.
|
|
28
|
-
"@le-space/shared-types": "0.6.
|
|
27
|
+
"@le-space/aleph-bootstrap": "0.6.44",
|
|
28
|
+
"@le-space/shared-types": "0.6.44"
|
|
29
29
|
}
|
|
30
30
|
}
|