Wire Temporal workflow execution via api.riotpiao.com
- Add SynthesisClient.execute_workflow() for POST /workflow
- Wired agent_handler to call START_WORKFLOW via gateway
- JWT token propagated to all workflow operations
- Store workflow_id/run_id in temporal_workflow_links table (migration 005)
- Document full Temporal integration flow
Temporal.io gRPC ← (gateway translates REST) ← POST /workflow api.riotpiao.com
↓
Agent handler receives workflow_id/run_id
↓
Store in temporal_workflow_links (external reference table)
↓
Query status via DESCRIBE_WORKFLOW action
Architecture: Temporal owns execution, Memory DB owns reasoning traces + links
Compilation: ✅
This commit is contained in:
@@ -249,6 +249,44 @@ impl SynthesisClient {
|
||||
self.execute_with_operation(req, Some("synthesis/infer"))
|
||||
.await
|
||||
}
|
||||
|
||||
/// Execute Temporal workflow via api.riotpiao.com/workflow
|
||||
/// Calls gateway which handles gRPC to Temporal service
|
||||
pub async fn execute_workflow(
|
||||
&self,
|
||||
workflow_request: serde_json::Value,
|
||||
) -> Result<serde_json::Value, String> {
|
||||
let client = reqwest::Client::new();
|
||||
let url = format!("{}/workflow", self.base_url);
|
||||
let start_time = std::time::Instant::now();
|
||||
|
||||
let response = client
|
||||
.post(&url)
|
||||
.header("Authorization", format!("Bearer {}", self.jwt_token))
|
||||
.header("Content-Type", "application/json")
|
||||
.json(&workflow_request)
|
||||
.timeout(std::time::Duration::from_secs(self.timeout_secs as u64))
|
||||
.send()
|
||||
.await
|
||||
.map_err(|e| format!("Workflow request failed: {}", e))?;
|
||||
|
||||
let elapsed_ms = start_time.elapsed().as_millis() as u32;
|
||||
|
||||
if response.status().is_success() {
|
||||
let body = response
|
||||
.json::<serde_json::Value>()
|
||||
.await
|
||||
.map_err(|e| format!("Failed to parse workflow response: {}", e))?;
|
||||
tracing::debug!("Workflow executed in {}ms", elapsed_ms);
|
||||
Ok(body)
|
||||
} else {
|
||||
let error_text = response
|
||||
.text()
|
||||
.await
|
||||
.unwrap_or_else(|_| "unknown error".to_string());
|
||||
Err(format!("Workflow failed ({}): {}", response.status(), error_text))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user