@openclaw/feishu 2026.5.25-beta.1 → 2026.5.26-beta.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/dist/api.js +1 -1
- package/dist/{channel-CBVi0Pse.js → channel-DavfT_AA.js} +569 -12
- package/dist/channel-plugin-api.js +1 -1
- package/dist/{channel.runtime-qTiXSDEF.js → channel.runtime-ItBg9SfS.js} +1 -1
- package/dist/{monitor-OdRQj8yf.js → monitor-gFxvkDyO.js} +1 -1
- package/dist/{monitor.account-DilSvSo7.js → monitor.account-CmXHWuwG.js} +9 -9
- package/dist/runtime-api.js +1 -1
- package/dist/setup-api.js +1 -1
- package/npm-shrinkwrap.json +3 -3
- package/package.json +4 -4
package/dist/api.js
CHANGED
|
@@ -2,7 +2,7 @@ import { a as parseFeishuTargetId, i as parseFeishuDirectConversationId, n as bu
|
|
|
2
2
|
import { n as getFeishuThreadBindingManager, r as testing, t as createFeishuThreadBindingManager } from "./thread-bindings-D24m3Cjy.js";
|
|
3
3
|
import { n as handleFeishuSubagentEnded, r as handleFeishuSubagentSpawning, t as handleFeishuSubagentDeliveryTarget } from "./subagent-hooks-fuyBHOVu.js";
|
|
4
4
|
import { r as listEnabledFeishuAccounts } from "./accounts-CXnY5H8g.js";
|
|
5
|
-
import { a as setFeishuNamedAccountEnabled, i as feishuSetupAdapter, n as feishuSetupWizard, r as runFeishuLogin, t as feishuPlugin } from "./channel-
|
|
5
|
+
import { a as setFeishuNamedAccountEnabled, i as feishuSetupAdapter, n as feishuSetupWizard, r as runFeishuLogin, t as feishuPlugin } from "./channel-DavfT_AA.js";
|
|
6
6
|
import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.js";
|
|
7
7
|
import { a as jsonToolResult, d as registerFeishuChatTools, f as createFeishuToolClient, m as resolveFeishuToolAccount, n as registerFeishuDriveTools, o as toolExecutionErrorResult, p as resolveAnyEnabledFeishuToolsConfig, s as unknownToolActionResult } from "./drive-DwgWWkJi.js";
|
|
8
8
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, readStringValue, uniqueStrings } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as parseFeishuTargetId, i as parseFeishuDirectConversationId, n as buildFeishuModelOverrideParentCandidates, r as parseFeishuConversationId, t as buildFeishuConversationId } from "./conversation-id-DuL575sn.js";
|
|
2
2
|
import { n as looksLikeFeishuId, r as normalizeFeishuTarget, t as detectIdType } from "./targets-BUjQ1TcA.js";
|
|
3
|
-
import { a as resolveDefaultFeishuAccountId, f as isRecord$
|
|
3
|
+
import { a as resolveDefaultFeishuAccountId, f as isRecord$2, i as listFeishuAccountIds, n as inspectFeishuCredentials, o as resolveFeishuAccount, r as listEnabledFeishuAccounts, s as resolveFeishuRuntimeAccount } from "./accounts-CXnY5H8g.js";
|
|
4
4
|
import { n as createFeishuSendReceipt, s as createFeishuCardInteractionEnvelope } from "./send-result-CHvu8Rr7.js";
|
|
5
5
|
import { t as messageActionTargetAliases } from "./security-audit-BIeA3W3Q.js";
|
|
6
6
|
import { n as collectRuntimeConfigAssignments, r as secretTargetRegistryEntries } from "./secret-contract-ChjJKAJ9.js";
|
|
@@ -8,6 +8,7 @@ import { t as collectFeishuSecurityAuditFindings } from "./security-audit-shared
|
|
|
8
8
|
import { t as resolveFeishuSessionConversation } from "./session-conversation-CZSMgac-.js";
|
|
9
9
|
import { normalizeLowercaseStringOrEmpty, normalizeOptionalLowercaseString, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
10
10
|
import { getSessionBindingService } from "openclaw/plugin-sdk/conversation-runtime";
|
|
11
|
+
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
11
12
|
import { describeAccountSnapshot } from "openclaw/plugin-sdk/account-helpers";
|
|
12
13
|
import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
|
|
13
14
|
import { adaptScopedAccountAccessor, createHybridChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers";
|
|
@@ -20,15 +21,20 @@ import { normalizeMessagePresentation, renderMessagePresentationFallbackText } f
|
|
|
20
21
|
import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
|
21
22
|
import { createRuntimeOutboundDelegates } from "openclaw/plugin-sdk/outbound-runtime";
|
|
22
23
|
import { buildProbeChannelStatusSummary, createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
|
|
23
|
-
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$2, normalizeAccountId, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
|
|
24
|
+
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$2, normalizeAccountId as normalizeAccountId$1, resolveMergedAccountConfig } from "openclaw/plugin-sdk/account-resolution";
|
|
24
25
|
import { createResolvedApproverActionAuthAdapter, resolveApprovalApprovers } from "openclaw/plugin-sdk/approval-auth-runtime";
|
|
25
26
|
import { createActionGate } from "openclaw/plugin-sdk/channel-actions";
|
|
26
27
|
import { buildChannelConfigSchema } from "openclaw/plugin-sdk/channel-config-primitives";
|
|
27
28
|
import { PAIRING_APPROVED_MESSAGE } from "openclaw/plugin-sdk/channel-status";
|
|
28
29
|
import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
|
|
29
|
-
import { normalizeAccountId as normalizeAccountId$
|
|
30
|
+
import { normalizeAccountId as normalizeAccountId$2 } from "openclaw/plugin-sdk/account-id";
|
|
30
31
|
import { z } from "zod";
|
|
31
32
|
import { buildSecretInputSchema, hasConfiguredSecretInput as hasConfiguredSecretInput$2 } from "openclaw/plugin-sdk/secret-input";
|
|
33
|
+
import fs from "node:fs";
|
|
34
|
+
import os from "node:os";
|
|
35
|
+
import path from "node:path";
|
|
36
|
+
import { loadSessionStore, resolveSessionFilePath, resolveStorePath, updateSessionStore } from "openclaw/plugin-sdk/session-store-runtime";
|
|
37
|
+
import { resolveStateDir } from "openclaw/plugin-sdk/state-paths";
|
|
32
38
|
import { createChannelIngressResolver, defineStableChannelIngressIdentity } from "openclaw/plugin-sdk/channel-ingress-runtime";
|
|
33
39
|
import { DEFAULT_ACCOUNT_ID as DEFAULT_ACCOUNT_ID$1, createSetupTranslator, formatDocsLink, hasConfiguredSecretInput as hasConfiguredSecretInput$1, mergeAllowFromEntries, patchTopLevelChannelConfigSection, promptSingleChannelSecretInput, splitSetupEntries } from "openclaw/plugin-sdk/setup";
|
|
34
40
|
//#region extensions/feishu/src/approval-auth.ts
|
|
@@ -272,7 +278,7 @@ const FeishuConfigSchema = z.object({
|
|
|
272
278
|
}).strict().superRefine((value, ctx) => {
|
|
273
279
|
const defaultAccount = value.defaultAccount?.trim();
|
|
274
280
|
if (defaultAccount && value.accounts && Object.keys(value.accounts).length > 0) {
|
|
275
|
-
const normalizedDefaultAccount = normalizeAccountId$
|
|
281
|
+
const normalizedDefaultAccount = normalizeAccountId$2(defaultAccount);
|
|
276
282
|
if (!Object.prototype.hasOwnProperty.call(value.accounts, normalizedDefaultAccount)) ctx.addIssue({
|
|
277
283
|
code: z.ZodIssueCode.custom,
|
|
278
284
|
path: ["defaultAccount"],
|
|
@@ -367,6 +373,556 @@ async function listFeishuDirectoryGroups(params) {
|
|
|
367
373
|
}).map((entry) => entry.id));
|
|
368
374
|
}
|
|
369
375
|
//#endregion
|
|
376
|
+
//#region extensions/feishu/src/doctor.ts
|
|
377
|
+
const FEISHU_STATE_DIR = "feishu";
|
|
378
|
+
const BACKUP_PREFIX = "feishu-state-repair";
|
|
379
|
+
const BLANK_USER_MESSAGE_REPAIR_THRESHOLD = 3;
|
|
380
|
+
const SESSION_FILE_INSPECTION_MAX_BYTES = 16 * 1024 * 1024;
|
|
381
|
+
function timestampForPath(now = /* @__PURE__ */ new Date()) {
|
|
382
|
+
return now.toISOString().replaceAll(":", "-");
|
|
383
|
+
}
|
|
384
|
+
function isRecord$1(value) {
|
|
385
|
+
return Boolean(value && typeof value === "object" && !Array.isArray(value));
|
|
386
|
+
}
|
|
387
|
+
function toFeishuSessionEntry(value) {
|
|
388
|
+
if (!isRecord$1(value)) return {};
|
|
389
|
+
return {
|
|
390
|
+
sessionId: value.sessionId,
|
|
391
|
+
sessionFile: value.sessionFile
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
function countLabel(count, singular, plural = `${singular}s`) {
|
|
395
|
+
return `${count} ${count === 1 ? singular : plural}`;
|
|
396
|
+
}
|
|
397
|
+
function existsDir(dir) {
|
|
398
|
+
try {
|
|
399
|
+
return fs.statSync(dir).isDirectory();
|
|
400
|
+
} catch {
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
function existsFile(filePath) {
|
|
405
|
+
try {
|
|
406
|
+
return fs.statSync(filePath).isFile();
|
|
407
|
+
} catch {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
function safeReadDir(dir) {
|
|
412
|
+
try {
|
|
413
|
+
return fs.readdirSync(dir, { withFileTypes: true });
|
|
414
|
+
} catch {
|
|
415
|
+
return [];
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
function isPathWithinRoot(targetPath, rootPath) {
|
|
419
|
+
const resolvedTarget = path.resolve(targetPath);
|
|
420
|
+
const resolvedRoot = path.resolve(rootPath);
|
|
421
|
+
const relative = path.relative(resolvedRoot, resolvedTarget);
|
|
422
|
+
return Boolean(relative) && !relative.startsWith("..") && !path.isAbsolute(relative);
|
|
423
|
+
}
|
|
424
|
+
function formatDisplayPath(filePath) {
|
|
425
|
+
const home = os.homedir();
|
|
426
|
+
const resolved = path.resolve(filePath);
|
|
427
|
+
return resolved === home || resolved.startsWith(`${home}${path.sep}`) ? `~${resolved.slice(home.length)}` : resolved;
|
|
428
|
+
}
|
|
429
|
+
function formatFinding(finding) {
|
|
430
|
+
switch (finding.kind) {
|
|
431
|
+
case "corrupt-state-json": return `- Feishu local JSON state is corrupt: ${formatDisplayPath(finding.path)}`;
|
|
432
|
+
case "missing-session-transcript": return `- Feishu session ${finding.sessionKey} points to a missing transcript in ${formatDisplayPath(finding.storePath)}`;
|
|
433
|
+
case "invalid-session-transcript": return `- Feishu session ${finding.sessionKey} has an invalid transcript (${finding.reason}): ${formatDisplayPath(finding.path)}`;
|
|
434
|
+
case "blank-user-message-run": return `- Feishu session ${finding.sessionKey} contains ${finding.count} blank user messages: ${formatDisplayPath(finding.path)}`;
|
|
435
|
+
}
|
|
436
|
+
return finding;
|
|
437
|
+
}
|
|
438
|
+
function isFeishuSessionStoreKey(key) {
|
|
439
|
+
const normalized = key.trim().toLowerCase();
|
|
440
|
+
return /^agent:[^:]+:feishu(?::|$)/.test(normalized) || /^feishu(?::|$)/.test(normalized);
|
|
441
|
+
}
|
|
442
|
+
function isFeishuAcpBindingSessionKey(key) {
|
|
443
|
+
return /^agent:[^:]+:acp:binding:feishu(?::|$)/.test(key.trim().toLowerCase());
|
|
444
|
+
}
|
|
445
|
+
function normalizeMetadataString(value) {
|
|
446
|
+
return typeof value === "string" ? value.trim().toLowerCase() : "";
|
|
447
|
+
}
|
|
448
|
+
function isFeishuSessionEntry(key, value) {
|
|
449
|
+
if (isFeishuAcpBindingSessionKey(key)) return false;
|
|
450
|
+
if (isFeishuSessionStoreKey(key)) return true;
|
|
451
|
+
if (!isRecord$1(value)) return false;
|
|
452
|
+
if (normalizeMetadataString(value.channel) === "feishu" || normalizeMetadataString(value.lastChannel) === "feishu") return true;
|
|
453
|
+
if (normalizeMetadataString((isRecord$1(value.route) ? value.route : null)?.channel) === "feishu") return true;
|
|
454
|
+
if (normalizeMetadataString((isRecord$1(value.deliveryContext) ? value.deliveryContext : null)?.channel) === "feishu") return true;
|
|
455
|
+
if (normalizeMetadataString((isRecord$1(value.pendingFinalDeliveryContext) ? value.pendingFinalDeliveryContext : null)?.channel) === "feishu") return true;
|
|
456
|
+
const origin = isRecord$1(value.origin) ? value.origin : null;
|
|
457
|
+
const originProvider = normalizeMetadataString(origin?.provider);
|
|
458
|
+
const originSurface = normalizeMetadataString(origin?.surface);
|
|
459
|
+
const originFrom = normalizeMetadataString(origin?.from);
|
|
460
|
+
return originProvider === "feishu" || originSurface.startsWith("feishu") || originFrom.startsWith("feishu:");
|
|
461
|
+
}
|
|
462
|
+
function collectConfiguredAgentIds(cfg) {
|
|
463
|
+
const ids = /* @__PURE__ */ new Set();
|
|
464
|
+
ids.add(resolveConfiguredDefaultAgentId(cfg));
|
|
465
|
+
for (const agent of cfg.agents?.list ?? []) if (typeof agent.id === "string" && agent.id.trim()) ids.add(normalizeAgentId(agent.id));
|
|
466
|
+
return [...ids].toSorted();
|
|
467
|
+
}
|
|
468
|
+
function resolveConfiguredDefaultAgentId(cfg) {
|
|
469
|
+
const agents = cfg.agents?.list ?? [];
|
|
470
|
+
const chosen = agents.find((agent) => agent?.default) ?? agents[0];
|
|
471
|
+
return normalizeAgentId(typeof chosen?.id === "string" && chosen.id.trim() ? chosen.id : "main");
|
|
472
|
+
}
|
|
473
|
+
function collectFeishuSessionTargets(params) {
|
|
474
|
+
const byStorePath = /* @__PURE__ */ new Map();
|
|
475
|
+
const addTarget = (target) => {
|
|
476
|
+
byStorePath.set(path.resolve(target.storePath), {
|
|
477
|
+
...target,
|
|
478
|
+
storePath: path.resolve(target.storePath)
|
|
479
|
+
});
|
|
480
|
+
};
|
|
481
|
+
for (const agentId of collectConfiguredAgentIds(params.cfg)) addTarget({
|
|
482
|
+
agentId,
|
|
483
|
+
storePath: resolveStorePath(params.cfg.session?.store, {
|
|
484
|
+
agentId,
|
|
485
|
+
env: params.env
|
|
486
|
+
})
|
|
487
|
+
});
|
|
488
|
+
const agentsDir = path.join(params.stateDir, "agents");
|
|
489
|
+
for (const agentDir of safeReadDir(agentsDir)) {
|
|
490
|
+
if (!agentDir.isDirectory()) continue;
|
|
491
|
+
const agentId = normalizeAgentId(agentDir.name);
|
|
492
|
+
const storePath = path.join(agentsDir, agentDir.name, "sessions", "sessions.json");
|
|
493
|
+
if (existsFile(storePath)) addTarget({
|
|
494
|
+
agentId,
|
|
495
|
+
storePath
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
return [...byStorePath.values()].toSorted((left, right) => left.storePath.localeCompare(right.storePath));
|
|
499
|
+
}
|
|
500
|
+
function collectJsonFiles(rootDir, limit = 200) {
|
|
501
|
+
const files = [];
|
|
502
|
+
const visit = (dir) => {
|
|
503
|
+
if (files.length >= limit) return;
|
|
504
|
+
for (const entry of safeReadDir(dir).toSorted((left, right) => left.name.localeCompare(right.name))) {
|
|
505
|
+
const fullPath = path.join(dir, entry.name);
|
|
506
|
+
if (entry.isDirectory()) {
|
|
507
|
+
visit(fullPath);
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
if (entry.isFile() && entry.name.endsWith(".json")) files.push(fullPath);
|
|
511
|
+
if (files.length >= limit) return;
|
|
512
|
+
}
|
|
513
|
+
};
|
|
514
|
+
if (existsDir(rootDir)) visit(rootDir);
|
|
515
|
+
return files;
|
|
516
|
+
}
|
|
517
|
+
function collectCorruptFeishuStateJsonFindings(feishuStateDir) {
|
|
518
|
+
const findings = [];
|
|
519
|
+
for (const filePath of collectJsonFiles(feishuStateDir)) try {
|
|
520
|
+
JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
521
|
+
} catch {
|
|
522
|
+
findings.push({
|
|
523
|
+
kind: "corrupt-state-json",
|
|
524
|
+
path: filePath
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
return findings;
|
|
528
|
+
}
|
|
529
|
+
function resolveSessionTranscriptCandidates(params) {
|
|
530
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
531
|
+
const sessionsDir = path.dirname(params.storePath);
|
|
532
|
+
const addSafeCandidate = (candidate) => {
|
|
533
|
+
const resolved = path.isAbsolute(candidate) ? path.resolve(candidate) : path.resolve(sessionsDir, candidate);
|
|
534
|
+
if (resolved === sessionsDir || !isPathWithinRoot(resolved, sessionsDir)) return;
|
|
535
|
+
candidates.add(resolved);
|
|
536
|
+
};
|
|
537
|
+
if (typeof params.entry.sessionId === "string" && /^[a-z0-9][a-z0-9._-]{0,127}$/i.test(params.entry.sessionId)) {
|
|
538
|
+
candidates.add(resolveSessionFilePath(params.entry.sessionId, typeof params.entry.sessionFile === "string" ? { sessionFile: params.entry.sessionFile } : void 0, {
|
|
539
|
+
agentId: params.agentId,
|
|
540
|
+
sessionsDir
|
|
541
|
+
}));
|
|
542
|
+
return [...candidates].toSorted();
|
|
543
|
+
}
|
|
544
|
+
if (typeof params.entry.sessionFile === "string" && params.entry.sessionFile.trim()) addSafeCandidate(params.entry.sessionFile.trim());
|
|
545
|
+
return [...candidates].toSorted();
|
|
546
|
+
}
|
|
547
|
+
function isSessionHeader(value) {
|
|
548
|
+
return isRecord$1(value) && value.type === "session" && typeof value.id === "string";
|
|
549
|
+
}
|
|
550
|
+
function isBlankUserMessage(value) {
|
|
551
|
+
if (!isRecord$1(value) || value.type !== "message" || !isRecord$1(value.message)) return false;
|
|
552
|
+
if (value.message.role !== "user") return false;
|
|
553
|
+
const content = value.message.content;
|
|
554
|
+
if (typeof content === "string") return content.trim().length === 0;
|
|
555
|
+
return Array.isArray(content) && content.length === 0;
|
|
556
|
+
}
|
|
557
|
+
function isUserMessage(value) {
|
|
558
|
+
return isRecord$1(value) && value.type === "message" && isRecord$1(value.message) && value.message.role === "user";
|
|
559
|
+
}
|
|
560
|
+
function inspectSessionTranscript(params) {
|
|
561
|
+
let stat;
|
|
562
|
+
try {
|
|
563
|
+
stat = fs.statSync(params.transcriptPath);
|
|
564
|
+
} catch {
|
|
565
|
+
return null;
|
|
566
|
+
}
|
|
567
|
+
if (!stat.isFile()) return {
|
|
568
|
+
kind: "invalid-session-transcript",
|
|
569
|
+
sessionKey: params.sessionKey,
|
|
570
|
+
storePath: params.storePath,
|
|
571
|
+
path: params.transcriptPath,
|
|
572
|
+
reason: "not a file"
|
|
573
|
+
};
|
|
574
|
+
if (stat.size > SESSION_FILE_INSPECTION_MAX_BYTES) return null;
|
|
575
|
+
let raw = "";
|
|
576
|
+
try {
|
|
577
|
+
raw = fs.readFileSync(params.transcriptPath, "utf-8");
|
|
578
|
+
} catch {
|
|
579
|
+
return {
|
|
580
|
+
kind: "invalid-session-transcript",
|
|
581
|
+
sessionKey: params.sessionKey,
|
|
582
|
+
storePath: params.storePath,
|
|
583
|
+
path: params.transcriptPath,
|
|
584
|
+
reason: "unreadable"
|
|
585
|
+
};
|
|
586
|
+
}
|
|
587
|
+
const entries = [];
|
|
588
|
+
let malformedLines = 0;
|
|
589
|
+
let blankUserMessageRun = 0;
|
|
590
|
+
let maxBlankUserMessageRun = 0;
|
|
591
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
592
|
+
if (!line.trim()) continue;
|
|
593
|
+
try {
|
|
594
|
+
const entry = JSON.parse(line);
|
|
595
|
+
entries.push(entry);
|
|
596
|
+
if (isBlankUserMessage(entry)) {
|
|
597
|
+
blankUserMessageRun += 1;
|
|
598
|
+
maxBlankUserMessageRun = Math.max(maxBlankUserMessageRun, blankUserMessageRun);
|
|
599
|
+
} else if (isUserMessage(entry)) blankUserMessageRun = 0;
|
|
600
|
+
} catch {
|
|
601
|
+
malformedLines += 1;
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
if (entries.length === 0) return {
|
|
605
|
+
kind: "invalid-session-transcript",
|
|
606
|
+
sessionKey: params.sessionKey,
|
|
607
|
+
storePath: params.storePath,
|
|
608
|
+
path: params.transcriptPath,
|
|
609
|
+
reason: "empty transcript"
|
|
610
|
+
};
|
|
611
|
+
if (!isSessionHeader(entries[0])) return {
|
|
612
|
+
kind: "invalid-session-transcript",
|
|
613
|
+
sessionKey: params.sessionKey,
|
|
614
|
+
storePath: params.storePath,
|
|
615
|
+
path: params.transcriptPath,
|
|
616
|
+
reason: "invalid session header"
|
|
617
|
+
};
|
|
618
|
+
if (malformedLines > 0) return {
|
|
619
|
+
kind: "invalid-session-transcript",
|
|
620
|
+
sessionKey: params.sessionKey,
|
|
621
|
+
storePath: params.storePath,
|
|
622
|
+
path: params.transcriptPath,
|
|
623
|
+
reason: `${malformedLines} malformed JSONL line(s)`
|
|
624
|
+
};
|
|
625
|
+
if (maxBlankUserMessageRun >= BLANK_USER_MESSAGE_REPAIR_THRESHOLD) return {
|
|
626
|
+
kind: "blank-user-message-run",
|
|
627
|
+
sessionKey: params.sessionKey,
|
|
628
|
+
storePath: params.storePath,
|
|
629
|
+
path: params.transcriptPath,
|
|
630
|
+
count: maxBlankUserMessageRun
|
|
631
|
+
};
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
function collectFeishuSessionFindings(params) {
|
|
635
|
+
const transcriptCandidates = resolveSessionTranscriptCandidates(params);
|
|
636
|
+
const existing = transcriptCandidates.filter(existsFile);
|
|
637
|
+
if (transcriptCandidates.length > 0 && existing.length === 0) return [{
|
|
638
|
+
kind: "missing-session-transcript",
|
|
639
|
+
sessionKey: params.sessionKey,
|
|
640
|
+
storePath: params.storePath
|
|
641
|
+
}];
|
|
642
|
+
const findings = [];
|
|
643
|
+
for (const transcriptPath of existing) {
|
|
644
|
+
const finding = inspectSessionTranscript({
|
|
645
|
+
sessionKey: params.sessionKey,
|
|
646
|
+
storePath: params.storePath,
|
|
647
|
+
transcriptPath
|
|
648
|
+
});
|
|
649
|
+
if (finding) findings.push(finding);
|
|
650
|
+
}
|
|
651
|
+
return findings;
|
|
652
|
+
}
|
|
653
|
+
function hasCorruptFeishuStateJsonFinding(inspection) {
|
|
654
|
+
return inspection.findings.some((finding) => finding.kind === "corrupt-state-json");
|
|
655
|
+
}
|
|
656
|
+
function sessionEntryId(storePath, key) {
|
|
657
|
+
return `${path.resolve(storePath)}\0${key}`;
|
|
658
|
+
}
|
|
659
|
+
function collectRepairSessionEntries(inspection) {
|
|
660
|
+
const entriesById = /* @__PURE__ */ new Map();
|
|
661
|
+
for (const entry of inspection.sessionEntries) entriesById.set(sessionEntryId(entry.storePath, entry.key), entry);
|
|
662
|
+
const repairEntries = [];
|
|
663
|
+
const seen = /* @__PURE__ */ new Set();
|
|
664
|
+
for (const finding of inspection.findings) {
|
|
665
|
+
if (finding.kind === "corrupt-state-json") continue;
|
|
666
|
+
const id = sessionEntryId(finding.storePath, finding.sessionKey);
|
|
667
|
+
if (seen.has(id)) continue;
|
|
668
|
+
const entry = entriesById.get(id);
|
|
669
|
+
if (entry) {
|
|
670
|
+
repairEntries.push(entry);
|
|
671
|
+
seen.add(id);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
return repairEntries.toSorted((left, right) => left.storePath.localeCompare(right.storePath) || left.key.localeCompare(right.key));
|
|
675
|
+
}
|
|
676
|
+
function inspectFeishuDoctorState(params) {
|
|
677
|
+
const env = params.env ?? process.env;
|
|
678
|
+
const stateDir = resolveStateDir(env, os.homedir);
|
|
679
|
+
const feishuStateDir = path.join(stateDir, FEISHU_STATE_DIR);
|
|
680
|
+
const findings = collectCorruptFeishuStateJsonFindings(feishuStateDir);
|
|
681
|
+
const sessionEntries = [];
|
|
682
|
+
for (const target of collectFeishuSessionTargets({
|
|
683
|
+
cfg: params.cfg,
|
|
684
|
+
env,
|
|
685
|
+
stateDir
|
|
686
|
+
})) {
|
|
687
|
+
const store = loadSessionStore(target.storePath, { skipCache: true });
|
|
688
|
+
for (const [key, entry] of Object.entries(store).toSorted(([left], [right]) => left.localeCompare(right))) {
|
|
689
|
+
if (!isFeishuSessionEntry(key, entry)) continue;
|
|
690
|
+
const sessionEntry = toFeishuSessionEntry(entry);
|
|
691
|
+
sessionEntries.push({
|
|
692
|
+
key,
|
|
693
|
+
storePath: target.storePath,
|
|
694
|
+
agentId: target.agentId,
|
|
695
|
+
entry: sessionEntry
|
|
696
|
+
});
|
|
697
|
+
findings.push(...collectFeishuSessionFindings({
|
|
698
|
+
sessionKey: key,
|
|
699
|
+
storePath: target.storePath,
|
|
700
|
+
agentId: target.agentId,
|
|
701
|
+
entry: sessionEntry
|
|
702
|
+
}));
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return {
|
|
706
|
+
stateDir,
|
|
707
|
+
feishuStateDir,
|
|
708
|
+
findings,
|
|
709
|
+
sessionEntries
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
function ensureBackupDir(stateDir, now) {
|
|
713
|
+
const backupDir = path.join(stateDir, "backups", `${BACKUP_PREFIX}-${timestampForPath(now)}`);
|
|
714
|
+
fs.mkdirSync(backupDir, {
|
|
715
|
+
recursive: true,
|
|
716
|
+
mode: 448
|
|
717
|
+
});
|
|
718
|
+
return backupDir;
|
|
719
|
+
}
|
|
720
|
+
function resolveUniquePath(candidate) {
|
|
721
|
+
if (!fs.existsSync(candidate)) return candidate;
|
|
722
|
+
for (let index = 1; index < 1e3; index += 1) {
|
|
723
|
+
const next = `${candidate}.${index}`;
|
|
724
|
+
if (!fs.existsSync(next)) return next;
|
|
725
|
+
}
|
|
726
|
+
throw new Error(`Unable to resolve unique path for ${candidate}`);
|
|
727
|
+
}
|
|
728
|
+
function movePathToBackup(params) {
|
|
729
|
+
if (!fs.existsSync(params.sourcePath)) return false;
|
|
730
|
+
const targetPath = resolveUniquePath(path.join(params.backupDir, params.relativeTarget));
|
|
731
|
+
fs.mkdirSync(path.dirname(targetPath), {
|
|
732
|
+
recursive: true,
|
|
733
|
+
mode: 448
|
|
734
|
+
});
|
|
735
|
+
fs.renameSync(params.sourcePath, targetPath);
|
|
736
|
+
return true;
|
|
737
|
+
}
|
|
738
|
+
function copyStoreBackup(params) {
|
|
739
|
+
if (!existsFile(params.storePath)) return;
|
|
740
|
+
const targetPath = path.join(params.backupDir, "session-stores", params.agentId, path.basename(params.storePath));
|
|
741
|
+
fs.mkdirSync(path.dirname(targetPath), {
|
|
742
|
+
recursive: true,
|
|
743
|
+
mode: 448
|
|
744
|
+
});
|
|
745
|
+
fs.copyFileSync(params.storePath, resolveUniquePath(targetPath));
|
|
746
|
+
}
|
|
747
|
+
function collectSessionArtifactPaths(params) {
|
|
748
|
+
const artifacts = /* @__PURE__ */ new Set();
|
|
749
|
+
for (const transcriptPath of resolveSessionTranscriptCandidates(params)) {
|
|
750
|
+
artifacts.add(transcriptPath);
|
|
751
|
+
if (transcriptPath.endsWith(".jsonl")) {
|
|
752
|
+
const base = transcriptPath.slice(0, -6);
|
|
753
|
+
artifacts.add(`${base}.trajectory.jsonl`);
|
|
754
|
+
artifacts.add(`${base}.trajectory-path.json`);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return [...artifacts].toSorted();
|
|
758
|
+
}
|
|
759
|
+
function archiveSessionArtifacts(params) {
|
|
760
|
+
const seen = /* @__PURE__ */ new Set();
|
|
761
|
+
let archived = 0;
|
|
762
|
+
for (const entry of params.entries) for (const artifactPath of collectSessionArtifactPaths({
|
|
763
|
+
storePath: params.storePath,
|
|
764
|
+
agentId: entry.agentId,
|
|
765
|
+
entry: entry.entry
|
|
766
|
+
})) {
|
|
767
|
+
if (seen.has(artifactPath) || !existsFile(artifactPath)) continue;
|
|
768
|
+
seen.add(artifactPath);
|
|
769
|
+
const archivedPath = resolveUniquePath(`${artifactPath}.deleted.${params.archiveTimestamp}`);
|
|
770
|
+
fs.renameSync(artifactPath, archivedPath);
|
|
771
|
+
archived += 1;
|
|
772
|
+
}
|
|
773
|
+
return archived;
|
|
774
|
+
}
|
|
775
|
+
async function repairFeishuDoctorState(params) {
|
|
776
|
+
const env = params.env ?? process.env;
|
|
777
|
+
const now = params.now ?? /* @__PURE__ */ new Date();
|
|
778
|
+
const inspection = params.inspection ?? inspectFeishuDoctorState({
|
|
779
|
+
cfg: params.cfg,
|
|
780
|
+
env
|
|
781
|
+
});
|
|
782
|
+
const backupDir = ensureBackupDir(inspection.stateDir, now);
|
|
783
|
+
const archiveTimestamp = timestampForPath(now);
|
|
784
|
+
const warnings = [];
|
|
785
|
+
const stateDirRepairAttempted = hasCorruptFeishuStateJsonFinding(inspection);
|
|
786
|
+
let rebuiltStateDir = false;
|
|
787
|
+
if (stateDirRepairAttempted) try {
|
|
788
|
+
rebuiltStateDir = movePathToBackup({
|
|
789
|
+
sourcePath: inspection.feishuStateDir,
|
|
790
|
+
backupDir,
|
|
791
|
+
relativeTarget: FEISHU_STATE_DIR
|
|
792
|
+
});
|
|
793
|
+
fs.mkdirSync(inspection.feishuStateDir, {
|
|
794
|
+
recursive: true,
|
|
795
|
+
mode: 448
|
|
796
|
+
});
|
|
797
|
+
} catch (error) {
|
|
798
|
+
warnings.push(`- Failed to rebuild Feishu local state: ${String(error)}`);
|
|
799
|
+
}
|
|
800
|
+
const entriesByStore = /* @__PURE__ */ new Map();
|
|
801
|
+
for (const entry of collectRepairSessionEntries(inspection)) {
|
|
802
|
+
const existing = entriesByStore.get(entry.storePath);
|
|
803
|
+
if (existing) existing.entries.push({
|
|
804
|
+
key: entry.key,
|
|
805
|
+
entry: entry.entry
|
|
806
|
+
});
|
|
807
|
+
else entriesByStore.set(entry.storePath, {
|
|
808
|
+
agentId: entry.agentId,
|
|
809
|
+
entries: [{
|
|
810
|
+
key: entry.key,
|
|
811
|
+
entry: entry.entry
|
|
812
|
+
}]
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
let removedSessionEntries = 0;
|
|
816
|
+
let touchedSessionStores = 0;
|
|
817
|
+
let archivedSessionArtifacts = 0;
|
|
818
|
+
for (const [storePath, group] of [...entriesByStore.entries()].toSorted(([left], [right]) => left.localeCompare(right))) try {
|
|
819
|
+
copyStoreBackup({
|
|
820
|
+
storePath,
|
|
821
|
+
backupDir,
|
|
822
|
+
agentId: group.agentId
|
|
823
|
+
});
|
|
824
|
+
const keys = new Set(group.entries.map((entry) => entry.key));
|
|
825
|
+
const removedEntries = await updateSessionStore(storePath, (store) => {
|
|
826
|
+
const removed = [];
|
|
827
|
+
for (const key of keys) if (Object.prototype.hasOwnProperty.call(store, key)) {
|
|
828
|
+
delete store[key];
|
|
829
|
+
const entry = group.entries.find((candidate) => candidate.key === key);
|
|
830
|
+
if (entry) removed.push(entry);
|
|
831
|
+
}
|
|
832
|
+
return removed;
|
|
833
|
+
}, {
|
|
834
|
+
skipMaintenance: true,
|
|
835
|
+
allowDropAcpMetaSessionKeys: [...keys]
|
|
836
|
+
});
|
|
837
|
+
const removed = removedEntries.length;
|
|
838
|
+
removedSessionEntries += removed;
|
|
839
|
+
if (removed > 0) {
|
|
840
|
+
touchedSessionStores += 1;
|
|
841
|
+
archivedSessionArtifacts += archiveSessionArtifacts({
|
|
842
|
+
storePath,
|
|
843
|
+
entries: removedEntries.map((entry) => ({
|
|
844
|
+
agentId: group.agentId,
|
|
845
|
+
entry: entry.entry
|
|
846
|
+
})),
|
|
847
|
+
archiveTimestamp
|
|
848
|
+
});
|
|
849
|
+
}
|
|
850
|
+
} catch (error) {
|
|
851
|
+
warnings.push(`- Failed to archive Feishu sessions in ${formatDisplayPath(storePath)}: ${String(error)}`);
|
|
852
|
+
}
|
|
853
|
+
return {
|
|
854
|
+
backupDir,
|
|
855
|
+
stateDirRepairAttempted,
|
|
856
|
+
rebuiltStateDir,
|
|
857
|
+
removedSessionEntries,
|
|
858
|
+
touchedSessionStores,
|
|
859
|
+
archivedSessionArtifacts,
|
|
860
|
+
warnings
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
function formatPreviewWarning(inspection) {
|
|
864
|
+
const previewFindings = inspection.findings.slice(0, 5).map(formatFinding);
|
|
865
|
+
const remaining = inspection.findings.length - previewFindings.length;
|
|
866
|
+
const repairActions = [];
|
|
867
|
+
if (hasCorruptFeishuStateJsonFinding(inspection)) repairActions.push(`archive ${formatDisplayPath(inspection.feishuStateDir)}`);
|
|
868
|
+
const repairSessionEntries = collectRepairSessionEntries(inspection);
|
|
869
|
+
if (repairSessionEntries.length > 0) repairActions.push(`archive artifacts and remove ${countLabel(repairSessionEntries.length, "flagged Feishu-scoped session entry", "flagged Feishu-scoped session entries")}`);
|
|
870
|
+
const repairSummary = repairActions.length > 0 ? repairActions.join(" and ") : "apply targeted Feishu state cleanup";
|
|
871
|
+
return [
|
|
872
|
+
"- Feishu local channel state may need repair.",
|
|
873
|
+
...previewFindings,
|
|
874
|
+
...remaining > 0 ? [`- ...and ${remaining} more Feishu state finding(s).`] : [],
|
|
875
|
+
`- Repair will ${repairSummary}, while preserving Feishu App ID/secret config and healthy session entries.`,
|
|
876
|
+
"- Run \"openclaw doctor --fix\" to rebuild Feishu local state."
|
|
877
|
+
].join("\n");
|
|
878
|
+
}
|
|
879
|
+
function formatRepairChange(report) {
|
|
880
|
+
const stateRepairStatus = report.stateDirRepairAttempted ? report.rebuiltStateDir ? "yes" : "no existing state" : "not needed";
|
|
881
|
+
return [
|
|
882
|
+
"Feishu local state repaired.",
|
|
883
|
+
`- Backup dir: ${formatDisplayPath(report.backupDir)}`,
|
|
884
|
+
`- Rebuilt Feishu runtime state: ${stateRepairStatus}`,
|
|
885
|
+
`- Removed ${countLabel(report.removedSessionEntries, "Feishu-scoped session entry", "Feishu-scoped session entries")} from ${countLabel(report.touchedSessionStores, "session store")}.`,
|
|
886
|
+
`- Archived ${countLabel(report.archivedSessionArtifacts, "session artifact file")}.`,
|
|
887
|
+
"- Preserved Feishu App ID/secret config."
|
|
888
|
+
].join("\n");
|
|
889
|
+
}
|
|
890
|
+
function hasConfiguredFeishuChannel(cfg) {
|
|
891
|
+
return Boolean(cfg.channels?.feishu);
|
|
892
|
+
}
|
|
893
|
+
async function runFeishuDoctorSequence(params) {
|
|
894
|
+
if (!hasConfiguredFeishuChannel(params.cfg)) return {
|
|
895
|
+
changeNotes: [],
|
|
896
|
+
warningNotes: []
|
|
897
|
+
};
|
|
898
|
+
const inspection = inspectFeishuDoctorState({
|
|
899
|
+
cfg: params.cfg,
|
|
900
|
+
env: params.env
|
|
901
|
+
});
|
|
902
|
+
if (inspection.findings.length === 0) return {
|
|
903
|
+
changeNotes: [],
|
|
904
|
+
warningNotes: []
|
|
905
|
+
};
|
|
906
|
+
if (!params.shouldRepair) return {
|
|
907
|
+
changeNotes: [],
|
|
908
|
+
warningNotes: [formatPreviewWarning(inspection)]
|
|
909
|
+
};
|
|
910
|
+
const report = await repairFeishuDoctorState({
|
|
911
|
+
cfg: params.cfg,
|
|
912
|
+
env: params.env,
|
|
913
|
+
inspection
|
|
914
|
+
});
|
|
915
|
+
return {
|
|
916
|
+
changeNotes: [formatRepairChange(report)],
|
|
917
|
+
warningNotes: report.warnings
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
const feishuDoctor = { runConfigSequence: async ({ cfg, env, shouldRepair }) => await runFeishuDoctorSequence({
|
|
921
|
+
cfg,
|
|
922
|
+
env,
|
|
923
|
+
shouldRepair
|
|
924
|
+
}) };
|
|
925
|
+
//#endregion
|
|
370
926
|
//#region extensions/feishu/src/policy.ts
|
|
371
927
|
const FEISHU_PROVIDER_PREFIX_RE = /^(feishu|lark):/i;
|
|
372
928
|
const FEISHU_TYPED_PREFIX_RE = /^(chat|group|channel|user|dm|open_id):/i;
|
|
@@ -426,7 +982,7 @@ function createFeishuIngressSubject(params) {
|
|
|
426
982
|
function createFeishuIngressResolver(params) {
|
|
427
983
|
return createChannelIngressResolver({
|
|
428
984
|
channelId: "feishu",
|
|
429
|
-
accountId: normalizeAccountId(params.accountId) ?? "default",
|
|
985
|
+
accountId: normalizeAccountId$1(params.accountId) ?? "default",
|
|
430
986
|
identity: feishuIngressIdentity,
|
|
431
987
|
cfg: params.cfg,
|
|
432
988
|
...params.readAllowFromStore ? { readStoreAllowFrom: params.readAllowFromStore } : {}
|
|
@@ -532,8 +1088,8 @@ function resolveFeishuReplyPolicy(params) {
|
|
|
532
1088
|
const resolvedCfg = resolveMergedAccountConfig({
|
|
533
1089
|
channelConfig: feishuCfg,
|
|
534
1090
|
accounts: feishuCfg?.accounts,
|
|
535
|
-
accountId: normalizeAccountId(params.accountId),
|
|
536
|
-
normalizeAccountId,
|
|
1091
|
+
accountId: normalizeAccountId$1(params.accountId),
|
|
1092
|
+
normalizeAccountId: normalizeAccountId$1,
|
|
537
1093
|
omitKeys: ["defaultAccount"]
|
|
538
1094
|
});
|
|
539
1095
|
const groupRequireMention = resolveFeishuGroupConfig({
|
|
@@ -1148,13 +1704,13 @@ function readBooleanParam(params, keys) {
|
|
|
1148
1704
|
}
|
|
1149
1705
|
}
|
|
1150
1706
|
function hasLegacyFeishuCardCommandValue(actionValue) {
|
|
1151
|
-
return isRecord$
|
|
1707
|
+
return isRecord$2(actionValue) && actionValue.oc !== "ocf1" && (Boolean(typeof actionValue.command === "string" && actionValue.command.trim()) || Boolean(typeof actionValue.text === "string" && actionValue.text.trim()));
|
|
1152
1708
|
}
|
|
1153
1709
|
function containsLegacyFeishuCardCommandValue(node) {
|
|
1154
1710
|
if (Array.isArray(node)) return node.some((item) => containsLegacyFeishuCardCommandValue(item));
|
|
1155
|
-
if (!isRecord$
|
|
1711
|
+
if (!isRecord$2(node)) return false;
|
|
1156
1712
|
if (node.tag === "button" && hasLegacyFeishuCardCommandValue(node.value)) return true;
|
|
1157
|
-
if (node.tag === "button" && Array.isArray(node.behaviors) && node.behaviors.some((behavior) => isRecord$
|
|
1713
|
+
if (node.tag === "button" && Array.isArray(node.behaviors) && node.behaviors.some((behavior) => isRecord$2(behavior) && hasLegacyFeishuCardCommandValue(behavior.value))) return true;
|
|
1158
1714
|
return Object.values(node).some((value) => containsLegacyFeishuCardCommandValue(value));
|
|
1159
1715
|
}
|
|
1160
1716
|
const meta = {
|
|
@@ -1167,7 +1723,7 @@ const meta = {
|
|
|
1167
1723
|
aliases: ["lark"],
|
|
1168
1724
|
order: 70
|
|
1169
1725
|
};
|
|
1170
|
-
const loadFeishuChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-
|
|
1726
|
+
const loadFeishuChannelRuntime = createLazyRuntimeNamedExport(() => import("./channel.runtime-ItBg9SfS.js"), "feishuChannelRuntime");
|
|
1171
1727
|
function toFeishuMessageSendResult(result, kind) {
|
|
1172
1728
|
const receipt = result.receipt ?? createFeishuSendReceipt({
|
|
1173
1729
|
messageId: result.messageId,
|
|
@@ -1498,6 +2054,7 @@ const feishuPlugin = createChatChannelPlugin({
|
|
|
1498
2054
|
},
|
|
1499
2055
|
mentions: { stripPatterns: () => ["<at user_id=\"[^\"]*\">[^<]*</at>"] },
|
|
1500
2056
|
reload: { configPrefixes: ["channels.feishu"] },
|
|
2057
|
+
doctor: feishuDoctor,
|
|
1501
2058
|
configSchema: buildChannelConfigSchema(FeishuConfigSchema),
|
|
1502
2059
|
config: {
|
|
1503
2060
|
...feishuConfigAdapter,
|
|
@@ -1986,7 +2543,7 @@ const feishuPlugin = createChatChannelPlugin({
|
|
|
1986
2543
|
})
|
|
1987
2544
|
}),
|
|
1988
2545
|
gateway: { startAccount: async (ctx) => {
|
|
1989
|
-
const { monitorFeishuProvider } = await import("./monitor-
|
|
2546
|
+
const { monitorFeishuProvider } = await import("./monitor-gFxvkDyO.js");
|
|
1990
2547
|
const account = resolveFeishuRuntimeAccount({
|
|
1991
2548
|
cfg: ctx.cfg,
|
|
1992
2549
|
accountId: ctx.accountId
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as feishuPlugin } from "./channel-
|
|
1
|
+
import { t as feishuPlugin } from "./channel-DavfT_AA.js";
|
|
2
2
|
export { feishuPlugin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as resolveFeishuAccount, s as resolveFeishuRuntimeAccount, y as parseFeishuCommentTarget } from "./accounts-CXnY5H8g.js";
|
|
2
|
-
import { h as listFeishuDirectoryPeers, m as listFeishuDirectoryGroups, o as buildFeishuPresentationCardElements } from "./channel-
|
|
2
|
+
import { h as listFeishuDirectoryPeers, m as listFeishuDirectoryGroups, o as buildFeishuPresentationCardElements } from "./channel-DavfT_AA.js";
|
|
3
3
|
import { r as createFeishuClient } from "./client-BnH2fRL2.js";
|
|
4
4
|
import { c as getChatInfo, l as getChatMembers, r as cleanupAmbientCommentTypingReaction, t as deliverCommentThreadText, u as getFeishuMemberInfo } from "./drive-DwgWWkJi.js";
|
|
5
5
|
import { chunkTextForOutbound } from "./runtime-api.js";
|
|
@@ -3,7 +3,7 @@ import { l as fetchBotIdentityForMonitor } from "./monitor.state-CxrHFQX2.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-CmXHWuwG.js");
|
|
7
7
|
return await monitorAccountRuntimePromise;
|
|
8
8
|
}
|
|
9
9
|
async function monitorFeishuProvider(opts = {}) {
|
|
@@ -2,12 +2,12 @@ import { t as buildFeishuConversationId } from "./conversation-id-DuL575sn.js";
|
|
|
2
2
|
import { i as resolveReceiveIdType } from "./targets-BUjQ1TcA.js";
|
|
3
3
|
import { t as createFeishuThreadBindingManager } from "./thread-bindings-D24m3Cjy.js";
|
|
4
4
|
import { _ as buildFeishuCommentTarget, f as isRecord$1, h as readString, l as encodeQuery, m as parseCommentContentElements, p as normalizeString, s as resolveFeishuRuntimeAccount, u as extractReplyText, v as normalizeCommentFileType } from "./accounts-CXnY5H8g.js";
|
|
5
|
-
import { c as normalizeFeishuAllowEntry, d as resolveFeishuGroupConversationIngressAccess, f as resolveFeishuGroupSenderActivationIngressAccess, l as resolveFeishuDmIngressAccess, p as resolveFeishuReplyPolicy, s as hasExplicitFeishuGroupConfig, u as resolveFeishuGroupConfig } from "./channel-
|
|
5
|
+
import { c as normalizeFeishuAllowEntry, d as resolveFeishuGroupConversationIngressAccess, f as resolveFeishuGroupSenderActivationIngressAccess, l as resolveFeishuDmIngressAccess, p as resolveFeishuReplyPolicy, s as hasExplicitFeishuGroupConfig, u as resolveFeishuGroupConfig } from "./channel-DavfT_AA.js";
|
|
6
6
|
import { c as decodeFeishuCardAction, o as buildFeishuCardActionTextFallback, s as createFeishuCardInteractionEnvelope } from "./send-result-CHvu8Rr7.js";
|
|
7
7
|
import { t as getFeishuRuntime } from "./runtime-C5JxBWZp.js";
|
|
8
8
|
import { a as getFeishuUserAgent, i as createFeishuWSClient, n as createEventDispatcher, r as createFeishuClient } from "./client-BnH2fRL2.js";
|
|
9
9
|
import { c as getChatInfo, i as createCommentTypingReactionLifecycle, t as deliverCommentThreadText } from "./drive-DwgWWkJi.js";
|
|
10
|
-
import { buildAgentMediaPayload, createReplyPrefixContext, evaluateSupplementalContextVisibility, loadSessionStore, normalizeAgentId as normalizeAgentId$
|
|
10
|
+
import { buildAgentMediaPayload, createReplyPrefixContext, evaluateSupplementalContextVisibility, loadSessionStore, normalizeAgentId as normalizeAgentId$2, resolveChannelContextVisibilityMode, resolveSessionStoreEntry } from "./runtime-api.js";
|
|
11
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-DQClIwTI.js";
|
|
12
12
|
import { i as waitForAbortableDelay, r as raceWithTimeoutAndAbort } from "./probe-Da81t6a5.js";
|
|
13
13
|
import { a as feishuWebhookRateLimiter, c as wsClients, i as botOpenIds, l as fetchBotIdentityForMonitor, n as FEISHU_WEBHOOK_MAX_BODY_BYTES, o as httpServers, r as botNames, s as recordWebhookStatus, t as FEISHU_WEBHOOK_BODY_TIMEOUT_MS } from "./monitor.state-CxrHFQX2.js";
|
|
@@ -664,12 +664,12 @@ function resolveUserPath(p) {
|
|
|
664
664
|
//#endregion
|
|
665
665
|
//#region extensions/feishu/src/agent-config.ts
|
|
666
666
|
const DEFAULT_AGENT_ID = "main";
|
|
667
|
-
function normalizeAgentId(value) {
|
|
667
|
+
function normalizeAgentId$1(value) {
|
|
668
668
|
return (value ?? "").trim().toLowerCase() || DEFAULT_AGENT_ID;
|
|
669
669
|
}
|
|
670
670
|
function resolveFeishuConfigReasoningDefault(cfg, agentId) {
|
|
671
|
-
const id = normalizeAgentId(agentId);
|
|
672
|
-
return cfg.agents?.list?.find((entry) => normalizeAgentId(entry?.id) === id)?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault ?? "off";
|
|
671
|
+
const id = normalizeAgentId$1(agentId);
|
|
672
|
+
return cfg.agents?.list?.find((entry) => normalizeAgentId$1(entry?.id) === id)?.reasoningDefault ?? cfg.agents?.defaults?.reasoningDefault ?? "off";
|
|
673
673
|
}
|
|
674
674
|
//#endregion
|
|
675
675
|
//#region extensions/feishu/src/reasoning-preview.ts
|
|
@@ -1974,7 +1974,7 @@ async function handleFeishuMessage(params) {
|
|
|
1974
1974
|
const dmPolicy = feishuCfg?.dmPolicy ?? "pairing";
|
|
1975
1975
|
const configAllowFrom = feishuCfg?.allowFrom ?? [];
|
|
1976
1976
|
const rawBroadcastAgents = isGroup ? resolveBroadcastAgents(cfg, ctx.chatId) : null;
|
|
1977
|
-
const broadcastAgents = rawBroadcastAgents ? uniqueStrings(rawBroadcastAgents.map((id) => normalizeAgentId$
|
|
1977
|
+
const broadcastAgents = rawBroadcastAgents ? uniqueStrings(rawBroadcastAgents.map((id) => normalizeAgentId$2(id))) : null;
|
|
1978
1978
|
const messageCreateTimeMs = event.message.create_time ? Number.parseInt(event.message.create_time, 10) : Date.now();
|
|
1979
1979
|
let requireMention = false;
|
|
1980
1980
|
if (isGroup) {
|
|
@@ -2498,12 +2498,12 @@ async function handleFeishuMessage(params) {
|
|
|
2498
2498
|
return;
|
|
2499
2499
|
}
|
|
2500
2500
|
const strategy = cfg.broadcast?.strategy === "sequential" ? "sequential" : "parallel";
|
|
2501
|
-
const activeAgentId = ctx.mentionedBot || !requireMention ? normalizeAgentId$
|
|
2502
|
-
const agentIds = (cfg.agents?.list ?? []).map((a) => normalizeAgentId$
|
|
2501
|
+
const activeAgentId = ctx.mentionedBot || !requireMention ? normalizeAgentId$2(route.agentId) : null;
|
|
2502
|
+
const agentIds = (cfg.agents?.list ?? []).map((a) => normalizeAgentId$2(a.id));
|
|
2503
2503
|
const hasKnownAgents = agentIds.length > 0;
|
|
2504
2504
|
log(`feishu[${account.accountId}]: broadcasting to ${broadcastAgents.length} agents (strategy=${strategy}, active=${activeAgentId ?? "none"})`);
|
|
2505
2505
|
const dispatchForAgent = async (agentId) => {
|
|
2506
|
-
if (hasKnownAgents && !agentIds.includes(normalizeAgentId$
|
|
2506
|
+
if (hasKnownAgents && !agentIds.includes(normalizeAgentId$2(agentId))) {
|
|
2507
2507
|
log(`feishu[${account.accountId}]: broadcast agent ${agentId} not found in agents.list; skipping`);
|
|
2508
2508
|
return;
|
|
2509
2509
|
}
|
package/dist/runtime-api.js
CHANGED
|
@@ -4,10 +4,10 @@ import { createReplyPrefixContext } from "openclaw/plugin-sdk/channel-message";
|
|
|
4
4
|
import { createChannelPairingController } from "openclaw/plugin-sdk/channel-pairing";
|
|
5
5
|
import { PAIRING_APPROVED_MESSAGE, buildProbeChannelStatusSummary, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/channel-status";
|
|
6
6
|
import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
|
|
7
|
+
import { loadSessionStore, resolveSessionStoreEntry } from "openclaw/plugin-sdk/session-store-runtime";
|
|
7
8
|
import { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, createActionGate, createDedupeCache } from "openclaw/plugin-sdk/core";
|
|
8
9
|
import { buildAgentMediaPayload } from "openclaw/plugin-sdk/agent-media-payload";
|
|
9
10
|
import { evaluateSupplementalContextVisibility, filterSupplementalContextItems, resolveChannelContextVisibilityMode } from "openclaw/plugin-sdk/context-visibility-runtime";
|
|
10
|
-
import { loadSessionStore, resolveSessionStoreEntry } from "openclaw/plugin-sdk/session-store-runtime";
|
|
11
11
|
import { readJsonFileWithFallback } from "openclaw/plugin-sdk/json-store";
|
|
12
12
|
import { createPersistentDedupe } from "openclaw/plugin-sdk/persistent-dedupe";
|
|
13
13
|
import { isRequestBodyLimitError, readRequestBodyWithLimit, requestBodyErrorToText } from "openclaw/plugin-sdk/webhook-ingress";
|
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-DavfT_AA.js";
|
|
2
2
|
export { feishuPlugin, feishuSetupAdapter, feishuSetupWizard };
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/feishu",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.26-beta.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/feishu",
|
|
9
|
-
"version": "2026.5.
|
|
9
|
+
"version": "2026.5.26-beta.2",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@larksuiteoapi/node-sdk": "1.65.0",
|
|
12
12
|
"typebox": "1.1.38",
|
|
13
13
|
"zod": "4.4.3"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"openclaw": ">=2026.5.
|
|
16
|
+
"openclaw": ">=2026.5.26-beta.2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependenciesMeta": {
|
|
19
19
|
"openclaw": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/feishu",
|
|
3
|
-
"version": "2026.5.
|
|
3
|
+
"version": "2026.5.26-beta.2",
|
|
4
4
|
"description": "OpenClaw Feishu/Lark channel plugin (community maintained by @m1heng)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"zod": "4.4.3"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"openclaw": ">=2026.5.
|
|
16
|
+
"openclaw": ">=2026.5.26-beta.2"
|
|
17
17
|
},
|
|
18
18
|
"peerDependenciesMeta": {
|
|
19
19
|
"openclaw": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"minHostVersion": ">=2026.4.25"
|
|
45
45
|
},
|
|
46
46
|
"compat": {
|
|
47
|
-
"pluginApi": ">=2026.5.
|
|
47
|
+
"pluginApi": ">=2026.5.26-beta.2"
|
|
48
48
|
},
|
|
49
49
|
"build": {
|
|
50
|
-
"openclawVersion": "2026.5.
|
|
50
|
+
"openclawVersion": "2026.5.26-beta.2"
|
|
51
51
|
},
|
|
52
52
|
"release": {
|
|
53
53
|
"publishToClawHub": true,
|