warpmetal 0.8.4 → 0.8.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/installer.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "warpmetal",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Agent-safe CLI and skill for purchasing, renewing, and managing WarpMetal VPS servers",
5
5
  "type": "module",
6
6
  "bin": {
package/src/installer.js CHANGED
@@ -123,6 +123,14 @@ function validateArtifact(artifact) {
123
123
  return { ...artifact, url: url.toString() };
124
124
  }
125
125
 
126
+ function serverAllowsRuntimeInstall(server, currentTime = Date.now()) {
127
+ if (!server?.publicIp) return false;
128
+ if (server.state === "ready") return true;
129
+ if (!["cancellation_pending", "cancelled"].includes(server.state)) return false;
130
+ const termEndsAt = Date.parse(server.termEndsAt || "");
131
+ return Number.isFinite(termEndsAt) && termEndsAt > currentTime;
132
+ }
133
+
126
134
  export function verifyRuntimeArtifact(content, metadata) {
127
135
  const artifact = validateArtifact(metadata);
128
136
  const digest = createHash("sha256").update(content).digest("hex");
@@ -270,8 +278,8 @@ export async function installRuntime({
270
278
  throw new CliError("The server ID is invalid.", { exitCode: 2 });
271
279
  }
272
280
  const server = (await client.getServer(serverId, token)).data?.task;
273
- if (server?.state !== "ready" || !server.publicIp) {
274
- throw new CliError("The VPS must be ready before runtime installation.", {
281
+ if (!serverAllowsRuntimeInstall(server)) {
282
+ throw new CliError("The VPS must be ready and within its active paid term before runtime installation.", {
275
283
  exitCode: 5,
276
284
  });
277
285
  }