@mushi-mushi/cli 0.28.0 → 0.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -445,4 +445,4 @@ The CLI is also importable for tooling (used by `create-mushi-mushi`):
445
445
  MIT
446
446
 
447
447
  <!-- mushi-readme-stats-footer -->
448
- <sub>Monorepo scale (July 2026): 59 edge functions · 374 SQL migrations · 13 outbound plugins · 11 inbound adapters · 19 pipeline agents. Canonical counts: <a href="https://github.com/kensaurus/mushi-mushi/blob/master/docs/stats.md">docs/stats.md</a> · <code>pnpm docs-stats</code></sub>
448
+ <sub>Monorepo scale (July 2026): 64 edge functions · 410 SQL migrations · 13 outbound plugins · 11 inbound adapters · 19 pipeline agents. Canonical counts: <a href="https://github.com/kensaurus/mushi-mushi/blob/master/docs/stats.md">docs/stats.md</a> · <code>pnpm docs-stats</code></sub>
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/version.ts
4
+ var MUSHI_CLI_VERSION = true ? "0.29.1" : "0.0.0-dev";
5
+ var MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.24.1";
6
+
7
+ export {
8
+ MUSHI_CLI_VERSION,
9
+ MUSHI_MCP_PIN_SPEC
10
+ };
@@ -0,0 +1,8 @@
1
+ // src/version.ts
2
+ var MUSHI_CLI_VERSION = true ? "0.29.1" : "0.0.0-dev";
3
+ var MUSHI_MCP_PIN_SPEC = "@mushi-mushi/mcp@0.24.1";
4
+
5
+ export {
6
+ MUSHI_CLI_VERSION,
7
+ MUSHI_MCP_PIN_SPEC
8
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MUSHI_CLI_VERSION
3
- } from "./chunk-U2VGB63C.js";
3
+ } from "./chunk-JE3STWB2.js";
4
4
  import {
5
5
  assertEndpoint,
6
6
  normalizeEndpoint
@@ -471,7 +471,30 @@ function requireUuid(value, label = "id") {
471
471
  );
472
472
  }
473
473
  var API_TIMEOUT_MS = 15e3;
