Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/env.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirExistsSync } from "./fsutils";

let googleIdxFolderExists: boolean | undefined;
export function isFirebaseStudio() {

Check warning on line 4 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing JSDoc comment

Check warning on line 4 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing return type on function
if (googleIdxFolderExists === true || process.env.MONOSPACE_ENV) return true;
if (googleIdxFolderExists === false) return false;
googleIdxFolderExists = dirExistsSync("/google/idx");
Expand All @@ -9,21 +9,27 @@
}

let isFirebaseMcpFlag = false;
export function isFirebaseMcp() {

Check warning on line 12 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing JSDoc comment

Check warning on line 12 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing return type on function
return isFirebaseMcpFlag;
return isFirebaseMcpFlag || process.env.IS_FIREBASE_MCP === "true";
}

export function setFirebaseMcp(value: boolean) {

Check warning on line 16 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing JSDoc comment

Check warning on line 16 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing return type on function
isFirebaseMcpFlag = value;
if (value) {
process.env.IS_FIREBASE_MCP = "true";
} else {
delete process.env.IS_FIREBASE_MCP;
}
}

// Detect if the CLI was invoked by a coding agent, based on well-known env vars.
// Standardized standard (AI_AGENT) is checked first to allow universal override.
// See: https://github.com/vercel/vercel/tree/main/packages/detect-agent
export function detectAIAgent(): string {

Check warning on line 28 in src/env.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing JSDoc comment
// 1. Standardized standard
if (process.env.AI_AGENT) {
return process.env.AI_AGENT.trim();
const aiAgent = process.env.AI_AGENT?.trim();
if (aiAgent) {
return aiAgent;
}

// 2. Specific agents (ordered as requested)
Expand Down
3 changes: 3 additions & 0 deletions src/mcp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
this.clientInfo = clientInfo;
if (clientInfo?.name) {
void this.trackGA4("mcp_client_connected");
if (!process.env.AI_AGENT?.trim()) {
process.env.AI_AGENT = clientInfo.name;
}
}
if (!this.clientInfo?.name) this.clientInfo = { name: "<unknown-client>" };

Expand All @@ -158,7 +161,7 @@
}

/** Wait until initialization has finished. */
ready() {

Check warning on line 164 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing return type on function
if (this._ready) return Promise.resolve();
return new Promise((resolve, reject) => {
this._readyPromises.push({ resolve: resolve as () => void, reject });
Expand All @@ -169,12 +172,12 @@
return this.clientInfo?.name ?? (isFirebaseStudio() ? "Firebase Studio" : "<unknown-client>");
}

private get clientConfigKey() {

Check warning on line 175 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing return type on function
return `mcp.clientConfigs.${this.clientName}:${this.startupRoot || process.cwd()}`;
}

getStoredClientConfig(): ClientConfig {
return configstore.get(this.clientConfigKey) || {};

Check warning on line 180 in src/mcp/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe return of an `any` typed value
}

updateStoredClientConfig(update: Partial<ClientConfig>) {
Expand Down
Loading