@stage-labs/metro 0.1.0-beta.121 → 0.1.0-beta.123
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.123",
|
|
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": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.123",
|
|
4
4
|
"description": "Metro for Claude Code, installed by the metro daemon on this machine: every connector the agent holds as its own MCP server relayed through the daemon, the orchestrator-only guard on the main thread, the standing rules loaded at each session start, and a refresh skill for when the daemon could not keep the server list current. No vendor credential ever sits in a config file.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Bonustrack",
|
|
@@ -104,6 +104,7 @@ async function toAnthropic(
|
|
|
104
104
|
signal: watch.signal,
|
|
105
105
|
redirect: 'manual',
|
|
106
106
|
});
|
|
107
|
+
noteRefusal('anthropic', route.model, upstream);
|
|
107
108
|
noteUsageHeaders('anthropic', upstream.headers);
|
|
108
109
|
const scanner = new UsageScanner('anthropic');
|
|
109
110
|
await pipeResponse(upstream, res, watch, key === '' ? { scanner } : { ownCredential: true, scanner });
|
|
@@ -137,13 +138,22 @@ async function toOpenRouter(
|
|
|
137
138
|
signal: watch.signal,
|
|
138
139
|
redirect: 'manual',
|
|
139
140
|
});
|
|
141
|
+
noteRefusal('openrouter', route.model, upstream);
|
|
140
142
|
await pipeResponse(upstream, res, watch, { keepalive: true, ownCredential: true, scanner: new UsageScanner('openrouter') });
|
|
141
143
|
}
|
|
142
144
|
|
|
145
|
+
const thinkingOff = (body: Record<string, unknown>): boolean => isRecord(body.thinking) && body.thinking.type === 'disabled';
|
|
146
|
+
|
|
143
147
|
export function openrouterBody(body: Record<string, unknown>, model: string, zdr: boolean): Record<string, unknown> {
|
|
144
|
-
|
|
148
|
+
const sent: Record<string, unknown> = { ...body, model };
|
|
149
|
+
if (thinkingOff(body)) delete sent.thinking;
|
|
150
|
+
if (!zdr) return sent;
|
|
145
151
|
const provider = isRecord(body.provider) ? body.provider : {};
|
|
146
|
-
return { ...
|
|
152
|
+
return { ...sent, provider: { ...provider, zdr: true } };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function noteRefusal(provider: string, model: string, upstream: Response): void {
|
|
156
|
+
if (!upstream.ok) log.warn({ provider, model, status: upstream.status }, 'gateway: the provider refused the request');
|
|
147
157
|
}
|
|
148
158
|
|
|
149
159
|
async function dispatch(req: IncomingMessage, res: ServerResponse, path: string, deps: GatewayDeps): Promise<void> {
|
|
@@ -8,8 +8,6 @@ import { mintTerminalTicket } from './tickets.js';
|
|
|
8
8
|
|
|
9
9
|
const PREFIX = '/api/terminal';
|
|
10
10
|
const TICKETS = `${PREFIX}/tickets`;
|
|
11
|
-
const BUFFER = `${PREFIX}/buffer`;
|
|
12
|
-
const BUFFER_MAX = 1024 * 1024;
|
|
13
11
|
const SESSION_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/;
|
|
14
12
|
|
|
15
13
|
export const tmuxCommand = (session: string, home = homedir()): string[] => [
|
|
@@ -39,7 +37,6 @@ export const tmuxCommand = (session: string, home = homedir()): string[] => [
|
|
|
39
37
|
];
|
|
40
38
|
|
|
41
39
|
export interface TerminalApiDeps {
|
|
42
|
-
tmux?: string;
|
|
43
40
|
authorize: (subject: string) => void;
|
|
44
41
|
command?: (session: string) => string[];
|
|
45
42
|
}
|
|
@@ -67,15 +64,9 @@ export function sessionOf(raw: unknown): string {
|
|
|
67
64
|
return raw;
|
|
68
65
|
}
|
|
69
66
|
|
|
70
|
-
export function tmuxBuffer(tmux = 'tmux'): string {
|
|
71
|
-
const run = spawnSync(tmux, ['save-buffer', '-'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], maxBuffer: BUFFER_MAX });
|
|
72
|
-
if (run.error !== undefined || run.status !== 0) throw new ApiError('tmux holds nothing copied yet: select text in the terminal first', 404);
|
|
73
|
-
return run.stdout;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
67
|
export function handleTerminalRequest(req: IncomingMessage, res: ServerResponse, deps: TerminalApiDeps): boolean {
|
|
77
68
|
const path = (req.url ?? '').split('?')[0] ?? '';
|
|
78
|
-
if (path !== PREFIX && path !== TICKETS
|
|
69
|
+
if (path !== PREFIX && path !== TICKETS) return false;
|
|
79
70
|
if (req.method === 'OPTIONS') {
|
|
80
71
|
res.writeHead(204, cors(req)).end();
|
|
81
72
|
return true;
|
|
@@ -93,10 +84,6 @@ export function handleTerminalRequest(req: IncomingMessage, res: ServerResponse,
|
|
|
93
84
|
sendJson(req, res, 200, { available: tmuxAvailable(deps), sessions: tmuxSessions() });
|
|
94
85
|
return;
|
|
95
86
|
}
|
|
96
|
-
if (path === BUFFER) {
|
|
97
|
-
sendJson(req, res, 200, { text: tmuxBuffer(deps.tmux) });
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
87
|
const wanted = sessionOf(bodyField(await readJsonBody(req), 'session'));
|
|
101
88
|
const minted = mintTerminalTicket(session.subject, wanted);
|
|
102
89
|
log.info({ subject: session.subject, session: wanted }, 'terminal: ticket minted');
|
package/runtime/runtime.json
CHANGED