@stage-labs/metro 0.1.0-beta.184 → 0.1.0-beta.185

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.184",
3
+ "version": "0.1.0-beta.185",
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.184",
3
+ "version": "0.1.0-beta.185",
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, and the standing rules loaded at each session start. No vendor credential ever sits in a config file.",
5
5
  "author": {
6
6
  "name": "Bonustrack",
@@ -70,7 +70,7 @@ export function agentEnv(user: AgentUser, extra: Record<string, string> = {}): R
70
70
  export function asUser(user: AgentUser | null, file: string, args: readonly string[], extra: Record<string, string> = {}): [string, string[]] {
71
71
  if (user === null) return [file, [...args]];
72
72
  const env = Object.entries(agentEnv(user, extra)).map(([k, v]) => `${k}=${v}`);
73
- return ['runuser', ['-u', user.name, '--', 'env', '-i', ...env, file, ...args]];
73
+ return ['setpriv', [`--reuid=${String(user.uid)}`, `--regid=${String(user.gid)}`, '--init-groups', 'env', '-i', ...env, file, ...args]];
74
74
  }
75
75
 
76
76
  export const asAgent = (file: string, args: readonly string[], extra: Record<string, string> = {}): [string, string[]] =>
@@ -5,7 +5,8 @@ import { isRecord } from '@metro-labs/core/is-record';
5
5
  import { log } from '@metro-labs/core/log';
6
6
  import { openrouterModels, openrouterZdrModels } from './openrouter.js';
7
7
  import { anthropicModels, bedrockModels } from './provider-models.js';
8
- import { syncAvailableModelsQuietly } from '../claude/setup.js';
8
+ import { routeOf, syncAvailableModelsQuietly } from '../claude/setup.js';
9
+ import { sessionRunning, stopSession } from '../claude/session.js';
9
10
  import { forgetOne } from './usage.js';
10
11
  import {
11
12
  addConnection,
@@ -35,10 +36,19 @@ const DEVICE_ID_RE = /^[A-Za-z0-9_-]{16,64}$/;
35
36
 
36
37
  export type { ModelApiDeps } from './model-store.js';
37
38
 
39
+ function restartRunningSession(): boolean {
40
+ if (!sessionRunning()) return false;
41
+ stopSession();
42
+ return true;
43
+ }
44
+
38
45
  function kept(store: Store, next: ModelConfig, deps: ModelApiDeps, note: string, fields: Record<string, unknown>): unknown {
46
+ const before = routeOf(store.read());
39
47
  store.write(next);
40
48
  syncAvailableModelsQuietly(deps.setup ?? {}, next);
41
49
  log.info(fields, note);
50
+ if (routeOf(next) !== before && (deps.restartSession ?? restartRunningSession)())
51
+ log.info({ was: before, now: routeOf(next) }, 'model-api: the model changed, so the Claude session restarts on it');
42
52
  return settingsBody(next);
43
53
  }
44
54
 
@@ -23,6 +23,7 @@ export interface ModelApiDeps {
23
23
  anthropicBase?: string;
24
24
  bedrockControlBase?: string;
25
25
  setup?: SetupDeps;
26
+ restartSession?: () => boolean;
26
27
  }
27
28
 
28
29
  export interface Store {
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.184"
2
+ "version": "0.1.0-beta.185"
3
3
  }