@stage-labs/metro 0.1.0-beta.145 → 0.1.0-beta.146

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.145",
3
+ "version": "0.1.0-beta.146",
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.145",
3
+ "version": "0.1.0-beta.146",
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",
@@ -24,10 +24,6 @@ export interface OwnedAgent {
24
24
 
25
25
  export type DeletedAgent = OwnedAgent;
26
26
 
27
- export interface ResetAgentKey extends OwnedAgent {
28
- key: string;
29
- }
30
-
31
27
  export function normalizeAgentName(raw: unknown): string {
32
28
  const name = typeof raw === 'string' ? raw.trim() : '';
33
29
  if (!AGENT_NAME_RE.test(name))
@@ -19,7 +19,6 @@ import {
19
19
  import {
20
20
  type AgentSummary,
21
21
  type DeletedAgent,
22
- type ResetAgentKey,
23
22
  } from './admin.js';
24
23
 
25
24
  const PREFIX = '/api/agents';
@@ -30,10 +29,6 @@ export interface AgentApiDeps extends AccountApiDeps {
30
29
  subject: string,
31
30
  id: string,
32
31
  ) => Promise<DeletedAgent>;
33
- resetKey: (
34
- subject: string,
35
- id: string,
36
- ) => Promise<ResetAgentKey>;
37
32
  gatherAccounts: (allowed: Set<string>) => Promise<{
38
33
  accounts: Record<string, unknown[]>;
39
34
  unavailable: string[];
@@ -47,14 +42,12 @@ export interface AgentApiDeps extends AccountApiDeps {
47
42
  type Routable =
48
43
  | { kind: 'collection' }
49
44
  | { kind: 'agent'; id: string }
50
- | { kind: 'key'; id: string }
51
45
  | { kind: 'accounts'; id: string; route: AccountRoute };
52
46
 
53
47
  type Target = Routable | { kind: 'unknown' } | null;
54
48
 
55
49
  function subTarget(id: string, rest: string[]): Target {
56
50
  if (rest.length === 0) return { kind: 'agent', id };
57
- if (rest.length === 1 && rest[0] === 'key') return { kind: 'key', id };
58
51
  if (rest[0] !== 'accounts') return { kind: 'unknown' };
59
52
  const route = accountRoute(rest.slice(1));
60
53
  return route === null ? { kind: 'unknown' } : { kind: 'accounts', id, route };
@@ -145,26 +138,6 @@ async function handleList(
145
138
  sendJson(req, res, 200, { ...base, accounts, unavailable });
146
139
  }
147
140
 
148
- async function handleResetKey(
149
- req: IncomingMessage,
150
- res: ServerResponse,
151
- deps: AgentApiDeps,
152
- session: ApiSession,
153
- id: string,
154
- ): Promise<void> {
155
- const reset = await deps.resetKey(session.subject, id);
156
- log.info(
157
- { agent: reset.name, id: reset.id, owner: session.subject },
158
- 'agent-api: reset agent key',
159
- );
160
- sendJson(req, res, 200, {
161
- id: reset.id,
162
- name: reset.name,
163
- reset: true,
164
- ...credentials(reset.key),
165
- });
166
- }
167
-
168
141
  async function handleDelete(
169
142
  req: IncomingMessage,
170
143
  res: ServerResponse,
@@ -190,11 +163,10 @@ async function routeAgent(
190
163
  tgt: AgentTarget,
191
164
  ): Promise<void> {
192
165
  try {
193
- if (tgt.kind !== 'collection') requireAdmin(session);
194
- if (tgt.kind === 'key') await handleResetKey(req, res, deps, session, tgt.id);
195
- else if (tgt.kind === 'agent')
166
+ if (tgt.kind === 'agent') {
167
+ requireAdmin(session);
196
168
  await handleDelete(req, res, deps, session, tgt.id);
197
- else await handleList(req, res, deps, session);
169
+ } else await handleList(req, res, deps, session);
198
170
  } catch (err) {
199
171
  apiFailure(req, res, err);
200
172
  }
@@ -203,7 +175,6 @@ async function routeAgent(
203
175
  const ALLOWED: Record<AgentTarget['kind'], string[]> = {
204
176
  collection: ['GET'],
205
177
  agent: ['DELETE'],
206
- key: ['POST'],
207
178
  };
208
179
 
209
180
  function methodAllowed(tgt: Routable, method: string | undefined): boolean {
@@ -4,14 +4,13 @@ import { ApiError } from '@metro-labs/http/api-error';
4
4
  import { isOrganizationId } from '@metro-labs/http/workos-token';
5
5
  import { ensureSecureDir, writeSecure } from '@metro-labs/core/secure-fs';
6
6
  import {
7
- AgentAdminError,
8
7
  newApiKey,
8
+ AgentAdminError,
9
9
  normalizeAgentName,
10
10
  type AgentSummary,
11
11
  type CreatedAgent,
12
12
  type DeletedAgent,
13
13
  type OwnedAgent,
14
- type ResetAgentKey,
15
14
  } from './admin.js';
16
15
  import type { AccountRef } from './account-attach.js';
17
16
  import {
@@ -24,7 +23,7 @@ import {
24
23
  type AgentFile,
25
24
  } from './files.js';
26
25
  import { newId } from '@metro-labs/core/ids';
27
- import { registerKey, rotateAgentKey, unregisterAgentKey } from './keys.js';
26
+ import { registerKey, unregisterAgentKey } from './keys.js';
28
27
  import { MOVABLE_STATIONS, type LoadedAgent } from '../stations/materialize.js';
29
28
  import type { StationName } from '@metro-labs/core/station-names';
30
29
  import { normalizeAddress } from '@metro-labs/core/address';
@@ -144,19 +143,6 @@ export async function ensureLocalAgent(dir = agentsDir()): Promise<Ensured> {
144
143
  return 'created';
145
144
  }
146
145
 
147
- export async function localResetAgentKey(
148
- subject: string,
149
- id: string,
150
- dir = agentsDir(),
151
- ): Promise<ResetAgentKey> {
152
- const stored = ownedOrThrow(subject, id, dir);
153
- const key = newApiKey();
154
- stored.file.key = key;
155
- save(stored);
156
- rotateAgentKey(id, key);
157
- return Promise.resolve({ id, name: stored.file.name, key });
158
- }
159
-
160
146
  export async function localDeleteAgent(
161
147
  subject: string,
162
148
  id: string,
@@ -30,11 +30,6 @@ export function unregisterAgentKey(agentId: string): void {
30
30
  if (id === agentId) agentIdByKeyHash.delete(hash);
31
31
  }
32
32
 
33
- export function rotateAgentKey(agentId: string, key: string | null): void {
34
- unregisterAgentKey(agentId);
35
- if (key !== null) registerKey(key, agentId);
36
- }
37
-
38
33
  export function agentIdForKey(token: string): string | undefined {
39
34
  if (token === '') return undefined;
40
35
  return agentIdByKeyHash.get(digest(token));
@@ -23,7 +23,7 @@ import { agentsDir, fileSource } from '../agents/files.js';
23
23
  import { syncPluginServers } from '../connectors/plugin-sync.js';
24
24
  import { readLocalConnectors } from '../connectors/store.js';
25
25
  import { ensureMetroPlugin } from '../claude/plugin-install.js';
26
- import { sessionRunning, stopSession, unwatchSession, watchSession } from '../claude/session.js';
26
+ import { unwatchSession, watchSession } from '../claude/session.js';
27
27
  import { tryClaudeSetup } from '../claude/setup.js';
28
28
  import { applyLocalOwner } from './local-owner.js';
29
29
  import { installBearerSessions } from '../routes/bearer.js';
@@ -34,7 +34,6 @@ import { localSessionApis } from '../routes/local-mode.js';
34
34
  import type { SessionApis } from '../routes/session-apis.js';
35
35
  import {
36
36
  agentLiveness,
37
- closeAgentSession,
38
37
  createMetroMcp,
39
38
  } from '../mcp/index.js';
40
39
  import { metroCall } from '../mcp/ctx.js';
@@ -116,12 +115,6 @@ function sessionApis(): SessionApis {
116
115
  exitCode = HOLD_EXIT;
117
116
  onShutdown();
118
117
  },
119
- closeAgentSession,
120
- restartClaudeSession: () => {
121
- if (!sessionRunning()) return false;
122
- stopSession();
123
- return true;
124
- },
125
118
  gatherAccounts: gatherAccountsForAgents,
126
119
  capabilities: accountStationCapabilities,
127
120
  liveness: agentLiveness,
@@ -138,11 +138,6 @@ export function agentLiveness(): Map<string, AgentLiveness> {
138
138
  return activeRegistry?.liveness() ?? new Map<string, AgentLiveness>();
139
139
  }
140
140
 
141
- export async function closeAgentSession(agentId: string): Promise<boolean> {
142
- const scopeKey = sessionScopeKey({ kind: 'agent', agentId });
143
- return (await activeRegistry?.closeScope(scopeKey)) ?? false;
144
- }
145
-
146
141
  export async function createMetroMcp(): Promise<{
147
142
  httpHandler: (req: IncomingMessage, res: ServerResponse) => Promise<void>;
148
143
  startInbound: () => void;
@@ -43,7 +43,6 @@ import {
43
43
  localListAgents,
44
44
  localOwnedAgentOrThrow,
45
45
  localOwner,
46
- localResetAgentKey,
47
46
  readLocalAgentFile,
48
47
  } from '../agents/file-admin.js';
49
48
  import { readModelConfig } from '../gateway/model-config.js';
@@ -54,8 +53,6 @@ export interface LocalModeDeps {
54
53
  reloadAgents: () => Promise<void>;
55
54
  restart: () => void;
56
55
  stop: () => void;
57
- closeAgentSession: (id: string) => Promise<boolean>;
58
- restartClaudeSession: () => boolean;
59
56
  gatherAccounts: AgentApiDeps['gatherAccounts'];
60
57
  capabilities: AgentApiDeps['capabilities'];
61
58
  liveness: AgentApiDeps['liveness'];
@@ -89,13 +86,6 @@ function agentApi(deps: LocalModeDeps): AgentApiDeps {
89
86
  attachSessions: attachSessions(deps),
90
87
  listAgents: localListAgents,
91
88
  deleteAgent: localDeleteAgent,
92
- resetKey: async (subject, id) => {
93
- const reset = await localResetAgentKey(subject, id);
94
- const closed = await deps.closeAgentSession(id);
95
- const restarted = deps.restartClaudeSession();
96
- log.info({ agent: reset.name, id, sessionClosed: closed, claudeRestarted: restarted }, 'local: key rotated');
97
- return reset;
98
- },
99
89
  gatherAccounts: deps.gatherAccounts,
100
90
  capabilities: deps.capabilities,
101
91
  attachable: ATTACHABLE.filter((s) => s !== 'webhook'),
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.145"
2
+ "version": "0.1.0-beta.146"
3
3
  }