#16592: feat(feishu): add write mode import for markdown documents
channel: feishu
size: M
Cluster:
Memory Management Enhancements
## Summary
- feat(feishu): add write mode import for markdown documents
- Split from our `v2026.2.13` patch train as a single-purpose change for easier review.
## Why
- Keep the diff focused and low-risk so it can be merged or reverted independently.
## Scope
- Branch: `feat/feishu-write-mode-import-en`
- Files changed: 3
- Key files:
- `extensions/feishu/src/doc-schema.ts`
- `extensions/feishu/src/docx.test.ts`
- `extensions/feishu/src/docx.ts`
## Test Plan
- Suggested local command:
- `./node_modules/.bin/vitest run extensions/feishu/src/docx.test.ts`
- Validation status:
- [ ] CI checks pass
- [ ] Maintainer re-ran local tests
## Risk & Rollback
- Risk: low to medium; impact limited to touched module(s).
- Rollback: revert this PR commit(s) cleanly.
## Co-authorship
- Co-authored by @ciberponk and Codex (GPT-5).
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds a new `import` mode to the `feishu_doc` write action, allowing markdown documents to be imported via Feishu's Import Task API rather than the existing blocks-based approach. The change introduces optional parameters (`mode`, `title`, `folder_token`) to the write action schema, implements `createDocFromMarkdownViaImport()` function that creates a temporary document, uploads the markdown file, triggers the import task, polls for completion, and cleans up the temporary document.
Key changes:
- Added `mode` parameter to write action schema with values `"blocks"` (default) or `"import"`
- New `createDocFromMarkdownViaImport()` function handles the import workflow
- Tests cover both success and validation error scenarios
- Import mode requires `title` and `folder_token` parameters for proper operation
Two issues were previously identified and remain unresolved:
- Schema uses `Type.Union` which violates the repository's tool schema guidelines (should use `optionalStringEnum` from `openclaw/plugin-sdk`)
- Polling loop has no delay between API retries, which will hammer the Feishu API unnecessarily
<h3>Confidence Score: 2/5</h3>
- This PR has two unresolved issues that should be fixed before merging
- Score reflects two previously-reported but still-unfixed issues: schema guideline violation and missing retry delay in polling loop. Both issues are straightforward to fix but impact code quality and API behavior.
- `extensions/feishu/src/doc-schema.ts` (schema guideline violation) and `extensions/feishu/src/docx.ts` (missing polling delay)
<sub>Last reviewed commit: c923500</sub>
<!-- greptile_other_comments_section -->
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#16438: feat(feishu): add create_from_markdown import action
by ciberponk · 2026-02-14
88.6%
#14402: fix(feishu): chunk large documents for write/append to avoid API 40...
by lml2468 · 2026-02-12
78.9%
#16647: feat(feishu_doc): allow optional initial content on create
by ciberponk · 2026-02-15
75.3%
#16594: feat(feishu): add set_public_permission doc action
by ciberponk · 2026-02-14
75.3%
#16607: feat(feishu): add get_public_permission doc action
by ciberponk · 2026-02-14
75.2%
#12755: feat(feishu): render post rich text as markdown
by WilsonLiu95 · 2026-02-09
73.4%
#16409: fix(feishu): preserve docx block order via sequential inserts
by ciberponk · 2026-02-14
73.4%
#20304: feat(feishu): support Docx table create/write + image/file upload a...
by xuhao1 · 2026-02-18
73.3%
#16637: feat(feishu_doc): support optional public_access on create
by ciberponk · 2026-02-14
72.9%
#16123: Feishu card default
by QiuYi111 · 2026-02-14
71.9%