agentCallableFunctions function

List<String> agentCallableFunctions(
  1. List<CatalogApi> catalogs
)

The functions of catalogs the agent may ask the renderer to run with callRendererFunction: those whose allowedCallers admits the agent, and which need no user activation, which a call from the agent never has.

Implementation

List<String> agentCallableFunctions(List<CatalogApi> catalogs) {
  final seen = <String>{};
  return [
    for (final CatalogApi catalog in catalogs)
      if ((catalog.protocolVersion ?? A2uiProtocolVersion.v0_9).isAtLeast(
        A2uiProtocolVersion.v1_0,
      ))
        for (final FunctionApi function in catalog.functions.values)
          if ((function.allowedCallers == AllowedCallers.agentOnly ||
                  function.allowedCallers == AllowedCallers.rendererOrAgent) &&
              !function.requiresUserActivation &&
              seen.add(function.name))
            function.name,
  ];
}