@stage-labs/metro 0.1.0-beta.138 → 0.1.0-beta.139
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 +1 -1
- package/runtime/marketplace/plugin/.claude-plugin/plugin.json +1 -1
- package/runtime/node_modules/@metro-labs/daemon/src/routes/local-mode.ts +2 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/session-apis.ts +3 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/owner.ts +48 -0
- package/runtime/runtime.json +1 -1
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.139",
|
|
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.139",
|
|
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",
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from '../connectors/store.js';
|
|
32
32
|
import {
|
|
33
33
|
assertLocalOwner,
|
|
34
|
+
setLocalOwner,
|
|
34
35
|
LOCAL_PROJECT_ID,
|
|
35
36
|
localAttachAccount,
|
|
36
37
|
localDeleteAgent,
|
|
@@ -213,6 +214,7 @@ export function localSessionApis(deps: LocalModeDeps): SessionApis {
|
|
|
213
214
|
claudeApi: { authorize: (subject) => { assertLocalOwner(subject); } },
|
|
214
215
|
updateApi: { authorize: (subject) => { assertLocalOwner(subject); }, restart: deps.restart },
|
|
215
216
|
controlApi: { authorize: (subject) => { assertLocalOwner(subject); }, restart: deps.restart, stop: deps.stop },
|
|
217
|
+
ownerApi: { authorize: (subject) => { assertLocalOwner(subject); }, setOwner: (owner) => setLocalOwner(owner) },
|
|
216
218
|
machineApi: { authorize: (subject) => { assertLocalOwner(subject); } },
|
|
217
219
|
modelApi: { authorize: (subject) => { assertLocalOwner(subject); } },
|
|
218
220
|
gateway: { config: readModelConfig },
|
|
@@ -12,6 +12,7 @@ import type { ModeInfo } from '@metro-labs/http/mode-api';
|
|
|
12
12
|
import { handleBundleRequest, type BundleApiDeps } from '../agents/bundle.js';
|
|
13
13
|
import { handleUpdateRequest, type UpdateApiDeps } from '../server/update.js';
|
|
14
14
|
import { handleControlRequest, type ControlApiDeps } from '../server/control.js';
|
|
15
|
+
import { handleOwnerRequest, type OwnerApiDeps } from '../server/owner.js';
|
|
15
16
|
import { handleMachineRequest, type MachineApiDeps } from '../server/machine.js';
|
|
16
17
|
import { handleModelRequest, type ModelApiDeps } from '../gateway/model-api.js';
|
|
17
18
|
import type { GatewayDeps } from '../gateway/gateway.js';
|
|
@@ -22,6 +23,7 @@ export interface SessionApis {
|
|
|
22
23
|
bundleApi?: BundleApiDeps;
|
|
23
24
|
updateApi?: UpdateApiDeps;
|
|
24
25
|
controlApi?: ControlApiDeps;
|
|
26
|
+
ownerApi?: OwnerApiDeps;
|
|
25
27
|
machineApi?: MachineApiDeps;
|
|
26
28
|
modelApi?: ModelApiDeps;
|
|
27
29
|
gateway?: GatewayDeps;
|
|
@@ -48,6 +50,7 @@ export function handleSessionApis(
|
|
|
48
50
|
...when(apis.bundleApi, (d) => handleBundleRequest(req, res, d)),
|
|
49
51
|
...when(apis.updateApi, (d) => handleUpdateRequest(req, res, d)),
|
|
50
52
|
...when(apis.controlApi, (d) => handleControlRequest(req, res, d)),
|
|
53
|
+
...when(apis.ownerApi, (d) => handleOwnerRequest(req, res, d)),
|
|
51
54
|
...when(apis.machineApi, (d) => handleMachineRequest(req, res, d)),
|
|
52
55
|
...when(apis.modelApi, (d) => handleModelRequest(req, res, d)),
|
|
53
56
|
...when(apis.terminalApi, (d) => handleTerminalRequest(req, res, d)),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import { ApiError } from '@metro-labs/http/api-error';
|
|
3
|
+
import { apiFailure, apiSession, cors, readJsonBody, requireAdmin, sendJson } from '@metro-labs/http/api-http';
|
|
4
|
+
import { isOrganizationId } from '@metro-labs/http/workos-token';
|
|
5
|
+
import { isRecord } from '@metro-labs/core/is-record';
|
|
6
|
+
import { log } from '@metro-labs/core/log';
|
|
7
|
+
|
|
8
|
+
const PATH = '/api/owner';
|
|
9
|
+
|
|
10
|
+
export interface OwnerApiDeps {
|
|
11
|
+
authorize: (subject: string) => void;
|
|
12
|
+
setOwner: (owner: string) => string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function move(req: IncomingMessage, deps: OwnerApiDeps): Promise<{ owner: string }> {
|
|
16
|
+
const session = await apiSession(req);
|
|
17
|
+
if (!session) throw new ApiError('unauthorized', 401);
|
|
18
|
+
deps.authorize(session.subject);
|
|
19
|
+
requireAdmin(session);
|
|
20
|
+
const body = await readJsonBody(req);
|
|
21
|
+
const owner = isRecord(body) && typeof body.owner === 'string' ? body.owner.trim() : '';
|
|
22
|
+
if (!isOrganizationId(owner)) throw new ApiError('owner must be an organization id', 400);
|
|
23
|
+
if (owner === session.subject) throw new ApiError('this machine already belongs to that organization', 409);
|
|
24
|
+
const saved = deps.setOwner(owner);
|
|
25
|
+
log.info({ from: session.subject, to: saved }, 'owner: this machine moved to another organization');
|
|
26
|
+
return { owner: saved };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function handleOwnerRequest(req: IncomingMessage, res: ServerResponse, deps: OwnerApiDeps): boolean {
|
|
30
|
+
const path = (req.url ?? '').split('?')[0] ?? '';
|
|
31
|
+
if (path !== PATH) return false;
|
|
32
|
+
if (req.method === 'OPTIONS') {
|
|
33
|
+
res.writeHead(204, cors(req)).end();
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (req.method !== 'POST') {
|
|
37
|
+
sendJson(req, res, 405, { error: 'method not allowed' });
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
move(req, deps)
|
|
41
|
+
.then((body) => {
|
|
42
|
+
sendJson(req, res, 200, body);
|
|
43
|
+
})
|
|
44
|
+
.catch((err: unknown) => {
|
|
45
|
+
apiFailure(req, res, err, 'owner-api');
|
|
46
|
+
});
|
|
47
|
+
return true;
|
|
48
|
+
}
|
package/runtime/runtime.json
CHANGED