SuperAPI AI Directory

lark-router

Coding & development

View repository

Updated 10-16 09:28

About this skill

lark-router — Lark Auth Router skill

3-rule quick reference

Rule Condition Decision Typical example
Rule 1 Operations that must be performed as User user Calendar write / approval instance / approval task approval
Rule 2 External tenant DM blocked error 230038 — DM to an external user
Rule 3 Everything else bot IM notification / Base read / Wiki reference

Execution flow

Step 1: Run the router

larc auth router "<task description>"

Example output:

Auth decision: BOT
Rule applied:  Rule 3 — Bot default
Reason:        IM notification does not require user attribution
Minimum scopes: im:message:send_as_bot

Step 2: Run lark-cli based on the decision

Decision lark-cli flag
user lark-cli --as user <command>
bot lark-cli <command>(default is bot)
blocked Do not run → report to the user

Step 3: If blocked

外部テナントへのDMはLark API で不可 (error 230038)。
対応策:
  A) 管理コンソールでゲスト招待 → open_id で直接指定
  B) オープンリンク共有 (open_sharing=anyone_readable)
参照: docs/known-issues/lark-external-user-api-gap.md

Scope authorization

# ルーター実行後、スコープが不足している場合
larc auth login --scope "<router output の scopes>"

# または既存プロファイルを使用
larc auth login --profile writer        # 一般書き込み操作
larc auth login --profile backoffice_agent  # 全スコープ

Minimal scope set quick reference

Operation Scope
Bot IM read im:message:readonly
Bot IM send im:message:send_as_bot
User IM send im:message
Base write bitable:app
Wiki write wiki:node:create
Calendar write calendar:calendar
Approval instance creation approval:instance:write
Approval task approve/reject approval:task:write

Test cases (regression)

larc auth router "send IM notification to team"    # → BOT
larc auth router "create calendar event"            # → USER
larc auth router "send DM to external user"         # → BLOCKED
larc auth router "submit expense approval"          # → USER
larc auth router "read wiki page"                   # → BOT

Related

  • Implementation: lib/auth.sh — _auth_router() (GitHub Issue #32)
  • Design doc: docs/permission-model.md
  • Known constraints: docs/known-issues/lark-external-user-api-gap.md
  • Meegle Story: #23312641