MCPcopy Create free account
hub / github.com/c4pt0r/pie / dynamic_trigger_response

Function dynamic_trigger_response

crates/coding-agent/tests/dynamic_trigger_e2e.rs:230–316  ·  view source on GitHub ↗
(context: &Context)

Source from the content-addressed store, hash-verified

228}
229
230fn 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") {

Callers 2

dynamic_trigger_streamFunction · 0.85

Calls 5

last_message_textFunction · 0.85
first_dynamic_rule_idFunction · 0.85
iterMethod · 0.80
assistant_textFunction · 0.70
assistant_tool_callFunction · 0.70

Tested by

no test coverage detected