diff --git a/src/router.rs b/src/router.rs index 660c906..df6532e 100644 --- a/src/router.rs +++ b/src/router.rs @@ -151,9 +151,22 @@ async fn deliver_one( // Build supervisor method and params from Message let method = msg.message.clone(); let params = build_params(&msg)?; - + // Send - let out_id = client.call(&method, params).await?; + // If this is a job.run and we have a secret configured on the client, + // prefer the typed wrapper that injects the secret into inner supervisor params. + let out_id = if method == "job.run" { + if let Some(j) = msg.job.first() { + let jv = job_to_json(j)?; + // This uses SupervisorClient::job_run, which sets {"secret": "...", "job": } + client.job_run(jv).await? + } else { + // Fallback: no embedded job, use the generic call + client.call(&method, params).await? + } + } else { + client.call(&method, params).await? + }; // Store transport id and initial Sent status let _ = service