@stage-labs/metro 0.1.0-beta.187 → 0.1.0-beta.188
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.188",
|
|
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.188",
|
|
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",
|
|
@@ -7,10 +7,11 @@ import { errMsg, log } from '@metro-labs/core/log';
|
|
|
7
7
|
import type { AgentUser } from './user.js';
|
|
8
8
|
|
|
9
9
|
const SKIPPED = new Set(['snap', 'lost+found']);
|
|
10
|
-
const SIZE_MS =
|
|
11
|
-
const
|
|
10
|
+
const SIZE_MS = 2_000;
|
|
11
|
+
const SIZES_BUDGET_MS = 6_000;
|
|
12
|
+
const NAMES_MAX = 1_000;
|
|
12
13
|
|
|
13
|
-
export type EntryState = 'here' | 'copying' | 'moved' | 'failed';
|
|
14
|
+
export type EntryState = 'here' | 'waiting' | 'copying' | 'moved' | 'failed';
|
|
14
15
|
|
|
15
16
|
export interface WorkspaceEntry {
|
|
16
17
|
name: string;
|
|
@@ -21,11 +22,12 @@ export interface WorkspaceEntry {
|
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
interface Job {
|
|
24
|
-
state: 'copying' | 'failed';
|
|
25
|
+
state: 'waiting' | 'copying' | 'failed';
|
|
25
26
|
error: string | null;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
const jobs = new Map<string, Job>();
|
|
30
|
+
let queue: Promise<void> = Promise.resolve();
|
|
29
31
|
|
|
30
32
|
const offered = (name: string): boolean => !name.startsWith('.') && !SKIPPED.has(name) && !name.includes('/');
|
|
31
33
|
|
|
@@ -54,16 +56,18 @@ function stateOf(name: string, user: AgentUser): Pick<WorkspaceEntry, 'state' |
|
|
|
54
56
|
return { state: present(join(user.home, name)) ? 'moved' : 'here', error: null };
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
export function listWorkspace(user: AgentUser, from = homedir()): WorkspaceEntry[] {
|
|
59
|
+
export function listWorkspace(user: AgentUser, from = homedir(), now = Date.now): WorkspaceEntry[] {
|
|
60
|
+
const until = now() + SIZES_BUDGET_MS;
|
|
58
61
|
return readdirSync(from)
|
|
59
62
|
.filter(offered)
|
|
63
|
+
.sort((a, b) => a.localeCompare(b))
|
|
60
64
|
.flatMap((name): WorkspaceEntry[] => {
|
|
61
65
|
const path = join(from, name);
|
|
62
66
|
const kind = kindOf(path);
|
|
63
67
|
if (kind === null) return [];
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
const bytes = kind === 'file' ? lstatSync(path).size : kind === 'folder' && now() < until ? sizeOf(path) : null;
|
|
69
|
+
return [{ name, kind, bytes, ...stateOf(name, user) }];
|
|
70
|
+
});
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
function run(file: string, args: string[]): Promise<void> {
|
|
@@ -105,7 +109,8 @@ function wantedNames(names: unknown): string[] {
|
|
|
105
109
|
|
|
106
110
|
function assertMovable(name: string, listed: ReadonlySet<string>, user: AgentUser): void {
|
|
107
111
|
if (!listed.has(name)) throw new ApiError(`${name} is not an entry metro offers to move`, 400);
|
|
108
|
-
|
|
112
|
+
const job = jobs.get(name)?.state;
|
|
113
|
+
if (job === 'copying' || job === 'waiting') throw new ApiError(`${name} is already being moved`, 409);
|
|
109
114
|
if (present(join(user.home, name))) throw new ApiError(`${name} already exists in ${user.home}`, 409);
|
|
110
115
|
}
|
|
111
116
|
|
|
@@ -114,10 +119,13 @@ export function startMove(names: unknown, user: AgentUser, from = homedir()): st
|
|
|
114
119
|
const listed = new Set(readdirSync(from).filter(offered));
|
|
115
120
|
for (const name of wanted) assertMovable(name, listed, user);
|
|
116
121
|
for (const name of wanted) {
|
|
117
|
-
jobs.set(name, { state: '
|
|
118
|
-
|
|
119
|
-
jobs.set(name, { state: '
|
|
120
|
-
|
|
122
|
+
jobs.set(name, { state: 'waiting', error: null });
|
|
123
|
+
queue = queue.then(async () => {
|
|
124
|
+
jobs.set(name, { state: 'copying', error: null });
|
|
125
|
+
await moveOne(name, user, from).catch((err: unknown) => {
|
|
126
|
+
jobs.set(name, { state: 'failed', error: errMsg(err) });
|
|
127
|
+
log.warn({ name, err: errMsg(err) }, 'agent-user: could not move a folder to the agent user');
|
|
128
|
+
});
|
|
121
129
|
});
|
|
122
130
|
}
|
|
123
131
|
return wanted;
|
package/runtime/runtime.json
CHANGED