@stage-labs/metro 0.1.0-beta.44 → 0.1.0-beta.46
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/dist/api.js +5 -5
- package/dist/bedrock-proxy.js +1 -1
- package/dist/cli.js +6 -6
- package/dist/plugin.js +1 -1
- package/dist/prompt.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/serve.js +1 -1
- package/package.json +1 -1
- package/runtime/node_modules/@metro-labs/discord-bot/src/accounts.ts +0 -1
- package/runtime/node_modules/@metro-labs/mcp/package.json +1 -5
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/agent-import.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/attach-grant.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/attach-serve.ts +2 -5
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/boot.ts +5 -23
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/claude-files.ts +1 -3
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/cli-pair-api.ts +2 -4
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connect-hint.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-oauth.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-tools.ts +3 -5
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-verify.ts +1 -4
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/events.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/http.ts +1 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/identity.ts +4 -83
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/is-record.ts +2 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/local-cli-api.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/local-mode.ts +1 -37
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/oauth-client.ts +1 -4
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/oauth-discovery.ts +1 -4
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/paths.ts +0 -33
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/protocol.ts +3 -3
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/run-api.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/session-config.ts +1 -6
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/session.ts +1 -42
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/siwe-auth.ts +2 -11
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/siwe-routes.ts +2 -2
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/tunnel.ts +8 -90
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/upload-api.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/version.ts +1 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-connectors.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/db/connector-config.ts +1 -4
- package/runtime/node_modules/@metro-labs/mcp/src/db/connector-relay.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/db/file-admin.ts +6 -4
- package/runtime/node_modules/@metro-labs/mcp/src/db/file-source.ts +1 -3
- package/runtime/node_modules/@metro-labs/mcp/src/db/local-connectors.ts +11 -22
- package/runtime/node_modules/@metro-labs/mcp/src/db/materialize.ts +3 -13
- package/runtime/node_modules/@metro-labs/mcp/src/db/projects.ts +3 -3
- package/runtime/node_modules/@metro-labs/mcp/src/db/runtimes.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/db/schema.ts +2 -4
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/event-store.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/monitor/api.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/stations/account-store.ts +1 -21
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attach-resolve.ts +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/stations/lines.ts +1 -1
- package/runtime/node_modules/@metro-labs/telegram/package.json +0 -2
- package/runtime/node_modules/@metro-labs/telegram/src/accounts.ts +0 -1
- package/runtime/node_modules/@metro-labs/telegram-bot/src/accounts.ts +0 -1
- package/runtime/node_modules/@metro-labs/webhook/src/station.ts +2 -5
- package/runtime/node_modules/@metro-labs/whatsapp/src/accounts.ts +0 -1
- package/runtime/node_modules/@metro-labs/xmtp/src/accounts.ts +0 -1
- package/runtime/runtime.json +1 -1
- package/runtime/node_modules/@metro-labs/mcp/src/db/token-carry.ts +0 -45
|
@@ -23,9 +23,8 @@ export const users = pgTable('users', {
|
|
|
23
23
|
address: text('address').unique(),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
export const PROJECT_ROLES = ['admin', 'member'] as const;
|
|
27
26
|
|
|
28
|
-
export type ProjectRole =
|
|
27
|
+
export type ProjectRole = 'admin' | 'member';
|
|
29
28
|
|
|
30
29
|
export const projects = pgTable('projects', {
|
|
31
30
|
id: text('id').primaryKey(),
|
|
@@ -80,9 +79,8 @@ export const stations = pgTable('stations', {
|
|
|
80
79
|
config: jsonb('config').notNull(),
|
|
81
80
|
});
|
|
82
81
|
|
|
83
|
-
export const CONNECTOR_TRANSPORTS = ['http', 'sse'] as const;
|
|
84
82
|
|
|
85
|
-
export type ConnectorTransport =
|
|
83
|
+
export type ConnectorTransport = 'http' | 'sse';
|
|
86
84
|
|
|
87
85
|
export const connectors = pgTable(
|
|
88
86
|
'connectors',
|
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
import type { JSONRPCMessage } from '@modelcontextprotocol/sdk/types.js';
|
|
7
7
|
import { frameInScope, frameLine } from './frame-scope.js';
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
const EVENT_STORE_MAX = 500;
|
|
10
10
|
|
|
11
11
|
interface StoredEvent {
|
|
12
12
|
eventId: EventId;
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
authConfigFromEnv,
|
|
10
10
|
authenticate,
|
|
11
11
|
} from '../mcp/request-identity.js';
|
|
12
|
+
import { METRO_VERSION } from '../daemon/version.js';
|
|
12
13
|
|
|
13
14
|
export type MonitorCall = (
|
|
14
15
|
train: string,
|
|
@@ -18,7 +19,6 @@ export type MonitorCall = (
|
|
|
18
19
|
|
|
19
20
|
const KEEPALIVE_MS = 25_000;
|
|
20
21
|
const CALL_BODY_MAX = 256 * 1024;
|
|
21
|
-
const METRO_VERSION = process.env.npm_package_version ?? '0.1.0-beta.15';
|
|
22
22
|
|
|
23
23
|
function monitorEnabled(): boolean {
|
|
24
24
|
return hasAnyKey() || authConfigFromEnv().sessionSecret !== '';
|
|
@@ -7,7 +7,6 @@ export type Die = (msg: string) => never;
|
|
|
7
7
|
export interface MakeLoaderOpts<T> {
|
|
8
8
|
prefix: string;
|
|
9
9
|
file: string;
|
|
10
|
-
allowlistEnv: string[];
|
|
11
10
|
validate: (raw: T[], die: Die) => void;
|
|
12
11
|
}
|
|
13
12
|
|
|
@@ -24,17 +23,6 @@ export function makeAccountStore<T extends { id: string }>(
|
|
|
24
23
|
process.exit(2);
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
let allowlistRaw: string | undefined;
|
|
28
|
-
for (const k of opts.allowlistEnv) {
|
|
29
|
-
allowlistRaw ??= process.env[k];
|
|
30
|
-
}
|
|
31
|
-
const allowlist = new Set(
|
|
32
|
-
(allowlistRaw ?? '')
|
|
33
|
-
.split(',')
|
|
34
|
-
.map((s) => s.trim())
|
|
35
|
-
.filter(Boolean),
|
|
36
|
-
);
|
|
37
|
-
|
|
38
26
|
function loadAccounts(): T[] {
|
|
39
27
|
if (!existsSync(opts.file))
|
|
40
28
|
return die(
|
|
@@ -50,15 +38,7 @@ export function makeAccountStore<T extends { id: string }>(
|
|
|
50
38
|
if (!Array.isArray(raw) || raw.length === 0)
|
|
51
39
|
die(`${opts.file} must be a non-empty array`);
|
|
52
40
|
opts.validate(raw, die);
|
|
53
|
-
|
|
54
|
-
? raw.filter((a) => allowlist.has(a.id))
|
|
55
|
-
: raw;
|
|
56
|
-
if (selected.length === 0) {
|
|
57
|
-
die(
|
|
58
|
-
`no accounts match ${opts.allowlistEnv[0]} (${[...allowlist].join(', ')})`,
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
return selected;
|
|
41
|
+
return raw;
|
|
62
42
|
}
|
|
63
43
|
|
|
64
44
|
return { die, loadAccounts };
|
|
@@ -151,7 +151,7 @@ const sourcesOf = (a: CanonicalAttachment): string[] =>
|
|
|
151
151
|
return typeof v === 'string' && v.length > 0;
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
async function resolveAttachment(
|
|
155
155
|
a: CanonicalAttachment,
|
|
156
156
|
budget: InlineBudget = { used: 0 },
|
|
157
157
|
opts: ResolveOptions = {},
|
|
@@ -5,7 +5,7 @@ const PREFIX = 'metro://';
|
|
|
5
5
|
const build = (station: string, ...seg: (string | number)[]): Line =>
|
|
6
6
|
asLine(`${PREFIX}${station}/${seg.map(String).join('/')}`);
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function parseAccountScoped(
|
|
9
9
|
line: Line | string,
|
|
10
10
|
station: string,
|
|
11
11
|
validate?: (resource: string) => boolean,
|
|
@@ -29,7 +29,6 @@ function validateAccount(a: UserAccount, seen: Set<string>, die: Die): void {
|
|
|
29
29
|
export const { loadAccounts } = makeAccountStore<UserAccount>({
|
|
30
30
|
prefix: 'telegram',
|
|
31
31
|
file: ACCOUNTS_FILE,
|
|
32
|
-
allowlistEnv: ['TELEGRAM_ONLY_ACCOUNTS', 'TELEGRAM_ACCOUNTS'],
|
|
33
32
|
validate(raw, die) {
|
|
34
33
|
const seen = new Set<string>();
|
|
35
34
|
for (const a of raw) validateAccount(a, seen, die);
|
|
@@ -19,7 +19,6 @@ export interface AccountConfig {
|
|
|
19
19
|
export const { loadAccounts } = makeAccountStore<AccountConfig>({
|
|
20
20
|
prefix: 'telegram-bot',
|
|
21
21
|
file: ACCOUNTS_FILE,
|
|
22
|
-
allowlistEnv: ['TELEGRAM_BOT_ONLY_ACCOUNTS', 'TELEGRAM_BOT_ACCOUNTS'],
|
|
23
22
|
validate(raw, die) {
|
|
24
23
|
const seenId = new Set<string>();
|
|
25
24
|
const seenTok = new Set<string>();
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { Line
|
|
2
|
+
import { Line } from '@metro-labs/mcp/lines';
|
|
3
3
|
import { mintId, type MetroEvent } from '@metro-labs/mcp/events';
|
|
4
4
|
import type { Endpoint } from '@metro-labs/mcp/endpoints';
|
|
5
5
|
import type { Station, Verb } from '@metro-labs/mcp/stations/types';
|
|
6
6
|
|
|
7
|
-
const sessionOwner = (sessionId: string): Line =>
|
|
8
|
-
asLine(`metro://session/${sessionId}`);
|
|
9
|
-
|
|
10
7
|
export const webhookStation: Station = {
|
|
11
8
|
name: 'webhook',
|
|
12
9
|
hasAccounts: true,
|
|
@@ -31,7 +28,7 @@ export function webhookEntry(
|
|
|
31
28
|
line,
|
|
32
29
|
lineName: endpoint.label,
|
|
33
30
|
from: line,
|
|
34
|
-
to:
|
|
31
|
+
to: line,
|
|
35
32
|
messageId:
|
|
36
33
|
headers['x-github-delivery'] ?? headers['x-request-id'] ?? randomUUID(),
|
|
37
34
|
text: `${headers['x-github-event'] ?? headers['x-intercom-topic'] ?? 'event'} ${method} ${url}`,
|
|
@@ -28,7 +28,6 @@ function validateAccount(
|
|
|
28
28
|
export const { loadAccounts } = makeAccountStore<WhatsAppAccount>({
|
|
29
29
|
prefix: 'whatsapp',
|
|
30
30
|
file: ACCOUNTS_FILE,
|
|
31
|
-
allowlistEnv: ['WHATSAPP_ONLY_ACCOUNTS', 'WHATSAPP_ACCOUNTS'],
|
|
32
31
|
validate(raw, die) {
|
|
33
32
|
const seen = new Set<string>();
|
|
34
33
|
for (const a of raw) validateAccount(a, seen, die);
|
|
@@ -28,7 +28,6 @@ export interface AccountConfig {
|
|
|
28
28
|
export const { loadAccounts } = makeAccountStore<AccountConfig>({
|
|
29
29
|
prefix: 'xmtp',
|
|
30
30
|
file: ACCOUNTS_FILE,
|
|
31
|
-
allowlistEnv: ['XMTP_ONLY_ACCOUNTS', 'XMTP_ACCOUNTS'],
|
|
32
31
|
validate(raw, die) {
|
|
33
32
|
const seen = new Set<string>();
|
|
34
33
|
for (const a of raw) {
|
package/runtime/runtime.json
CHANGED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { tokenStorePath } from '@metro-labs/whatsapp/tokens';
|
|
3
|
-
import { errMsg, log } from '../daemon/log.js';
|
|
4
|
-
import { writeSecure } from '../daemon/secure-fs.js';
|
|
5
|
-
|
|
6
|
-
export const PREVIOUS_ACCOUNT_ID = 'previousAccountId';
|
|
7
|
-
|
|
8
|
-
export interface CarriedStation {
|
|
9
|
-
station: string;
|
|
10
|
-
id: string;
|
|
11
|
-
config: Record<string, unknown>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function previousAccountId(
|
|
15
|
-
config: Record<string, unknown>,
|
|
16
|
-
): string | undefined {
|
|
17
|
-
const raw = config[PREVIOUS_ACCOUNT_ID];
|
|
18
|
-
return typeof raw === 'string' && raw !== '' ? raw : undefined;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function carryTokenStores(list: CarriedStation[]): number {
|
|
22
|
-
let carried = 0;
|
|
23
|
-
for (const s of list) {
|
|
24
|
-
if (s.station !== 'whatsapp') continue;
|
|
25
|
-
const previous = previousAccountId(s.config);
|
|
26
|
-
if (previous === undefined || previous === s.id) continue;
|
|
27
|
-
const from = tokenStorePath(previous);
|
|
28
|
-
const to = tokenStorePath(s.id);
|
|
29
|
-
if (!existsSync(from) || existsSync(to)) continue;
|
|
30
|
-
try {
|
|
31
|
-
writeSecure(to, readFileSync(from, 'utf8'));
|
|
32
|
-
carried += 1;
|
|
33
|
-
log.info(
|
|
34
|
-
{ from: previous, to: s.id },
|
|
35
|
-
'db: carried the whatsapp token store to the station id',
|
|
36
|
-
);
|
|
37
|
-
} catch (err) {
|
|
38
|
-
log.error(
|
|
39
|
-
{ from: previous, to: s.id, err: errMsg(err) },
|
|
40
|
-
'db: could not carry the whatsapp token store',
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return carried;
|
|
45
|
-
}
|