@@ -1329,6 +1329,7 @@ def fast_api_common_options():
13291329 """Decorator to add common fast api options to click commands."""
13301330
13311331 def decorator (func ):
1332+
13321333 @click .option (
13331334 "--host" ,
13341335 type = str ,
@@ -1433,6 +1434,17 @@ def decorator(func):
14331434 ),
14341435 default = None ,
14351436 )
1437+ # Parsed into list[str] by the wrapper below (server commands need a list).
1438+ @click .option (
1439+ "--trigger_sources" ,
1440+ type = str ,
1441+ help = (
1442+ "Optional. Comma-separated list of trigger sources to enable"
1443+ " (e.g., 'pubsub,eventarc'). Registers /apps/{app_name}/trigger/*"
1444+ " endpoints for batch and event-driven agent invocations."
1445+ ),
1446+ default = None ,
1447+ )
14361448 @functools .wraps (func )
14371449 @click .pass_context
14381450 def wrapper (ctx , * args , ** kwargs ):
@@ -1444,6 +1456,21 @@ def wrapper(ctx, *args, **kwargs):
14441456 ):
14451457 kwargs ["log_level" ] = "DEBUG"
14461458
1459+ # Parse comma-separated trigger_sources into a list and validate.
1460+ trigger_sources_raw = kwargs .get ("trigger_sources" )
1461+ if trigger_sources_raw is not None :
1462+ valid_sources = ["pubsub" , "eventarc" ]
1463+ parsed_sources = [
1464+ s .strip () for s in trigger_sources_raw .split ("," ) if s .strip ()
1465+ ]
1466+ invalid = [s for s in parsed_sources if s not in valid_sources ]
1467+ if invalid :
1468+ raise click .BadParameter (
1469+ f"Invalid trigger source(s): { ', ' .join (invalid )} . "
1470+ f"Valid sources are: { ', ' .join (valid_sources )} "
1471+ )
1472+ kwargs ["trigger_sources" ] = parsed_sources
1473+
14471474 return func (* args , ** kwargs )
14481475
14491476 return wrapper
@@ -1486,6 +1513,7 @@ def cli_web(
14861513 extra_plugins : Optional [list [str ]] = None ,
14871514 logo_text : Optional [str ] = None ,
14881515 logo_image_url : Optional [str ] = None ,
1516+ trigger_sources : Optional [list [str ]] = None ,
14891517):
14901518 """Starts a FastAPI server with Web UI for agents.
14911519
@@ -1542,6 +1570,7 @@ async def _lifespan(app: FastAPI):
15421570 extra_plugins = extra_plugins ,
15431571 logo_text = logo_text ,
15441572 logo_image_url = logo_image_url ,
1573+ trigger_sources = trigger_sources ,
15451574 )
15461575 config = uvicorn .Config (
15471576 app ,
@@ -1597,6 +1626,7 @@ def cli_api_server(
15971626 reload_agents : bool = False ,
15981627 extra_plugins : Optional [list [str ]] = None ,
15991628 auto_create_session : bool = False ,
1629+ trigger_sources : Optional [list [str ]] = None ,
16001630):
16011631 """Starts a FastAPI server for agents.
16021632
@@ -1630,6 +1660,7 @@ def cli_api_server(
16301660 reload_agents = reload_agents ,
16311661 extra_plugins = extra_plugins ,
16321662 auto_create_session = auto_create_session ,
1663+ trigger_sources = trigger_sources ,
16331664 ),
16341665 host = host ,
16351666 port = port ,
@@ -1763,6 +1794,17 @@ def cli_api_server(
17631794 default = False ,
17641795 help = "Optional. Whether to enable A2A endpoint." ,
17651796)
1797+ # Kept as raw str (not parsed to list) — interpolated directly into Dockerfile CMD.
1798+ @click .option (
1799+ "--trigger_sources" ,
1800+ type = str ,
1801+ help = (
1802+ "Optional. Comma-separated list of trigger sources to enable"
1803+ " (e.g., 'pubsub,eventarc'). Registers /trigger/* endpoints"
1804+ " for batch and event-driven agent invocations."
1805+ ),
1806+ default = None ,
1807+ )
17661808@click .option (
17671809 "--allow_origins" ,
17681810 help = (
@@ -1799,6 +1841,7 @@ def cli_deploy_cloud_run(
17991841 session_db_url : Optional [str ] = None , # Deprecated
18001842 artifact_storage_uri : Optional [str ] = None , # Deprecated
18011843 a2a : bool = False ,
1844+ trigger_sources : Optional [str ] = None ,
18021845):
18031846 """Deploys an agent to Cloud Run.
18041847
@@ -1876,6 +1919,7 @@ def cli_deploy_cloud_run(
18761919 memory_service_uri = memory_service_uri ,
18771920 use_local_storage = use_local_storage ,
18781921 a2a = a2a ,
1922+ trigger_sources = trigger_sources ,
18791923 extra_gcloud_args = tuple (gcloud_args ),
18801924 )
18811925 except Exception as e :
@@ -2272,6 +2316,17 @@ def cli_deploy_agent_engine(
22722316 " version in the dev environment)"
22732317 ),
22742318)
2319+ # Kept as raw str (not parsed to list) — interpolated directly into Dockerfile CMD.
2320+ @click .option (
2321+ "--trigger_sources" ,
2322+ type = str ,
2323+ help = (
2324+ "Optional. Comma-separated list of trigger sources to enable"
2325+ " (e.g., 'pubsub,eventarc'). Registers /trigger/* endpoints"
2326+ " for batch and event-driven agent invocations."
2327+ ),
2328+ default = None ,
2329+ )
22752330@adk_services_options (default_use_local_storage = False )
22762331@click .argument (
22772332 "agent" ,
@@ -2298,6 +2353,7 @@ def cli_deploy_gke(
22982353 artifact_service_uri : Optional [str ] = None ,
22992354 memory_service_uri : Optional [str ] = None ,
23002355 use_local_storage : bool = False ,
2356+ trigger_sources : Optional [str ] = None ,
23012357):
23022358 """Deploys an agent to GKE.
23032359
@@ -2329,6 +2385,7 @@ def cli_deploy_gke(
23292385 artifact_service_uri = artifact_service_uri ,
23302386 memory_service_uri = memory_service_uri ,
23312387 use_local_storage = use_local_storage ,
2388+ trigger_sources = trigger_sources ,
23322389 )
23332390 except Exception as e :
23342391 click .secho (f"Deploy failed: { e } " , fg = "red" , err = True )
0 commit comments