mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 04:41:25 +00:00
refactor(outbound): centralize outbound identity
This commit is contained in:
@@ -14,8 +14,6 @@ import { getCliSessionId, setCliSessionId } from "../../agents/cli-session.js";
|
||||
import { lookupContextTokens } from "../../agents/context.js";
|
||||
import { resolveCronStyleNow } from "../../agents/current-time.js";
|
||||
import { DEFAULT_CONTEXT_TOKENS, DEFAULT_MODEL, DEFAULT_PROVIDER } from "../../agents/defaults.js";
|
||||
import { resolveAgentAvatar } from "../../agents/identity-avatar.js";
|
||||
import { resolveAgentIdentity } from "../../agents/identity.js";
|
||||
import { loadModelCatalog } from "../../agents/model-catalog.js";
|
||||
import { runWithModelFallback } from "../../agents/model-fallback.js";
|
||||
import {
|
||||
@@ -46,6 +44,7 @@ import {
|
||||
} from "../../config/sessions.js";
|
||||
import { registerAgentRunContext } from "../../infra/agent-events.js";
|
||||
import { deliverOutboundPayloads } from "../../infra/outbound/deliver.js";
|
||||
import { resolveAgentOutboundIdentity } from "../../infra/outbound/identity.js";
|
||||
import { getRemoteSkillEligibility } from "../../infra/skills-remote.js";
|
||||
import { logWarn } from "../../logger.js";
|
||||
import { buildAgentMainSessionKey, normalizeAgentId } from "../../routing/session-key.js";
|
||||
@@ -557,18 +556,11 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
logWarn(`[cron:${params.job.id}] ${message}`);
|
||||
return withRunSession({ status: "ok", summary, outputText });
|
||||
}
|
||||
const agentIdentity = resolveAgentIdentity(cfgWithAgentDefaults, agentId);
|
||||
const avatar = resolveAgentAvatar(cfgWithAgentDefaults, agentId);
|
||||
const icon_url = avatar.kind === "remote" ? avatar.url : undefined;
|
||||
const username = agentIdentity?.name?.trim() || undefined;
|
||||
const rawEmoji = agentIdentity?.emoji?.trim();
|
||||
// Slack `icon_emoji` requires :emoji_name: (not a Unicode emoji).
|
||||
const icon_emoji =
|
||||
!icon_url && rawEmoji && /^:[^:\\s]+:$/.test(rawEmoji) ? rawEmoji : undefined;
|
||||
const identity = resolveAgentOutboundIdentity(cfgWithAgentDefaults, agentId);
|
||||
|
||||
// Shared subagent announce flow is text-based. When we have an explicit sender
|
||||
// identity to preserve, prefer direct outbound delivery even for plain-text payloads.
|
||||
if (deliveryPayloadHasStructuredContent || username || icon_url || icon_emoji) {
|
||||
if (deliveryPayloadHasStructuredContent || identity) {
|
||||
try {
|
||||
const payloadsForDelivery =
|
||||
deliveryPayloadHasStructuredContent && deliveryPayloads.length > 0
|
||||
@@ -584,9 +576,7 @@ export async function runCronIsolatedAgentTurn(params: {
|
||||
accountId: resolvedDelivery.accountId,
|
||||
threadId: resolvedDelivery.threadId,
|
||||
payloads: payloadsForDelivery,
|
||||
username,
|
||||
icon_url,
|
||||
icon_emoji,
|
||||
identity,
|
||||
bestEffort: deliveryBestEffort,
|
||||
deps: createOutboundSendDeps(params.deps),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user