用途:在调用 Lark API 前,依据任务描述自动判断应以 user 还是 bot 身份执行,并给出所需的最小权限范围;对于无法通过 API 完成的操作(如向外部租户发 DM)直接判为 blocked。
主要能力:内置三条判断规则——Rule 1:需要用户署名的操作(如 Calendar 写入、审批实例、审批任务审批)判为 user;Rule 2:向外部租户发送 DM 判为 blocked(error 230038);Rule 3:其余操作(IM 通知、Base 读取、Wiki 参照等)默认判为 bot。执行 larc auth router "<task description>" 后输出判定结果、适用规则、理由和最小 scope 集。
使用方式:先运行 larc auth router "<task>",再按结果执行——user 用 lark-cli --as user <command>,bot 用 lark-cli <command>(默认 bot),blocked 则不执行并向用户报告。scope 不足时用 larc auth login --scope "<router output 的 scopes>",或使用已有 profile,例如 larc auth login --profile writer、larc auth login --profile backoffice_agent。
适用场景:需要区分用户与机器人身份的 Lark 自动化流程,以及希望收敛权限范围、避免过度授权的操作。
限制:外部租户 DM 在 Lark API 层不可用(error 230038),可改为管理控制台访客邀请后以 open_id 直接指定,或使用 open_sharing=anyone_readable 的开放链接共享;判定基于任务描述文本,具体 scope 与 profile 内容以实际环境为准。相关实现位于 lib/auth.sh,另见 docs/permission-model.md 与 docs/known-issues/lark-external-user-api-gap.md。