MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / processLinkedMessage

Function processLinkedMessage

apps/web/src/lib/bot/run.ts:9–69  ·  view source on GitHub ↗
({
  thread,
  message,
  platformIntegration,
  user,
}: {
  thread: Thread;
  message: Message;
  platformIntegration: PlatformIntegration;
  user: User;
})

Source from the content-addressed store, hash-verified

7import { captureException } from '@sentry/nextjs';
8
9export async function processLinkedMessage({
10 thread,
11 message,
12 platformIntegration,
13 user,
14}: {
15 thread: Thread;
16 message: Message;
17 platformIntegration: PlatformIntegration;
18 user: User;
19}) {
20 const botPlatform = botPlatforms.requireByAdapter(thread.adapter);
21 const stopProcessingIndicator = await botPlatform.startProcessingIndicator({
22 thread,
23 messageId: message.id,
24 status: 'Thinking...',
25 platformIntegration,
26 });
27
28 let handedOff = false;
29 try {
30 let botRequestId: string;
31 try {
32 botRequestId = await createBotRequest({
33 createdBy: user.id,
34 organizationId: platformIntegration.owned_by_organization_id ?? null,
35 platformIntegrationId: platformIntegration.id,
36 platform: thread.adapter.name,
37 platformThreadId: thread.id,
38 platformMessageId: message.id,
39 userMessage: message.text,
40 modelUsed: undefined,
41 });
42 } catch (error) {
43 captureException(error, {
44 tags: { component: 'kilo-bot', op: 'create-bot-request' },
45 extra: {
46 platform: thread.adapter.name,
47 platformIntegrationId: platformIntegration.id,
48 userId: user.id,
49 threadId: thread.id,
50 messageId: message.id,
51 },
52 });
53 await botPlatform.withAuthContext({
54 platformIntegration,
55 fn: () =>
56 thread.post({
57 markdown:
58 'Sorry, I could not start processing your message because of an internal error. Please try again in a moment.',
59 }),
60 });
61 return;
62 }
63
64 handedOff = await processMessage({
65 thread,
66 message,

Callers 2

createKiloBotFunction · 0.90
reprocessLinkedMessageFunction · 0.90

Calls 3

createBotRequestFunction · 0.90
postMethod · 0.80
processMessageFunction · 0.70

Tested by

no test coverage detected