claude-codex-proxy 1.0.5-beta.34 → 1.0.5-beta.35

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": "claude-codex-proxy",
3
- "version": "1.0.5-beta.34",
3
+ "version": "1.0.5-beta.35",
4
4
  "description": "Multi-account proxy server for OpenAI Codex CLI with Claude API compatibility",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -13,13 +13,32 @@ import { shouldLogRawProxyPayloads } from '../utils/proxy-logging.js';
13
13
  let accountRotator = null;
14
14
  let currentStrategy = null;
15
15
 
16
+ /**
17
+ * Resolves the session affinity identifier used by the upstream Codex request.
18
+ * Metadata is preferred for Claude Code compatibility, followed by Pi's
19
+ * supported session affinity headers.
20
+ */
16
21
  function getRequestContext(req) {
22
+ let metadataSessionId;
23
+
17
24
  try {
18
25
  const metadata = JSON.parse(req.body?.metadata?.user_id || '{}');
19
- return { sessionId: metadata.session_id };
26
+ metadataSessionId = metadata.session_id;
20
27
  } catch (_) {
21
- return { sessionId: undefined };
28
+ // Ignore malformed optional metadata and continue with HTTP headers.
22
29
  }
30
+
31
+ const getHeader = (name) => {
32
+ if (typeof req.get === 'function') return req.get(name);
33
+ return req.headers?.[name];
34
+ };
35
+
36
+ return {
37
+ sessionId: metadataSessionId
38
+ || getHeader('session-id')
39
+ || getHeader('x-session-id')
40
+ || getHeader('x-session-affinity')
41
+ };
23
42
  }
24
43
 
25
44
  function getAccountRotator() {