@stage-labs/metro 0.1.0-beta.212 → 0.1.0-beta.214
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/claude.js +3 -2
- package/package.json +1 -1
- package/runtime/marketplace/plugin/.claude-plugin/plugin.json +1 -1
- package/runtime/node_modules/@metro-labs/daemon/src/agents/account-lookups.ts +1 -1
- package/runtime/node_modules/@metro-labs/xmtp/src/actions.ts +2 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/resolve.ts +44 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/sender.ts +1 -1
- package/runtime/node_modules/@metro-labs/xmtp/src/station.ts +1 -0
- package/runtime/runtime.json +1 -1
package/dist/claude.js
CHANGED
|
@@ -38,6 +38,7 @@ export function gatewayEnv(base, agentKey, port) {
|
|
|
38
38
|
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY: '1',
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
|
+
export const channelEnv = (env) => set(env, 'MCP_PROTOCOL_NEGOTIATION') ? env : { ...env, MCP_PROTOCOL_NEGOTIATION: 'legacy' };
|
|
41
42
|
const OWN_CREDENTIALS = ['ANTHROPIC_API_KEY', 'ANTHROPIC_AUTH_TOKEN'];
|
|
42
43
|
export function credentialEnv(env, agentKey, signedIn) {
|
|
43
44
|
if (signedIn || OWN_CREDENTIALS.some((name) => set(env, name)))
|
|
@@ -142,9 +143,9 @@ export async function launchClaude(extra) {
|
|
|
142
143
|
try {
|
|
143
144
|
if ('skip' in decision) {
|
|
144
145
|
process.stderr.write(`metro claude: ${decision.skip}\n`);
|
|
145
|
-
return await runClaude(claudeArgs(extra, mcp?.path, mode, prompt), process.env);
|
|
146
|
+
return await runClaude(claudeArgs(extra, mcp?.path, mode, prompt), channelEnv(process.env));
|
|
146
147
|
}
|
|
147
|
-
return await runClaude(claudeArgs(extra, mcp?.path, mode, prompt), gatewayLaunchEnv(decision.key, port));
|
|
148
|
+
return await runClaude(claudeArgs(extra, mcp?.path, mode, prompt), channelEnv(gatewayLaunchEnv(decision.key, port)));
|
|
148
149
|
}
|
|
149
150
|
finally {
|
|
150
151
|
mcp?.cleanup();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metro",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.214",
|
|
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",
|
|
@@ -26,7 +26,7 @@ async function handleResolve(req: IncomingMessage, res: ServerResponse, deps: Lo
|
|
|
26
26
|
if (stationByName(target.station)?.resolvesSenders !== true)
|
|
27
27
|
throw new ApiError(`metro cannot look a sender up on ${target.station}`, 400);
|
|
28
28
|
const query = lookupQuery(req);
|
|
29
|
-
if (query === '') throw new ApiError('
|
|
29
|
+
if (query === '') throw new ApiError('something to look up is required', 400);
|
|
30
30
|
sendJson(req, res, 200, await deps.resolveSender(target.station, target.accountId, query));
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -13,6 +13,7 @@ import { messagingAliases } from '@metro-labs/core/stations/messaging-normalize'
|
|
|
13
13
|
import { TrainError } from '@metro-labs/core/train-error';
|
|
14
14
|
import { claimNameAction, nameAction, setProfile } from './profile.js';
|
|
15
15
|
import { profileAction } from './sender.js';
|
|
16
|
+
import { resolveSenderAction } from './resolve.js';
|
|
16
17
|
import { makeStation, respond, type CallMsg } from '@metro-labs/core/stations/station-runtime';
|
|
17
18
|
|
|
18
19
|
type Args = Record<string, unknown>;
|
|
@@ -180,6 +181,7 @@ const handlers: Record<string, (id: string, args: Args) => Promise<void>> = {
|
|
|
180
181
|
claim_name: claimNameAction,
|
|
181
182
|
name: nameAction,
|
|
182
183
|
profile: profileAction,
|
|
184
|
+
resolve_sender: resolveSenderAction,
|
|
183
185
|
send,
|
|
184
186
|
ask,
|
|
185
187
|
react,
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { IdentifierKind } from '@xmtp/node-sdk';
|
|
2
|
+
import { namehash, type Hex } from 'viem';
|
|
3
|
+
import { normalize } from 'viem/ens';
|
|
4
|
+
import { respond } from '@metro-labs/core/stations/station-runtime';
|
|
5
|
+
import { TrainError } from '@metro-labs/core/train-error';
|
|
6
|
+
import { accountForCall } from './accounts.js';
|
|
7
|
+
import { BASENAME_L2_RESOLVER, BASENAME_REGISTRY, REGISTRY_ABI } from './profile.js';
|
|
8
|
+
import { readerFor, type Reader } from './sender.js';
|
|
9
|
+
|
|
10
|
+
const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
|
|
11
|
+
const INBOX_RE = /^[0-9a-f]{64}$/;
|
|
12
|
+
const NAME_RE = /^[a-z0-9-]+(\.[a-z0-9-]+)*\.eth$/i;
|
|
13
|
+
const ZERO = '0x0000000000000000000000000000000000000000';
|
|
14
|
+
const ADDR_ABI = [
|
|
15
|
+
{ name: 'addr', type: 'function', stateMutability: 'view', inputs: [{ name: 'node', type: 'bytes32' }], outputs: [{ name: '', type: 'address' }] },
|
|
16
|
+
] as const;
|
|
17
|
+
|
|
18
|
+
function refuse(query: string, why: string): never {
|
|
19
|
+
throw new TrainError('bad_request', `'${query}' ${why}`, { retryable: false });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function addressOfName(name: string, client: Reader): Promise<string> {
|
|
23
|
+
const node = namehash(normalize(name));
|
|
24
|
+
const found: Hex = await client.readContract({ address: BASENAME_REGISTRY, abi: REGISTRY_ABI, functionName: 'resolver', args: [node] });
|
|
25
|
+
const resolver = found === ZERO ? BASENAME_L2_RESOLVER : found;
|
|
26
|
+
const address = await client.readContract({ address: resolver, abi: ADDR_ABI, functionName: 'addr', args: [node] });
|
|
27
|
+
if (address === ZERO) refuse(name, 'points to no address');
|
|
28
|
+
return address;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function addressOf(query: string, client: Reader = readerFor()): Promise<string> {
|
|
32
|
+
if (INBOX_RE.test(query)) refuse(query, 'is already an inbox id, so add it directly instead of looking it up');
|
|
33
|
+
if (ADDRESS_RE.test(query)) return query.toLowerCase();
|
|
34
|
+
if (NAME_RE.test(query)) return (await addressOfName(query.toLowerCase(), client)).toLowerCase();
|
|
35
|
+
refuse(query, 'is not a wallet address (0x followed by 40 characters) or a name ending in .eth');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function resolveSenderAction(id: string, args: Record<string, unknown>): Promise<void> {
|
|
39
|
+
const query = typeof args.query === 'string' ? args.query.trim() : '';
|
|
40
|
+
const acct = accountForCall({ account: typeof args.account === 'string' ? args.account : undefined });
|
|
41
|
+
const address = await addressOf(query);
|
|
42
|
+
const inboxId = await acct.client.fetchInboxIdByIdentifier({ identifier: address, identifierKind: IdentifierKind.Ethereum });
|
|
43
|
+
respond(id, { result: { account: acct.cfg.id, query, address, exists: inboxId !== null, id: inboxId } });
|
|
44
|
+
}
|
|
@@ -39,7 +39,7 @@ const makeReader = (rpc: string) => createPublicClient({ chain: base, transport:
|
|
|
39
39
|
export type Reader = ReturnType<typeof makeReader>;
|
|
40
40
|
|
|
41
41
|
let reader: Reader | null = null;
|
|
42
|
-
const readerFor = (): Reader => (reader ??= makeReader(baseRpc()));
|
|
42
|
+
export const readerFor = (): Reader => (reader ??= makeReader(baseRpc()));
|
|
43
43
|
|
|
44
44
|
const trimmed = (v: string): string | null => (v.trim() === '' ? null : v.trim());
|
|
45
45
|
|
package/runtime/runtime.json
CHANGED