← Back to PRs

#20304: feat(feishu): support Docx table create/write + image/file upload actions in feishu_doc [AI-assisted]

by xuhao1 open 2026-02-18 19:17 View on GitHub →
channel: feishu size: L
## Summary - Problem: `feishu_doc` could not create regular Docx table blocks through the tool API. - Why it matters: Feishu Docx table automation requires “create table shell first, then fill cells”. - What changed: Added `create_table`, `write_table_cells`, and `create_table_with_values` actions to `feishu_doc`. - What did NOT change (scope boundary): No changes to auth, account routing, or non-Docx Feishu tools. ## Change Type (select all) - [x] Feature - [x] Docs ## Scope (select all touched areas) - [x] Integrations - [x] API / contracts ## Linked Issue/PR - Closes #20303 ## User-visible / Behavior Changes - `feishu_doc` now supports: - `create_table` for Docx table block creation - `write_table_cells` for filling existing table cells - `create_table_with_values` for one-step create+fill ## Security Impact (required) - New permissions/capabilities? (`Yes/No`) No - Secrets/tokens handling changed? (`Yes/No`) No - New/changed network calls? (`Yes/No`) No - Command/tool execution surface changed? (`Yes/No`) Yes (new tool actions in existing tool) - Data access scope changed? (`Yes/No`) No - If any `Yes`, explain risk + mitigation: - Risk: expanded action surface in `feishu_doc` could be misused with malformed parameters. - Mitigation: strict schema validation and bounded row/column behavior based on returned table metadata. ## Repro + Verification ### Environment - OS: Linux (container) - Runtime/container: OpenClaw main runtime - Model/provider: gpt-5.3-codex via OpenClaw - Integration/channel (if any): Feishu - Relevant config (redacted): Feishu bot configured with docx scopes ### Steps 1. Call `feishu_doc` with `action=create_table` on a Docx doc token. 2. Confirm table block is returned and table block exists in doc. 3. Call `feishu_doc` with `action=write_table_cells` and 2D values. 4. Call `action=create_table_with_values` and verify one-step success. ### Expected - Table block is created and cells are populated as provided. ### Actual - Verified locally in runtime: creation succeeds and cell writes succeed after restart. ## Evidence - [x] Trace/log snippets Snippet (local runtime): - `create_table_with_values` → `{ success: true, table_block_id: "...", cells_written: 4 }` ## Human Verification (required) What I personally verified (not just CI), and how: - Verified scenarios: - Create 2x2 table with custom column widths. - Write 2x2 values into existing table. - One-step create-and-fill flow. - Edge cases checked: - Values matrix larger than table dimensions is bounded by table row/col size. - Empty/invalid values rejected by schema/runtime checks. - What I did **not** verify: - Full `pnpm build && pnpm check && pnpm test` on upstream repo in this environment. ## Compatibility / Migration - Backward compatible? (`Yes/No`) Yes - Config/env changes? (`Yes/No`) No - Migration needed? (`Yes/No`) No ## Failure Recovery (if this breaks) - How to disable/revert this change quickly: - Revert this PR or remove the three new action branches in `docx.ts` and schema entries in `doc-schema.ts`. - Files/config to restore: - `extensions/feishu/src/docx.ts` - `extensions/feishu/src/doc-schema.ts` - `extensions/feishu/skills/feishu-doc/SKILL.md` - Known bad symptoms reviewers should watch for: - 400 errors while writing cells (usually means incorrect table-cell handling path). ## Risks and Mitigations - Risk: Feishu API response shape differences across SDK versions for table/cell fields. - Mitigation: derive rows/cols/cell IDs from fetched table block metadata and fail with clear errors when unavailable. --- AI-assisted: Yes (implementation + drafting assisted by AI tooling). The code paths were manually reviewed and runtime-tested. <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds three new Docx table actions (`create_table`, `write_table_cells`, `create_table_with_values`) to the `feishu_doc` tool, enabling programmatic table creation and cell population in Feishu documents. - New `createTable` function creates table blocks directly via the Feishu `documentBlockChildren.create` API with configurable row/column sizes and optional column widths - New `writeTableCells` function fetches table metadata, iterates cells in row-major order, clears existing content, and inserts converted markdown into each cell - `createTableWithValues` composes the two above for a one-step create-and-fill workflow - Schema additions in `doc-schema.ts` with proper validation constraints (`minimum: 1`, `minItems: 1`) - SKILL.md updated with usage examples for all three new actions - Note: the existing `references/block-types.md` still states "Table blocks CANNOT be created via the `documentBlockChildren.create` API" — this is now outdated given the new `create_table` action <h3>Confidence Score: 4/5</h3> - This PR is safe to merge — it adds well-structured new actions to an existing tool with proper error handling and input validation. - The new table operations are cleanly implemented, follow existing patterns in the codebase, include proper bounds checking and error handling, and are additive (no changes to existing behavior). Minor concerns: sequential per-cell API calls could be slow for large tables, and `Type.Number` instead of `Type.Integer` for row/col counts is imprecise but consistent with existing patterns. - `extensions/feishu/src/docx.ts` — review the sequential API call pattern in `writeTableCells` for performance with large tables. <sub>Last reviewed commit: c295e09</sub> <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs