Skip to content

Commit 6b6fb56

Browse files
committed
feat(search-experts): find who knows a topic from contributors across connected sources
Adds search_experts to the Search MCP, the Assistant and the Organization Search block. Live providers report each result's contributors when asked; the use case ranks them by role, source, recency and rank, matches them to the People directory by email, Slack account or an unambiguous name, and returns evidence links to the items.
1 parent 2ffbae6 commit 6b6fb56

40 files changed

Lines changed: 1455 additions & 74 deletions

‎apps/sim/blocks/blocks/organization.ts‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const OrganizationBlock: BlockConfig = {
4747
{ text: 'since', field: 'historyStartDate' },
4848
],
4949
list_my_activity: ['List my activity', { text: 'in', field: 'source' }],
50+
search_experts: ['Find experts', { text: 'on', field: 'query' }],
5051
},
5152
},
5253
},
@@ -65,30 +66,30 @@ export const OrganizationBlock: BlockConfig = {
6566
title: 'Query',
6667
type: 'long-input',
6768
placeholder: 'What to look for',
68-
condition: { field: 'operation', value: ['search', 'search_people'] },
69+
condition: { field: 'operation', value: ['search', 'search_people', 'search_experts'] },
6970
},
7071
{
7172
id: 'source',
7273
title: 'Source',
7374
type: 'short-input',
7475
placeholder: 'slack, jira, confluence, google_drive, gitlab…',
75-
condition: { field: 'operation', value: ['search', 'list_my_activity'] },
76+
condition: { field: 'operation', value: ['search', 'list_my_activity', 'search_experts'] },
7677
mode: 'advanced',
7778
},
7879
{
7980
id: 'startDate',
8081
title: 'Start Date',
8182
type: 'short-input',
8283
placeholder: '2026-01-01T00:00:00-08:00 (inclusive)',
83-
condition: { field: 'operation', value: ['search', 'list_my_activity'] },
84+
condition: { field: 'operation', value: ['search', 'list_my_activity', 'search_experts'] },
8485
mode: 'advanced',
8586
},
8687
{
8788
id: 'endDate',
8889
title: 'End Date',
8990
type: 'short-input',
9091
placeholder: '2026-02-01T00:00:00-08:00 (exclusive)',
91-
condition: { field: 'operation', value: ['search', 'list_my_activity'] },
92+
condition: { field: 'operation', value: ['search', 'list_my_activity', 'search_experts'] },
9293
mode: 'advanced',
9394
},
9495
{
@@ -190,10 +191,10 @@ export const OrganizationBlock: BlockConfig = {
190191
id: 'topK',
191192
title: 'Max Results',
192193
type: 'short-input',
193-
placeholder: '20 for Search, 25 for activity, 50 for chat history',
194+
placeholder: '20 for Search, 10 for experts, 25 for activity, 50 for chat history',
194195
condition: {
195196
field: 'operation',
196-
value: ['search', 'list_my_chat_history', 'list_my_activity'],
197+
value: ['search', 'list_my_chat_history', 'list_my_activity', 'search_experts'],
197198
},
198199
mode: 'advanced',
199200
},
@@ -257,15 +258,15 @@ export const OrganizationBlock: BlockConfig = {
257258
title: 'Department',
258259
type: 'short-input',
259260
placeholder: 'Part of a department',
260-
condition: { field: 'operation', value: 'search_people' },
261+
condition: { field: 'operation', value: ['search_people', 'search_experts'] },
261262
mode: 'advanced',
262263
},
263264
{
264265
id: 'location',
265266
title: 'Location',
266267
type: 'short-input',
267268
placeholder: 'Part of a location',
268-
condition: { field: 'operation', value: 'search_people' },
269+
condition: { field: 'operation', value: ['search_people', 'search_experts'] },
269270
mode: 'advanced',
270271
},
271272
{
@@ -395,14 +396,20 @@ export const OrganizationBlock: BlockConfig = {
395396
type: 'array',
396397
description: 'List My Chat History: the person’s own questions, newest first by default',
397398
},
398-
note: { type: 'string', description: 'Search People: guidance when no one matches' },
399+
note: { type: 'string', description: 'Search People and Search Experts: guidance' },
399400
window: { type: 'json', description: 'List My Activity: the window read' },
400401
items: { type: 'array', description: 'List My Activity: activity entries, newest first' },
401402
truncated: { type: 'boolean', description: 'List My Activity: whether more entries remain' },
402403
coverage: { type: 'string', description: 'List My Activity: complete or partial' },
403404
sources: {
404405
type: 'array',
405-
description: 'List My Activity: each source’s status and where to connect it',
406+
description:
407+
'List My Activity and Search Experts: each source’s status and where to connect it',
408+
},
409+
experts: { type: 'array', description: 'Search Experts: ranked experts with evidence' },
410+
otherContributors: {
411+
type: 'array',
412+
description: 'Search Experts: strong contributors outside the directory',
406413
},
407414
},
408415
}

