@getmikie/cli 1.1.104 → 1.1.105

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getmikie/cli",
3
- "version": "1.1.104",
3
+ "version": "1.1.105",
4
4
  "description": "Native Mikie relay launcher for MCP clients",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -24,10 +24,10 @@
24
24
  "node": ">=22"
25
25
  },
26
26
  "optionalDependencies": {
27
- "@getmikie/darwin-arm64": "1.1.104",
28
- "@getmikie/darwin-x64": "1.1.104",
29
- "@getmikie/linux-x64-gnu": "1.1.104",
30
- "@getmikie/win32-x64": "1.1.104"
27
+ "@getmikie/darwin-arm64": "1.1.105",
28
+ "@getmikie/darwin-x64": "1.1.105",
29
+ "@getmikie/linux-x64-gnu": "1.1.105",
30
+ "@getmikie/win32-x64": "1.1.105"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public",
@@ -81,12 +81,34 @@ function hasExactKeys(value, keys) {
81
81
  );
82
82
  }
83
83
 
84
- function parseClientRepair(stdout, code) {
84
+ const MAX_NATIVE_DIAGNOSTIC_BYTES = 512;
85
+
86
+ function nativeDiagnostic({ code, stdout, stderr }) {
87
+ const redact = (value) =>
88
+ String(value ?? "")
89
+ .replace(
90
+ /(authorization|api[_-]?key|password|secret|token)\s*[:=]\s*[^\s,;]+/gi,
91
+ "$1=[redacted]",
92
+ )
93
+ .replace(/\s+/g, " ")
94
+ .trim()
95
+ .slice(0, MAX_NATIVE_DIAGNOSTIC_BYTES);
96
+ const details = [`exit=${Number.isInteger(code) ? code : 1}`];
97
+ const safeStderr = redact(stderr);
98
+ const safeStdout = redact(stdout);
99
+ if (safeStderr) details.push(`stderr=${safeStderr}`);
100
+ if (safeStdout) details.push(`stdout=${safeStdout}`);
101
+ return details.join("; ");
102
+ }
103
+
104
+ function parseClientRepair({ stdout, stderr, code }) {
85
105
  let receipt;
86
106
  try {
87
107
  receipt = JSON.parse(stdout.trim());
88
108
  } catch {
89
- throw new Error("native client reconciliation returned invalid JSON");
109
+ throw new Error(
110
+ `native client reconciliation returned invalid JSON (${nativeDiagnostic({ code, stdout, stderr })})`,
111
+ );
90
112
  }
91
113
  const exact = hasExactKeys(receipt, [
92
114
  "schema_version",
@@ -124,17 +146,32 @@ function parseClientRepair(stdout, code) {
124
146
  receipt.action === "refused" &&
125
147
  receipt.restart_required === false;
126
148
  if ((code === 0 && !current && !migrated && !absent) || (code !== 0 && !refused)) {
127
- throw new Error("native client reconciliation returned an invalid receipt");
149
+ throw new Error(
150
+ `native client reconciliation returned an invalid receipt (${nativeDiagnostic({ code, stdout, stderr })})`,
151
+ );
128
152
  }
129
153
  return receipt;
130
154
  }
131
155
 
132
- function parseClientSettlement(stdout, code, phase) {
156
+ function parseClientSettlement({ stdout, stderr, code }, phase) {
133
157
  let receipt;
134
158
  try {
135
159
  receipt = JSON.parse(stdout.trim());
136
160
  } catch {
137
- throw new Error("native client reconciliation settlement returned invalid JSON");
161
+ throw new Error(
162
+ `native client reconciliation settlement returned invalid JSON (${nativeDiagnostic({ code, stdout, stderr })})`,
163
+ );
164
+ }
165
+ const failed =
166
+ code !== 0 &&
167
+ hasExactKeys(receipt, ["schema_version", "phase", "status"]) &&
168
+ receipt.schema_version === CLIENT_SETTLEMENT_SCHEMA &&
169
+ receipt.phase === phase &&
170
+ receipt.status === "failed";
171
+ if (failed) {
172
+ throw new Error(
173
+ `native client reconciliation settlement failed (${nativeDiagnostic({ code, stdout, stderr })})`,
174
+ );
138
175
  }
139
176
  if (
140
177
  code !== 0 ||
@@ -143,7 +180,9 @@ function parseClientSettlement(stdout, code, phase) {
143
180
  receipt.phase !== phase ||
144
181
  receipt.status !== "settled"
145
182
  ) {
146
- throw new Error("native client reconciliation settlement failed");
183
+ throw new Error(
184
+ `native client reconciliation settlement failed (${nativeDiagnostic({ code, stdout, stderr })})`,
185
+ );
147
186
  }
148
187
  }
149
188
 
@@ -492,14 +531,14 @@ export async function reconcileInstalledClients({
492
531
  capture: true,
493
532
  environment: { ...baseEnvironment, MIKIE_NPM_UPDATE_REPAIR_PHASE: "prepare" },
494
533
  });
495
- const preparedReceipt = parseClientRepair(prepared.stdout, prepared.code);
534
+ const preparedReceipt = parseClientRepair(prepared);
496
535
  const settlementPhase = preparedReceipt.action === "refused" ? "rollback" : "commit";
497
536
  const committed = await commands.run(binary, CLIENT_REPAIR_ARGUMENTS, {
498
537
  shell: false,
499
538
  capture: true,
500
539
  environment: { ...baseEnvironment, MIKIE_NPM_UPDATE_REPAIR_PHASE: settlementPhase },
501
540
  });
502
- parseClientSettlement(committed.stdout, committed.code, settlementPhase);
541
+ parseClientSettlement(committed, settlementPhase);
503
542
  if (preparedReceipt.action === "refused") {
504
543
  throw new Error(
505
544
  "Mikie could not authenticate every configured client; close active clients and run `mikie update` before reinstalling",