Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/messaging/outbound/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
ChannelMessageActionName,
OpenClawConfig,
} from 'openclaw/plugin-sdk';
import type { ChannelThreadingToolContext } from 'openclaw/plugin-sdk/channel-contract';
import type { ChannelMessageToolSchemaContribution, ChannelThreadingToolContext } from 'openclaw/plugin-sdk/channel-contract';
import { extractToolSend } from 'openclaw/plugin-sdk/tool-send';
import { readStringParam } from 'openclaw/plugin-sdk/param-readers';
import { jsonResult, readReactionParams } from '../../core/sdk-compat';
Expand All @@ -32,6 +32,17 @@ import { uploadAndSendMediaLark } from './media';

const log = larkLogger('outbound/actions');

const FEISHU_SEND_TEXT_DESCRIPTION =
'Text to send as a separate Feishu message. During a normal Feishu streaming-card reply, do not call send just to repeat or finalize the same answer; return the final answer normally so the active card can be completed by the reply dispatcher. Use send only when the user explicitly needs an additional separate message.';

const FEISHU_MESSAGE_TOOL_SCHEMA = {
properties: {
message: { type: 'string', description: FEISHU_SEND_TEXT_DESCRIPTION },
text: { type: 'string', description: FEISHU_SEND_TEXT_DESCRIPTION },
},
visibility: 'current-channel' as const,
} as unknown as ChannelMessageToolSchemaContribution;

// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -170,7 +181,7 @@ export const feishuMessageActions: ChannelMessageActionAdapter = {
return {
actions: Array.from(SUPPORTED_ACTIONS),
capabilities: ['cards'],
schema: null,
schema: FEISHU_MESSAGE_TOOL_SCHEMA,
};
},

Expand Down
38 changes: 38 additions & 0 deletions tests/message-actions-schema.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { describe, expect, it } from 'vitest';
import type { ClawdbotConfig } from 'openclaw/plugin-sdk';
import { feishuMessageActions } from '../src/messaging/outbound/actions';

function configuredFeishuConfig(): ClawdbotConfig {
return {
channels: {
feishu: {
appId: 'cli_a',
appSecret: 'secret',
},
},
} as unknown as ClawdbotConfig;
}

describe('Feishu message action discovery', () => {
it('guides send text away from duplicate streaming-card final replies', () => {
const discovery = feishuMessageActions.describeMessageTool({
cfg: configuredFeishuConfig(),
currentChannelProvider: 'feishu',
});

expect(discovery?.actions).toContain('send');
expect(discovery?.schema).toMatchObject({
visibility: 'current-channel',
properties: {
message: {
type: 'string',
description: expect.stringContaining('do not call send'),
},
text: {
type: 'string',
description: expect.stringContaining('active card'),
},
},
});
});
});
Loading