@openclaw/feishu 2026.6.33 → 2026.6.35
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/dist/api.js +3 -3
- package/dist/{channel-CJZM55mB.js → channel-We0XLs41.js} +4 -4
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-DC21Vx4J.js → channel.runtime-C87TM6Nf.js} +5 -5
- package/dist/{client-BwgAJuvo.js → client-D-eyvVn6.js} +2 -5
- package/dist/{drive-djUl8IRC.js → drive-DHEQt4No.js} +1 -1
- package/dist/{monitor-BZS7ekeI.js → monitor-Bbkm5wOd.js} +2 -2
- package/dist/{monitor.account-D5SNO1bC.js → monitor.account-BR2lDLpY.js} +135 -63
- package/dist/{monitor.state-CGL1occz.js → monitor.state-BtuWakmU.js} +1 -1
- package/dist/{probe-EyeJQb3C.js → probe-DnmqazOw.js} +1 -1
- package/dist/{send-B0nDqief.js → send-DoOi2RJc.js} +1 -1
- package/dist/setup-api.js +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.js +145 -188
- package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/light/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.js +33 -76
- package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.js +168 -208
- package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
- package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
- package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
- package/node_modules/protobufjs/index.d.ts +0 -8
- package/node_modules/protobufjs/package.json +2 -3
- package/node_modules/protobufjs/src/parse.js +3 -0
- package/node_modules/protobufjs/src/util/minimal.js +0 -3
- package/npm-shrinkwrap.json +6 -13
- package/package.json +4 -4
- package/node_modules/@protobufjs/inquire/CHANGELOG.md +0 -8
- package/node_modules/@protobufjs/inquire/LICENSE +0 -26
- package/node_modules/@protobufjs/inquire/README.md +0 -13
- package/node_modules/@protobufjs/inquire/index.d.ts +0 -10
- package/node_modules/@protobufjs/inquire/index.js +0 -38
- package/node_modules/@protobufjs/inquire/package.json +0 -21
- package/node_modules/@protobufjs/inquire/tests/data/array.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/emptyArray.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/emptyObject.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/data/object.js +0 -1
- package/node_modules/@protobufjs/inquire/tests/index.js +0 -20
package/dist/api.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as listEnabledFeishuAccounts } from "./accounts-Cfzht2Hc.js";
|
|
2
|
-
import { a as setFeishuNamedAccountEnabled, i as feishuSetupAdapter, n as feishuSetupWizard, r as runFeishuLogin, t as feishuPlugin } from "./channel-
|
|
2
|
+
import { a as setFeishuNamedAccountEnabled, i as feishuSetupAdapter, n as feishuSetupWizard, r as runFeishuLogin, t as feishuPlugin } from "./channel-We0XLs41.js";
|
|
3
3
|
import { a as parseFeishuTargetId, i as parseFeishuDirectConversationId, n as buildFeishuModelOverrideParentCandidates, r as parseFeishuConversationId, t as buildFeishuConversationId } from "./conversation-id-DuL575sn.js";
|
|
4
4
|
import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.js";
|
|
5
|
-
import { r as createFeishuClient } from "./client-
|
|
6
|
-
import { a as jsonToolResult, d as registerFeishuChatTools, f as createFeishuToolClient, h as resolveToolsConfig, m as resolveFeishuToolAccount, n as registerFeishuDriveTools, o as toolExecutionErrorResult, p as resolveAnyEnabledFeishuToolsConfig, s as unknownToolActionResult } from "./drive-
|
|
5
|
+
import { r as createFeishuClient } from "./client-D-eyvVn6.js";
|
|
6
|
+
import { a as jsonToolResult, d as registerFeishuChatTools, f as createFeishuToolClient, h as resolveToolsConfig, m as resolveFeishuToolAccount, n as registerFeishuDriveTools, o as toolExecutionErrorResult, p as resolveAnyEnabledFeishuToolsConfig, s as unknownToolActionResult } from "./drive-DHEQt4No.js";
|
|
7
7
|
import { n as getFeishuThreadBindingManager, r as testing, t as createFeishuThreadBindingManager } from "./thread-bindings-V0bwk0A1.js";
|
|
8
8
|
import { n as handleFeishuSubagentEnded, r as handleFeishuSubagentSpawning, t as handleFeishuSubagentDeliveryTarget } from "./subagent-hooks-1pqt5tAA.js";
|
|
9
9
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, readStringValue, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -1659,7 +1659,7 @@ const feishuSetupWizard = {
|
|
|
1659
1659
|
});
|
|
1660
1660
|
let probeResult = null;
|
|
1661
1661
|
if (configured && account.configured) try {
|
|
1662
|
-
const { probeFeishu } = await import("./probe-
|
|
1662
|
+
const { probeFeishu } = await import("./probe-DnmqazOw.js").then((n) => n.n);
|
|
1663
1663
|
probeResult = await probeFeishu(account);
|
|
1664
1664
|
} catch {}
|
|
1665
1665
|
if (!configured) return [formatFeishuStatusLine("needs-credentials")];
|
|
@@ -1735,7 +1735,7 @@ const meta = {
|
|
|
1735
1735
|
order: 70,
|
|
1736
1736
|
preferSessionLookupForAnnounceTarget: true
|
|
1737
1737
|
};
|
|
1738
|
-
const loadFeishuChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-
|
|
1738
|
+
const loadFeishuChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-C87TM6Nf.js"), "feishuChannelRuntime");
|
|
1739
1739
|
function toFeishuMessageSendResult(result, kind) {
|
|
1740
1740
|
const receipt = result.receipt ?? createFeishuSendReceipt({
|
|
1741
1741
|
messageId: result.messageId,
|
|
@@ -1767,7 +1767,7 @@ const feishuMessageAdapter = defineChannelMessageAdapter({
|
|
|
1767
1767
|
}
|
|
1768
1768
|
});
|
|
1769
1769
|
async function createFeishuActionClient(account) {
|
|
1770
|
-
const { createFeishuClient } = await import("./client-
|
|
1770
|
+
const { createFeishuClient } = await import("./client-D-eyvVn6.js").then((n) => n.t);
|
|
1771
1771
|
return createFeishuClient(account);
|
|
1772
1772
|
}
|
|
1773
1773
|
const collectFeishuSecurityWarnings = createAllowlistProviderGroupPolicyWarningCollector({
|
|
@@ -2551,7 +2551,7 @@ const feishuPlugin = createChatChannelPlugin({
|
|
|
2551
2551
|
})
|
|
2552
2552
|
}),
|
|
2553
2553
|
gateway: { startAccount: async (ctx) => {
|
|
2554
|
-
const { monitorFeishuProvider } = await import("./monitor-
|
|
2554
|
+
const { monitorFeishuProvider } = await import("./monitor-Bbkm5wOd.js");
|
|
2555
2555
|
const account = resolveFeishuRuntimeAccount({
|
|
2556
2556
|
cfg: ctx.cfg,
|
|
2557
2557
|
accountId: ctx.accountId
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as feishuPlugin } from "./channel-
|
|
1
|
+
import { t as feishuPlugin } from "./channel-We0XLs41.js";
|
|
2
2
|
export { feishuPlugin };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { o as resolveFeishuAccount, s as resolveFeishuRuntimeAccount, v as parseFeishuCommentTarget } from "./accounts-Cfzht2Hc.js";
|
|
2
|
-
import { h as listFeishuDirectoryPeers, m as listFeishuDirectoryGroups, o as buildFeishuPresentationCardElements } from "./channel-
|
|
3
|
-
import { r as createFeishuClient } from "./client-
|
|
4
|
-
import { c as getChatInfo, l as getChatMembers, r as cleanupAmbientCommentTypingReaction, t as deliverCommentThreadText, u as getFeishuMemberInfo } from "./drive-
|
|
2
|
+
import { h as listFeishuDirectoryPeers, m as listFeishuDirectoryGroups, o as buildFeishuPresentationCardElements } from "./channel-We0XLs41.js";
|
|
3
|
+
import { r as createFeishuClient } from "./client-D-eyvVn6.js";
|
|
4
|
+
import { c as getChatInfo, l as getChatMembers, r as cleanupAmbientCommentTypingReaction, t as deliverCommentThreadText, u as getFeishuMemberInfo } from "./drive-DHEQt4No.js";
|
|
5
5
|
import { chunkTextForOutbound } from "./runtime-api.js";
|
|
6
|
-
import { a as sendCardFeishu, c as sendStructuredCardFeishu, g as shouldSuppressFeishuTextForVoiceMedia, h as sendMediaFeishu, i as resolveFeishuCardTemplate, n as getMessageFeishu, o as sendMarkdownCardFeishu, s as sendMessageFeishu, t as editMessageFeishu } from "./send-
|
|
7
|
-
import { t as probeFeishu } from "./probe-
|
|
6
|
+
import { a as sendCardFeishu, c as sendStructuredCardFeishu, g as shouldSuppressFeishuTextForVoiceMedia, h as sendMediaFeishu, i as resolveFeishuCardTemplate, n as getMessageFeishu, o as sendMarkdownCardFeishu, s as sendMessageFeishu, t as editMessageFeishu } from "./send-DoOi2RJc.js";
|
|
7
|
+
import { t as probeFeishu } from "./probe-DnmqazOw.js";
|
|
8
8
|
import { interactiveReplyToPresentation, normalizeInteractiveReply, normalizeMessagePresentation, renderMessagePresentationFallbackText, resolveInteractiveTextFallback } from "openclaw/plugin-sdk/interactive-runtime";
|
|
9
9
|
import { isRecord, normalizeLowercaseStringOrEmpty, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
10
|
import path from "node:path";
|
|
@@ -38,10 +38,7 @@ var client_exports = /* @__PURE__ */ __exportAll({
|
|
|
38
38
|
});
|
|
39
39
|
const pluginVersion = readPluginPackageVersion({ require: createRequire(import.meta.url) });
|
|
40
40
|
const FEISHU_USER_AGENT = `openclaw-feishu-builtin/${pluginVersion}/${process.platform}`;
|
|
41
|
-
const FEISHU_WS_CONFIG = {
|
|
42
|
-
PingInterval: 30,
|
|
43
|
-
PingTimeout: 3
|
|
44
|
-
};
|
|
41
|
+
const FEISHU_WS_CONFIG = { pingTimeout: 3 };
|
|
45
42
|
/** User-Agent header value for all Feishu API requests. */
|
|
46
43
|
function getFeishuUserAgent() {
|
|
47
44
|
return FEISHU_USER_AGENT;
|
|
@@ -160,4 +157,4 @@ function createEventDispatcher(account) {
|
|
|
160
157
|
});
|
|
161
158
|
}
|
|
162
159
|
//#endregion
|
|
163
|
-
export { getFeishuUserAgent as a, createFeishuWSClient as i, createEventDispatcher as n, createFeishuClient as r, client_exports as t };
|
|
160
|
+
export { getFeishuUserAgent as a, createFeishuWSClient as i, createEventDispatcher as n, FEISHU_HTTP_TIMEOUT_MS as o, createFeishuClient as r, resolveConfiguredHttpTimeoutMs as s, client_exports as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as encodeQuery, d as isRecord$1, i as listFeishuAccountIds, l as extractReplyText, m as readString, o as resolveFeishuAccount, r as listEnabledFeishuAccounts, s as resolveFeishuRuntimeAccount, u as formatFeishuApiError, v as parseFeishuCommentTarget } from "./accounts-Cfzht2Hc.js";
|
|
2
|
-
import { r as createFeishuClient } from "./client-
|
|
2
|
+
import { r as createFeishuClient } from "./client-D-eyvVn6.js";
|
|
3
3
|
import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { optionalPositiveIntegerSchema } from "openclaw/plugin-sdk/channel-actions";
|
|
5
5
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as listEnabledFeishuAccounts, s as resolveFeishuRuntimeAccount } from "./accounts-Cfzht2Hc.js";
|
|
2
|
-
import { f as fetchBotIdentityForMonitor } from "./monitor.state-
|
|
2
|
+
import { f as fetchBotIdentityForMonitor } from "./monitor.state-BtuWakmU.js";
|
|
3
3
|
//#region extensions/feishu/src/monitor.ts
|
|
4
4
|
let monitorAccountRuntimePromise;
|
|
5
5
|
async function loadMonitorAccountRuntime() {
|
|
6
|
-
monitorAccountRuntimePromise ??= import("./monitor.account-
|
|
6
|
+
monitorAccountRuntimePromise ??= import("./monitor.account-BR2lDLpY.js");
|
|
7
7
|
return await monitorAccountRuntimePromise;
|
|
8
8
|
}
|
|
9
9
|
async function monitorFeishuProvider(opts = {}) {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { _ as normalizeCommentFileType, c as encodeQuery, d as isRecord$1, f as normalizeString, g as buildFeishuCommentTarget, h as requestFeishuApi, l as extractReplyText, m as readString, o as resolveFeishuAccount, p as parseCommentContentElements, s as resolveFeishuRuntimeAccount } from "./accounts-Cfzht2Hc.js";
|
|
2
2
|
import { i as resolveReceiveIdType } from "./targets-BUjQ1TcA.js";
|
|
3
|
-
import { c as normalizeFeishuAllowEntry, d as resolveFeishuGroupConversationIngressAccess, f as resolveFeishuGroupSenderActivationIngressAccess, l as resolveFeishuDmIngressAccess, p as resolveFeishuReplyPolicy, s as hasExplicitFeishuGroupConfig, u as resolveFeishuGroupConfig } from "./channel-
|
|
3
|
+
import { c as normalizeFeishuAllowEntry, d as resolveFeishuGroupConversationIngressAccess, f as resolveFeishuGroupSenderActivationIngressAccess, l as resolveFeishuDmIngressAccess, p as resolveFeishuReplyPolicy, s as hasExplicitFeishuGroupConfig, u as resolveFeishuGroupConfig } from "./channel-We0XLs41.js";
|
|
4
4
|
import { c as decodeFeishuCardAction, o as buildFeishuCardActionTextFallback, s as createFeishuCardInteractionEnvelope } from "./send-result-DSsIa4-p.js";
|
|
5
5
|
import { t as buildFeishuConversationId } from "./conversation-id-DuL575sn.js";
|
|
6
6
|
import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.js";
|
|
7
|
-
import { a as getFeishuUserAgent, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient } from "./client-
|
|
8
|
-
import { c as getChatInfo, i as createCommentTypingReactionLifecycle, t as deliverCommentThreadText } from "./drive-
|
|
7
|
+
import { a as getFeishuUserAgent, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient, s as resolveConfiguredHttpTimeoutMs } from "./client-D-eyvVn6.js";
|
|
8
|
+
import { c as getChatInfo, i as createCommentTypingReactionLifecycle, t as deliverCommentThreadText } from "./drive-DHEQt4No.js";
|
|
9
9
|
import { t as createFeishuThreadBindingManager } from "./thread-bindings-V0bwk0A1.js";
|
|
10
10
|
import { createReplyPrefixContext, evaluateSupplementalContextVisibility, loadSessionStore, normalizeAgentId as normalizeAgentId$2, resolveChannelContextVisibilityMode, resolveSessionStoreEntry } from "./runtime-api.js";
|
|
11
|
-
import { _ as normalizeFeishuExternalKey, a as sendCardFeishu, c as sendStructuredCardFeishu, d as isFeishuBroadcastMention, f as isMentionForwardRequest, g as shouldSuppressFeishuTextForVoiceMedia, h as sendMediaFeishu, i as resolveFeishuCardTemplate, l as parsePostContent, m as saveMessageResourceFeishu, n as getMessageFeishu, p as isFeishuGroupChatType, r as listFeishuThreadMessages, s as sendMessageFeishu, u as extractMentionTargets } from "./send-
|
|
12
|
-
import { i as waitForAbortableDelay, r as raceWithTimeoutAndAbort } from "./probe-
|
|
13
|
-
import { a as clearFeishuBotIdentityState, c as httpServers, d as wsClients, f as fetchBotIdentityForMonitor, i as botOpenIds, l as recordWebhookStatus, n as FEISHU_WEBHOOK_MAX_BODY_BYTES, o as closeTrackedFeishuHttpServer, r as botNames, s as feishuWebhookRateLimiter, t as FEISHU_WEBHOOK_BODY_TIMEOUT_MS, u as setFeishuBotIdentityState } from "./monitor.state-
|
|
11
|
+
import { _ as normalizeFeishuExternalKey, a as sendCardFeishu, c as sendStructuredCardFeishu, d as isFeishuBroadcastMention, f as isMentionForwardRequest, g as shouldSuppressFeishuTextForVoiceMedia, h as sendMediaFeishu, i as resolveFeishuCardTemplate, l as parsePostContent, m as saveMessageResourceFeishu, n as getMessageFeishu, p as isFeishuGroupChatType, r as listFeishuThreadMessages, s as sendMessageFeishu, u as extractMentionTargets } from "./send-DoOi2RJc.js";
|
|
12
|
+
import { i as waitForAbortableDelay, r as raceWithTimeoutAndAbort } from "./probe-DnmqazOw.js";
|
|
13
|
+
import { a as clearFeishuBotIdentityState, c as httpServers, d as wsClients, f as fetchBotIdentityForMonitor, i as botOpenIds, l as recordWebhookStatus, n as FEISHU_WEBHOOK_MAX_BODY_BYTES, o as closeTrackedFeishuHttpServer, r as botNames, s as feishuWebhookRateLimiter, t as FEISHU_WEBHOOK_BODY_TIMEOUT_MS, u as setFeishuBotIdentityState } from "./monitor.state-BtuWakmU.js";
|
|
14
14
|
import { createChannelMessageReplyPipeline, formatChannelProgressDraftLineForEntry, isChannelProgressDraftWorkToolName, resolveAgentOutboundIdentity } from "openclaw/plugin-sdk/channel-outbound";
|
|
15
15
|
import { createChannelPairingController, createChannelPairingController as createChannelPairingController$1 } from "openclaw/plugin-sdk/channel-pairing";
|
|
16
16
|
import { ensureConfiguredBindingRouteReady, resolveConfiguredBindingRoute, resolveRuntimeConversationBindingRoute } from "openclaw/plugin-sdk/conversation-runtime";
|
|
@@ -35,6 +35,8 @@ import { resolveDefaultGroupPolicy, resolveOpenProviderRuntimeGroupPolicy, warnM
|
|
|
35
35
|
import { resolveChannelConfigWrites } from "openclaw/plugin-sdk/channel-config-writes";
|
|
36
36
|
import { formatReasoningMessage } from "openclaw/plugin-sdk/agent-runtime";
|
|
37
37
|
import { logTypingFailure } from "openclaw/plugin-sdk/channel-feedback";
|
|
38
|
+
import { sliceUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
39
|
+
import { readProviderJsonResponse } from "openclaw/plugin-sdk/provider-http";
|
|
38
40
|
import * as http from "node:http";
|
|
39
41
|
import { installRequestBodyLimitGuard, readWebhookBodyOrReject } from "openclaw/plugin-sdk/webhook-request-guards";
|
|
40
42
|
import { isAbortRequestText, isBtwRequestText } from "openclaw/plugin-sdk/command-primitives-runtime";
|
|
@@ -855,6 +857,13 @@ function resolveFeishuReasoningPreviewEnabled(params) {
|
|
|
855
857
|
return configDefault === "stream";
|
|
856
858
|
}
|
|
857
859
|
//#endregion
|
|
860
|
+
//#region extensions/feishu/src/json-response.ts
|
|
861
|
+
/** Feishu control-plane JSON responses are tiny; 16 MiB leaves ample headroom. */
|
|
862
|
+
const FEISHU_JSON_MAX_BYTES = 16 * 1024 * 1024;
|
|
863
|
+
async function readFeishuJsonResponse(response, label = "feishu.api") {
|
|
864
|
+
return readProviderJsonResponse(response, label, { maxBytes: FEISHU_JSON_MAX_BYTES });
|
|
865
|
+
}
|
|
866
|
+
//#endregion
|
|
858
867
|
//#region extensions/feishu/src/streaming-card.ts
|
|
859
868
|
const STREAMING_UPDATE_THROTTLE_MS = 160;
|
|
860
869
|
const STREAMING_SIGNIFICANT_DELTA_CHARS = 18;
|
|
@@ -879,7 +888,18 @@ function resolveAllowedHostnames(domain) {
|
|
|
879
888
|
}
|
|
880
889
|
return ["open.feishu.cn"];
|
|
881
890
|
}
|
|
882
|
-
|
|
891
|
+
function cancelUnreadResponseBody(response) {
|
|
892
|
+
if (!response.bodyUsed) response.body?.cancel().catch(() => void 0);
|
|
893
|
+
}
|
|
894
|
+
async function assertSuccessfulCardKitResponse(response, auditContext, action) {
|
|
895
|
+
if (!response.ok) {
|
|
896
|
+
cancelUnreadResponseBody(response);
|
|
897
|
+
throw new Error(`${action} failed with HTTP ${response.status}`);
|
|
898
|
+
}
|
|
899
|
+
const data = await readFeishuJsonResponse(response, auditContext);
|
|
900
|
+
if (data.code !== 0) throw new Error(`${action} failed: ${data.msg ?? "unknown error"} (code=${String(data.code)})`);
|
|
901
|
+
}
|
|
902
|
+
async function getToken(creds, deps) {
|
|
883
903
|
const key = `${creds.domain ?? "feishu"}|${creds.appId}`;
|
|
884
904
|
const cached = tokenCache.get(key);
|
|
885
905
|
const rawNow = Date.now();
|
|
@@ -900,15 +920,22 @@ async function getToken(creds) {
|
|
|
900
920
|
app_secret: creds.appSecret
|
|
901
921
|
})
|
|
902
922
|
},
|
|
923
|
+
fetchImpl: deps?.fetchImpl,
|
|
924
|
+
lookupFn: deps?.lookupFn,
|
|
903
925
|
policy: { allowedHostnames: resolveAllowedHostnames(creds.domain) },
|
|
904
|
-
auditContext: "feishu.streaming-card.token"
|
|
926
|
+
auditContext: "feishu.streaming-card.token",
|
|
927
|
+
timeoutMs: creds.httpTimeoutMs ?? 3e4
|
|
905
928
|
});
|
|
906
|
-
|
|
929
|
+
let data;
|
|
930
|
+
try {
|
|
931
|
+
if (!response.ok) {
|
|
932
|
+
cancelUnreadResponseBody(response);
|
|
933
|
+
throw new Error(`Token request failed with HTTP ${response.status}`);
|
|
934
|
+
}
|
|
935
|
+
data = await readFeishuJsonResponse(response, "feishu.streaming-card.token");
|
|
936
|
+
} finally {
|
|
907
937
|
await release();
|
|
908
|
-
throw new Error(`Token request failed with HTTP ${response.status}`);
|
|
909
938
|
}
|
|
910
|
-
const data = await response.json();
|
|
911
|
-
await release();
|
|
912
939
|
if (data.code !== 0 || !data.tenant_access_token) throw new Error(`Token error: ${data.msg}`);
|
|
913
940
|
tokenCache.set(key, {
|
|
914
941
|
token: data.tenant_access_token,
|
|
@@ -919,7 +946,7 @@ async function getToken(creds) {
|
|
|
919
946
|
function truncateSummary(text, max = 50) {
|
|
920
947
|
if (!text) return "";
|
|
921
948
|
const clean = text.replace(/\n/g, " ").trim();
|
|
922
|
-
return clean.length <= max ? clean : clean
|
|
949
|
+
return clean.length <= max ? clean : sliceUtf16Safe(clean, 0, max - 3) + "...";
|
|
923
950
|
}
|
|
924
951
|
function hasNaturalStreamingBoundary(text) {
|
|
925
952
|
return /[\n。!?!?;;::]$/.test(text);
|
|
@@ -949,7 +976,7 @@ function resolveStreamingCardSendMode(options) {
|
|
|
949
976
|
}
|
|
950
977
|
/** Streaming card session manager */
|
|
951
978
|
var FeishuStreamingSession = class {
|
|
952
|
-
constructor(client, creds, log) {
|
|
979
|
+
constructor(client, creds, log, deps) {
|
|
953
980
|
this.state = null;
|
|
954
981
|
this.queue = Promise.resolve();
|
|
955
982
|
this.closed = false;
|
|
@@ -960,6 +987,8 @@ var FeishuStreamingSession = class {
|
|
|
960
987
|
this.client = client;
|
|
961
988
|
this.creds = creds;
|
|
962
989
|
this.log = log;
|
|
990
|
+
this.fetchImpl = deps?.fetchImpl;
|
|
991
|
+
this.lookupFn = deps?.lookupFn;
|
|
963
992
|
}
|
|
964
993
|
async start(receiveId, receiveIdType = "chat_id", options) {
|
|
965
994
|
if (this.state) return;
|
|
@@ -1001,7 +1030,10 @@ var FeishuStreamingSession = class {
|
|
|
1001
1030
|
init: {
|
|
1002
1031
|
method: "POST",
|
|
1003
1032
|
headers: {
|
|
1004
|
-
Authorization: `Bearer ${await getToken(this.creds
|
|
1033
|
+
Authorization: `Bearer ${await getToken(this.creds, {
|
|
1034
|
+
fetchImpl: this.fetchImpl,
|
|
1035
|
+
lookupFn: this.lookupFn
|
|
1036
|
+
})}`,
|
|
1005
1037
|
"Content-Type": "application/json",
|
|
1006
1038
|
"User-Agent": getFeishuUserAgent()
|
|
1007
1039
|
},
|
|
@@ -1010,15 +1042,22 @@ var FeishuStreamingSession = class {
|
|
|
1010
1042
|
data: JSON.stringify(cardJson)
|
|
1011
1043
|
})
|
|
1012
1044
|
},
|
|
1045
|
+
fetchImpl: this.fetchImpl,
|
|
1046
|
+
lookupFn: this.lookupFn,
|
|
1013
1047
|
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
|
|
1014
|
-
auditContext: "feishu.streaming-card.create"
|
|
1048
|
+
auditContext: "feishu.streaming-card.create",
|
|
1049
|
+
timeoutMs: this.creds.httpTimeoutMs ?? 3e4
|
|
1015
1050
|
});
|
|
1016
|
-
|
|
1051
|
+
let createData;
|
|
1052
|
+
try {
|
|
1053
|
+
if (!createRes.ok) {
|
|
1054
|
+
cancelUnreadResponseBody(createRes);
|
|
1055
|
+
throw new Error(`Create card request failed with HTTP ${createRes.status}`);
|
|
1056
|
+
}
|
|
1057
|
+
createData = await readFeishuJsonResponse(createRes, "feishu.streaming-card.create");
|
|
1058
|
+
} finally {
|
|
1017
1059
|
await releaseCreate();
|
|
1018
|
-
throw new Error(`Create card request failed with HTTP ${createRes.status}`);
|
|
1019
1060
|
}
|
|
1020
|
-
const createData = await createRes.json();
|
|
1021
|
-
await releaseCreate();
|
|
1022
1061
|
if (createData.code !== 0 || !createData.data?.card_id) throw new Error(`Create card failed: ${createData.msg}`);
|
|
1023
1062
|
const cardId = createData.data.card_id;
|
|
1024
1063
|
const cardContent = JSON.stringify({
|
|
@@ -1073,7 +1112,10 @@ var FeishuStreamingSession = class {
|
|
|
1073
1112
|
init: {
|
|
1074
1113
|
method: "PUT",
|
|
1075
1114
|
headers: {
|
|
1076
|
-
Authorization: `Bearer ${await getToken(this.creds
|
|
1115
|
+
Authorization: `Bearer ${await getToken(this.creds, {
|
|
1116
|
+
fetchImpl: this.fetchImpl,
|
|
1117
|
+
lookupFn: this.lookupFn
|
|
1118
|
+
})}`,
|
|
1077
1119
|
"Content-Type": "application/json",
|
|
1078
1120
|
"User-Agent": getFeishuUserAgent()
|
|
1079
1121
|
},
|
|
@@ -1083,13 +1125,16 @@ var FeishuStreamingSession = class {
|
|
|
1083
1125
|
uuid: `s_${this.state.cardId}_${this.state.sequence}`
|
|
1084
1126
|
})
|
|
1085
1127
|
},
|
|
1128
|
+
fetchImpl: this.fetchImpl,
|
|
1129
|
+
lookupFn: this.lookupFn,
|
|
1086
1130
|
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
|
|
1087
|
-
auditContext: "feishu.streaming-card.update"
|
|
1131
|
+
auditContext: "feishu.streaming-card.update",
|
|
1132
|
+
timeoutMs: this.creds.httpTimeoutMs ?? 3e4
|
|
1088
1133
|
});
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1134
|
+
try {
|
|
1135
|
+
await assertSuccessfulCardKitResponse(response, "feishu.streaming-card.update", "Update card content");
|
|
1136
|
+
} finally {
|
|
1137
|
+
await release();
|
|
1093
1138
|
}
|
|
1094
1139
|
return true;
|
|
1095
1140
|
} catch (error) {
|
|
@@ -1107,7 +1152,10 @@ var FeishuStreamingSession = class {
|
|
|
1107
1152
|
init: {
|
|
1108
1153
|
method: "PUT",
|
|
1109
1154
|
headers: {
|
|
1110
|
-
Authorization: `Bearer ${await getToken(this.creds
|
|
1155
|
+
Authorization: `Bearer ${await getToken(this.creds, {
|
|
1156
|
+
fetchImpl: this.fetchImpl,
|
|
1157
|
+
lookupFn: this.lookupFn
|
|
1158
|
+
})}`,
|
|
1111
1159
|
"Content-Type": "application/json",
|
|
1112
1160
|
"User-Agent": getFeishuUserAgent()
|
|
1113
1161
|
},
|
|
@@ -1121,13 +1169,16 @@ var FeishuStreamingSession = class {
|
|
|
1121
1169
|
uuid: `r_${this.state.cardId}_${this.state.sequence}`
|
|
1122
1170
|
})
|
|
1123
1171
|
},
|
|
1172
|
+
fetchImpl: this.fetchImpl,
|
|
1173
|
+
lookupFn: this.lookupFn,
|
|
1124
1174
|
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
|
|
1125
|
-
auditContext: "feishu.streaming-card.replace"
|
|
1175
|
+
auditContext: "feishu.streaming-card.replace",
|
|
1176
|
+
timeoutMs: this.creds.httpTimeoutMs ?? 3e4
|
|
1126
1177
|
});
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1178
|
+
try {
|
|
1179
|
+
await assertSuccessfulCardKitResponse(response, "feishu.streaming-card.replace", "Replace card content");
|
|
1180
|
+
} finally {
|
|
1181
|
+
await release();
|
|
1131
1182
|
}
|
|
1132
1183
|
return true;
|
|
1133
1184
|
} catch (error) {
|
|
@@ -1146,35 +1197,35 @@ var FeishuStreamingSession = class {
|
|
|
1146
1197
|
const delayMs = Math.max(0, this.updateThrottleMs - (Date.now() - this.lastUpdateTime));
|
|
1147
1198
|
this.flushTimer = setTimeout(() => {
|
|
1148
1199
|
this.flushTimer = null;
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
this.update(
|
|
1200
|
+
if (!this.pendingText || this.closed) return;
|
|
1201
|
+
this.lastUpdateTime = Date.now();
|
|
1202
|
+
this.flushPendingUpdate().catch((error) => this.log?.(`Scheduled flush update failed: ${String(error)}`));
|
|
1152
1203
|
}, delayMs);
|
|
1153
1204
|
}
|
|
1205
|
+
async flushPendingUpdate() {
|
|
1206
|
+
this.queue = this.queue.then(async () => {
|
|
1207
|
+
if (!this.state || this.closed) return;
|
|
1208
|
+
const nextText = this.pendingText;
|
|
1209
|
+
if (!nextText) return;
|
|
1210
|
+
this.pendingText = null;
|
|
1211
|
+
if (nextText === this.state.sentText) return;
|
|
1212
|
+
if (await this.updateCardContent(nextText, (e) => this.log?.(`Update failed: ${String(e)}`)) && this.state) this.state.sentText = nextText;
|
|
1213
|
+
});
|
|
1214
|
+
await this.queue;
|
|
1215
|
+
}
|
|
1154
1216
|
async update(text) {
|
|
1155
|
-
if (!this.state || this.closed) return;
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
this.pendingText = mergedInput;
|
|
1217
|
+
if (!this.state || this.closed || !text) return;
|
|
1218
|
+
this.state.currentText = text;
|
|
1219
|
+
this.pendingText = text;
|
|
1159
1220
|
this.clearFlushTimer();
|
|
1160
|
-
const shouldForceUpdate = shouldPushStreamingUpdate(this.state.
|
|
1221
|
+
const shouldForceUpdate = shouldPushStreamingUpdate(this.state.sentText, text);
|
|
1161
1222
|
const now = Date.now();
|
|
1162
1223
|
if (!shouldForceUpdate && now - this.lastUpdateTime < this.updateThrottleMs) {
|
|
1163
1224
|
this.schedulePendingFlush();
|
|
1164
1225
|
return;
|
|
1165
1226
|
}
|
|
1166
1227
|
this.lastUpdateTime = now;
|
|
1167
|
-
|
|
1168
|
-
if (!this.state || this.closed) return;
|
|
1169
|
-
const nextText = this.pendingText ?? mergedInput;
|
|
1170
|
-
const mergedText = mergeStreamingText(this.state.currentText, nextText);
|
|
1171
|
-
if (!mergedText || mergedText === this.state.currentText) return;
|
|
1172
|
-
if (mergedText === this.state.sentText) return;
|
|
1173
|
-
this.pendingText = null;
|
|
1174
|
-
this.state.currentText = mergedText;
|
|
1175
|
-
if (await this.updateCardContent(mergedText, (e) => this.log?.(`Update failed: ${String(e)}`)) && this.state) this.state.sentText = mergedText;
|
|
1176
|
-
});
|
|
1177
|
-
await this.queue;
|
|
1228
|
+
await this.flushPendingUpdate();
|
|
1178
1229
|
}
|
|
1179
1230
|
async updateNoteContent(note) {
|
|
1180
1231
|
if (!this.state || !this.state.hasNote) return;
|
|
@@ -1185,7 +1236,10 @@ var FeishuStreamingSession = class {
|
|
|
1185
1236
|
init: {
|
|
1186
1237
|
method: "PUT",
|
|
1187
1238
|
headers: {
|
|
1188
|
-
Authorization: `Bearer ${await getToken(this.creds
|
|
1239
|
+
Authorization: `Bearer ${await getToken(this.creds, {
|
|
1240
|
+
fetchImpl: this.fetchImpl,
|
|
1241
|
+
lookupFn: this.lookupFn
|
|
1242
|
+
})}`,
|
|
1189
1243
|
"Content-Type": "application/json",
|
|
1190
1244
|
"User-Agent": getFeishuUserAgent()
|
|
1191
1245
|
},
|
|
@@ -1195,10 +1249,17 @@ var FeishuStreamingSession = class {
|
|
|
1195
1249
|
uuid: `n_${this.state.cardId}_${this.state.sequence}`
|
|
1196
1250
|
})
|
|
1197
1251
|
},
|
|
1252
|
+
fetchImpl: this.fetchImpl,
|
|
1253
|
+
lookupFn: this.lookupFn,
|
|
1198
1254
|
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
|
|
1199
|
-
auditContext: "feishu.streaming-card.note-update"
|
|
1200
|
-
|
|
1201
|
-
|
|
1255
|
+
auditContext: "feishu.streaming-card.note-update",
|
|
1256
|
+
timeoutMs: this.creds.httpTimeoutMs ?? 3e4
|
|
1257
|
+
}).then(async ({ response, release }) => {
|
|
1258
|
+
try {
|
|
1259
|
+
await assertSuccessfulCardKitResponse(response, "feishu.streaming-card.note-update", "Update card note");
|
|
1260
|
+
} finally {
|
|
1261
|
+
await release();
|
|
1262
|
+
}
|
|
1202
1263
|
}).catch((e) => this.log?.(`Note update failed: ${String(e)}`));
|
|
1203
1264
|
}
|
|
1204
1265
|
async close(finalText, options) {
|
|
@@ -1206,8 +1267,7 @@ var FeishuStreamingSession = class {
|
|
|
1206
1267
|
this.closed = true;
|
|
1207
1268
|
this.clearFlushTimer();
|
|
1208
1269
|
await this.queue;
|
|
1209
|
-
const
|
|
1210
|
-
const text = finalText ?? pendingMerged;
|
|
1270
|
+
const text = finalText ?? this.pendingText ?? this.state.currentText;
|
|
1211
1271
|
const apiBase = resolveApiBase(this.creds.domain);
|
|
1212
1272
|
let visibleContentSent = Boolean(this.state.sentText.trim());
|
|
1213
1273
|
if ((text || finalText !== void 0) && text !== this.state.sentText) {
|
|
@@ -1219,29 +1279,40 @@ var FeishuStreamingSession = class {
|
|
|
1219
1279
|
}
|
|
1220
1280
|
}
|
|
1221
1281
|
if (options?.note) await this.updateNoteContent(options.note);
|
|
1282
|
+
const acceptedText = this.state.sentText;
|
|
1222
1283
|
this.state.sequence += 1;
|
|
1223
1284
|
await fetchWithSsrFGuard({
|
|
1224
1285
|
url: `${apiBase}/cardkit/v1/cards/${this.state.cardId}/settings`,
|
|
1225
1286
|
init: {
|
|
1226
1287
|
method: "PATCH",
|
|
1227
1288
|
headers: {
|
|
1228
|
-
Authorization: `Bearer ${await getToken(this.creds
|
|
1289
|
+
Authorization: `Bearer ${await getToken(this.creds, {
|
|
1290
|
+
fetchImpl: this.fetchImpl,
|
|
1291
|
+
lookupFn: this.lookupFn
|
|
1292
|
+
})}`,
|
|
1229
1293
|
"Content-Type": "application/json; charset=utf-8",
|
|
1230
1294
|
"User-Agent": getFeishuUserAgent()
|
|
1231
1295
|
},
|
|
1232
1296
|
body: JSON.stringify({
|
|
1233
1297
|
settings: JSON.stringify({ config: {
|
|
1234
1298
|
streaming_mode: false,
|
|
1235
|
-
summary: { content: truncateSummary(
|
|
1299
|
+
summary: { content: truncateSummary(acceptedText) }
|
|
1236
1300
|
} }),
|
|
1237
1301
|
sequence: this.state.sequence,
|
|
1238
1302
|
uuid: `c_${this.state.cardId}_${this.state.sequence}`
|
|
1239
1303
|
})
|
|
1240
1304
|
},
|
|
1305
|
+
fetchImpl: this.fetchImpl,
|
|
1306
|
+
lookupFn: this.lookupFn,
|
|
1241
1307
|
policy: { allowedHostnames: resolveAllowedHostnames(this.creds.domain) },
|
|
1242
|
-
auditContext: "feishu.streaming-card.close"
|
|
1243
|
-
|
|
1244
|
-
|
|
1308
|
+
auditContext: "feishu.streaming-card.close",
|
|
1309
|
+
timeoutMs: this.creds.httpTimeoutMs ?? 3e4
|
|
1310
|
+
}).then(async ({ response, release }) => {
|
|
1311
|
+
try {
|
|
1312
|
+
await assertSuccessfulCardKitResponse(response, "feishu.streaming-card.close", "Close streaming card");
|
|
1313
|
+
} finally {
|
|
1314
|
+
await release();
|
|
1315
|
+
}
|
|
1245
1316
|
}).catch((e) => this.log?.(`Close failed: ${String(e)}`));
|
|
1246
1317
|
const finalState = this.state;
|
|
1247
1318
|
this.state = null;
|
|
@@ -1604,7 +1675,8 @@ function createFeishuReplyDispatcher(params) {
|
|
|
1604
1675
|
const creds = account.appId && account.appSecret ? {
|
|
1605
1676
|
appId: account.appId,
|
|
1606
1677
|
appSecret: account.appSecret,
|
|
1607
|
-
domain: account.domain
|
|
1678
|
+
domain: account.domain,
|
|
1679
|
+
httpTimeoutMs: resolveConfiguredHttpTimeoutMs(account)
|
|
1608
1680
|
} : null;
|
|
1609
1681
|
if (!creds) return;
|
|
1610
1682
|
streaming = new FeishuStreamingSession(createFeishuClient(account), creds, (message) => params.runtime.log?.(`feishu[${account.accountId}] ${message}`));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as probeFeishu } from "./probe-
|
|
1
|
+
import { t as probeFeishu } from "./probe-DnmqazOw.js";
|
|
2
2
|
import { parseStrictPositiveInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
3
3
|
import { normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { WEBHOOK_ANOMALY_COUNTER_DEFAULTS, WEBHOOK_RATE_LIMIT_DEFAULTS, createFixedWindowRateLimiter, createWebhookAnomalyTracker } from "openclaw/plugin-sdk/webhook-ingress";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
-
import { r as createFeishuClient } from "./client-
|
|
2
|
+
import { r as createFeishuClient } from "./client-D-eyvVn6.js";
|
|
3
3
|
import { asDateTimestampMs, resolveExpiresAtMsFromDurationMs, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
4
4
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
5
5
|
//#region extensions/feishu/src/async.ts
|
|
@@ -2,7 +2,7 @@ import { d as isRecord$1, h as requestFeishuApi, s as resolveFeishuRuntimeAccoun
|
|
|
2
2
|
import { i as resolveReceiveIdType, r as normalizeFeishuTarget } from "./targets-BUjQ1TcA.js";
|
|
3
3
|
import { i as toFeishuSendResult, r as resolveFeishuReceiptKind, t as assertFeishuMessageApiSuccess } from "./send-result-DSsIa4-p.js";
|
|
4
4
|
import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.js";
|
|
5
|
-
import { r as createFeishuClient } from "./client-
|
|
5
|
+
import { r as createFeishuClient } from "./client-D-eyvVn6.js";
|
|
6
6
|
import { parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
7
7
|
import { isRecord, normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
8
8
|
import { convertMarkdownTables } from "openclaw/plugin-sdk/text-chunking";
|
package/dist/setup-api.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as feishuSetupAdapter, n as feishuSetupWizard, t as feishuPlugin } from "./channel-
|
|
1
|
+
import { i as feishuSetupAdapter, n as feishuSetupWizard, t as feishuPlugin } from "./channel-We0XLs41.js";
|
|
2
2
|
export { feishuPlugin, feishuSetupAdapter, feishuSetupWizard };
|