feat(message): add list/get/search/members read actions to Lark channel#467
Open
KevinWangQQ wants to merge 1 commit into
Open
feat(message): add list/get/search/members read actions to Lark channel#467KevinWangQQ wants to merge 1 commit into
KevinWangQQ wants to merge 1 commit into
Conversation
Add 4 read actions to the Lark/Feishu `message` tool adapter, parallel to
the existing send/react/reactions/delete/unsend write actions, so agents
can answer 'what was just said in chat X' without grepping local cache.
API surface:
- message action=list chatId=<oc_xxx> [limit] [scan] [sender] [since_hours|since_days]
- message action=get messageId=<om_xxx> [full=true]
- message action=search chatId=<oc_xxx> text=... [limit] [scan]
- message action=members chatId=<oc_xxx> [pageToken]
Implementation reuses the already-exported helpers `getMessageFeishu` and
`listChatMembersFeishu`; `list` and `search` add a thin wrapper around
`im/v1/messages` GET with ByCreateTimeDesc paging plus a small client-side
filter layer (sender / substring text / since-hours).
The new action names ('list', 'get', 'members') are not yet in the openclaw
SDK `ChannelMessageActionName` union (only 'search' is). They are valid Lark
actions, so the `SUPPORTED_ACTIONS` Set casts the new names through unknown
and the switch labels widen to `string`. A follow-up SDK PR can extend the
union and remove the casts. No write actions or backward compat changed.
Smoke verified locally against live Feishu API: 4 actions all return well-
formed JSON over a real chat (containers, members, messages, search hits).
Pre-existing typecheck failures on main (capabilities literal in
describeMessageTool, task.ts agent_task_status) are unaffected by this
patch and out of scope.
|
|
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.
Problem
Agents using the
messagetool against the Feishu/Lark channel can today only write (send/react/reactions/delete/unsend). To answer questions like "what was just said in group X?" or "who's in this chat?", they have to fall back to grepping local message-cache files, which is lossy (rolling truncation, ~hours of replication lag) and asymmetric with the write surface.Solution
Add 4 read actions to
feishuMessageActions, parallel to the existing write set:listchatId(required, also acceptschat/channel/to); optionallimit(≤200),scan(≤200),sender(open_id),since_hours/since_days{ messages: [...], nextPageToken?, hasMore, scanned, count }getmessageId(required); optionalfull/expandto enableexpandForwardingetMessageFeishu{ message: FeishuMessageInfo }searchchatId+text/query/q(required); optionallimit(≤200),scan(≤500){ messages: [...], scanned, count }(client-side substring)memberschatId(required); optionalpageToken{ members: [...], hasMore, nextPageToken }Implementation reuses already-exported package helpers wherever possible:
get→getMessageFeishu(frommessaging/shared/message-lookup.ts)members→listChatMembersFeishu(frommessaging/outbound/chat-manage.ts)list/search→ thin loops aroundim/v1/messages(ByCreateTimeDescpaging) plus a smallbuildExcerpthelper that handlestext/post/interactive/ media / system message types.API surface
Backward compatibility
Pure addition. No existing action's signature, return shape, or behaviour changes.
Type-system note
ChannelMessageActionNamein the openclaw SDK currently only contains'search'of the four —'list','get','members'are not yet in the union. Rather than block this PR on an SDK change,SUPPORTED_ACTIONScasts the new names throughunknown as ChannelMessageActionName[]and theswitchwidens tostring. A follow-up SDK PR (againstopenclaw/openclaw) can extend the union and remove the casts. Two unrelated pre-existing typecheck failures onmain(capabilities: ['cards']literal vs'presentation'|'delivery-pin', andtask.tsagent_task_status) are untouched.Required scopes
Same scopes as the existing read helpers being reused —
im:message:readonly,im:chat:readonly. Already documented forgetMessageFeishu/listChatMembersFeishu.Tests
Smoke-verified locally against the live Feishu API (
@larksuite/[email protected]install with this patch applied):listreturned 3 most-recent messages from a real group chat withcount/scanned/nextPageToken/hasMoreand a sanetextExcerptfor each.getreturned a fullFeishuMessageInfofor a known message id including reactions/sender/parsed body.searchreturned 5 substring hits over a 50-row scan window withscanned/countaccounting.membersreturned 10 human members of the same chat withmemberId/name/memberIdType.I'm happy to add a Vitest harness if the project would like one for read paths — let me know the preferred shape.
Related downstream
A standalone Python skill (
feishu-group/scripts/fg.py) currently provides similar read functionality outside the SDK; once this PR ships it becomes a fallback for patch drift / pre-merge installs only. Local install + idempotent patch script that motivated this PR: it overlays these two files onto the npm-installed package and skips when upstream already supports them.