codemax-pro 1.3.1 → 1.3.2
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/index.js +12 -3
- package/lib.js +26 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -184,8 +184,13 @@ async function setup(opts) {
|
|
|
184
184
|
if (want('desktop')) {
|
|
185
185
|
step('Claude Desktop');
|
|
186
186
|
const r = L.configureDesktop(key);
|
|
187
|
-
if (!r.written.length) warn('nothing could be written — is the app installed?');
|
|
188
187
|
for (const w of r.written) ok(w);
|
|
188
|
+
if (r.policyError) {
|
|
189
|
+
bad('could not write the Windows policy — the desktop app will not pick this up');
|
|
190
|
+
dim(r.policyError);
|
|
191
|
+
dim('the local profile below still applies, but the policy is the reliable one');
|
|
192
|
+
}
|
|
193
|
+
if (!r.written.length) warn('nothing could be written — is the app installed?');
|
|
189
194
|
if (r.machinePolicy) {
|
|
190
195
|
warn('a machine-wide policy exists and overrides what was just written');
|
|
191
196
|
dim(`${L.paths.winMachinePolicy} — ask whoever manages this device to set it there`);
|
|
@@ -272,6 +277,10 @@ async function main() {
|
|
|
272
277
|
return setup(opts);
|
|
273
278
|
}
|
|
274
279
|
|
|
280
|
+
/* Set the exit code and let Node wind down on its own, rather than calling process.exit().
|
|
281
|
+
* Forcing an exit while a socket from the connection check is still tearing down is what produced
|
|
282
|
+
* the libuv assertion above; setting the code lets the loop drain first and reports the same
|
|
283
|
+
* result to the shell. */
|
|
275
284
|
main()
|
|
276
|
-
.then((code) => process.
|
|
277
|
-
.catch((e) => { p(''); bad(e.message); p(''); process.
|
|
285
|
+
.then((code) => { process.exitCode = code || 0; })
|
|
286
|
+
.catch((e) => { p(''); bad(e.message); p(''); process.exitCode = 1; });
|
package/lib.js
CHANGED
|
@@ -164,6 +164,12 @@ async function checkKey(apiKey, timeoutMs = 30000) {
|
|
|
164
164
|
signal: AbortSignal.timeout(timeoutMs),
|
|
165
165
|
});
|
|
166
166
|
const ms = Date.now() - started;
|
|
167
|
+
/* Drain the body even though nothing here reads it. An unread response keeps its
|
|
168
|
+
* connection in fetch's pool, the pool keeps a libuv handle alive, and exiting while that
|
|
169
|
+
* handle is mid-teardown aborts the process with
|
|
170
|
+
* `Assertion failed: !(handle->flags & UV_HANDLE_CLOSING)`. Seen on Windows: the whole
|
|
171
|
+
* report printed correctly and then the process crashed, which reads as a broken tool. */
|
|
172
|
+
try { await res.arrayBuffer(); } catch { /* body already gone; nothing to release */ }
|
|
167
173
|
if (res.ok) return { ok: true, ms };
|
|
168
174
|
// Rate limiting proves the key is real and accepted; it is not a setup failure.
|
|
169
175
|
if (res.status === 429) return { ok: true, ms, note: 'rate limited right now' };
|
|
@@ -303,21 +309,35 @@ function writeWinPolicy(values) {
|
|
|
303
309
|
'',
|
|
304
310
|
];
|
|
305
311
|
const tmp = path.join(os.tmpdir(), `codemax-3p-${process.pid}.reg`);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
312
|
+
let error = null;
|
|
313
|
+
try {
|
|
314
|
+
// UTF-16LE with a BOM is what reg.exe expects for a v5 file; UTF-8 imports as mojibake.
|
|
315
|
+
fs.writeFileSync(tmp, '' + lines.join('\r\n'), 'utf16le');
|
|
316
|
+
execSync(`reg import "${tmp}"`, { encoding: 'utf8', stdio: 'pipe' });
|
|
317
|
+
} catch (e) {
|
|
318
|
+
/* Captured rather than swallowed. The first version returned a bare false here, so a failed
|
|
319
|
+
* import was indistinguishable from "not attempted" — and what the user saw afterwards was
|
|
320
|
+
* a report saying "policy not set" with nothing anywhere explaining why. */
|
|
321
|
+
error = String((e && (e.stderr || e.message)) || 'unknown').trim().split(/\r?\n/)[0];
|
|
322
|
+
}
|
|
309
323
|
try { fs.unlinkSync(tmp); } catch { /* temp */ }
|
|
310
|
-
|
|
324
|
+
|
|
325
|
+
// Trust the registry, not the exit code: confirm the value is actually readable back.
|
|
326
|
+
const verified = sh(`reg query "${paths.winPolicy}" /v inferenceProvider`) !== null;
|
|
327
|
+
return { ok: verified, error: verified ? null : (error || 'reg import reported success but the value is not readable back') };
|
|
311
328
|
}
|
|
312
329
|
|
|
313
330
|
function configureDesktop(apiKey) {
|
|
314
331
|
const values = desktopValues(apiKey);
|
|
315
332
|
const written = [];
|
|
316
333
|
let machinePolicy = false;
|
|
334
|
+
let policyError = null;
|
|
317
335
|
|
|
318
336
|
if (IS_WIN) {
|
|
319
337
|
machinePolicy = sh(`reg query "${paths.winMachinePolicy}" /v inferenceProvider`) !== null;
|
|
320
|
-
|
|
338
|
+
const r = writeWinPolicy(values);
|
|
339
|
+
if (r.ok) written.push(paths.winPolicy);
|
|
340
|
+
else policyError = r.error;
|
|
321
341
|
}
|
|
322
342
|
|
|
323
343
|
const dir = paths.configLibrary();
|
|
@@ -348,7 +368,7 @@ function configureDesktop(apiKey) {
|
|
|
348
368
|
devJson.allowDevTools = true;
|
|
349
369
|
writeJson(dev, devJson);
|
|
350
370
|
|
|
351
|
-
return { written, machinePolicy };
|
|
371
|
+
return { written, machinePolicy, policyError };
|
|
352
372
|
}
|
|
353
373
|
|
|
354
374
|
/* Older versions put an `env` block in claude_desktop_config.json and an MCP server entry in
|