codemax-pro 1.3.0 → 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.
Files changed (4) hide show
  1. package/README.md +1 -37
  2. package/index.js +12 -3
  3. package/lib.js +38 -10
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -47,7 +47,6 @@ Claude Desktop
47
47
  ✓ policy gateway → https://api.codemax.pro
48
48
  ✓ auth x-api-key
49
49
  ✓ models 4 configured
50
- ✓ fetch egress ["*"], preflight off
51
50
 
52
51
  Conflicts
53
52
  ✓ no environment variables competing with the settings file
@@ -66,46 +65,11 @@ didn't work", and none of them produces an error:
66
65
 
67
66
  ---
68
67
 
69
- ## Claude Desktop
70
-
71
- The desktop app is not the CLI. It doesn't read `~/.claude/settings.json`, and setting
72
- `ANTHROPIC_BASE_URL` in the environment does nothing to it — it's a separate application that talks
73
- to whichever inference endpoint it's configured with.
74
-
75
- So this uses Anthropic's supported **third-party inference** mode, with the provider set to
76
- `gateway`. It writes to both places the app looks:
77
-
78
- | Platform | Written to |
79
- | --- | --- |
80
- | Windows | `HKCU\SOFTWARE\Policies\Claude` **and** `%LOCALAPPDATA%\Claude-3p\configLibrary\` |
81
- | macOS | `~/Library/Application Support/Claude-3p/configLibrary/` |
82
- | Linux | `~/.config/Claude-3p/configLibrary/` |
83
-
84
- Along with the endpoint and key it sets the model list, the credential header, the sandbox egress
85
- allowlist, and turns off the fetch-domain preflight.
86
-
87
- > ### ⚠️ Quit the desktop app fully, then reopen it
68
+ > ### ⚠️ Quit Claude Desktop fully, then reopen it
88
69
  > It reads its configuration **once, at launch**. Closing the window leaves the process running, so
89
70
  > a reopened window keeps the old settings — and it looks exactly like setup failed. Quit from the
90
71
  > system tray (Windows) or menu bar (macOS).
91
72
 
92
- **Web search** needs no setup — it is handled at the endpoint. **Web fetch** works on any host by
93
- default; an organisation that wants the sandbox restricted should set its own allowlist through MDM.
94
-
95
- ---
96
-
97
- ## Models
98
-
99
- | Model | Best for |
100
- | --- | --- |
101
- | `claude-opus-5` | Complex architecture and hard coding problems |
102
- | `claude-fable-5` | Extended reasoning, long-running work |
103
- | `claude-sonnet-5` | Fast, capable general-purpose work |
104
- | `claude-haiku-4-5` | Quick turnarounds and background tasks |
105
-
106
- Legacy names (`claude-opus-4-8`, `claude-sonnet-4-6`, `claude-3-5-sonnet` and others) are accepted
107
- and map onto the current lineup.
108
-
109
73
  ---
110
74
 
111
75
  ## Safety
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.exit(code || 0))
277
- .catch((e) => { p(''); bad(e.message); p(''); process.exit(1); });
285
+ .then((code) => { process.exitCode = code || 0; })
286
+ .catch((e) => { p(''); bad(e.message); p(''); process.exitCode = 1; });
package/lib.js CHANGED
@@ -20,11 +20,19 @@ const IS_MAC = process.platform === 'darwin';
20
20
  const HOME = process.env.HOME || process.env.USERPROFILE || os.homedir();
21
21
 
22
22
  /* The tiers this endpoint serves. Written out rather than discovered so the desktop model picker
23
- * is populated even before the app has talked to the endpoint once. */
23
+ * is populated even before the app has talked to the endpoint once.
24
+ *
25
+ * `supports1m` adds a second picker entry for that model, labelled as the 1M context window. It is
26
+ * an assertion the app cannot check: claim it on a model the endpoint will not take a 1M request
27
+ * for, and every request made from that entry fails at inference time — so it is set per model
28
+ * against what each one actually advertises, not switched on across the board.
29
+ *
30
+ * Haiku is deliberately absent from that list: it serves a 200K window, and giving it a 1M entry
31
+ * would offer the customer something that cannot work. */
24
32
  const MODELS = [
25
- { name: 'claude-opus-5' },
26
- { name: 'claude-fable-5' },
27
- { name: 'claude-sonnet-5' },
33
+ { name: 'claude-opus-5', supports1m: true },
34
+ { name: 'claude-fable-5', supports1m: true },
35
+ { name: 'claude-sonnet-5', supports1m: true },
28
36
  { name: 'claude-haiku-4-5-20251001' },
29
37
  ];
30
38
 
@@ -156,6 +164,12 @@ async function checkKey(apiKey, timeoutMs = 30000) {
156
164
  signal: AbortSignal.timeout(timeoutMs),
157
165
  });
158
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 */ }
159
173
  if (res.ok) return { ok: true, ms };
160
174
  // Rate limiting proves the key is real and accepted; it is not a setup failure.
161
175
  if (res.status === 429) return { ok: true, ms, note: 'rate limited right now' };
@@ -295,21 +309,35 @@ function writeWinPolicy(values) {
295
309
  '',
296
310
  ];
297
311
  const tmp = path.join(os.tmpdir(), `codemax-3p-${process.pid}.reg`);
298
- // UTF-16LE with a BOM is what reg.exe expects for a v5 file; UTF-8 imports as mojibake.
299
- fs.writeFileSync(tmp, '' + lines.join('\r\n'), 'utf16le');
300
- const ok = sh(`reg import "${tmp}"`) !== null;
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
+ }
301
323
  try { fs.unlinkSync(tmp); } catch { /* temp */ }
302
- return ok;
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') };
303
328
  }
304
329
 
305
330
  function configureDesktop(apiKey) {
306
331
  const values = desktopValues(apiKey);
307
332
  const written = [];
308
333
  let machinePolicy = false;
334
+ let policyError = null;
309
335
 
310
336
  if (IS_WIN) {
311
337
  machinePolicy = sh(`reg query "${paths.winMachinePolicy}" /v inferenceProvider`) !== null;
312
- if (writeWinPolicy(values)) written.push(paths.winPolicy);
338
+ const r = writeWinPolicy(values);
339
+ if (r.ok) written.push(paths.winPolicy);
340
+ else policyError = r.error;
313
341
  }
314
342
 
315
343
  const dir = paths.configLibrary();
@@ -340,7 +368,7 @@ function configureDesktop(apiKey) {
340
368
  devJson.allowDevTools = true;
341
369
  writeJson(dev, devJson);
342
370
 
343
- return { written, machinePolicy };
371
+ return { written, machinePolicy, policyError };
344
372
  }
345
373
 
346
374
  /* Older versions put an `env` block in claude_desktop_config.json and an MCP server entry in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codemax-pro",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Setup for CodeMax — configures Claude Code CLI, VS Code, and Claude Desktop, with a doctor and reset",
5
5
  "main": "index.js",
6
6
  "bin": {