@stage-labs/metro 0.1.0-beta.253 → 0.1.0-beta.254

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.253",
3
+ "version": "0.1.0-beta.254",
4
4
  "description": "The metro command line: run your agent on this machine, relaying its chat channels and connectors to Claude Code.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "metro",
3
- "version": "0.1.0-beta.253",
3
+ "version": "0.1.0-beta.254",
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",
@@ -38,16 +38,26 @@ export function requestKind(req: IncomingMessage, body: Body): RequestKind {
38
38
  return chore(body) ? 'other' : 'main';
39
39
  }
40
40
 
41
+ const messagesOf = (body: Body): unknown[] => (Array.isArray(body.messages) ? body.messages : []);
42
+
43
+ const askedEfforts = (body: Body): string[] => [body, ...messagesOf(body).map(record)].map(effortOf).filter((effort) => effort !== '');
44
+
41
45
  export function plannedEffort(req: IncomingMessage, body: Body): string | null {
42
- const current = effortOf(body);
43
- if (current === '') return null;
46
+ const asked = askedEfforts(body);
47
+ if (asked.length === 0) return null;
44
48
  const kind = requestKind(req, body);
45
49
  if (kind === 'other') return null;
46
50
  const wanted = kind === 'subagent' ? SUBAGENT_EFFORT : MAIN_EFFORT;
47
- return wanted === current ? null : wanted;
51
+ return asked.every((effort) => effort === wanted) ? null : wanted;
48
52
  }
49
53
 
50
- export const withEffort = (body: Body, effort: string): Body => ({ ...body, output_config: { ...record(body.output_config), effort } });
54
+ const withOwnEffort = (item: Body, effort: string): Body => (effortOf(item) === '' ? item : { ...item, output_config: { ...record(item.output_config), effort } });
55
+
56
+ export function withEffort(body: Body, effort: string): Body {
57
+ const top = withOwnEffort(body, effort);
58
+ if (!Array.isArray(body.messages)) return top;
59
+ return { ...top, messages: body.messages.map((message: unknown) => (isRecord(message) ? withOwnEffort(message, effort) : message)) };
60
+ }
51
61
 
52
62
  export function withoutEffort(body: Body): Body {
53
63
  const config = Object.fromEntries(Object.entries(record(body.output_config)).filter(([key]) => key !== 'effort'));
@@ -6,6 +6,10 @@ export function allowedWebHost(host: string): boolean {
6
6
  return PREVIEW.test(host);
7
7
  }
8
8
 
9
+ export const APP_RETURN = 'metro://auth';
10
+
11
+ export const isAppReturn = (returnTo: string): boolean => returnTo === APP_RETURN;
12
+
9
13
  export function validateReturnTo(returnTo: string): boolean {
10
14
  let url: URL;
11
15
  try {
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.253"
2
+ "version": "0.1.0-beta.254"
3
3
  }