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

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.147",
3
+ "version": "0.1.0-beta.148",
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.147",
3
+ "version": "0.1.0-beta.148",
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",
@@ -53,8 +53,29 @@ async function waitOperation(base: string, token: string, first: Record<string,
53
53
  return op;
54
54
  }
55
55
 
56
+ const REASONS: Record<string, string> = {
57
+ DASHER_USER: 'this is a Google Workspace account; the individual tier needs a personal Google account',
58
+ NON_USER_ACCOUNT: 'this is not a user account',
59
+ RESTRICTED_AGE: 'the account does not meet the age requirement',
60
+ UNSUPPORTED_LOCATION: 'Gemini Code Assist for individuals is not offered where this account is located',
61
+ UNKNOWN_LOCATION: 'Google could not tell where this account is located',
62
+ RESTRICTED_NETWORK: 'the network this box is on is restricted',
63
+ INELIGIBLE_ACCOUNT: 'Google marks this account as not eligible',
64
+ };
65
+
66
+ function refuseIneligible(load: Record<string, unknown>): void {
67
+ if (isRecord(load.currentTier) || !Array.isArray(load.ineligibleTiers)) return;
68
+ const tiers = load.ineligibleTiers.filter(isRecord);
69
+ if (tiers.length === 0) return;
70
+ const validation = tiers.find((t) => t.reasonCode === 'VALIDATION_REQUIRED' && text(t.validationUrl) !== null);
71
+ if (validation !== undefined) throw new GeminiAuthError(`Google asks you to validate the account first: open ${text(validation.validationUrl) ?? ''} and then connect again`);
72
+ const said = tiers.map((t) => `${text(t.reasonMessage) ?? 'not eligible'} [${text(t.reasonCode) ?? 'UNKNOWN'}: ${REASONS[text(t.reasonCode) ?? ''] ?? 'no known reason'}]`);
73
+ throw new GeminiAuthError(said.join('; '));
74
+ }
75
+
56
76
  export async function onboard(tokens: GeminiTokens, base = CODE_ASSIST_BASE, fetchImpl: typeof fetch = fetch): Promise<Onboarded> {
57
77
  const load = await call(base, 'loadCodeAssist', tokens.accessToken, { metadata: METADATA }, fetchImpl);
78
+ refuseIneligible(load);
58
79
  const tier = tierOf(load);
59
80
  const known = text(load.cloudaicompanionProject);
60
81
  if (known !== null) return { project: known, tier: tier.name ?? tier.id };
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.1.0-beta.147"
2
+ "version": "0.1.0-beta.148"
3
3
  }