theclawbay 0.3.4 → 0.3.5

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.
@@ -18,6 +18,7 @@ const errors_1 = require("../lib/managed/errors");
18
18
  const DEFAULT_BACKEND_URL = "https://theclawbay.com";
19
19
  const DEFAULT_PROVIDER_ID = "theclawbay";
20
20
  const LEGACY_PROVIDER_ID = "codex-lb";
21
+ const CLI_HTTP_USER_AGENT = "theclawbay-cli";
21
22
  const DEFAULT_CODEX_MODEL = "gpt-5.4";
22
23
  const DEFAULT_OPENCLAW_MODEL = "gpt-5.4";
23
24
  const DEFAULT_MODELS = ["gpt-5.4", "gpt-5.3-codex", "gpt-5.3-codex-spark", "gpt-5.2-codex", "gpt-5.1-codex"];
@@ -64,7 +65,8 @@ function normalizeUrl(raw, label) {
64
65
  }
65
66
  }
66
67
  function hasCommand(name) {
67
- const result = (0, node_child_process_1.spawnSync)("which", [name], { stdio: "ignore" });
68
+ const lookupCommand = node_os_1.default.platform() === "win32" ? "where.exe" : "which";
69
+ const result = (0, node_child_process_1.spawnSync)(lookupCommand, [name], { stdio: "ignore" });
68
70
  return result.status === 0;
69
71
  }
70
72
  function removeManagedBlock(source, start, end) {
@@ -124,7 +126,11 @@ async function fetchBackendModelIds(backendUrl, apiKey) {
124
126
  const url = `${trimTrailingSlash(backendUrl)}/api/codex-auth/v1/proxy/v1/models`;
125
127
  try {
126
128
  const response = await fetch(url, {
127
- headers: { Authorization: `Bearer ${apiKey}` },
129
+ headers: {
130
+ Authorization: `Bearer ${apiKey}`,
131
+ Accept: "application/json",
132
+ "User-Agent": CLI_HTTP_USER_AGENT,
133
+ },
128
134
  signal: AbortSignal.timeout(4500),
129
135
  });
130
136
  if (!response.ok)
@@ -9,6 +9,7 @@ const node_crypto_1 = require("node:crypto");
9
9
  const promises_1 = __importDefault(require("node:fs/promises"));
10
10
  const node_path_1 = __importDefault(require("node:path"));
11
11
  const node_child_process_1 = require("node:child_process");
12
+ const node_os_1 = __importDefault(require("node:os"));
12
13
  const MODELS_CACHE_FILE = "models_cache.json";
13
14
  const MODELS_CACHE_STATE_FILE = "theclawbay.models-cache.json";
14
15
  const TARGET_MODEL_ID = "gpt-5.4";
@@ -198,12 +199,26 @@ function parseCodexVersion(stdout) {
198
199
  const match = stdout.match(/\b(\d+\.\d+\.\d+)\b/);
199
200
  return match ? match[1] : null;
200
201
  }
202
+ function runVersionCommand(command, args) {
203
+ const run = (0, node_child_process_1.spawnSync)(command, args, {
204
+ encoding: "utf8",
205
+ stdio: ["ignore", "pipe", "pipe"],
206
+ });
207
+ if (run.status !== 0)
208
+ return null;
209
+ return parseCodexVersion(`${run.stdout ?? ""}\n${run.stderr ?? ""}`);
210
+ }
201
211
  function inferCodexClientVersion() {
212
+ if (node_os_1.default.platform() === "win32") {
213
+ for (const commandLine of ["codex --version", "codex-cli --version", "codex.cmd --version", "codex-cli.cmd --version"]) {
214
+ const parsed = runVersionCommand("cmd.exe", ["/d", "/s", "/c", commandLine]);
215
+ if (parsed)
216
+ return parsed;
217
+ }
218
+ return null;
219
+ }
202
220
  for (const command of ["codex", "codex-cli"]) {
203
- const run = (0, node_child_process_1.spawnSync)(command, ["--version"], { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
204
- if (run.status !== 0)
205
- continue;
206
- const parsed = parseCodexVersion(run.stdout ?? "");
221
+ const parsed = runVersionCommand(command, ["--version"]);
207
222
  if (parsed)
208
223
  return parsed;
209
224
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "theclawbay",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "description": "The Claw Bay CLI: one-time API-key setup for direct Codex access.",
5
5
  "license": "MIT",
6
6
  "bin": {