474
- async function apiCall(path, config, options = {}) {
474
+ function normalizeApiError(error, httpStatus) {
475
+ const fallbackCode = httpStatus ? `HTTP_${httpStatus}` : "API_ERROR";
476
+ if (typeof error === "string") return { code: fallbackCode, message: error };
477
+ if (error && typeof error === "object") {
478
+ const e = error;
479
+ if (typeof e["code"] === "string" && typeof e["message"] === "string") {
480
+ return e;
481
+ }
482
+ const formErrors = Array.isArray(e["formErrors"]) ? e["formErrors"].map(String) : [];
483
+ const fieldErrors = e["fieldErrors"] && typeof e["fieldErrors"] === "object" ? Object.entries(e["fieldErrors"]).map(
484
+ ([field, msgs]) => `${field}: ${Array.isArray(msgs) ? msgs.join(", ") : String(msgs)}`
485
+ ) : [];
486
+ const parts = [...formErrors, ...fieldErrors];
487
+ if (parts.length > 0) return { code: "VALIDATION_ERROR", message: parts.join("; ") };
488
+ return {
489
+ ...e,
490
+ code: typeof e["code"] === "string" ? e["code"] : fallbackCode,
491
+ message: typeof e["message"] === "string" ? e["message"] : `Request failed${httpStatus ? ` (${httpStatus})` : ""}`
492
+ };
493
+ }
494
+ return { code: fallbackCode, message: `Request failed${httpStatus ? ` (${httpStatus})` : ""}` };
495
+ }
496
+ async function apiCall(path, config, options = {}, callOptions = {}) {
497
+ const timeoutMs = callOptions.timeoutMs ?? API_TIMEOUT_MS;
475
498
  const endpoint = config.endpoint;
476
499
  if (!endpoint) {
477
500
  return {
@@ -483,7 +506,7 @@ async function apiCall(path, config, options = {}) {
483
506
  };
484
507
  }
485
508
  const controller = new AbortController();
486
- const timer = setTimeout(() => controller.abort(), API_TIMEOUT_MS);
509
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
487
510
  const signals = [controller.signal, getAbortSignal()];
488
511
  const compositeSignal = AbortSignal.any ? AbortSignal.any(signals) : controller.signal;
489
512
  try {
@@ -512,6 +535,7 @@ async function apiCall(path, config, options = {}) {
512
535
  }
513
536
  } else {
514
537
  const text = await res.text();
538
+ if (callOptions.text && res.ok) return { ok: true, data: text };
515
539
  try {
516
540
  body = JSON.parse(text);
517
541
  } catch {
@@ -535,6 +559,13 @@ async function apiCall(path, config, options = {}) {
535
559
  error: { code: errCode, message: errMsg }
536
560
  };
537
561
  }
562
+ if (typeof body === "object" && body !== null && body.ok === false) {
563
+ return {
564
+ ok: false,
565
+ httpStatus: res.status,
566
+ error: normalizeApiError(body.error, res.status)
567
+ };
568
+ }
538
569
  return body;
539
570
  } catch (err) {
540
571
  clearTimeout(timer);
@@ -543,7 +574,7 @@ async function apiCall(path, config, options = {}) {
543
574
  ok: false,
544
575
  error: {
545
576
  code: "TIMEOUT",
546
- message: `Request timed out after ${API_TIMEOUT_MS / 1e3}s. Check your network or endpoint.`
577
+ message: `Request timed out after ${timeoutMs / 1e3}s. Check your network or endpoint.`
547
578
  }
548
579
  };
549
580
  }
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  MUSHI_CLI_VERSION,
4
4
  MUSHI_MCP_PIN_SPEC
5
- } from "./chunk-UVO4A2G6.js";
5
+ } from "./chunk-HHOPCVNI.js";
6
6
  import {
7
7
  detectFramework,
8
8
  envVarsToWrite,
@@ -540,7 +540,30 @@ async function probeEndpointHealth(endpoint) {
540
540
  throw err;
541
541
  }
542
542
  }
543
- async function apiCall(path, config, options = {}) {
543
+ function normalizeApiError(error, httpStatus) {
544
+ const fallbackCode = httpStatus ? `HTTP_${httpStatus}` : "API_ERROR";
545
+ if (typeof error === "string") return { code: fallbackCode, message: error };
546
+ if (error && typeof error === "object") {
547
+ const e = error;
548
+ if (typeof e["code"] === "string" && typeof e["message"] === "string") {
549
+ return e;
550
+ }
551
+ const formErrors = Array.isArray(e["formErrors"]) ? e["formErrors"].map(String) : [];
552
+ const fieldErrors = e["fieldErrors"] && typeof e["fieldErrors"] === "object" ? Object.entries(e["fieldErrors"]).map(
553
+ ([field, msgs]) => `${field}: ${Array.isArray(msgs) ? msgs.join(", ") : String(msgs)}`
554
+ ) : [];
555
+ const parts = [...formErrors, ...fieldErrors];
556
+ if (parts.length > 0) return { code: "VALIDATION_ERROR", message: parts.join("; ") };
557
+ return {
558
+ ...e,
559
+ code: typeof e["code"] === "string" ? e["code"] : fallbackCode,
560
+ message: typeof e["message"] === "string" ? e["message"] : `Request failed${httpStatus ? ` (${httpStatus})` : ""}`
561
+ };
562
+ }
563
+ return { code: fallbackCode, message: `Request failed${httpStatus ? ` (${httpStatus})` : ""}` };
564
+ }
565
+ async function apiCall(path, config, options = {}, callOptions = {}) {
566
+ const timeoutMs = callOptions.timeoutMs ?? API_TIMEOUT_MS;
544
567
  const endpoint = config.endpoint;
545
568
  if (!endpoint) {
546
569
  return {
@@ -552,7 +575,7 @@ async function apiCall(path, config, options = {}) {
552
575
  };
553
576
  }
554
577
  const controller = new AbortController();
555
- const timer = setTimeout(() => controller.abort(), API_TIMEOUT_MS);
578
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
556
579
  const signals = [controller.signal, getAbortSignal()];
557
580
  const compositeSignal = AbortSignal.any ? AbortSignal.any(signals) : controller.signal;
558
581
  try {
@@ -581,6 +604,7 @@ async function apiCall(path, config, options = {}) {
581
604
  }
582
605
  } else {
583
606
  const text = await res.text();
607
+ if (callOptions.text && res.ok) return { ok: true, data: text };
584
608
  try {
585
609
  body = JSON.parse(text);
586
610
  } catch {
@@ -604,6 +628,13 @@ async function apiCall(path, config, options = {}) {
604
628
  error: { code: errCode, message: errMsg }
605
629
  };
606
630
  }
631
+ if (typeof body === "object" && body !== null && body.ok === false) {
632
+ return {
633
+ ok: false,
634
+ httpStatus: res.status,
635
+ error: normalizeApiError(body.error, res.status)
636
+ };
637
+ }
607
638
  return body;
608
639
  } catch (err) {
609
640
  clearTimeout(timer);
@@ -612,7 +643,7 @@ async function apiCall(path, config, options = {}) {
612
643
  ok: false,
613
644
  error: {
614
645
  code: "TIMEOUT",
615
- message: `Request timed out after ${API_TIMEOUT_MS / 1e3}s. Check your network or endpoint.`
646
+ message: `Request timed out after ${timeoutMs / 1e3}s. Check your network or endpoint.`
616
647
  }
617
648
  };
618
649
  }
@@ -1064,6 +1095,7 @@ async function runConnect(opts, baseConfig = {}) {
1064
1095
  }
1065
1096
 
1066
1097
  export {
1098
+ MushiCliError,
1067
1099
  printAndExit,
1068
1100
  installSignalHandlers,
1069
1101
  trySaveKeyToKeychain,
@@ -6,10 +6,10 @@ import {
6
6
  saveConfig,
7
7
  savedSdkKeyFor,
8
8
  waitForIngestReady
9
- } from "./chunk-AV3RKAEE.js";
9
+ } from "./chunk-KQ6POXZH.js";
10
10
  import {
11
11
  MUSHI_MCP_PIN_SPEC
12
- } from "./chunk-U2VGB63C.js";
12
+ } from "./chunk-JE3STWB2.js";
13
13
  import {
14
14
  detectFramework,
15
15
  envVarsToWrite,
@@ -2,8 +2,8 @@
2
2
  import {
3
3
  resolveSdkEnvKey,
4
4
  runConnect
5
- } from "./chunk-FJETUM25.js";
6
- import "./chunk-UVO4A2G6.js";
5
+ } from "./chunk-MDYYLRWB.js";
6
+ import "./chunk-HHOPCVNI.js";
7
7
  import "./chunk-KOBEOGNF.js";
8
8
  import "./chunk-LDPFTQLE.js";
9
9
  import "./chunk-PDX44BCA.js";