@meltstudio/meltctl 5.7.0 → 5.7.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 (2) hide show
  1. package/dist/index.js +97 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7450,7 +7450,7 @@ var CLI_VERSION;
7450
7450
  var init_version = __esm({
7451
7451
  "src/utils/version.ts"() {
7452
7452
  "use strict";
7453
- CLI_VERSION = "5.7.0";
7453
+ CLI_VERSION = "5.7.1";
7454
7454
  }
7455
7455
  });
7456
7456
 
@@ -26559,8 +26559,10 @@ function createPlansResource(config2) {
26559
26559
  method: "POST",
26560
26560
  body: JSON.stringify(input)
26561
26561
  });
26562
- if (status !== 201 && status !== 200)
26563
- throw new Error(data.error ?? `Failed to submit plan (${status})`);
26562
+ if (status !== 201 && status !== 200) {
26563
+ const base = data.error ?? `Failed to submit plan (${status})`;
26564
+ throw new Error(data.details ? `${base} \u2014 ${data.details}` : base);
26565
+ }
26564
26566
  return data;
26565
26567
  },
26566
26568
  async list(filters) {
@@ -27886,17 +27888,52 @@ function createProfileAuditsResource(config2) {
27886
27888
  }
27887
27889
 
27888
27890
  // ../sdk/dist/client.js
27891
+ var DEFAULT_TIMEOUT_MS = 1e4;
27892
+ var RETRYABLE_STATUS = /* @__PURE__ */ new Set([502, 503, 504]);
27893
+ function delay(ms) {
27894
+ return new Promise((resolve) => setTimeout(resolve, ms));
27895
+ }
27896
+ function buildSignal(timeoutMs, caller) {
27897
+ const timeout = AbortSignal.timeout(timeoutMs);
27898
+ if (!caller)
27899
+ return timeout;
27900
+ const anyFn = AbortSignal.any;
27901
+ return anyFn ? anyFn([caller, timeout]) : timeout;
27902
+ }
27889
27903
  async function apiFetch(config2, path9, options = {}) {
27890
- const response = await fetch(`${config2.baseUrl}${path9}`, {
27891
- ...options,
27892
- headers: {
27893
- Authorization: `Bearer ${config2.token}`,
27894
- "Content-Type": "application/json",
27895
- ...options.headers
27904
+ const method = (options.method ?? "GET").toUpperCase();
27905
+ const idempotent = method === "GET" || method === "HEAD";
27906
+ const timeoutMs = config2.timeoutMs ?? DEFAULT_TIMEOUT_MS;
27907
+ const maxAttempts = idempotent ? 2 : 1;
27908
+ let lastError;
27909
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
27910
+ try {
27911
+ const response = await fetch(`${config2.baseUrl}${path9}`, {
27912
+ ...options,
27913
+ signal: buildSignal(timeoutMs, options.signal),
27914
+ headers: {
27915
+ Authorization: `Bearer ${config2.token}`,
27916
+ "Content-Type": "application/json",
27917
+ ...options.headers
27918
+ }
27919
+ });
27920
+ if (idempotent && attempt < maxAttempts && RETRYABLE_STATUS.has(response.status)) {
27921
+ lastError = new Error(`Upstream ${response.status}`);
27922
+ await delay(250 * attempt);
27923
+ continue;
27924
+ }
27925
+ const data = await response.json();
27926
+ return { data, status: response.status };
27927
+ } catch (err) {
27928
+ lastError = err;
27929
+ if (idempotent && attempt < maxAttempts) {
27930
+ await delay(250 * attempt);
27931
+ continue;
27932
+ }
27933
+ throw err;
27896
27934
  }
27897
- });
27898
- const data = await response.json();
27899
- return { data, status: response.status };
27935
+ }
27936
+ throw lastError;
27900
27937
  }
27901
27938
  function createMeltClient(config2) {
27902
27939
  return {
@@ -52869,8 +52906,10 @@ function createPlansResource2(config2) {
52869
52906
  method: "POST",
52870
52907
  body: JSON.stringify(input)
52871
52908
  });
52872
- if (status !== 201 && status !== 200)
52873
- throw new Error(data.error ?? `Failed to submit plan (${status})`);
52909
+ if (status !== 201 && status !== 200) {
52910
+ const base = data.error ?? `Failed to submit plan (${status})`;
52911
+ throw new Error(data.details ? `${base} \u2014 ${data.details}` : base);
52912
+ }
52874
52913
  return data;
52875
52914
  },
52876
52915
  async list(filters) {
@@ -54156,17 +54195,52 @@ function createProfileAuditsResource2(config2) {
54156
54195
  }
54157
54196
  };
54158
54197
  }
54198
+ var DEFAULT_TIMEOUT_MS2 = 1e4;
54199
+ var RETRYABLE_STATUS2 = /* @__PURE__ */ new Set([502, 503, 504]);
54200
+ function delay2(ms) {
54201
+ return new Promise((resolve) => setTimeout(resolve, ms));
54202
+ }
54203
+ function buildSignal2(timeoutMs, caller) {
54204
+ const timeout = AbortSignal.timeout(timeoutMs);
54205
+ if (!caller)
54206
+ return timeout;
54207
+ const anyFn = AbortSignal.any;
54208
+ return anyFn ? anyFn([caller, timeout]) : timeout;
54209
+ }
54159
54210
  async function apiFetch2(config2, path22, options = {}) {
54160
- const response = await fetch(`${config2.baseUrl}${path22}`, {
54161
- ...options,
54162
- headers: {
54163
- Authorization: `Bearer ${config2.token}`,
54164
- "Content-Type": "application/json",
54165
- ...options.headers
54211
+ const method = (options.method ?? "GET").toUpperCase();
54212
+ const idempotent = method === "GET" || method === "HEAD";
54213
+ const timeoutMs = config2.timeoutMs ?? DEFAULT_TIMEOUT_MS2;
54214
+ const maxAttempts = idempotent ? 2 : 1;
54215
+ let lastError;
54216
+ for (let attempt = 1; attempt <= maxAttempts; attempt++) {
54217
+ try {
54218
+ const response = await fetch(`${config2.baseUrl}${path22}`, {
54219
+ ...options,
54220
+ signal: buildSignal2(timeoutMs, options.signal),
54221
+ headers: {
54222
+ Authorization: `Bearer ${config2.token}`,
54223
+ "Content-Type": "application/json",
54224
+ ...options.headers
54225
+ }
54226
+ });
54227
+ if (idempotent && attempt < maxAttempts && RETRYABLE_STATUS2.has(response.status)) {
54228
+ lastError = new Error(`Upstream ${response.status}`);
54229
+ await delay2(250 * attempt);
54230
+ continue;
54231
+ }
54232
+ const data = await response.json();
54233
+ return { data, status: response.status };
54234
+ } catch (err) {
54235
+ lastError = err;
54236
+ if (idempotent && attempt < maxAttempts) {
54237
+ await delay2(250 * attempt);
54238
+ continue;
54239
+ }
54240
+ throw err;
54166
54241
  }
54167
- });
54168
- const data = await response.json();
54169
- return { data, status: response.status };
54242
+ }
54243
+ throw lastError;
54170
54244
  }
54171
54245
  function createMeltClient2(config2) {
54172
54246
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltstudio/meltctl",
3
- "version": "5.7.0",
3
+ "version": "5.7.1",
4
4
  "description": "AI-first development tooling for Melt teams — companion CLI for the org-distributed Claude Code dev skills",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",