@stage-labs/metro 0.1.0-beta.130 → 0.1.0-beta.131

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.130",
3
+ "version": "0.1.0-beta.131",
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.130",
3
+ "version": "0.1.0-beta.131",
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",
@@ -60,7 +60,7 @@ function isOwner(subject: string, dir: string): boolean {
60
60
  return owner !== null && owner === normalizeAddress(subject);
61
61
  }
62
62
 
63
- function storedAgents(dir: string): Stored[] {
63
+ export function storedAgents(dir: string): Stored[] {
64
64
  return listAgentFiles(dir).map((path) => ({ path, file: readAgentFile(path) }));
65
65
  }
66
66
 
@@ -0,0 +1,33 @@
1
+ import { existsSync, readFileSync, rmSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { errMsg, log } from '@metro-labs/core/log';
4
+ import { agentsDir } from './files.js';
5
+ import { LOCAL_PROJECT_ID, localCreateAgent, localOwner, storedAgents } from './file-admin.js';
6
+
7
+ export const SEED_FILE = '.agent';
8
+
9
+ export type Seeded = 'created' | 'present' | 'none' | 'failed';
10
+
11
+ export async function seedAgent(dir = agentsDir()): Promise<Seeded> {
12
+ const path = join(dir, SEED_FILE);
13
+ if (!existsSync(path)) return 'none';
14
+ const name = readFileSync(path, 'utf8').trim();
15
+ const owner = localOwner(dir);
16
+ if (owner === null) {
17
+ log.warn({ name }, 'agent seed: no owner yet, leaving the seed for the next boot');
18
+ return 'failed';
19
+ }
20
+ if (storedAgents(dir).length > 0) {
21
+ rmSync(path, { force: true });
22
+ return 'present';
23
+ }
24
+ try {
25
+ const made = await localCreateAgent(owner, LOCAL_PROJECT_ID, name, dir);
26
+ rmSync(path, { force: true });
27
+ log.info({ id: made.id, name: made.name }, 'agent seed: agent created from the launch name');
28
+ return 'created';
29
+ } catch (err) {
30
+ log.warn({ name, err: errMsg(err) }, 'agent seed: could not create the agent');
31
+ return 'failed';
32
+ }
33
+ }
@@ -27,6 +27,7 @@ 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 { localOwner } from '../agents/file-admin.js';
30
+ import { seedAgent } from '../agents/seed.js';
30
31
  import { ensureStationDeps } from '../stations/runtime-deps.js';
31
32
  import { localSessionApis } from '../routes/local-mode.js';
32
33
  import type { SessionApis } from '../routes/session-apis.js';
@@ -134,6 +135,7 @@ function startConnectors(): void {
134
135
 
135
136
  async function main(): Promise<void> {
136
137
  applyLocalOwner();
138
+ await seedAgent();
137
139
  await materializeFrom(fileSource, { allowEmpty: true });
138
140
  supervisor.start();
139
141
  const metroMcp = await createMetroMcp();
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.130"
2
+ "version": "0.1.0-beta.131"
3
3
  }