@amaster.ai/pi-lark 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/skills/lark-approval/references/lark-approval-initiate.md +2 -5
- package/skills/lark-approval/references/lark-approval-instances-initiated.md +6 -0
- package/skills/lark-approval/references/lark-approval-tasks-query.md +9 -0
- package/skills/lark-approval/references/lark-approval-tasks-rollback.md +8 -2
- package/skills/lark-apps/SKILL.md +25 -7
- package/skills/lark-apps/references/lark-apps-access-scope-set.md +1 -1
- package/skills/lark-apps/references/lark-apps-automation.md +164 -0
- package/skills/lark-apps/references/lark-apps-db-execute.md +186 -2
- package/skills/lark-apps/references/lark-apps-db.md +3 -3
- package/skills/lark-apps/references/lark-apps-get.md +43 -0
- package/skills/lark-apps/references/lark-apps-html-publish.md +7 -2
- package/skills/lark-apps/references/lark-apps-init.md +1 -2
- package/skills/lark-apps/references/lark-apps-openapi-key.md +1 -1
- package/skills/lark-apps/references/lark-apps-release-create.md +3 -1
- package/skills/lark-apps/references/lark-apps-role.md +133 -0
- package/skills/lark-base/SKILL.md +7 -3
- package/skills/lark-base/references/dashboard-block-data-config.md +28 -2
- package/skills/lark-base/references/lark-base-cell-value.md +9 -4
- package/skills/lark-base/references/lark-base-dashboard-block-get-data.md +7 -7
- package/skills/lark-base/references/lark-base-dashboard.md +11 -2
- package/skills/lark-base/references/lark-base-data-query.md +9 -7
- package/skills/lark-base/references/lark-base-field-create.md +4 -2
- package/skills/lark-base/references/lark-base-field-json.md +52 -15
- package/skills/lark-base/references/lark-base-field-update.md +4 -2
- package/skills/lark-base/references/lark-base-view-set-filter.md +3 -1
- package/skills/lark-calendar/SKILL.md +89 -31
- package/skills/lark-calendar/references/lark-calendar-create.md +8 -39
- package/skills/lark-calendar/references/lark-calendar-room-find.md +5 -9
- package/skills/lark-calendar/references/lark-calendar-rsvp.md +1 -5
- package/skills/lark-calendar/references/lark-calendar-schedule-clear-time.md +59 -0
- package/skills/lark-calendar/references/lark-calendar-schedule-fuzzy-time.md +88 -0
- package/skills/lark-calendar/references/lark-calendar-schedule-meeting.md +67 -210
- package/skills/lark-calendar/references/lark-calendar-suggestion.md +1 -5
- package/skills/lark-calendar/references/lark-calendar-update.md +2 -7
- package/skills/lark-doc/SKILL.md +1 -1
- package/skills/lark-doc/references/lark-doc-fetch.md +4 -2
- package/skills/lark-doc/references/lark-doc-mindnote.md +17 -2
- package/skills/lark-doc/references/lark-doc-whiteboard.md +4 -0
- package/skills/lark-doc/references/lark-doc-xml-extended-blocks.md +35 -0
- package/skills/lark-doc/references/lark-doc-xml.md +3 -2
- package/skills/lark-drive/SKILL.md +20 -8
- package/skills/lark-drive/references/lark-drive-comment-location.md +16 -4
- package/skills/lark-drive/references/lark-drive-comments-guide.md +16 -8
- package/skills/lark-drive/references/lark-drive-delete.md +35 -11
- package/skills/lark-drive/references/lark-drive-export.md +39 -10
- package/skills/lark-drive/references/lark-drive-files-list.md +27 -2
- package/skills/lark-drive/references/lark-drive-inspect.md +2 -0
- package/skills/lark-drive/references/lark-drive-list-comments.md +125 -0
- package/skills/lark-drive/references/lark-drive-member-add.md +1 -1
- package/skills/lark-drive/references/lark-drive-move.md +5 -3
- package/skills/lark-drive/references/lark-drive-permission-guide.md +12 -0
- package/skills/lark-drive/references/lark-drive-pull.md +3 -3
- package/skills/lark-drive/references/lark-drive-push.md +33 -6
- package/skills/lark-drive/references/lark-drive-status.md +12 -14
- package/skills/lark-drive/references/lark-drive-task-result.md +58 -5
- package/skills/lark-drive/references/lark-drive-workflow-knowledge-organize.md +26 -20
- package/skills/lark-drive/references/lark-drive-workflow.md +2 -1
- package/skills/lark-event/SKILL.md +2 -1
- package/skills/lark-event/references/lark-event-approval.md +170 -0
- package/skills/lark-im/SKILL.md +5 -4
- package/skills/lark-im/references/lark-im-messages-reply.md +1 -1
- package/skills/lark-im/references/lark-im-messages-send.md +1 -1
- package/skills/lark-mail/SKILL.md +12 -9
- package/skills/lark-mail/references/lark-mail-forward.md +1 -1
- package/skills/lark-mail/references/lark-mail-message-modify.md +48 -0
- package/skills/lark-mail/references/lark-mail-message-trash.md +41 -0
- package/skills/lark-mail/references/lark-mail-reply-all.md +1 -1
- package/skills/lark-mail/references/lark-mail-reply.md +1 -1
- package/skills/lark-mail/references/lark-mail-watch.md +1 -1
- package/skills/lark-markdown/SKILL.md +3 -2
- package/skills/lark-markdown/references/lark-markdown-create.md +22 -2
- package/skills/lark-minutes/SKILL.md +19 -4
- package/skills/lark-minutes/references/lark-minutes-download.md +0 -2
- package/skills/lark-minutes/references/lark-minutes-search.md +0 -2
- package/skills/lark-minutes/references/lark-minutes-speaker-replace.md +0 -2
- package/skills/lark-minutes/references/lark-minutes-summary.md +0 -2
- package/skills/lark-minutes/references/lark-minutes-todo.md +2 -4
- package/skills/lark-minutes/references/lark-minutes-update.md +0 -2
- package/skills/lark-minutes/references/lark-minutes-upload.md +10 -10
- package/skills/lark-shared/SKILL.md +26 -8
- package/skills/lark-sheets/SKILL.md +98 -29
- package/skills/lark-sheets/references/lark-sheets-batch-update.md +18 -9
- package/skills/lark-sheets/references/lark-sheets-changeset.md +105 -0
- package/skills/lark-sheets/references/lark-sheets-chart.md +4 -2
- package/skills/lark-sheets/references/lark-sheets-conditional-format.md +2 -0
- package/skills/lark-sheets/references/lark-sheets-filter-view.md +1 -1
- package/skills/lark-sheets/references/lark-sheets-float-image.md +6 -6
- package/skills/lark-sheets/references/lark-sheets-formula-translation.md +12 -3
- package/skills/lark-sheets/references/lark-sheets-formula-verify.md +77 -0
- package/skills/lark-sheets/references/lark-sheets-history.md +93 -0
- package/skills/lark-sheets/references/lark-sheets-pivot-table.md +7 -2
- package/skills/lark-sheets/references/lark-sheets-range-operations.md +44 -14
- package/skills/lark-sheets/references/lark-sheets-read-data.md +3 -3
- package/skills/lark-sheets/references/lark-sheets-sheet-structure.md +4 -4
- package/skills/lark-sheets/references/lark-sheets-visual-standards.md +4 -4
- package/skills/lark-sheets/references/lark-sheets-workbook.md +29 -4
- package/skills/lark-sheets/references/lark-sheets-write-cells.md +21 -11
- package/skills/lark-slides/SKILL.md +29 -18
- package/skills/lark-slides/references/asset-planning.md +16 -5
- package/skills/lark-slides/references/examples.md +57 -227
- package/skills/lark-slides/references/iconpark.md +2 -2
- package/skills/lark-slides/references/lark-slides-create.md +21 -2
- package/skills/lark-slides/references/lark-slides-media-upload.md +0 -1
- package/skills/lark-slides/references/lark-slides-pptx-template-workflows.md +89 -0
- package/skills/lark-slides/references/lark-slides-replace-pages.md +1 -1
- package/skills/lark-slides/references/lark-slides-replace-slide.md +1 -1
- package/skills/lark-slides/references/lark-slides-screenshot.md +11 -8
- package/skills/lark-slides/references/lark-slides-whiteboard.md +31 -30
- package/skills/lark-slides/references/lark-slides-xml-get.md +100 -0
- package/skills/lark-slides/references/lark-slides-xml-presentation-slide-delete.md +9 -7
- package/skills/lark-slides/references/lark-slides-xml-presentation-slide-get.md +4 -4
- package/skills/lark-slides/references/lark-slides-xml-presentation-slide-replace.md +12 -10
- package/skills/lark-slides/references/lark-slides-xml-presentations-get.md +14 -13
- package/skills/lark-slides/references/planning-layer.md +32 -2
- package/skills/lark-slides/references/slides_chart_demo.xml +1 -0
- package/skills/lark-slides/references/slides_xml_schema_definition.xml +8 -3
- package/skills/lark-slides/references/troubleshooting.md +7 -25
- package/skills/lark-slides/references/validation-checklist.md +18 -9
- package/skills/lark-slides/references/visual-planning.md +4 -3
- package/skills/lark-slides/references/xml-format-guide.md +65 -1
- package/skills/lark-slides/references/xml-schema-quick-ref.md +7 -3
- package/skills/lark-slides/scripts/xml_text_overlap_lint.py +907 -54
- package/skills/lark-slides/scripts/xml_text_overlap_lint_test.py +876 -5
- package/skills/lark-task/SKILL.md +1 -0
- package/skills/lark-task/references/lark-task-create.md +14 -1
- package/skills/lark-vc/SKILL.md +6 -3
- package/skills/lark-vc/references/lark-vc-recording.md +0 -2
- package/skills/lark-vc/references/vc-domain-boundaries.md +9 -1
- package/skills/lark-vc-agent/SKILL.md +25 -15
- package/skills/lark-vc-agent/references/lark-vc-agent-meeting-events.md +65 -37
- package/skills/lark-vc-agent/references/lark-vc-agent-meeting-leave.md +1 -1
- package/skills/lark-vc-agent/references/lark-vc-agent-meeting-list-active.md +8 -8
- package/skills/lark-whiteboard/references/lark-whiteboard-workflow.md +5 -2
- package/skills/lark-wiki/SKILL.md +7 -3
- package/skills/lark-wiki/references/lark-wiki-move-to-drive.md +122 -0
- package/skills/lark-wiki/references/lark-wiki-move.md +5 -3
- package/skills/lark-wiki/references/lark-wiki-node-get.md +1 -1
- package/skills/lark-wiki/references/lark-wiki-node-list.md +9 -2
- package/skills/lark-calendar/references/lark-calendar-agenda.md +0 -78
- package/skills/lark-calendar/references/lark-calendar-freebusy.md +0 -124
- package/skills/lark-calendar/references/lark-calendar-search-event.md +0 -29
- package/skills/lark-sheets/references/lark-sheets-core-operations.md +0 -103
- package/skills/lark-slides/references/lark-slides-xml-presentation-slide-create.md +0 -220
|
@@ -5,15 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
将文件或文件夹移动到用户云空间(云盘/云存储)的其他位置。
|
|
7
7
|
|
|
8
|
-
## 与
|
|
8
|
+
## 与 Wiki 移动 shortcut 的区别
|
|
9
9
|
|
|
10
10
|
- `drive +move` 只处理 **Drive 文件夹树内部** 的位置调整,目标位置用 `--folder-token` 表示
|
|
11
11
|
- `wiki +move` 处理的是 **Wiki 知识空间 / 页面层级**:要么移动已有 Wiki 节点,要么把 Drive 文档迁入 Wiki
|
|
12
|
-
-
|
|
12
|
+
- `wiki +move-to-drive` 把 **已有 Wiki 节点移出知识库**,放到 Drive 文件夹或“我的空间”根目录
|
|
13
|
+
- 如果用户说“移动到某个文件夹”“移动到我的空间根目录”,还要判断源对象:源对象已在 Drive 时使用 `drive +move`;源对象是 Wiki 节点时使用 `wiki +move-to-drive`
|
|
13
14
|
- 如果用户说“移动到某个知识库 / 页面下”“迁入 Wiki / 知识空间”,应使用 `wiki +move`
|
|
14
15
|
- 如果用户说“移动到我的文档库 / 我的知识库 / 个人知识库 / my_library”,不要使用 `drive +move`;先按 Wiki 目标处理
|
|
15
16
|
- `我的文档库` 不是 Drive root folder,也不是 `--folder-token` 省略后的默认目的地
|
|
16
|
-
- `drive +move` 不支持 wiki
|
|
17
|
+
- `drive +move` 不支持 Wiki 文档;Wiki 节点到 Drive 应使用 `wiki +move-to-drive`,目标是 Wiki 时使用 `wiki +move`
|
|
17
18
|
|
|
18
19
|
## 不要误用到 `我的文档库`
|
|
19
20
|
|
|
@@ -117,4 +118,5 @@ lark-cli drive +task_result \
|
|
|
117
118
|
## 参考
|
|
118
119
|
|
|
119
120
|
- [lark-drive](../SKILL.md) -- 云空间(云盘/云存储)全部命令
|
|
121
|
+
- [wiki +move-to-drive](../../lark-wiki/references/lark-wiki-move-to-drive.md) -- 将 Wiki 节点移出知识库并放入 Drive
|
|
120
122
|
- [lark-shared](../../lark-shared/SKILL.md) -- 认证和全局参数
|
|
@@ -10,6 +10,18 @@
|
|
|
10
10
|
|
|
11
11
|
如果用户只是想向文档 owner 申请访问权限,优先使用 [`lark-drive-apply-permission.md`](lark-drive-apply-permission.md)。
|
|
12
12
|
|
|
13
|
+
## 公开权限修改前门槛
|
|
14
|
+
|
|
15
|
+
公开权限修改是高风险写操作。执行 `drive permission.public patch --yes` 前同时确认:
|
|
16
|
+
|
|
17
|
+
| 条件 | 可执行信号 |
|
|
18
|
+
|------|------------|
|
|
19
|
+
| 具体目标 | 单个 URL/token,或用户确认过的资源列表 |
|
|
20
|
+
| 公开范围 | 用户明确选择组织内/互联网、可读/可编辑等具体 `link_share_entity` 档位 |
|
|
21
|
+
| 执行确认 | 用户在本轮确认按该目标和范围执行 |
|
|
22
|
+
|
|
23
|
+
“开放一下”“共享给大家”“让大家能看”只表达目标状态,不包含具体公开范围。先列出可选范围并停止等待用户选择;公开档位必须来自用户选择,CLI 的 `--yes` 只表示已获得用户对该档位的执行确认。
|
|
24
|
+
|
|
13
25
|
## 公开权限错误码
|
|
14
26
|
|
|
15
27
|
调用 `lark-cli drive permission.public patch` 更新文档公开权限失败时,如果返回以下错误码,按表格给用户明确下一步。不要把这些错误简单归类为缺少 scope;它们通常表示租户、对外分享或文档密级策略拦截。
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
| `summary.deleted_local` | 启用 `--delete-local --yes` 时删除的本地文件数 |
|
|
18
18
|
| `items[]` | 每个文件的明细(`rel_path` / `file_token` / `source_id` / `action` / 失败时的 `error`) |
|
|
19
19
|
|
|
20
|
-
`summary.failed > 0` 时命令以 **非零状态码**(`exit=1
|
|
20
|
+
`summary.failed > 0` 时命令以 **非零状态码**(`exit=1`)退出:同一份 `summary + items` 会以 `ok:false` 部分失败信封写到 **stdout**(字段在 `data.summary` / `data.items`),stderr 不再输出单独的错误信封;脚本/agent 直接通过 exit code 判断成败即可,不需要再去解 `summary.failed`。
|
|
21
21
|
|
|
22
22
|
## 远端同名文件冲突
|
|
23
23
|
|
|
24
|
-
如果 Drive 中多个条目映射到同一个 `rel_path
|
|
24
|
+
如果 Drive 中多个条目映射到同一个 `rel_path`,默认直接失败(stderr 类型化错误信封:`error.type=validation`、`error.subtype=failed_precondition`,`error.params[]` 逐条列出冲突的 `rel_path` 及碰撞条目),且不会下载、覆盖或删除任何本地文件。只有“多个 `type=file` 同名”的场景支持显式策略;`file-folder` 这类异构冲突始终直接失败。
|
|
25
25
|
|
|
26
26
|
| 策略 | 行为 |
|
|
27
27
|
|------|------|
|
|
@@ -80,7 +80,7 @@ lark-cli drive +pull --local-dir ./repo --folder-token fldcnxxxxxxxxx \
|
|
|
80
80
|
|
|
81
81
|
- `--delete-local`(无 `--yes`)→ Validate 直接报错:`--delete-local requires --yes`,没有任何下载、列表请求或删除发生。
|
|
82
82
|
- `--delete-local --yes`,**且下载阶段全部成功** → 扫一遍 `--local-dir` 下所有常规文件,把不在云端清单里的逐个 `os.Remove`。**只删常规文件,不删目录**:远端文件夹被删除后,对应本地目录会保留空壳。
|
|
83
|
-
- `--delete-local --yes`,**但下载阶段有任何条目失败** → **跳过整个删除阶段**,命令以 `
|
|
83
|
+
- `--delete-local --yes`,**但下载阶段有任何条目失败** → **跳过整个删除阶段**,命令以 `ok:false` 部分失败结果非零退出。设计意图:避免出现"前面下载失败、后面继续删本地文件"的半同步状态;操作者修好下载错误后再重跑即可。
|
|
84
84
|
- 远端同名文件冲突且使用默认 `fail` → 在下载阶段前失败,删除阶段不会运行。
|
|
85
85
|
- 不传 `--delete-local` → `summary.deleted_local` 永远是 0;命令对本地"多余"文件视而不见。
|
|
86
86
|
|
|
@@ -15,15 +15,16 @@
|
|
|
15
15
|
| `summary.skipped` | 因 `--if-exists=skip` 或 `--if-exists=smart` 命中“无需传输”而跳过的文件数 |
|
|
16
16
|
| `summary.failed` | 上传 / 覆盖 / 建目录 / 删除失败的条目数;**只要不为 0,命令就以非零状态退出**(结构化 `items[]` 仍在 stdout 上) |
|
|
17
17
|
| `summary.deleted_remote` | 启用 `--delete-remote --yes` 时删除的云端文件数 |
|
|
18
|
-
| `
|
|
18
|
+
| `summary.aborted` | 命中终止性错误并停止后续批处理时为 `true` |
|
|
19
|
+
| `items[]` | 每个条目的明细(`rel_path` / `file_token` / `action` / 覆盖时的 `version` / `size_bytes` / 失败时的 `error` / `hint` / `phase` / `error_class` / `code` / `subtype` / `retryable`) |
|
|
19
20
|
|
|
20
|
-
`items[].action` 取值:`uploaded` / `overwritten` / `skipped` / `folder_created` / `deleted_remote` / `failed` / `delete_failed`。
|
|
21
|
+
`items[].action` 取值:`uploaded` / `overwritten` / `skipped` / `folder_created` / `deleted_remote` / `already_deleted` / `failed` / `delete_failed`。
|
|
21
22
|
|
|
22
23
|
> 本地目录(包括空目录)会被镜像到 Drive;新建的子目录会以 `action: "folder_created"` 出现在 `items[]` 里,但**不计入** `summary.uploaded`(该字段只数文件)。已存在的远端目录复用其 token,不会重复 `create_folder`,也不会出现在 `items[]` 里。
|
|
23
24
|
|
|
24
25
|
## 远端同名文件冲突
|
|
25
26
|
|
|
26
|
-
如果 Drive 中多个条目映射到同一个 `rel_path
|
|
27
|
+
如果 Drive 中多个条目映射到同一个 `rel_path`,默认直接失败(stderr 类型化错误信封:`error.type=validation`、`error.subtype=failed_precondition`,`error.params[]` 逐条列出冲突的 `rel_path` 及碰撞条目),且不会上传、覆盖或进入 `--delete-remote` 删除阶段。只有“多个 `type=file` 同名”的场景支持显式策略;`file-folder` 这类异构冲突始终直接失败。
|
|
27
28
|
|
|
28
29
|
| 策略 | 行为 |
|
|
29
30
|
|------|------|
|
|
@@ -95,6 +96,7 @@ lark-cli drive +push --local-dir ./repo --folder-token fldcnxxxxxxxxx \
|
|
|
95
96
|
- `--delete-remote`(无 `--yes`)→ Validate 直接报错:`--delete-remote requires --yes`,不会发起任何列表 / 上传 / 删除请求。
|
|
96
97
|
- `--delete-remote --yes` → Validate 阶段还会**动态做一次** `space:document:delete` 的 scope 预检:缺这条 scope 时整次运行立刻失败、不发任何上传请求,避免出现"上传都成功了,但删除阶段才报 missing_scope"的半同步状态。
|
|
97
98
|
- `--delete-remote --yes`(且 scope 已授权)→ 正常执行:先把本地文件 push 上去,再扫一遍远端 `type=file` 列表,把不在本地清单里的逐个删除。**任何上传 / 覆盖 / 建目录失败时,整段 `--delete-remote` 阶段会被跳过**(stderr 上有提示),命令以非零状态退出,远端不会被破坏。
|
|
99
|
+
- 删除阶段如果服务端返回 `1061007 file has been delete`,说明目标远端文件在本次 DELETE 前已经不存在;这已经满足 `--delete-remote` 的目标状态,输出会记为 `action: "already_deleted"`,不计入 `summary.failed`,也不计入 `summary.deleted_remote`。
|
|
98
100
|
- 远端同名冲突且使用默认 `fail`,或冲突里混有 folder / 其他非 `type=file` 对象 → 在上传阶段前失败,删除阶段不会运行。
|
|
99
101
|
- 不传 `--delete-remote` → `summary.deleted_remote` 永远是 0;命令对远端"多余"文件视而不见。
|
|
100
102
|
- 在线文档(docx / sheet / bitable / ...)和快捷方式即使本地完全没有同名文件,也**不会**进入删除候选,因为它们从来不进 `summary.uploaded` 的对齐域。
|
|
@@ -110,22 +112,47 @@ lark-cli drive +push --local-dir ./repo --folder-token fldcnxxxxxxxxx \
|
|
|
110
112
|
"uploaded": 0,
|
|
111
113
|
"skipped": 0,
|
|
112
114
|
"failed": 0,
|
|
113
|
-
"deleted_remote": 0
|
|
115
|
+
"deleted_remote": 0,
|
|
116
|
+
"aborted": false
|
|
114
117
|
},
|
|
115
118
|
"items": [
|
|
116
119
|
{"rel_path": "...", "file_token": "...", "action": "folder_created"},
|
|
117
120
|
{"rel_path": "...", "file_token": "...", "action": "uploaded", "size_bytes": 0},
|
|
118
121
|
{"rel_path": "...", "file_token": "...", "action": "overwritten", "version": "...", "size_bytes": 0},
|
|
119
122
|
{"rel_path": "...", "file_token": "...", "action": "skipped", "size_bytes": 0},
|
|
120
|
-
{"rel_path": "...", "action": "failed", "size_bytes": 0, "error": "..."},
|
|
123
|
+
{"rel_path": "...", "action": "failed", "size_bytes": 0, "error": "...", "hint": "...", "phase": "upload", "error_class": "...", "code": 0, "subtype": "...", "retryable": false},
|
|
121
124
|
{"rel_path": "...", "file_token": "...", "action": "deleted_remote"},
|
|
122
|
-
{"rel_path": "...", "file_token": "...", "action": "
|
|
125
|
+
{"rel_path": "...", "file_token": "...", "action": "already_deleted"},
|
|
126
|
+
{"rel_path": "...", "file_token": "...", "action": "delete_failed", "error": "...", "hint": "...", "phase": "delete", "error_class": "...", "code": 0, "subtype": "...", "retryable": false}
|
|
123
127
|
]
|
|
124
128
|
}
|
|
125
129
|
```
|
|
126
130
|
|
|
127
131
|
`rel_path` 始终用 `/` 作为分隔符(跨平台一致)。
|
|
128
132
|
|
|
133
|
+
## 失败处理与 agent 行为
|
|
134
|
+
|
|
135
|
+
`+push` 的失败项带结构化字段,agent 必须优先读 `items[].error_class` / `phase` / `code`,不要只看自然语言 `error` 文本。`summary.aborted=true` 表示命令已经遇到终止性错误并停止后续批处理;这时**不要原样重试**,先修复根因。
|
|
136
|
+
|
|
137
|
+
常见终止性错误:
|
|
138
|
+
|
|
139
|
+
| `error_class` | 常见 `code` | 含义 | Agent 应对 |
|
|
140
|
+
|---|---:|---|---|
|
|
141
|
+
| `app_scope_missing` | `99991672` | 应用身份缺少 Drive / 文件夹相关 scope | 停止重试,引导开通错误里列出的应用身份权限,例如 `space:folder:create` 或 `drive:drive` |
|
|
142
|
+
| `user_scope_missing` | `99991679` | 用户身份缺少授权 | 停止重试,走 `lark-cli auth login --scope ...` 补错误里列出的 scope |
|
|
143
|
+
| `permission_denied` | `1061004` / HTTP 403 | 当前身份无权操作目标资源 | 停止重试,检查目标文件夹权限、身份类型(user / bot)和资源可见性 |
|
|
144
|
+
| `invalid_api_parameters` | `1061002` | API 参数被服务端拒绝 | 停止重试,检查 `--folder-token`、覆盖模式、`file_token`、文件名和上传参数;不要对同一参数组合批量重试 |
|
|
145
|
+
| `parent_node_missing` | `1061044` | 上传 / 建目录使用的父文件夹不存在或当前身份不可见 | 停止重试,检查 `--folder-token` 是否仍存在、是否有权限、父目录是否在 push 过程中被删除;不要继续上传同一目录树 |
|
|
146
|
+
| `parent_sibling_limit` | `1062507` | 目标父文件夹单层子节点数量超过上限 | 停止重试,清理目标目录、换一个 `--folder-token`,或把上传内容拆到多个子目录 |
|
|
147
|
+
| `rate_limited` | `99991400` | 触发频控 | 停止当前批次,退避后再重试 |
|
|
148
|
+
| `server_error` | `1061001` / `2200` | Drive 服务端异常 | 停止当前批次,稍后重试;保留 `log_id` 便于排查 |
|
|
149
|
+
|
|
150
|
+
非终止但需要解释的状态:
|
|
151
|
+
|
|
152
|
+
- `file_size_limit` / `1061043`:文件超过 Drive 上传限制。不要继续尝试同一文件;改拆分或换存储方式。
|
|
153
|
+
- `upload_size_mismatch` / `1062009`:本地文件在上传过程中发生变化,或声明大小与实际读取大小不一致。重新扫描本地文件后再 push。
|
|
154
|
+
- `remote_not_found` / `1061007`:一般表示远端文件已不存在。删除阶段的 `1061007` 会被视为 `already_deleted` 成功项;其他阶段需重新列表确认远端状态。
|
|
155
|
+
|
|
129
156
|
## 性能注意
|
|
130
157
|
|
|
131
158
|
- 默认 `skip` 下,已存在的远端文件一律不碰;`overwrite` 下,重复跑会重传所有命中的同名文件;`smart` 下会按 `modified_time` 跳过已对齐的远端文件,但对“远端更旧”的文件仍会进入覆盖路径,因此它减少的是**不必要的重传**,不是把覆盖风险完全拿掉。
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
## 远端同名文件冲突
|
|
21
21
|
|
|
22
|
-
如果 Drive 中多个条目映射到同一个 `rel_path`,`+status` 会在下载/hash
|
|
22
|
+
如果 Drive 中多个条目映射到同一个 `rel_path`,`+status` 会在下载/hash 前直接失败,在 stderr 返回类型化错误信封(`error.type=validation`、`error.subtype=failed_precondition`);`error.params[]` 每条的 `name` 是冲突的 `rel_path`,`reason` 枚举该路径下所有碰撞条目(`type` + `file_token`)。不要把这种情况当成普通 `modified`;它表示同步域本身有歧义,需要先整理云端结构,或在 `+pull` / `+push` 中仅对“duplicate file”场景显式选择冲突策略。
|
|
23
23
|
|
|
24
24
|
## 命令
|
|
25
25
|
|
|
@@ -76,20 +76,18 @@ lark-cli drive +status \
|
|
|
76
76
|
```json
|
|
77
77
|
{
|
|
78
78
|
"ok": false,
|
|
79
|
+
"identity": "user",
|
|
79
80
|
"error": {
|
|
80
|
-
"type": "
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
}
|
|
81
|
+
"type": "validation",
|
|
82
|
+
"subtype": "failed_precondition",
|
|
83
|
+
"message": "1 rel_path(s) map to multiple Drive entries",
|
|
84
|
+
"hint": "resolve the duplicate remote files first: re-run +pull with --on-duplicate-remote=rename (downloads each with a hashed suffix), or use --on-duplicate-remote=newest|oldest (supported by +pull/+sync/+push) to pick one, or delete the extra remote files; a plain retry will not help",
|
|
85
|
+
"params": [
|
|
86
|
+
{
|
|
87
|
+
"name": "dup.txt",
|
|
88
|
+
"reason": "2 Drive entries collide here: file <full_file_token>, folder <folder_token>"
|
|
89
|
+
}
|
|
90
|
+
]
|
|
93
91
|
}
|
|
94
92
|
}
|
|
95
93
|
```
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
> **前置条件:** 先阅读 [`../lark-shared/SKILL.md`](../../lark-shared/SKILL.md) 了解认证、全局参数和安全规则。
|
|
5
5
|
|
|
6
|
-
查询异步任务结果。该 shortcut
|
|
6
|
+
查询异步任务结果。该 shortcut 聚合了导入、导出、Drive 文件/文件夹移动/删除、Wiki 节点 / 文档迁入 Wiki、Wiki 节点移出 Wiki、Wiki 删除等多种异步任务的结果查询,统一接口方便调用。
|
|
7
7
|
|
|
8
8
|
> [!IMPORTANT]
|
|
9
9
|
> 对于 `import` 场景,如果使用 `--as bot` 且这次查询**已经拿到最终在线文档目标**(`ready=true` 且返回了最终 `token` / `url`),CLI 会**再次尝试为当前 CLI 用户自动授予该资源的 `full_access`(可管理权限)**。
|
|
@@ -31,7 +31,7 @@ lark-cli drive +task_result \
|
|
|
31
31
|
--ticket <EXPORT_TICKET> \
|
|
32
32
|
--file-token <SOURCE_DOC_TOKEN>
|
|
33
33
|
|
|
34
|
-
#
|
|
34
|
+
# 查询 Drive 文件/文件夹移动/删除任务状态
|
|
35
35
|
lark-cli drive +task_result \
|
|
36
36
|
--scenario task_check \
|
|
37
37
|
--task-id <TASK_ID>
|
|
@@ -41,6 +41,11 @@ lark-cli drive +task_result \
|
|
|
41
41
|
--scenario wiki_move \
|
|
42
42
|
--task-id <TASK_ID>
|
|
43
43
|
|
|
44
|
+
# 查询 Wiki 节点移出知识库任务结果(wiki +move-to-drive 异步超时后的续跑)
|
|
45
|
+
lark-cli drive +task_result \
|
|
46
|
+
--scenario wiki_move_to_drive \
|
|
47
|
+
--task-id <TASK_ID>
|
|
48
|
+
|
|
44
49
|
# 查询 Wiki 删除知识空间任务结果(wiki +delete-space 异步超时后的续跑)
|
|
45
50
|
lark-cli drive +task_result \
|
|
46
51
|
--scenario wiki_delete_space \
|
|
@@ -51,9 +56,9 @@ lark-cli drive +task_result \
|
|
|
51
56
|
|
|
52
57
|
| 参数 | 必填 | 说明 |
|
|
53
58
|
|------|------|------|
|
|
54
|
-
| `--scenario` | 是 | 任务场景,可选值:`import` (导入任务)、`export` (导出任务)、`task_check` (
|
|
59
|
+
| `--scenario` | 是 | 任务场景,可选值:`import` (导入任务)、`export` (导出任务)、`task_check` (Drive 文件/文件夹移动/删除任务)、`wiki_move` (Wiki 移动任务)、`wiki_move_to_drive` (Wiki 节点移出知识库任务)、`wiki_delete_space` (Wiki 删除知识空间任务)、`wiki_delete_node` (Wiki 删除节点任务) |
|
|
55
60
|
| `--ticket` | 条件必填 | 异步任务 ticket,**import/export 场景必填** |
|
|
56
|
-
| `--task-id` | 条件必填 | 异步任务 ID,**task_check
|
|
61
|
+
| `--task-id` | 条件必填 | 异步任务 ID,**task_check 及所有 wiki 场景必填**;必须原样传递完整 ID |
|
|
57
62
|
| `--file-token` | 条件必填 | 导出任务对应的源文档 token,**export 场景必填** |
|
|
58
63
|
|
|
59
64
|
## 场景说明
|
|
@@ -62,9 +67,11 @@ lark-cli drive +task_result \
|
|
|
62
67
|
|------|------|----------|
|
|
63
68
|
| `import` | 文档导入任务(如将本地文件导入为云文档) | `--ticket` |
|
|
64
69
|
| `export` | 文档导出任务(如云文档导出为 PDF/Word) | `--ticket`、`--file-token` |
|
|
65
|
-
| `task_check` |
|
|
70
|
+
| `task_check` | Drive 文件/文件夹移动/删除任务 | `--task-id` |
|
|
66
71
|
| `wiki_move` | Wiki 移动任务(`wiki +move` 的 docs-to-wiki 异步流程,超时后续跑用) | `--task-id` |
|
|
72
|
+
| `wiki_move_to_drive` | Wiki 节点移出知识库任务(`wiki +move-to-drive` 超时后续跑用) | `--task-id` |
|
|
67
73
|
| `wiki_delete_space` | Wiki 删除知识空间任务(`wiki +delete-space` 的异步流程,超时后续跑用) | `--task-id` |
|
|
74
|
+
| `wiki_delete_node` | Wiki 删除节点任务(`wiki +node-delete` 的异步流程,超时后续跑用) | `--task-id` |
|
|
68
75
|
|
|
69
76
|
## 返回结果
|
|
70
77
|
|
|
@@ -196,6 +203,29 @@ lark-cli drive +task_result \
|
|
|
196
203
|
- `space_id`、`obj_token`、`obj_type`、`title` 等:从首个 `move_results[0].node` 平铺到顶层,方便直接引用
|
|
197
204
|
- `move_results`: 保留完整列表(适用于一次任务移动多个文档的场景)
|
|
198
205
|
|
|
206
|
+
### Wiki_move_to_drive 场景返回
|
|
207
|
+
|
|
208
|
+
```json
|
|
209
|
+
{
|
|
210
|
+
"scenario": "wiki_move_to_drive",
|
|
211
|
+
"task_id": "<OPAQUE_TASK_ID>",
|
|
212
|
+
"ready": true,
|
|
213
|
+
"failed": false,
|
|
214
|
+
"status": 0,
|
|
215
|
+
"status_msg": "success",
|
|
216
|
+
"obj_token": "doxcnXXX",
|
|
217
|
+
"obj_type": "docx",
|
|
218
|
+
"url": "https://example.feishu.cn/docx/doxcnXXX"
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**字段说明:**
|
|
223
|
+
- `ready`: `move_wiki_to_docs_result.status=0` 时为 `true`
|
|
224
|
+
- `failed`: `status<0` 时为 `true`;`status=1` 表示仍在处理
|
|
225
|
+
- `status` / `status_msg`: 协议返回的数值状态与可读消息;不要把字符串状态当作成功值解析
|
|
226
|
+
- `obj_token` / `obj_type` / `url`: 成功后新 Drive 文档的资源信息
|
|
227
|
+
- `task_id`: 签名后的 opaque ID,可能包含多个连字符;服务端响应省略 `task.task_id` 时回退为请求中的完整 ID
|
|
228
|
+
|
|
199
229
|
### Wiki_delete_space 场景返回
|
|
200
230
|
|
|
201
231
|
```json
|
|
@@ -256,6 +286,26 @@ lark-cli drive +task_result --scenario wiki_move --task-id <TASK_ID> --as user
|
|
|
256
286
|
|
|
257
287
|
> **身份保持一致**:续跑命令的 `--as` 必须与原 `wiki +move` 调用一致;`wiki +move` 的 `next_command` 已自动带上正确的 `--as`。
|
|
258
288
|
|
|
289
|
+
### 配合 wiki +move-to-drive 使用
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
# 1. 把 Wiki 节点移到 Drive 文件夹;省略 --folder-token 表示当前身份的“我的空间”根目录
|
|
293
|
+
lark-cli wiki +move-to-drive \
|
|
294
|
+
--node-token <WIKI_NODE_TOKEN> \
|
|
295
|
+
--folder-token <TARGET_FOLDER_TOKEN> \
|
|
296
|
+
--as user
|
|
297
|
+
# 若轮询窗口内完成:直接返回 ready=true、obj_token、obj_type 和 url
|
|
298
|
+
# 若轮询窗口结束仍未完成:返回 ready=false、完整 task_id、timed_out=true 和 next_command
|
|
299
|
+
|
|
300
|
+
# 2. 使用完整 task_id 和相同身份续跑
|
|
301
|
+
lark-cli drive +task_result \
|
|
302
|
+
--scenario wiki_move_to_drive \
|
|
303
|
+
--task-id <COMPLETE_TASK_ID> \
|
|
304
|
+
--as user
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
> **调用上下文和 ID 都要保持原样**:续跑的 `--profile` 与 `--as` 必须与初始移动一致;`task_id` 可能包含多个连字符,不要拆分或截断。`wiki +move-to-drive` 返回的 `next_command` 会保留 profile 与身份。
|
|
308
|
+
|
|
259
309
|
### 配合 wiki +delete-space 使用
|
|
260
310
|
|
|
261
311
|
```bash
|
|
@@ -291,7 +341,9 @@ lark-cli drive +export-download --file-token <EXPORTED_FILE_TOKEN>
|
|
|
291
341
|
| export | `drive:drive.metadata:readonly` |
|
|
292
342
|
| task_check | `drive:drive.metadata:readonly` |
|
|
293
343
|
| wiki_move | `wiki:space:read` |
|
|
344
|
+
| wiki_move_to_drive | `wiki:space:read` |
|
|
294
345
|
| wiki_delete_space | `wiki:space:read` |
|
|
346
|
+
| wiki_delete_node | `wiki:space:read` |
|
|
295
347
|
|
|
296
348
|
> [!NOTE]
|
|
297
349
|
> `import` 场景在 `--as bot` 且任务最终就绪时,还可能额外尝试一次协作者授权;如果 `permission_grant.status = failed`,请根据失败信息检查应用是否具备相应的文档协作者授权能力。
|
|
@@ -299,4 +351,5 @@ lark-cli drive +export-download --file-token <EXPORTED_FILE_TOKEN>
|
|
|
299
351
|
## 参考
|
|
300
352
|
|
|
301
353
|
- [lark-drive](../SKILL.md) -- 云空间(云盘/云存储)全部命令
|
|
354
|
+
- [wiki +move-to-drive](../../lark-wiki/references/lark-wiki-move-to-drive.md) -- 将 Wiki 节点移出知识库并放入 Drive
|
|
302
355
|
- [lark-shared](../../lark-shared/SKILL.md) -- 认证和全局参数
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# 知识整理工作流
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workflow id: `knowledge_organize`
|
|
4
|
+
|
|
5
|
+
Risk / Structure: `R2-R3` / `S3`
|
|
6
|
+
|
|
7
|
+
This file implements the registered knowledge organization workflow. Before execution, the agent MUST read [`lark-drive-workflow.md`](lark-drive-workflow.md) and [`../../lark-shared/SKILL.md`](../../lark-shared/SKILL.md), and follow the shared execution protocol, Artifact Contract, Workflow Loading rules, authentication rules, and write confirmation rules.
|
|
8
|
+
|
|
9
|
+
It defines the workflow-specific state machine and progressive loading map. Stage-specific rules live in phase files and MUST be loaded only when the workflow reaches the corresponding state.
|
|
4
10
|
|
|
5
11
|
Phase files are references for this workflow, not independent skills. Do not route user requests directly to a phase file.
|
|
6
12
|
|
|
@@ -80,7 +86,7 @@ When this workflow is triggered, the agent MUST:
|
|
|
80
86
|
|
|
81
87
|
## Runtime State
|
|
82
88
|
|
|
83
|
-
Agent MUST maintain these internal fields during one workflow run:
|
|
89
|
+
This workflow extends the shared Artifact Contract. Agent MUST maintain these internal fields during one workflow run:
|
|
84
90
|
|
|
85
91
|
| Field | Meaning |
|
|
86
92
|
|-------|---------|
|
|
@@ -114,24 +120,24 @@ Agent MUST maintain these internal fields during one workflow run:
|
|
|
114
120
|
|
|
115
121
|
## Execution State Machine
|
|
116
122
|
|
|
117
|
-
| State | Entry Condition | Agent MUST Do | User-Facing Output | wait_for_user | Next State |
|
|
118
|
-
|
|
119
|
-
| `PARSE_SCOPE` | Workflow triggered | Load discovery phase; parse target, environment, identity, and target type | Scope confirmation or clarification question | `true` | `INVENTORY` |
|
|
120
|
-
| `INVENTORY` | Scope confirmed | Load discovery phase; recursively list resources and build `resource_items` | Inventory progress / summary; continue automatically unless blocked | `false` unless blocked | `CONTENT_READ` |
|
|
121
|
-
| `CONTENT_READ` | Inventory complete | Load analysis phase; identify low-confidence items and perform mandatory partial read when needed | Low-confidence read summary | `false` unless auth / permission blocks | `ISSUE_ANALYSIS` |
|
|
122
|
-
| `ISSUE_ANALYSIS` | Resource list and partial reads ready | Load analysis phase; detect structure problems, evidence, and organization approach | Inventory result, problems, organization approach, and decision options | `true` | `RULE_GENERATION` |
|
|
123
|
-
| `RULE_GENERATION` | User confirms organization approach | Load analysis phase; generate classification rules and `target_tree` | No separate stop; target tree is shown with plan generation | `false` | `PLAN_GENERATION` |
|
|
124
|
-
| `PLAN_GENERATION` | Target tree ready | Load planning phase; generate complete internal `plan_items`; show target tree plus plan overview or page | Target tree and plan overview / paginated plan page | `true` | `EXEC_CONFIRM` |
|
|
125
|
-
| `EXEC_CONFIRM` | User wants execution | Load planning phase; ask user to choose execution scope | Execution options and write-operation summary | `true` | `EXECUTE` or `DONE` |
|
|
126
|
-
| `EXECUTE` | User explicitly confirmed execution scope | Load execution phase; execute only whitelisted write operations for confirmed scope while maintaining internal recovery state | Progress reports for large or long-running execution; if blocked after successful moves, ask whether to try restoring to `整理前的位置` | `false` unless blocked / recovery offered | `VERIFY`, `ROLLBACK_CONFIRM`, or `DONE` |
|
|
127
|
-
| `VERIFY` | Execution finished | Load execution phase; rescan target scope and compare actual path/token against plan | Verification table and final summary; if serious mismatches exist, ask whether to try restoring to `整理前的位置` | `false` unless recovery offered | `DONE` or `ROLLBACK_CONFIRM` |
|
|
128
|
-
| `ROLLBACK_CONFIRM` | User asks to restore after execution failure / verification mismatch / explicit rollback request | Load rollback phase; generate internal `rollback_plan`; ask whether to execute recovery | Recoverable scope and restore confirmation | `true` | `ROLLBACK` or `DONE` |
|
|
129
|
-
| `ROLLBACK` | User explicitly confirms restore execution | Load rollback phase; execute confirmed reverse moves only | Recovery progress / result | `false` | `ROLLBACK_VERIFY` |
|
|
130
|
-
| `ROLLBACK_VERIFY` | Recovery execution finished | Load rollback phase; verify restored locations and decide whether cleanup candidates exist | Recovery verification result | `false` | `ROLLBACK_CLEANUP_CONFIRM` or `DONE` |
|
|
131
|
-
| `ROLLBACK_CLEANUP_CONFIRM` | Cleanup candidates exist after recovery, or user asks to clean workflow-created empty folders / nodes | Load rollback phase; generate cleanup plan and ask for delete confirmation | Cleanup candidates and delete confirmation | `true` | `ROLLBACK_CLEANUP` or `DONE` |
|
|
132
|
-
| `ROLLBACK_CLEANUP` | User explicitly confirms cleanup deletion | Load rollback phase; delete only confirmed workflow-created safe-empty folders / nodes | Cleanup progress / result | `false` | `ROLLBACK_CLEANUP_VERIFY` |
|
|
133
|
-
| `ROLLBACK_CLEANUP_VERIFY` | Cleanup deletion finished | Load rollback phase; verify deleted cleanup targets | Cleanup verification result | `false` | `DONE` |
|
|
134
|
-
| `DONE` | No more action | Stop | Final answer | `false` | End |
|
|
123
|
+
| State | Protocol Step | Entry Condition | Agent MUST Do | User-Facing Output | wait_for_user | Next State |
|
|
124
|
+
|-------|---------------|-----------------|---------------|--------------------|---------------|------------|
|
|
125
|
+
| `PARSE_SCOPE` | `route` / `scope` | Workflow triggered | Load discovery phase; parse target, environment, identity, and target type | Scope confirmation or clarification question | `true` | `INVENTORY` |
|
|
126
|
+
| `INVENTORY` | `read` | Scope confirmed | Load discovery phase; recursively list resources and build `resource_items` | Inventory progress / summary; continue automatically unless blocked | `false` unless blocked | `CONTENT_READ` |
|
|
127
|
+
| `CONTENT_READ` | `read` | Inventory complete | Load analysis phase; identify low-confidence items and perform mandatory partial read when needed | Low-confidence read summary | `false` unless auth / permission blocks | `ISSUE_ANALYSIS` |
|
|
128
|
+
| `ISSUE_ANALYSIS` | `assess` / `plan` | Resource list and partial reads ready | Load analysis phase; detect structure problems, evidence, and organization approach | Inventory result, problems, organization approach, and decision options | `true` | `RULE_GENERATION` |
|
|
129
|
+
| `RULE_GENERATION` | `assess` / `plan` | User confirms organization approach | Load analysis phase; generate classification rules and `target_tree` | No separate stop; target tree is shown with plan generation | `false` | `PLAN_GENERATION` |
|
|
130
|
+
| `PLAN_GENERATION` | `assess` / `plan` | Target tree ready | Load planning phase; generate complete internal `plan_items`; show target tree plus plan overview or page | Target tree and plan overview / paginated plan page | `true` | `EXEC_CONFIRM` |
|
|
131
|
+
| `EXEC_CONFIRM` | `confirm` | User wants execution | Load planning phase; ask user to choose execution scope | Execution options and write-operation summary | `true` | `EXECUTE` or `DONE` |
|
|
132
|
+
| `EXECUTE` | `execute` | User explicitly confirmed execution scope | Load execution phase; execute only whitelisted write operations for confirmed scope while maintaining internal recovery state | Progress reports for large or long-running execution; if blocked after successful moves, ask whether to try restoring to `整理前的位置` | `false` unless blocked / recovery offered | `VERIFY`, `ROLLBACK_CONFIRM`, or `DONE` |
|
|
133
|
+
| `VERIFY` | `verify` | Execution finished | Load execution phase; rescan target scope and compare actual path/token against plan | Verification table and final summary; if serious mismatches exist, ask whether to try restoring to `整理前的位置` | `false` unless recovery offered | `DONE` or `ROLLBACK_CONFIRM` |
|
|
134
|
+
| `ROLLBACK_CONFIRM` | `recovery confirm` | User asks to restore after execution failure / verification mismatch / explicit rollback request | Load rollback phase; generate internal `rollback_plan`; ask whether to execute recovery | Recoverable scope and restore confirmation | `true` | `ROLLBACK` or `DONE` |
|
|
135
|
+
| `ROLLBACK` | `recovery execute` | User explicitly confirms restore execution | Load rollback phase; execute confirmed reverse moves only | Recovery progress / result | `false` | `ROLLBACK_VERIFY` |
|
|
136
|
+
| `ROLLBACK_VERIFY` | `recovery verify` | Recovery execution finished | Load rollback phase; verify restored locations and decide whether cleanup candidates exist | Recovery verification result | `false` | `ROLLBACK_CLEANUP_CONFIRM` or `DONE` |
|
|
137
|
+
| `ROLLBACK_CLEANUP_CONFIRM` | `cleanup confirm` | Cleanup candidates exist after recovery, or user asks to clean workflow-created empty folders / nodes | Load rollback phase; generate cleanup plan and ask for delete confirmation | Cleanup candidates and delete confirmation | `true` | `ROLLBACK_CLEANUP` or `DONE` |
|
|
138
|
+
| `ROLLBACK_CLEANUP` | `cleanup execute` | User explicitly confirms cleanup deletion | Load rollback phase; delete only confirmed workflow-created safe-empty folders / nodes | Cleanup progress / result | `false` | `ROLLBACK_CLEANUP_VERIFY` |
|
|
139
|
+
| `ROLLBACK_CLEANUP_VERIFY` | `cleanup verify` | Cleanup deletion finished | Load rollback phase; verify deleted cleanup targets | Cleanup verification result | `false` | `DONE` |
|
|
140
|
+
| `DONE` | `done` | No more action | Stop | Final answer | `false` | End |
|
|
135
141
|
|
|
136
142
|
## Progressive Load Map
|
|
137
143
|
|
|
@@ -97,7 +97,7 @@ Structure Level:
|
|
|
97
97
|
2. Entry file 超过约 300 行时,优先拆 `commands`、`outputs` 或 `artifacts` reference。
|
|
98
98
|
3. 只有执行、验证、恢复或 rollback 状态链复杂到影响可读性时,才升级到 `S3` phase files。
|
|
99
99
|
4. 垂直业务包优先作为已有 workflow 的 recipe / policy / template,不默认新增独立 workflow。
|
|
100
|
-
5. 已有样板:`permission_governance` 是 `R2/S2
|
|
100
|
+
5. 已有样板:`permission_governance` 是 `R2/S2`;`knowledge_organize` 是 `R2-R3/S3`。
|
|
101
101
|
|
|
102
102
|
## 加载与拆分边界
|
|
103
103
|
|
|
@@ -111,6 +111,7 @@ Structure Level:
|
|
|
111
111
|
| Workflow | Status | Risk | Structure | Entry File | Trigger |
|
|
112
112
|
|----------|--------|------|-----------|------------|---------|
|
|
113
113
|
| `permission_governance` | Registered | `R2` | `S2` | [`lark-drive-workflow-permission-governance.md`](lark-drive-workflow-permission-governance.md) | 权限审计、公开链接/外部访问、复制/下载/评论/分享设置、权限申请、owner 转移 / 批量 owner 转移、密级标签调整 |
|
|
114
|
+
| `knowledge_organize` | Registered | `R2-R3` | `S3` | [`lark-drive-workflow-knowledge-organize.md`](lark-drive-workflow-knowledge-organize.md) | 整理云盘 / 文件夹 / 文档库 / 知识库、盘点目录结构、归类资源、生成整理方案,并在用户确认后创建目录或移动资源 |
|
|
114
115
|
|
|
115
116
|
## Workflow Loading
|
|
116
117
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: lark-event
|
|
3
3
|
version: 1.0.0
|
|
4
|
-
description: "Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM messages/reactions/chat changes, Task updates, VC meeting started/joined/ended, Minutes generated, Whiteboard updated, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses."
|
|
4
|
+
description: "Lark/Feishu real-time event listening / subscribing / consuming: stream events as NDJSON via `lark-cli event consume <EventKey>` (covers IM messages/reactions/chat changes, Approval status changes, Task updates, VC meeting started/joined/ended, Minutes generated, Whiteboard updated, etc.). Use for Lark bots, real-time message processing, long-running subscribers, streaming webhook/push handlers. Supports `--max-events` / `--timeout` bounded runs and a stderr ready-marker contract — designed for AI agents running as subprocesses."
|
|
5
5
|
metadata:
|
|
6
6
|
requires:
|
|
7
7
|
bins: ["lark-cli"]
|
|
@@ -147,6 +147,7 @@ Lark-defined semantic tags (**not** JSON Schema's standard `format`). Common val
|
|
|
147
147
|
|
|
148
148
|
| Topic | Reference | Coverage |
|
|
149
149
|
|------------|------------------------------------------------------------------------------|---|
|
|
150
|
+
| Approval | [`references/lark-event-approval.md`](references/lark-event-approval.md) | Catalog of 2 Approval EventKeys (`approval.instance.status_changed_v4`, `approval.task.status_changed_v4`) + optional/multi `subscription_type` pre-registration + user-auth subscription lifecycle + flat output field reference |
|
|
150
151
|
| IM | [`references/lark-event-im.md`](references/lark-event-im.md) | Catalog of 12 IM EventKeys + shape notes (flat vs V2 envelope) + `im.message.receive_v1` field gotchas (`sender_id` is open_id only; `.content` is plain text except for `interactive` cards) + common jq recipes (filter by chat_type / message_type / sender); for `card.action.trigger` see also [`../lark-im/references/lark-im-card-action-reply.md`](../lark-im/references/lark-im-card-action-reply.md) |
|
|
151
152
|
| Task | [`references/lark-event-task.md`](references/lark-event-task.md) | Catalog of 1 Task EventKey (`task.task.update_user_access_v2`) + Native V2 envelope shape + task commit types + user/bot subscription notes |
|
|
152
153
|
| VC | [`references/lark-event-vc.md`](references/lark-event-vc.md) | Catalog of 4 VC EventKeys (`vc.meeting.participant_meeting_started_v1`, `vc.meeting.participant_meeting_joined_v1`, `vc.meeting.participant_meeting_ended_v1`, `vc.note.generated_v1`) + field reference + source type semantics (meeting only) |
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Approval Events
|
|
2
|
+
|
|
3
|
+
> **Prerequisite:** Read [`../SKILL.md`](../SKILL.md) first for the `event consume` essentials (commands, subprocess contract, jq usage).
|
|
4
|
+
|
|
5
|
+
## Key catalog (2)
|
|
6
|
+
|
|
7
|
+
| EventKey | Purpose |
|
|
8
|
+
|---|---|
|
|
9
|
+
| `approval.instance.status_changed_v4` | An approval instance status changed |
|
|
10
|
+
| `approval.task.status_changed_v4` | An approval task status changed |
|
|
11
|
+
|
|
12
|
+
Both keys use a **Custom schema**. The raw Lark schema 2.0 envelope is flattened: event metadata is exposed as `type`, `event_id`, and `timestamp`, while approval business fields are exposed at the top level.
|
|
13
|
+
|
|
14
|
+
Both keys carry a **PreConsume hook** that subscribes the current authorized user through the Approval subscription APIs before listening. The consumer intentionally does **not** unsubscribe on exit; the server-side Approval subscription relation remains until it is canceled outside `event consume`. These keys require `--as user`.
|
|
15
|
+
|
|
16
|
+
## Listener and subscription selection
|
|
17
|
+
|
|
18
|
+
At the raw CLI level, each `event consume` process accepts exactly one EventKey. `approval.instance.status_changed_v4` and `approval.task.status_changed_v4` have different output shapes, so listening to both still means two processes.
|
|
19
|
+
|
|
20
|
+
For Approval only, `subscription_type` is an optional setup param used by PreConsume to register server-side Approval subscription relations before the local listener starts. It is **not** an output field, a local event filter, or a local subscription identity. The pushed event does not say which subscription relation caused delivery, and one business event can match both relations; deduplicate with `event_id` when needed.
|
|
21
|
+
|
|
22
|
+
`subscription_type` may be omitted, a single value, a comma-separated list, or a JSON string array:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Omitted: register both INVOLVED_APPROVAL and MANAGED_APPROVAL for this EventKey
|
|
26
|
+
lark-cli event consume approval.instance.status_changed_v4 --as user
|
|
27
|
+
|
|
28
|
+
# Single relation
|
|
29
|
+
lark-cli event consume approval.instance.status_changed_v4 \
|
|
30
|
+
-p subscription_type=INVOLVED_APPROVAL \
|
|
31
|
+
--as user
|
|
32
|
+
|
|
33
|
+
# Explicit multi-relation registration for one local consumer
|
|
34
|
+
lark-cli event consume approval.task.status_changed_v4 \
|
|
35
|
+
-p subscription_type=INVOLVED_APPROVAL,MANAGED_APPROVAL \
|
|
36
|
+
--as user
|
|
37
|
+
|
|
38
|
+
# JSON array form; quote it for the shell
|
|
39
|
+
lark-cli event consume approval.task.status_changed_v4 \
|
|
40
|
+
-p 'subscription_type=["INVOLVED_APPROVAL","MANAGED_APPROVAL"]' \
|
|
41
|
+
--as user
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
| Value | Meaning |
|
|
45
|
+
|---|---|
|
|
46
|
+
| `INVOLVED_APPROVAL` | Receive events where the current user is the approval requester or approver |
|
|
47
|
+
| `MANAGED_APPROVAL` | Receive events under approval definitions managed by the current user |
|
|
48
|
+
|
|
49
|
+
User-intent inference:
|
|
50
|
+
|
|
51
|
+
| User intent | EventKey(s) | `subscription_type` |
|
|
52
|
+
|---|---|---|
|
|
53
|
+
| Mentions approval instances, approval forms, approval order/status, or "instance status" | `approval.instance.status_changed_v4` | infer from relation words below |
|
|
54
|
+
| Mentions approval tasks, approval todo items, approver operations, or "task status" | `approval.task.status_changed_v4` | infer from relation words below |
|
|
55
|
+
| Says "approval status changes/events" without saying task vs instance | both EventKeys | infer from relation words below |
|
|
56
|
+
| Says "my approvals", "approvals involving me", "I requested/approved", "待我审批", "我发起/我参与" | requested EventKey(s) | `INVOLVED_APPROVAL` |
|
|
57
|
+
| Says "approvals I manage", "managed definitions", "definitions managed by me", "我管理的审批定义" | requested EventKey(s) | `MANAGED_APPROVAL` |
|
|
58
|
+
| Explicitly asks for both involved and managed, or says "all approval subscriptions" | requested EventKey(s), or both if EventKey is also ambiguous | omit `subscription_type`, or pass both values in one `-p` |
|
|
59
|
+
| Relation is ambiguous and the user wants broad coverage | requested EventKey(s), or both if EventKey is also ambiguous | omit `subscription_type` so PreConsume registers both |
|
|
60
|
+
|
|
61
|
+
If the user's wording omits the relation and broad listening is acceptable, omit `subscription_type`. Ask only when registering both relations would be materially harmful.
|
|
62
|
+
|
|
63
|
+
## Scopes & auth
|
|
64
|
+
|
|
65
|
+
| EventKey | Scope | Auth |
|
|
66
|
+
|---|---|---|
|
|
67
|
+
| `approval.instance.status_changed_v4` | `approval:instance:read` | user |
|
|
68
|
+
| `approval.task.status_changed_v4` | `approval:task:read` | user |
|
|
69
|
+
|
|
70
|
+
## Subscription behavior
|
|
71
|
+
|
|
72
|
+
Startup calls the endpoint for the selected EventKey:
|
|
73
|
+
|
|
74
|
+
```text
|
|
75
|
+
POST /open-apis/approval/v4/instances/subscription
|
|
76
|
+
POST /open-apis/approval/v4/tasks/subscription
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
For each resolved `subscription_type`, PreConsume sends one request body:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{"subscription_type":"INVOLVED_APPROVAL"}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
If `subscription_type` is omitted, PreConsume sends two registration requests for that EventKey: one with `INVOLVED_APPROVAL`, then one with `MANAGED_APPROVAL`. If listening to both instance and task events, run two consumers; each consumer may omit `subscription_type` to register both relations for its own EventKey.
|
|
86
|
+
|
|
87
|
+
Do not start two consumers for the same Approval EventKey merely to split `INVOLVED_APPROVAL` and `MANAGED_APPROVAL`. The server push and flattened output are keyed by EventKey and cannot be distinguished by subscription relation.
|
|
88
|
+
|
|
89
|
+
Shutdown behavior:
|
|
90
|
+
|
|
91
|
+
`event consume` does not call the Approval unsubscribe APIs when it exits. This applies to graceful exit, Ctrl+C / SIGTERM, stdin EOF, `--timeout`, and `--max-events`.
|
|
92
|
+
|
|
93
|
+
To stop future delivery for a user, cancel the Approval subscription relation outside this consumer. The unsubscribe APIs are separate operations and are not called by `event consume`.
|
|
94
|
+
|
|
95
|
+
## Output fields
|
|
96
|
+
|
|
97
|
+
Common fields:
|
|
98
|
+
|
|
99
|
+
| Field | Type | Description |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `type` | string | Event type |
|
|
102
|
+
| `event_id` | string | Globally unique event ID; use for deduplication |
|
|
103
|
+
| `timestamp` | string (timestamp_ms) | Event delivery time in milliseconds, taken from `header.create_time` |
|
|
104
|
+
|
|
105
|
+
Instance event fields:
|
|
106
|
+
|
|
107
|
+
| Field | Type | Description |
|
|
108
|
+
|---|---|---|
|
|
109
|
+
| `approval_code` | string | Approval definition code; not a subscription dimension |
|
|
110
|
+
| `instance_code` | string | Approval instance code |
|
|
111
|
+
| `external_id` | string | Third-party approval instance id, when present |
|
|
112
|
+
| `status` | string enum | `PENDING`, `APPROVED`, `REJECTED`, `CANCELED`, `DELETED`, `REVERTED`, `OVERTIME_CLOSE`, `OVERTIME_RECOVER` |
|
|
113
|
+
| `operate_time` | string (timestamp_ms) | Status change time |
|
|
114
|
+
| `start_user` | object | Instance starter user IDs, omitted when unavailable |
|
|
115
|
+
| `start_user.open_id` | string (open_id) | Instance starter open_id, when present |
|
|
116
|
+
| `start_user.union_id` | string (union_id) | Instance starter union_id, when present |
|
|
117
|
+
| `start_user.user_id` | string (user_id) | Instance starter tenant user_id, when present |
|
|
118
|
+
|
|
119
|
+
Task event fields:
|
|
120
|
+
|
|
121
|
+
| Field | Type | Description |
|
|
122
|
+
|---|---|---|
|
|
123
|
+
| `approval_code` | string | Approval definition code; not a subscription dimension |
|
|
124
|
+
| `instance_code` | string | Approval instance code |
|
|
125
|
+
| `task_id` | string | Approval task id |
|
|
126
|
+
| `external_id` | string | Third-party approval external id, when present |
|
|
127
|
+
| `task_external_id` | string | Third-party task external id, when emitted |
|
|
128
|
+
| `assigned_user` | object | Task assignee or operator user IDs, omitted for automatic flows without an operator |
|
|
129
|
+
| `assigned_user.open_id` | string (open_id) | Task assignee or operator open_id, when present |
|
|
130
|
+
| `assigned_user.union_id` | string (union_id) | Task assignee or operator union_id, when present |
|
|
131
|
+
| `assigned_user.user_id` | string (user_id) | Task assignee or operator tenant user_id, when present |
|
|
132
|
+
| `status` | string enum | `REVERTED`, `PENDING`, `APPROVED`, `REJECTED`, `TRANSFERRED`, `ROLLBACK`, `DONE`, `OVERTIME_CLOSE`, `OVERTIME_RECOVER` |
|
|
133
|
+
| `operate_time` | string (timestamp_ms) | Status change time |
|
|
134
|
+
|
|
135
|
+
## Examples
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Stream approval instance updates broadly; registers both involved and managed relations
|
|
139
|
+
lark-cli event consume approval.instance.status_changed_v4 \
|
|
140
|
+
--as user
|
|
141
|
+
|
|
142
|
+
# Stream approval instance updates only for approvals involving the current user
|
|
143
|
+
lark-cli event consume approval.instance.status_changed_v4 \
|
|
144
|
+
-p subscription_type=INVOLVED_APPROVAL \
|
|
145
|
+
--as user
|
|
146
|
+
|
|
147
|
+
# Stream approval task updates for definitions managed by the current user
|
|
148
|
+
lark-cli event consume approval.task.status_changed_v4 \
|
|
149
|
+
-p subscription_type=MANAGED_APPROVAL \
|
|
150
|
+
--as user
|
|
151
|
+
|
|
152
|
+
# Broad approval status listening:
|
|
153
|
+
# run both EventKeys as separate processes; omit subscription_type so each registers both relations.
|
|
154
|
+
lark-cli event consume approval.instance.status_changed_v4 \
|
|
155
|
+
--as user > approval-instance.ndjson &
|
|
156
|
+
lark-cli event consume approval.task.status_changed_v4 \
|
|
157
|
+
--as user > approval-task.ndjson &
|
|
158
|
+
wait
|
|
159
|
+
|
|
160
|
+
# Listen to both involved and managed task subscriptions with one local consumer.
|
|
161
|
+
lark-cli event consume approval.task.status_changed_v4 \
|
|
162
|
+
-p subscription_type=INVOLVED_APPROVAL,MANAGED_APPROVAL \
|
|
163
|
+
--as user > approval-task.ndjson
|
|
164
|
+
|
|
165
|
+
# Project a compact approval-task record
|
|
166
|
+
lark-cli event consume approval.task.status_changed_v4 \
|
|
167
|
+
-p subscription_type=INVOLVED_APPROVAL \
|
|
168
|
+
--as user \
|
|
169
|
+
--jq '{event_id, task_id, status, at: .operate_time}'
|
|
170
|
+
```
|