mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:34:31 +00:00
refactor: unify outbound session context wiring
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { resolveSessionAgentId } from "../../agents/agent-scope.js";
|
||||
import { AGENT_LANE_NESTED } from "../../agents/lanes.js";
|
||||
import { getChannelPlugin, normalizeChannelId } from "../../channels/plugins/index.js";
|
||||
import { createOutboundSendDeps, type CliDeps } from "../../cli/outbound-send-deps.js";
|
||||
@@ -17,6 +16,7 @@ import {
|
||||
normalizeOutboundPayloads,
|
||||
normalizeOutboundPayloadsForJson,
|
||||
} from "../../infra/outbound/payloads.js";
|
||||
import { buildOutboundSessionContext } from "../../infra/outbound/session-context.js";
|
||||
import type { RuntimeEnv } from "../../runtime.js";
|
||||
import { isInternalMessageChannel } from "../../utils/message-channel.js";
|
||||
import type { AgentCommandOpts } from "./types.js";
|
||||
@@ -212,25 +212,24 @@ export async function deliverAgentCommandResult(params: {
|
||||
}
|
||||
if (deliver && deliveryChannel && !isInternalMessageChannel(deliveryChannel)) {
|
||||
if (deliveryTarget) {
|
||||
const deliveryAgentId =
|
||||
opts.agentId ??
|
||||
(opts.sessionKey
|
||||
? resolveSessionAgentId({ sessionKey: opts.sessionKey, config: cfg })
|
||||
: undefined);
|
||||
const deliverySession = buildOutboundSessionContext({
|
||||
cfg,
|
||||
agentId: opts.agentId,
|
||||
sessionKey: opts.sessionKey,
|
||||
});
|
||||
await deliverOutboundPayloads({
|
||||
cfg,
|
||||
channel: deliveryChannel,
|
||||
to: deliveryTarget,
|
||||
accountId: resolvedAccountId,
|
||||
payloads: deliveryPayloads,
|
||||
agentId: deliveryAgentId,
|
||||
session: deliverySession,
|
||||
replyToId: resolvedReplyToId ?? null,
|
||||
threadId: resolvedThreadTarget ?? null,
|
||||
bestEffort: bestEffortDeliver,
|
||||
onError: (err) => logDeliveryError(err),
|
||||
onPayload: logPayload,
|
||||
deps: createOutboundSendDeps(deps),
|
||||
sessionKey: opts.sessionKey,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user