@actagent/feishu 2026.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/actagent.plugin.json +224 -0
- package/api.ts +33 -0
- package/channel-entry.ts +21 -0
- package/channel-plugin-api.ts +2 -0
- package/contract-api.ts +17 -0
- package/index.ts +83 -0
- package/legacy-state-migrations-api.ts +2 -0
- package/npm-shrinkwrap.json +539 -0
- package/package.json +64 -0
- package/runtime-api.ts +58 -0
- package/runtime-setter-api.ts +3 -0
- package/secret-contract-api.ts +6 -0
- package/security-contract-api.ts +2 -0
- package/session-key-api.ts +2 -0
- package/setup-api.ts +4 -0
- package/setup-entry.test.ts +33 -0
- package/setup-entry.ts +25 -0
- package/skills/feishu-doc/SKILL.md +211 -0
- package/skills/feishu-doc/references/block-types.md +103 -0
- package/skills/feishu-drive/SKILL.md +97 -0
- package/skills/feishu-perm/SKILL.md +119 -0
- package/skills/feishu-wiki/SKILL.md +113 -0
- package/src/accounts.test.ts +481 -0
- package/src/accounts.ts +380 -0
- package/src/agent-config.ts +22 -0
- package/src/app-registration.test.ts +62 -0
- package/src/app-registration.ts +355 -0
- package/src/approval-auth.test.ts +25 -0
- package/src/approval-auth.ts +26 -0
- package/src/async.test.ts +68 -0
- package/src/async.ts +109 -0
- package/src/audio-preflight.runtime.ts +10 -0
- package/src/bitable.test.ts +174 -0
- package/src/bitable.ts +781 -0
- package/src/bot-content.ts +488 -0
- package/src/bot-group-name.test.ts +148 -0
- package/src/bot-runtime-api.ts +13 -0
- package/src/bot-sender-name.test.ts +68 -0
- package/src/bot-sender-name.ts +137 -0
- package/src/bot.broadcast.test.ts +643 -0
- package/src/bot.card-action.test.ts +647 -0
- package/src/bot.checkBotMentioned.test.ts +266 -0
- package/src/bot.helpers.test.ts +136 -0
- package/src/bot.stripBotMention.test.ts +127 -0
- package/src/bot.test.ts +3817 -0
- package/src/bot.ts +1788 -0
- package/src/card-action.ts +515 -0
- package/src/card-interaction.test.ts +132 -0
- package/src/card-interaction.ts +160 -0
- package/src/card-test-helpers.ts +55 -0
- package/src/card-ux-approval.ts +66 -0
- package/src/card-ux-launcher.test.ts +126 -0
- package/src/card-ux-launcher.ts +136 -0
- package/src/card-ux-shared.ts +34 -0
- package/src/channel-runtime-api.ts +17 -0
- package/src/channel.runtime.ts +48 -0
- package/src/channel.test.ts +1337 -0
- package/src/channel.ts +1401 -0
- package/src/chat-schema.ts +30 -0
- package/src/chat.test.ts +295 -0
- package/src/chat.ts +198 -0
- package/src/client-timeout.ts +44 -0
- package/src/client.test.ts +463 -0
- package/src/client.ts +263 -0
- package/src/comment-dispatcher-runtime-api.ts +7 -0
- package/src/comment-dispatcher.test.ts +186 -0
- package/src/comment-dispatcher.ts +108 -0
- package/src/comment-handler-runtime-api.ts +4 -0
- package/src/comment-handler.test.ts +588 -0
- package/src/comment-handler.ts +304 -0
- package/src/comment-reaction.test.ts +139 -0
- package/src/comment-reaction.ts +260 -0
- package/src/comment-shared.test.ts +184 -0
- package/src/comment-shared.ts +405 -0
- package/src/comment-target.ts +45 -0
- package/src/config-schema.test.ts +327 -0
- package/src/config-schema.ts +338 -0
- package/src/conversation-id.test.ts +19 -0
- package/src/conversation-id.ts +199 -0
- package/src/dedup-migrations.test.ts +90 -0
- package/src/dedup-migrations.ts +103 -0
- package/src/dedup.test.ts +95 -0
- package/src/dedup.ts +304 -0
- package/src/dedupe-key.ts +68 -0
- package/src/directory.static.ts +62 -0
- package/src/directory.test.ts +142 -0
- package/src/directory.ts +125 -0
- package/src/doc-schema.ts +183 -0
- package/src/doctor.test.ts +382 -0
- package/src/doctor.ts +876 -0
- package/src/docx-batch-insert.test.ts +117 -0
- package/src/docx-batch-insert.ts +223 -0
- package/src/docx-color-text.ts +154 -0
- package/src/docx-table-ops.test.ts +54 -0
- package/src/docx-table-ops.ts +316 -0
- package/src/docx-types.ts +39 -0
- package/src/docx.account-selection.test.ts +96 -0
- package/src/docx.test.ts +706 -0
- package/src/docx.ts +1598 -0
- package/src/drive-schema.ts +93 -0
- package/src/drive.test.ts +1240 -0
- package/src/drive.ts +830 -0
- package/src/dynamic-agent.test.ts +156 -0
- package/src/dynamic-agent.ts +144 -0
- package/src/event-types.ts +46 -0
- package/src/external-keys.test.ts +21 -0
- package/src/external-keys.ts +20 -0
- package/src/lifecycle.test-support.ts +223 -0
- package/src/media.test.ts +956 -0
- package/src/media.ts +1106 -0
- package/src/mention-target.types.ts +6 -0
- package/src/mention.ts +115 -0
- package/src/message-action-contract.ts +14 -0
- package/src/monitor-state-runtime-api.ts +8 -0
- package/src/monitor-transport-runtime-api.ts +11 -0
- package/src/monitor.account.ts +501 -0
- package/src/monitor.acp-init-failure.lifecycle.test-support.ts +215 -0
- package/src/monitor.bot-identity.ts +87 -0
- package/src/monitor.bot-menu-handler.ts +164 -0
- package/src/monitor.bot-menu.lifecycle.test-support.ts +221 -0
- package/src/monitor.bot-menu.test.ts +200 -0
- package/src/monitor.broadcast.reply-once.lifecycle.test-support.ts +265 -0
- package/src/monitor.card-action.lifecycle.test-support.ts +418 -0
- package/src/monitor.cleanup.test.ts +384 -0
- package/src/monitor.comment-notice-handler.ts +106 -0
- package/src/monitor.comment.test.ts +968 -0
- package/src/monitor.comment.ts +1386 -0
- package/src/monitor.lifecycle.test.ts +5 -0
- package/src/monitor.message-handler.ts +346 -0
- package/src/monitor.reaction.test.ts +770 -0
- package/src/monitor.startup.test.ts +232 -0
- package/src/monitor.startup.ts +76 -0
- package/src/monitor.state.defaults.test.ts +47 -0
- package/src/monitor.state.ts +171 -0
- package/src/monitor.synthetic-error.ts +19 -0
- package/src/monitor.test-mocks.ts +47 -0
- package/src/monitor.transport.ts +451 -0
- package/src/monitor.ts +104 -0
- package/src/monitor.webhook-e2e.test.ts +284 -0
- package/src/monitor.webhook-security.test.ts +394 -0
- package/src/monitor.webhook.test-helpers.ts +138 -0
- package/src/outbound-runtime-api.ts +2 -0
- package/src/outbound.test.ts +1255 -0
- package/src/outbound.ts +742 -0
- package/src/perm-schema.ts +53 -0
- package/src/perm.ts +171 -0
- package/src/pins.ts +109 -0
- package/src/policy.test.ts +224 -0
- package/src/policy.ts +322 -0
- package/src/post.test.ts +106 -0
- package/src/post.ts +276 -0
- package/src/presentation-card.ts +204 -0
- package/src/probe.test.ts +310 -0
- package/src/probe.ts +181 -0
- package/src/processing-claims.ts +60 -0
- package/src/qr-terminal.ts +2 -0
- package/src/reactions.ts +124 -0
- package/src/reasoning-preview.test.ts +114 -0
- package/src/reasoning-preview.ts +29 -0
- package/src/reply-dispatcher-runtime-api.ts +8 -0
- package/src/reply-dispatcher.test.ts +2009 -0
- package/src/reply-dispatcher.ts +865 -0
- package/src/runtime.ts +10 -0
- package/src/secret-contract.ts +146 -0
- package/src/secret-input.ts +2 -0
- package/src/security-audit-shared.ts +70 -0
- package/src/security-audit.test.ts +60 -0
- package/src/security-audit.ts +2 -0
- package/src/send-result.ts +81 -0
- package/src/send-target.test.ts +87 -0
- package/src/send-target.ts +36 -0
- package/src/send.reply-fallback.test.ts +418 -0
- package/src/send.test.ts +661 -0
- package/src/send.ts +860 -0
- package/src/sequential-key.test.ts +73 -0
- package/src/sequential-key.ts +29 -0
- package/src/sequential-queue.test.ts +184 -0
- package/src/sequential-queue.ts +90 -0
- package/src/session-conversation.ts +42 -0
- package/src/session-route.ts +49 -0
- package/src/setup-core.ts +52 -0
- package/src/setup-surface.test.ts +485 -0
- package/src/setup-surface.ts +620 -0
- package/src/streaming-card.test.ts +549 -0
- package/src/streaming-card.ts +611 -0
- package/src/subagent-hooks.test.ts +632 -0
- package/src/subagent-hooks.ts +414 -0
- package/src/targets.ts +98 -0
- package/src/test-support/lifecycle-test-support.ts +459 -0
- package/src/thread-bindings.test.ts +181 -0
- package/src/thread-bindings.ts +332 -0
- package/src/tool-account-routing.test.ts +419 -0
- package/src/tool-account.test.ts +45 -0
- package/src/tool-account.ts +98 -0
- package/src/tool-factory-test-harness.ts +83 -0
- package/src/tool-result.test.ts +33 -0
- package/src/tool-result.ts +17 -0
- package/src/tools-config.test.ts +52 -0
- package/src/tools-config.ts +29 -0
- package/src/types.ts +111 -0
- package/src/typing.test.ts +145 -0
- package/src/typing.ts +215 -0
- package/src/wiki-schema.ts +70 -0
- package/src/wiki.ts +271 -0
- package/subagent-hooks-api.ts +22 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Feishu plugin module implements processing claims behavior.
|
|
2
|
+
const EVENT_DEDUP_TTL_MS = 5 * 60 * 1000;
|
|
3
|
+
const EVENT_MEMORY_MAX_SIZE = 2_000;
|
|
4
|
+
|
|
5
|
+
const processingClaims = new Map<string, number>();
|
|
6
|
+
|
|
7
|
+
function resolveEventDedupeKey(
|
|
8
|
+
namespace: string,
|
|
9
|
+
messageId: string | undefined | null,
|
|
10
|
+
): string | null {
|
|
11
|
+
const trimmed = messageId?.trim();
|
|
12
|
+
return trimmed ? `${namespace}:${trimmed}` : null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function pruneProcessingClaims(now: number): void {
|
|
16
|
+
const cutoff = now - EVENT_DEDUP_TTL_MS;
|
|
17
|
+
for (const [key, seenAt] of processingClaims) {
|
|
18
|
+
if (seenAt < cutoff) {
|
|
19
|
+
processingClaims.delete(key);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
while (processingClaims.size > EVENT_MEMORY_MAX_SIZE) {
|
|
23
|
+
const oldestKey = processingClaims.keys().next().value;
|
|
24
|
+
if (!oldestKey) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
processingClaims.delete(oldestKey);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function tryBeginFeishuMessageProcessing(
|
|
32
|
+
messageId: string | undefined | null,
|
|
33
|
+
namespace = "global",
|
|
34
|
+
): boolean {
|
|
35
|
+
const key = resolveEventDedupeKey(namespace, messageId);
|
|
36
|
+
if (!key) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
const now = Date.now();
|
|
40
|
+
pruneProcessingClaims(now);
|
|
41
|
+
if (processingClaims.has(key)) {
|
|
42
|
+
processingClaims.delete(key);
|
|
43
|
+
processingClaims.set(key, now);
|
|
44
|
+
pruneProcessingClaims(now);
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
processingClaims.set(key, now);
|
|
48
|
+
pruneProcessingClaims(now);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function releaseFeishuMessageProcessing(
|
|
53
|
+
messageId: string | undefined | null,
|
|
54
|
+
namespace = "global",
|
|
55
|
+
): void {
|
|
56
|
+
const key = resolveEventDedupeKey(namespace, messageId);
|
|
57
|
+
if (key) {
|
|
58
|
+
processingClaims.delete(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
package/src/reactions.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// Feishu plugin module implements reactions behavior.
|
|
2
|
+
import type { ACTAgentBotConfig } from "../runtime-api.js";
|
|
3
|
+
import { resolveFeishuRuntimeAccount } from "./accounts.js";
|
|
4
|
+
import { createFeishuClient } from "./client.js";
|
|
5
|
+
|
|
6
|
+
type FeishuReaction = {
|
|
7
|
+
reactionId: string;
|
|
8
|
+
emojiType: string;
|
|
9
|
+
operatorType: "app" | "user";
|
|
10
|
+
operatorId: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function resolveConfiguredFeishuClient(params: { cfg: ACTAgentBotConfig; accountId?: string }) {
|
|
14
|
+
const account = resolveFeishuRuntimeAccount(params);
|
|
15
|
+
if (!account.configured) {
|
|
16
|
+
throw new Error(`Feishu account "${account.accountId}" not configured`);
|
|
17
|
+
}
|
|
18
|
+
return createFeishuClient(account);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function assertFeishuReactionApiSuccess(response: { code?: number; msg?: string }, action: string) {
|
|
22
|
+
if (response.code !== 0) {
|
|
23
|
+
throw new Error(`Feishu ${action} failed: ${response.msg || `code ${response.code}`}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Add a reaction (emoji) to a message.
|
|
29
|
+
* @param emojiType - Feishu emoji type, e.g., "SMILE", "THUMBSUP", "HEART"
|
|
30
|
+
* @see https://open.feishu.cn/document/server-docs/im-v1/message-reaction/emojis-introduce
|
|
31
|
+
*/
|
|
32
|
+
export async function addReactionFeishu(params: {
|
|
33
|
+
cfg: ACTAgentBotConfig;
|
|
34
|
+
messageId: string;
|
|
35
|
+
emojiType: string;
|
|
36
|
+
accountId?: string;
|
|
37
|
+
}): Promise<{ reactionId: string }> {
|
|
38
|
+
const { cfg, messageId, emojiType, accountId } = params;
|
|
39
|
+
const client = resolveConfiguredFeishuClient({ cfg, accountId });
|
|
40
|
+
|
|
41
|
+
const response = (await client.im.messageReaction.create({
|
|
42
|
+
path: { message_id: messageId },
|
|
43
|
+
data: {
|
|
44
|
+
reaction_type: {
|
|
45
|
+
emoji_type: emojiType,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})) as {
|
|
49
|
+
code?: number;
|
|
50
|
+
msg?: string;
|
|
51
|
+
data?: { reaction_id?: string };
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
assertFeishuReactionApiSuccess(response, "add reaction");
|
|
55
|
+
|
|
56
|
+
const reactionId = response.data?.reaction_id;
|
|
57
|
+
if (!reactionId) {
|
|
58
|
+
throw new Error("Feishu add reaction failed: no reaction_id returned");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return { reactionId };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Remove a reaction from a message.
|
|
66
|
+
*/
|
|
67
|
+
export async function removeReactionFeishu(params: {
|
|
68
|
+
cfg: ACTAgentBotConfig;
|
|
69
|
+
messageId: string;
|
|
70
|
+
reactionId: string;
|
|
71
|
+
accountId?: string;
|
|
72
|
+
}): Promise<void> {
|
|
73
|
+
const { cfg, messageId, reactionId, accountId } = params;
|
|
74
|
+
const client = resolveConfiguredFeishuClient({ cfg, accountId });
|
|
75
|
+
|
|
76
|
+
const response = (await client.im.messageReaction.delete({
|
|
77
|
+
path: {
|
|
78
|
+
message_id: messageId,
|
|
79
|
+
reaction_id: reactionId,
|
|
80
|
+
},
|
|
81
|
+
})) as { code?: number; msg?: string };
|
|
82
|
+
|
|
83
|
+
assertFeishuReactionApiSuccess(response, "remove reaction");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* List all reactions for a message.
|
|
88
|
+
*/
|
|
89
|
+
export async function listReactionsFeishu(params: {
|
|
90
|
+
cfg: ACTAgentBotConfig;
|
|
91
|
+
messageId: string;
|
|
92
|
+
emojiType?: string;
|
|
93
|
+
accountId?: string;
|
|
94
|
+
}): Promise<FeishuReaction[]> {
|
|
95
|
+
const { cfg, messageId, emojiType, accountId } = params;
|
|
96
|
+
const client = resolveConfiguredFeishuClient({ cfg, accountId });
|
|
97
|
+
|
|
98
|
+
const response = (await client.im.messageReaction.list({
|
|
99
|
+
path: { message_id: messageId },
|
|
100
|
+
params: emojiType ? { reaction_type: emojiType } : undefined,
|
|
101
|
+
})) as {
|
|
102
|
+
code?: number;
|
|
103
|
+
msg?: string;
|
|
104
|
+
data?: {
|
|
105
|
+
items?: Array<{
|
|
106
|
+
reaction_id?: string;
|
|
107
|
+
reaction_type?: { emoji_type?: string };
|
|
108
|
+
operator_type?: string;
|
|
109
|
+
operator_id?: { open_id?: string; user_id?: string; union_id?: string };
|
|
110
|
+
}>;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
assertFeishuReactionApiSuccess(response, "list reactions");
|
|
115
|
+
|
|
116
|
+
const items = response.data?.items ?? [];
|
|
117
|
+
return items.map((item) => ({
|
|
118
|
+
reactionId: item.reaction_id ?? "",
|
|
119
|
+
emojiType: item.reaction_type?.emoji_type ?? "",
|
|
120
|
+
operatorType: item.operator_type === "app" ? "app" : "user",
|
|
121
|
+
operatorId:
|
|
122
|
+
item.operator_id?.open_id ?? item.operator_id?.user_id ?? item.operator_id?.union_id ?? "",
|
|
123
|
+
}));
|
|
124
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Feishu tests cover reasoning preview plugin behavior.
|
|
2
|
+
import { afterAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
import type { ACTAgentBotConfig } from "./bot-runtime-api.js";
|
|
4
|
+
import { resolveFeishuReasoningPreviewEnabled } from "./reasoning-preview.js";
|
|
5
|
+
|
|
6
|
+
const { loadSessionStoreMock } = vi.hoisted(() => ({
|
|
7
|
+
loadSessionStoreMock: vi.fn(),
|
|
8
|
+
}));
|
|
9
|
+
|
|
10
|
+
vi.mock("./bot-runtime-api.js", async () => {
|
|
11
|
+
const actual =
|
|
12
|
+
await vi.importActual<typeof import("./bot-runtime-api.js")>("./bot-runtime-api.js");
|
|
13
|
+
return {
|
|
14
|
+
...actual,
|
|
15
|
+
loadSessionStore: loadSessionStoreMock,
|
|
16
|
+
};
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterAll(() => {
|
|
20
|
+
vi.doUnmock("./bot-runtime-api.js");
|
|
21
|
+
vi.resetModules();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("resolveFeishuReasoningPreviewEnabled", () => {
|
|
25
|
+
const emptyCfg: ACTAgentBotConfig = {};
|
|
26
|
+
|
|
27
|
+
beforeEach(() => {
|
|
28
|
+
vi.clearAllMocks();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("enables previews only for stream reasoning sessions", () => {
|
|
32
|
+
loadSessionStoreMock.mockReturnValue({
|
|
33
|
+
"agent:main:feishu:dm:ou_sender_1": { reasoningLevel: "stream" },
|
|
34
|
+
"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "on" },
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
expect(
|
|
38
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
39
|
+
cfg: emptyCfg,
|
|
40
|
+
agentId: "main",
|
|
41
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
42
|
+
sessionKey: "agent:main:feishu:dm:ou_sender_1",
|
|
43
|
+
}),
|
|
44
|
+
).toBe(true);
|
|
45
|
+
expect(
|
|
46
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
47
|
+
cfg: emptyCfg,
|
|
48
|
+
agentId: "main",
|
|
49
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
50
|
+
sessionKey: "agent:main:feishu:dm:ou_sender_2",
|
|
51
|
+
}),
|
|
52
|
+
).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("returns false for missing sessions or load failures", () => {
|
|
56
|
+
loadSessionStoreMock.mockImplementationOnce(() => {
|
|
57
|
+
throw new Error("disk unavailable");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
expect(
|
|
61
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
62
|
+
cfg: emptyCfg,
|
|
63
|
+
agentId: "main",
|
|
64
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
65
|
+
sessionKey: "agent:main:feishu:dm:ou_sender_1",
|
|
66
|
+
}),
|
|
67
|
+
).toBe(false);
|
|
68
|
+
expect(
|
|
69
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
70
|
+
cfg: emptyCfg,
|
|
71
|
+
agentId: "main",
|
|
72
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
73
|
+
}),
|
|
74
|
+
).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("falls back to configured stream defaults", () => {
|
|
78
|
+
loadSessionStoreMock.mockReturnValue({
|
|
79
|
+
"agent:main:feishu:dm:ou_sender_1": {},
|
|
80
|
+
"agent:main:feishu:dm:ou_sender_2": { reasoningLevel: "off" },
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const cfg: ACTAgentBotConfig = {
|
|
84
|
+
agents: {
|
|
85
|
+
defaults: { reasoningDefault: "stream" },
|
|
86
|
+
list: [{ id: "Ops", reasoningDefault: "off" }],
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
expect(
|
|
91
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
92
|
+
cfg,
|
|
93
|
+
agentId: "main",
|
|
94
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
95
|
+
sessionKey: "agent:main:feishu:dm:ou_sender_1",
|
|
96
|
+
}),
|
|
97
|
+
).toBe(true);
|
|
98
|
+
expect(
|
|
99
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
100
|
+
cfg,
|
|
101
|
+
agentId: "ops",
|
|
102
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
103
|
+
}),
|
|
104
|
+
).toBe(false);
|
|
105
|
+
expect(
|
|
106
|
+
resolveFeishuReasoningPreviewEnabled({
|
|
107
|
+
cfg,
|
|
108
|
+
agentId: "main",
|
|
109
|
+
storePath: "/tmp/feishu-sessions.json",
|
|
110
|
+
sessionKey: "agent:main:feishu:dm:ou_sender_2",
|
|
111
|
+
}),
|
|
112
|
+
).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Feishu plugin module implements reasoning preview behavior.
|
|
2
|
+
import { resolveFeishuConfigReasoningDefault } from "./agent-config.js";
|
|
3
|
+
import { loadSessionStore, resolveSessionStoreEntry } from "./bot-runtime-api.js";
|
|
4
|
+
import type { ACTAgentBotConfig } from "./bot-runtime-api.js";
|
|
5
|
+
|
|
6
|
+
export function resolveFeishuReasoningPreviewEnabled(params: {
|
|
7
|
+
cfg: ACTAgentBotConfig;
|
|
8
|
+
agentId: string;
|
|
9
|
+
storePath: string;
|
|
10
|
+
sessionKey?: string;
|
|
11
|
+
}): boolean {
|
|
12
|
+
const configDefault = resolveFeishuConfigReasoningDefault(params.cfg, params.agentId);
|
|
13
|
+
|
|
14
|
+
if (!params.sessionKey) {
|
|
15
|
+
return configDefault === "stream";
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
try {
|
|
19
|
+
const store = loadSessionStore(params.storePath, { skipCache: true });
|
|
20
|
+
const level = resolveSessionStoreEntry({ store, sessionKey: params.sessionKey }).existing
|
|
21
|
+
?.reasoningLevel;
|
|
22
|
+
if (level === "on" || level === "stream" || level === "off") {
|
|
23
|
+
return level === "stream";
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return configDefault === "stream";
|
|
29
|
+
}
|