fix(regression): propagate team scope into child spawns

This commit is contained in:
Gustavo Madeira Santana
2026-04-17 22:15:26 -04:00
parent 0b45ea937a
commit 91f0217cf6
6 changed files with 7 additions and 1 deletions

View File

@@ -651,6 +651,7 @@ describe("msteams monitor handler authz", () => {
expect(dispatched?.ctxPayload).toMatchObject({
BodyForAgent:
"[Thread history]\nAlice: Allowed context\n[/Thread history]\n\nCurrent message",
GroupSpace: "team123",
});
expect(
String((dispatched?.ctxPayload as { BodyForAgent?: string }).BodyForAgent),

View File

@@ -773,6 +773,7 @@ export function createMSTeamsMessageHandler(deps: MSTeamsMessageHandlerDeps) {
ChatType: isDirectMessage ? "direct" : isChannel ? "channel" : "group",
ConversationLabel: envelopeFrom,
GroupSubject: !isDirectMessage ? conversationType : undefined,
GroupSpace: teamId,
SenderName: senderName,
SenderId: senderId,
Provider: "msteams" as const,

View File

@@ -196,6 +196,7 @@ describe("slack prepareSlackMessage inbound contract", () => {
expect(prepared).toBeTruthy();
expectInboundContextContract(prepared!.ctxPayload as any);
expect(prepared!.ctxPayload.GroupSpace).toBe("T1");
});
it("does not enable Slack status reactions when the message timestamp is missing", async () => {

View File

@@ -736,6 +736,7 @@ export async function prepareSlackMessage(params: {
ChatType: isDirectMessage ? "direct" : "channel",
ConversationLabel: envelopeFrom,
GroupSubject: isRoomish ? roomLabel : undefined,
GroupSpace: ctx.teamId || undefined,
GroupSystemPrompt: groupSystemPrompt,
UntrustedContext: untrustedChannelMetadata ? [untrustedChannelMetadata] : undefined,
SenderName: senderName,

View File

@@ -983,9 +983,10 @@ describe("slack slash command session metadata", () => {
expect(recordSessionMetaFromInboundMock).toHaveBeenCalledTimes(1);
const call = recordSessionMetaFromInboundMock.mock.calls[0]?.[0] as {
sessionKey?: string;
ctx?: { OriginatingChannel?: string };
ctx?: { GroupSpace?: string; OriginatingChannel?: string };
};
expect(call.ctx?.OriginatingChannel).toBe("slack");
expect(call.ctx?.GroupSpace).toBe("T1");
expect(call.sessionKey).toBeDefined();
});

View File

@@ -577,6 +577,7 @@ export async function registerSlackMonitorSlashCommands(params: {
: `slack:group:${command.channel_id}`,
}) ?? (isDirectMessage ? senderName : roomLabel),
GroupSubject: isRoomish ? roomLabel : undefined,
GroupSpace: ctx.teamId || undefined,
GroupSystemPrompt: groupSystemPrompt,
UntrustedContext: untrustedChannelMetadata ? [untrustedChannelMetadata] : undefined,
SenderName: senderName,