(context: &Context)
| 228 | } |
| 229 | |
| 230 | fn dynamic_trigger_response(context: &Context) -> AssistantMessage { |
| 231 | let last_text = last_message_text(context); |
| 232 | let transcript_text = context |
| 233 | .messages |
| 234 | .iter() |
| 235 | .map(message_text) |
| 236 | .collect::<Vec<_>>() |
| 237 | .join("\n"); |
| 238 | let has_tool_result = context |
| 239 | .messages |
| 240 | .iter() |
| 241 | .any(|m| matches!(m, Message::ToolResult(_))); |
| 242 | if has_tool_result && transcript_text.contains("hello from home e2e") { |
| 243 | let id = first_dynamic_rule_id(&transcript_text).unwrap_or("dyn-missing"); |
| 244 | assistant_text(&format!("matched {id}: hello from home e2e")) |
| 245 | } else if has_tool_result { |
| 246 | let id = first_dynamic_rule_id(&transcript_text).unwrap_or("dyn-missing"); |
| 247 | assistant_text(&format!("matched {id}: done")) |
| 248 | } else if !last_text.contains("Dynamic trigger rules") && last_text.contains("helloworld") { |
| 249 | assistant_tool_call( |
| 250 | "call-new-trigger-home", |
| 251 | "NewTrigger", |
| 252 | serde_json::json!({ |
| 253 | "condition": "$HOME contains a file named helloworld", |
| 254 | "action": "print the contents of $HOME/helloworld", |
| 255 | "spec": last_text, |
| 256 | }), |
| 257 | ) |
| 258 | } else if last_text.contains("visible to future turns") { |
| 259 | assistant_tool_call( |
| 260 | "call-new-trigger-promote", |
| 261 | "NewTrigger", |
| 262 | serde_json::json!({ |
| 263 | "condition": "the event says build finished", |
| 264 | "action": "echo dynamic-fired", |
| 265 | "promote_to_chat": true |
| 266 | }), |
| 267 | ) |
| 268 | } else if last_text.contains("每小时") || last_text.to_lowercase().contains("hourly scheduled") |
| 269 | { |
| 270 | assistant_tool_call( |
| 271 | "call-new-cron-job", |
| 272 | "NewCronJob", |
| 273 | serde_json::json!({ |
| 274 | "schedule": "hourly", |
| 275 | "action": "Check the Hacker News front page for notable stories" |
| 276 | }), |
| 277 | ) |
| 278 | } else if last_text.contains("Create a trigger") { |
| 279 | assistant_tool_call( |
| 280 | "call-new-trigger", |
| 281 | "NewTrigger", |
| 282 | serde_json::json!({ |
| 283 | "condition": "the event says build finished", |
| 284 | "action": "echo dynamic-fired" |
| 285 | }), |
| 286 | ) |
| 287 | } else if last_text.contains("Dynamic trigger rules") && last_text.contains("helloworld") { |
no test coverage detected