@stage-labs/metro 0.1.0-beta.148 → 0.1.0-beta.149

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.148",
3
+ "version": "0.1.0-beta.149",
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.148",
3
+ "version": "0.1.0-beta.149",
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",
@@ -1,4 +1,5 @@
1
1
  import { isRecord } from '@metro-labs/core/is-record';
2
+ import { log } from '@metro-labs/core/log';
2
3
  import { GeminiAuthError, type GeminiTokens } from './gemini-auth.js';
3
4
 
4
5
  export const CODE_ASSIST_BASE = 'https://cloudcode-pa.googleapis.com';
@@ -73,16 +74,35 @@ function refuseIneligible(load: Record<string, unknown>): void {
73
74
  throw new GeminiAuthError(said.join('; '));
74
75
  }
75
76
 
77
+ const MANAGED =
78
+ 'Google treats this account as a managed (Workspace) one: it has a Code Assist tier but no project of its own, and the individual tier is for personal Google accounts (gmail.com). Sign in with the personal account that holds your Google AI plan';
79
+
80
+ function tierToOnboard(load: Record<string, unknown>): { id: string; name: string | null } {
81
+ const allowed = Array.isArray(load.allowedTiers) ? load.allowedTiers.filter(isRecord) : [];
82
+ const chosen = allowed.find((t) => t.isDefault === true);
83
+ return { id: text(chosen?.id) ?? FREE_TIER, name: text(chosen?.name) };
84
+ }
85
+
86
+ const summary = (load: Record<string, unknown>): Record<string, unknown> => ({
87
+ current: isRecord(load.currentTier) ? text(load.currentTier.id) : null,
88
+ paid: isRecord(load.paidTier) ? text(load.paidTier.id) : null,
89
+ allowed: Array.isArray(load.allowedTiers) ? load.allowedTiers.filter(isRecord).map((t) => `${text(t.id) ?? '?'}${t.isDefault === true ? '*' : ''}`) : [],
90
+ ineligible: Array.isArray(load.ineligibleTiers) ? load.ineligibleTiers.filter(isRecord).map((t) => `${text(t.tierId) ?? '?'}:${text(t.reasonCode) ?? '?'}`) : [],
91
+ project: text(load.cloudaicompanionProject),
92
+ });
93
+
76
94
  export async function onboard(tokens: GeminiTokens, base = CODE_ASSIST_BASE, fetchImpl: typeof fetch = fetch): Promise<Onboarded> {
77
95
  const load = await call(base, 'loadCodeAssist', tokens.accessToken, { metadata: METADATA }, fetchImpl);
96
+ log.info(summary(load), 'gemini: Code Assist answered loadCodeAssist');
78
97
  refuseIneligible(load);
79
98
  const tier = tierOf(load);
80
99
  const known = text(load.cloudaicompanionProject);
81
100
  if (known !== null) return { project: known, tier: tier.name ?? tier.id };
82
- const tierId = tier.id ?? FREE_TIER;
83
- const op = await waitOperation(base, tokens.accessToken, await call(base, 'onboardUser', tokens.accessToken, { tierId, metadata: METADATA }, fetchImpl), fetchImpl);
101
+ if (isRecord(load.currentTier)) throw new GeminiAuthError(MANAGED);
102
+ const wanted = tierToOnboard(load);
103
+ const op = await waitOperation(base, tokens.accessToken, await call(base, 'onboardUser', tokens.accessToken, { tierId: wanted.id, metadata: METADATA }, fetchImpl), fetchImpl);
84
104
  const response = isRecord(op.response) ? op.response : {};
85
105
  const project = isRecord(response.cloudaicompanionProject) ? text(response.cloudaicompanionProject.id) : null;
86
106
  if (project === null) throw new GeminiAuthError('Google did not assign a Code Assist project to this account; sign in to https://geminicli.com once with the Gemini CLI, then try again');
87
- return { project, tier: tier.name ?? tierId };
107
+ return { project, tier: wanted.name ?? wanted.id };
88
108
  }
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.148"
2
+ "version": "0.1.0-beta.149"
3
3
  }