@@ -13,13 +13,12 @@ use crate::platform::api::types::{
1313 build_cloud_runner_config_v2,
1414} ;
1515use crate :: platform:: api:: { PlatformApiClient , PlatformApiError } ;
16+ use crate :: platform:: session:: PlatformSession ;
1617use std:: str:: FromStr ;
1718
1819/// Arguments for the create deployment config tool
1920#[ derive( Debug , Deserialize ) ]
2021pub struct CreateDeploymentConfigArgs {
21- /// The project UUID
22- pub project_id : String ,
2322 /// Service name for the deployment
2423 pub service_name : String ,
2524 /// Repository ID from GitHub integration
@@ -102,7 +101,6 @@ A deployment config defines how to build and deploy a service, including:
102101- Auto-deploy settings
103102
104103**Required Parameters:**
105- - project_id: The project UUID
106104- service_name: Name for the service (lowercase, hyphens allowed)
107105- repository_id: GitHub repository ID (from platform GitHub integration)
108106- repository_full_name: Full repo name like "owner/repo"
@@ -138,10 +136,6 @@ A deployment config defines how to build and deploy a service, including:
138136 parameters : json ! ( {
139137 "type" : "object" ,
140138 "properties" : {
141- "project_id" : {
142- "type" : "string" ,
143- "description" : "The UUID of the project"
144- } ,
145139 "service_name" : {
146140 "type" : "string" ,
147141 "description" : "Name for the service (lowercase, hyphens allowed)"
@@ -218,27 +212,38 @@ A deployment config defines how to build and deploy a service, including:
218212 }
219213 } ,
220214 "required" : [
221- "project_id" , " service_name", "repository_id" , "repository_full_name" ,
215+ "service_name" , "repository_id" , "repository_full_name" ,
222216 "port" , "branch" , "target_type" , "provider" , "environment_id"
223217 ]
224218 } ) ,
225219 }
226220 }
227221
228222 async fn call ( & self , args : Self :: Args ) -> Result < Self :: Output , Self :: Error > {
229- // Validate required fields
230- if args. project_id . trim ( ) . is_empty ( ) {
223+ // Load project_id from session (authoritative source — prevents stale IDs from LLM context)
224+ let session = match PlatformSession :: load ( ) {
225+ Ok ( s) => s,
226+ Err ( _) => {
227+ return Ok ( format_error_for_llm (
228+ "create_deployment_config" ,
229+ ErrorCategory :: InternalError ,
230+ "Failed to load platform session" ,
231+ Some ( vec ! [ "Try authenticating with `sync-ctl auth login`" ] ) ,
232+ ) ) ;
233+ }
234+ } ;
235+
236+ if !session. is_project_selected ( ) {
231237 return Ok ( format_error_for_llm (
232238 "create_deployment_config" ,
233239 ErrorCategory :: ValidationFailed ,
234- "project_id cannot be empty" ,
235- Some ( vec ! [
236- "Use list_projects to find valid project IDs" ,
237- "Use current_context to get the selected project" ,
238- ] ) ,
240+ "No project selected" ,
241+ Some ( vec ! [ "Use select_project to choose a project first" ] ) ,
239242 ) ) ;
240243 }
241244
245+ let project_id = session. project_id . clone ( ) . unwrap_or_default ( ) ;
246+
242247 if args. service_name . trim ( ) . is_empty ( ) {
243248 return Ok ( format_error_for_llm (
244249 "create_deployment_config" ,
@@ -316,7 +321,7 @@ A deployment config defines how to build and deploy a service, including:
316321 if let Some ( ref provider) = provider_enum {
317322 if matches ! ( provider, CloudProvider :: Gcp | CloudProvider :: Azure ) {
318323 if let Ok ( credential) = client
319- . check_provider_connection ( provider, & args . project_id )
324+ . check_provider_connection ( provider, & project_id)
320325 . await
321326 {
322327 if let Some ( cred) = credential {
@@ -351,7 +356,7 @@ A deployment config defines how to build and deploy a service, including:
351356 // Note: Send both field name variants (dockerfile/dockerfilePath, context/buildContext)
352357 // for backend compatibility - different endpoints may expect different field names
353358 let request = CreateDeploymentConfigRequest {
354- project_id : args . project_id . clone ( ) ,
359+ project_id,
355360 service_name : args. service_name . clone ( ) ,
356361 repository_id : args. repository_id ,
357362 repository_full_name : args. repository_full_name . clone ( ) ,
0 commit comments