@datarails-ai/dr-cli 1.6.112 → 1.6.113

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/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ import { fileURLToPath as fileURLToPath3 } from "url";
8
8
  // package.json
9
9
  var package_default = {
10
10
  name: "@datarails-ai/dr-cli",
11
- version: "1.6.112",
11
+ version: "1.6.113",
12
12
  description: "Datarails CLI",
13
13
  type: "module",
14
14
  engines: {
@@ -69,7 +69,7 @@ var package_default = {
69
69
  };
70
70
 
71
71
  // src/buildInfo.ts
72
- var BUILD_TIME = "2026-10-08T11:22:19.091Z";
72
+ var BUILD_TIME = "2026-10-09T10:02:15.002Z";
73
73
  function formatBuildTime(iso) {
74
74
  if (iso === "") return "";
75
75
  const d = new Date(iso);
@@ -371,10 +371,10 @@ function credentialsFilePath() {
371
371
  const override = process.env[CREDENTIALS_FILE_ENV];
372
372
  return override !== void 0 && override !== "" ? override : DEFAULT_CREDENTIALS_FILE;
373
373
  }
374
- async function readCredentialsFile(path11) {
374
+ async function readCredentialsFile(path12) {
375
375
  let raw;
376
376
  try {
377
- raw = await readFile(path11, "utf8");
377
+ raw = await readFile(path12, "utf8");
378
378
  } catch (err) {
379
379
  if (err.code === "ENOENT") return void 0;
380
380
  throw err;
@@ -383,17 +383,17 @@ async function readCredentialsFile(path11) {
383
383
  try {
384
384
  parsed2 = JSON.parse(raw);
385
385
  } catch {
386
- throw new Error(`credential file ${path11} is not valid JSON`);
386
+ throw new Error(`credential file ${path12} is not valid JSON`);
387
387
  }
388
388
  try {
389
389
  return credentialsFileSchema.parse(parsed2);
390
390
  } catch (err) {
391
391
  const reason = err instanceof Error ? err.message : String(err);
392
- throw new Error(`credential file ${path11} is malformed: ${reason}`, { cause: err });
392
+ throw new Error(`credential file ${path12} is malformed: ${reason}`, { cause: err });
393
393
  }
394
394
  }
395
- async function writeCredentialsFile(path11, creds) {
396
- await mkdir(dirname(path11), { recursive: true, mode: 448 });
395
+ async function writeCredentialsFile(path12, creds) {
396
+ await mkdir(dirname(path12), { recursive: true, mode: 448 });
397
397
  let next;
398
398
  try {
399
399
  next = credentialsFileSchema.parse({
@@ -402,15 +402,15 @@ async function writeCredentialsFile(path11, creds) {
402
402
  });
403
403
  } catch (err) {
404
404
  const reason = err instanceof Error ? err.message : String(err);
405
- throw new Error(`refusing to write an unreadable credential file ${path11}: ${reason}`, {
405
+ throw new Error(`refusing to write an unreadable credential file ${path12}: ${reason}`, {
406
406
  cause: err
407
407
  });
408
408
  }
409
409
  const body = JSON.stringify(next, null, 2);
410
- const tmp = `${path11}.${process.pid}.tmp`;
410
+ const tmp = `${path12}.${process.pid}.tmp`;
411
411
  await writeFile(tmp, body, { mode: 384 });
412
412
  await chmod(tmp, 384);
413
- await rename(tmp, path11);
413
+ await rename(tmp, path12);
414
414
  }
415
415
 
416
416
  // src/auth/types.ts
@@ -580,10 +580,10 @@ var ScopeDeniedError = class extends Error {
580
580
  * credential, not the `--server`/`--account` one. Named, the message points `dr whoami`
581
581
  * at it; omitted, "this identity" is the one the reader just ran the command as.
582
582
  */
583
- constructor(method, path11, code, required2, identity2) {
583
+ constructor(method, path12, code, required2, identity2) {
584
584
  super("");
585
585
  this.method = method;
586
- this.path = path11;
586
+ this.path = path12;
587
587
  this.code = code;
588
588
  this.identity = identity2;
589
589
  this.name = "ScopeDeniedError";
@@ -2172,12 +2172,12 @@ var AuthorizedClient = class _AuthorizedClient {
2172
2172
  * Relative paths are prefixed with {@link AuthorizedClient.host}; absolute
2173
2173
  * `http(s)://` URLs pass through unchanged. Mirrors `client.go:79-94` `Do`.
2174
2174
  */
2175
- async do(method, path11, body, options) {
2175
+ async do(method, path12, body, options) {
2176
2176
  const sentBearer = this.hasBearer();
2177
- let res = await this.doWithAuth(method, path11, body, options, true);
2178
- await _AuthorizedClient.throwIfScopeDenied(method, path11, res);
2177
+ let res = await this.doWithAuth(method, path12, body, options, true);
2178
+ await _AuthorizedClient.throwIfScopeDenied(method, path12, res);
2179
2179
  if (this.isAuthRejected(res) && sentBearer && !this.isCookieless()) {
2180
- res = await this.doWithAuth(method, path11, body, options, false);
2180
+ res = await this.doWithAuth(method, path12, body, options, false);
2181
2181
  }
2182
2182
  if (this.isAuthRejected(res)) {
2183
2183
  try {
@@ -2186,11 +2186,11 @@ var AuthorizedClient = class _AuthorizedClient {
2186
2186
  host: this._authHost
2187
2187
  });
2188
2188
  this._session = fresh;
2189
- res = await this.doWithAuth(method, path11, body, options, true);
2189
+ res = await this.doWithAuth(method, path12, body, options, true);
2190
2190
  } catch (err) {
2191
2191
  _AuthorizedClient.logRefreshFailure("post-401 force-refresh", err);
2192
2192
  }
2193
- await _AuthorizedClient.throwIfScopeDenied(method, path11, res);
2193
+ await _AuthorizedClient.throwIfScopeDenied(method, path12, res);
2194
2194
  }
2195
2195
  if (!this.isAuthRejected(res) && res.ok) {
2196
2196
  try {
@@ -2227,11 +2227,11 @@ var AuthorizedClient = class _AuthorizedClient {
2227
2227
  *
2228
2228
  * @internal
2229
2229
  */
2230
- async doWithAuth(method, path11, body, options, includeBearer) {
2230
+ async doWithAuth(method, path12, body, options, includeBearer) {
2231
2231
  if (includeBearer) {
2232
2232
  await this.ensureFreshAuth(JWT_REFRESH_BUFFER_MS, options?.signal);
2233
2233
  }
2234
- const url = this.resolveUrl(path11);
2234
+ const url = this.resolveUrl(path12);
2235
2235
  const headers = new Headers();
2236
2236
  const hasBody = body !== void 0 && body !== null;
2237
2237
  this.applyAuthHeaders(headers, hasBody, includeBearer);
@@ -2258,37 +2258,37 @@ var AuthorizedClient = class _AuthorizedClient {
2258
2258
  * empty bodies (incl. 204 and `""`). Throws on non-2xx with the truncated
2259
2259
  * body in the message. Mirrors `client.go:137-138` + `doJSON` happy path.
2260
2260
  */
2261
- async getJSON(path11, options) {
2262
- return this.requestJson("GET", path11, void 0, options);
2261
+ async getJSON(path12, options) {
2262
+ return this.requestJson("GET", path12, void 0, options);
2263
2263
  }
2264
2264
  /**
2265
2265
  * Issues a `POST` with `payload` JSON-encoded as the body and decodes the
2266
2266
  * JSON response into `T`. Mirrors `client.go:142` `PostJSON`.
2267
2267
  */
2268
- async postJSON(path11, payload, options) {
2269
- return this.requestJson("POST", path11, payload, options);
2268
+ async postJSON(path12, payload, options) {
2269
+ return this.requestJson("POST", path12, payload, options);
2270
2270
  }
2271
2271
  /**
2272
2272
  * Issues a `PUT` with `payload` JSON-encoded as the body and decodes the
2273
2273
  * JSON response into `T`. Mirrors `client.go:148` `PutJSON`.
2274
2274
  */
2275
- async putJSON(path11, payload, options) {
2276
- return this.requestJson("PUT", path11, payload, options);
2275
+ async putJSON(path12, payload, options) {
2276
+ return this.requestJson("PUT", path12, payload, options);
2277
2277
  }
2278
2278
  /**
2279
2279
  * Issues a `PATCH` with `payload` JSON-encoded as the body and decodes the
2280
2280
  * JSON response into `T`. Symmetric with {@link AuthorizedClient.putJSON}.
2281
2281
  */
2282
- async patchJSON(path11, payload, options) {
2283
- return this.requestJson("PATCH", path11, payload, options);
2282
+ async patchJSON(path12, payload, options) {
2283
+ return this.requestJson("PATCH", path12, payload, options);
2284
2284
  }
2285
2285
  /**
2286
2286
  * Issues a `DELETE` (no body) and decodes the JSON response into `T`.
2287
2287
  * Mirrors `client.go:154` `DeleteJSON`. Callers needing a DELETE-with-body
2288
2288
  * should drop down to {@link AuthorizedClient.do} directly.
2289
2289
  */
2290
- async deleteJSON(path11, options) {
2291
- return this.requestJson("DELETE", path11, void 0, options);
2290
+ async deleteJSON(path12, options) {
2291
+ return this.requestJson("DELETE", path12, void 0, options);
2292
2292
  }
2293
2293
  /**
2294
2294
  * Issues a `POST` with a `multipart/form-data` body composed of `fields`
@@ -2318,7 +2318,7 @@ var AuthorizedClient = class _AuthorizedClient {
2318
2318
  * passed as `body`, mirroring Go's `writer.FormDataContentType()` override
2319
2319
  * at `client.go:191`.
2320
2320
  */
2321
- async postMultipart(path11, fields, file, options) {
2321
+ async postMultipart(path12, fields, file, options) {
2322
2322
  const fd = new FormData();
2323
2323
  for (const [k, v] of Object.entries(fields)) {
2324
2324
  fd.set(k, v);
@@ -2332,7 +2332,7 @@ var AuthorizedClient = class _AuthorizedClient {
2332
2332
  fd.set(options.fileFieldName, file, options.filename);
2333
2333
  }
2334
2334
  await this.ensureFreshAuth(JWT_REFRESH_BUFFER_MS, options?.signal);
2335
- const url = this.resolveUrl(path11);
2335
+ const url = this.resolveUrl(path12);
2336
2336
  const headers = new Headers();
2337
2337
  this.applyAuthHeaders(headers, true, true);
2338
2338
  headers.delete("Content-Type");
@@ -2343,19 +2343,19 @@ var AuthorizedClient = class _AuthorizedClient {
2343
2343
  signal: options?.signal
2344
2344
  });
2345
2345
  const text2 = await res.text();
2346
- _AuthorizedClient.throwIfScopeDeniedBody("POST", path11, res.status, text2);
2346
+ _AuthorizedClient.throwIfScopeDeniedBody("POST", path12, res.status, text2);
2347
2347
  if (res.status === 401 || res.status === 403) {
2348
- throw new SessionExpiredError(`POST ${path11} (HTTP ${res.status})`);
2348
+ throw new SessionExpiredError(`POST ${path12} (HTTP ${res.status})`);
2349
2349
  }
2350
2350
  if (res.status < 200 || res.status >= 300) {
2351
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2351
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2352
2352
  }
2353
2353
  if (text2 === "" || text2 === '""') return null;
2354
2354
  try {
2355
2355
  return JSON.parse(text2);
2356
2356
  } catch (err) {
2357
2357
  const msg = err instanceof Error ? err.message : String(err);
2358
- throw new Error(`POST ${path11}: decode: ${msg}`);
2358
+ throw new Error(`POST ${path12}: decode: ${msg}`);
2359
2359
  }
2360
2360
  }
2361
2361
  /**
@@ -2368,7 +2368,7 @@ var AuthorizedClient = class _AuthorizedClient {
2368
2368
  * Same retry/auth semantics as `postMultipart`: bypasses the 401/403
2369
2369
  * replay ladder because the FormData body is single-shot.
2370
2370
  */
2371
- async postMultipartFiles(path11, fields, files, fileFieldName, options) {
2371
+ async postMultipartFiles(path12, fields, files, fileFieldName, options) {
2372
2372
  if (fileFieldName === "") {
2373
2373
  throw new Error("postMultipartFiles: fileFieldName must be non-empty");
2374
2374
  }
@@ -2383,7 +2383,7 @@ var AuthorizedClient = class _AuthorizedClient {
2383
2383
  fd.append(fileFieldName, part.blob, part.filename);
2384
2384
  }
2385
2385
  await this.ensureFreshAuth(JWT_REFRESH_BUFFER_MS, options?.signal);
2386
- const url = this.resolveUrl(path11);
2386
+ const url = this.resolveUrl(path12);
2387
2387
  const headers = new Headers();
2388
2388
  this.applyAuthHeaders(headers, true, true);
2389
2389
  headers.delete("Content-Type");
@@ -2394,19 +2394,19 @@ var AuthorizedClient = class _AuthorizedClient {
2394
2394
  signal: options?.signal
2395
2395
  });
2396
2396
  const text2 = await res.text();
2397
- _AuthorizedClient.throwIfScopeDeniedBody("POST", path11, res.status, text2);
2397
+ _AuthorizedClient.throwIfScopeDeniedBody("POST", path12, res.status, text2);
2398
2398
  if (res.status === 401 || res.status === 403) {
2399
- throw new SessionExpiredError(`POST ${path11} (HTTP ${res.status})`);
2399
+ throw new SessionExpiredError(`POST ${path12} (HTTP ${res.status})`);
2400
2400
  }
2401
2401
  if (res.status < 200 || res.status >= 300) {
2402
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2402
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2403
2403
  }
2404
2404
  if (text2 === "" || text2 === '""') return null;
2405
2405
  try {
2406
2406
  return JSON.parse(text2);
2407
2407
  } catch (err) {
2408
2408
  const msg = err instanceof Error ? err.message : String(err);
2409
- throw new Error(`POST ${path11}: decode: ${msg}`);
2409
+ throw new Error(`POST ${path12}: decode: ${msg}`);
2410
2410
  }
2411
2411
  }
2412
2412
  /**
@@ -2420,7 +2420,7 @@ var AuthorizedClient = class _AuthorizedClient {
2420
2420
  * the requestJson retry ladder because the FormData body is
2421
2421
  * single-shot.
2422
2422
  */
2423
- async postMultipartNamed(path11, fields, files, options) {
2423
+ async postMultipartNamed(path12, fields, files, options) {
2424
2424
  const fd = new FormData();
2425
2425
  for (const [k, v] of Object.entries(fields)) {
2426
2426
  fd.set(k, v);
@@ -2442,7 +2442,7 @@ var AuthorizedClient = class _AuthorizedClient {
2442
2442
  fd.set(part.fieldName, part.blob, part.filename);
2443
2443
  }
2444
2444
  await this.ensureFreshAuth(JWT_REFRESH_BUFFER_MS, options?.signal);
2445
- const url = this.resolveUrl(path11);
2445
+ const url = this.resolveUrl(path12);
2446
2446
  const headers = new Headers();
2447
2447
  this.applyAuthHeaders(headers, true, true);
2448
2448
  headers.delete("Content-Type");
@@ -2453,19 +2453,19 @@ var AuthorizedClient = class _AuthorizedClient {
2453
2453
  signal: options?.signal
2454
2454
  });
2455
2455
  const text2 = await res.text();
2456
- _AuthorizedClient.throwIfScopeDeniedBody("POST", path11, res.status, text2);
2456
+ _AuthorizedClient.throwIfScopeDeniedBody("POST", path12, res.status, text2);
2457
2457
  if (res.status === 401 || res.status === 403) {
2458
- throw new SessionExpiredError(`POST ${path11} (HTTP ${res.status})`);
2458
+ throw new SessionExpiredError(`POST ${path12} (HTTP ${res.status})`);
2459
2459
  }
2460
2460
  if (res.status < 200 || res.status >= 300) {
2461
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2461
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2462
2462
  }
2463
2463
  if (text2 === "" || text2 === '""') return null;
2464
2464
  try {
2465
2465
  return JSON.parse(text2);
2466
2466
  } catch (err) {
2467
2467
  const msg = err instanceof Error ? err.message : String(err);
2468
- throw new Error(`POST ${path11}: decode: ${msg}`);
2468
+ throw new Error(`POST ${path12}: decode: ${msg}`);
2469
2469
  }
2470
2470
  }
2471
2471
  /**
@@ -2497,17 +2497,17 @@ var AuthorizedClient = class _AuthorizedClient {
2497
2497
  * Multipart callers MUST NOT route through here (body is not safely
2498
2498
  * replayable); they go through `do()` directly. See Task 1.14.
2499
2499
  */
2500
- async requestJson(method, path11, payload, options) {
2500
+ async requestJson(method, path12, payload, options) {
2501
2501
  const body = payload === void 0 ? void 0 : JSON.stringify(payload);
2502
2502
  const sentBearer = this.hasBearer();
2503
- let res = await this.doWithAuth(method, path11, body, options, true);
2504
- await _AuthorizedClient.throwIfScopeDenied(method, path11, res);
2503
+ let res = await this.doWithAuth(method, path12, body, options, true);
2504
+ await _AuthorizedClient.throwIfScopeDenied(method, path12, res);
2505
2505
  let triedSessionOnly = false;
2506
2506
  let refreshed = false;
2507
2507
  let refreshErr;
2508
2508
  if (this.isAuthRejected(res) && sentBearer && !this.isCookieless()) {
2509
2509
  triedSessionOnly = true;
2510
- res = await this.doWithAuth(method, path11, body, options, false);
2510
+ res = await this.doWithAuth(method, path12, body, options, false);
2511
2511
  }
2512
2512
  if (this.isAuthRejected(res)) {
2513
2513
  try {
@@ -2517,29 +2517,29 @@ var AuthorizedClient = class _AuthorizedClient {
2517
2517
  });
2518
2518
  this._session = fresh;
2519
2519
  refreshed = true;
2520
- res = await this.doWithAuth(method, path11, body, options, true);
2520
+ res = await this.doWithAuth(method, path12, body, options, true);
2521
2521
  } catch (err) {
2522
2522
  refreshErr = err;
2523
2523
  }
2524
2524
  }
2525
2525
  if (this.isAuthRejected(res)) {
2526
2526
  const text3 = await res.text();
2527
- _AuthorizedClient.throwIfScopeDeniedBody(method, path11, res.status, text3);
2527
+ _AuthorizedClient.throwIfScopeDeniedBody(method, path12, res.status, text3);
2528
2528
  if (refreshed || triedSessionOnly) {
2529
2529
  const attempted = refreshed ? "session-only retry and JWT refresh" : "session-only retry";
2530
2530
  throw new Error(
2531
- `${method} ${path11}: HTTP ${res.status} after ${attempted} (authenticated, but endpoint rejected \u2014 check permissions, tenant/org context, or body): ${truncate2(text3, 200)}`
2531
+ `${method} ${path12}: HTTP ${res.status} after ${attempted} (authenticated, but endpoint rejected \u2014 check permissions, tenant/org context, or body): ${truncate2(text3, 200)}`
2532
2532
  );
2533
2533
  }
2534
2534
  if (refreshErr !== void 0) {
2535
2535
  const msg = refreshErr instanceof Error ? refreshErr.message : String(refreshErr);
2536
- throw new Error(`${method} ${path11}: ${msg} (HTTP ${res.status})`);
2536
+ throw new Error(`${method} ${path12}: ${msg} (HTTP ${res.status})`);
2537
2537
  }
2538
- throw new SessionExpiredError(`${method} ${path11} (HTTP ${res.status})`);
2538
+ throw new SessionExpiredError(`${method} ${path12} (HTTP ${res.status})`);
2539
2539
  }
2540
2540
  const text2 = await res.text();
2541
2541
  if (res.status < 200 || res.status >= 300) {
2542
- throw new Error(`${method} ${path11}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2542
+ throw new Error(`${method} ${path12}: HTTP ${res.status}: ${truncate2(text2, 200)}`);
2543
2543
  }
2544
2544
  try {
2545
2545
  await this._store.touch(this._serverKey, this._email);
@@ -2550,7 +2550,7 @@ var AuthorizedClient = class _AuthorizedClient {
2550
2550
  return JSON.parse(text2);
2551
2551
  } catch (err) {
2552
2552
  const msg = err instanceof Error ? err.message : String(err);
2553
- throw new Error(`${method} ${path11}: decode: ${msg}`);
2553
+ throw new Error(`${method} ${path12}: decode: ${msg}`);
2554
2554
  }
2555
2555
  }
2556
2556
  /**
@@ -2617,7 +2617,7 @@ var AuthorizedClient = class _AuthorizedClient {
2617
2617
  * caller, and `requestJson` reads it in its own final-messaging branch. The clone is read
2618
2618
  * only on a 403, so the ordinary path pays one status comparison.
2619
2619
  */
2620
- static async throwIfScopeDenied(method, path11, res) {
2620
+ static async throwIfScopeDenied(method, path12, res) {
2621
2621
  if (res.status !== 403) return;
2622
2622
  let text2;
2623
2623
  try {
@@ -2625,22 +2625,22 @@ var AuthorizedClient = class _AuthorizedClient {
2625
2625
  } catch {
2626
2626
  return;
2627
2627
  }
2628
- _AuthorizedClient.throwIfScopeDeniedBody(method, path11, res.status, text2);
2628
+ _AuthorizedClient.throwIfScopeDeniedBody(method, path12, res.status, text2);
2629
2629
  }
2630
2630
  /** {@link AuthorizedClient.throwIfScopeDenied} for a body already in hand — the multipart
2631
2631
  * methods and `requestJson`'s final branch have read theirs and must not read it twice. */
2632
- static throwIfScopeDeniedBody(method, path11, status2, text2) {
2632
+ static throwIfScopeDeniedBody(method, path12, status2, text2) {
2633
2633
  const denial = parseScopeDenial(status2, text2);
2634
- if (denial !== void 0) throw new ScopeDeniedError(method, path11, denial.code);
2634
+ if (denial !== void 0) throw new ScopeDeniedError(method, path12, denial.code);
2635
2635
  }
2636
2636
  /** True iff `res` is the auth-rejection signal (401 or 403). */
2637
2637
  isAuthRejected(res) {
2638
2638
  return res.status === 401 || res.status === 403;
2639
2639
  }
2640
2640
  /** Prefixes relative paths with the configured host; absolute URLs pass through. */
2641
- resolveUrl(path11) {
2642
- if (path11.startsWith("http://") || path11.startsWith("https://")) return path11;
2643
- return this._host + path11;
2641
+ resolveUrl(path12) {
2642
+ if (path12.startsWith("http://") || path12.startsWith("https://")) return path12;
2643
+ return this._host + path12;
2644
2644
  }
2645
2645
  };
2646
2646
  function truncate2(s, n) {
@@ -2653,8 +2653,8 @@ import { readdir, rm } from "fs/promises";
2653
2653
  import { basename, dirname as dirname2, join as join3 } from "path";
2654
2654
  var INDEX_PREFIX2 = "__index__:";
2655
2655
  var FileKeyringBackend = class _FileKeyringBackend {
2656
- constructor(path11) {
2657
- this.path = path11;
2656
+ constructor(path12) {
2657
+ this.path = path12;
2658
2658
  }
2659
2659
  path;
2660
2660
  load() {
@@ -2790,7 +2790,7 @@ var FileKeyringBackend = class _FileKeyringBackend {
2790
2790
  * A rotation that supplies a new expiry therefore keeps it, and a rotation
2791
2791
  * on its own leaves the date the metadata op carries.
2792
2792
  */
2793
- static applyOps(creds, ops, path11) {
2793
+ static applyOps(creds, ops, path12) {
2794
2794
  const next = { ...creds };
2795
2795
  const order = ["apikey", "access", "refresh", "meta"];
2796
2796
  for (const slot of order) {
@@ -2798,7 +2798,7 @@ var FileKeyringBackend = class _FileKeyringBackend {
2798
2798
  const opSlot = _FileKeyringBackend.slotOf(creds, op.account);
2799
2799
  if (opSlot === void 0) {
2800
2800
  throw new Error(
2801
- `credential file ${path11} holds ${creds.server}:${creds.email} and cannot also store ${op.account}: it is a single-identity store. Remove that file to use the OS keychain instead.`
2801
+ `credential file ${path12} holds ${creds.server}:${creds.email} and cannot also store ${op.account}: it is a single-identity store. Remove that file to use the OS keychain instead.`
2802
2802
  );
2803
2803
  }
2804
2804
  if (opSlot !== slot) continue;
@@ -3943,6 +3943,10 @@ var PROD_GATE_TIER_A = /* @__PURE__ */ new Set([
3943
3943
  "extable|delete",
3944
3944
  "entity|delete",
3945
3945
  "badge-command|delete",
3946
+ // devices command-delete over several ids or a machine's whole WAITING queue
3947
+ // (one token, N commands). Same hard delete N times over, so the word gate
3948
+ // stays — once for the whole set, with every target on screen before it.
3949
+ "badge-command-batch|delete",
3946
3950
  "function|delete",
3947
3951
  "lut|delete",
3948
3952
  "calcval|delete",
@@ -4153,6 +4157,9 @@ function confirmSecretPath() {
4153
4157
  }
4154
4158
  return path2.join(base, "dr-cs-cli", "delete-secret");
4155
4159
  }
4160
+ function confirmStateDir() {
4161
+ return path2.dirname(confirmSecretPath());
4162
+ }
4156
4163
  function userConfigDir() {
4157
4164
  const platform = process.platform;
4158
4165
  if (platform === "win32") {
@@ -4217,8 +4224,8 @@ var NO_IDENTITY = {
4217
4224
  var started;
4218
4225
  var targetServer = "";
4219
4226
  var identity = NO_IDENTITY;
4220
- function recordCommandStart(path11, nowMs) {
4221
- started = { command: path11.command, subcommand: path11.subcommand, startedAtMs: nowMs };
4227
+ function recordCommandStart(path12, nowMs) {
4228
+ started = { command: path12.command, subcommand: path12.subcommand, startedAtMs: nowMs };
4222
4229
  }
4223
4230
  function setTelemetryTarget(server, id) {
4224
4231
  targetServer = server;
@@ -4329,22 +4336,22 @@ function formatSampleCell(v) {
4329
4336
 
4330
4337
  // src/commands/_setupCall.ts
4331
4338
  async function refuseIfProvisionedExternally(action, opts) {
4332
- const path11 = credentialsFilePath();
4333
- const creds = await readCredentialsFile(path11);
4339
+ const path12 = credentialsFilePath();
4340
+ const creds = await readCredentialsFile(path12);
4334
4341
  if (creds === void 0) return;
4335
4342
  if (creds.apiKey !== void 0) {
4336
4343
  if (opts?.allowApiKey === true) return;
4337
4344
  throw new Error(
4338
- `cannot ${action}: the credentials in ${path11} are an API key. Run \`dr login --api-key\` to replace the key (and update its \`apiKeyExpiresAt\` in that file, if set \u2014 nothing derives that date, and a stale one warns "expired" on every command), or \`dr logout\` to remove it and log in with a browser instead \u2014 it cannot be read back afterwards, so keep a copy if it is still needed.`
4345
+ `cannot ${action}: the credentials in ${path12} are an API key. Run \`dr login --api-key\` to replace the key (and update its \`apiKeyExpiresAt\` in that file, if set \u2014 nothing derives that date, and a stale one warns "expired" on every command), or \`dr logout\` to remove it and log in with a browser instead \u2014 it cannot be read back afterwards, so keep a copy if it is still needed.`
4339
4346
  );
4340
4347
  }
4341
4348
  if (creds.apiKeyEnvVar !== void 0 && opts?.allowApiKey !== true) {
4342
4349
  throw new Error(
4343
- `cannot ${action}: the credentials in ${path11} name the environment variable ${creds.apiKeyEnvVar} as their API key, which is what later commands would authenticate as. Remove that file (\`dr logout\`) to log in with a browser instead.`
4350
+ `cannot ${action}: the credentials in ${path12} name the environment variable ${creds.apiKeyEnvVar} as their API key, which is what later commands would authenticate as. Remove that file (\`dr logout\`) to log in with a browser instead.`
4344
4351
  );
4345
4352
  }
4346
4353
  if (isInteractiveFileLogin(creds)) return;
4347
- throw provisionedExternallyError(path11, action);
4354
+ throw provisionedExternallyError(path12, action);
4348
4355
  }
4349
4356
  function isInteractiveFileLogin(creds) {
4350
4357
  return creds.sessionId !== void 0 && creds.sessionId !== "" || creds.interactiveLogin === true;
@@ -4364,26 +4371,26 @@ async function refuseLoginOverStoredApiKey(store, serverKey, email) {
4364
4371
  `cannot log in: ${serverKey}:${email} already holds an API key, which is what later commands would authenticate as \u2014 this login would succeed under your name and then run as the key. Run \`dr login --api-key\` to replace the key, or \`dr logout\` to remove it first \u2014 it cannot be read back afterwards, so keep a copy if it is still needed.`
4365
4372
  );
4366
4373
  }
4367
- function provisionedExternallyError(path11, action) {
4374
+ function provisionedExternallyError(path12, action) {
4368
4375
  return new Error(
4369
- `cannot ${action}: the credentials in ${path11} were provisioned externally and carry no interactive session. Whatever provisioned them is responsible for renewing them; remove that file to log in interactively instead.`
4376
+ `cannot ${action}: the credentials in ${path12} were provisioned externally and carry no interactive session. Whatever provisioned them is responsible for renewing them; remove that file to log in interactively instead.`
4370
4377
  );
4371
4378
  }
4372
4379
  async function refuseImpersonationWithCredentialFile() {
4373
4380
  const action = "log in as another user";
4374
- const path11 = credentialsFilePath();
4375
- const creds = await readCredentialsFile(path11);
4381
+ const path12 = credentialsFilePath();
4382
+ const creds = await readCredentialsFile(path12);
4376
4383
  if (creds === void 0) return;
4377
4384
  if (creds.apiKey !== void 0) {
4378
4385
  throw new Error(
4379
- `cannot ${action}: the credentials in ${path11} are an API key, and an API-key token cannot mint further credentials. Impersonating needs a browser login, so remove that file (\`dr logout\`) and run \`dr login --server <key>\` \u2014 the key cannot be read back afterwards, so keep a copy if it is still needed.`
4386
+ `cannot ${action}: the credentials in ${path12} are an API key, and an API-key token cannot mint further credentials. Impersonating needs a browser login, so remove that file (\`dr logout\`) and run \`dr login --server <key>\` \u2014 the key cannot be read back afterwards, so keep a copy if it is still needed.`
4380
4387
  );
4381
4388
  }
4382
4389
  if (!isInteractiveFileLogin(creds)) {
4383
- throw provisionedExternallyError(path11, action);
4390
+ throw provisionedExternallyError(path12, action);
4384
4391
  }
4385
4392
  throw new Error(
4386
- `cannot ${action}: ${path11} is in use as a single-identity credential store, which cannot hold a second identity. Remove that file to store sessions in the OS keychain instead.`
4393
+ `cannot ${action}: ${path12} is in use as a single-identity credential store, which cannot hold a second identity. Remove that file to store sessions in the OS keychain instead.`
4387
4394
  );
4388
4395
  }
4389
4396
  function fileStoreServerKey(creds, serverFlag) {
@@ -4402,14 +4409,14 @@ function fileStoreServerKey(creds, serverFlag) {
4402
4409
  return creds.server;
4403
4410
  }
4404
4411
  async function resolveFileStore(serverFlag) {
4405
- const path11 = credentialsFilePath();
4406
- const creds = await readCredentialsFile(path11);
4412
+ const path12 = credentialsFilePath();
4413
+ const creds = await readCredentialsFile(path12);
4407
4414
  if (creds === void 0) return void 0;
4408
4415
  return {
4409
- store: new KeyringStore(new FileKeyringBackend(path11)),
4416
+ store: new KeyringStore(new FileKeyringBackend(path12)),
4410
4417
  key: fileStoreServerKey(creds, serverFlag),
4411
4418
  email: creds.email,
4412
- path: path11
4419
+ path: path12
4413
4420
  };
4414
4421
  }
4415
4422
  var DAY_MS = 864e5;
@@ -5334,7 +5341,7 @@ var V2_TERMINAL_HINTS = {
5334
5341
  access_denied: " (the login was refused, expired, or already used: run `dr login` again)",
5335
5342
  token_issuance_failed: " (the server could not issue the token: run `dr login` again to start a new login)"
5336
5343
  };
5337
- async function poll(host, path11, deviceCode, options, terminalHints, onSuccess) {
5344
+ async function poll(host, path12, deviceCode, options, terminalHints, onSuccess) {
5338
5345
  const interval = options.interval ?? 2e3;
5339
5346
  const maxWait = options.maxWait ?? 6e5;
5340
5347
  const now = options.now ?? Date.now;
@@ -5354,7 +5361,7 @@ async function poll(host, path11, deviceCode, options, terminalHints, onSuccess)
5354
5361
  client_id: CLIENT_ID,
5355
5362
  device_code: deviceCode
5356
5363
  });
5357
- const res = await fetch(`${base}${path11}`, {
5364
+ const res = await fetch(`${base}${path12}`, {
5358
5365
  method: "POST",
5359
5366
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
5360
5367
  body: body.toString(),
@@ -5871,8 +5878,8 @@ var UserExistsError = class extends Error {
5871
5878
  }
5872
5879
  };
5873
5880
  async function create(client, payload, options) {
5874
- const path11 = "/api/it/users";
5875
- const res = await client.do("POST", path11, JSON.stringify(payload), options);
5881
+ const path12 = "/api/it/users";
5882
+ const res = await client.do("POST", path12, JSON.stringify(payload), options);
5876
5883
  const text2 = await res.text();
5877
5884
  if (res.status >= 200 && res.status < 300) {
5878
5885
  let parsed2;
@@ -5880,11 +5887,11 @@ async function create(client, payload, options) {
5880
5887
  parsed2 = JSON.parse(text2);
5881
5888
  } catch (err) {
5882
5889
  const msg = err instanceof Error ? err.message : String(err);
5883
- throw new Error(`POST ${path11}: decode: ${msg}`);
5890
+ throw new Error(`POST ${path12}: decode: ${msg}`);
5884
5891
  }
5885
5892
  const id = parsed2.data?.id;
5886
5893
  if (typeof id !== "number") {
5887
- throw new Error(`POST ${path11}: response missing data.id`);
5894
+ throw new Error(`POST ${path12}: response missing data.id`);
5888
5895
  }
5889
5896
  return {
5890
5897
  id,
@@ -5903,11 +5910,11 @@ async function create(client, payload, options) {
5903
5910
  throw new UserExistsError(payload.email);
5904
5911
  }
5905
5912
  }
5906
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5913
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5907
5914
  }
5908
5915
  async function registerIdentity(client, id, options) {
5909
- const path11 = `/api/it/users/${id}/register_identity`;
5910
- const res = await client.do("PUT", path11, void 0, options);
5916
+ const path12 = `/api/it/users/${id}/register_identity`;
5917
+ const res = await client.do("PUT", path12, void 0, options);
5911
5918
  const text2 = await res.text();
5912
5919
  if (res.status >= 200 && res.status < 300) {
5913
5920
  let body;
@@ -5915,11 +5922,11 @@ async function registerIdentity(client, id, options) {
5915
5922
  body = JSON.parse(text2);
5916
5923
  } catch (err) {
5917
5924
  const msg = err instanceof Error ? err.message : String(err);
5918
- throw new Error(`PUT ${path11}: decode: ${msg}`);
5925
+ throw new Error(`PUT ${path12}: decode: ${msg}`);
5919
5926
  }
5920
5927
  if (typeof body.sent !== "boolean") {
5921
5928
  throw new Error(
5922
- `PUT ${path11}: expected a boolean "sent" in the 2xx body, got ${truncate4(text2, 200)}`
5929
+ `PUT ${path12}: expected a boolean "sent" in the 2xx body, got ${truncate4(text2, 200)}`
5923
5930
  );
5924
5931
  }
5925
5932
  return body.sent ? { status: "registered" } : { status: "already_exists" };
@@ -5933,36 +5940,36 @@ async function registerIdentity(client, id, options) {
5933
5940
  }
5934
5941
  return { status: "failed", ...reason !== void 0 ? { reason } : {} };
5935
5942
  }
5936
- throw new Error(`PUT ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5943
+ throw new Error(`PUT ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5937
5944
  }
5938
5945
  async function assignPermissionGroups(client, id, groupIds, options) {
5939
- const path11 = `/api/it/users/${id}/permission_groups`;
5946
+ const path12 = `/api/it/users/${id}/permission_groups`;
5940
5947
  const body = JSON.stringify({ permission_groups: groupIds });
5941
- const res = await client.do("POST", path11, body, options);
5948
+ const res = await client.do("POST", path12, body, options);
5942
5949
  const text2 = await res.text();
5943
5950
  if (res.status >= 200 && res.status < 300) {
5944
5951
  return;
5945
5952
  }
5946
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5953
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5947
5954
  }
5948
5955
  async function updateUserRole(client, id, role, options) {
5949
- const path11 = `/api/it/users/${id}/permissions`;
5956
+ const path12 = `/api/it/users/${id}/permissions`;
5950
5957
  const body = JSON.stringify({ role });
5951
- const res = await client.do("PUT", path11, body, options);
5958
+ const res = await client.do("PUT", path12, body, options);
5952
5959
  const text2 = await res.text();
5953
5960
  if (res.status >= 200 && res.status < 300) {
5954
5961
  return;
5955
5962
  }
5956
- throw new Error(`PUT ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5963
+ throw new Error(`PUT ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5957
5964
  }
5958
5965
  async function removePermissionGroup(client, id, groupId, options) {
5959
- const path11 = `/api/it/users/${id}/permission_groups/${groupId}`;
5960
- const res = await client.do("DELETE", path11, void 0, options);
5966
+ const path12 = `/api/it/users/${id}/permission_groups/${groupId}`;
5967
+ const res = await client.do("DELETE", path12, void 0, options);
5961
5968
  const text2 = await res.text();
5962
5969
  if (res.status >= 200 && res.status < 300) {
5963
5970
  return;
5964
5971
  }
5965
- throw new Error(`DELETE ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5972
+ throw new Error(`DELETE ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5966
5973
  }
5967
5974
  var PasswordValidationError = class extends Error {
5968
5975
  errors;
@@ -5975,9 +5982,9 @@ var PasswordValidationError = class extends Error {
5975
5982
  }
5976
5983
  };
5977
5984
  async function setPassword(client, id, password, options) {
5978
- const path11 = `/api/it/users/${id}/set_password`;
5985
+ const path12 = `/api/it/users/${id}/set_password`;
5979
5986
  const body = JSON.stringify({ password });
5980
- const res = await client.do("PUT", path11, body, options);
5987
+ const res = await client.do("PUT", path12, body, options);
5981
5988
  if (res.status >= 200 && res.status < 300) {
5982
5989
  await res.text();
5983
5990
  return;
@@ -5995,7 +6002,7 @@ async function setPassword(client, id, password, options) {
5995
6002
  throw new PasswordValidationError(messages);
5996
6003
  }
5997
6004
  }
5998
- throw new Error(`PUT ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
6005
+ throw new Error(`PUT ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
5999
6006
  }
6000
6007
  var EmailInUseError = class extends Error {
6001
6008
  email;
@@ -6007,12 +6014,12 @@ var EmailInUseError = class extends Error {
6007
6014
  };
6008
6015
  async function updateUserEmail(client, id, newEmail, options) {
6009
6016
  const current = await get(client, id, options);
6010
- const path11 = `/api/it/users/${id}`;
6017
+ const path12 = `/api/it/users/${id}`;
6011
6018
  const body = JSON.stringify({
6012
6019
  email: newEmail,
6013
6020
  excel_online_email: current.profile?.excel_online_email ?? null
6014
6021
  });
6015
- const res = await client.do("PUT", path11, body, options);
6022
+ const res = await client.do("PUT", path12, body, options);
6016
6023
  const text2 = await res.text();
6017
6024
  if (res.status >= 200 && res.status < 300) {
6018
6025
  return { id, email: newEmail, previousEmail: current.email };
@@ -6020,7 +6027,7 @@ async function updateUserEmail(client, id, newEmail, options) {
6020
6027
  if (res.status === 400 && /already in use/i.test(text2)) {
6021
6028
  throw new EmailInUseError(newEmail);
6022
6029
  }
6023
- throw new Error(`PUT ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
6030
+ throw new Error(`PUT ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
6024
6031
  }
6025
6032
  var StoredEmailInvalidError = class extends Error {
6026
6033
  id;
@@ -6036,14 +6043,14 @@ var StoredEmailInvalidError = class extends Error {
6036
6043
  };
6037
6044
  async function setEmailNotifications(client, id, enabled, options) {
6038
6045
  const current = await get(client, id, options);
6039
- const path11 = `/api/it/users/${id}`;
6046
+ const path12 = `/api/it/users/${id}`;
6040
6047
  const body = JSON.stringify({
6041
6048
  disable_emails: !enabled,
6042
6049
  // Echoed verbatim — see the note above. Never a new value.
6043
6050
  email: current.email,
6044
6051
  excel_online_email: current.profile?.excel_online_email ?? null
6045
6052
  });
6046
- const res = await client.do("PUT", path11, body, options);
6053
+ const res = await client.do("PUT", path12, body, options);
6047
6054
  const text2 = await res.text();
6048
6055
  if (res.status >= 200 && res.status < 300) {
6049
6056
  return {
@@ -6056,7 +6063,7 @@ async function setEmailNotifications(client, id, enabled, options) {
6056
6063
  if (res.status === 400 && /valid email address/i.test(text2)) {
6057
6064
  throw new StoredEmailInvalidError(id, current.email);
6058
6065
  }
6059
- throw new Error(`PUT ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
6066
+ throw new Error(`PUT ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
6060
6067
  }
6061
6068
  async function getCanLoginAs(client, params = {}, options) {
6062
6069
  const qs = new URLSearchParams();
@@ -6069,8 +6076,8 @@ async function getCanLoginAs(client, params = {}, options) {
6069
6076
  if (params.pageSize !== void 0) {
6070
6077
  qs.set("page_size", String(params.pageSize));
6071
6078
  }
6072
- const path11 = qs.toString() === "" ? "/api/it/users/can_login_as" : `/api/it/users/can_login_as?${qs.toString()}`;
6073
- const out = await client.getJSON(path11, options);
6079
+ const path12 = qs.toString() === "" ? "/api/it/users/can_login_as" : `/api/it/users/can_login_as?${qs.toString()}`;
6080
+ const out = await client.getJSON(path12, options);
6074
6081
  if (out === null) {
6075
6082
  return { count: 0, next: null, previous: null, results: [] };
6076
6083
  }
@@ -6280,7 +6287,9 @@ function registerLoginAsCommand(root) {
6280
6287
  }
6281
6288
 
6282
6289
  // src/commands/devices.ts
6290
+ import { createHash as createHash2 } from "crypto";
6283
6291
  import { promises as fs3 } from "fs";
6292
+ import * as path4 from "path";
6284
6293
 
6285
6294
  // src/api/devices.ts
6286
6295
  var COMMANDS_V2_PAGE_SIZE = 500;
@@ -6289,7 +6298,7 @@ async function paginateCommandsV2(client, machineId, options) {
6289
6298
  let page = 1;
6290
6299
  for (; ; ) {
6291
6300
  const env = await client.getJSON(
6292
- `/api/badge/${machineId}/commands/v2?page_size=${COMMANDS_V2_PAGE_SIZE}&page=${page}`,
6301
+ `/api/badge/${encodeURIComponent(machineId)}/commands/v2?page_size=${COMMANDS_V2_PAGE_SIZE}&page=${page}`,
6293
6302
  options
6294
6303
  );
6295
6304
  if (env === null) break;
@@ -6368,6 +6377,76 @@ function parsePositiveIntArg(raw, label) {
6368
6377
  return n;
6369
6378
  }
6370
6379
 
6380
+ // src/commands/_retry.ts
6381
+ var AMBIGUOUS_STATUSES = /* @__PURE__ */ new Set([502, 504, 524]);
6382
+ var MAX_BACKOFF_MS = 8e3;
6383
+ function isAbortError(err) {
6384
+ if (typeof err !== "object" || err === null) return false;
6385
+ const name = err.name;
6386
+ if (name === "AbortError" || name === "TimeoutError") return true;
6387
+ return err.code === "ABORT_ERR";
6388
+ }
6389
+ function httpStatusOf(err) {
6390
+ const msg = err instanceof Error ? err.message : String(err);
6391
+ const m = /\bHTTP (\d{3})\b/.exec(msg);
6392
+ return m === null ? void 0 : Number(m[1]);
6393
+ }
6394
+ function classifyFailure(err) {
6395
+ if (isAbortError(err)) return "abort";
6396
+ const status2 = httpStatusOf(err);
6397
+ if (status2 === void 0) return "transient";
6398
+ if (AMBIGUOUS_STATUSES.has(status2)) return "ambiguous";
6399
+ if (status2 === 429) return "transient";
6400
+ if (status2 >= 400 && status2 < 500) return "client";
6401
+ return "transient";
6402
+ }
6403
+ function defaultBackoffMs(failedAttempt) {
6404
+ return Math.min(1e3 * 2 ** (failedAttempt - 1), MAX_BACKOFF_MS);
6405
+ }
6406
+ async function sleep2(ms, signal) {
6407
+ if (ms <= 0) return;
6408
+ if (signal?.aborted === true) throw abortErrorFor(signal);
6409
+ await new Promise((resolve3, reject) => {
6410
+ const timer = setTimeout(() => {
6411
+ signal?.removeEventListener("abort", onAbort);
6412
+ resolve3();
6413
+ }, ms);
6414
+ function onAbort() {
6415
+ clearTimeout(timer);
6416
+ reject(abortErrorFor(signal));
6417
+ }
6418
+ signal?.addEventListener("abort", onAbort, { once: true });
6419
+ });
6420
+ }
6421
+ function abortErrorFor(signal) {
6422
+ const reason = signal?.reason;
6423
+ if (reason instanceof Error) return reason;
6424
+ return Object.assign(new Error("This operation was aborted"), {
6425
+ name: "AbortError"
6426
+ });
6427
+ }
6428
+ async function retryAsync(fn, opts) {
6429
+ const retries = Number.isFinite(opts.retries) ? Math.max(0, Math.floor(opts.retries)) : 0;
6430
+ for (let attempt = 1; ; attempt++) {
6431
+ try {
6432
+ return await fn();
6433
+ } catch (err) {
6434
+ const kind = classifyFailure(err);
6435
+ const retryable = kind === "transient" || kind !== "abort" && opts.alsoRetry?.(err) === true;
6436
+ if (!retryable || attempt > retries) throw err;
6437
+ const delay = opts.delayMs ?? defaultBackoffMs;
6438
+ const waitMs = typeof delay === "function" ? delay(attempt) : delay;
6439
+ opts.onRetry?.(attempt, err, waitMs);
6440
+ await sleep2(waitMs, opts.signal);
6441
+ }
6442
+ }
6443
+ }
6444
+
6445
+ // src/commands/_shellQuote.ts
6446
+ function shellQuote(value) {
6447
+ return `'${value.replace(/'/g, `'\\''`)}'`;
6448
+ }
6449
+
6371
6450
  // src/commands/devices.ts
6372
6451
  async function runDevicesList(cfg) {
6373
6452
  const devices = await list3(cfg.client, { signal: cfg.signal });
@@ -6419,7 +6498,7 @@ async function runDevicesDownloadLogs(cfg) {
6419
6498
  if (cfg.uuid === "") {
6420
6499
  throw new Error("uuid is required");
6421
6500
  }
6422
- const path11 = `/api/it/devices/request_logs/${cfg.uuid}`;
6501
+ const path12 = `/api/it/devices/request_logs/${cfg.uuid}`;
6423
6502
  const res = await downloadLogsStream(cfg.client, cfg.uuid, {
6424
6503
  signal: cfg.signal
6425
6504
  });
@@ -6431,10 +6510,10 @@ async function runDevicesDownloadLogs(cfg) {
6431
6510
  }
6432
6511
  if (res.status < 200 || res.status >= 300) {
6433
6512
  await res.text();
6434
- throw new Error(`GET ${path11}: HTTP ${res.status}`);
6513
+ throw new Error(`GET ${path12}: HTTP ${res.status}`);
6435
6514
  }
6436
6515
  if (res.body === null) {
6437
- throw new Error(`GET ${path11}: empty response body`);
6516
+ throw new Error(`GET ${path12}: empty response body`);
6438
6517
  }
6439
6518
  if (cfg.output === "-") {
6440
6519
  const reader = res.body.getReader();
@@ -6503,6 +6582,210 @@ async function runDevicesCommandDelete(cfg) {
6503
6582
  }
6504
6583
  });
6505
6584
  }
6585
+ var ERR_IDS_AND_ALL_QUEUED = "pass command ids OR --all-queued, not both";
6586
+ var ERR_ALL_QUEUED_NEEDS_MACHINE = "--all-queued needs --machine <machine_id> (find it with 'dr devices list --json')";
6587
+ var ERR_PLAN_NEEDS_ALL_QUEUED = "--plan only applies to --all-queued";
6588
+ var ERR_CONFIRM_NEEDS_PLAN = "--all-queued with --confirm-token also needs --plan \u2014 paste the exact confirm command the plan printed";
6589
+ function badgeBatchAction(id) {
6590
+ return { resource: "badge-command-batch", id, verb: "delete" };
6591
+ }
6592
+ function shortHash(key) {
6593
+ return createHash2("sha256").update(key).digest("hex").slice(0, 12);
6594
+ }
6595
+ function buildBadgeCommandBatchAction(ids) {
6596
+ const sorted = [...new Set(ids)].sort((a, b) => a - b);
6597
+ return badgeBatchAction(shortHash(`ids:${sorted.join(",")}`));
6598
+ }
6599
+ function badgeQueuePlanId(machineId, dataQuery, ids) {
6600
+ const sorted = [...new Set(ids)].sort((a, b) => a - b);
6601
+ return shortHash(`queue:${machineId}|dq=${dataQuery ?? ""}|ids=${sorted.join(",")}`);
6602
+ }
6603
+ function buildBadgeQueuePlanAction(planId) {
6604
+ return badgeBatchAction(planId);
6605
+ }
6606
+ function badgePlanDir() {
6607
+ return path4.join(confirmStateDir(), "badge-command-plans");
6608
+ }
6609
+ function badgePlanPath(planId) {
6610
+ if (!/^[0-9a-f]{12}$/.test(planId)) {
6611
+ throw new Error(`invalid --plan "${planId}" \u2014 paste the confirm command the plan printed`);
6612
+ }
6613
+ return path4.join(badgePlanDir(), `${planId}.json`);
6614
+ }
6615
+ async function writeBadgeQueuePlan(planId, plan) {
6616
+ const dir = badgePlanDir();
6617
+ await fs3.mkdir(dir, { recursive: true, mode: 448 });
6618
+ const cutoff = Date.now() - CONFIRM_TOKEN_TTL_MS;
6619
+ for (const name of await fs3.readdir(dir)) {
6620
+ const file = path4.join(dir, name);
6621
+ try {
6622
+ if ((await fs3.stat(file)).mtimeMs < cutoff) await fs3.rm(file, { force: true });
6623
+ } catch {
6624
+ }
6625
+ }
6626
+ await fs3.writeFile(badgePlanPath(planId), JSON.stringify(plan), { mode: 384 });
6627
+ }
6628
+ async function readBadgeQueuePlan(planId, machineId, dataQuery) {
6629
+ let raw;
6630
+ try {
6631
+ raw = await fs3.readFile(badgePlanPath(planId), "utf8");
6632
+ } catch (err) {
6633
+ if (err.code === "ENOENT") {
6634
+ throw new Error(
6635
+ `plan ${planId} was not found on this computer \u2014 it expired or was made elsewhere. Re-run the command without --confirm-token and --plan to plan again.`
6636
+ );
6637
+ }
6638
+ throw err;
6639
+ }
6640
+ let plan;
6641
+ try {
6642
+ plan = JSON.parse(raw);
6643
+ } catch {
6644
+ throw new Error(`plan ${planId} is unreadable \u2014 plan again`);
6645
+ }
6646
+ const ids = Array.isArray(plan.ids) ? plan.ids : [];
6647
+ const ok = plan.machineId === machineId && (plan.dataQuery ?? void 0) === dataQuery && ids.length > 0 && ids.every((n) => Number.isInteger(n) && n > 0) && badgeQueuePlanId(machineId, dataQuery, ids) === planId;
6648
+ if (!ok) {
6649
+ throw new Error(
6650
+ `plan ${planId} does not match --machine / --data-query, or was changed \u2014 plan again`
6651
+ );
6652
+ }
6653
+ return [...new Set(ids)].sort((a, b) => a - b);
6654
+ }
6655
+ async function removeBadgeQueuePlan(planId) {
6656
+ try {
6657
+ await fs3.rm(badgePlanPath(planId), { force: true });
6658
+ } catch {
6659
+ }
6660
+ }
6661
+ async function runDevicesCommandDeleteBatch(cfg) {
6662
+ const machineId = cfg.machineId ?? "";
6663
+ const planning = isPlanPhase(cfg.token);
6664
+ if (cfg.allQueued && cfg.ids.length > 0) throw new Error(ERR_IDS_AND_ALL_QUEUED);
6665
+ if (cfg.allQueued && machineId === "") throw new Error(ERR_ALL_QUEUED_NEEDS_MACHINE);
6666
+ if (!cfg.allQueued && cfg.planId !== void 0) throw new Error(ERR_PLAN_NEEDS_ALL_QUEUED);
6667
+ if (cfg.allQueued && !planning && cfg.planId === void 0) {
6668
+ throw new Error(ERR_CONFIRM_NEEDS_PLAN);
6669
+ }
6670
+ const explicitIds = [...new Set(cfg.ids)].sort((a, b) => a - b);
6671
+ if (!cfg.allQueued && explicitIds.length === 0) {
6672
+ throw new Error("at least one command id is required");
6673
+ }
6674
+ let plannedIds;
6675
+ if (!cfg.allQueued) {
6676
+ await preflightConfirmToken(buildBadgeCommandBatchAction(explicitIds), cfg.token);
6677
+ } else if (cfg.planId !== void 0) {
6678
+ plannedIds = await readBadgeQueuePlan(cfg.planId, machineId, cfg.dataQuery);
6679
+ await preflightConfirmToken(buildBadgeQueuePlanAction(cfg.planId), cfg.token);
6680
+ }
6681
+ const readQueue = machineId !== "" && (planning || isProdServer(cfg.serverFlag));
6682
+ const queue = readQueue ? await commands(cfg.client, machineId, { signal: cfg.signal }) : [];
6683
+ const byId = new Map(queue.map((c) => [c.id, c]));
6684
+ let ids;
6685
+ let action;
6686
+ let confirmCmd;
6687
+ let planId;
6688
+ const machineArg = machineId === "" ? "" : ` --machine ${shellQuote(machineId)}`;
6689
+ const dqArg = cfg.dataQuery === void 0 ? "" : ` --data-query ${cfg.dataQuery}`;
6690
+ if (cfg.allQueued) {
6691
+ if (plannedIds !== void 0) {
6692
+ ids = plannedIds;
6693
+ planId = cfg.planId;
6694
+ } else {
6695
+ ids = [...byId.values()].filter((c) => cfg.dataQuery === void 0 || c.data_query === cfg.dataQuery).map((c) => c.id).sort((a, b) => a - b);
6696
+ if (ids.length === 0) {
6697
+ const filter = cfg.dataQuery === void 0 ? "" : ` for data query ${cfg.dataQuery}`;
6698
+ cfg.out.write(
6699
+ `(no queued commands${filter} on machine ${machineId} \u2014 nothing to delete)
6700
+ `
6701
+ );
6702
+ return;
6703
+ }
6704
+ planId = badgeQueuePlanId(machineId, cfg.dataQuery, ids);
6705
+ await writeBadgeQueuePlan(planId, {
6706
+ machineId,
6707
+ dataQuery: cfg.dataQuery ?? null,
6708
+ ids
6709
+ });
6710
+ }
6711
+ action = buildBadgeQueuePlanAction(planId);
6712
+ confirmCmd = `dr devices command-delete${machineArg} --all-queued${dqArg} --plan ${planId} --server ${cfg.serverFlag}`;
6713
+ } else {
6714
+ ids = explicitIds;
6715
+ action = buildBadgeCommandBatchAction(ids);
6716
+ confirmCmd = `dr devices command-delete ${ids.join(" ")}${machineArg} --server ${cfg.serverFlag}`;
6717
+ }
6718
+ await twoStepConfirm({
6719
+ out: cfg.out,
6720
+ action,
6721
+ token: cfg.token,
6722
+ server: cfg.serverFlag,
6723
+ confirmCmd,
6724
+ describe: async () => {
6725
+ const scope = machineId === "" ? "" : ` on machine ${machineId}` + (cfg.dataQuery === void 0 ? "" : ` (data query ${cfg.dataQuery})`);
6726
+ const lines = [`${ids.length} badge commands${scope}:`];
6727
+ for (const id of ids) {
6728
+ const c = byId.get(id);
6729
+ if (c !== void 0) {
6730
+ lines.push(
6731
+ `command ${id}: ${strOr(c.action, "-")} ${strOr(c.status, "-")} data_query=${fmtIntOrDash(c.data_query ?? null)} updated=${c.update_time}`
6732
+ );
6733
+ } else if (readQueue) {
6734
+ lines.push(
6735
+ `command ${id}: (not in this machine's WAITING queue \u2014 will still attempt delete)`
6736
+ );
6737
+ } else {
6738
+ lines.push(`command ${id}`);
6739
+ }
6740
+ }
6741
+ if (cfg.allQueued) {
6742
+ lines.push("(only these commands; anything queued after the plan is left alone)");
6743
+ }
6744
+ return lines;
6745
+ },
6746
+ execute: async () => {
6747
+ extendForBatch(cfg.extendTimeout, ids.length);
6748
+ const failed = [];
6749
+ const gone = [];
6750
+ let deleted = 0;
6751
+ const summary = () => `Deleted ${deleted} of ${ids.length} badge commands` + (gone.length > 0 ? `; ${gone.length} already gone` : "") + (failed.length > 0 ? `; ${failed.length} failed: ${failed.join(", ")}` : "") + ".\n";
6752
+ try {
6753
+ for (const id of ids) {
6754
+ try {
6755
+ await commandDelete(cfg.client, id, { signal: cfg.signal });
6756
+ deleted += 1;
6757
+ cfg.out.write(`Deleted badge command ${id}.
6758
+ `);
6759
+ } catch (err) {
6760
+ if (cfg.signal.aborted) {
6761
+ const done = deleted + gone.length + failed.length;
6762
+ cfg.out.write(`Stopped after ${done} of ${ids.length} badge commands. ${summary()}`);
6763
+ throw err;
6764
+ }
6765
+ if (cfg.allQueued && httpStatusOf(err) === 404) {
6766
+ cfg.out.write(`Badge command ${id} is already gone (HTTP 404) \u2014 skipped.
6767
+ `);
6768
+ gone.push(id);
6769
+ continue;
6770
+ }
6771
+ const msg = err instanceof Error ? err.message : String(err);
6772
+ cfg.out.write(`warning: badge command ${id} failed to delete: ${msg}
6773
+ `);
6774
+ failed.push(id);
6775
+ }
6776
+ }
6777
+ } finally {
6778
+ if (planId !== void 0) await removeBadgeQueuePlan(planId);
6779
+ }
6780
+ cfg.out.write(summary());
6781
+ if (failed.length > 0) {
6782
+ throw new Error(
6783
+ `${failed.length} of ${ids.length} badge command deletes failed: ${failed.join(", ")}`
6784
+ );
6785
+ }
6786
+ }
6787
+ });
6788
+ }
6506
6789
  function writeTable(out, rows) {
6507
6790
  if (rows.length === 0) return;
6508
6791
  const widths = [];
@@ -6747,24 +7030,64 @@ function registerDevicesCommand(root) {
6747
7030
  });
6748
7031
  addServerFlag(commandsCmd);
6749
7032
  addAccountFlag(commandsCmd);
6750
- const commandDeleteCmd = devices.command("command-delete").description("Delete a queued/executed remote command by id (two-step confirm)").argument("<id>", "command id (positive integer)").option(
7033
+ const commandDeleteCmd = devices.command("command-delete").description(
7034
+ "Delete remote commands (two-step confirm): one id, several ids, or every WAITING command on a machine (--machine <machine_id> --all-queued). Several commands are one batch \u2014 one plan, one token, one confirmation."
7035
+ ).argument("[ids...]", "command id(s) \u2014 positive integers; omit with --all-queued").option(
7036
+ "--machine <machine_id>",
7037
+ "Machine whose queue to read: required with --all-queued; with ids it adds each command's details to the plan"
7038
+ ).option(
7039
+ "--all-queued",
7040
+ "Target every WAITING command in the machine's queue (as listed by `devices commands`)",
7041
+ false
7042
+ ).option("--data-query <id>", "With --all-queued: only commands for this data-query id").option(
7043
+ "--plan <plan_id>",
7044
+ "With --all-queued, on confirm: the plan id the plan printed in its confirm command. Exactly the commands that plan listed are deleted"
7045
+ ).option(
6751
7046
  "--confirm-token <token>",
6752
7047
  "Token from a prior plan run \u2014 required to actually delete",
6753
7048
  ""
6754
- ).action(async (idStr, opts) => {
6755
- const id = parseSinglePositiveIntArg(idStr, "command");
6756
- const action = {
6757
- resource: "badge-command",
6758
- id: String(id),
6759
- verb: "delete"
6760
- };
6761
- await preflightConfirmToken(action, opts.confirmToken);
7049
+ ).option("--timeout <seconds>", BATCH_TIMEOUT_FLAG_HELP).action(async (idStrs, opts) => {
7050
+ const target = resolveCommandDeleteTarget(idStrs, opts);
7051
+ if (target.kind === "single") {
7052
+ const action = {
7053
+ resource: "badge-command",
7054
+ id: String(target.id),
7055
+ verb: "delete"
7056
+ };
7057
+ await preflightConfirmToken(action, opts.confirmToken);
7058
+ const serverKey2 = resolveServer(opts.server);
7059
+ const setup2 = await setupCall(opts.server, opts.account, batchSetupOptions(opts.timeout));
7060
+ try {
7061
+ await runDevicesCommandDelete({
7062
+ client: setup2.client,
7063
+ id: target.id,
7064
+ token: opts.confirmToken,
7065
+ serverFlag: serverKey2,
7066
+ signal: setup2.signal,
7067
+ out: process.stdout
7068
+ });
7069
+ } finally {
7070
+ setup2.cleanup();
7071
+ }
7072
+ return;
7073
+ }
7074
+ if (!target.allQueued) {
7075
+ await preflightConfirmToken(buildBadgeCommandBatchAction(target.ids), opts.confirmToken);
7076
+ } else if (target.planId !== void 0) {
7077
+ await readBadgeQueuePlan(target.planId, target.machineId ?? "", target.dataQuery);
7078
+ await preflightConfirmToken(buildBadgeQueuePlanAction(target.planId), opts.confirmToken);
7079
+ }
6762
7080
  const serverKey = resolveServer(opts.server);
6763
- const setup = await setupCall(opts.server, opts.account);
7081
+ const setup = await setupCall(opts.server, opts.account, batchSetupOptions(opts.timeout));
6764
7082
  try {
6765
- await runDevicesCommandDelete({
7083
+ await runDevicesCommandDeleteBatch({
6766
7084
  client: setup.client,
6767
- id,
7085
+ ids: target.ids,
7086
+ machineId: target.machineId,
7087
+ allQueued: target.allQueued,
7088
+ dataQuery: target.dataQuery,
7089
+ planId: target.planId,
7090
+ extendTimeout: setup.extendTimeout,
6768
7091
  token: opts.confirmToken,
6769
7092
  serverFlag: serverKey,
6770
7093
  signal: setup.signal,
@@ -6777,14 +7100,41 @@ function registerDevicesCommand(root) {
6777
7100
  addServerFlag(commandDeleteCmd);
6778
7101
  addAccountFlag(commandDeleteCmd);
6779
7102
  }
7103
+ function resolveCommandDeleteTarget(idStrs, opts) {
7104
+ const allQueued = opts.allQueued === true;
7105
+ const machineId = opts.machine === void 0 || opts.machine === "" ? void 0 : opts.machine;
7106
+ if (allQueued && idStrs.length > 0) throw new Error(ERR_IDS_AND_ALL_QUEUED);
7107
+ if (allQueued && machineId === void 0) throw new Error(ERR_ALL_QUEUED_NEEDS_MACHINE);
7108
+ if (!allQueued && idStrs.length === 0) {
7109
+ throw new Error(
7110
+ "pass one or more command ids, or --machine <machine_id> --all-queued to delete the whole queue"
7111
+ );
7112
+ }
7113
+ if (opts.dataQuery !== void 0 && !allQueued) {
7114
+ throw new Error("--data-query only filters --all-queued; with explicit ids, pass just the ids");
7115
+ }
7116
+ if (opts.plan !== void 0 && !allQueued) throw new Error(ERR_PLAN_NEEDS_ALL_QUEUED);
7117
+ if (allQueued && !isPlanPhase(opts.confirmToken) && opts.plan === void 0) {
7118
+ throw new Error(ERR_CONFIRM_NEEDS_PLAN);
7119
+ }
7120
+ const dataQuery = opts.dataQuery === void 0 ? void 0 : parseSinglePositiveIntArg(opts.dataQuery, "data query");
7121
+ const planId = opts.plan === void 0 || opts.plan === "" ? void 0 : opts.plan;
7122
+ const ids = [...new Set(idStrs.map((s) => parseSinglePositiveIntArg(s, "command")))].sort(
7123
+ (a, b) => a - b
7124
+ );
7125
+ if (!allQueued && ids.length === 1 && machineId === void 0) {
7126
+ return { kind: "single", id: ids[0] };
7127
+ }
7128
+ return { kind: "batch", ids, machineId, allQueued, dataQuery, planId };
7129
+ }
6780
7130
 
6781
7131
  // src/api/features.ts
6782
7132
  async function list4(client, params, options) {
6783
- let path11 = `/api/it/features?page=${params.page}&page_size=${params.pageSize}`;
7133
+ let path12 = `/api/it/features?page=${params.page}&page_size=${params.pageSize}`;
6784
7134
  if (params.search !== void 0 && params.search.trim() !== "") {
6785
- path11 += "&search=" + rawQueryEscape(params.search.trim());
7135
+ path12 += "&search=" + rawQueryEscape(params.search.trim());
6786
7136
  }
6787
- const out = await client.getJSON(path11, options);
7137
+ const out = await client.getJSON(path12, options);
6788
7138
  return out ?? { count: 0, next: null, previous: null, results: [] };
6789
7139
  }
6790
7140
  async function listEnriched(client, options) {
@@ -7305,68 +7655,68 @@ async function listPermissionGroups(client, options) {
7305
7655
  return out ?? [];
7306
7656
  }
7307
7657
  async function createPermissionGroup(client, payload, options) {
7308
- const path11 = "/api/it/permission_groups";
7309
- const res = await client.do("POST", path11, JSON.stringify(payload), options);
7658
+ const path12 = "/api/it/permission_groups";
7659
+ const res = await client.do("POST", path12, JSON.stringify(payload), options);
7310
7660
  const text2 = await res.text();
7311
7661
  if (res.status < 200 || res.status >= 300) {
7312
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7662
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7313
7663
  }
7314
- return parsePermissionGroup("POST", path11, text2);
7664
+ return parsePermissionGroup("POST", path12, text2);
7315
7665
  }
7316
- function parsePermissionGroup(method, path11, text2) {
7666
+ function parsePermissionGroup(method, path12, text2) {
7317
7667
  try {
7318
7668
  return JSON.parse(text2);
7319
7669
  } catch (err) {
7320
7670
  const msg = err instanceof Error ? err.message : String(err);
7321
- throw new Error(`${method} ${path11}: decode: ${msg} (body: ${truncate4(text2, 200)})`);
7671
+ throw new Error(`${method} ${path12}: decode: ${msg} (body: ${truncate4(text2, 200)})`);
7322
7672
  }
7323
7673
  }
7324
7674
  async function getPermissionGroup(client, id, options) {
7325
- const path11 = `/api/it/permission_groups/${id}`;
7326
- const res = await client.do("GET", path11, void 0, options);
7675
+ const path12 = `/api/it/permission_groups/${id}`;
7676
+ const res = await client.do("GET", path12, void 0, options);
7327
7677
  const text2 = await res.text();
7328
7678
  if (res.status < 200 || res.status >= 300) {
7329
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7679
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7330
7680
  }
7331
- return parsePermissionGroup("GET", path11, text2);
7681
+ return parsePermissionGroup("GET", path12, text2);
7332
7682
  }
7333
7683
  async function updatePermissionGroup(client, id, name, options) {
7334
- const path11 = `/api/it/permission_groups/${id}`;
7335
- const res = await client.do("PUT", path11, JSON.stringify({ name }), options);
7684
+ const path12 = `/api/it/permission_groups/${id}`;
7685
+ const res = await client.do("PUT", path12, JSON.stringify({ name }), options);
7336
7686
  const text2 = await res.text();
7337
7687
  if (res.status < 200 || res.status >= 300) {
7338
- throw new Error(`PUT ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7688
+ throw new Error(`PUT ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7339
7689
  }
7340
- return parsePermissionGroup("PUT", path11, text2);
7690
+ return parsePermissionGroup("PUT", path12, text2);
7341
7691
  }
7342
7692
  async function deletePermissionGroup(client, id, options) {
7343
- const path11 = `/api/it/permission_groups/${id}`;
7344
- const res = await client.do("DELETE", path11, void 0, options);
7693
+ const path12 = `/api/it/permission_groups/${id}`;
7694
+ const res = await client.do("DELETE", path12, void 0, options);
7345
7695
  if (res.status < 200 || res.status >= 300) {
7346
7696
  const text2 = await res.text();
7347
- throw new Error(`DELETE ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7697
+ throw new Error(`DELETE ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7348
7698
  }
7349
7699
  }
7350
- function decodeJsonBody(method, path11, text2) {
7700
+ function decodeJsonBody(method, path12, text2) {
7351
7701
  try {
7352
7702
  return JSON.parse(text2);
7353
7703
  } catch (err) {
7354
7704
  const msg = err instanceof Error ? err.message : String(err);
7355
- throw new Error(`${method} ${path11}: decode: ${msg} (body: ${truncate4(text2, 200)})`);
7705
+ throw new Error(`${method} ${path12}: decode: ${msg} (body: ${truncate4(text2, 200)})`);
7356
7706
  }
7357
7707
  }
7358
7708
  function redactPasswordsInBodyText(text2) {
7359
7709
  return text2.replace(/"password"\s*:\s*"(?:[^"\\]|\\.)*"/g, '"password":"[redacted]"');
7360
7710
  }
7361
- async function orgMigrationRequest(client, method, path11, payload, options) {
7362
- const res = await client.do(method, path11, JSON.stringify(payload), options);
7711
+ async function orgMigrationRequest(client, method, path12, payload, options) {
7712
+ const res = await client.do(method, path12, JSON.stringify(payload), options);
7363
7713
  const text2 = await res.text();
7364
7714
  if (res.status < 200 || res.status >= 300) {
7365
7715
  throw new Error(
7366
- `${method} ${path11}: HTTP ${res.status}: ${truncate4(redactPasswordsInBodyText(text2), 600)}`
7716
+ `${method} ${path12}: HTTP ${res.status}: ${truncate4(redactPasswordsInBodyText(text2), 600)}`
7367
7717
  );
7368
7718
  }
7369
- return decodeJsonBody(method, path11, text2);
7719
+ return decodeJsonBody(method, path12, text2);
7370
7720
  }
7371
7721
  async function exportCreate(client, payload, options) {
7372
7722
  return orgMigrationRequest(
@@ -7482,10 +7832,10 @@ var ALLOWED_ROLES = /* @__PURE__ */ new Set([
7482
7832
  ]);
7483
7833
  var DEFAULT_ROLE = "VIEWER";
7484
7834
  var REGISTER_IDENTITY_HEADER = "register_identity";
7485
- async function readUsersCsv(path11) {
7835
+ async function readUsersCsv(path12) {
7486
7836
  let raw;
7487
7837
  try {
7488
- raw = await fs4.readFile(path11, "utf8");
7838
+ raw = await fs4.readFile(path12, "utf8");
7489
7839
  } catch (err) {
7490
7840
  const m = err instanceof Error ? err.message : String(err);
7491
7841
  throw new Error(`read --file: ${m}`);
@@ -7665,13 +8015,13 @@ async function getRoles(client, segment, options) {
7665
8015
  return out ?? [];
7666
8016
  }
7667
8017
  async function grantRoleToUsers(client, appSegment, payload, options) {
7668
- const path11 = `/api/${appSegment}/users/grant_permissions_bulk`;
7669
- const res = await client.do("POST", path11, JSON.stringify(payload), options);
8018
+ const path12 = `/api/${appSegment}/users/grant_permissions_bulk`;
8019
+ const res = await client.do("POST", path12, JSON.stringify(payload), options);
7670
8020
  const text2 = await res.text();
7671
8021
  if (res.status >= 200 && res.status < 300) {
7672
8022
  return;
7673
8023
  }
7674
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
8024
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7675
8025
  }
7676
8026
  async function getUserTableRoles(client, userId, options) {
7677
8027
  const out = await client.getJSON(
@@ -7688,14 +8038,14 @@ async function getUserPermissionFilters(client, userId, options) {
7688
8038
  return out ?? [];
7689
8039
  }
7690
8040
  async function setUserPermissionFilters(client, userId, newFilters, options) {
7691
- const path11 = `/api/it/users/${userId}/permission_filters`;
8041
+ const path12 = `/api/it/users/${userId}/permission_filters`;
7692
8042
  const body = JSON.stringify({ new_filters: newFilters });
7693
- const res = await client.do("POST", path11, body, options);
8043
+ const res = await client.do("POST", path12, body, options);
7694
8044
  const text2 = await res.text();
7695
8045
  if (res.status >= 200 && res.status < 300) {
7696
8046
  return;
7697
8047
  }
7698
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
8048
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncate4(text2, 200)}`);
7699
8049
  }
7700
8050
  async function getTableRoles(client, options) {
7701
8051
  return getRoles(client, "table", options);
@@ -8392,10 +8742,10 @@ var EXPECTED_HEADER2 = [
8392
8742
  "filter_excluded"
8393
8743
  ];
8394
8744
  var RESOURCES = /* @__PURE__ */ new Set(["table", "element", "role", "filter"]);
8395
- async function readPermissionsCsv(path11) {
8745
+ async function readPermissionsCsv(path12) {
8396
8746
  let raw;
8397
8747
  try {
8398
- raw = await fs6.readFile(path11, "utf8");
8748
+ raw = await fs6.readFile(path12, "utf8");
8399
8749
  } catch (err) {
8400
8750
  const m = err instanceof Error ? err.message : String(err);
8401
8751
  throw new Error(`read --file: ${m}`);
@@ -8826,10 +9176,10 @@ function registerUsersBulkPermissionsCommand(users) {
8826
9176
  // src/commands/_emailRenameCsv.ts
8827
9177
  import { promises as fs7 } from "fs";
8828
9178
  var EXPECTED_HEADER3 = ["source", "target"];
8829
- async function readEmailRenameCsv(path11) {
9179
+ async function readEmailRenameCsv(path12) {
8830
9180
  let raw;
8831
9181
  try {
8832
- raw = await fs7.readFile(path11, "utf8");
9182
+ raw = await fs7.readFile(path12, "utf8");
8833
9183
  } catch (err) {
8834
9184
  const m = err instanceof Error ? err.message : String(err);
8835
9185
  throw new Error(`read --file: ${m}`);
@@ -9382,10 +9732,10 @@ function registerUsersRegisterIdentityCommand(users) {
9382
9732
 
9383
9733
  // src/commands/_payload.ts
9384
9734
  import { promises as fs8 } from "fs";
9385
- async function readAndParse(path11, flagName) {
9735
+ async function readAndParse(path12, flagName) {
9386
9736
  let raw;
9387
9737
  try {
9388
- raw = await fs8.readFile(path11, "utf8");
9738
+ raw = await fs8.readFile(path12, "utf8");
9389
9739
  } catch (err) {
9390
9740
  const m = err instanceof Error ? err.message : String(err);
9391
9741
  throw new Error(`read ${flagName}: ${m}`);
@@ -9398,15 +9748,15 @@ async function readAndParse(path11, flagName) {
9398
9748
  throw new Error(`parse ${flagName}: ${m}`);
9399
9749
  }
9400
9750
  }
9401
- async function readJsonPayload(path11, flagName = "--payload-file") {
9402
- const parsed2 = await readAndParse(path11, flagName);
9751
+ async function readJsonPayload(path12, flagName = "--payload-file") {
9752
+ const parsed2 = await readAndParse(path12, flagName);
9403
9753
  if (parsed2 === null || typeof parsed2 !== "object" || Array.isArray(parsed2)) {
9404
9754
  throw new Error(`parse ${flagName}: expected a JSON object`);
9405
9755
  }
9406
9756
  return parsed2;
9407
9757
  }
9408
- async function readJsonPayloadList(path11, flagName = "--payload-file") {
9409
- const parsed2 = await readAndParse(path11, flagName);
9758
+ async function readJsonPayloadList(path12, flagName = "--payload-file") {
9759
+ const parsed2 = await readAndParse(path12, flagName);
9410
9760
  if (Array.isArray(parsed2)) {
9411
9761
  return parsed2;
9412
9762
  }
@@ -9417,8 +9767,8 @@ async function readJsonPayloadList(path11, flagName = "--payload-file") {
9417
9767
  }
9418
9768
  throw new Error(`parse ${flagName}: expected a JSON array, got ${describeJsonValue(parsed2)}`);
9419
9769
  }
9420
- async function readJsonPayloadObjectOrList(path11, flagName = "--payload-file") {
9421
- const parsed2 = await readAndParse(path11, flagName);
9770
+ async function readJsonPayloadObjectOrList(path12, flagName = "--payload-file") {
9771
+ const parsed2 = await readAndParse(path12, flagName);
9422
9772
  if (Array.isArray(parsed2)) {
9423
9773
  return parsed2;
9424
9774
  }
@@ -10460,10 +10810,10 @@ function registerUsersCommand(root) {
10460
10810
  // src/commands/_groupCsv.ts
10461
10811
  import { promises as fs9 } from "fs";
10462
10812
  var EXPECTED_HEADER4 = ["group_name", "role", "members"];
10463
- async function readGroupsCsv(path11) {
10813
+ async function readGroupsCsv(path12) {
10464
10814
  let raw;
10465
10815
  try {
10466
- raw = await fs9.readFile(path11, "utf8");
10816
+ raw = await fs9.readFile(path12, "utf8");
10467
10817
  } catch (err) {
10468
10818
  const m = err instanceof Error ? err.message : String(err);
10469
10819
  throw new Error(`read --file: ${m}`);
@@ -11947,8 +12297,8 @@ async function getData(client, params = {}, options) {
11947
12297
  if (params.organizationClassification !== void 0) {
11948
12298
  qs.set("organization_classification", params.organizationClassification);
11949
12299
  }
11950
- const path11 = qs.toString() === "" ? "/api/it/manager_screen/data" : `/api/it/manager_screen/data?${qs.toString()}`;
11951
- const out = await client.getJSON(path11, options);
12300
+ const path12 = qs.toString() === "" ? "/api/it/manager_screen/data" : `/api/it/manager_screen/data?${qs.toString()}`;
12301
+ const out = await client.getJSON(path12, options);
11952
12302
  return out ?? EMPTY_PAGE;
11953
12303
  }
11954
12304
 
@@ -12125,7 +12475,7 @@ function registerSupportManagerCommand(root) {
12125
12475
  }
12126
12476
 
12127
12477
  // src/commands/templates.ts
12128
- import { createHash as createHash2 } from "crypto";
12478
+ import { createHash as createHash3 } from "crypto";
12129
12479
  import { promises as fs10 } from "fs";
12130
12480
 
12131
12481
  // src/commands/_envelope.ts
@@ -12198,8 +12548,8 @@ function isUnionBranchNoise(entry, valueErrors) {
12198
12548
  var RAW_TABLES_BASE = "/finance-os/api/data_models/v1/raw";
12199
12549
  var AGGREGATE_POLL_INTERVAL_MS = 1e3;
12200
12550
  var AGGREGATE_POLL_TIMEOUT_MS = 6e4;
12201
- async function startTask(client, label, path11, body, options) {
12202
- const res = await client.do("POST", path11, JSON.stringify(body), options);
12551
+ async function startTask(client, label, path12, body, options) {
12552
+ const res = await client.do("POST", path12, JSON.stringify(body), options);
12203
12553
  if (res.status !== 202) {
12204
12554
  const text2 = await res.text();
12205
12555
  throw new Error(
@@ -12281,7 +12631,7 @@ var defaultSleep2 = (ms, signal) => new Promise((resolve3, reject) => {
12281
12631
  }, ms);
12282
12632
  signal?.addEventListener("abort", onAbort, { once: true });
12283
12633
  });
12284
- async function pollTask(client, label, path11, options = {}) {
12634
+ async function pollTask(client, label, path12, options = {}) {
12285
12635
  const interval = options.pollIntervalMs ?? AGGREGATE_POLL_INTERVAL_MS;
12286
12636
  const timeout = options.timeoutMs ?? AGGREGATE_POLL_TIMEOUT_MS;
12287
12637
  const sleep3 = options.sleep ?? defaultSleep2;
@@ -12309,7 +12659,7 @@ async function pollTask(client, label, path11, options = {}) {
12309
12659
  }
12310
12660
  let result;
12311
12661
  try {
12312
- result = await getTaskOnce(client, label, path11, {
12662
+ result = await getTaskOnce(client, label, path12, {
12313
12663
  signal: tickAc.signal
12314
12664
  });
12315
12665
  } catch (err) {
@@ -12361,10 +12711,10 @@ async function listMyOrgOnly(client, options) {
12361
12711
  return out ?? [];
12362
12712
  }
12363
12713
  async function get3(client, id, options) {
12364
- const path11 = `/api/templates/${id}`;
12365
- const out = await client.getJSON(path11, options);
12714
+ const path12 = `/api/templates/${id}`;
12715
+ const out = await client.getJSON(path12, options);
12366
12716
  if (out === null) {
12367
- throw new Error(`GET ${path11}: empty response (expected a template row)`);
12717
+ throw new Error(`GET ${path12}: empty response (expected a template row)`);
12368
12718
  }
12369
12719
  return out;
12370
12720
  }
@@ -12392,8 +12742,8 @@ async function setFieldFx(client, fieldId, body, options) {
12392
12742
  return client.putJSON(`/api/templates/fields/${fieldId}`, body, options);
12393
12743
  }
12394
12744
  async function create2(client, dataModelId, name, options) {
12395
- const path11 = `/api/templates/data_models/${dataModelId}/templates`;
12396
- const out = await client.postJSON(path11, { name }, options);
12745
+ const path12 = `/api/templates/data_models/${dataModelId}/templates`;
12746
+ const out = await client.postJSON(path12, { name }, options);
12397
12747
  return out ?? {
12398
12748
  id: 0,
12399
12749
  name: "",
@@ -12401,7 +12751,7 @@ async function create2(client, dataModelId, name, options) {
12401
12751
  };
12402
12752
  }
12403
12753
  async function sample(client, id, params, options) {
12404
- const path11 = `${RAW_TABLES_BASE}/${id}/data`;
12754
+ const path12 = `${RAW_TABLES_BASE}/${id}/data`;
12405
12755
  const body = {
12406
12756
  limit: params.rows,
12407
12757
  offset: params.offset
@@ -12412,9 +12762,9 @@ async function sample(client, id, params, options) {
12412
12762
  if (params.filters && params.filters.length > 0) {
12413
12763
  body["filters"] = [...params.filters];
12414
12764
  }
12415
- const out = await client.postJSON(path11, body, options);
12765
+ const out = await client.postJSON(path12, body, options);
12416
12766
  if (out === null) {
12417
- throw new Error(`POST ${path11}: empty response from sample endpoint`);
12767
+ throw new Error(`POST ${path12}: empty response from sample endpoint`);
12418
12768
  }
12419
12769
  return out;
12420
12770
  }
@@ -12425,7 +12775,7 @@ async function distinct(client, id, fieldId, options = {}) {
12425
12775
  }
12426
12776
  var LEGACY_TABLES_BASE2 = "/finance-os/api/tables/v1";
12427
12777
  async function sampleLegacy(client, id, params, options) {
12428
- const path11 = `${LEGACY_TABLES_BASE2}/${id}/data`;
12778
+ const path12 = `${LEGACY_TABLES_BASE2}/${id}/data`;
12429
12779
  const body = {
12430
12780
  limit: params.rows,
12431
12781
  offset: params.offset,
@@ -12434,17 +12784,17 @@ async function sampleLegacy(client, id, params, options) {
12434
12784
  if (params.select && params.select.length > 0) {
12435
12785
  body["select"] = params.select;
12436
12786
  }
12437
- const out = await client.postJSON(path11, body, options);
12787
+ const out = await client.postJSON(path12, body, options);
12438
12788
  if (out === null) {
12439
- throw new Error(`POST ${path11}: empty response from sample endpoint`);
12789
+ throw new Error(`POST ${path12}: empty response from sample endpoint`);
12440
12790
  }
12441
12791
  return out;
12442
12792
  }
12443
12793
  async function distinctByNameLegacy(client, id, field, options) {
12444
- const path11 = `${LEGACY_TABLES_BASE2}/${id}/fields/by-name/${rawPathSegmentEscape(field)}/distinct`;
12445
- const out = await client.getJSON(path11, options);
12794
+ const path12 = `${LEGACY_TABLES_BASE2}/${id}/fields/by-name/${rawPathSegmentEscape(field)}/distinct`;
12795
+ const out = await client.getJSON(path12, options);
12446
12796
  if (out === null) {
12447
- throw new Error(`GET ${path11}: empty response from distinct endpoint`);
12797
+ throw new Error(`GET ${path12}: empty response from distinct endpoint`);
12448
12798
  }
12449
12799
  return out;
12450
12800
  }
@@ -13136,7 +13486,7 @@ function buildSetFieldTypeAction(changes) {
13136
13486
  };
13137
13487
  }
13138
13488
  const canonical = changes.map((c) => `${c.fieldId}:${c.newType}`).slice().sort().join("|");
13139
- const sha = createHash2("sha256").update(canonical).digest("hex").slice(0, 12);
13489
+ const sha = createHash3("sha256").update(canonical).digest("hex").slice(0, 12);
13140
13490
  return {
13141
13491
  resource: "field-batch",
13142
13492
  id: sha,
@@ -13575,10 +13925,10 @@ async function list7(client, options) {
13575
13925
  return out ?? [];
13576
13926
  }
13577
13927
  async function get4(client, id, options) {
13578
- const path11 = `/api/templates/data_models/${id}`;
13579
- const out = await client.getJSON(path11, options);
13928
+ const path12 = `/api/templates/data_models/${id}`;
13929
+ const out = await client.getJSON(path12, options);
13580
13930
  if (out === null) {
13581
- throw new Error(`GET ${path11}: empty response`);
13931
+ throw new Error(`GET ${path12}: empty response`);
13582
13932
  }
13583
13933
  return out;
13584
13934
  }
@@ -14436,7 +14786,7 @@ function registerDashboardsCommand(root) {
14436
14786
  }
14437
14787
 
14438
14788
  // src/commands/folders.ts
14439
- import { createHash as createHash3 } from "crypto";
14789
+ import { createHash as createHash4 } from "crypto";
14440
14790
 
14441
14791
  // src/api/folders.ts
14442
14792
  var FOLDER_ENTITY_TYPES = ["dashboard", "story"];
@@ -14461,17 +14811,17 @@ async function create4(client, entityType, name, parentId, options) {
14461
14811
  return out;
14462
14812
  }
14463
14813
  async function reorder(client, payload, options) {
14464
- const path11 = "/api/folders/reorder";
14465
- const res = await client.do("POST", path11, JSON.stringify(payload), options);
14814
+ const path12 = "/api/folders/reorder";
14815
+ const res = await client.do("POST", path12, JSON.stringify(payload), options);
14466
14816
  if (!res.ok) {
14467
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${await res.text()}`);
14817
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${await res.text()}`);
14468
14818
  }
14469
14819
  }
14470
14820
  async function move(client, folderId, parentId, options) {
14471
- const path11 = `/api/folders/${folderId}`;
14472
- const out = await client.patchJSON(path11, { parent_id: parentId }, options);
14821
+ const path12 = `/api/folders/${folderId}`;
14822
+ const out = await client.patchJSON(path12, { parent_id: parentId }, options);
14473
14823
  if (out === null) {
14474
- throw new Error(`unexpected empty response from PATCH ${path11}`);
14824
+ throw new Error(`unexpected empty response from PATCH ${path12}`);
14475
14825
  }
14476
14826
  return out;
14477
14827
  }
@@ -14595,7 +14945,7 @@ function containerLabel(containerId, names) {
14595
14945
  }
14596
14946
  var itemKey = (i) => `${i.kind}:${i.id}`;
14597
14947
  function reorderConfirmId(entityType, containerArg, request) {
14598
- const sha = createHash3("sha256").update(request).digest("hex").slice(0, 12);
14948
+ const sha = createHash4("sha256").update(request).digest("hex").slice(0, 12);
14599
14949
  return `${entityType}:${containerArg}:${sha}`;
14600
14950
  }
14601
14951
  function flagOffError(entityType, err) {
@@ -15486,19 +15836,19 @@ var CacheKeyHttpError = class extends Error {
15486
15836
  status;
15487
15837
  path;
15488
15838
  bodyText;
15489
- constructor(method, path11, status2, bodyText) {
15490
- super(`${method} ${path11}: HTTP ${status2}: ${truncate5(bodyText, 200)}`);
15839
+ constructor(method, path12, status2, bodyText) {
15840
+ super(`${method} ${path12}: HTTP ${status2}: ${truncate5(bodyText, 200)}`);
15491
15841
  this.name = "CacheKeyHttpError";
15492
15842
  this.status = status2;
15493
- this.path = path11;
15843
+ this.path = path12;
15494
15844
  this.bodyText = bodyText;
15495
15845
  }
15496
15846
  };
15497
- async function putOnce(client, path11, body, options) {
15498
- const res = await client.do("PUT", path11, body, options);
15847
+ async function putOnce(client, path12, body, options) {
15848
+ const res = await client.do("PUT", path12, body, options);
15499
15849
  const text2 = await res.text();
15500
15850
  if (res.status !== 409 && (res.status < 200 || res.status >= 300)) {
15501
- throw new CacheKeyHttpError("PUT", path11, res.status, text2);
15851
+ throw new CacheKeyHttpError("PUT", path12, res.status, text2);
15502
15852
  }
15503
15853
  if (text2 === "" || text2 === '""') {
15504
15854
  return { status: res.status, parsed: null };
@@ -15507,7 +15857,7 @@ async function putOnce(client, path11, body, options) {
15507
15857
  return { status: res.status, parsed: JSON.parse(text2) };
15508
15858
  } catch (err) {
15509
15859
  const msg = err instanceof Error ? err.message : String(err);
15510
- throw new Error(`PUT ${path11}: decode: ${msg}`);
15860
+ throw new Error(`PUT ${path12}: decode: ${msg}`);
15511
15861
  }
15512
15862
  }
15513
15863
  function extractCacheKey(body) {
@@ -15521,8 +15871,8 @@ function extractCacheKey(body) {
15521
15871
  }
15522
15872
  return "";
15523
15873
  }
15524
- function withCacheKey(path11, key) {
15525
- return `${path11}?cache_key=${encodeURIComponent(key)}`;
15874
+ function withCacheKey(path12, key) {
15875
+ return `${path12}?cache_key=${encodeURIComponent(key)}`;
15526
15876
  }
15527
15877
  var CACHE_KEY_POLL_INTERVAL_MS = 500;
15528
15878
  var abortableSleep = (ms, signal) => new Promise((resolve3, reject) => {
@@ -15540,22 +15890,22 @@ var abortableSleep = (ms, signal) => new Promise((resolve3, reject) => {
15540
15890
  }, ms);
15541
15891
  signal?.addEventListener("abort", onAbort, { once: true });
15542
15892
  });
15543
- async function putWithCacheKeyPolling(client, path11, payload, options = {}) {
15893
+ async function putWithCacheKeyPolling(client, path12, payload, options = {}) {
15544
15894
  const interval = options.pollIntervalMs ?? CACHE_KEY_POLL_INTERVAL_MS;
15545
15895
  const sleep3 = options.sleep ?? abortableSleep;
15546
15896
  const label = options.label ?? "data";
15547
15897
  const body = JSON.stringify(payload);
15548
- const first = await putOnce(client, path11, body, options);
15898
+ const first = await putOnce(client, path12, body, options);
15549
15899
  if (first.status !== 409) {
15550
15900
  return first.parsed;
15551
15901
  }
15552
15902
  const cacheKey = extractCacheKey(first.parsed);
15553
15903
  if (cacheKey === "") {
15554
15904
  throw new Error(
15555
- `PUT ${path11}: 409 without cache_key: ${truncate5(JSON.stringify(first.parsed ?? ""), 200)}`
15905
+ `PUT ${path12}: 409 without cache_key: ${truncate5(JSON.stringify(first.parsed ?? ""), 200)}`
15556
15906
  );
15557
15907
  }
15558
- const pollPath = withCacheKey(path11, cacheKey);
15908
+ const pollPath = withCacheKey(path12, cacheKey);
15559
15909
  for (; ; ) {
15560
15910
  try {
15561
15911
  await sleep3(interval, options.signal);
@@ -15748,13 +16098,13 @@ function parseDrilldown(body) {
15748
16098
  async function exportDrilldownCsv(client, id, body, options = {}) {
15749
16099
  const interval = options.pollIntervalMs ?? CACHE_KEY_POLL_INTERVAL_MS;
15750
16100
  const sleep3 = options.sleep ?? abortableSleep;
15751
- const path11 = `/api/functions/${id}/drilldown/export_to_csv`;
16101
+ const path12 = `/api/functions/${id}/drilldown/export_to_csv`;
15752
16102
  const payload = JSON.stringify(body);
15753
- let res = await putOnce(client, path11, payload, options);
16103
+ let res = await putOnce(client, path12, payload, options);
15754
16104
  while (res.status === 409) {
15755
16105
  const key = extractCacheKey(res.parsed);
15756
16106
  if (key === "") {
15757
- throw new Error(`PUT ${path11}: 409 without cache_key: ${preview(res.parsed)}`);
16107
+ throw new Error(`PUT ${path12}: 409 without cache_key: ${preview(res.parsed)}`);
15758
16108
  }
15759
16109
  for (; ; ) {
15760
16110
  try {
@@ -15781,12 +16131,12 @@ async function exportDrilldownCsv(client, id, body, options = {}) {
15781
16131
  if (e["is_ready"] === true) break;
15782
16132
  }
15783
16133
  }
15784
- res = await putOnce(client, withCacheKey(path11, key), payload, options);
16134
+ res = await putOnce(client, withCacheKey(path12, key), payload, options);
15785
16135
  }
15786
16136
  const parsed2 = res.parsed;
15787
16137
  const reportId = parsed2 !== null && typeof parsed2 === "object" ? parsed2["drill_down_report_id"] : void 0;
15788
16138
  if (typeof reportId !== "number") {
15789
- throw new Error(`PUT ${path11}: no drill_down_report_id in ${preview(parsed2)}`);
16139
+ throw new Error(`PUT ${path12}: no drill_down_report_id in ${preview(parsed2)}`);
15790
16140
  }
15791
16141
  const reportPath = `/api/dashboards/report/${reportId}?report_type=drill_down_report`;
15792
16142
  const report = await client.do("GET", reportPath, void 0, options);
@@ -16809,23 +17159,23 @@ function registerFunctionsCommand(root) {
16809
17159
 
16810
17160
  // src/api/semanticTables.ts
16811
17161
  async function list12(client, options) {
16812
- const path11 = "/finance-os/api/semantictables/v1/";
16813
- const out = await client.getJSON(path11, options);
17162
+ const path12 = "/finance-os/api/semantictables/v1/";
17163
+ const out = await client.getJSON(path12, options);
16814
17164
  if (out === null) {
16815
17165
  return { success: true, data: [], error: null };
16816
17166
  }
16817
17167
  return out;
16818
17168
  }
16819
17169
  async function get7(client, alias, options) {
16820
- const path11 = `/finance-os/api/semantictables/v1/by-alias/${rawPathSegmentEscape(alias)}`;
16821
- const out = await client.getJSON(path11, options);
17170
+ const path12 = `/finance-os/api/semantictables/v1/by-alias/${rawPathSegmentEscape(alias)}`;
17171
+ const out = await client.getJSON(path12, options);
16822
17172
  if (out === null) {
16823
- throw new Error(`GET ${path11}: empty response from semantictables get`);
17173
+ throw new Error(`GET ${path12}: empty response from semantictables get`);
16824
17174
  }
16825
17175
  return out;
16826
17176
  }
16827
17177
  async function data3(client, alias, params, options) {
16828
- const path11 = `/finance-os/api/semantictables/v1/${rawPathSegmentEscape(alias)}/data`;
17178
+ const path12 = `/finance-os/api/semantictables/v1/${rawPathSegmentEscape(alias)}/data`;
16829
17179
  const body = {
16830
17180
  limit: params.rows,
16831
17181
  offset: params.offset,
@@ -16837,17 +17187,17 @@ async function data3(client, alias, params, options) {
16837
17187
  if (params.filters && params.filters.length > 0) {
16838
17188
  body["filters"] = params.filters;
16839
17189
  }
16840
- const out = await client.postJSON(path11, body, options);
17190
+ const out = await client.postJSON(path12, body, options);
16841
17191
  if (out === null) {
16842
- throw new Error(`POST ${path11}: empty response from semantictables data`);
17192
+ throw new Error(`POST ${path12}: empty response from semantictables data`);
16843
17193
  }
16844
17194
  return out;
16845
17195
  }
16846
17196
  async function distinct2(client, alias, field, options) {
16847
- const path11 = `/finance-os/api/semantictables/v1/${rawPathSegmentEscape(alias)}/fields/by-alias/${rawPathSegmentEscape(field)}/distinct`;
16848
- const out = await client.getJSON(path11, options);
17197
+ const path12 = `/finance-os/api/semantictables/v1/${rawPathSegmentEscape(alias)}/fields/by-alias/${rawPathSegmentEscape(field)}/distinct`;
17198
+ const out = await client.getJSON(path12, options);
16849
17199
  if (out === null) {
16850
- throw new Error(`GET ${path11}: empty response from semantictables distinct`);
17200
+ throw new Error(`GET ${path12}: empty response from semantictables distinct`);
16851
17201
  }
16852
17202
  return out;
16853
17203
  }
@@ -17266,23 +17616,23 @@ function findByTableId(items, titleOf, tableId, variant) {
17266
17616
  return hits[0];
17267
17617
  }
17268
17618
  function tablePagePath(key, q) {
17269
- let path11 = `/OData.svc/${key}?$top=${q.top}&$skip=${q.skip}`;
17619
+ let path12 = `/OData.svc/${key}?$top=${q.top}&$skip=${q.skip}`;
17270
17620
  if (q.select !== void 0 && q.select.length > 0) {
17271
- path11 += `&$select=${encodeURIComponent(q.select.join(","))}`;
17621
+ path12 += `&$select=${encodeURIComponent(q.select.join(","))}`;
17272
17622
  }
17273
17623
  if (q.filter !== void 0 && q.filter !== "") {
17274
- path11 += `&$filter=${encodeURIComponent(q.filter)}`;
17624
+ path12 += `&$filter=${encodeURIComponent(q.filter)}`;
17275
17625
  }
17276
- return path11;
17626
+ return path12;
17277
17627
  }
17278
- async function getXml(client, path11, accept, options) {
17279
- const res = await client.do("GET", path11, void 0, {
17628
+ async function getXml(client, path12, accept, options) {
17629
+ const res = await client.do("GET", path12, void 0, {
17280
17630
  ...options,
17281
17631
  headers: { ...options?.headers, Accept: accept }
17282
17632
  });
17283
17633
  const body = await res.text();
17284
17634
  if (res.status < 200 || res.status >= 300) {
17285
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncate4(body, 200)}`);
17635
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncate4(body, 200)}`);
17286
17636
  }
17287
17637
  return body;
17288
17638
  }
@@ -17621,10 +17971,10 @@ async function list13(client, options) {
17621
17971
  return out;
17622
17972
  }
17623
17973
  async function get8(client, id, options) {
17624
- const path11 = `/api/storytelling/${id}`;
17625
- const out = await client.getJSON(path11, options);
17974
+ const path12 = `/api/storytelling/${id}`;
17975
+ const out = await client.getJSON(path12, options);
17626
17976
  if (out === null) {
17627
- throw new Error(`GET ${path11}: empty response from storyboards get`);
17977
+ throw new Error(`GET ${path12}: empty response from storyboards get`);
17628
17978
  }
17629
17979
  return out;
17630
17980
  }
@@ -17907,18 +18257,18 @@ async function list14(client, options) {
17907
18257
  return out ?? [];
17908
18258
  }
17909
18259
  async function get9(client, id, options) {
17910
- const path11 = `/api/extables/${id}`;
17911
- const out = await client.getJSON(path11, options);
18260
+ const path12 = `/api/extables/${id}`;
18261
+ const out = await client.getJSON(path12, options);
17912
18262
  if (out === null) {
17913
- throw new Error(`GET ${path11}: empty response from extables get`);
18263
+ throw new Error(`GET ${path12}: empty response from extables get`);
17914
18264
  }
17915
18265
  return out;
17916
18266
  }
17917
18267
  async function clone(client, id, name, options) {
17918
- const path11 = `/api/extables/${id}/clone`;
17919
- const out = await client.postJSON(path11, { name }, options);
18268
+ const path12 = `/api/extables/${id}/clone`;
18269
+ const out = await client.postJSON(path12, { name }, options);
17920
18270
  if (out === null) {
17921
- throw new Error(`POST ${path11}: empty response from extables clone`);
18271
+ throw new Error(`POST ${path12}: empty response from extables clone`);
17922
18272
  }
17923
18273
  return out;
17924
18274
  }
@@ -18184,18 +18534,18 @@ async function getMappedData(client, documentId, lutId, options) {
18184
18534
  return out ?? {};
18185
18535
  }
18186
18536
  async function create7(client, tableId, body, options) {
18187
- const path11 = `/api/templates/${tableId}/lutdocuments`;
18188
- const out = await client.postJSON(path11, body, options);
18537
+ const path12 = `/api/templates/${tableId}/lutdocuments`;
18538
+ const out = await client.postJSON(path12, body, options);
18189
18539
  if (out === null) {
18190
- throw new Error(`POST ${path11}: empty response from lut create`);
18540
+ throw new Error(`POST ${path12}: empty response from lut create`);
18191
18541
  }
18192
18542
  return out;
18193
18543
  }
18194
18544
  async function update3(client, id, body, options) {
18195
- const path11 = `/api/templates/lutdocuments/${id}`;
18196
- const out = await client.putJSON(path11, body, options);
18545
+ const path12 = `/api/templates/lutdocuments/${id}`;
18546
+ const out = await client.putJSON(path12, body, options);
18197
18547
  if (out === null) {
18198
- throw new Error(`PUT ${path11}: empty response from lut update`);
18548
+ throw new Error(`PUT ${path12}: empty response from lut update`);
18199
18549
  }
18200
18550
  return out;
18201
18551
  }
@@ -18213,19 +18563,19 @@ async function saveMappings(client, documentId, body, options = {}) {
18213
18563
  const sleep3 = options.sleep ?? defaultPollSleep;
18214
18564
  const now = options.now ?? Date.now;
18215
18565
  const deadline = now() + timeout;
18216
- const path11 = `/api/documents/${documentId}/web_update_lut`;
18566
+ const path12 = `/api/documents/${documentId}/web_update_lut`;
18217
18567
  const payload = JSON.stringify(body);
18218
- const first = await postOnce(client, path11, payload, options.signal);
18568
+ const first = await postOnce(client, path12, payload, options.signal);
18219
18569
  if (first.status === 200) {
18220
18570
  return toResult(first.text);
18221
18571
  }
18222
18572
  const cacheKey = extractCacheKey2(first.text);
18223
18573
  if (cacheKey === "") {
18224
18574
  throw new Error(
18225
- `POST ${path11}: HTTP ${first.status} without a cache_key to join: ${truncateBody(first.text)}`
18575
+ `POST ${path12}: HTTP ${first.status} without a cache_key to join: ${truncateBody(first.text)}`
18226
18576
  );
18227
18577
  }
18228
- const pollPath = `${path11}?cache_key=${encodeURIComponent(cacheKey)}`;
18578
+ const pollPath = `${path12}?cache_key=${encodeURIComponent(cacheKey)}`;
18229
18579
  for (; ; ) {
18230
18580
  if (now() >= deadline) {
18231
18581
  throw new Error(
@@ -18239,13 +18589,13 @@ async function saveMappings(client, documentId, body, options = {}) {
18239
18589
  }
18240
18590
  }
18241
18591
  }
18242
- async function postOnce(client, path11, payload, signal) {
18243
- const res = await client.do("POST", path11, payload, { signal });
18592
+ async function postOnce(client, path12, payload, signal) {
18593
+ const res = await client.do("POST", path12, payload, { signal });
18244
18594
  const text2 = await res.text();
18245
18595
  if (res.status === 200 || res.status === 409) {
18246
18596
  return { status: res.status, text: text2 };
18247
18597
  }
18248
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncateBody(text2)}`);
18598
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncateBody(text2)}`);
18249
18599
  }
18250
18600
  function extractCacheKey2(text2) {
18251
18601
  try {
@@ -18288,12 +18638,12 @@ var defaultPollSleep = (ms, signal) => new Promise((resolve3, reject) => {
18288
18638
  signal?.addEventListener("abort", onAbort, { once: true });
18289
18639
  });
18290
18640
  async function getLutFile(client, documentId, options) {
18291
- const path11 = `/api/documents/${documentId}/lut-file`;
18292
- const res = await client.do("GET", path11, void 0, options);
18641
+ const path12 = `/api/documents/${documentId}/lut-file`;
18642
+ const res = await client.do("GET", path12, void 0, options);
18293
18643
  if (res.status < 200 || res.status >= 300) {
18294
18644
  const text2 = await res.text();
18295
18645
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
18296
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncated}`);
18646
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncated}`);
18297
18647
  }
18298
18648
  const ab = await res.arrayBuffer();
18299
18649
  return Buffer.from(ab);
@@ -18327,12 +18677,12 @@ async function calculate(client, id, body, reqOptions) {
18327
18677
  await client.putJSON(`/api/documents/${id}/calculate`, body, reqOptions);
18328
18678
  }
18329
18679
  async function downloadDebugZip(client, docVersionId, type, reqOptions) {
18330
- const path11 = `/api/documents/download_debug_zip_file/${docVersionId}?type=${type}`;
18331
- const res = await client.do("GET", path11, void 0, reqOptions);
18680
+ const path12 = `/api/documents/download_debug_zip_file/${docVersionId}?type=${type}`;
18681
+ const res = await client.do("GET", path12, void 0, reqOptions);
18332
18682
  if (res.status < 200 || res.status >= 300) {
18333
18683
  const text2 = await res.text();
18334
18684
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
18335
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncated}`);
18685
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncated}`);
18336
18686
  }
18337
18687
  const ab = await res.arrayBuffer();
18338
18688
  return Buffer.from(ab);
@@ -18436,8 +18786,8 @@ async function startAddDynamicRanges(client, file, filename, dynamicRanges, reqO
18436
18786
  );
18437
18787
  }
18438
18788
  async function getDocumentJobStatusOnce(client, basePath, requestId, reqOptions) {
18439
- const path11 = `${basePath}/${requestId}`;
18440
- const res = await client.do("GET", path11, void 0, reqOptions);
18789
+ const path12 = `${basePath}/${requestId}`;
18790
+ const res = await client.do("GET", path12, void 0, reqOptions);
18441
18791
  if (res.status === 202) {
18442
18792
  await res.text();
18443
18793
  return { kind: "processing" };
@@ -18704,22 +19054,22 @@ async function syncDataQuery(client, id, body, reqOptions) {
18704
19054
  return out ?? {};
18705
19055
  }
18706
19056
  async function getAutoCalculateSettings(client, docId, reqOptions) {
18707
- const path11 = `/api/documents/${docId}/auto_calculate_settings`;
18708
- const res = await client.do("GET", path11, void 0, reqOptions);
19057
+ const path12 = `/api/documents/${docId}/auto_calculate_settings`;
19058
+ const res = await client.do("GET", path12, void 0, reqOptions);
18709
19059
  if (res.status === 404) {
18710
19060
  await res.text().catch(() => "");
18711
19061
  return null;
18712
19062
  }
18713
19063
  const text2 = await res.text();
18714
19064
  if (res.status < 200 || res.status >= 300) {
18715
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${text2.slice(0, 200)}`);
19065
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${text2.slice(0, 200)}`);
18716
19066
  }
18717
19067
  if (text2 === "" || text2 === '""') return null;
18718
19068
  try {
18719
19069
  return JSON.parse(text2);
18720
19070
  } catch (err) {
18721
19071
  const msg = err instanceof Error ? err.message : String(err);
18722
- throw new Error(`GET ${path11}: decode: ${msg}`);
19072
+ throw new Error(`GET ${path12}: decode: ${msg}`);
18723
19073
  }
18724
19074
  }
18725
19075
  async function enableAutoCalculate(client, docId, reqOptions) {
@@ -19961,10 +20311,10 @@ function registerLutCommand(root) {
19961
20311
 
19962
20312
  // src/api/scans.ts
19963
20313
  async function getStatus(client, tableId, options) {
19964
- const path11 = `/api/scans/status/${tableId}`;
19965
- const out = await client.getJSON(path11, options);
20314
+ const path12 = `/api/scans/status/${tableId}`;
20315
+ const out = await client.getJSON(path12, options);
19966
20316
  if (out === null) {
19967
- throw new Error(`GET ${path11}: empty response from scans status`);
20317
+ throw new Error(`GET ${path12}: empty response from scans status`);
19968
20318
  }
19969
20319
  return out;
19970
20320
  }
@@ -20243,18 +20593,18 @@ async function list17(client, options) {
20243
20593
  return out ?? [];
20244
20594
  }
20245
20595
  async function get10(client, id, options) {
20246
- const path11 = `/api/exreports/reports/${id}`;
20247
- const out = await client.getJSON(path11, options);
20596
+ const path12 = `/api/exreports/reports/${id}`;
20597
+ const out = await client.getJSON(path12, options);
20248
20598
  if (out === null) {
20249
- throw new Error(`GET ${path11}: empty response from reports get`);
20599
+ throw new Error(`GET ${path12}: empty response from reports get`);
20250
20600
  }
20251
20601
  return out;
20252
20602
  }
20253
20603
  async function clone2(client, id, name, options) {
20254
- const path11 = `/api/exreports/reports/${id}/clone`;
20255
- const out = await client.postJSON(path11, { name }, options);
20604
+ const path12 = `/api/exreports/reports/${id}/clone`;
20605
+ const out = await client.postJSON(path12, { name }, options);
20256
20606
  if (out === null) {
20257
- throw new Error(`POST ${path11}: empty response from reports clone`);
20607
+ throw new Error(`POST ${path12}: empty response from reports clone`);
20258
20608
  }
20259
20609
  return out;
20260
20610
  }
@@ -20733,8 +21083,8 @@ async function loadDefinition(payloadFile, mutations) {
20733
21083
  }
20734
21084
  return out;
20735
21085
  }
20736
- async function writeJsonFile(path11, value) {
20737
- await fs12.writeFile(path11, JSON.stringify(value, null, 2) + "\n", "utf8");
21086
+ async function writeJsonFile(path12, value) {
21087
+ await fs12.writeFile(path12, JSON.stringify(value, null, 2) + "\n", "utf8");
20738
21088
  }
20739
21089
  function designSummary(def) {
20740
21090
  const design = typeof def.options?.design === "string" ? def.options.design : "-";
@@ -21059,8 +21409,8 @@ function registerBudgetBuilderCommand(root) {
21059
21409
 
21060
21410
  // src/api/dataflow.ts
21061
21411
  async function get11(client, templateId, options) {
21062
- const path11 = `/api/dataflow/${templateId}/data`;
21063
- const out = await client.putJSON(path11, {}, options);
21412
+ const path12 = `/api/dataflow/${templateId}/data`;
21413
+ const out = await client.putJSON(path12, {}, options);
21064
21414
  return out ?? [];
21065
21415
  }
21066
21416
 
@@ -21189,8 +21539,8 @@ function registerDataflowCommand(root) {
21189
21539
 
21190
21540
  // src/api/metrics.ts
21191
21541
  async function listSemantic(client, options) {
21192
- const path11 = "/finance-os/api/metrics/v1/semantic_list";
21193
- const out = await client.getJSON(path11, options);
21542
+ const path12 = "/finance-os/api/metrics/v1/semantic_list";
21543
+ const out = await client.getJSON(path12, options);
21194
21544
  if (out === null) {
21195
21545
  return {
21196
21546
  success: true,
@@ -21201,23 +21551,23 @@ async function listSemantic(client, options) {
21201
21551
  return out;
21202
21552
  }
21203
21553
  async function listRaw2(client, options) {
21204
- const path11 = "/finance-os/api/metrics/v1/";
21205
- const out = await client.getJSON(path11, options);
21554
+ const path12 = "/finance-os/api/metrics/v1/";
21555
+ const out = await client.getJSON(path12, options);
21206
21556
  if (out === null) {
21207
21557
  return { success: true, data: [], error: null };
21208
21558
  }
21209
21559
  return out;
21210
21560
  }
21211
21561
  async function get12(client, id, options) {
21212
- const path11 = `/finance-os/api/metrics/v1/${id}`;
21213
- const out = await client.getJSON(path11, options);
21562
+ const path12 = `/finance-os/api/metrics/v1/${id}`;
21563
+ const out = await client.getJSON(path12, options);
21214
21564
  if (out === null) {
21215
- throw new Error(`GET ${path11}: empty response from metrics get`);
21565
+ throw new Error(`GET ${path12}: empty response from metrics get`);
21216
21566
  }
21217
21567
  return out;
21218
21568
  }
21219
21569
  async function getData2(client, params, options) {
21220
- const path11 = "/finance-os/api/metrics/v1/data";
21570
+ const path12 = "/finance-os/api/metrics/v1/data";
21221
21571
  const body = {
21222
21572
  metric_ids: params.metric_ids,
21223
21573
  aggregation_period: params.aggregation_period,
@@ -21238,14 +21588,14 @@ async function getData2(client, params, options) {
21238
21588
  if (params.dimension_filters !== void 0 && Object.keys(params.dimension_filters).length > 0) {
21239
21589
  body["dimension_filters"] = params.dimension_filters;
21240
21590
  }
21241
- const out = await client.postJSON(path11, body, options);
21591
+ const out = await client.postJSON(path12, body, options);
21242
21592
  if (out === null) {
21243
- throw new Error(`POST ${path11}: empty response from metrics data`);
21593
+ throw new Error(`POST ${path12}: empty response from metrics data`);
21244
21594
  }
21245
21595
  return out;
21246
21596
  }
21247
21597
  async function drilldown2(client, params, options) {
21248
- const path11 = "/finance-os/api/metrics/v1/drill_down";
21598
+ const path12 = "/finance-os/api/metrics/v1/drill_down";
21249
21599
  const body = {
21250
21600
  metric_ids: params.metric_ids
21251
21601
  };
@@ -21259,12 +21609,12 @@ async function drilldown2(client, params, options) {
21259
21609
  body["dimension_filters"] = params.dimension_filters;
21260
21610
  }
21261
21611
  const out = await client.postJSON(
21262
- path11,
21612
+ path12,
21263
21613
  body,
21264
21614
  options
21265
21615
  );
21266
21616
  if (out === null) {
21267
- throw new Error(`POST ${path11}: empty response from metrics drilldown`);
21617
+ throw new Error(`POST ${path12}: empty response from metrics drilldown`);
21268
21618
  }
21269
21619
  return out;
21270
21620
  }
@@ -21298,7 +21648,7 @@ function parseDimensionFilters(raw) {
21298
21648
  }
21299
21649
 
21300
21650
  // src/commands/metricsCreate.ts
21301
- import { createHash as createHash4 } from "crypto";
21651
+ import { createHash as createHash5 } from "crypto";
21302
21652
 
21303
21653
  // src/api/metricsMonolith.ts
21304
21654
  async function create9(client, body, options) {
@@ -21434,9 +21784,9 @@ async function listDimensions(client, params, options) {
21434
21784
  if (params?.metric !== void 0) {
21435
21785
  qs.push(`metric=${params.metric}`);
21436
21786
  }
21437
- const path11 = qs.length > 0 ? `/api/insights/dimensions?${qs.join("&")}` : "/api/insights/dimensions";
21787
+ const path12 = qs.length > 0 ? `/api/insights/dimensions?${qs.join("&")}` : "/api/insights/dimensions";
21438
21788
  const out = await client.getJSON(
21439
- path11,
21789
+ path12,
21440
21790
  options
21441
21791
  );
21442
21792
  return unwrapList(out);
@@ -21893,34 +22243,34 @@ function reAggregateFailureMessage(progress, outcome, waitedSec) {
21893
22243
 
21894
22244
  // src/api/suggestions.ts
21895
22245
  async function listMetricSuggestions(client, options) {
21896
- const path11 = "/api/insights/metric_suggestions";
21897
- const out = await client.getJSON(path11, options);
22246
+ const path12 = "/api/insights/metric_suggestions";
22247
+ const out = await client.getJSON(path12, options);
21898
22248
  if (out === null) {
21899
- throw new Error(`GET ${path11}: empty response (expected {suggestions, dismissed, last_run})`);
22249
+ throw new Error(`GET ${path12}: empty response (expected {suggestions, dismissed, last_run})`);
21900
22250
  }
21901
22251
  return out;
21902
22252
  }
21903
22253
  async function refreshMetricSuggestions(client, options) {
21904
- const path11 = "/api/insights/metric_suggestions/refresh";
21905
- const out = await client.postJSON(path11, {}, options);
22254
+ const path12 = "/api/insights/metric_suggestions/refresh";
22255
+ const out = await client.postJSON(path12, {}, options);
21906
22256
  if (out === null) {
21907
- throw new Error(`POST ${path11}: empty response (expected 202 with {run_id})`);
22257
+ throw new Error(`POST ${path12}: empty response (expected 202 with {run_id})`);
21908
22258
  }
21909
22259
  return out;
21910
22260
  }
21911
22261
  async function listDimensionSuggestions(client, options) {
21912
- const path11 = "/api/insights/dimension_suggestions";
21913
- const out = await client.getJSON(path11, options);
22262
+ const path12 = "/api/insights/dimension_suggestions";
22263
+ const out = await client.getJSON(path12, options);
21914
22264
  if (out === null) {
21915
- throw new Error(`GET ${path11}: empty response (expected {suggestions, dismissed, last_run})`);
22265
+ throw new Error(`GET ${path12}: empty response (expected {suggestions, dismissed, last_run})`);
21916
22266
  }
21917
22267
  return out;
21918
22268
  }
21919
22269
  async function refreshDimensionSuggestions(client, options) {
21920
- const path11 = "/api/insights/dimension_suggestions/refresh";
21921
- const out = await client.postJSON(path11, {}, options);
22270
+ const path12 = "/api/insights/dimension_suggestions/refresh";
22271
+ const out = await client.postJSON(path12, {}, options);
21922
22272
  if (out === null) {
21923
- throw new Error(`POST ${path11}: empty response (expected 202 with {run_id})`);
22273
+ throw new Error(`POST ${path12}: empty response (expected 202 with {run_id})`);
21924
22274
  }
21925
22275
  return out;
21926
22276
  }
@@ -21950,71 +22300,6 @@ async function mapWithConcurrency(items, concurrency, task) {
21950
22300
  return results;
21951
22301
  }
21952
22302
 
21953
- // src/commands/_retry.ts
21954
- var AMBIGUOUS_STATUSES = /* @__PURE__ */ new Set([502, 504, 524]);
21955
- var MAX_BACKOFF_MS = 8e3;
21956
- function isAbortError(err) {
21957
- if (typeof err !== "object" || err === null) return false;
21958
- const name = err.name;
21959
- if (name === "AbortError" || name === "TimeoutError") return true;
21960
- return err.code === "ABORT_ERR";
21961
- }
21962
- function httpStatusOf(err) {
21963
- const msg = err instanceof Error ? err.message : String(err);
21964
- const m = /\bHTTP (\d{3})\b/.exec(msg);
21965
- return m === null ? void 0 : Number(m[1]);
21966
- }
21967
- function classifyFailure(err) {
21968
- if (isAbortError(err)) return "abort";
21969
- const status2 = httpStatusOf(err);
21970
- if (status2 === void 0) return "transient";
21971
- if (AMBIGUOUS_STATUSES.has(status2)) return "ambiguous";
21972
- if (status2 === 429) return "transient";
21973
- if (status2 >= 400 && status2 < 500) return "client";
21974
- return "transient";
21975
- }
21976
- function defaultBackoffMs(failedAttempt) {
21977
- return Math.min(1e3 * 2 ** (failedAttempt - 1), MAX_BACKOFF_MS);
21978
- }
21979
- async function sleep2(ms, signal) {
21980
- if (ms <= 0) return;
21981
- if (signal?.aborted === true) throw abortErrorFor(signal);
21982
- await new Promise((resolve3, reject) => {
21983
- const timer = setTimeout(() => {
21984
- signal?.removeEventListener("abort", onAbort);
21985
- resolve3();
21986
- }, ms);
21987
- function onAbort() {
21988
- clearTimeout(timer);
21989
- reject(abortErrorFor(signal));
21990
- }
21991
- signal?.addEventListener("abort", onAbort, { once: true });
21992
- });
21993
- }
21994
- function abortErrorFor(signal) {
21995
- const reason = signal?.reason;
21996
- if (reason instanceof Error) return reason;
21997
- return Object.assign(new Error("This operation was aborted"), {
21998
- name: "AbortError"
21999
- });
22000
- }
22001
- async function retryAsync(fn, opts) {
22002
- const retries = Number.isFinite(opts.retries) ? Math.max(0, Math.floor(opts.retries)) : 0;
22003
- for (let attempt = 1; ; attempt++) {
22004
- try {
22005
- return await fn();
22006
- } catch (err) {
22007
- const kind = classifyFailure(err);
22008
- const retryable = kind === "transient" || kind !== "abort" && opts.alsoRetry?.(err) === true;
22009
- if (!retryable || attempt > retries) throw err;
22010
- const delay = opts.delayMs ?? defaultBackoffMs;
22011
- const waitMs = typeof delay === "function" ? delay(attempt) : delay;
22012
- opts.onRetry?.(attempt, err, waitMs);
22013
- await sleep2(waitMs, opts.signal);
22014
- }
22015
- }
22016
- }
22017
-
22018
22303
  // src/commands/_fieldScreens.ts
22019
22304
  var SYSTEM_CATEGORY = "system";
22020
22305
  var SYSTEM_FIELD_NAMES = [
@@ -22712,9 +22997,9 @@ async function fetchRowCounts(client, tables, concurrency, opts, retryDelayMs) {
22712
22997
  }
22713
22998
  return { counts, unavailable, failures };
22714
22999
  }
22715
- async function writeOwnerOnly(path11, contents) {
22716
- await writeFile2(path11, contents, { encoding: "utf8", mode: 384 });
22717
- if (process.platform !== "win32") await chmod2(path11, 384);
23000
+ async function writeOwnerOnly(path12, contents) {
23001
+ await writeFile2(path12, contents, { encoding: "utf8", mode: 384 });
23002
+ if (process.platform !== "win32") await chmod2(path12, 384);
22718
23003
  }
22719
23004
  function errText(e) {
22720
23005
  return (e instanceof Error ? e.message : String(e)).replace(/\s+/g, " ").trim();
@@ -22806,20 +23091,20 @@ function parseSuppressionDimension(d, source, i) {
22806
23091
  });
22807
23092
  return { name, mappings };
22808
23093
  }
22809
- async function loadSuppression(path11) {
23094
+ async function loadSuppression(path12) {
22810
23095
  let text2;
22811
23096
  try {
22812
- text2 = await readFile2(path11, "utf8");
23097
+ text2 = await readFile2(path12, "utf8");
22813
23098
  } catch (err) {
22814
- throw new Error(`--suppression: cannot read ${path11} (${errText(err)})`);
23099
+ throw new Error(`--suppression: cannot read ${path12} (${errText(err)})`);
22815
23100
  }
22816
23101
  let parsed2;
22817
23102
  try {
22818
23103
  parsed2 = JSON.parse(text2);
22819
23104
  } catch (err) {
22820
- throw new Error(`--suppression: ${path11} is not valid JSON (${errText(err)})`);
23105
+ throw new Error(`--suppression: ${path12} is not valid JSON (${errText(err)})`);
22821
23106
  }
22822
- return parseSuppression(parsed2, path11);
23107
+ return parseSuppression(parsed2, path12);
22823
23108
  }
22824
23109
  async function runDimensionSuggestionsProfile(cfg) {
22825
23110
  const now = cfg.now ?? Date.now;
@@ -24749,14 +25034,14 @@ async function runMetricsDelete(cfg) {
24749
25034
  }
24750
25035
  });
24751
25036
  }
24752
- function shortHash(input) {
24753
- return createHash4("sha256").update(input).digest("hex").slice(0, 12);
25037
+ function shortHash2(input) {
25038
+ return createHash5("sha256").update(input).digest("hex").slice(0, 12);
24754
25039
  }
24755
25040
  function buildMetricsBatchDeleteAction(ids) {
24756
25041
  const sorted = [...new Set(ids)].sort((a, b) => a - b);
24757
25042
  return {
24758
25043
  resource: "metrics-batch",
24759
- id: shortHash(sorted.join(",")),
25044
+ id: shortHash2(sorted.join(",")),
24760
25045
  verb: "delete"
24761
25046
  };
24762
25047
  }
@@ -26499,17 +26784,17 @@ function registerMetricsCommand(root) {
26499
26784
 
26500
26785
  // src/api/fx.ts
26501
26786
  async function getRates(client, options) {
26502
- const path11 = "/finance-os/api/foreign_exchange/v1/currency-rates";
26503
- const out = await client.getJSON(path11, options);
26787
+ const path12 = "/finance-os/api/foreign_exchange/v1/currency-rates";
26788
+ const out = await client.getJSON(path12, options);
26504
26789
  if (out === null) {
26505
26790
  return { base_currency: "", date: null, rates: {} };
26506
26791
  }
26507
26792
  return out;
26508
26793
  }
26509
- async function fetchCurrencyList(client, path11, options) {
26794
+ async function fetchCurrencyList(client, path12, options) {
26510
26795
  let out;
26511
26796
  try {
26512
- out = await client.getJSON(path11, options);
26797
+ out = await client.getJSON(path12, options);
26513
26798
  } catch (err) {
26514
26799
  if (isNotFoundError(err)) return [];
26515
26800
  throw err;
@@ -26563,7 +26848,7 @@ async function getOrgReportingCurrencies(client, organizationId, options) {
26563
26848
  }
26564
26849
 
26565
26850
  // src/commands/fxConfig.ts
26566
- import { createHash as createHash5 } from "crypto";
26851
+ import { createHash as createHash6 } from "crypto";
26567
26852
 
26568
26853
  // src/api/widgets.ts
26569
26854
  async function list18(client, dashboardId, options) {
@@ -26578,18 +26863,18 @@ async function listRaw3(client, dashboardId, options) {
26578
26863
  return out ?? [];
26579
26864
  }
26580
26865
  async function create10(client, dashboardId, body, options) {
26581
- const path11 = `/api/dashboards/${dashboardId}/widgets`;
26582
- const out = await client.postJSON(path11, body, options);
26866
+ const path12 = `/api/dashboards/${dashboardId}/widgets`;
26867
+ const out = await client.postJSON(path12, body, options);
26583
26868
  if (out === null) {
26584
- throw new Error(`POST ${path11}: empty response from widget create`);
26869
+ throw new Error(`POST ${path12}: empty response from widget create`);
26585
26870
  }
26586
26871
  return out;
26587
26872
  }
26588
26873
  async function update6(client, dashboardId, id, body, options) {
26589
- const path11 = `/api/dashboards/${dashboardId}/widgets/${id}`;
26590
- const out = await client.putJSON(path11, body, options);
26874
+ const path12 = `/api/dashboards/${dashboardId}/widgets/${id}`;
26875
+ const out = await client.putJSON(path12, body, options);
26591
26876
  if (out === null) {
26592
- throw new Error(`PUT ${path11}: empty response from widget update`);
26877
+ throw new Error(`PUT ${path12}: empty response from widget update`);
26593
26878
  }
26594
26879
  return out;
26595
26880
  }
@@ -26597,10 +26882,10 @@ async function deleteById10(client, dashboardId, id, options) {
26597
26882
  await client.deleteJSON(`/api/dashboards/${dashboardId}/widgets/${id}`, options);
26598
26883
  }
26599
26884
  async function getTemplateFields(client, templateId, options) {
26600
- const path11 = `/api/templates/${templateId}`;
26601
- const out = await client.getJSON(path11, options);
26885
+ const path12 = `/api/templates/${templateId}`;
26886
+ const out = await client.getJSON(path12, options);
26602
26887
  if (out === null) {
26603
- throw new Error(`GET ${path11}: empty response from template fetch`);
26888
+ throw new Error(`GET ${path12}: empty response from template fetch`);
26604
26889
  }
26605
26890
  const fields = Array.isArray(out.fields) ? out.fields : [];
26606
26891
  const result = [];
@@ -26622,11 +26907,6 @@ async function putDataWithPolling(client, dashboardId, id, payload, options = {}
26622
26907
  );
26623
26908
  }
26624
26909
 
26625
- // src/commands/_shellQuote.ts
26626
- function shellQuote(value) {
26627
- return `'${value.replace(/'/g, `'\\''`)}'`;
26628
- }
26629
-
26630
26910
  // src/commands/_fxCurrencies.ts
26631
26911
  var FX_CURRENCY_SYMBOLS = /* @__PURE__ */ new Map([
26632
26912
  ["AED", "\u062F.\u0625"],
@@ -27056,7 +27336,7 @@ async function runFxSetPosting(cfg) {
27056
27336
  verb: "set-fx"
27057
27337
  } : {
27058
27338
  resource: "field-batch",
27059
- id: createHash5("sha256").update(
27339
+ id: createHash6("sha256").update(
27060
27340
  changes.map((c) => `${c.field.id}:posting`).slice().sort().join("|")
27061
27341
  ).digest("hex").slice(0, 12),
27062
27342
  verb: "set-fx"
@@ -27510,7 +27790,7 @@ function buildSetReportingAction(changes) {
27510
27790
  };
27511
27791
  }
27512
27792
  const canonical = changes.map((c) => `${c.field.id}:reporting:${c.code}:${c.symbol ?? ""}`).slice().sort().join("|");
27513
- const sha = createHash5("sha256").update(canonical).digest("hex").slice(0, 12);
27793
+ const sha = createHash6("sha256").update(canonical).digest("hex").slice(0, 12);
27514
27794
  return { resource: "field-batch", id: sha, verb: "set-fx" };
27515
27795
  }
27516
27796
  function renderReportingOutcome(out, results, skipped, notFxTables, asJson) {
@@ -28490,9 +28770,9 @@ function registerFxCommand(root) {
28490
28770
  }
28491
28771
 
28492
28772
  // src/commands/errorEnrichments.ts
28493
- import { createHash as createHash6 } from "crypto";
28773
+ import { createHash as createHash7 } from "crypto";
28494
28774
  import { promises as fs13 } from "fs";
28495
- import * as path4 from "path";
28775
+ import * as path5 from "path";
28496
28776
 
28497
28777
  // src/api/errorEnrichments.ts
28498
28778
  var BASE = "/api/v3/data_integrations/error-enrichments/";
@@ -28553,12 +28833,12 @@ async function stats(client, filters, options) {
28553
28833
  return out;
28554
28834
  }
28555
28835
  async function exportCsv(client, options) {
28556
- const path11 = `${BASE}export-csv/`;
28557
- const res = await client.do("GET", path11, void 0, options);
28836
+ const path12 = `${BASE}export-csv/`;
28837
+ const res = await client.do("GET", path12, void 0, options);
28558
28838
  if (res.status < 200 || res.status >= 300) {
28559
28839
  const text2 = await res.text();
28560
28840
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
28561
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncated}`);
28841
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncated}`);
28562
28842
  }
28563
28843
  return res.text();
28564
28844
  }
@@ -29001,7 +29281,7 @@ async function runEnrichmentsExport(cfg) {
29001
29281
  }
29002
29282
  if (!single && outPath !== void 0) {
29003
29283
  for (const s of cfg.servers) {
29004
- await fs13.rm(path4.join(outPath, `${s}.csv`), { force: true });
29284
+ await fs13.rm(path5.join(outPath, `${s}.csv`), { force: true });
29005
29285
  }
29006
29286
  }
29007
29287
  const results = await sweep(
@@ -29021,7 +29301,7 @@ async function runEnrichmentsExport(cfg) {
29021
29301
  cfg.out.write(csv);
29022
29302
  continue;
29023
29303
  }
29024
- const dest = single ? outPath : path4.join(outPath, `${r.server}.csv`);
29304
+ const dest = single ? outPath : path5.join(outPath, `${r.server}.csv`);
29025
29305
  await fs13.writeFile(dest, csv, "utf8");
29026
29306
  const rows = csvRowCount(csv);
29027
29307
  cfg.out.write(`Wrote ${rows} rule${plural(rows)} to ${dest}
@@ -29029,8 +29309,8 @@ async function runEnrichmentsExport(cfg) {
29029
29309
  }
29030
29310
  requireSweepSuccess(results);
29031
29311
  }
29032
- function shortHash2(input) {
29033
- return createHash6("sha256").update(input).digest("hex").slice(0, 12);
29312
+ function shortHash3(input) {
29313
+ return createHash7("sha256").update(input).digest("hex").slice(0, 12);
29034
29314
  }
29035
29315
  function canonicalBatch(parts) {
29036
29316
  return stableJson(parts);
@@ -29052,7 +29332,7 @@ function buildCreateAction(rules, fromArrayPayload) {
29052
29332
  }
29053
29333
  return {
29054
29334
  resource: "error-enrichment-batch",
29055
- id: shortHash2(canonicalBatch(rules.map(stableJson).sort())),
29335
+ id: shortHash3(canonicalBatch(rules.map(stableJson).sort())),
29056
29336
  verb: "create"
29057
29337
  };
29058
29338
  }
@@ -29064,7 +29344,7 @@ function buildUpdateAction(patches, mode) {
29064
29344
  const entries = patches.map((p) => ({ id: p.id, json: stableJson(p.patch) })).sort((a, b) => a.id - b.id || (a.json < b.json ? -1 : a.json > b.json ? 1 : 0));
29065
29345
  return {
29066
29346
  resource: "error-enrichment-batch",
29067
- id: shortHash2(canonicalBatch(entries)),
29347
+ id: shortHash3(canonicalBatch(entries)),
29068
29348
  verb: "update"
29069
29349
  };
29070
29350
  }
@@ -29075,7 +29355,7 @@ function buildDeleteAction(ids) {
29075
29355
  }
29076
29356
  return {
29077
29357
  resource: "error-enrichment-batch",
29078
- id: shortHash2(canonicalBatch(unique)),
29358
+ id: shortHash3(canonicalBatch(unique)),
29079
29359
  verb: "delete"
29080
29360
  };
29081
29361
  }
@@ -29316,7 +29596,7 @@ async function runEnrichmentsImport(cfg) {
29316
29596
  await preflightConfirmToken(action, cfg.token);
29317
29597
  const csv = await fs13.readFile(cfg.file, "utf8");
29318
29598
  const csvRows = csv === "" ? 0 : Math.max(csv.trimEnd().split("\n").length - 1, 0);
29319
- const filename = path4.basename(cfg.file);
29599
+ const filename = path5.basename(cfg.file);
29320
29600
  await twoStepConfirm({
29321
29601
  out: cfg.out,
29322
29602
  action,
@@ -29825,25 +30105,25 @@ function registerErrorEnrichmentsCommand(root) {
29825
30105
  }
29826
30106
 
29827
30107
  // src/commands/skill.ts
29828
- import { createHash as createHash7 } from "crypto";
30108
+ import { createHash as createHash8 } from "crypto";
29829
30109
  import { readFile as readFile3, mkdir as mkdir2, readdir as readdir2, rm as rm2, rmdir, stat, writeFile as writeFile3 } from "fs/promises";
29830
- import { dirname as dirname6, join as join8, resolve as resolve2 } from "path";
30110
+ import { dirname as dirname6, join as join9, resolve as resolve2 } from "path";
29831
30111
 
29832
30112
  // src/commands/_skillsRoot.ts
29833
30113
  import { existsSync, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
29834
- import { basename as basename3, dirname as dirname5, join as join7 } from "path";
30114
+ import { basename as basename3, dirname as dirname5, join as join8 } from "path";
29835
30115
  import { fileURLToPath as fileURLToPath2 } from "url";
29836
30116
  var PLUGIN_ONLY_MARKER = ".plugin-only";
29837
30117
  var PLUGIN_MAP_FILE = "plugins.json";
29838
30118
  var ROUTER_FILE = "SKILL.md";
29839
30119
  function skillRootSearchPaths(here = dirname5(fileURLToPath2(import.meta.url))) {
29840
- return { bundled: join7(here, "skills"), plugins: join7(here, "..", "..", "plugins") };
30120
+ return { bundled: join8(here, "skills"), plugins: join8(here, "..", "..", "plugins") };
29841
30121
  }
29842
30122
  function skillRoots(here = dirname5(fileURLToPath2(import.meta.url))) {
29843
30123
  const { bundled, plugins } = skillRootSearchPaths(here);
29844
30124
  if (isDir(bundled)) return [bundled];
29845
30125
  if (!isDir(plugins)) return [];
29846
- return readdirSync(plugins, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join7(plugins, e.name, "skills")).filter(isDir).sort();
30126
+ return readdirSync(plugins, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => join8(plugins, e.name, "skills")).filter(isDir).sort();
29847
30127
  }
29848
30128
  function skillDirs(roots = skillRoots()) {
29849
30129
  const seen = /* @__PURE__ */ new Map();
@@ -29852,9 +30132,9 @@ function skillDirs(roots = skillRoots()) {
29852
30132
  const map = readPluginMap(root);
29853
30133
  for (const entry of readdirSync(root, { withFileTypes: true })) {
29854
30134
  if (!entry.isDirectory()) continue;
29855
- const dir = join7(root, entry.name);
29856
- if (existsSync(join7(dir, PLUGIN_ONLY_MARKER))) continue;
29857
- if (!isFile(join7(dir, ROUTER_FILE))) continue;
30135
+ const dir = join8(root, entry.name);
30136
+ if (existsSync(join8(dir, PLUGIN_ONLY_MARKER))) continue;
30137
+ if (!isFile(join8(dir, ROUTER_FILE))) continue;
29858
30138
  const previous = seen.get(entry.name);
29859
30139
  if (previous !== void 0) {
29860
30140
  throw new Error(`duplicate skill name "${entry.name}": ${previous} and ${dir}`);
@@ -29874,12 +30154,12 @@ function pluginOf(root, name, map) {
29874
30154
  if (map === null) return basename3(dirname5(root));
29875
30155
  const plugin = map.get(name);
29876
30156
  if (plugin === void 0) {
29877
- throw new Error(`${join7(root, PLUGIN_MAP_FILE)} names no plugin for skill "${name}"`);
30157
+ throw new Error(`${join8(root, PLUGIN_MAP_FILE)} names no plugin for skill "${name}"`);
29878
30158
  }
29879
30159
  return plugin;
29880
30160
  }
29881
30161
  function readPluginMap(root) {
29882
- const file = join7(root, PLUGIN_MAP_FILE);
30162
+ const file = join8(root, PLUGIN_MAP_FILE);
29883
30163
  if (!existsSync(file)) return null;
29884
30164
  const parsed2 = JSON.parse(readFileSync2(file, "utf8"));
29885
30165
  const map = /* @__PURE__ */ new Map();
@@ -29921,7 +30201,7 @@ async function readSkillFiles(skillRoot) {
29921
30201
  const entries = await readdir2(dir, { withFileTypes: true });
29922
30202
  for (const e of entries) {
29923
30203
  if (isIgnoredSkillEntry(e.name)) continue;
29924
- const childAbs = join8(dir, e.name);
30204
+ const childAbs = join9(dir, e.name);
29925
30205
  const childRel = prefix === "" ? e.name : `${prefix}/${e.name}`;
29926
30206
  if (e.isDirectory()) {
29927
30207
  await walk(childAbs, childRel);
@@ -29987,7 +30267,7 @@ async function runSkillPrint(cfg) {
29987
30267
  throw new Error(`skill "${skill.name}" has no file "${relPath}" \u2014 available: ${available}`);
29988
30268
  }
29989
30269
  if (cfg.hash) {
29990
- const hex = createHash7("sha256").update(hit.bytes).digest("hex");
30270
+ const hex = createHash8("sha256").update(hit.bytes).digest("hex");
29991
30271
  cfg.out.write(hex + "\n");
29992
30272
  return;
29993
30273
  }
@@ -30003,26 +30283,26 @@ function relSegments(relPath) {
30003
30283
  return segs;
30004
30284
  }
30005
30285
  function skillDirAbs(targetAbs, dotDir, name) {
30006
- return join8(targetAbs, dotDir, "skills", name);
30286
+ return join9(targetAbs, dotDir, "skills", name);
30007
30287
  }
30008
30288
  var MANIFEST_FILE = ".dr-cli-manifest.json";
30009
30289
  var MARKER_BEGIN = "<!-- dr-cli:begin -->";
30010
30290
  var MARKER_END = "<!-- dr-cli:end -->";
30011
30291
  var USERSPACE_ENV = "DR_CLI_USERSPACE_SKILLS";
30012
30292
  var DESKTOP_APP_DIRS = [
30013
- join8("AppData", "Roaming", "Claude"),
30014
- join8("Library", "Application Support", "Claude"),
30015
- join8(".config", "Claude")
30293
+ join9("AppData", "Roaming", "Claude"),
30294
+ join9("Library", "Application Support", "Claude"),
30295
+ join9(".config", "Claude")
30016
30296
  ];
30017
30297
  function desktopAppDirs(targetAbs, env) {
30018
- const dirs = DESKTOP_APP_DIRS.map((d) => join8(targetAbs, d));
30298
+ const dirs = DESKTOP_APP_DIRS.map((d) => join9(targetAbs, d));
30019
30299
  const appData = env["APPDATA"];
30020
30300
  const userHome = env["USERPROFILE"] ?? env["HOME"];
30021
30301
  if (appData === void 0 || appData === "" || userHome === void 0 || userHome === "")
30022
30302
  return dirs;
30023
30303
  const same = (a, b) => process.platform === "win32" ? a.toLowerCase() === b.toLowerCase() : a === b;
30024
30304
  if (!same(resolve2(userHome), targetAbs)) return dirs;
30025
- const redirected = join8(resolve2(appData), "Claude");
30305
+ const redirected = join9(resolve2(appData), "Claude");
30026
30306
  return dirs.some((d) => same(d, redirected)) ? dirs : [...dirs, redirected];
30027
30307
  }
30028
30308
  async function registryPluginNames(file) {
@@ -30059,14 +30339,14 @@ async function pluginRegistries(targetAbs, env) {
30059
30339
  const names = await read(file);
30060
30340
  if (names !== null) found.push({ file, names });
30061
30341
  };
30062
- await add3(join8(targetAbs, ".claude", "plugins", "installed_plugins.json"), registryPluginNames);
30342
+ await add3(join9(targetAbs, ".claude", "plugins", "installed_plugins.json"), registryPluginNames);
30063
30343
  for (const appDir of desktopAppDirs(targetAbs, env)) {
30064
- const sessions = join8(appDir, "local-agent-mode-sessions");
30344
+ const sessions = join9(appDir, "local-agent-mode-sessions");
30065
30345
  for (const account of await subdirs(sessions)) {
30066
- for (const org of await subdirs(join8(sessions, account))) {
30067
- const base = join8(sessions, account, org);
30068
- await add3(join8(base, "rpm", "manifest.json"), desktopManifestPluginNames);
30069
- await add3(join8(base, "cowork_plugins", "installed_plugins.json"), registryPluginNames);
30346
+ for (const org of await subdirs(join9(sessions, account))) {
30347
+ const base = join9(sessions, account, org);
30348
+ await add3(join9(base, "rpm", "manifest.json"), desktopManifestPluginNames);
30349
+ await add3(join9(base, "cowork_plugins", "installed_plugins.json"), registryPluginNames);
30070
30350
  }
30071
30351
  }
30072
30352
  }
@@ -30110,7 +30390,7 @@ async function runSkillInstall(cfg) {
30110
30390
  const probe = await pluginManagedProbe(abs, cfg.env);
30111
30391
  if (probe.managed && !(cfg.force ?? false)) {
30112
30392
  cfg.out.write(
30113
- `Skipped ${join8(abs, ".claude", "skills")}: this machine gets the dr-cli skills from the dr-cli plugin (${probe.reason}). Pass --force to write them anyway.
30393
+ `Skipped ${join9(abs, ".claude", "skills")}: this machine gets the dr-cli skills from the dr-cli plugin (${probe.reason}). Pass --force to write them anyway.
30114
30394
  `
30115
30395
  );
30116
30396
  for (const s of skills) {
@@ -30137,7 +30417,7 @@ async function runSkillInstall(cfg) {
30137
30417
  await maybeInstallToGemini(abs, skills, cfg.out, verbose);
30138
30418
  }
30139
30419
  async function maybeInstallToGemini(targetAbs, skills, out, verbose) {
30140
- const geminiDir = join8(targetAbs, ".gemini");
30420
+ const geminiDir = join9(targetAbs, ".gemini");
30141
30421
  try {
30142
30422
  const st = await stat(geminiDir);
30143
30423
  if (!st.isDirectory()) {
@@ -30156,9 +30436,9 @@ async function maybeInstallToGemini(targetAbs, skills, out, verbose) {
30156
30436
  verbose,
30157
30437
  label: `Gemini skill ${s.name}`
30158
30438
  });
30159
- routerImportPaths.push(join8(skillDir, ...relSegments(ROUTER_FILE)));
30439
+ routerImportPaths.push(join9(skillDir, ...relSegments(ROUTER_FILE)));
30160
30440
  }
30161
- const geminiMd = join8(geminiDir, "GEMINI.md");
30441
+ const geminiMd = join9(geminiDir, "GEMINI.md");
30162
30442
  const block = renderImportBlock(routerImportPaths, "`dr skill install`");
30163
30443
  const { changed } = await updateMarkdownMarkerBlock(geminiMd, block);
30164
30444
  out.write(
@@ -30191,9 +30471,9 @@ async function runSkillInitProject(cfg) {
30191
30471
  verbose,
30192
30472
  label: `skill ${s.name}`
30193
30473
  });
30194
- routerSkillPaths.push(join8(skillDir, ...relSegments(ROUTER_FILE)));
30474
+ routerSkillPaths.push(join9(skillDir, ...relSegments(ROUTER_FILE)));
30195
30475
  }
30196
- const geminiMd = join8(abs, "GEMINI.md");
30476
+ const geminiMd = join9(abs, "GEMINI.md");
30197
30477
  const geminiBlock = renderImportBlock(routerSkillPaths, "`dr skill init-project`");
30198
30478
  const { changed: geminiChanged } = await updateMarkdownMarkerBlock(geminiMd, geminiBlock);
30199
30479
  cfg.out.write(
@@ -30201,7 +30481,7 @@ async function runSkillInitProject(cfg) {
30201
30481
  ` : `Gemini imports already registered \u2014 no change: ${geminiMd}
30202
30482
  `
30203
30483
  );
30204
- const agentsMd = join8(abs, "AGENTS.md");
30484
+ const agentsMd = join9(abs, "AGENTS.md");
30205
30485
  const agentsBlock = renderInlineBlock(skills, "`dr skill init-project`", ".dr-cli/skills");
30206
30486
  const agentsBytes = Buffer.byteLength(agentsBlock, "utf8");
30207
30487
  if (agentsBytes > AGENTS_WARN_BYTES) {
@@ -30241,7 +30521,7 @@ async function writeOneFile(targetPath, bytes) {
30241
30521
  }
30242
30522
  async function readManifest(skillDir) {
30243
30523
  try {
30244
- const raw = await readFile3(join8(skillDir, MANIFEST_FILE), "utf8");
30524
+ const raw = await readFile3(join9(skillDir, MANIFEST_FILE), "utf8");
30245
30525
  const parsed2 = JSON.parse(raw);
30246
30526
  const files = parsed2.files;
30247
30527
  return Array.isArray(files) ? files.filter((x) => typeof x === "string") : [];
@@ -30250,7 +30530,7 @@ async function readManifest(skillDir) {
30250
30530
  }
30251
30531
  }
30252
30532
  async function removeUserSpaceCopy(skillDir) {
30253
- const manifestPath = join8(skillDir, MANIFEST_FILE);
30533
+ const manifestPath = join9(skillDir, MANIFEST_FILE);
30254
30534
  try {
30255
30535
  await stat(manifestPath);
30256
30536
  } catch {
@@ -30259,7 +30539,7 @@ async function removeUserSpaceCopy(skillDir) {
30259
30539
  let files = 0;
30260
30540
  for (const rel of await readManifest(skillDir)) {
30261
30541
  try {
30262
- const p = join8(skillDir, ...relSegments(rel));
30542
+ const p = join9(skillDir, ...relSegments(rel));
30263
30543
  await rm2(p, { force: true });
30264
30544
  await rmdir(dirname6(p)).catch(() => {
30265
30545
  });
@@ -30281,7 +30561,7 @@ async function installSkillTree(opts) {
30281
30561
  let unchanged = 0;
30282
30562
  let totalBytes = 0;
30283
30563
  for (const f of files) {
30284
- const targetPath = join8(skillDir, ...relSegments(f.relPath));
30564
+ const targetPath = join9(skillDir, ...relSegments(f.relPath));
30285
30565
  const status2 = await writeOneFile(targetPath, f.bytes);
30286
30566
  totalBytes += f.bytes.length;
30287
30567
  if (status2 === "installed") {
@@ -30303,7 +30583,7 @@ async function installSkillTree(opts) {
30303
30583
  const current = new Set(files.map((f) => f.relPath));
30304
30584
  await mkdir2(skillDir, { recursive: true, mode: 493 });
30305
30585
  await writeFile3(
30306
- join8(skillDir, MANIFEST_FILE),
30586
+ join9(skillDir, MANIFEST_FILE),
30307
30587
  JSON.stringify({ files: [...current].sort() }) + "\n",
30308
30588
  {
30309
30589
  mode: 420
@@ -30313,7 +30593,7 @@ async function installSkillTree(opts) {
30313
30593
  for (const oldRel of prev) {
30314
30594
  if (current.has(oldRel)) continue;
30315
30595
  try {
30316
- const p = join8(skillDir, ...relSegments(oldRel));
30596
+ const p = join9(skillDir, ...relSegments(oldRel));
30317
30597
  await rm2(p, { force: true });
30318
30598
  await rmdir(dirname6(p)).catch(() => {
30319
30599
  });
@@ -30461,26 +30741,26 @@ async function listFull(client, tableId, options) {
30461
30741
  return out ?? [];
30462
30742
  }
30463
30743
  async function get14(client, tableId, id, options) {
30464
- const path11 = `/api/templates/${tableId}/mappers/${id}`;
30465
- const out = await client.getJSON(path11, options);
30744
+ const path12 = `/api/templates/${tableId}/mappers/${id}`;
30745
+ const out = await client.getJSON(path12, options);
30466
30746
  if (out === null) {
30467
- throw new Error(`GET ${path11}: empty response from datamapper get`);
30747
+ throw new Error(`GET ${path12}: empty response from datamapper get`);
30468
30748
  }
30469
30749
  return out;
30470
30750
  }
30471
30751
  async function getDetails2(client, id, options) {
30472
- const path11 = `/api/templates/mappers/${id}`;
30473
- const out = await client.getJSON(path11, options);
30752
+ const path12 = `/api/templates/mappers/${id}`;
30753
+ const out = await client.getJSON(path12, options);
30474
30754
  if (out === null) {
30475
- throw new Error(`GET ${path11}: empty response from datamapper details`);
30755
+ throw new Error(`GET ${path12}: empty response from datamapper details`);
30476
30756
  }
30477
30757
  return out;
30478
30758
  }
30479
30759
  async function create12(client, tableId, body, options) {
30480
- const path11 = `/api/templates/${tableId}/mappers`;
30481
- const out = await client.postJSON(path11, body, options);
30760
+ const path12 = `/api/templates/${tableId}/mappers`;
30761
+ const out = await client.postJSON(path12, body, options);
30482
30762
  if (out === null) {
30483
- throw new Error(`POST ${path11}: empty response from datamapper create`);
30763
+ throw new Error(`POST ${path12}: empty response from datamapper create`);
30484
30764
  }
30485
30765
  return out;
30486
30766
  }
@@ -30492,14 +30772,14 @@ async function listCustomFunctions(client, options) {
30492
30772
  return out ?? [];
30493
30773
  }
30494
30774
  async function previewData(client, body, options) {
30495
- const path11 = "/api/templates/preview-data";
30496
- return client.postJSON(path11, body, options);
30775
+ const path12 = "/api/templates/preview-data";
30776
+ return client.postJSON(path12, body, options);
30497
30777
  }
30498
30778
  async function updateBinding(client, mapperId, body, options) {
30499
- const path11 = `/api/templates/mappers/${mapperId}/binding`;
30500
- const out = await client.postJSON(path11, body, options);
30779
+ const path12 = `/api/templates/mappers/${mapperId}/binding`;
30780
+ const out = await client.postJSON(path12, body, options);
30501
30781
  if (out === null) {
30502
- throw new Error(`POST ${path11}: empty response from datamapper binding update`);
30782
+ throw new Error(`POST ${path12}: empty response from datamapper binding update`);
30503
30783
  }
30504
30784
  return out;
30505
30785
  }
@@ -30710,12 +30990,12 @@ function formatCalcFieldError(name, preview2, full) {
30710
30990
  // src/commands/_errorLog.ts
30711
30991
  import { promises as fs14 } from "fs";
30712
30992
  import * as os3 from "os";
30713
- import * as path5 from "path";
30993
+ import * as path6 from "path";
30714
30994
  var RESPONSE_BODY_MAX_BYTES = 8 * 1024;
30715
30995
  async function writeErrorLog(opts) {
30716
30996
  const filename = `dr-cli-error-${timestampStamp()}.md`;
30717
30997
  const dir = await chooseDir(opts.dirOverride);
30718
- const filePath = path5.join(dir, filename);
30998
+ const filePath = path6.join(dir, filename);
30719
30999
  const md = formatLog(opts);
30720
31000
  await fs14.writeFile(filePath, md, { encoding: "utf8" });
30721
31001
  return filePath;
@@ -31454,11 +31734,11 @@ function buildCoordEntries(pairs, role) {
31454
31734
  });
31455
31735
  }
31456
31736
  async function readSheetHeaders(client, docId, versionId, sheet, signal) {
31457
- const path11 = `/api/documents/${docId}/versions/${versionId}/raw?start_row=1&end_row=1&data_only=false&sheet_ind=0&sheet_name=${rawQueryEscape(sheet)}&optimize=true`;
31737
+ const path12 = `/api/documents/${docId}/versions/${versionId}/raw?start_row=1&end_row=1&data_only=false&sheet_ind=0&sheet_name=${rawQueryEscape(sheet)}&optimize=true`;
31458
31738
  let rows;
31459
31739
  try {
31460
31740
  const opts = signal === void 0 ? void 0 : { signal };
31461
- const got = await client.getJSON(path11, opts);
31741
+ const got = await client.getJSON(path12, opts);
31462
31742
  rows = got ?? [];
31463
31743
  } catch (err) {
31464
31744
  const m = err instanceof Error ? err.message : String(err);
@@ -32120,15 +32400,15 @@ async function list21(client, options) {
32120
32400
  return out ?? [];
32121
32401
  }
32122
32402
  async function get15(client, id, options) {
32123
- const path11 = `/api/mapper_recipients/mapper_templates/${id}`;
32124
- const out = await client.getJSON(path11, options);
32403
+ const path12 = `/api/mapper_recipients/mapper_templates/${id}`;
32404
+ const out = await client.getJSON(path12, options);
32125
32405
  if (out === null) {
32126
- throw new Error(`GET ${path11}: empty response from mapper recipe get`);
32406
+ throw new Error(`GET ${path12}: empty response from mapper recipe get`);
32127
32407
  }
32128
32408
  return out;
32129
32409
  }
32130
32410
  async function create13(client, args, options) {
32131
- const path11 = "/api/mapper_recipients/mapper_templates";
32411
+ const path12 = "/api/mapper_recipients/mapper_templates";
32132
32412
  const body = {
32133
32413
  name: args.name,
32134
32414
  description: args.description,
@@ -32136,9 +32416,9 @@ async function create13(client, args, options) {
32136
32416
  config: JSON.stringify(args.config),
32137
32417
  fields_to_change: JSON.stringify(args.fields_to_change)
32138
32418
  };
32139
- const out = await client.postJSON(path11, body, options);
32419
+ const out = await client.postJSON(path12, body, options);
32140
32420
  if (out === null) {
32141
- throw new Error(`POST ${path11}: empty response from mapper recipe create`);
32421
+ throw new Error(`POST ${path12}: empty response from mapper recipe create`);
32142
32422
  }
32143
32423
  return out;
32144
32424
  }
@@ -32324,7 +32604,7 @@ function parseFromVersion(s) {
32324
32604
 
32325
32605
  // src/commands/documents.ts
32326
32606
  import { readFile as readFile4, writeFile as writeFile4 } from "fs/promises";
32327
- import * as path6 from "path";
32607
+ import * as path7 from "path";
32328
32608
 
32329
32609
  // src/api/documentSplits.ts
32330
32610
  var SPLITS_PATH = "/api/documents/cycles/splits";
@@ -32337,15 +32617,15 @@ async function list22(client, query, options) {
32337
32617
  params.set("dimension_tags_value", query.dimensionTagsValue);
32338
32618
  }
32339
32619
  const qs = params.toString();
32340
- const path11 = qs === "" ? SPLITS_PATH : `${SPLITS_PATH}?${qs}`;
32341
- const out = await client.getJSON(path11, options);
32620
+ const path12 = qs === "" ? SPLITS_PATH : `${SPLITS_PATH}?${qs}`;
32621
+ const out = await client.getJSON(path12, options);
32342
32622
  return out ?? [];
32343
32623
  }
32344
32624
  async function create14(client, payload, customTagId, options) {
32345
- const path11 = customTagId === void 0 ? SPLITS_PATH : `${SPLITS_PATH}?custom_tag_id=${customTagId}`;
32346
- const out = await client.postJSON(path11, payload, options);
32625
+ const path12 = customTagId === void 0 ? SPLITS_PATH : `${SPLITS_PATH}?custom_tag_id=${customTagId}`;
32626
+ const out = await client.postJSON(path12, payload, options);
32347
32627
  if (out === null) {
32348
- throw new Error(`POST ${path11}: empty response from split create`);
32628
+ throw new Error(`POST ${path12}: empty response from split create`);
32349
32629
  }
32350
32630
  return out;
32351
32631
  }
@@ -32353,10 +32633,10 @@ async function undo(client, splitId, options) {
32353
32633
  return client.putJSON(`/api/documents/cycles/split/${splitId}/undo`, {}, options);
32354
32634
  }
32355
32635
  async function status(client, splitId, options) {
32356
- const path11 = `/api/documents/document_split/${splitId}/status`;
32357
- const out = await client.getJSON(path11, options);
32636
+ const path12 = `/api/documents/document_split/${splitId}/status`;
32637
+ const out = await client.getJSON(path12, options);
32358
32638
  if (out === null) {
32359
- throw new Error(`GET ${path11}: empty response from split status`);
32639
+ throw new Error(`GET ${path12}: empty response from split status`);
32360
32640
  }
32361
32641
  return out;
32362
32642
  }
@@ -32802,7 +33082,7 @@ async function runDebugZip(cfg) {
32802
33082
  }
32803
33083
  async function runUploadPollDownload(core) {
32804
33084
  const buf = await readFile4(core.filePath);
32805
- const filename = path6.basename(core.filePath);
33085
+ const filename = path7.basename(core.filePath);
32806
33086
  const start = await core.start(new Blob([buf]), filename);
32807
33087
  core.out.write(
32808
33088
  `Uploaded ${filename}; request ${String(start.requestId)} started \u2014 polling for the result\u2026
@@ -32815,8 +33095,8 @@ async function runUploadPollDownload(core) {
32815
33095
  `);
32816
33096
  }
32817
33097
  function defaultJobOutputPath(inputPath, suffix) {
32818
- const parsed2 = path6.parse(inputPath);
32819
- return path6.join(parsed2.dir, `${parsed2.name}${suffix}`);
33098
+ const parsed2 = path7.parse(inputPath);
33099
+ return path7.join(parsed2.dir, `${parsed2.name}${suffix}`);
32820
33100
  }
32821
33101
  async function runAutoCalculate(cfg) {
32822
33102
  await runUploadPollDownload({
@@ -33592,34 +33872,34 @@ import { Option as Option2 } from "commander";
33592
33872
 
33593
33873
  // src/api/integrations.ts
33594
33874
  async function list23(client, opts, reqOptions) {
33595
- let path11 = `/api/v3/data_integrations/?page=${opts.page}&page_size=${opts.pageSize}`;
33875
+ let path12 = `/api/v3/data_integrations/?page=${opts.page}&page_size=${opts.pageSize}`;
33596
33876
  const s = (opts.search ?? "").trim();
33597
33877
  if (s !== "") {
33598
- path11 += `&search=${rawQueryEscape(s)}`;
33878
+ path12 += `&search=${rawQueryEscape(s)}`;
33599
33879
  }
33600
- const out = await client.getJSON(path11, reqOptions);
33880
+ const out = await client.getJSON(path12, reqOptions);
33601
33881
  return out ?? { count: 0, next: null, previous: null, results: [] };
33602
33882
  }
33603
33883
  async function getById2(client, id, reqOptions) {
33604
- const path11 = `/api/v3/data_integrations/${id}/`;
33605
- const out = await client.getJSON(path11, reqOptions);
33884
+ const path12 = `/api/v3/data_integrations/${id}/`;
33885
+ const out = await client.getJSON(path12, reqOptions);
33606
33886
  if (out === null) {
33607
- throw new Error(`GET ${path11}: empty response from data_integrations get`);
33887
+ throw new Error(`GET ${path12}: empty response from data_integrations get`);
33608
33888
  }
33609
33889
  return out;
33610
33890
  }
33611
33891
  async function getDataSourcesPage(client, page, reqOptions) {
33612
- const path11 = `/api/v3/data_integrations/data-sources?page=${page}`;
33613
- const out = await client.getJSON(path11, reqOptions);
33892
+ const path12 = `/api/v3/data_integrations/data-sources?page=${page}`;
33893
+ const out = await client.getJSON(path12, reqOptions);
33614
33894
  return out ?? { next: null, results: [] };
33615
33895
  }
33616
33896
  async function listTypes(client, search, reqOptions) {
33617
- let path11 = "/api/v3/data_integrations/types/";
33897
+ let path12 = "/api/v3/data_integrations/types/";
33618
33898
  const s = (search ?? "").trim();
33619
33899
  if (s !== "") {
33620
- path11 += `?search=${rawQueryEscape(s)}`;
33900
+ path12 += `?search=${rawQueryEscape(s)}`;
33621
33901
  }
33622
- const raw = await client.getJSON(path11, reqOptions);
33902
+ const raw = await client.getJSON(path12, reqOptions);
33623
33903
  if (raw === null) return [];
33624
33904
  if (typeof raw === "object" && raw !== null && !Array.isArray(raw) && "results" in raw && Array.isArray(raw.results)) {
33625
33905
  return raw.results;
@@ -33627,7 +33907,7 @@ async function listTypes(client, search, reqOptions) {
33627
33907
  if (Array.isArray(raw)) {
33628
33908
  return raw;
33629
33909
  }
33630
- throw new Error(`GET ${path11}: unrecognized response shape`);
33910
+ throw new Error(`GET ${path12}: unrecognized response shape`);
33631
33911
  }
33632
33912
  async function queryCheckStatus(client, queryIds, reqOptions) {
33633
33913
  const out = await client.putJSON(
@@ -33637,8 +33917,8 @@ async function queryCheckStatus(client, queryIds, reqOptions) {
33637
33917
  );
33638
33918
  return out ?? [];
33639
33919
  }
33640
- async function getErrorExplanation(client, path11, reqOptions) {
33641
- const res = await client.do("GET", path11, void 0, reqOptions);
33920
+ async function getErrorExplanation(client, path12, reqOptions) {
33921
+ const res = await client.do("GET", path12, void 0, reqOptions);
33642
33922
  const text2 = await res.text();
33643
33923
  if (res.status === 200) {
33644
33924
  let parsed2;
@@ -33675,18 +33955,18 @@ async function testConnection(client, rawBody, reqOptions) {
33675
33955
  return { status: res.status, rawText: text2 };
33676
33956
  }
33677
33957
  async function create15(client, body, reqOptions) {
33678
- const path11 = "/api/v3/data_integrations/";
33679
- const out = await client.postJSON(path11, body, reqOptions);
33958
+ const path12 = "/api/v3/data_integrations/";
33959
+ const out = await client.postJSON(path12, body, reqOptions);
33680
33960
  if (out === null) {
33681
- throw new Error(`POST ${path11}: empty response from data_integrations create`);
33961
+ throw new Error(`POST ${path12}: empty response from data_integrations create`);
33682
33962
  }
33683
33963
  return out;
33684
33964
  }
33685
33965
  async function update8(client, id, body, reqOptions) {
33686
- const path11 = `/api/v3/data_integrations/${id}/`;
33687
- const out = await client.putJSON(path11, body, reqOptions);
33966
+ const path12 = `/api/v3/data_integrations/${id}/`;
33967
+ const out = await client.putJSON(path12, body, reqOptions);
33688
33968
  if (out === null) {
33689
- throw new Error(`PUT ${path11}: empty response from data_integrations update`);
33969
+ throw new Error(`PUT ${path12}: empty response from data_integrations update`);
33690
33970
  }
33691
33971
  return out;
33692
33972
  }
@@ -33746,43 +34026,43 @@ async function shareGroups(client, id, groupIds, reqOptions) {
33746
34026
  return { detail: typeof out.detail === "string" ? out.detail : null };
33747
34027
  }
33748
34028
  async function itList(client, opts, reqOptions) {
33749
- let path11 = `/api/it/integrations?page=${opts.page}&page_size=${opts.pageSize}`;
34029
+ let path12 = `/api/it/integrations?page=${opts.page}&page_size=${opts.pageSize}`;
33750
34030
  const s = (opts.search ?? "").trim();
33751
34031
  if (s !== "") {
33752
- path11 += `&search=${rawQueryEscape(s)}`;
34032
+ path12 += `&search=${rawQueryEscape(s)}`;
33753
34033
  }
33754
- const out = await client.getJSON(path11, reqOptions);
34034
+ const out = await client.getJSON(path12, reqOptions);
33755
34035
  return out ?? { count: 0, next: null, previous: null, results: [] };
33756
34036
  }
33757
34037
  async function itGet(client, id, reqOptions) {
33758
- const path11 = `/api/it/integrations/${id}`;
33759
- const out = await client.getJSON(path11, reqOptions);
34038
+ const path12 = `/api/it/integrations/${id}`;
34039
+ const out = await client.getJSON(path12, reqOptions);
33760
34040
  if (out === null) {
33761
- throw new Error(`GET ${path11}: empty response from it integrations get`);
34041
+ throw new Error(`GET ${path12}: empty response from it integrations get`);
33762
34042
  }
33763
34043
  return out;
33764
34044
  }
33765
34045
  async function itGetRaw(client, id, reqOptions) {
33766
- const path11 = `/api/it/integrations/${id}`;
33767
- const out = await client.getJSON(path11, reqOptions);
34046
+ const path12 = `/api/it/integrations/${id}`;
34047
+ const out = await client.getJSON(path12, reqOptions);
33768
34048
  if (out === null) {
33769
- throw new Error(`GET ${path11}: empty response from it integrations get`);
34049
+ throw new Error(`GET ${path12}: empty response from it integrations get`);
33770
34050
  }
33771
34051
  return out;
33772
34052
  }
33773
34053
  async function itCreate(client, body, reqOptions) {
33774
- const path11 = "/api/it/integrations";
33775
- const out = await client.postJSON(path11, body, reqOptions);
34054
+ const path12 = "/api/it/integrations";
34055
+ const out = await client.postJSON(path12, body, reqOptions);
33776
34056
  if (out === null) {
33777
- throw new Error(`POST ${path11}: empty response from it integrations create`);
34057
+ throw new Error(`POST ${path12}: empty response from it integrations create`);
33778
34058
  }
33779
34059
  return out;
33780
34060
  }
33781
34061
  async function itUpdate(client, id, body, reqOptions) {
33782
- const path11 = `/api/it/integrations/${id}`;
33783
- const out = await client.putJSON(path11, body, reqOptions);
34062
+ const path12 = `/api/it/integrations/${id}`;
34063
+ const out = await client.putJSON(path12, body, reqOptions);
33784
34064
  if (out === null) {
33785
- throw new Error(`PUT ${path11}: empty response from it integrations update`);
34065
+ throw new Error(`PUT ${path12}: empty response from it integrations update`);
33786
34066
  }
33787
34067
  return out;
33788
34068
  }
@@ -33802,7 +34082,7 @@ async function itResync(client, id, reqOptions) {
33802
34082
  // src/commands/filebox.ts
33803
34083
  import { promises as fsPromises, existsSync as existsSync2 } from "fs";
33804
34084
  import * as nodePath from "path";
33805
- import { createHash as createHash8 } from "crypto";
34085
+ import { createHash as createHash9 } from "crypto";
33806
34086
 
33807
34087
  // src/commands/filebox_admin.ts
33808
34088
  import { promises as fs15 } from "fs";
@@ -35044,11 +35324,11 @@ async function updateScenario(client, scenarioId, patch, options) {
35044
35324
  return out ?? {};
35045
35325
  }
35046
35326
  async function deleteScenario(client, scenarioId, opts = {}, options) {
35047
- let path11 = `/api/documents/cycles/${scenarioId}/custom_tags`;
35327
+ let path12 = `/api/documents/cycles/${scenarioId}/custom_tags`;
35048
35328
  if (opts.documentId !== void 0) {
35049
- path11 += `?document_id=${opts.documentId}`;
35329
+ path12 += `?document_id=${opts.documentId}`;
35050
35330
  }
35051
- await client.deleteJSON(path11, options);
35331
+ await client.deleteJSON(path12, options);
35052
35332
  }
35053
35333
  async function bulkYearEdit(client, payload, options) {
35054
35334
  const out = await client.postJSON(
@@ -36431,7 +36711,7 @@ function buildIncludeBatchAction(docId, include, targets) {
36431
36711
  const canonical = `${docId}|${include ? "on" : "off"}|${targets.map((v) => v.id).slice().sort((a, b) => a - b).join(",")}`;
36432
36712
  return {
36433
36713
  resource: "filebox-version-batch",
36434
- id: createHash8("sha256").update(canonical).digest("hex").slice(0, 12),
36714
+ id: createHash9("sha256").update(canonical).digest("hex").slice(0, 12),
36435
36715
  verb: includeStateWords(include).verb
36436
36716
  };
36437
36717
  }
@@ -39187,8 +39467,8 @@ async function runIntegrationsErrors(cfg) {
39187
39467
  if (cfg.id <= 0) {
39188
39468
  throw new Error("integration id must be positive");
39189
39469
  }
39190
- const path11 = cfg.queryId > 0 ? `/api/data_integrations/${cfg.queryId}/data_query/error_explanation` : `/api/data_integrations/${cfg.id}/data_source/error_explanation`;
39191
- const result = await getErrorExplanation(cfg.client, path11, {
39470
+ const path12 = cfg.queryId > 0 ? `/api/data_integrations/${cfg.queryId}/data_query/error_explanation` : `/api/data_integrations/${cfg.id}/data_source/error_explanation`;
39471
+ const result = await getErrorExplanation(cfg.client, path12, {
39192
39472
  signal: cfg.signal
39193
39473
  });
39194
39474
  if (result.status === 404 || result.body === null) {
@@ -40497,7 +40777,7 @@ function registerITCommands(parent) {
40497
40777
 
40498
40778
  // src/commands/connectors.ts
40499
40779
  import { execFile } from "child_process";
40500
- import * as path8 from "path";
40780
+ import * as path9 from "path";
40501
40781
  import { promisify } from "util";
40502
40782
 
40503
40783
  // src/api/connectors.ts
@@ -40512,20 +40792,20 @@ var ControlPlaneError = class extends Error {
40512
40792
  }
40513
40793
  };
40514
40794
  async function ingestVersion(client, name, version, reqOptions) {
40515
- const path11 = `/connectors/${encodeURIComponent(name)}/ingest`;
40795
+ const path12 = `/connectors/${encodeURIComponent(name)}/ingest`;
40516
40796
  let out;
40517
40797
  try {
40518
- out = await client.postJSON(path11, { version }, reqOptions);
40798
+ out = await client.postJSON(path12, { version }, reqOptions);
40519
40799
  } catch (err) {
40520
- throw toControlPlaneError("POST", path11, err);
40800
+ throw toControlPlaneError("POST", path12, err);
40521
40801
  }
40522
40802
  if (out === null) {
40523
- throw new Error(`POST ${path11}: empty response from control-plane ingest`);
40803
+ throw new Error(`POST ${path12}: empty response from control-plane ingest`);
40524
40804
  }
40525
40805
  return out;
40526
40806
  }
40527
40807
  async function createConnector(client, fields, reqOptions) {
40528
- const path11 = "/connectors";
40808
+ const path12 = "/connectors";
40529
40809
  const body = {
40530
40810
  type: fields.type,
40531
40811
  secret_ref: fields.secret_ref,
@@ -40534,30 +40814,30 @@ async function createConnector(client, fields, reqOptions) {
40534
40814
  if (fields.org_id !== void 0) body["org_id"] = fields.org_id;
40535
40815
  let out;
40536
40816
  try {
40537
- out = await client.postJSON(path11, body, reqOptions);
40817
+ out = await client.postJSON(path12, body, reqOptions);
40538
40818
  } catch (err) {
40539
- throw toControlPlaneError("POST", path11, err);
40819
+ throw toControlPlaneError("POST", path12, err);
40540
40820
  }
40541
40821
  if (out === null) {
40542
- throw new Error(`POST ${path11}: empty response from control-plane connector create`);
40822
+ throw new Error(`POST ${path12}: empty response from control-plane connector create`);
40543
40823
  }
40544
40824
  return out;
40545
40825
  }
40546
40826
  async function createQuery(client, fields, reqOptions) {
40547
- const path11 = "/connector-queries";
40827
+ const path12 = "/connector-queries";
40548
40828
  let out;
40549
40829
  try {
40550
- out = await client.postJSON(path11, fields, reqOptions);
40830
+ out = await client.postJSON(path12, fields, reqOptions);
40551
40831
  } catch (err) {
40552
- throw toControlPlaneError("POST", path11, err);
40832
+ throw toControlPlaneError("POST", path12, err);
40553
40833
  }
40554
40834
  if (out === null) {
40555
- throw new Error(`POST ${path11}: empty response from control-plane query create`);
40835
+ throw new Error(`POST ${path12}: empty response from control-plane query create`);
40556
40836
  }
40557
40837
  return out;
40558
40838
  }
40559
40839
  async function repointQuery(client, queryId, fields, reqOptions) {
40560
- const path11 = `/connector-queries/${queryId}`;
40840
+ const path12 = `/connector-queries/${queryId}`;
40561
40841
  const body = {};
40562
40842
  if (fields.artifact_name !== void 0) body["artifact_name"] = fields.artifact_name;
40563
40843
  if (fields.artifact_version !== void 0) body["artifact_version"] = fields.artifact_version;
@@ -40567,66 +40847,66 @@ async function repointQuery(client, queryId, fields, reqOptions) {
40567
40847
  if (fields.query_config !== void 0) body["query_config"] = fields.query_config;
40568
40848
  let out;
40569
40849
  try {
40570
- out = await client.patchJSON(path11, body, reqOptions);
40850
+ out = await client.patchJSON(path12, body, reqOptions);
40571
40851
  } catch (err) {
40572
- throw toControlPlaneError("PATCH", path11, err);
40852
+ throw toControlPlaneError("PATCH", path12, err);
40573
40853
  }
40574
40854
  if (out === null) {
40575
- throw new Error(`PATCH ${path11}: empty response from control-plane repoint`);
40855
+ throw new Error(`PATCH ${path12}: empty response from control-plane repoint`);
40576
40856
  }
40577
40857
  return out;
40578
40858
  }
40579
40859
  async function getBinding(client, fileboxUuid, reqOptions) {
40580
- const path11 = `/internal/bindings/${encodeURIComponent(fileboxUuid)}`;
40860
+ const path12 = `/internal/bindings/${encodeURIComponent(fileboxUuid)}`;
40581
40861
  let out;
40582
40862
  try {
40583
- out = await client.getJSON(path11, reqOptions);
40863
+ out = await client.getJSON(path12, reqOptions);
40584
40864
  } catch (err) {
40585
- throw toControlPlaneError("GET", path11, err);
40865
+ throw toControlPlaneError("GET", path12, err);
40586
40866
  }
40587
40867
  if (out === null) {
40588
- throw new Error(`GET ${path11}: empty response from control-plane binding get`);
40868
+ throw new Error(`GET ${path12}: empty response from control-plane binding get`);
40589
40869
  }
40590
40870
  return out;
40591
40871
  }
40592
40872
  async function listQueries(client, reqOptions) {
40593
- const path11 = "/connector-queries";
40873
+ const path12 = "/connector-queries";
40594
40874
  try {
40595
- return await client.getJSON(path11, reqOptions) ?? [];
40875
+ return await client.getJSON(path12, reqOptions) ?? [];
40596
40876
  } catch (err) {
40597
- throw toControlPlaneError("GET", path11, err);
40877
+ throw toControlPlaneError("GET", path12, err);
40598
40878
  }
40599
40879
  }
40600
40880
  async function deleteQuery(client, queryId, reqOptions) {
40601
- const path11 = `/connector-queries/${queryId}`;
40881
+ const path12 = `/connector-queries/${queryId}`;
40602
40882
  try {
40603
- await client.deleteJSON(path11, reqOptions);
40883
+ await client.deleteJSON(path12, reqOptions);
40604
40884
  } catch (err) {
40605
- throw toControlPlaneError("DELETE", path11, err);
40885
+ throw toControlPlaneError("DELETE", path12, err);
40606
40886
  }
40607
40887
  }
40608
40888
  async function deregisterArtifact(client, name, version, reqOptions) {
40609
- const path11 = `/internal/artifacts/${encodeURIComponent(name)}/${encodeURIComponent(version)}`;
40889
+ const path12 = `/internal/artifacts/${encodeURIComponent(name)}/${encodeURIComponent(version)}`;
40610
40890
  try {
40611
- await client.deleteJSON(path11, reqOptions);
40891
+ await client.deleteJSON(path12, reqOptions);
40612
40892
  } catch (err) {
40613
- throw toControlPlaneError("DELETE", path11, err);
40893
+ throw toControlPlaneError("DELETE", path12, err);
40614
40894
  }
40615
40895
  }
40616
40896
  async function promoteActive(client, name, version, reqOptions) {
40617
- const path11 = `/connectors/${encodeURIComponent(name)}/active`;
40897
+ const path12 = `/connectors/${encodeURIComponent(name)}/active`;
40618
40898
  try {
40619
- return await client.postJSON(path11, { version }, reqOptions);
40899
+ return await client.postJSON(path12, { version }, reqOptions);
40620
40900
  } catch (err) {
40621
- throw toControlPlaneError("POST", path11, err);
40901
+ throw toControlPlaneError("POST", path12, err);
40622
40902
  }
40623
40903
  }
40624
40904
  async function resolveActive(client, name, orgId, reqOptions) {
40625
- const path11 = `/internal/connectors/${encodeURIComponent(name)}/active?org_id=${orgId}`;
40905
+ const path12 = `/internal/connectors/${encodeURIComponent(name)}/active?org_id=${orgId}`;
40626
40906
  try {
40627
- return await client.getJSON(path11, reqOptions);
40907
+ return await client.getJSON(path12, reqOptions);
40628
40908
  } catch (err) {
40629
- const e = toControlPlaneError("GET", path11, err);
40909
+ const e = toControlPlaneError("GET", path12, err);
40630
40910
  if (e instanceof ControlPlaneError && e.status === 404) return null;
40631
40911
  throw e;
40632
40912
  }
@@ -40636,19 +40916,19 @@ async function cancelSync(client, fileboxUuid, target = {}, reqOptions) {
40636
40916
  if (target.mode !== void 0) query.set("mode", target.mode);
40637
40917
  if (target.dateTags !== void 0) query.set("date_tags", target.dateTags);
40638
40918
  const suffix = query.toString() === "" ? "" : `?${query.toString()}`;
40639
- const path11 = `/fileboxes/${encodeURIComponent(fileboxUuid)}/sync/cancel${suffix}`;
40919
+ const path12 = `/fileboxes/${encodeURIComponent(fileboxUuid)}/sync/cancel${suffix}`;
40640
40920
  let out;
40641
40921
  try {
40642
- out = await client.postJSON(path11, {}, reqOptions);
40922
+ out = await client.postJSON(path12, {}, reqOptions);
40643
40923
  } catch (err) {
40644
- throw toControlPlaneError("POST", path11, err);
40924
+ throw toControlPlaneError("POST", path12, err);
40645
40925
  }
40646
40926
  if (out === null) {
40647
- throw new Error(`POST ${path11}: empty response from control-plane sync cancel`);
40927
+ throw new Error(`POST ${path12}: empty response from control-plane sync cancel`);
40648
40928
  }
40649
40929
  return out;
40650
40930
  }
40651
- function toControlPlaneError(method, path11, err) {
40931
+ function toControlPlaneError(method, path12, err) {
40652
40932
  const msg = err instanceof Error ? err.message : String(err);
40653
40933
  const m = /HTTP (\d{3})(?::\s*([\s\S]*))?$/.exec(msg);
40654
40934
  if (m === null) return err;
@@ -40657,13 +40937,13 @@ function toControlPlaneError(method, path11, err) {
40657
40937
  return new ControlPlaneError(
40658
40938
  status2,
40659
40939
  body,
40660
- `${method} ${path11}: HTTP ${status2}${body === "" ? "" : `: ${body}`}`
40940
+ `${method} ${path12}: HTTP ${status2}${body === "" ? "" : `: ${body}`}`
40661
40941
  );
40662
40942
  }
40663
40943
 
40664
40944
  // src/commands/connectorsDevFetch.ts
40665
40945
  import { promises as fs16 } from "fs";
40666
- import * as path7 from "path";
40946
+ import * as path8 from "path";
40667
40947
  import { randomUUID as randomUUID2 } from "crypto";
40668
40948
  function buildDevEnvelope(i) {
40669
40949
  const config = {
@@ -40747,11 +41027,11 @@ async function writeRunDir(input) {
40747
41027
  }
40748
41028
  await fs16.mkdir(input.outDir, { recursive: true });
40749
41029
  await fs16.writeFile(
40750
- path7.join(input.outDir, ENV_FILE),
41030
+ path8.join(input.outDir, ENV_FILE),
40751
41031
  JSON.stringify(input.env, null, 2) + "\n",
40752
41032
  "utf-8"
40753
41033
  );
40754
- const secretsPath = path7.join(input.outDir, SECRETS_FILE);
41034
+ const secretsPath = path8.join(input.outDir, SECRETS_FILE);
40755
41035
  await fs16.writeFile(
40756
41036
  secretsPath,
40757
41037
  JSON.stringify({ [input.secretRef]: input.credentials }, null, 2) + "\n",
@@ -40760,11 +41040,11 @@ async function writeRunDir(input) {
40760
41040
  if (process.platform !== "win32") {
40761
41041
  await fs16.chmod(secretsPath, 384);
40762
41042
  }
40763
- await fs16.writeFile(path7.join(input.outDir, CONNECTION_FILE), connectionSource, "utf-8");
40764
- await fs16.writeFile(path7.join(input.outDir, QUERY_FILE), querySource, "utf-8");
41043
+ await fs16.writeFile(path8.join(input.outDir, CONNECTION_FILE), connectionSource, "utf-8");
41044
+ await fs16.writeFile(path8.join(input.outDir, QUERY_FILE), querySource, "utf-8");
40765
41045
  }
40766
41046
  async function ensureGitignored(entry) {
40767
- const gitignorePath = path7.join(process.cwd(), ".gitignore");
41047
+ const gitignorePath = path8.join(process.cwd(), ".gitignore");
40768
41048
  let current = "";
40769
41049
  try {
40770
41050
  current = await fs16.readFile(gitignorePath, "utf-8");
@@ -40799,7 +41079,7 @@ function registerDevFetch(connectors) {
40799
41079
  if (opts.from === void 0 !== (opts.to === void 0)) {
40800
41080
  throw new Error("--from and --to must be provided together");
40801
41081
  }
40802
- const defaultRoot = path7.join("dev-run", fileboxUuid);
41082
+ const defaultRoot = path8.join("dev-run", fileboxUuid);
40803
41083
  const outDir = opts.output ?? defaultRoot;
40804
41084
  const gitignoreEntry = opts.output ?? "dev-run";
40805
41085
  const serverKey = resolveServer(opts.server);
@@ -41072,7 +41352,7 @@ async function runPublish(cfg) {
41072
41352
  }
41073
41353
  version = cfg.tag;
41074
41354
  } else {
41075
- const cwd = path8.dirname(cfg.dataqueryFile) || ".";
41355
+ const cwd = path9.dirname(cfg.dataqueryFile) || ".";
41076
41356
  const listTags3 = cfg.listTags ?? defaultListTags;
41077
41357
  const newest = newestVersion(await listTags3(cwd, prefix), prefix);
41078
41358
  if (newest === null) {
@@ -43274,7 +43554,7 @@ function registerWidgetsCommand(root) {
43274
43554
  }
43275
43555
 
43276
43556
  // src/commands/reconciliation.ts
43277
- import { createHash as createHash9 } from "crypto";
43557
+ import { createHash as createHash10 } from "crypto";
43278
43558
  import { promises as fs18 } from "fs";
43279
43559
 
43280
43560
  // src/api/reconciliation.ts
@@ -43332,8 +43612,8 @@ async function getAccountSettings(client, params = {}, options) {
43332
43612
  if (params.entity !== void 0 && params.entity !== "") {
43333
43613
  qs.set("entity", params.entity);
43334
43614
  }
43335
- const path11 = qs.toString() === "" ? "/api/reconciliation/accounts/settings" : `/api/reconciliation/accounts/settings?${qs.toString()}`;
43336
- const out = await client.getJSON(path11, options);
43615
+ const path12 = qs.toString() === "" ? "/api/reconciliation/accounts/settings" : `/api/reconciliation/accounts/settings?${qs.toString()}`;
43616
+ const out = await client.getJSON(path12, options);
43337
43617
  return out ?? [];
43338
43618
  }
43339
43619
  async function updateAccountSettings(client, payload, options) {
@@ -43386,8 +43666,8 @@ async function getProcessEvidences(client, params, options) {
43386
43666
  if (params.evidenceType !== void 0 && params.evidenceType !== "") {
43387
43667
  qs.set("evidence_type", params.evidenceType);
43388
43668
  }
43389
- const path11 = qs.toString() === "" ? `/api/reconciliation/processes/${params.processId}/evidences` : `/api/reconciliation/processes/${params.processId}/evidences?${qs.toString()}`;
43390
- const out = await client.getJSON(path11, options);
43669
+ const path12 = qs.toString() === "" ? `/api/reconciliation/processes/${params.processId}/evidences` : `/api/reconciliation/processes/${params.processId}/evidences?${qs.toString()}`;
43670
+ const out = await client.getJSON(path12, options);
43391
43671
  return out ?? [];
43392
43672
  }
43393
43673
  async function createSupportingItem(client, params, file, filename, options) {
@@ -43417,17 +43697,17 @@ async function getProcessSupportingItems(client, params, options) {
43417
43697
  if (params.entity !== void 0 && params.entity !== "") {
43418
43698
  qs.set("entity", params.entity);
43419
43699
  }
43420
- const path11 = qs.toString() === "" ? `/api/reconciliation/processes/${params.processId}/supporting_items` : `/api/reconciliation/processes/${params.processId}/supporting_items?${qs.toString()}`;
43421
- const out = await client.getJSON(path11, options);
43700
+ const path12 = qs.toString() === "" ? `/api/reconciliation/processes/${params.processId}/supporting_items` : `/api/reconciliation/processes/${params.processId}/supporting_items?${qs.toString()}`;
43701
+ const out = await client.getJSON(path12, options);
43422
43702
  return out ?? [];
43423
43703
  }
43424
43704
  async function getEvidenceFile(client, params, options) {
43425
- const path11 = params.accountId !== void 0 && params.accountId !== "" ? `/api/reconciliation/processes/${params.processId}/account/${params.accountId}/evidences/${params.evidenceId}/file` : `/api/reconciliation/processes/${params.processId}/evidences/${params.evidenceId}/file`;
43426
- const res = await client.do("GET", path11, void 0, options);
43705
+ const path12 = params.accountId !== void 0 && params.accountId !== "" ? `/api/reconciliation/processes/${params.processId}/account/${params.accountId}/evidences/${params.evidenceId}/file` : `/api/reconciliation/processes/${params.processId}/evidences/${params.evidenceId}/file`;
43706
+ const res = await client.do("GET", path12, void 0, options);
43427
43707
  if (res.status < 200 || res.status >= 300) {
43428
43708
  const text2 = await res.text();
43429
43709
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
43430
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncated}`);
43710
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncated}`);
43431
43711
  }
43432
43712
  const ab = await res.arrayBuffer();
43433
43713
  return Buffer.from(ab);
@@ -43440,8 +43720,8 @@ async function getFileboxConnections(client, params = {}, options) {
43440
43720
  if (params.fileboxId !== void 0) {
43441
43721
  qs.set("filebox_id", String(params.fileboxId));
43442
43722
  }
43443
- const path11 = qs.toString() === "" ? "/api/reconciliation/filebox/connections" : `/api/reconciliation/filebox/connections?${qs.toString()}`;
43444
- const out = await client.getJSON(path11, options);
43723
+ const path12 = qs.toString() === "" ? "/api/reconciliation/filebox/connections" : `/api/reconciliation/filebox/connections?${qs.toString()}`;
43724
+ const out = await client.getJSON(path12, options);
43445
43725
  return out ?? [];
43446
43726
  }
43447
43727
  async function getFileboxConnection(client, params, options) {
@@ -43482,8 +43762,8 @@ async function deleteFileboxConnection(client, connectionId, options) {
43482
43762
  );
43483
43763
  }
43484
43764
  async function getFileboxSyncProgress(client, params, options) {
43485
- const path11 = `/api/reconciliation/filebox/connections/${params.connectionId}/sync/progress`;
43486
- const res = await client.do("GET", path11, void 0, options);
43765
+ const path12 = `/api/reconciliation/filebox/connections/${params.connectionId}/sync/progress`;
43766
+ const res = await client.do("GET", path12, void 0, options);
43487
43767
  const text2 = await res.text();
43488
43768
  if (res.status === 200 || res.status === 409) {
43489
43769
  if (text2 === "" || text2 === '""') {
@@ -43493,11 +43773,11 @@ async function getFileboxSyncProgress(client, params, options) {
43493
43773
  return JSON.parse(text2);
43494
43774
  } catch (err) {
43495
43775
  const msg = err instanceof Error ? err.message : String(err);
43496
- throw new Error(`GET ${path11}: decode: ${msg}`);
43776
+ throw new Error(`GET ${path12}: decode: ${msg}`);
43497
43777
  }
43498
43778
  }
43499
43779
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
43500
- throw new Error(`GET ${path11}: HTTP ${res.status}: ${truncated}`);
43780
+ throw new Error(`GET ${path12}: HTTP ${res.status}: ${truncated}`);
43501
43781
  }
43502
43782
  async function getFileboxUnlinkedCount(client, params, options) {
43503
43783
  const qs = new URLSearchParams();
@@ -43643,15 +43923,15 @@ import { promises as fs17 } from "fs";
43643
43923
  var ASSIGNEE_REQUIRED = ["account_id", "type", "user_id"];
43644
43924
  var ASSIGNEE_OPTIONAL = ["user_name", "user_email"];
43645
43925
  var CLEAR_REQUIRED = ["account_id", "type"];
43646
- async function readAssigneeCsv(path11) {
43647
- return parseAssigneeCsvText(await readFileArg(path11));
43926
+ async function readAssigneeCsv(path12) {
43927
+ return parseAssigneeCsvText(await readFileArg(path12));
43648
43928
  }
43649
- async function readClearAssigneeCsv(path11) {
43650
- return parseClearAssigneeCsvText(await readFileArg(path11));
43929
+ async function readClearAssigneeCsv(path12) {
43930
+ return parseClearAssigneeCsvText(await readFileArg(path12));
43651
43931
  }
43652
- async function readFileArg(path11) {
43932
+ async function readFileArg(path12) {
43653
43933
  try {
43654
- return await fs17.readFile(path11, "utf8");
43934
+ return await fs17.readFile(path12, "utf8");
43655
43935
  } catch (err) {
43656
43936
  const m = err instanceof Error ? err.message : String(err);
43657
43937
  throw new Error(`read --file: ${m}`);
@@ -44901,7 +45181,7 @@ function chunkByJsonBytes(rows, maxBytes) {
44901
45181
  return chunks;
44902
45182
  }
44903
45183
  function settingsActionId(settings) {
44904
- return createHash9("sha256").update(JSON.stringify(settings)).digest("hex").slice(0, 12);
45184
+ return createHash10("sha256").update(JSON.stringify(settings)).digest("hex").slice(0, 12);
44905
45185
  }
44906
45186
  async function runReconciliationAccountsUpdateSettings(cfg) {
44907
45187
  const action = {
@@ -45279,7 +45559,7 @@ async function runReconciliationAccountsSetAssignee(cfg) {
45279
45559
  var ASSIGNEE_BATCH_CHUNK_SIZE = 100;
45280
45560
  function assigneeBatchActionId(date, rows) {
45281
45561
  const canonical = rows.map((r) => [r.accountId, r.type, r.userId, r.userName, r.userEmail]);
45282
- return createHash9("sha256").update(JSON.stringify([date, canonical])).digest("hex").slice(0, 12);
45562
+ return createHash10("sha256").update(JSON.stringify([date, canonical])).digest("hex").slice(0, 12);
45283
45563
  }
45284
45564
  async function runReconciliationAccountsSetAssigneeBatch(cfg) {
45285
45565
  const action = {
@@ -45433,7 +45713,7 @@ verify the date matches the accounts' reporting period (try \`dr reconciliation
45433
45713
  }
45434
45714
  function clearBatchActionId(date, rows) {
45435
45715
  const canonical = rows.map((r) => [r.accountId, r.type]);
45436
- return createHash9("sha256").update(JSON.stringify(["clear", date, canonical])).digest("hex").slice(0, 12);
45716
+ return createHash10("sha256").update(JSON.stringify(["clear", date, canonical])).digest("hex").slice(0, 12);
45437
45717
  }
45438
45718
  async function runReconciliationAccountsClearAssigneeBatch(cfg) {
45439
45719
  const action = {
@@ -46757,7 +47037,7 @@ function applyProse(data4, overlay, warn2 = () => {
46757
47037
 
46758
47038
  // src/commands/_validateReportRender.ts
46759
47039
  import { readFile as readFile6 } from "fs/promises";
46760
- import { join as join12 } from "path";
47040
+ import { join as join13 } from "path";
46761
47041
  var MARKER = "<!--__DATA_BLOCK__-->";
46762
47042
  function renderReportHtml(data4, templateHtml) {
46763
47043
  if (!templateHtml.includes(MARKER)) {
@@ -46768,7 +47048,7 @@ function renderReportHtml(data4, templateHtml) {
46768
47048
  return templateHtml.replace(MARKER, block);
46769
47049
  }
46770
47050
  function reportTemplatePath() {
46771
- return join12(findSkillDir("dr-validate"), "report-template.html");
47051
+ return join13(findSkillDir("dr-validate"), "report-template.html");
46772
47052
  }
46773
47053
  async function readReportTemplate() {
46774
47054
  return readFile6(reportTemplatePath(), "utf8");
@@ -47323,7 +47603,7 @@ function renderForError(v) {
47323
47603
  }
47324
47604
 
47325
47605
  // src/commands/mecWorkflow.ts
47326
- import { createHash as createHash10 } from "crypto";
47606
+ import { createHash as createHash11 } from "crypto";
47327
47607
 
47328
47608
  // src/api/workflow.ts
47329
47609
  function buildQueryString(params) {
@@ -47338,13 +47618,13 @@ function buildQueryString(params) {
47338
47618
  }
47339
47619
  return parts.length === 0 ? "" : `?${parts.join("&")}`;
47340
47620
  }
47341
- async function deleteWithBody(client, path11, body, options) {
47621
+ async function deleteWithBody(client, path12, body, options) {
47342
47622
  const encoded = JSON.stringify(body);
47343
- const res = await client.do("DELETE", path11, encoded, options);
47623
+ const res = await client.do("DELETE", path12, encoded, options);
47344
47624
  if (res.status < 200 || res.status >= 300) {
47345
47625
  const text2 = await res.text();
47346
47626
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
47347
- throw new Error(`DELETE ${path11}: HTTP ${res.status}: ${truncated}`);
47627
+ throw new Error(`DELETE ${path12}: HTTP ${res.status}: ${truncated}`);
47348
47628
  }
47349
47629
  await res.text();
47350
47630
  }
@@ -48084,10 +48364,10 @@ var STEP_TYPES = [
48084
48364
  "BudgetInput"
48085
48365
  ];
48086
48366
  var ROLES = ["WORKFLOW_V2_OWNER_ROLE", "WORKFLOW_V2_EDITOR_ROLE"];
48087
- async function readJsonFile(path11) {
48367
+ async function readJsonFile(path12) {
48088
48368
  let raw;
48089
48369
  try {
48090
- raw = await fs20.readFile(path11, "utf8");
48370
+ raw = await fs20.readFile(path12, "utf8");
48091
48371
  } catch (err) {
48092
48372
  const m = err instanceof Error ? err.message : String(err);
48093
48373
  throw new Error(`read --file: ${m}`);
@@ -48146,16 +48426,16 @@ function asParticipantId(value, where) {
48146
48426
  const obj = asObject2(value, where);
48147
48427
  return asPositiveInt(obj["id"], `${where}.id`);
48148
48428
  }
48149
- async function readTemplateCreatePayload(path11) {
48150
- const raw = await readJsonFile(path11);
48429
+ async function readTemplateCreatePayload(path12) {
48430
+ const raw = await readJsonFile(path12);
48151
48431
  return validateTemplatePayload(
48152
48432
  raw,
48153
48433
  /* requireAll */
48154
48434
  true
48155
48435
  );
48156
48436
  }
48157
- async function readTemplateUpdatePayload(path11) {
48158
- const raw = await readJsonFile(path11);
48437
+ async function readTemplateUpdatePayload(path12) {
48438
+ const raw = await readJsonFile(path12);
48159
48439
  return validateTemplatePayload(
48160
48440
  raw,
48161
48441
  /* requireAll */
@@ -48254,16 +48534,16 @@ function validateTagsArray(raw) {
48254
48534
  };
48255
48535
  });
48256
48536
  }
48257
- async function readStepCreatePayload(path11) {
48258
- const raw = await readJsonFile(path11);
48537
+ async function readStepCreatePayload(path12) {
48538
+ const raw = await readJsonFile(path12);
48259
48539
  return validateStepPayload(
48260
48540
  raw,
48261
48541
  /* requireAll */
48262
48542
  true
48263
48543
  );
48264
48544
  }
48265
- async function readStepUpdatePayload(path11) {
48266
- const raw = await readJsonFile(path11);
48545
+ async function readStepUpdatePayload(path12) {
48546
+ const raw = await readJsonFile(path12);
48267
48547
  return validateStepPayload(
48268
48548
  raw,
48269
48549
  /* requireAll */
@@ -48333,8 +48613,8 @@ function validateStepPayload(raw, requireAll) {
48333
48613
  requireBool("required_task_approval");
48334
48614
  return out;
48335
48615
  }
48336
- async function readStepReorderPayload(path11) {
48337
- const raw = await readJsonFile(path11);
48616
+ async function readStepReorderPayload(path12) {
48617
+ const raw = await readJsonFile(path12);
48338
48618
  const arr = asArray2(raw, "reorder");
48339
48619
  return arr.map((row, idx) => {
48340
48620
  const obj = asObject2(row, `reorder[${idx}]`);
@@ -48345,8 +48625,8 @@ async function readStepReorderPayload(path11) {
48345
48625
  };
48346
48626
  });
48347
48627
  }
48348
- async function readFileTaskCreatePayload(path11) {
48349
- const raw = await readJsonFile(path11);
48628
+ async function readFileTaskCreatePayload(path12) {
48629
+ const raw = await readJsonFile(path12);
48350
48630
  const arr = Array.isArray(raw) ? raw : [raw];
48351
48631
  if (arr.length === 0) {
48352
48632
  throw new Error("--file task: empty array");
@@ -48377,8 +48657,8 @@ function validateFileTaskRow(raw, where) {
48377
48657
  }
48378
48658
  return out;
48379
48659
  }
48380
- async function readNonFileTaskCreatePayload(path11) {
48381
- const raw = await readJsonFile(path11);
48660
+ async function readNonFileTaskCreatePayload(path12) {
48661
+ const raw = await readJsonFile(path12);
48382
48662
  const arr = Array.isArray(raw) ? raw : [raw];
48383
48663
  if (arr.length === 0) {
48384
48664
  throw new Error("--file task: empty array");
@@ -48415,12 +48695,12 @@ function validateNonFileTaskRow(raw, where) {
48415
48695
  }
48416
48696
  return out;
48417
48697
  }
48418
- async function readNonFileTaskUpdateOnePayload(path11) {
48419
- const raw = await readJsonFile(path11);
48698
+ async function readNonFileTaskUpdateOnePayload(path12) {
48699
+ const raw = await readJsonFile(path12);
48420
48700
  return validateNonFileTaskRow(raw, "task");
48421
48701
  }
48422
- async function readFileTaskNotifyPayload(path11) {
48423
- const raw = await readJsonFile(path11);
48702
+ async function readFileTaskNotifyPayload(path12) {
48703
+ const raw = await readJsonFile(path12);
48424
48704
  const obj = asObject2(raw, "notify");
48425
48705
  const assignees = asArray2(obj["assignees"], "notify.assignees").map((row, idx) => {
48426
48706
  const r = asObject2(row, `notify.assignees[${idx}]`);
@@ -48445,8 +48725,8 @@ async function readFileTaskNotifyPayload(path11) {
48445
48725
  }
48446
48726
  return out;
48447
48727
  }
48448
- async function readNonFileTaskNotifyPayload(path11) {
48449
- const raw = await readJsonFile(path11);
48728
+ async function readNonFileTaskNotifyPayload(path12) {
48729
+ const raw = await readJsonFile(path12);
48450
48730
  const obj = asObject2(raw, "notify");
48451
48731
  const assignees = asArray2(obj["assignees"], "notify.assignees").map((row, idx) => {
48452
48732
  const r = asObject2(row, `notify.assignees[${idx}]`);
@@ -48468,8 +48748,8 @@ async function readNonFileTaskNotifyPayload(path11) {
48468
48748
  }
48469
48749
  return out;
48470
48750
  }
48471
- async function readTaskApprovePayload(path11, approved) {
48472
- const raw = await readJsonFile(path11);
48751
+ async function readTaskApprovePayload(path12, approved) {
48752
+ const raw = await readJsonFile(path12);
48473
48753
  const obj = asObject2(raw, "approve");
48474
48754
  const tasks = asArray2(obj["tasks"], "approve.tasks").map((row, idx) => {
48475
48755
  const r = asObject2(row, `approve.tasks[${idx}]`);
@@ -48517,8 +48797,8 @@ function validateRoleOrId(value, where) {
48517
48797
  }
48518
48798
  return s;
48519
48799
  }
48520
- async function readMemberAddPayload(path11) {
48521
- const raw = await readJsonFile(path11);
48800
+ async function readMemberAddPayload(path12) {
48801
+ const raw = await readJsonFile(path12);
48522
48802
  const obj = asObject2(raw, "member");
48523
48803
  const emails = asArray2(obj["emails"], "member.emails").map(
48524
48804
  (e, idx) => asString(e, `member.emails[${idx}]`)
@@ -48529,8 +48809,8 @@ async function readMemberAddPayload(path11) {
48529
48809
  const role = validateRoleOrId(obj["role"], "member.role");
48530
48810
  return { emails, role };
48531
48811
  }
48532
- async function readGroupAddPayload(path11) {
48533
- const raw = await readJsonFile(path11);
48812
+ async function readGroupAddPayload(path12) {
48813
+ const raw = await readJsonFile(path12);
48534
48814
  const arr = Array.isArray(raw) ? raw : [raw];
48535
48815
  if (arr.length === 0) {
48536
48816
  throw new Error("--file group: empty array");
@@ -48543,8 +48823,8 @@ async function readGroupAddPayload(path11) {
48543
48823
  };
48544
48824
  });
48545
48825
  }
48546
- async function readMemberGrantBulkPayload(path11) {
48547
- const raw = await readJsonFile(path11);
48826
+ async function readMemberGrantBulkPayload(path12) {
48827
+ const raw = await readJsonFile(path12);
48548
48828
  const obj = asObject2(raw, "grant-bulk");
48549
48829
  const emails = asArray2(obj["emails"], "grant-bulk.emails").map(
48550
48830
  (e, idx) => asString(e, `grant-bulk.emails[${idx}]`)
@@ -48564,8 +48844,8 @@ async function readMemberGrantBulkPayload(path11) {
48564
48844
  role: validateRoleOrId(obj["role"], "grant-bulk.role")
48565
48845
  };
48566
48846
  }
48567
- async function readGroupGrantBulkPayload(path11) {
48568
- const raw = await readJsonFile(path11);
48847
+ async function readGroupGrantBulkPayload(path12) {
48848
+ const raw = await readJsonFile(path12);
48569
48849
  const obj = asObject2(raw, "grant-bulk");
48570
48850
  const permission_groups = asArray2(obj["permission_groups"], "grant-bulk.permission_groups").map(
48571
48851
  (id, idx) => asPositiveInt(id, `grant-bulk.permission_groups[${idx}]`)
@@ -48639,10 +48919,10 @@ function parseStepReorderShorthand(raw) {
48639
48919
  }
48640
48920
 
48641
48921
  // src/commands/_mecWorkflowFile.ts
48642
- async function readJsonFile2(path11) {
48922
+ async function readJsonFile2(path12) {
48643
48923
  let raw;
48644
48924
  try {
48645
- raw = await fs21.readFile(path11, "utf8");
48925
+ raw = await fs21.readFile(path12, "utf8");
48646
48926
  } catch (err) {
48647
48927
  const m = err instanceof Error ? err.message : String(err);
48648
48928
  throw new Error(`read --file: ${m}`);
@@ -48686,16 +48966,16 @@ function asNonNegativeInt2(value, where) {
48686
48966
  }
48687
48967
  var MEC_WORKFLOW_TYPE = "Month End Close";
48688
48968
  var NON_MEC_TYPES_HINT = "Financial Reporting | Budget | Forecast | Other";
48689
- async function readMecTemplateCreatePayload(path11) {
48690
- const raw = await readJsonFile2(path11);
48969
+ async function readMecTemplateCreatePayload(path12) {
48970
+ const raw = await readJsonFile2(path12);
48691
48971
  return validateMecTemplatePayload(
48692
48972
  raw,
48693
48973
  /* requireAll */
48694
48974
  true
48695
48975
  );
48696
48976
  }
48697
- async function readMecTemplateUpdatePayload(path11) {
48698
- const raw = await readJsonFile2(path11);
48977
+ async function readMecTemplateUpdatePayload(path12) {
48978
+ const raw = await readJsonFile2(path12);
48699
48979
  return validateMecTemplatePayload(
48700
48980
  raw,
48701
48981
  /* requireAll */
@@ -49373,13 +49653,13 @@ async function runMecAccountsTaskStatuses(cfg) {
49373
49653
  }
49374
49654
  renderMecAccountsTasksOrStatuses(cfg.out, resp, "statuses");
49375
49655
  }
49376
- function shortHash3(input) {
49377
- return createHash10("sha256").update(input).digest("hex").slice(0, 12);
49656
+ function shortHash4(input) {
49657
+ return createHash11("sha256").update(input).digest("hex").slice(0, 12);
49378
49658
  }
49379
49659
  async function runMecWorkflowCreate(cfg) {
49380
49660
  const action = {
49381
49661
  resource: "mec-workflow-template",
49382
- id: shortHash3(JSON.stringify(cfg.payload)),
49662
+ id: shortHash4(JSON.stringify(cfg.payload)),
49383
49663
  verb: "create"
49384
49664
  };
49385
49665
  await preflightConfirmToken(action, cfg.token);
@@ -50026,7 +50306,7 @@ async function runMecTaskDelete(cfg) {
50026
50306
  const sortedIds = [...cfg.ids].map((r) => r.id).sort((a, b) => a - b);
50027
50307
  const action = {
50028
50308
  resource: "mec-workflow-task-batch",
50029
- id: `${cfg.stepId}:${shortHash3(sortedIds.join(","))}`,
50309
+ id: `${cfg.stepId}:${shortHash4(sortedIds.join(","))}`,
50030
50310
  verb: "bulk-delete"
50031
50311
  };
50032
50312
  await preflightConfirmToken(action, cfg.token);
@@ -50189,7 +50469,7 @@ async function runMecTaskSignOff(cfg) {
50189
50469
  const sortedIds = [...cfg.ids].sort((a, b) => a - b);
50190
50470
  const action = {
50191
50471
  resource: "mec-workflow-task",
50192
- id: `${cfg.stepId}:${shortHash3(sortedIds.join(","))}`,
50472
+ id: `${cfg.stepId}:${shortHash4(sortedIds.join(","))}`,
50193
50473
  verb: cfg.isSignOff ? "sign-off" : "reopen"
50194
50474
  };
50195
50475
  await preflightConfirmToken(action, cfg.token);
@@ -50388,7 +50668,7 @@ async function runMecMemberGrantBulk(cfg) {
50388
50668
  const hashInput = cfg.payload.emails.join(",") + "|" + cfg.payload.entities_ids.join(",") + "|" + cfg.payload.role;
50389
50669
  const action = {
50390
50670
  resource: "mec-workflow-member-grant",
50391
- id: shortHash3(hashInput),
50671
+ id: shortHash4(hashInput),
50392
50672
  verb: "bulk"
50393
50673
  };
50394
50674
  await preflightConfirmToken(action, cfg.token);
@@ -50544,7 +50824,7 @@ async function runMecGroupGrantBulk(cfg) {
50544
50824
  const hashInput = cfg.payload.permission_groups.join(",") + "|" + cfg.payload.entities_ids.join(",") + "|" + cfg.payload.role;
50545
50825
  const action = {
50546
50826
  resource: "mec-workflow-group-grant",
50547
- id: shortHash3(hashInput),
50827
+ id: shortHash4(hashInput),
50548
50828
  verb: "bulk"
50549
50829
  };
50550
50830
  await preflightConfirmToken(action, cfg.token);
@@ -51758,7 +52038,7 @@ function wireMec(program) {
51758
52038
  }
51759
52039
 
51760
52040
  // src/commands/workflow.ts
51761
- import { createHash as createHash11 } from "crypto";
52041
+ import { createHash as createHash12 } from "crypto";
51762
52042
  function dash6(s) {
51763
52043
  if (s === null || s === void 0) return "-";
51764
52044
  if (typeof s === "number") return String(s);
@@ -52226,13 +52506,13 @@ function renderGroupList(out, rows) {
52226
52506
  (${rows.length} group${plural(rows.length)})
52227
52507
  `);
52228
52508
  }
52229
- function shortHash4(input) {
52230
- return createHash11("sha256").update(input).digest("hex").slice(0, 12);
52509
+ function shortHash5(input) {
52510
+ return createHash12("sha256").update(input).digest("hex").slice(0, 12);
52231
52511
  }
52232
52512
  async function runWorkflowCreate(cfg) {
52233
52513
  const action = {
52234
52514
  resource: "workflow-template",
52235
- id: shortHash4(JSON.stringify(cfg.payload)),
52515
+ id: shortHash5(JSON.stringify(cfg.payload)),
52236
52516
  verb: "create"
52237
52517
  };
52238
52518
  await preflightConfirmToken(action, cfg.token);
@@ -52874,7 +53154,7 @@ async function runTaskDelete(cfg) {
52874
53154
  const sortedIds = [...cfg.ids].map((r) => r.id).sort((a, b) => a - b);
52875
53155
  const action = {
52876
53156
  resource: "workflow-task-batch",
52877
- id: `${cfg.stepId}:${shortHash4(sortedIds.join(","))}`,
53157
+ id: `${cfg.stepId}:${shortHash5(sortedIds.join(","))}`,
52878
53158
  verb: "bulk-delete"
52879
53159
  };
52880
53160
  await preflightConfirmToken(action, cfg.token);
@@ -53037,7 +53317,7 @@ async function runTaskSignOff(cfg) {
53037
53317
  const sortedIds = [...cfg.ids].sort((a, b) => a - b);
53038
53318
  const action = {
53039
53319
  resource: "workflow-task",
53040
- id: `${cfg.stepId}:${shortHash4(sortedIds.join(","))}`,
53320
+ id: `${cfg.stepId}:${shortHash5(sortedIds.join(","))}`,
53041
53321
  verb: cfg.isSignOff ? "sign-off" : "reopen"
53042
53322
  };
53043
53323
  await preflightConfirmToken(action, cfg.token);
@@ -53234,7 +53514,7 @@ async function runMemberGrantBulk(cfg) {
53234
53514
  const hashInput = cfg.payload.emails.join(",") + "|" + cfg.payload.entities_ids.join(",") + "|" + cfg.payload.role;
53235
53515
  const action = {
53236
53516
  resource: "workflow-member-grant",
53237
- id: shortHash4(hashInput),
53517
+ id: shortHash5(hashInput),
53238
53518
  verb: "bulk"
53239
53519
  };
53240
53520
  await preflightConfirmToken(action, cfg.token);
@@ -53390,7 +53670,7 @@ async function runGroupGrantBulk(cfg) {
53390
53670
  const hashInput = cfg.payload.permission_groups.join(",") + "|" + cfg.payload.entities_ids.join(",") + "|" + cfg.payload.role;
53391
53671
  const action = {
53392
53672
  resource: "workflow-group-grant",
53393
- id: shortHash4(hashInput),
53673
+ id: shortHash5(hashInput),
53394
53674
  verb: "bulk"
53395
53675
  };
53396
53676
  await preflightConfirmToken(action, cfg.token);
@@ -54386,7 +54666,7 @@ function wireWorkflow(root) {
54386
54666
  }
54387
54667
 
54388
54668
  // src/commands/cash.ts
54389
- import { createHash as createHash12 } from "crypto";
54669
+ import { createHash as createHash13 } from "crypto";
54390
54670
  import { promises as fs25 } from "fs";
54391
54671
 
54392
54672
  // src/api/cash.ts
@@ -54428,8 +54708,8 @@ async function putTransactions(client, params, payload, options) {
54428
54708
  return out ?? { count: 0, next: null, previous: null, results: [] };
54429
54709
  }
54430
54710
  async function rescanTemplateRules(client, params, options) {
54431
- const path11 = `/api/templates/${params.templateId}/rules/rescan`;
54432
- const res = await client.do("POST", path11, void 0, options);
54711
+ const path12 = `/api/templates/${params.templateId}/rules/rescan`;
54712
+ const res = await client.do("POST", path12, void 0, options);
54433
54713
  const text2 = await res.text();
54434
54714
  let body = text2;
54435
54715
  if (body.startsWith('"') && body.endsWith('"') && body.length >= 2) {
@@ -54442,7 +54722,7 @@ async function rescanTemplateRules(client, params, options) {
54442
54722
  return { status: res.status, body };
54443
54723
  }
54444
54724
  const truncated = body.length > 200 ? `${body.slice(0, 200)}\u2026` : body;
54445
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncated}`);
54725
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncated}`);
54446
54726
  }
54447
54727
  async function listRules(client, params, options) {
54448
54728
  const qs = params.archived === true ? "?is_archive=true" : "";
@@ -54504,12 +54784,12 @@ async function reorderRules(client, params, payload, options) {
54504
54784
  }
54505
54785
  async function exportRulesCsv(client, params, options) {
54506
54786
  const qs = params.archived === true ? "?is_archive=true" : "";
54507
- const path11 = `/api/templates/${params.templateId}/rules/export_to_csv${qs}`;
54508
- const res = await client.do("POST", path11, void 0, options);
54787
+ const path12 = `/api/templates/${params.templateId}/rules/export_to_csv${qs}`;
54788
+ const res = await client.do("POST", path12, void 0, options);
54509
54789
  if (res.status < 200 || res.status >= 300) {
54510
54790
  const text2 = await res.text();
54511
54791
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
54512
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncated}`);
54792
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncated}`);
54513
54793
  }
54514
54794
  const csv = await res.text();
54515
54795
  const disposition = res.headers.get("content-disposition") ?? "";
@@ -54530,19 +54810,19 @@ async function upsertHiddenRules(client, params, payload, options) {
54530
54810
  return out ?? [];
54531
54811
  }
54532
54812
  async function deleteHiddenRules(client, params, customerTransactionIds, options) {
54533
- const path11 = `/api/templates/${params.templateId}/hidden_rules`;
54813
+ const path12 = `/api/templates/${params.templateId}/hidden_rules`;
54534
54814
  const body = JSON.stringify(customerTransactionIds);
54535
- const res = await client.do("DELETE", path11, body, options);
54815
+ const res = await client.do("DELETE", path12, body, options);
54536
54816
  if (res.status < 200 || res.status >= 300) {
54537
54817
  const text2 = await res.text();
54538
54818
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
54539
- throw new Error(`DELETE ${path11}: HTTP ${res.status}: ${truncated}`);
54819
+ throw new Error(`DELETE ${path12}: HTTP ${res.status}: ${truncated}`);
54540
54820
  }
54541
54821
  await res.text();
54542
54822
  }
54543
54823
  async function triggerAiRules(client, options) {
54544
- const path11 = `/api/templates/ai-rules`;
54545
- const res = await client.do("POST", path11, void 0, options);
54824
+ const path12 = `/api/templates/ai-rules`;
54825
+ const res = await client.do("POST", path12, void 0, options);
54546
54826
  const text2 = await res.text();
54547
54827
  let body = text2;
54548
54828
  if (body.startsWith('"') && body.endsWith('"') && body.length >= 2) {
@@ -54555,7 +54835,7 @@ async function triggerAiRules(client, options) {
54555
54835
  return { status: res.status, body };
54556
54836
  }
54557
54837
  const truncated = body.length > 200 ? `${body.slice(0, 200)}\u2026` : body;
54558
- throw new Error(`POST ${path11}: HTTP ${res.status}: ${truncated}`);
54838
+ throw new Error(`POST ${path12}: HTTP ${res.status}: ${truncated}`);
54559
54839
  }
54560
54840
 
54561
54841
  // src/commands/_cashRuleFile.ts
@@ -54575,10 +54855,10 @@ var OPERATIONS = [
54575
54855
  "WILDCARD"
54576
54856
  ];
54577
54857
  var STATUSES = ["active", "inactive", "archived"];
54578
- async function readJsonFile3(path11) {
54858
+ async function readJsonFile3(path12) {
54579
54859
  let raw;
54580
54860
  try {
54581
- raw = await fs23.readFile(path11, "utf8");
54861
+ raw = await fs23.readFile(path12, "utf8");
54582
54862
  } catch (err) {
54583
54863
  const m = err instanceof Error ? err.message : String(err);
54584
54864
  throw new Error(`read --file: ${m}`);
@@ -54590,8 +54870,8 @@ async function readJsonFile3(path11) {
54590
54870
  throw new Error(`parse --file: ${m}`);
54591
54871
  }
54592
54872
  }
54593
- async function readCreatePayload(path11) {
54594
- const raw = await readJsonFile3(path11);
54873
+ async function readCreatePayload(path12) {
54874
+ const raw = await readJsonFile3(path12);
54595
54875
  if (Array.isArray(raw)) {
54596
54876
  const rules = [];
54597
54877
  raw.forEach((entry, idx) => {
@@ -54604,19 +54884,19 @@ async function readCreatePayload(path11) {
54604
54884
  }
54605
54885
  return { kind: "single", rule: validateCreate(raw, "rule") };
54606
54886
  }
54607
- async function readUpdatePayload(path11) {
54608
- const raw = await readJsonFile3(path11);
54887
+ async function readUpdatePayload(path12) {
54888
+ const raw = await readJsonFile3(path12);
54609
54889
  if (Array.isArray(raw)) {
54610
54890
  throw new Error("--file: update payload must be an object, not an array");
54611
54891
  }
54612
54892
  return validateCreate(raw, "rule");
54613
54893
  }
54614
- async function readReorderPayload(path11) {
54615
- const raw = await readJsonFile3(path11);
54894
+ async function readReorderPayload(path12) {
54895
+ const raw = await readJsonFile3(path12);
54616
54896
  return validateReorder(raw, "payload");
54617
54897
  }
54618
- async function readHiddenRulesPayload(path11) {
54619
- const raw = await readJsonFile3(path11);
54898
+ async function readHiddenRulesPayload(path12) {
54899
+ const raw = await readJsonFile3(path12);
54620
54900
  if (!Array.isArray(raw)) {
54621
54901
  throw new Error("--file: hidden-rules payload must be a JSON array");
54622
54902
  }
@@ -54844,10 +55124,10 @@ function validateReorder(raw, ctx) {
54844
55124
  // src/commands/_cashRuleCsv.ts
54845
55125
  import { promises as fs24 } from "fs";
54846
55126
  var EXPECTED_HEADER5 = ["Detailed Rule", "Parameters", "Category"];
54847
- async function readCsvImportPayload(path11) {
55127
+ async function readCsvImportPayload(path12) {
54848
55128
  let raw;
54849
55129
  try {
54850
- raw = await fs24.readFile(path11, "utf8");
55130
+ raw = await fs24.readFile(path12, "utf8");
54851
55131
  } catch (err) {
54852
55132
  const m = err instanceof Error ? err.message : String(err);
54853
55133
  throw new Error(`read --file: ${m}`);
@@ -55477,7 +55757,7 @@ async function runCashRulesDeleteAll(cfg) {
55477
55757
  return;
55478
55758
  }
55479
55759
  const ids = targets.map((r) => r.id).sort((a, b) => a - b);
55480
- const sha = createHash12("sha256").update(ids.join(",")).digest("hex").slice(0, 12);
55760
+ const sha = createHash13("sha256").update(ids.join(",")).digest("hex").slice(0, 12);
55481
55761
  const action = {
55482
55762
  resource: "cash-rules-batch",
55483
55763
  id: `${templateId}:${sha}`,
@@ -56621,12 +56901,12 @@ async function renameGroup(client, body, options) {
56621
56901
  return client.putJSON("/bo/pre_kickoff/qbo_manage_companies/v2", body, options);
56622
56902
  }
56623
56903
  async function deleteEntity(client, body, options) {
56624
- const path11 = "/bo/pre_kickoff/qbo_manage_companies/v2";
56625
- const res = await client.do("DELETE", path11, JSON.stringify(body), options);
56904
+ const path12 = "/bo/pre_kickoff/qbo_manage_companies/v2";
56905
+ const res = await client.do("DELETE", path12, JSON.stringify(body), options);
56626
56906
  if (res.status < 200 || res.status >= 300) {
56627
56907
  const text2 = await res.text();
56628
56908
  const truncated = text2.length > 200 ? `${text2.slice(0, 200)}\u2026` : text2;
56629
- throw new Error(`DELETE ${path11}: HTTP ${res.status}: ${truncated}`);
56909
+ throw new Error(`DELETE ${path12}: HTTP ${res.status}: ${truncated}`);
56630
56910
  }
56631
56911
  }
56632
56912
  async function markAsManuallyCompleted(client, documentId, options) {
@@ -60434,9 +60714,9 @@ function registerKbCommand(root) {
60434
60714
  // src/mcp/claudeConfig.ts
60435
60715
  import { promises as fs28 } from "fs";
60436
60716
  import { homedir as homedir4 } from "os";
60437
- import { dirname as dirname8, join as join13 } from "path";
60717
+ import { dirname as dirname8, join as join14 } from "path";
60438
60718
  function configPath(opts) {
60439
- return join13(opts.home ?? homedir4(), ".claude.json");
60719
+ return join14(opts.home ?? homedir4(), ".claude.json");
60440
60720
  }
60441
60721
  async function readClaudeConfig(opts = {}) {
60442
60722
  const p = configPath(opts);
@@ -60608,8 +60888,8 @@ function buildContractListQuery(params) {
60608
60888
  }
60609
60889
  async function listContracts(client, params = {}, options) {
60610
60890
  const qs = buildContractListQuery(params);
60611
- const path11 = qs === "" ? `${BASE2}/contracts/` : `${BASE2}/contracts/?${qs}`;
60612
- const out = await client.getJSON(path11, options);
60891
+ const path12 = qs === "" ? `${BASE2}/contracts/` : `${BASE2}/contracts/?${qs}`;
60892
+ const out = await client.getJSON(path12, options);
60613
60893
  if (out === null) {
60614
60894
  return { items: [], total: 0, page: null, size: null, pages: null };
60615
60895
  }
@@ -61272,9 +61552,9 @@ function buildVendorListQuery(params) {
61272
61552
  if (params.size !== void 0) qs.set("size", String(params.size));
61273
61553
  return qs.toString();
61274
61554
  }
61275
- function withQuery(path11, params) {
61555
+ function withQuery(path12, params) {
61276
61556
  const qs = buildVendorListQuery(params);
61277
- return qs === "" ? path11 : `${path11}?${qs}`;
61557
+ return qs === "" ? path12 : `${path12}?${qs}`;
61278
61558
  }
61279
61559
  function emptyPage() {
61280
61560
  return { items: [], total: 0, page: null, size: null, pages: null };
@@ -62387,10 +62667,10 @@ async function preflightFile(filePath) {
62387
62667
  mime
62388
62668
  };
62389
62669
  }
62390
- async function readDraft(path11) {
62670
+ async function readDraft(path12) {
62391
62671
  let raw;
62392
62672
  try {
62393
- raw = await fsPromises3.readFile(path11, "utf8");
62673
+ raw = await fsPromises3.readFile(path12, "utf8");
62394
62674
  } catch (err) {
62395
62675
  const m = err instanceof Error ? err.message : String(err);
62396
62676
  throw new Error(`read --from: ${m}`);
@@ -62974,13 +63254,13 @@ batch ${i + 1}/${batches.length} failed: ${msg}
62974
63254
  }
62975
63255
  });
62976
63256
  }
62977
- async function appendCreatedSidecar(path11, contracts) {
63257
+ async function appendCreatedSidecar(path12, contracts) {
62978
63258
  if (contracts.length === 0) return;
62979
63259
  const lines = contracts.map((c) => {
62980
63260
  const vendor = c.vendor !== void 0 && c.vendor !== null ? c.vendor.name : "";
62981
63261
  return `${c.id} ${vendor}`;
62982
63262
  }).join("\n");
62983
- await fsPromises3.appendFile(path11, lines + "\n", "utf8");
63263
+ await fsPromises3.appendFile(path12, lines + "\n", "utf8");
62984
63264
  }
62985
63265
  async function runContractUpdate(cfg) {
62986
63266
  let raw;
@@ -64465,7 +64745,7 @@ function registerMultiProductCommand(root) {
64465
64745
 
64466
64746
  // src/commands/desk.ts
64467
64747
  import { promises as fs31 } from "fs";
64468
- import * as path9 from "path";
64748
+ import * as path10 from "path";
64469
64749
  import { Option as Option3 } from "commander";
64470
64750
 
64471
64751
  // src/api/desk.ts
@@ -64500,14 +64780,14 @@ async function getSmtpConnection(client, teamId, options) {
64500
64780
  }
64501
64781
  }
64502
64782
  async function testSmtpConnection(client, teamId, options) {
64503
- const path11 = `${TEAMS}/${teamId}/smtp-connection/test`;
64504
- const out = await client.postJSON(path11, {}, options);
64505
- return required(out, `POST ${path11}`);
64783
+ const path12 = `${TEAMS}/${teamId}/smtp-connection/test`;
64784
+ const out = await client.postJSON(path12, {}, options);
64785
+ return required(out, `POST ${path12}`);
64506
64786
  }
64507
64787
  async function setTeamSupportEmail(client, teamId, emailAddress, options) {
64508
- const path11 = `/bo/teams/${teamId}/`;
64509
- const out = await client.patchJSON(path11, { support_email: emailAddress }, options);
64510
- return required(out, `PATCH ${path11}`);
64788
+ const path12 = `/bo/teams/${teamId}/`;
64789
+ const out = await client.patchJSON(path12, { support_email: emailAddress }, options);
64790
+ return required(out, `PATCH ${path12}`);
64511
64791
  }
64512
64792
  async function registerSendgridDomain(client, domain, options) {
64513
64793
  const out = await client.postJSON(
@@ -64518,38 +64798,38 @@ async function registerSendgridDomain(client, domain, options) {
64518
64798
  return required(out, `POST ${TEAMS}/onboarding/sendgrid`);
64519
64799
  }
64520
64800
  async function getSendgridDomainStatus(client, domain, options) {
64521
- const path11 = `${TEAMS}/onboarding/sendgrid${querySuffix(domain)}`;
64522
- const out = await client.getJSON(path11, options);
64523
- return required(out, `GET ${path11}`);
64801
+ const path12 = `${TEAMS}/onboarding/sendgrid${querySuffix(domain)}`;
64802
+ const out = await client.getJSON(path12, options);
64803
+ return required(out, `GET ${path12}`);
64524
64804
  }
64525
64805
  async function verifySendgridDomain(client, domain, options) {
64526
- const path11 = `${TEAMS}/onboarding/sendgrid/verify${querySuffix(domain)}`;
64527
- const out = await client.postJSON(path11, {}, options);
64528
- return required(out, `POST ${path11}`);
64806
+ const path12 = `${TEAMS}/onboarding/sendgrid/verify${querySuffix(domain)}`;
64807
+ const out = await client.postJSON(path12, {}, options);
64808
+ return required(out, `POST ${path12}`);
64529
64809
  }
64530
64810
  async function createTicket(client, body, options) {
64531
64811
  const out = await client.postJSON(TICKETS, body, options);
64532
64812
  return required(out, `POST ${TICKETS}`);
64533
64813
  }
64534
64814
  async function createTicketMessage(client, ticketId, body, options) {
64535
- const path11 = `${TICKETS}${encodeURIComponent(ticketId)}/messages/`;
64536
- const out = await client.postJSON(path11, body, options);
64537
- return required(out, `POST ${path11}`);
64815
+ const path12 = `${TICKETS}${encodeURIComponent(ticketId)}/messages/`;
64816
+ const out = await client.postJSON(path12, body, options);
64817
+ return required(out, `POST ${path12}`);
64538
64818
  }
64539
64819
  async function uploadTicketAttachment(client, ticketId, file, filename, messageId, options) {
64540
- const path11 = `${TICKETS}${encodeURIComponent(ticketId)}/attachments/upload`;
64820
+ const path12 = `${TICKETS}${encodeURIComponent(ticketId)}/attachments/upload`;
64541
64821
  const fields = messageId === void 0 ? {} : { message_id: messageId };
64542
- const out = await client.postMultipart(path11, fields, file, {
64822
+ const out = await client.postMultipart(path12, fields, file, {
64543
64823
  fileFieldName: "file",
64544
64824
  filename,
64545
64825
  ...options
64546
64826
  });
64547
- return required(out, `POST ${path11}`);
64827
+ return required(out, `POST ${path12}`);
64548
64828
  }
64549
64829
  async function orgClone(client, payload, options) {
64550
- const path11 = "/api/desk/v1/admin/org-clone";
64551
- const out = await client.postJSON(path11, payload, options);
64552
- return required(out, `POST ${path11}`);
64830
+ const path12 = "/api/desk/v1/admin/org-clone";
64831
+ const out = await client.postJSON(path12, payload, options);
64832
+ return required(out, `POST ${path12}`);
64553
64833
  }
64554
64834
  function querySuffix(domain) {
64555
64835
  if (domain === void 0 || domain === "") return "";
@@ -65124,8 +65404,8 @@ async function planAttachments(paths, stat2 = async (p) => {
65124
65404
  for (const raw of paths) {
65125
65405
  const filePath = raw.trim();
65126
65406
  if (filePath === "") throw new Error("--attach needs a path.");
65127
- const filename = path9.basename(filePath);
65128
- const ext = path9.extname(filename).toLowerCase();
65407
+ const filename = path10.basename(filePath);
65408
+ const ext = path10.extname(filename).toLowerCase();
65129
65409
  const contentType = ATTACHMENT_CONTENT_TYPES[ext];
65130
65410
  if (contentType === void 0) {
65131
65411
  throw new Error(
@@ -66446,12 +66726,12 @@ function registerAppSpaceCommand(root) {
66446
66726
  // src/auth/versionCheck.ts
66447
66727
  import { promises as fs33 } from "fs";
66448
66728
  import * as os4 from "os";
66449
- import * as path10 from "path";
66729
+ import * as path11 from "path";
66450
66730
  var LATEST_JSON_URL = "https://drcli.datarails.com/cli/latest.json";
66451
66731
  var CACHE_TTL_MS = 60 * 60 * 1e3;
66452
66732
  var FETCH_TIMEOUT_MS = 4e3;
66453
66733
  function cachePath() {
66454
- return path10.join(os4.homedir(), ".dr", "version-check.json");
66734
+ return path11.join(os4.homedir(), ".dr", "version-check.json");
66455
66735
  }
66456
66736
  function compareSemver(a, b) {
66457
66737
  const norm = (s) => {
@@ -66485,7 +66765,7 @@ async function readCache() {
66485
66765
  }
66486
66766
  async function writeCache(entry) {
66487
66767
  const target = cachePath();
66488
- const dir = path10.dirname(target);
66768
+ const dir = path11.dirname(target);
66489
66769
  await fs33.mkdir(dir, { recursive: true });
66490
66770
  const tmp = `${target}.tmp.${process.pid}`;
66491
66771
  await fs33.writeFile(tmp, JSON.stringify(entry), { mode: 384 });
@@ -66901,7 +67181,7 @@ function commandPath(actionCommand) {
66901
67181
 
66902
67182
  // src/telemetry/config.ts
66903
67183
  import { homedir as homedir6 } from "os";
66904
- import { join as join15 } from "path";
67184
+ import { join as join16 } from "path";
66905
67185
  import { readFile as readFile7 } from "fs/promises";
66906
67186
  var TELEMETRY_ENV = "DR_CLI_TELEMETRY";
66907
67187
  var DISABLED_VALUES = /* @__PURE__ */ new Set(["0", "false", "off", "no"]);
@@ -66935,12 +67215,12 @@ function parseCollectorConfig(raw) {
66935
67215
  return { endpoint, headerName, headerValue };
66936
67216
  }
66937
67217
  function remoteSettingsPath() {
66938
- return join15(homedir6(), ".claude", "remote-settings.json");
67218
+ return join16(homedir6(), ".claude", "remote-settings.json");
66939
67219
  }
66940
- async function readCollectorConfig(path11 = remoteSettingsPath()) {
67220
+ async function readCollectorConfig(path12 = remoteSettingsPath()) {
66941
67221
  let raw;
66942
67222
  try {
66943
- raw = await readFile7(path11, "utf8");
67223
+ raw = await readFile7(path12, "utf8");
66944
67224
  } catch {
66945
67225
  return null;
66946
67226
  }