@kodelyth/feishu 2026.5.39 → 2026.6.1

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.
Files changed (47) hide show
  1. package/dist/accounts-D0ow-lRb.js +429 -0
  2. package/dist/api.js +2308 -0
  3. package/dist/app-registration-DBSnysKJ.js +184 -0
  4. package/dist/audio-preflight.runtime-Dpjbn-7r.js +7 -0
  5. package/dist/channel-13WQvQ0u.js +2115 -0
  6. package/dist/channel-entry.js +22 -0
  7. package/dist/channel-plugin-api.js +2 -0
  8. package/dist/channel.runtime-JMJonrJ4.js +729 -0
  9. package/dist/client-D1pzbBGo.js +157 -0
  10. package/dist/contract-api.js +9 -0
  11. package/dist/conversation-id-_58ecqlx.js +139 -0
  12. package/dist/drive-CgHOluXx.js +883 -0
  13. package/dist/index.js +68 -0
  14. package/dist/monitor-oWptK0zL.js +60 -0
  15. package/dist/monitor.account-DHaWlslg.js +5207 -0
  16. package/dist/monitor.state-C211a4tX.js +100 -0
  17. package/dist/probe-CF4duEpK.js +149 -0
  18. package/dist/rolldown-runtime-DUslC3ob.js +14 -0
  19. package/dist/runtime-DSh5rL_d.js +8 -0
  20. package/dist/runtime-api.js +14 -0
  21. package/dist/secret-contract-NSee-WzN.js +119 -0
  22. package/dist/secret-contract-api.js +2 -0
  23. package/dist/security-audit-DWVC0vSK.js +11 -0
  24. package/dist/security-audit-shared-Dpcwxeft.js +38 -0
  25. package/dist/security-contract-api.js +2 -0
  26. package/dist/send-DfZuV4Fi.js +1212 -0
  27. package/dist/session-conversation-Duaukbnl.js +27 -0
  28. package/dist/session-key-api.js +2 -0
  29. package/dist/setup-api.js +2 -0
  30. package/dist/setup-entry.js +15 -0
  31. package/dist/subagent-hooks-Dtegs0kh.js +235 -0
  32. package/dist/subagent-hooks-api.js +23 -0
  33. package/dist/targets-DFskxX4p.js +48 -0
  34. package/dist/thread-bindings-DI7lVSOE.js +222 -0
  35. package/package.json +20 -7
  36. package/api.js +0 -7
  37. package/channel-entry.js +0 -7
  38. package/channel-plugin-api.js +0 -7
  39. package/contract-api.js +0 -7
  40. package/index.js +0 -7
  41. package/runtime-api.js +0 -7
  42. package/secret-contract-api.js +0 -7
  43. package/security-contract-api.js +0 -7
  44. package/session-key-api.js +0 -7
  45. package/setup-api.js +0 -7
  46. package/setup-entry.js +0 -7
  47. package/subagent-hooks-api.js +0 -7
