Skip to content

feat: add firebase ailogic:providers CLI commands#10778

Open
marb2000 wants to merge 4 commits into
firebase:mainfrom
marb2000:feat/ailogic-providers
Open

feat: add firebase ailogic:providers CLI commands#10778
marb2000 wants to merge 4 commits into
firebase:mainfrom
marb2000:feat/ailogic-providers

Conversation

@marb2000

@marb2000 marb2000 commented Jul 8, 2026

Copy link
Copy Markdown
Member

Description

Adds the firebase ailogic:providers:* command group to manage the Gemini API providers for Firebase AI Logic from the CLI, so developers and CI pipelines can enable, disable, and inspect providers without using the Firebase Console.

  • ailogic:providers:enable <providerType> — enables the Firebase AI Logic API (firebasevertexai.googleapis.com) if needed, then the selected provider's underlying API. gemini-developer-api enables generativelanguage.googleapis.com; agent-platform-gemini-api requires the Blaze (pay-as-you-go) plan and enables aiplatform.googleapis.com.
  • ailogic:providers:disable <providerType> — prompts for confirmation (skippable with --force) and turns off the proxy when no providers remain enabled.
  • ailogic:providers:list — reports which providers are enabled.

Supporting changes:

  • A shared interactive enablement flow (ensureAILogicApiEnabled) used when the API isn't yet enabled, which checks the serviceusage.services.enable permission up front so callers get a clear error before any prompts.
  • firebase help <namespace> now lists the subcommands under a prefix (e.g. firebase help ailogic:providers) for discoverability.
  • ensureApiEnabled.uncacheEnabledAPI to keep the local API-enablement cache consistent after enabling/disabling an API.

All commands live under the fixed global location (no --location flag), support --json output, and reject client-breaking actions in --non-interactive mode unless --force is passed. Permissions map to the firebasevertexai and serviceusage IAM permissions.

This is the first of a series of scoped PRs bringing Firebase AI Logic management (providers, configuration, prompt templates, triggers) to the CLI.

Scenarios Tested

  • providers:enable gemini-developer-api on a project with the API disabled — enables the AI Logic API and generativelanguage.googleapis.com.
  • providers:enable agent-platform-gemini-api on a Blaze project succeeds; on a Spark project it fails with an upgrade link and does not change the plan.
  • providers:disable — confirmation prompt shown; --force and --non-interactive paths covered; proxy is disabled only when no providers remain.
  • providers:list — reflects enablement state with and without billing.
  • Interactive enablement flow — re-prompts on a Spark billing failure; fails up front when the caller lacks serviceusage.services.enable.
  • firebase help ailogic:providers — lists the namespace subcommands.
  • Unit tests added in src/gcp/ailogic.spec.ts, src/gcp/serviceusage.spec.ts, and src/commands/help.spec.ts. npm test (lint + compile + mocha) passes.

Sample Commands

firebase ailogic:providers:enable gemini-developer-api
firebase ailogic:providers:list
firebase ailogic:providers:list --json
firebase ailogic:providers:disable gemini-developer-api --force
firebase help ailogic:providers

@wiz-9635d3485b

wiz-9635d3485b Bot commented Jul 8, 2026

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Low
Software Management Finding Software Management Findings -
Total 1 Low

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the firebase ailogic:providers:* CLI commands (enable, disable, and list) to manage Gemini API providers, along with updates to the help command to list namespace subcommands. Feedback on these changes suggests removing the ensureAILogicApiEnabled check from the disable and list commands to prevent unnecessary enablement prompts, and removing a redundant billing check in listProviders that could cause permission issues. Additionally, the reviewer recommends simplifying the associated unit tests and replacing an any cast in help.spec.ts with a type-safe alternative to adhere to the repository's style guide.

Comment thread src/commands/ailogic-providers-disable.ts Outdated
Comment thread src/commands/ailogic-providers-list.ts Outdated
Comment thread src/gcp/ailogic.ts
Comment thread src/gcp/ailogic.spec.ts Outdated
Comment thread src/commands/help.spec.ts Outdated
Add `firebase ailogic:providers:{enable,disable,list}` to manage the
Gemini API providers (Gemini Developer API and Agent Platform Gemini API)
for Firebase AI Logic from the CLI.

- providers:enable enables the Firebase AI Logic API and the selected
  provider's underlying API; agent-platform-gemini-api requires the Blaze
  (pay-as-you-go) plan.
- providers:disable prompts for confirmation (--force to skip) and turns
  off the proxy when no providers remain enabled.
- providers:list reports which providers are enabled.
- Adds a shared interactive enablement flow (used when the API is not yet
  enabled) that checks enable permission up front before prompting.
- Adds `firebase help <namespace>` listing of subcommands under a prefix
  so ailogic commands are discoverable.

Requires the firebasevertexai and serviceusage IAM permissions; commands
support --json and --non-interactive.
@marb2000 marb2000 force-pushed the feat/ailogic-providers branch from 2efdcd1 to 79fbcdc Compare July 8, 2026 16:42
@marb2000

marb2000 commented Jul 8, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review! Addressed all the feedback:

  • providers:disable / providers:list: removed the ensureAILogicApiEnabled call so these commands no longer force or prompt for API enablement — list now just reports providers as disabled and disable is a no-op prompt-free path when the API is already off.
  • listProviders billing check: removed. Since aiplatform.googleapis.com can't be enabled without billing, an enabled Vertex API already implies the agent-platform provider is available; this also avoids failures for callers without billing-viewer permission.
  • Unit tests: consolidated the two listProviders list tests into one now that billing state is irrelevant.
  • help.spec.ts any cast: replaced. Note the exact suggested cast doesn't compile (TS2352) because actionFn is a private member of Command and the types don't structurally overlap, so I used as unknown as { actionFn: ... } with a fully-specified target type — no any.

@marb2000 marb2000 force-pushed the feat/ailogic-providers branch from abc2d66 to 6621514 Compare July 8, 2026 22:52
@codecov-commenter

codecov-commenter commented Jul 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 55.83333% with 53 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@edc599e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/gcp/ailogic.ts 48.61% 33 Missing and 4 partials ⚠️
src/commands/help.ts 59.25% 6 Missing and 5 partials ⚠️
src/ensureApiEnabled.ts 20.00% 4 Missing ⚠️
src/gcp/serviceusage.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10778   +/-   ##
=======================================
  Coverage        ?   58.09%           
=======================================
  Files           ?      615           
  Lines           ?    40074           
  Branches        ?     8113           
=======================================
  Hits            ?    23280           
  Misses          ?    14861           
  Partials        ?     1933           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants