feat(im): add strict Feishu image send path#456
Open
xfcycc wants to merge 1 commit into
Open
Conversation
- add uploadAndSendImageLark for Feishu upload-then-send image delivery - register feishu_im_bot_send_image with fixed /tmp/openclaw local access - validate image format, size, dimensions, and successful message_id responses - document agent usage and cover strict image sends with tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a strict Feishu image-message path for cases where an agent must send an actual IM image instead of a card image, text link, or file fallback.
Feishu's documented image delivery flow is two-step:
image_type=messageto get animage_keymsg_type=imageandcontent={"image_key":"..."}This PR exposes that path as a dedicated bot tool and only reports success after Feishu returns a real
message_idfor the image message.What changed
uploadAndSendImageLark, a strict upload-then-send helper that:image_type=messagemsg_type=imagewith the returnedimage_keymessage_idfeishu_im_bot_send_imageas a new bot-identity IM tool insrc/tools/tat/im/send-image.ts.feishu_im_bot_imagedownload tool unchanged; the new send tool is registered separately fromsrc/tools/tat/im/index.ts.skills/feishu-channel-rules/SKILL.mdso image sends use the strict image tool instead of card/markdown embedding.message_idfailures.Why
The generic media path can fall back to sending a text link when upload fails. That behavior is useful for best-effort delivery, but it makes
ok=trueambiguous for tasks that require the recipient to actually see an image message.This PR adds a separate strict path for those cases:
img_keyvaluesimage_keySecurity and permissions
im:resourcefor image upload andim:message:send_as_bot/ message send permission for delivery./tmp/openclaw; the agent cannot pass a customlocal_rootsvalue through the tool.Testing
After rebasing onto latest
main(bfb0ff7):pnpm test -- tests/media-image-send.test.ts— 21 files / 171 tests passedpnpm exec eslint src/messaging/outbound/media.ts src/tools/tat/im/send-image.ts tests/media-image-send.test.ts index.tspnpm buildgit diff --checkuploadAndSendImageLarkbefore the file-split refactor, returning a real Feishu message idmessageId=om_x100b501ba09c4888c3205f456e16391and detectedpng 640x320Notes
pnpm typecheckstill fails on baseline issues unrelated to this PR:openclaw/plugin-sdk/zalouseris not exported by the installedopenclawpackagesrc/messaging/inbound/handler.tshas existing implicitanyparameterssrc/messaging/outbound/actions.tsstill advertisescardsin capabilities, while the installed SDK type only acceptspresentation/delivery-pinmainaddssrc/tools/oapi/task/task.ts, whereagent_task_statusis not recognized by the installed SDK type