Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions apps/api/src/handlers/discord/__tests__/index.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/api/src/handlers/discord/__tests__/task-launch.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions apps/api/src/handlers/discord/fast-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function processDiscordFastAgentMessage(input: {
metadata: ReturnType<typeof discordMetadataForChannel>;
sessionThreadId: string;
interaction?: DiscordInteractionReplyContext;
activeTaskId?: string | null;
activeTasks?: { taskId: string }[];
}): Promise<void> {
const history =
input.channel.isThread || input.channel.isDirectMessage
Expand Down Expand Up @@ -66,8 +66,8 @@ export async function processDiscordFastAgentMessage(input: {
input.interaction?.interaction.member?.nick ??
input.sender.global_name ??
input.sender.username,
activeTaskId: input.activeTaskId,
launchTask: async ({ prompt, environmentId }) => {
activeTasks: input.activeTasks,
launchTask: async ({ prompt, environmentId, parentSessionId }) => {
const workspaceOverride = environmentId
? await resolveDiscordWorkspace({
type: 'environment',
Expand Down Expand Up @@ -105,6 +105,7 @@ export async function processDiscordFastAgentMessage(input: {
metadata: input.metadata,
channel: input.channel,
forceNewThread: true,
fastAgentSessionId: parentSessionId,
skipRoutingConfirmation: true,
workspaceOverride,
});
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/handlers/discord/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ async function processDiscordGatewayEvent(
channel.isDirectMessage || channel.isThread
? channel.channelId
: defaultFastMessage.id,
activeTaskId: activeRun?.taskId ?? null,
activeTasks: activeRun ? [{ taskId: activeRun.taskId }] : [],
});
return { ok: true, fastAnswered: true, fastDefaulted: true };
}
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/handlers/discord/task-launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export async function launchDiscordTask(input: {
workspace: DiscordWorkspaceSelection;
/** `/new` in an existing task thread creates a sibling, never a second run in-place. */
forceNewThread?: boolean;
fastAgentSessionId?: string;
/**
* An already-posted message to turn into the acknowledgement instead of
* posting a new one — a routing card sitting in the task thread becomes the
Expand Down Expand Up @@ -452,6 +453,9 @@ export async function launchDiscordTask(input: {
? { images: input.queuedMessage.images }
: {}),
communicationProvider: 'discord',
...(input.fastAgentSessionId
? { fastAgentSessionId: input.fastAgentSessionId }
: {}),
communicationChannelId,
...(input.metadata.communicationGuildId
? { communicationGuildId: input.metadata.communicationGuildId }
Expand Down
4 changes: 4 additions & 0 deletions apps/api/src/handlers/discord/task-orchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export async function startNewDiscordTask(input: {
initiator: TaskInitiator;
};
forceNewThread?: boolean;
fastAgentSessionId?: string;
workspaceOverride?: DiscordWorkspaceSelection;
/**
* True when the Discord intake path successfully pinned 👀 on the origin
Expand Down Expand Up @@ -366,6 +367,9 @@ export async function startNewDiscordTask(input: {
channel: input.channel,
workspace,
forceNewThread: input.forceNewThread,
...(input.fastAgentSessionId
? { fastAgentSessionId: input.fastAgentSessionId }
: {}),
...(kickoffMessage ? { kickoffMessage } : {}),
...(input.intakeAckPinned ? { intakeAckPinned: true } : {}),
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function createFastAgentTaskLauncher(params: {
communicationThreadId: threadId,
communicationMessageId: params.event.ts,
communicationContextInherited: true,
fastAgentSessionId: parentSessionId,
fastAgentParent: {
sessionId: parentSessionId,
slackTeamId: params.teamId,
Expand Down
7 changes: 4 additions & 3 deletions apps/api/src/handlers/slack/events/fast-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { PRODUCT_NAME } from '@roomote/types';
import {
acquireFastAgentTurnLock,
answerFastAgentQuestion,
type FastAgentActiveTask,
type LaunchFastAgentSlackTask,
} from '@roomote/cloud-agents/server';
import { type SlackEvent, type SlackNotifier } from '@roomote/slack';
Expand Down Expand Up @@ -51,7 +52,7 @@ export async function processFastAgentMessage(params: {
apiBaseUrl?: string;
usageText?: string;
continuation?: boolean;
activeTaskId?: string | null;
activeTasks?: FastAgentActiveTask[];
launchTask?: LaunchFastAgentSlackTask;
processingReactionName?: string;
}): Promise<void> {
Expand All @@ -63,7 +64,7 @@ export async function processFastAgentMessage(params: {
apiBaseUrl,
usageText = `Use \`/fast <question>\` after mentioning ${PRODUCT_NAME}.`,
continuation = false,
activeTaskId = null,
activeTasks = [],
launchTask,
processingReactionName = 'eyes',
} = params;
Expand Down Expand Up @@ -156,7 +157,7 @@ export async function processFastAgentMessage(params: {
currentMessage?.user === event.user
? currentMessage.username
: undefined,
activeTaskId,
activeTasks,
launchTask,
postSlackReply: async ({ message, kickoff }) => {
const posted = await postSlackThreadMarkdownMessage({
Expand Down
6 changes: 3 additions & 3 deletions apps/api/src/handlers/slack/events/message-entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,7 @@ function startFastAgentResponse(params: {
teamId: string;
usageText?: string;
continuation?: boolean;
activeTaskId?: string | null;
activeTasks?: { taskId: string }[];
processingReactionName: string;
errorLogPrefix: string;
}): void {
Expand Down Expand Up @@ -1736,7 +1736,7 @@ async function handleSlackEntryEvent(params: {
slack,
userId: userMapping.userId,
teamId,
activeTaskId: activeRun?.taskId ?? null,
activeTasks: activeRun ? [{ taskId: activeRun.taskId }] : [],
continuation: fastAgentEntryMode === 'default',
processingReactionName: ackEmoji,
errorLogPrefix: `❌ Background fast-agent response failed for thread ${threadId}:`,
Expand Down Expand Up @@ -1764,7 +1764,7 @@ async function handleSlackEntryEvent(params: {
userId: userMapping.userId,
teamId,
continuation: true,
activeTaskId: activeRun?.taskId ?? null,
activeTasks: activeRun ? [{ taskId: activeRun.taskId }] : [],
processingReactionName: ackEmoji,
errorLogPrefix: `❌ Background fast-agent continuation failed for thread ${threadId}:`,
});
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading