AS AgentScopeAPI 手册 / API Reference

AgentAccessGuard

@Service public class AgentAccessGuard
源码Source io/agentscope/builder/web/share/AgentAccessGuard.java:33–76

智能体访问守卫,承载智能体的部署、调度与服务化运行。位于 io.agentscope.builder.web.share 包。核心成员包括 require、load、AgentAccessGuard。

Convenience gate for controllers: resolve an agent by id (across globals, own, shared-in) and verify the caller holds at least the required tier. Keeps the findVisible + can pattern out of every controller while staying explicit at the call site (no AOP magic).

Visibility resolution is delegated to the plane-local AgentVisibilityResolver (catalog service in the control plane, a JPA read view in the data plane) so this guard stays usable from both planes without a cross-plane Maven dependency.

构造器摘要Constructor Summary

构造器Constructor说明Description
public AgentAccessGuard(AgentVisibilityResolver visibilityResolver, AgentAclService acl)
初始化 `AgentAccessGuard` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public AgentDefinition require(String userId, String agentId, Tier required)
执行 `require` 方法。
Resolves the agent and returns it iff `userId` holds at least `required`.
public AgentDefinition load(String userId, String agentId)
从持久化存储恢复数据。
Get the agent without enforcing a tier (404 if invisible).

构造器详情Constructor Detail

AgentAccessGuard

public AgentAccessGuard(AgentVisibilityResolver visibilityResolver, AgentAclService acl)

初始化 AgentAccessGuard 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
visibilityResolverAgentVisibilityResolvervisibility 解析器(类型 `AgentVisibilityResolver`)。The visibility resolver.
aclAgentAclServiceacl(类型 `AgentAclService`)。The acl.
源码Source io/agentscope/builder/web/share/AgentAccessGuard.java:39–42

方法详情Method Detail

require

public AgentDefinition require(String userId, String agentId, Tier required)

执行 require 方法。

Resolves the agent and returns it iff userId holds at least required.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
agentIdString智能体标识(类型 `String`)。The agent id.
requiredTier必填(类型 `Tier`)。The required.
返回Returns AgentDefinition
返回智能体定义。Returns agent definition.
抛出Throws
  • ResponseStatusException 可能抛出 `ResponseStatusException`。404 if the agent is invisible to the user, 403 if visible but below the required tier.
源码Source io/agentscope/builder/web/share/AgentAccessGuard.java:50–65

load

public AgentDefinition load(String userId, String agentId)

从持久化存储恢复数据。

Get the agent without enforcing a tier (404 if invisible).

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns AgentDefinition
返回智能体定义。Returns agent definition.
源码Source io/agentscope/builder/web/share/AgentAccessGuard.java:68–75
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.