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
67 changes: 67 additions & 0 deletions packages/sdk/src/server/lib/fast-agent-parent-event.test.ts

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

30 changes: 25 additions & 5 deletions packages/sdk/src/server/lib/fast-agent-parent-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,17 @@ function isFastAutomationReportEvent(
);
}

function buildTelegramAutomationMessage(params: {
automationName: string;
message: string;
running: boolean;
}): string {
const label = params.running
? `Automation "${params.automationName}" is running.`
: `Automation: ${params.automationName}`;
return `${label}\n\n${params.message}`;
}

/** Groups a report's suggestion cards; unique per run occurrence. */
function buildFastAutomationSuggestionEventId(
event: Extract<
Expand Down Expand Up @@ -1906,14 +1917,15 @@ async function createTelegramFastAgentParentTurn(
sessionId: session.id,
footerContext: params.footerContext,
});
const automation = await resolveFastAutomationLaunchContext({
event: params.event,
conversation,
});
const launchTask = createFastAgentCommunicationTaskLauncher({
userId: actorUserId,
conversation,
telegramLiveTaskProvider: provider,
automation: await resolveFastAutomationLaunchContext({
event: params.event,
conversation,
}),
automation,
});
return {
userId: actorUserId,
Expand Down Expand Up @@ -1949,6 +1961,14 @@ async function createTelegramFastAgentParentTurn(
suggestions.length > 0,
)
: message;
const displayedMessage =
automation && (kickoff || isFastAutomationReportEvent(params.event))
? buildTelegramAutomationMessage({
automationName: automation.automationName,
message: reportMessage,
running: Boolean(kickoff),
})
: reportMessage;
const action =
params.event.type === 'pull_request_feedback' &&
params.event.suggestedActionQuestion &&
Expand Down Expand Up @@ -1985,7 +2005,7 @@ async function createTelegramFastAgentParentTurn(
...(conversation.replyTarget.threadId
? { threadId: conversation.replyTarget.threadId }
: {}),
text: reportMessage,
text: displayedMessage,
textFormat: 'markdown',
images,
...(action
Expand Down
Loading