@stage-labs/metro 0.1.0-beta.72 → 0.1.0-beta.73
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": "@stage-labs/metro",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.73",
|
|
4
4
|
"description": "The metro command line. Sign in once per machine, then hand your MCP connector list to Claude Code without the credentials touching disk, argv or shell history.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -2,7 +2,7 @@ import { randomUUID } from 'node:crypto';
|
|
|
2
2
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
3
3
|
import { arch, platform, release } from 'node:os';
|
|
4
4
|
import { isRecord } from '../daemon/is-record.js';
|
|
5
|
-
import { errMsg } from '../daemon/log.js';
|
|
5
|
+
import { errMsg, log } from '../daemon/log.js';
|
|
6
6
|
import { refreshTokens, tokensStale, type CodexTokens } from './codex-auth.js';
|
|
7
7
|
import { assembleMessage, CodexEventTranslator, parseEvent, SseParser } from './codex-stream.js';
|
|
8
8
|
import { ToolNames, toResponsesRequest } from './codex-translate.js';
|
|
@@ -10,7 +10,8 @@ import { GatewayError, idleMessage, providerStatus, sendError, upstreamMessage,
|
|
|
10
10
|
import type { ModelConfig } from './model-config.js';
|
|
11
11
|
|
|
12
12
|
export const CODEX_BASE = 'https://chatgpt.com/backend-api/codex';
|
|
13
|
-
const CODEX_VERSION = '0.
|
|
13
|
+
const CODEX_VERSION = '0.153.4';
|
|
14
|
+
const VERSION_RE = /^\d+\.\d+\.\d+(?:-[A-Za-z0-9.]+)?$/;
|
|
14
15
|
const PING_MS = 25_000;
|
|
15
16
|
const STATUS_OF: Record<string, number> = { rate_limit_error: 429, invalid_request_error: 400, permission_error: 403, overloaded_error: 529 };
|
|
16
17
|
|
|
@@ -30,7 +31,15 @@ export const freshCodexState = (): CodexState => ({ refreshing: null, latest: nu
|
|
|
30
31
|
|
|
31
32
|
const OS_NAMES: Record<string, string> = { darwin: 'Mac OS', linux: 'Linux', win32: 'Windows' };
|
|
32
33
|
|
|
33
|
-
export
|
|
34
|
+
export function codexVersion(): string {
|
|
35
|
+
const wanted = process.env.METRO_CODEX_VERSION?.trim() ?? '';
|
|
36
|
+
if (wanted === '') return CODEX_VERSION;
|
|
37
|
+
if (VERSION_RE.test(wanted)) return wanted;
|
|
38
|
+
log.warn({ value: wanted }, 'gateway: METRO_CODEX_VERSION is not a version like 0.153.4; using the built-in one');
|
|
39
|
+
return CODEX_VERSION;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const userAgent = (): string => `codex_cli_rs/${codexVersion()} (${OS_NAMES[platform()] ?? platform()} ${release()}; ${arch()}) metro`;
|
|
34
43
|
|
|
35
44
|
function headersFor(tokens: CodexTokens, sessionId: string): Record<string, string> {
|
|
36
45
|
return {
|
|
@@ -192,7 +201,7 @@ export function codexCount(res: ServerResponse, body: Record<string, unknown>):
|
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
export async function codexModels(tokens: CodexTokens, deps: Omit<CodexDeps, 'save'>): Promise<string[]> {
|
|
195
|
-
const res = await (deps.fetchImpl ?? fetch)(`${deps.base ?? CODEX_BASE}/models?client_version=${
|
|
204
|
+
const res = await (deps.fetchImpl ?? fetch)(`${deps.base ?? CODEX_BASE}/models?client_version=${codexVersion()}`, {
|
|
196
205
|
headers: { ...headersFor(tokens, randomUUID()), accept: 'application/json' },
|
|
197
206
|
redirect: 'manual',
|
|
198
207
|
});
|
package/runtime/runtime.json
CHANGED