‎apps/sim/blocks/sdk-names.generated.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ const BLOCKS: Record<string, string> = {
320320
openai: '{"namespace":"legacy.openai"}',
321321
oracle_fusion_financials: '{"namespace":"oracleFusionFinancials","methods":{"oracle_fusion_financials_apply_receivables_receipt":"applyReceivablesReceipt","oracle_fusion_financials_approve_receivables_invoice":"approveReceivablesInvoice","oracle_fusion_financials_create_expense_line":"createExpenseLine","oracle_fusion_financials_create_expense_report":"createExpenseReport","oracle_fusion_financials_create_receivables_credit_memo":"createReceivablesCreditMemo","oracle_fusion_financials_create_receivables_invoice":"createReceivablesInvoice","oracle_fusion_financials_create_receivables_receipt":"createReceivablesReceipt","oracle_fusion_financials_get_expense_line":"getExpenseLine","oracle_fusion_financials_get_expense_report":"getExpenseReport","oracle_fusion_financials_get_gl_journal_batch":"getGlJournalBatch","oracle_fusion_financials_get_gl_ledger":"getGlLedger","oracle_fusion_financials_get_payables_invoice":"getPayablesInvoice","oracle_fusion_financials_get_payables_invoice_line":"getPayablesInvoiceLine","oracle_fusion_financials_get_payables_payment":"getPayablesPayment","oracle_fusion_financials_get_receivables_credit_memo":"getReceivablesCreditMemo","oracle_fusion_financials_get_receivables_invoice":"getReceivablesInvoice","oracle_fusion_financials_get_receivables_invoice_installment":"getReceivablesInvoiceInstallment","oracle_fusion_financials_get_receivables_invoice_line":"getReceivablesInvoiceLine","oracle_fusion_financials_get_receivables_receipt":"getReceivablesReceipt","oracle_fusion_financials_list_expense_lines":"listExpenseLines","oracle_fusion_financials_list_expense_reports":"listExpenseReports","oracle_fusion_financials_list_gl_balances":"listGlBalances","oracle_fusion_financials_list_gl_journal_batches":"listGlJournalBatches","oracle_fusion_financials_list_gl_ledgers":"listGlLedgers","oracle_fusion_financials_list_payables_invoice_lines":"listPayablesInvoiceLines","oracle_fusion_financials_list_payables_invoices":"listPayablesInvoices","oracle_fusion_financials_list_payables_payments":"listPayablesPayments","oracle_fusion_financials_list_receivables_credit_memos":"listReceivablesCreditMemos","oracle_fusion_financials_list_receivables_invoice_installments":"listReceivablesInvoiceInstallments","oracle_fusion_financials_list_receivables_invoice_lines":"listReceivablesInvoiceLines","oracle_fusion_financials_list_receivables_invoices":"listReceivablesInvoices","oracle_fusion_financials_list_receivables_receipts":"listReceivablesReceipts","oracle_fusion_financials_submit_expense_report":"submitExpenseReport","oracle_fusion_financials_update_expense_line":"updateExpenseLine","oracle_fusion_financials_update_expense_report":"updateExpenseReport","oracle_fusion_financials_update_receivables_invoice":"updateReceivablesInvoice"},"paramAliases":{"action":{"oauthCredential":"credential"}}}',
322322
oracledb: '{"namespace":"oracledb","methods":{"delete":"deleteData","execute":"executeSql","insert":"insertData","introspect":"introspectSchema","query":"querySelect","update":"updateData"},"paramAliases":{"action":{"oauthCredential":"credential"}}}',
323-
organization: '{"namespace":"organization","methods":{"list_my_activity":"listMyActivity","list_my_chat_history":"listMyChatHistory","read_document":"readDocument","search":"search","search_people":"searchPeople"}}',
323+
organization: '{"namespace":"organization","methods":{"list_my_activity":"listMyActivity","list_my_chat_history":"listMyChatHistory","read_document":"readDocument","search":"search","search_experts":"searchExperts","search_people":"searchPeople"}}',
324324
otter: '{"namespace":"legacy.otter","methods":{"create_conversation":"importRecording","get_conversation":"getConversation","get_conversation_audio":"getConversationAudio","get_workspace":"getWorkspace","list_channel_members":"listChannelMembers","list_channels":"listChannels","list_conversations":"listConversations","list_workspace_conversations":"listWorkspaceConversations"},"triggers":{"otter_conversation_completed":"conversationCompleted","otter_conversation_shared":"conversationShared","otter_webhook":"webhook"}}',
325325
otter_v2: '{"namespace":"otter","methods":{"create_conversation":"importRecording","get_conversation":"getConversation","get_conversation_audio":"getConversationAudio","get_workspace":"getWorkspace","list_channel_members":"listChannelMembers","list_channels":"listChannels","list_conversations":"listConversations","list_workspace_conversations":"listWorkspaceConversations"},"triggers":{"otter_conversation_completed":"conversationCompleted","otter_conversation_shared":"conversationShared","otter_webhook":"webhook"},"paramAliases":{"action":{"oauthCredential":"credential"}}}',
326326
outlook: '{"namespace":"outlook","methods":{"copy_outlook":"copyEmail","create_event_calendar":"createEvent","create_folder_outlook":"createFolder","delete_event_calendar":"deleteEvent","delete_outlook":"deleteEmail","draft_outlook":"draftEmail","forward_outlook":"forwardEmail","get_attachment_outlook":"getAttachment","get_event_calendar":"getCalendarEvent","list_attachments_outlook":"listAttachments","list_events_calendar":"listCalendarEvents","list_folders_outlook":"listFolders","mark_read_outlook":"markAsRead","mark_unread_outlook":"markAsUnread","move_outlook":"moveEmail","read_outlook":"readEmail","reply_all_outlook":"replyAll","reply_outlook":"replyToEmail","respond_calendar":"respondToInvite","search_outlook":"searchEmail","send_outlook":"sendEmail","update_event_calendar":"updateEvent","update_message_outlook":"setCategoriesFlag"},"triggers":{"outlook_poller":"poller"},"paramAliases":{"action":{"oauthCredential":"credential"},"trigger":{"oauthCredential":"credential"}}}',

‎apps/sim/blocks/sdk-names/organization.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"list_my_chat_history": "listMyChatHistory",
66
"read_document": "readDocument",
77
"search": "search",
8+
"search_experts": "searchExperts",
89
"search_people": "searchPeople"
910
}
1011
}