@@ -0,0 +1,100 @@
1
+ import { t as probeFeishu } from "./probe-CF4duEpK.js";
2
+ import { normalizeLowercaseStringOrEmpty } from "klaw/plugin-sdk/string-coerce-runtime";
3
+ import { WEBHOOK_ANOMALY_COUNTER_DEFAULTS, WEBHOOK_RATE_LIMIT_DEFAULTS, createFixedWindowRateLimiter, createWebhookAnomalyTracker } from "klaw/plugin-sdk/webhook-ingress";
4
+ //#region extensions/feishu/src/monitor.startup.ts
5
+ const FEISHU_STARTUP_BOT_INFO_TIMEOUT_DEFAULT_MS = 3e4;
6
+ const FEISHU_STARTUP_BOT_INFO_TIMEOUT_ENV = "KLAW_FEISHU_STARTUP_PROBE_TIMEOUT_MS";
7
+ function resolveStartupProbeTimeoutMs() {
8
+ const raw = process.env[FEISHU_STARTUP_BOT_INFO_TIMEOUT_ENV];
9
+ if (raw) {
10
+ const parsed = Number(raw);
11
+ if (Number.isFinite(parsed) && parsed > 0) return Math.floor(parsed);
12
+ console.warn(`[feishu] ${FEISHU_STARTUP_BOT_INFO_TIMEOUT_ENV}="${raw}" is invalid; using default ${FEISHU_STARTUP_BOT_INFO_TIMEOUT_DEFAULT_MS}ms`);
13
+ }
14
+ return FEISHU_STARTUP_BOT_INFO_TIMEOUT_DEFAULT_MS;
15
+ }
16
+ const FEISHU_STARTUP_BOT_INFO_TIMEOUT_MS = resolveStartupProbeTimeoutMs();
17
+ function isTimeoutErrorMessage(message) {
18
+ const lower = normalizeLowercaseStringOrEmpty(message);
19
+ return lower.includes("timeout") || lower.includes("timed out");
20
+ }
21
+ function isAbortErrorMessage(message) {
22
+ return normalizeLowercaseStringOrEmpty(message).includes("aborted");
23
+ }
24
+ async function fetchBotIdentityForMonitor(account, options = {}) {
25
+ if (options.abortSignal?.aborted) return {};
26
+ const timeoutMs = options.timeoutMs ?? FEISHU_STARTUP_BOT_INFO_TIMEOUT_MS;
27
+ const result = await probeFeishu(account, {
28
+ timeoutMs,
29
+ abortSignal: options.abortSignal
30
+ });
31
+ if (result.ok) return {
32
+ botOpenId: result.botOpenId,
33
+ botName: result.botName
34
+ };
35
+ const probeError = result.error ?? void 0;
36
+ if (options.abortSignal?.aborted || isAbortErrorMessage(probeError)) return {};
37
+ if (isTimeoutErrorMessage(probeError)) (options.runtime?.error ?? console.error)(`feishu[${account.accountId}]: bot info probe timed out after ${timeoutMs}ms; continuing startup`);
38
+ return {};
39
+ }
40
+ //#endregion
41
+ //#region extensions/feishu/src/monitor.state.ts
42
+ const wsClients = /* @__PURE__ */ new Map();
43
+ const httpServers = /* @__PURE__ */ new Map();
44
+ const botOpenIds = /* @__PURE__ */ new Map();
45
+ const botNames = /* @__PURE__ */ new Map();
46
+ const FEISHU_WEBHOOK_MAX_BODY_BYTES = 64 * 1024;
47
+ const FEISHU_WEBHOOK_BODY_TIMEOUT_MS = 5e3;
48
+ const FEISHU_WEBHOOK_RATE_LIMIT_FALLBACK_DEFAULTS = {
49
+ windowMs: 6e4,
50
+ maxRequests: 120,
51
+ maxTrackedKeys: 4096
52
+ };
53
+ const FEISHU_WEBHOOK_ANOMALY_FALLBACK_DEFAULTS = {
54
+ maxTrackedKeys: 4096,
55
+ ttlMs: 360 * 6e4,
56
+ logEvery: 25
57
+ };
58
+ function coercePositiveInt(value, fallback) {
59
+ if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
60
+ const normalized = Math.floor(value);
61
+ return normalized > 0 ? normalized : fallback;
62
+ }
63
+ function resolveFeishuWebhookRateLimitDefaultsForTest(defaults) {
64
+ const resolved = defaults;
65
+ return {
66
+ windowMs: coercePositiveInt(resolved?.windowMs, FEISHU_WEBHOOK_RATE_LIMIT_FALLBACK_DEFAULTS.windowMs),
67
+ maxRequests: coercePositiveInt(resolved?.maxRequests, FEISHU_WEBHOOK_RATE_LIMIT_FALLBACK_DEFAULTS.maxRequests),
68
+ maxTrackedKeys: coercePositiveInt(resolved?.maxTrackedKeys, FEISHU_WEBHOOK_RATE_LIMIT_FALLBACK_DEFAULTS.maxTrackedKeys)
69
+ };
70
+ }
71
+ function resolveFeishuWebhookAnomalyDefaultsForTest(defaults) {
72
+ const resolved = defaults;
73
+ return {
74
+ maxTrackedKeys: coercePositiveInt(resolved?.maxTrackedKeys, FEISHU_WEBHOOK_ANOMALY_FALLBACK_DEFAULTS.maxTrackedKeys),
75
+ ttlMs: coercePositiveInt(resolved?.ttlMs, FEISHU_WEBHOOK_ANOMALY_FALLBACK_DEFAULTS.ttlMs),
76
+ logEvery: coercePositiveInt(resolved?.logEvery, FEISHU_WEBHOOK_ANOMALY_FALLBACK_DEFAULTS.logEvery)
77
+ };
78
+ }
79
+ const feishuWebhookRateLimitDefaults = resolveFeishuWebhookRateLimitDefaultsForTest(WEBHOOK_RATE_LIMIT_DEFAULTS);
80
+ const feishuWebhookAnomalyDefaults = resolveFeishuWebhookAnomalyDefaultsForTest(WEBHOOK_ANOMALY_COUNTER_DEFAULTS);
81
+ const feishuWebhookRateLimiter = createFixedWindowRateLimiter({
82
+ windowMs: feishuWebhookRateLimitDefaults.windowMs,
83
+ maxRequests: feishuWebhookRateLimitDefaults.maxRequests,
84
+ maxTrackedKeys: feishuWebhookRateLimitDefaults.maxTrackedKeys
85
+ });
86
+ const feishuWebhookAnomalyTracker = createWebhookAnomalyTracker({
87
+ maxTrackedKeys: feishuWebhookAnomalyDefaults.maxTrackedKeys,
88
+ ttlMs: feishuWebhookAnomalyDefaults.ttlMs,
89
+ logEvery: feishuWebhookAnomalyDefaults.logEvery
90
+ });
91
+ function recordWebhookStatus(runtime, accountId, path, statusCode) {
92
+ feishuWebhookAnomalyTracker.record({
93
+ key: `${accountId}:${path}:${statusCode}`,
94
+ statusCode,
95
+ log: runtime?.log ?? console.log,
96
+ message: (count) => `feishu[${accountId}]: webhook anomaly path=${path} status=${statusCode} count=${count}`
97
+ });
98
+ }
99
+ //#endregion
100
+ export { feishuWebhookRateLimiter as a, wsClients as c, botOpenIds as i, fetchBotIdentityForMonitor as l, FEISHU_WEBHOOK_MAX_BODY_BYTES as n, httpServers as o, botNames as r, recordWebhookStatus as s, FEISHU_WEBHOOK_BODY_TIMEOUT_MS as t };
@@ -0,0 +1,149 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-DUslC3ob.js";
2
+ import { r as createFeishuClient } from "./client-D1pzbBGo.js";
3
+ import { formatErrorMessage } from "klaw/plugin-sdk/error-runtime";
4
+ //#region extensions/feishu/src/async.ts
5
+ const RACE_TIMEOUT = Symbol("race-timeout");
6
+ const RACE_ABORT = Symbol("race-abort");
7
+ async function raceWithTimeoutAndAbort(promise, options = {}) {
8
+ if (options.abortSignal?.aborted) return { status: "aborted" };
9
+ if (options.timeoutMs === void 0 && !options.abortSignal) return {
10
+ status: "resolved",
11
+ value: await promise
12
+ };
13
+ let timeoutHandle;
14
+ let abortHandler;
15
+ const contenders = [promise];
16
+ if (options.timeoutMs !== void 0) contenders.push(new Promise((resolve) => {
17
+ timeoutHandle = setTimeout(() => resolve(RACE_TIMEOUT), options.timeoutMs);
18
+ }));
19
+ if (options.abortSignal) contenders.push(new Promise((resolve) => {
20
+ abortHandler = () => resolve(RACE_ABORT);
21
+ options.abortSignal?.addEventListener("abort", abortHandler, { once: true });
22
+ }));
23
+ try {
24
+ const result = await Promise.race(contenders);
25
+ if (result === RACE_TIMEOUT) return { status: "timeout" };
26
+ if (result === RACE_ABORT) return { status: "aborted" };
27
+ return {
28
+ status: "resolved",
29
+ value: result
30
+ };
31
+ } finally {
32
+ if (timeoutHandle) clearTimeout(timeoutHandle);
33
+ if (abortHandler) options.abortSignal?.removeEventListener("abort", abortHandler);
34
+ }
35
+ }
36
+ function waitForAbortableDelay(delayMs, abortSignal) {
37
+ if (abortSignal?.aborted) return Promise.resolve(false);
38
+ return new Promise((resolve) => {
39
+ let settled = false;
40
+ let timer;
41
+ let handleAbort;
42
+ const finish = (value) => {
43
+ if (settled) return;
44
+ settled = true;
45
+ if (timer) clearTimeout(timer);
46
+ if (handleAbort) abortSignal?.removeEventListener("abort", handleAbort);
47
+ resolve(value);
48
+ };
49
+ handleAbort = () => {
50
+ finish(false);
51
+ };
52
+ abortSignal?.addEventListener("abort", handleAbort, { once: true });
53
+ if (abortSignal?.aborted) {
54
+ finish(false);
55
+ return;
56
+ }
57
+ timer = setTimeout(() => finish(true), delayMs);
58
+ timer.unref?.();
59
+ });
60
+ }
61
+ //#endregion
62
+ //#region extensions/feishu/src/probe.ts
63
+ var probe_exports = /* @__PURE__ */ __exportAll({
64
+ FEISHU_PROBE_REQUEST_TIMEOUT_MS: () => FEISHU_PROBE_REQUEST_TIMEOUT_MS,
65
+ probeFeishu: () => probeFeishu
66
+ });
67
+ /** Cache probe results to reduce repeated health-check calls.
68
+ * Gateway health checks call probeFeishu() every minute; without caching this
69
+ * burns ~43,200 calls/month, easily exceeding Feishu's free-tier quota.
70
+ * Successful bot info is effectively static, while failures are cached briefly
71
+ * to avoid hammering the API during transient outages. */
72
+ const probeCache = /* @__PURE__ */ new Map();
73
+ const PROBE_SUCCESS_TTL_MS = 600 * 1e3;
74
+ const PROBE_ERROR_TTL_MS = 60 * 1e3;
75
+ const MAX_PROBE_CACHE_SIZE = 64;
76
+ const FEISHU_PROBE_REQUEST_TIMEOUT_MS = 1e4;
77
+ function setCachedProbeResult(cacheKey, result, ttlMs) {
78
+ probeCache.set(cacheKey, {
79
+ result,
80
+ expiresAt: Date.now() + ttlMs
81
+ });
82
+ if (probeCache.size > MAX_PROBE_CACHE_SIZE) {
83
+ const oldest = probeCache.keys().next().value;
84
+ if (oldest !== void 0) probeCache.delete(oldest);
85
+ }
86
+ return result;
87
+ }
88
+ async function probeFeishu(creds, options = {}) {
89
+ if (!creds?.appId || !creds?.appSecret) return {
90
+ ok: false,
91
+ error: "missing credentials (appId, appSecret)"
92
+ };
93
+ if (options.abortSignal?.aborted) return {
94
+ ok: false,
95
+ appId: creds.appId,
96
+ error: "probe aborted"
97
+ };
98
+ const timeoutMs = options.timeoutMs ?? 1e4;
99
+ const cacheKey = creds.accountId ?? `${creds.appId}:${creds.appSecret.slice(0, 8)}`;
100
+ const cached = probeCache.get(cacheKey);
101
+ if (cached && cached.expiresAt > Date.now()) return cached.result;
102
+ try {
103
+ const responseResult = await raceWithTimeoutAndAbort(createFeishuClient(creds).request({
104
+ method: "POST",
105
+ url: "/open-apis/bot/v1/klaw_bot/ping",
106
+ data: { needBotInfo: true },
107
+ timeout: timeoutMs
108
+ }), {
109
+ timeoutMs,
110
+ abortSignal: options.abortSignal
111
+ });
112
+ if (responseResult.status === "aborted") return {
113
+ ok: false,
114
+ appId: creds.appId,
115
+ error: "probe aborted"
116
+ };
117
+ if (responseResult.status === "timeout") return setCachedProbeResult(cacheKey, {
118
+ ok: false,
119
+ appId: creds.appId,
120
+ error: `probe timed out after ${timeoutMs}ms`
121
+ }, PROBE_ERROR_TTL_MS);
122
+ const response = responseResult.value;
123
+ if (options.abortSignal?.aborted) return {
124
+ ok: false,
125
+ appId: creds.appId,
126
+ error: "probe aborted"
127
+ };
128
+ if (response.code !== 0) return setCachedProbeResult(cacheKey, {
129
+ ok: false,
130
+ appId: creds.appId,
131
+ error: `API error: ${response.msg || `code ${response.code}`}`
132
+ }, PROBE_ERROR_TTL_MS);
133
+ const botInfo = response.data?.pingBotInfo;
134
+ return setCachedProbeResult(cacheKey, {
135
+ ok: true,
136
+ appId: creds.appId,
137
+ botName: botInfo?.botName,
138
+ botOpenId: botInfo?.botID
139
+ }, PROBE_SUCCESS_TTL_MS);
140
+ } catch (err) {
141
+ return setCachedProbeResult(cacheKey, {
142
+ ok: false,
143
+ appId: creds.appId,
144
+ error: formatErrorMessage(err)
145
+ }, PROBE_ERROR_TTL_MS);
146
+ }
147
+ }
148
+ //#endregion
149
+ export { waitForAbortableDelay as i, probe_exports as n, raceWithTimeoutAndAbort as r, probeFeishu as t };
@@ -0,0 +1,14 @@
1
+ import "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ //#endregion
14
+ export { __exportAll as t };
@@ -0,0 +1,8 @@
1
+ import { createPluginRuntimeStore } from "klaw/plugin-sdk/runtime-store";
2
+ //#region extensions/feishu/src/runtime.ts
3
+ const { setRuntime: setFeishuRuntime, getRuntime: getFeishuRuntime } = createPluginRuntimeStore({
4
+ pluginId: "feishu",
5
+ errorMessage: "Feishu runtime not initialized"
6
+ });
7
+ //#endregion
8
+ export { setFeishuRuntime as n, getFeishuRuntime as t };
@@ -0,0 +1,14 @@
1
+ import { n as setFeishuRuntime } from "./runtime-DSh5rL_d.js";
2
+ import { normalizeAgentId } from "klaw/plugin-sdk/routing";
3
+ import { createReplyPrefixContext } from "klaw/plugin-sdk/channel-message";
4
+ import { createChannelPairingController } from "klaw/plugin-sdk/channel-pairing";
5
+ import { PAIRING_APPROVED_MESSAGE, buildProbeChannelStatusSummary, createDefaultChannelRuntimeState } from "klaw/plugin-sdk/channel-status";
6
+ import { chunkTextForOutbound } from "klaw/plugin-sdk/text-chunking";
7
+ import { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, createActionGate, createDedupeCache } from "klaw/plugin-sdk/core";
8
+ import { buildAgentMediaPayload } from "klaw/plugin-sdk/agent-media-payload";
9
+ import { evaluateSupplementalContextVisibility, filterSupplementalContextItems, resolveChannelContextVisibilityMode } from "klaw/plugin-sdk/context-visibility-runtime";
10
+ import { loadSessionStore, resolveSessionStoreEntry } from "klaw/plugin-sdk/session-store-runtime";
11
+ import { readJsonFileWithFallback } from "klaw/plugin-sdk/json-store";
12
+ import { createPersistentDedupe } from "klaw/plugin-sdk/persistent-dedupe";
13
+ import { isRequestBodyLimitError, readRequestBodyWithLimit, requestBodyErrorToText } from "klaw/plugin-sdk/webhook-ingress";
14
+ export { DEFAULT_ACCOUNT_ID, PAIRING_APPROVED_MESSAGE, buildAgentMediaPayload, buildChannelConfigSchema, buildProbeChannelStatusSummary, chunkTextForOutbound, createActionGate, createChannelPairingController, createDedupeCache, createDefaultChannelRuntimeState, createPersistentDedupe, createReplyPrefixContext, evaluateSupplementalContextVisibility, filterSupplementalContextItems, isRequestBodyLimitError, loadSessionStore, normalizeAgentId, readJsonFileWithFallback, readRequestBodyWithLimit, requestBodyErrorToText, resolveChannelContextVisibilityMode, resolveSessionStoreEntry, setFeishuRuntime };
@@ -0,0 +1,119 @@
1
+ import { collectConditionalChannelFieldAssignments, collectSimpleChannelFieldAssignments, getChannelSurface, hasOwnProperty, normalizeSecretStringValue } from "klaw/plugin-sdk/channel-secret-basic-runtime";
2
+ //#region extensions/feishu/src/secret-contract.ts
3
+ const secretTargetRegistryEntries = [
4
+ {
5
+ id: "channels.feishu.accounts.*.appSecret",
6
+ targetType: "channels.feishu.accounts.*.appSecret",
7
+ configFile: "klaw.json",
8
+ pathPattern: "channels.feishu.accounts.*.appSecret",
9
+ secretShape: "secret_input",
10
+ expectedResolvedValue: "string",
11
+ includeInPlan: true,
12
+ includeInConfigure: true,
13
+ includeInAudit: true
14
+ },
15
+ {
16
+ id: "channels.feishu.accounts.*.encryptKey",
17
+ targetType: "channels.feishu.accounts.*.encryptKey",
18
+ configFile: "klaw.json",
19
+ pathPattern: "channels.feishu.accounts.*.encryptKey",
20
+ secretShape: "secret_input",
21
+ expectedResolvedValue: "string",
22
+ includeInPlan: true,
23
+ includeInConfigure: true,
24
+ includeInAudit: true
25
+ },
26
+ {
27
+ id: "channels.feishu.accounts.*.verificationToken",
28
+ targetType: "channels.feishu.accounts.*.verificationToken",
29
+ configFile: "klaw.json",
30
+ pathPattern: "channels.feishu.accounts.*.verificationToken",
31
+ secretShape: "secret_input",
32
+ expectedResolvedValue: "string",
33
+ includeInPlan: true,
34
+ includeInConfigure: true,
35
+ includeInAudit: true
36
+ },
37
+ {
38
+ id: "channels.feishu.appSecret",
39
+ targetType: "channels.feishu.appSecret",
40
+ configFile: "klaw.json",
41
+ pathPattern: "channels.feishu.appSecret",
42
+ secretShape: "secret_input",
43
+ expectedResolvedValue: "string",
44
+ includeInPlan: true,
45
+ includeInConfigure: true,
46
+ includeInAudit: true
47
+ },
48
+ {
49
+ id: "channels.feishu.encryptKey",
50
+ targetType: "channels.feishu.encryptKey",
51
+ configFile: "klaw.json",
52
+ pathPattern: "channels.feishu.encryptKey",
53
+ secretShape: "secret_input",
54
+ expectedResolvedValue: "string",
55
+ includeInPlan: true,
56
+ includeInConfigure: true,
57
+ includeInAudit: true
58
+ },
59
+ {
60
+ id: "channels.feishu.verificationToken",
61
+ targetType: "channels.feishu.verificationToken",
62
+ configFile: "klaw.json",
63
+ pathPattern: "channels.feishu.verificationToken",
64
+ secretShape: "secret_input",
65
+ expectedResolvedValue: "string",
66
+ includeInPlan: true,
67
+ includeInConfigure: true,
68
+ includeInAudit: true
69
+ }
70
+ ];
71
+ function collectRuntimeConfigAssignments(params) {
72
+ const resolved = getChannelSurface(params.config, "feishu");
73
+ if (!resolved) return;
74
+ const { channel: feishu, surface } = resolved;
75
+ collectSimpleChannelFieldAssignments({
76
+ channelKey: "feishu",
77
+ field: "appSecret",
78
+ channel: feishu,
79
+ surface,
80
+ defaults: params.defaults,
81
+ context: params.context,
82
+ topInactiveReason: "no enabled account inherits this top-level Feishu appSecret.",
83
+ accountInactiveReason: "Feishu account is disabled."
84
+ });
85
+ const baseConnectionMode = normalizeSecretStringValue(feishu.connectionMode) === "webhook" ? "webhook" : "websocket";
86
+ const resolveAccountMode = (account) => hasOwnProperty(account, "connectionMode") ? normalizeSecretStringValue(account.connectionMode) : baseConnectionMode;
87
+ collectConditionalChannelFieldAssignments({
88
+ channelKey: "feishu",
89
+ field: "encryptKey",
90
+ channel: feishu,
91
+ surface,
92
+ defaults: params.defaults,
93
+ context: params.context,
94
+ topLevelActiveWithoutAccounts: baseConnectionMode === "webhook",
95
+ topLevelInheritedAccountActive: ({ account, enabled }) => enabled && !hasOwnProperty(account, "encryptKey") && resolveAccountMode(account) === "webhook",
96
+ accountActive: ({ account, enabled }) => enabled && resolveAccountMode(account) === "webhook",
97
+ topInactiveReason: "no enabled Feishu webhook-mode surface inherits this top-level encryptKey.",
98
+ accountInactiveReason: "Feishu account is disabled or not running in webhook mode."
99
+ });
100
+ collectConditionalChannelFieldAssignments({
101
+ channelKey: "feishu",
102
+ field: "verificationToken",
103
+ channel: feishu,
104
+ surface,
105
+ defaults: params.defaults,
106
+ context: params.context,
107
+ topLevelActiveWithoutAccounts: baseConnectionMode === "webhook",
108
+ topLevelInheritedAccountActive: ({ account, enabled }) => enabled && !hasOwnProperty(account, "verificationToken") && resolveAccountMode(account) === "webhook",
109
+ accountActive: ({ account, enabled }) => enabled && resolveAccountMode(account) === "webhook",
110
+ topInactiveReason: "no enabled Feishu webhook-mode surface inherits this top-level verificationToken.",
111
+ accountInactiveReason: "Feishu account is disabled or not running in webhook mode."
112
+ });
113
+ }
114
+ const channelSecrets = {
115
+ secretTargetRegistryEntries,
116
+ collectRuntimeConfigAssignments
117
+ };
118
+ //#endregion
119
+ export { collectRuntimeConfigAssignments as n, secretTargetRegistryEntries as r, channelSecrets as t };
@@ -0,0 +1,2 @@
1
+ import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries, t as channelSecrets } from "./secret-contract-NSee-WzN.js";
2
+ export { channelSecrets, collectRuntimeConfigAssignments, secretTargetRegistryEntries };
@@ -0,0 +1,11 @@
1
+ import "./security-audit-shared-Dpcwxeft.js";
2
+ //#region extensions/feishu/src/message-action-contract.ts
3
+ const messageActionTargetAliases = {
4
+ read: { aliases: ["messageId"] },
5
+ pin: { aliases: ["messageId"] },
6
+ unpin: { aliases: ["messageId"] },
7
+ "list-pins": { aliases: ["chatId"] },
8
+ "channel-info": { aliases: ["chatId"] }
9
+ };
10
+ //#endregion
11
+ export { messageActionTargetAliases as t };
@@ -0,0 +1,38 @@
1
+ import { hasConfiguredSecretInput } from "klaw/plugin-sdk/secret-input";
2
+ //#region extensions/feishu/src/security-audit-shared.ts
3
+ function asRecord(value) {
4
+ return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
5
+ }
6
+ function hasNonEmptyString(value) {
7
+ return typeof value === "string" && value.trim().length > 0;
8
+ }
9
+ function isFeishuDocToolEnabled(cfg) {
10
+ const feishu = asRecord(asRecord(cfg.channels)?.feishu);
11
+ if (!feishu || feishu.enabled === false) return false;
12
+ const baseTools = asRecord(feishu.tools);
13
+ const baseDocEnabled = baseTools?.doc !== false;
14
+ const baseAppId = hasNonEmptyString(feishu.appId);
15
+ const baseAppSecret = hasConfiguredSecretInput(feishu.appSecret, cfg.secrets?.defaults);
16
+ const baseConfigured = baseAppId && baseAppSecret;
17
+ const accounts = asRecord(feishu.accounts);
18
+ if (!accounts || Object.keys(accounts).length === 0) return baseDocEnabled && baseConfigured;
19
+ for (const accountValue of Object.values(accounts)) {
20
+ const account = asRecord(accountValue) ?? {};
21
+ if (account.enabled === false) continue;
22
+ if (!((asRecord(account.tools) ?? baseTools)?.doc !== false)) continue;
23
+ if ((hasNonEmptyString(account.appId) || baseAppId) && (hasConfiguredSecretInput(account.appSecret, cfg.secrets?.defaults) || baseAppSecret)) return true;
24
+ }
25
+ return false;
26
+ }
27
+ function collectFeishuSecurityAuditFindings(params) {
28
+ if (!isFeishuDocToolEnabled(params.cfg)) return [];
29
+ return [{
30
+ checkId: "channels.feishu.doc_owner_open_id",
31
+ severity: "warn",
32
+ title: "Feishu doc create can grant requester permissions",
33
+ detail: "channels.feishu tools include \"doc\"; feishu_doc action \"create\" can grant document access to the trusted requesting Feishu user.",
34
+ remediation: "Disable channels.feishu.tools.doc when not needed, and restrict tool access for untrusted prompts."
35
+ }];
36
+ }
37
+ //#endregion
38
+ export { collectFeishuSecurityAuditFindings as t };
@@ -0,0 +1,2 @@
1
+ import { t as collectFeishuSecurityAuditFindings } from "./security-audit-shared-Dpcwxeft.js";
2
+ export { collectFeishuSecurityAuditFindings };