@stage-labs/metro 0.1.0-beta.140 → 0.1.0-beta.141

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.140",
3
+ "version": "0.1.0-beta.141",
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.140",
3
+ "version": "0.1.0-beta.141",
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",
@@ -1,5 +1,7 @@
1
1
  import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import { hostname } from 'node:os';
2
+ import { hostname, homedir } from 'node:os';
3
+ import { statfs } from 'node:fs/promises';
4
+ import { errMsg, log } from '@metro-labs/core/log';
3
5
  import { ApiError } from '@metro-labs/http/api-error';
4
6
  import { apiFailure, apiSession, cors, sendJson } from '@metro-labs/http/api-http';
5
7
  import { publicBaseUrl } from '../files/attach-serve.js';
@@ -18,9 +20,26 @@ export interface MachineApiDeps {
18
20
 
19
21
  const bootedAt = new Date(Date.now() - process.uptime() * 1000).toISOString();
20
22
 
21
- export function machineInfo(startedAt = bootedAt): Record<string, unknown> {
23
+ export interface Disk {
24
+ path: string;
25
+ totalBytes: number;
26
+ freeBytes: number;
27
+ }
28
+
29
+ export async function diskInfo(path = homedir()): Promise<Disk | null> {
30
+ try {
31
+ const s = await statfs(path);
32
+ return { path, totalBytes: s.bsize * s.blocks, freeBytes: s.bsize * s.bavail };
33
+ } catch (err) {
34
+ log.warn({ err: errMsg(err), path }, 'machine: could not read the disk');
35
+ return null;
36
+ }
37
+ }
38
+
39
+ export async function machineInfo(startedAt = bootedAt): Promise<Record<string, unknown>> {
22
40
  const store = process.env.METRO_RUNTIME_STORE?.trim() ?? '';
23
41
  return {
42
+ disk: await diskInfo(),
24
43
  version: METRO_VERSION,
25
44
  owner: localOwner(),
26
45
  hostname: hostname(),
@@ -49,10 +68,10 @@ export function handleMachineRequest(req: IncomingMessage, res: ServerResponse,
49
68
  return true;
50
69
  }
51
70
  apiSession(req)
52
- .then((session) => {
71
+ .then(async (session) => {
53
72
  if (!session) throw new ApiError('unauthorized', 401);
54
73
  deps.authorize(session.subject);
55
- sendJson(req, res, 200, machineInfo(deps.startedAt));
74
+ sendJson(req, res, 200, await machineInfo(deps.startedAt));
56
75
  })
57
76
  .catch((err: unknown) => {
58
77
  apiFailure(req, res, err, 'machine-api');
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.140"
2
+ "version": "0.1.0-beta.141"
3
3
  }