skalpel 2.0.18 → 2.0.20

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/dist/cli/index.js CHANGED
@@ -133,11 +133,19 @@ var init_streaming = __esm({
133
133
 
134
134
  // src/proxy/ws-client.ts
135
135
  import { EventEmitter } from "events";
136
+ import https from "https";
137
+ import http from "http";
136
138
  import WebSocket2 from "ws";
139
+ var H1_HTTPS_AGENT, H1_HTTP_AGENT;
137
140
  var init_ws_client = __esm({
138
141
  "src/proxy/ws-client.ts"() {
139
142
  "use strict";
140
143
  init_codex_oauth();
144
+ H1_HTTPS_AGENT = new https.Agent({
145
+ ALPNProtocols: ["http/1.1"],
146
+ keepAlive: true
147
+ });
148
+ H1_HTTP_AGENT = new http.Agent({ keepAlive: true });
141
149
  }
142
150
  });
143
151
 
@@ -1713,6 +1721,7 @@ function unconfigureAgent(agent) {
1713
1721
  import fs10 from "fs";
1714
1722
  import path11 from "path";
1715
1723
  import os8 from "os";
1724
+ import crypto from "crypto";
1716
1725
  var BEGIN_MARKER = "# BEGIN SKALPEL PROXY - do not edit manually";
1717
1726
  var END_MARKER = "# END SKALPEL PROXY";
1718
1727
  var PS_BEGIN_MARKER = "# BEGIN SKALPEL PROXY - do not edit manually";
@@ -1737,11 +1746,18 @@ function getPowerShellProfilePath() {
1737
1746
  if (fs10.existsSync(wpProfile)) return wpProfile;
1738
1747
  return psProfile;
1739
1748
  }
1749
+ function randomPlaceholder() {
1750
+ return `sk-codex-skalpel-${crypto.randomBytes(8).toString("hex")}`;
1751
+ }
1740
1752
  function generateUnixBlock(proxyConfig) {
1741
1753
  return [
1742
1754
  BEGIN_MARKER,
1743
1755
  `export ANTHROPIC_BASE_URL="http://localhost:${proxyConfig.anthropicPort}"`,
1744
1756
  `export OPENAI_BASE_URL="http://localhost:${proxyConfig.openaiPort}"`,
1757
+ // `:-` only evaluates the default when OPENAI_API_KEY is unset or empty,
1758
+ // so a user-provided key always wins. Bash, zsh, and POSIX sh all
1759
+ // support this syntax.
1760
+ `export OPENAI_API_KEY="\${OPENAI_API_KEY:-${randomPlaceholder()}}"`,
1745
1761
  END_MARKER
1746
1762
  ].join("\n");
1747
1763
  }
@@ -1750,6 +1766,9 @@ function generatePowerShellBlock(proxyConfig) {
1750
1766
  PS_BEGIN_MARKER,
1751
1767
  `$env:ANTHROPIC_BASE_URL = "http://localhost:${proxyConfig.anthropicPort}"`,
1752
1768
  `$env:OPENAI_BASE_URL = "http://localhost:${proxyConfig.openaiPort}"`,
1769
+ // Conditional assignment — only set when the user hasn't already
1770
+ // exported OPENAI_API_KEY in their session or parent profile.
1771
+ `if (-not $env:OPENAI_API_KEY) { $env:OPENAI_API_KEY = "${randomPlaceholder()}" }`,
1753
1772
  PS_END_MARKER
1754
1773
  ].join("\n");
1755
1774
  }
@@ -1893,7 +1912,7 @@ import { execSync as execSync5 } from "child_process";
1893
1912
 
1894
1913
  // src/proxy/server.ts
1895
1914
  init_handler();
1896
- import http from "http";
1915
+ import http2 from "http";
1897
1916
 
1898
1917
  // src/proxy/logger.ts
1899
1918
  import fs11 from "fs";
@@ -2318,12 +2337,10 @@ async function runWizard(options) {
2318
2337
  print11("");
2319
2338
  const codexConfigured = agentsToConfigure.some((a) => a.name === "codex");
2320
2339
  if (codexConfigured) {
2321
- print11(" [!] Codex auth: recommended -> run 'codex login' first to enable ChatGPT plan billing.");
2322
- print11(" The OPENAI_API_KEY env var (placeholder OK) is still required for Codex startup");
2323
- print11(" but is ignored by Skalpel when OAuth is present.");
2324
- if (!process.env.OPENAI_API_KEY) {
2325
- print11(" example: export OPENAI_API_KEY=sk-codex-placeholder-skalpel");
2326
- }
2340
+ print11(" [!] Codex auth: recommended -> run 'codex login' to enable ChatGPT plan billing.");
2341
+ print11(" Without OAuth, Skalpel uses the OPENAI_API_KEY env var; if not already set,");
2342
+ print11(" Skalpel exports a placeholder so Codex starts. A real sk-... key is only");
2343
+ print11(" needed if you have no ChatGPT plan and want pay-as-you-go API billing.");
2327
2344
  print11("");
2328
2345
  }
2329
2346
  }
@@ -2542,7 +2559,7 @@ function clearNpxCache() {
2542
2559
  }
2543
2560
 
2544
2561
  // src/cli/auth/callback-server.ts
2545
- import * as http2 from "http";
2562
+ import * as http3 from "http";
2546
2563
  import * as net2 from "net";
2547
2564
 
2548
2565
  // src/cli/auth/session-storage.ts
@@ -2671,7 +2688,7 @@ async function startCallbackServer(port, timeoutMsOrOptions = DEFAULT_TIMEOUT_MS
2671
2688
  return new Promise((resolve2, reject) => {
2672
2689
  let settled = false;
2673
2690
  let timer;
2674
- const server = http2.createServer((req, res) => {
2691
+ const server = http3.createServer((req, res) => {
2675
2692
  const origin = req.headers.origin;
2676
2693
  const corsHeaders = buildCorsHeaders(origin);
2677
2694
  if (req.method === "OPTIONS") {