AS AgentScopeAPI 手册 / API Reference
类class agentscope.app.access

ResourceAccessPolicyBase

class ResourceAccessPolicyBase(ABC)
源码Source agentscope/app/access/_policy.py:79–150

资源访问策略基类,把智能体接入外部消息渠道与企业平台。位于 agentscope.app.access 包,继承自 ABC。核心成员包括 list_accessible、can_edit。

Applications subclass this policy to read access rules from configuration, external IAM systems, LDAP, request-scoped context, or any other source.

The policy intentionally does not manage users, groups, memberships, or resource-share records in AgentScope storage. It only maps a viewer_id to resource references.

方法摘要Method Summary

方法Method说明Description
async def list_accessible(viewer_id: str, kind: ResourceKind, storage: StorageBase) -> list[ResourceRef]asyncabstractabstractmethod
列出 `list_accessible`。
List cross-owner resources of ``kind`` accessible by ``viewer_id``.
async def can_edit(viewer_id: str, kind: ResourceKind, owner_id: str, resource_id: str, storage: StorageBase) -> boolasync
判断是否可以 `can_edit`。
Return whether ``viewer_id`` may mutate the given resource.

方法详情Method Detail

list_accessible

async def list_accessible(viewer_id: str, kind: ResourceKind, storage: StorageBase) -> list[ResourceRef]
asyncabstractabstractmethod

列出 list_accessible。

The returned refs should not include resources owned by viewer_id.

参数Parameters
名称Name类型Type说明Description
viewer_idstrviewer 标识(类型 `str`)。The current viewer's user id.
kindResourceKind资源种类到列出。The resource kind to list.
storageStorageBase存储(类型 `StorageBase`)。The owner-scoped storage backend. Policy subclasses may use it for read-only lookups.
返回Returns list[ResourceRef]
返回ResourceRef列表。`list[ResourceRef]`: The accessible cross-owner resource
源码Source agentscope/app/access/_policy.py:91–112

can_edit

async def can_edit(viewer_id: str, kind: ResourceKind, owner_id: str, resource_id: str, storage: StorageBase) -> bool
async

判断是否可以 can_edit。

Owners can always edit their own resources.

参数Parameters
名称Name类型Type说明Description
viewer_idstrviewer 标识(类型 `str`)。The current viewer's user id.
kindResourceKind资源种类。The resource kind.
owner_idstr资源所有者's 用户标识。The resource owner's user id.
resource_idstr资源标识(类型 `str`)。The resource id under `owner_id`.
storageStorageBase存储(类型 `StorageBase`)。The owner-scoped storage backend.
返回Returns bool
返回布尔值,表示判断结果。`bool`: `True` when mutation is allowed, otherwise `False`.
源码Source agentscope/app/access/_policy.py:114–150
基于官方固定版本源码静态生成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.