‎apps/sim/lib/api/contracts/mothership-assistant-tools.ts‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,39 @@ export const listMyChatHistoryInputSchema = z
574574
.strict()
575575
export type ListMyChatHistoryInput = z.output<typeof listMyChatHistoryInputSchema>
576576

577+
/** The longest activity window an expert search reads. */
578+
/** Who knows a topic, ranked by what they did on matching items the caller can read. */
579+
export const searchExpertsInputSchema = z
580+
.object({
581+
query: z
582+
.string()
583+
.trim()
584+
.min(1)
585+
.max(500)
586+
.describe('The topic, system, customer or project to find people for.'),
587+
source: workspaceSearchFiltersSchema.shape.source.describe(
588+
'Only this source, such as jira, confluence, google_drive, slack, gitlab or github.'
589+
),
590+
startDate: z.iso
591+
.datetime({ offset: true })
592+
.optional()
593+
.describe(
594+
`Inclusive start of the activity window, an ISO datetime with offset. With endDate, at most ${MAX_ACTIVITY_WINDOW_DAYS} days; without either, all time, with recent work weighted higher.`
595+
),
596+
endDate: z.iso
597+
.datetime({ offset: true })
598+
.optional()
599+
.describe('Exclusive end of the activity window, an ISO datetime with offset.'),
600+
department: peopleFieldFilter('Only experts whose directory department contains this text.'),
601+
location: peopleFieldFilter('Only experts whose directory location contains this text.'),
602+
topK: z.number().int().min(1).max(25).default(10).describe('Maximum experts to return.'),
603+
})
604+
.strict()
605+
.superRefine(refineActivityWindow)
606+
607+
export const SEARCH_EXPERTS_DESCRIPTION =
608+
'Find who in this organization knows a topic: people ranked by what they did on matching items you can read (Jira issues assigned or reported, Confluence pages written or edited, Drive files owned or edited, Slack messages, GitLab and GitHub merge and pull requests, Linear issues). Each expert comes with a score, their directory profile when they are in it, what they did by source, and evidence links to the items. Only items your own access returns count. Narrow with source, a date window, department or location.'
609+
577610
/** Connection requests name a provider and optionally an owned account to repair. */
578611
export const oauthGetAuthLinkInputSchema = z.object({
579612
providerName: z
@@ -658,6 +691,12 @@ export const assistantToolContracts = [
658691
'List what you did across your connected sources in a date window, newest first: Slack messages and Gmail mail you sent (replied when the message answers another), Google Calendar meetings you organized or accepted, Jira issues you created or that were assigned to you, Confluence pages you created or edited and comments you wrote. Each item has a documentId for read_document. Follow nextCursor for more; a source that failed and recovers on a later page can return entries older than that page. sources reports each source: not_connected and reconnect carry the provider to connect with oauth_get_auth_link.',
659692
inputSchema: listMyActivityInputSchema,
660693
},
694+
{
695+
id: 'search_experts',
696+
route: 'sim',
697+
description: SEARCH_EXPERTS_DESCRIPTION,
698+
inputSchema: searchExpertsInputSchema,
699+
},
661700
{
662701
id: 'oauth_get_auth_link',
663702
route: 'sim',

‎apps/sim/lib/internal/organization-search/execute-tool.integration.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,22 @@ describe('Organization Search tools in a workflow run', () => {
244244
expect((await response.json()).person).toMatchObject({ name: colleagueName })
245245
})
246246

247+
it('searches experts in a workflow run, pointing to integrations when no source is connected', async () => {
248+
const response = await executeOrganizationSearchTool({
249+
toolId: 'organization_search_experts',
250+
input: { query: 'billing migration' },
251+
headers: new Headers(),
252+
context: runAs(memberUserId, organizationWorkflowId, organizationWorkspaceId),
253+
requestId: generateId(),
254+
})
255+
expect(response.status).toBe(200)
256+
expect(await response.json()).toMatchObject({
257+
experts: [],
258+
sources: [],
259+
note: expect.stringMatching(/no connected sources.*\/integrations/),
260+
})
261+
})
262+
247263
it('refuses a run in an organization without Search', async () => {
248264
searchAvailable.value = false
249265
try {

‎apps/sim/lib/internal/organization-search/execute-tool.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { listOrganizationActivity } from '@/lib/internal/organization-search/lis
66
import { listOrganizationChatHistory } from '@/lib/internal/organization-search/list-my-chat-history'
77
import { readOrganizationDocument } from '@/lib/internal/organization-search/read-document'
88
import { searchOrganization } from '@/lib/internal/organization-search/search'
9+
import { searchOrganizationExperts } from '@/lib/internal/organization-search/search-experts'
910
import { searchOrganizationPeople } from '@/lib/internal/organization-search/search-people'
1011
import type { OrganizationSearchToolId } from '@/lib/internal/organization-search/tool-ids'
1112
import type { OrganizationSearchToolHandler } from '@/lib/internal/organization-search/types'
@@ -28,6 +29,7 @@ const HANDLERS: Record<OrganizationSearchToolId, OrganizationSearchToolHandler>
2829
organization_search_people: searchOrganizationPeople,
2930
organization_list_my_chat_history: listOrganizationChatHistory,
3031
organization_list_my_activity: listOrganizationActivity,
32+
organization_search_experts: searchOrganizationExperts,
3133
}
3234

3335
function failureResponse(toolId: string, error: unknown): Response {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { searchExpertsInputSchema } from '@/lib/api/contracts/mothership-assistant-tools'
2+
import { respondWithResultProvenance } from '@/lib/internal/organization-search/provenance'
3+
import type { OrganizationSearchToolHandler } from '@/lib/internal/organization-search/types'
4+
import { parseInternalOperationInput } from '@/lib/internal/tool-operations/parse-contract-input'
5+
import { searchExperts } from '@/lib/knowledge/application/experts'
6+
7+
/** `search_experts`, as the Search MCP and Assistant tool of that name. */
8+
export const searchOrganizationExperts: OrganizationSearchToolHandler = async (call) => {
9+
const parsed = parseInternalOperationInput({ body: searchExpertsInputSchema }, call.input)
10+
if (!parsed.success) return parsed.response
11+
const input = parsed.data.body
12+
return respondWithResultProvenance(call, input.query, (registry) =>
13+
searchExperts.execute({
14+
principal: call.principal,
15+
input: {
16+
...input,
17+
organizationId: call.principal.organizationId,
18+
surface: 'workflow',
19+
resultSecretRegistry: registry,
20+
signal: call.signal,
21+
},
22+
request: { headers: call.operation.headers },
23+
})
24+
)
25+
}

‎apps/sim/lib/internal/organization-search/tool-ids.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const ORGANIZATION_SEARCH_OPERATIONS = [
1717
{ id: 'search_people', label: 'Search People' },
1818
{ id: 'list_my_chat_history', label: 'List My Chat History' },
1919
{ id: 'list_my_activity', label: 'List My Activity' },
20+
{ id: 'search_experts', label: 'Search Experts' },
2021
] as const
2122

2223
/** An operation of the block, named as the Search MCP tool it runs. */

0 commit comments

Comments
 (0)