77use crate :: api:: runtime:: {
88 EventSanitizeFn , LlmConditionalFn , LlmExecutionFn , LlmRequestInterceptFn , LlmSanitizeRequestFn ,
99 LlmSanitizeResponseFn , LlmStreamExecutionFn , ToolConditionalFn , ToolExecutionFn ,
10- ToolInterceptFn , ToolSanitizeFn ,
10+ ToolExecutionFrameFn , ToolInterceptFn , ToolSanitizeFn ,
1111} ;
1212use crate :: api:: runtime:: { current_scope_stack, global_context} ;
1313use crate :: api:: shared:: ensure_runtime_owner;
@@ -203,12 +203,10 @@ macro_rules! global_intercept_registry_api {
203203 } ;
204204}
205205
206- macro_rules! global_execution_registry_api {
206+ macro_rules! global_execution_registry_register_api {
207207 (
208208 $( #[ $register_meta: meta] ) *
209209 $register_name: ident,
210- $( #[ $deregister_meta: meta] ) *
211- $deregister_name: ident,
212210 $field: ident,
213211 $fn_type: ty
214212 ) => {
@@ -233,10 +231,18 @@ macro_rules! global_execution_registry_api {
233231 . map_err( |error| FlowError :: Internal ( error. to_string( ) ) ) ?;
234232 state
235233 . $field
236- . register( ExecutionIntercept :: new( name, priority, callable) )
234+ . register( ExecutionIntercept :: new( name, priority, callable. into ( ) ) )
237235 . map_err( FlowError :: AlreadyExists )
238236 }
237+ } ;
238+ }
239239
240+ macro_rules! global_execution_registry_deregister_api {
241+ (
242+ $( #[ $deregister_meta: meta] ) *
243+ $deregister_name: ident,
244+ $field: ident
245+ ) => {
240246 $( #[ $deregister_meta] ) *
241247 ///
242248 /// # Parameters
@@ -259,6 +265,29 @@ macro_rules! global_execution_registry_api {
259265 } ;
260266}
261267
268+ macro_rules! global_execution_registry_api {
269+ (
270+ $( #[ $register_meta: meta] ) *
271+ $register_name: ident,
272+ $( #[ $deregister_meta: meta] ) *
273+ $deregister_name: ident,
274+ $field: ident,
275+ $fn_type: ty
276+ ) => {
277+ global_execution_registry_register_api!(
278+ $( #[ $register_meta] ) *
279+ $register_name,
280+ $field,
281+ $fn_type
282+ ) ;
283+ global_execution_registry_deregister_api!(
284+ $( #[ $deregister_meta] ) *
285+ $deregister_name,
286+ $field
287+ ) ;
288+ } ;
289+ }
290+
262291macro_rules! scope_guardrail_registry_api {
263292 (
264293 $( #[ $register_meta: meta] ) *
@@ -400,12 +429,10 @@ macro_rules! scope_intercept_registry_api {
400429 } ;
401430}
402431
403- macro_rules! scope_execution_registry_api {
432+ macro_rules! scope_execution_registry_register_api {
404433 (
405434 $( #[ $register_meta: meta] ) *
406435 $register_name: ident,
407- $( #[ $deregister_meta: meta] ) *
408- $deregister_name: ident,
409436 $field: ident,
410437 $fn_type: ty
411438 ) => {
@@ -438,10 +465,18 @@ macro_rules! scope_execution_registry_api {
438465 . ok_or_else( || FlowError :: NotFound ( format!( "scope {scope_uuid} not found" ) ) ) ?;
439466 registries
440467 . $field
441- . register( ExecutionIntercept :: new( name, priority, callable) )
468+ . register( ExecutionIntercept :: new( name, priority, callable. into ( ) ) )
442469 . map_err( FlowError :: AlreadyExists )
443470 }
471+ } ;
472+ }
444473
474+ macro_rules! scope_execution_registry_deregister_api {
475+ (
476+ $( #[ $deregister_meta: meta] ) *
477+ $deregister_name: ident,
478+ $field: ident
479+ ) => {
445480 $( #[ $deregister_meta] ) *
446481 ///
447482 /// # Parameters
@@ -467,6 +502,29 @@ macro_rules! scope_execution_registry_api {
467502 } ;
468503}
469504
505+ macro_rules! scope_execution_registry_api {
506+ (
507+ $( #[ $register_meta: meta] ) *
508+ $register_name: ident,
509+ $( #[ $deregister_meta: meta] ) *
510+ $deregister_name: ident,
511+ $field: ident,
512+ $fn_type: ty
513+ ) => {
514+ scope_execution_registry_register_api!(
515+ $( #[ $register_meta] ) *
516+ $register_name,
517+ $field,
518+ $fn_type
519+ ) ;
520+ scope_execution_registry_deregister_api!(
521+ $( #[ $deregister_meta] ) *
522+ $deregister_name,
523+ $field
524+ ) ;
525+ } ;
526+ }
527+
470528global_guardrail_registry_api ! (
471529 /// Register a global mark event sanitizer.
472530 register_mark_sanitize_guardrail,
@@ -535,14 +593,22 @@ global_intercept_registry_api!(
535593global_execution_registry_api ! (
536594 /// Register a global tool execution intercept.
537595 /// Execution intercepts can wrap or replace the tool callback. Each
538- /// callback returns a canonical tool execution outcome, while its
596+ /// callback returns Relay's tool execution outcome wrapper , while its
539597 /// continuation resolves to the raw downstream result JSON.
540598 register_tool_execution_intercept,
541599 /// Deregister a global tool execution intercept.
542600 deregister_tool_execution_intercept,
543601 tool_execution_intercepts,
544602 ToolExecutionFn
545603) ;
604+ global_execution_registry_register_api ! (
605+ /// Register a global annotation-aware tool execution intercept.
606+ /// Frame intercepts share the existing tool execution registry, namespace,
607+ /// and priority order with raw-JSON intercepts.
608+ register_tool_execution_frame_intercept,
609+ tool_execution_intercepts,
610+ ToolExecutionFrameFn
611+ ) ;
546612
547613global_guardrail_registry_api ! (
548614 /// Register a global LLM sanitize-request guardrail.
@@ -669,14 +735,22 @@ scope_intercept_registry_api!(
669735scope_execution_registry_api ! (
670736 /// Register a scope-local tool execution intercept.
671737 /// Execution intercepts can wrap or replace the tool callback inside the
672- /// owning scope. Each callback returns a canonical tool execution outcome,
738+ /// owning scope. Each callback returns Relay's tool execution outcome wrapper ,
673739 /// while its continuation resolves to the raw downstream result JSON.
674740 scope_register_tool_execution_intercept,
675741 /// Deregister a scope-local tool execution intercept.
676742 scope_deregister_tool_execution_intercept,
677743 tool_execution_intercepts,
678744 ToolExecutionFn
679745) ;
746+ scope_execution_registry_register_api ! (
747+ /// Register a scope-local annotation-aware tool execution intercept.
748+ /// Frame intercepts share the existing tool execution registry, namespace,
749+ /// and priority order with raw-JSON intercepts.
750+ scope_register_tool_execution_frame_intercept,
751+ tool_execution_intercepts,
752+ ToolExecutionFrameFn
753+ ) ;
680754
681755scope_guardrail_registry_api ! (
682756 /// Register a scope-local LLM sanitize-request guardrail.
0 commit comments