mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:01:24 +00:00
fix: route discord native subagent announce to channel target
This commit is contained in:
@@ -155,6 +155,8 @@ describe("/subagents spawn command", () => {
|
|||||||
const params = buildCommandTestParams("/subagents spawn beta do the thing", baseCfg, {
|
const params = buildCommandTestParams("/subagents spawn beta do the thing", baseCfg, {
|
||||||
CommandSource: "native",
|
CommandSource: "native",
|
||||||
CommandTargetSessionKey: "agent:main:main",
|
CommandTargetSessionKey: "agent:main:main",
|
||||||
|
OriginatingChannel: "discord",
|
||||||
|
OriginatingTo: "channel:12345",
|
||||||
});
|
});
|
||||||
params.sessionKey = "agent:main:slack:slash:u1";
|
params.sessionKey = "agent:main:slack:slash:u1";
|
||||||
|
|
||||||
@@ -164,6 +166,8 @@ describe("/subagents spawn command", () => {
|
|||||||
expect(result?.reply?.text).toContain("Spawned subagent beta");
|
expect(result?.reply?.text).toContain("Spawned subagent beta");
|
||||||
const [, spawnCtx] = spawnSubagentDirectMock.mock.calls[0];
|
const [, spawnCtx] = spawnSubagentDirectMock.mock.calls[0];
|
||||||
expect(spawnCtx.agentSessionKey).toBe("agent:main:main");
|
expect(spawnCtx.agentSessionKey).toBe("agent:main:main");
|
||||||
|
expect(spawnCtx.agentChannel).toBe("discord");
|
||||||
|
expect(spawnCtx.agentTo).toBe("channel:12345");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("returns forbidden for unauthorized cross-agent spawn", async () => {
|
it("returns forbidden for unauthorized cross-agent spawn", async () => {
|
||||||
|
|||||||
@@ -686,9 +686,9 @@ export const handleSubagentsCommand: CommandHandler = async (params, allowTextCo
|
|||||||
{ task, agentId, model, thinking, cleanup: "keep", expectsCompletionMessage: true },
|
{ task, agentId, model, thinking, cleanup: "keep", expectsCompletionMessage: true },
|
||||||
{
|
{
|
||||||
agentSessionKey: requesterKey,
|
agentSessionKey: requesterKey,
|
||||||
agentChannel: params.command.channel,
|
agentChannel: params.ctx.OriginatingChannel ?? params.command.channel,
|
||||||
agentAccountId: params.ctx.AccountId,
|
agentAccountId: params.ctx.AccountId,
|
||||||
agentTo: params.command.to,
|
agentTo: params.ctx.OriginatingTo ?? params.command.to,
|
||||||
agentThreadId: params.ctx.MessageThreadId,
|
agentThreadId: params.ctx.MessageThreadId,
|
||||||
agentGroupId: params.sessionEntry?.groupId ?? null,
|
agentGroupId: params.sessionEntry?.groupId ?? null,
|
||||||
agentGroupChannel: params.sessionEntry?.groupChannel ?? null,
|
agentGroupChannel: params.sessionEntry?.groupChannel ?? null,
|
||||||
|
|||||||
@@ -790,6 +790,11 @@ async function dispatchDiscordCommandInteraction(params: {
|
|||||||
Timestamp: Date.now(),
|
Timestamp: Date.now(),
|
||||||
CommandAuthorized: commandAuthorized,
|
CommandAuthorized: commandAuthorized,
|
||||||
CommandSource: "native" as const,
|
CommandSource: "native" as const,
|
||||||
|
// Native slash contexts use To=slash:<user> for interaction routing.
|
||||||
|
// For follow-up delivery (for example subagent completion announces),
|
||||||
|
// preserve the real Discord target separately.
|
||||||
|
OriginatingChannel: "discord" as const,
|
||||||
|
OriginatingTo: isDirectMessage ? `user:${user.id}` : `channel:${channelId}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
|
const { onModelSelected, ...prefixOptions } = createReplyPrefixOptions({
|
||||||
|
|||||||
Reference in New Issue
Block a user