@stage-labs/metro 0.1.0-beta.207 → 0.1.0-beta.209
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/approvals/pending.ts +7 -3
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/gates.ts +2 -1
- package/runtime/node_modules/@metro-labs/daemon/src/files/upload-store.ts +2 -2
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-dispatch.ts +1 -1
- package/runtime/runtime.json +1 -1
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.209",
|
|
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",
|
|
@@ -111,14 +111,18 @@ export function forgetPromptsOf(owner: object): void {
|
|
|
111
111
|
for (const [id, entry] of held) if (entry.owner === owner) held.delete(id);
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
export function
|
|
114
|
+
export function settlePrompts(toolMatches: (tool: string) => boolean, args: Record<string, unknown>): void {
|
|
115
115
|
for (const [id, entry] of held)
|
|
116
|
-
if (entry.tool
|
|
116
|
+
if (toolMatches(entry.tool) && previewMatches(entry.preview, args)) {
|
|
117
117
|
held.delete(id);
|
|
118
|
-
log.info({ requestId: id, tool: entry.tool }, 'approvals: the call
|
|
118
|
+
log.info({ requestId: id, tool: entry.tool }, 'approvals: the call reached metro, so Claude Code already closed the prompt');
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
export const settlePromptsFor = (name: string, args: Record<string, unknown>): void => {
|
|
123
|
+
settlePrompts((tool) => tool.endsWith(`__${name}`), args);
|
|
124
|
+
};
|
|
125
|
+
|
|
122
126
|
export async function expirePrompts(now = Date.now(), ttl = APPROVAL_TTL_MS): Promise<number> {
|
|
123
127
|
const overdue = [...held.values()].filter((entry) => now - entry.at >= ttl);
|
|
124
128
|
for (const entry of overdue)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ToolGroup } from '@metro-labs/core/stations/types';
|
|
2
2
|
import { policyFor, setPolicies, type PolicyTarget, type ToolPolicy } from '../policy/policy.js';
|
|
3
3
|
import { serverKeysOf } from './plugin-sync.js';
|
|
4
|
-
import { NEEDS_APPROVAL, takeGrant } from '../approvals/pending.js';
|
|
4
|
+
import { NEEDS_APPROVAL, settlePrompts, takeGrant } from '../approvals/pending.js';
|
|
5
5
|
|
|
6
6
|
interface GateRow {
|
|
7
7
|
id: string;
|
|
@@ -48,6 +48,7 @@ const promptFor = (connectorId: string, tool: string) => (asked: string): boolea
|
|
|
48
48
|
export function blockedReason(connectorId: string, tool: string, args: Record<string, unknown> = {}): string | null {
|
|
49
49
|
const gate = gates.find((g) => g.id === connectorId);
|
|
50
50
|
if (gate === undefined) return null;
|
|
51
|
+
settlePrompts(promptFor(connectorId, tool), args);
|
|
51
52
|
const access = policyFor({ kind: 'connector', id: connectorId }, { name: tool, group: toolGroupOf(gate, tool) });
|
|
52
53
|
if (access === 'deny') return `Blocked by the owner's policy for ${gate.name} (${tool}).`;
|
|
53
54
|
if (access === 'allow' || takeGrant(promptFor(connectorId, tool), args)) return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
2
|
import { readdirSync, rmSync, statSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { ensureSecureDir, readJson, writeSecure } from '@metro-labs/core/secure-fs';
|
|
6
6
|
import { grantAllowsPath, issueGrant } from './attach-grant.js';
|
|
@@ -16,7 +16,7 @@ const SUFFIXES = ['', '.part', '.meta', '.owner', '.grant'] as const;
|
|
|
16
16
|
const SWEEP_MS = 60_000;
|
|
17
17
|
|
|
18
18
|
export const uploadDir = (): string =>
|
|
19
|
-
process.env.METRO_UPLOAD_DIR ?? join(
|
|
19
|
+
process.env.METRO_UPLOAD_DIR ?? join(homedir(), '.metro', 'uploads');
|
|
20
20
|
|
|
21
21
|
export const newUploadId = (): string =>
|
|
22
22
|
`up_${randomBytes(16).toString('base64url')}`;
|
|
@@ -152,9 +152,9 @@ async function runTool(
|
|
|
152
152
|
if (name !== 'list_accounts' && scopeDenied(identity, name, a))
|
|
153
153
|
return errResult('metro: this account is outside your authorized scope');
|
|
154
154
|
|
|
155
|
+
settlePromptsFor(name, a);
|
|
155
156
|
const blocked = policyGate(name, a);
|
|
156
157
|
if (blocked) return blocked;
|
|
157
|
-
settlePromptsFor(name, a);
|
|
158
158
|
|
|
159
159
|
return dispatchTool(name, a, identity, hooks);
|
|
160
160
|
}
|
package/runtime/runtime.json
CHANGED