




















@@ -1,10 +1,6 @@
11import { formatInboundFromLabel as formatInboundFromLabelShared } from "openclaw/plugin-sdk/channel-inbound";
2-import { createDedupeCache, type OpenClawConfig } from "openclaw/plugin-sdk/core";
2+import { createDedupeCache } from "openclaw/plugin-sdk/core";
33import { resolveThreadSessionKeys as resolveThreadSessionKeysShared } from "openclaw/plugin-sdk/routing";
4-import {
5-normalizeLowercaseStringOrEmpty,
6-normalizeOptionalString,
7-} from "openclaw/plugin-sdk/text-runtime";
84import { rawDataToString } from "openclaw/plugin-sdk/webhook-ingress";
95106export { createDedupeCache, rawDataToString };
@@ -17,51 +13,8 @@ export type ResponsePrefixContext = {
1713identityName?: string;
1814};
191520-export function extractShortModelName(fullModel: string): string {
21-const slash = fullModel.lastIndexOf("/");
22-const modelPart = slash >= 0 ? fullModel.slice(slash + 1) : fullModel;
23-return modelPart.replace(/-\d{8}$/, "").replace(/-latest$/, "");
24-}
25-2616export const formatInboundFromLabel = formatInboundFromLabelShared;
271728-function normalizeAgentId(value: string | undefined | null): string {
29-const trimmed = (value ?? "").trim();
30-if (!trimmed) {
31-return "main";
32-}
33-if (/^[a-z0-9][a-z0-9_-]{0,63}$/i.test(trimmed)) {
34-return trimmed;
35-}
36-return (
37-normalizeLowercaseStringOrEmpty(trimmed)
38-.replace(/[^a-z0-9_-]+/g, "-")
39-.replace(/^-+/, "")
40-.replace(/-+$/, "")
41-.slice(0, 64) || "main"
42-);
43-}
44-45-type AgentEntry = NonNullable<NonNullable<OpenClawConfig["agents"]>["list"]>[number];
46-47-function isAgentEntry(entry: unknown): entry is AgentEntry {
48-return Boolean(entry && typeof entry === "object");
49-}
50-51-function listAgents(cfg: OpenClawConfig): AgentEntry[] {
52-return Array.isArray(cfg.agents?.list) ? cfg.agents.list.filter(isAgentEntry) : [];
53-}
54-55-function resolveAgentEntry(cfg: OpenClawConfig, agentId: string): AgentEntry | undefined {
56-const id = normalizeAgentId(agentId);
57-return listAgents(cfg).find((entry) => normalizeAgentId(entry.id) === id);
58-}
59-60-export function resolveIdentityName(cfg: OpenClawConfig, agentId: string): string | undefined {
61-const entry = resolveAgentEntry(cfg, agentId);
62-return normalizeOptionalString(entry?.identity?.name);
63-}
64-6518export function resolveThreadSessionKeys(params: {
6619baseSessionKey: string;
6720threadId?: string | null;
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。