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
36 changes: 26 additions & 10 deletions apps/sim/blocks/blocks/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const OPERATIONS = [
{ label: 'Read Document', id: 'read_document' },
{ label: 'Search People', id: 'search_people' },
{ label: 'List My Chat History', id: 'list_my_chat_history' },
{ label: 'List My Activity', id: 'list_my_activity' },
] as const

const OPERATION_IDS = new Set<string>(OPERATIONS.map((operation) => operation.id))
Expand All @@ -21,12 +22,14 @@ const OPERATION_IDS = new Set<string>(OPERATIONS.map((operation) => operation.id
export const OrganizationBlock: BlockConfig = {
type: 'organization',
name: 'Organization Search',
description: 'Search your organization’s sources, people directory, and your own chat history',
description:
'Search your organization’s sources, people directory, and your own chat history and activity',
longDescription:
'Search the organization’s connected sources through their live APIs, read the documents they return, and look people up in the People directory, and list your own questions to Sim over a date window. Every operation runs as the person who started the run, within their own access, so a scheduled or webhook run without a person fails instead of borrowing anyone’s access.',
'Search the organization’s connected sources through their live APIs, read the documents they return, look people up in the People directory, list your own questions to Sim over a date window, and list what you did across your connected sources. Every operation runs as the person who started the run, within their own access, so a scheduled or webhook run without a person fails instead of borrowing anyone’s access.',
bestPractices: `
- Use Search to find candidates, then Read Document with a returned documentId when the passage is not enough.
- Search People covers only this organization's people; use Search for customers, vendors, and other outside contacts.
- List My Activity covers only the run's person's own activity; use Search to find what anyone else did.
- Runs started by a schedule, a webhook, or a workspace API key have no person to search as, and fail.
`,
bgColor: '#2563EB',
Expand All @@ -46,6 +49,7 @@ export const OrganizationBlock: BlockConfig = {
'List my questions to Sim',
{ text: 'since', field: 'historyStartDate' },
],
list_my_activity: ['List my activity', { text: 'in', field: 'source' }],
},
},
},
Expand All @@ -71,23 +75,23 @@ export const OrganizationBlock: BlockConfig = {
title: 'Source',
type: 'short-input',
placeholder: 'slack, jira, confluence, google_drive, gitlab…',
condition: { field: 'operation', value: 'search' },
condition: { field: 'operation', value: ['search', 'list_my_activity'] },
mode: 'advanced',
},
{
id: 'startDate',
title: 'Start Date',
type: 'short-input',
placeholder: '2026-01-01T00:00:00-08:00 (inclusive)',
condition: { field: 'operation', value: 'search' },
condition: { field: 'operation', value: ['search', 'list_my_activity'] },
mode: 'advanced',
},
{
id: 'endDate',
title: 'End Date',
type: 'short-input',
placeholder: '2026-02-01T00:00:00-08:00 (exclusive)',
condition: { field: 'operation', value: 'search' },
condition: { field: 'operation', value: ['search', 'list_my_activity'] },
mode: 'advanced',
},
{
Expand Down Expand Up @@ -178,8 +182,11 @@ export const OrganizationBlock: BlockConfig = {
id: 'topK',
title: 'Max Results',
type: 'short-input',
placeholder: '20 for Search, 50 for chat history',
condition: { field: 'operation', value: ['search', 'list_my_chat_history'] },
placeholder: '20 for Search, 25 for activity, 50 for chat history',
condition: {
field: 'operation',
value: ['search', 'list_my_chat_history', 'list_my_activity'],
},
mode: 'advanced',
},
{
Expand Down Expand Up @@ -226,7 +233,7 @@ export const OrganizationBlock: BlockConfig = {
title: 'Cursor',
type: 'short-input',
placeholder: 'nextCursor from the previous page',
condition: { field: 'operation', value: 'search_people' },
condition: { field: 'operation', value: ['search_people', 'list_my_activity'] },
mode: 'advanced',
},
],
Expand Down Expand Up @@ -290,7 +297,7 @@ export const OrganizationBlock: BlockConfig = {
startChunkIndex: { type: 'number', description: 'Chunk to continue reading from' },
startOffset: { type: 'number', description: 'Where to continue reading' },
personId: { type: 'string', description: 'Person to show with their reporting line' },
cursor: { type: 'string', description: 'Next page of a people search' },
cursor: { type: 'string', description: 'Next page of a people search or activity listing' },
historyCursor: { type: 'string', description: 'Chat history: next page of the same window' },
historyStartDate: {
type: 'string',
Expand All @@ -317,12 +324,21 @@ export const OrganizationBlock: BlockConfig = {
person: { type: 'json', description: 'Search People: the one matching person' },
nextCursor: {
type: 'string',
description: 'Search People or List My Chat History: cursor for the next page',
description:
'Search People, List My Chat History or List My Activity: cursor for the next page',
},
questions: {
type: 'array',
description: 'List My Chat History: the person’s own questions, oldest first',
},
note: { type: 'string', description: 'Search People: guidance when no one matches' },
window: { type: 'json', description: 'List My Activity: the window read' },
items: { type: 'array', description: 'List My Activity: activity entries, newest first' },
truncated: { type: 'boolean', description: 'List My Activity: whether more entries remain' },
coverage: { type: 'string', description: 'List My Activity: complete or partial' },
sources: {
type: 'array',
description: 'List My Activity: each source’s status and where to connect it',
},
},
}
2 changes: 1 addition & 1 deletion apps/sim/blocks/sdk-names.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const BLOCKS: Record<string, string> = {
openai: '{"namespace":"legacy.openai"}',
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"}}}',
oracledb: '{"namespace":"oracledb","methods":{"delete":"deleteData","execute":"executeSql","insert":"insertData","introspect":"introspectSchema","query":"querySelect","update":"updateData"},"paramAliases":{"action":{"oauthCredential":"credential"}}}',
organization: '{"namespace":"organization","methods":{"list_my_chat_history":"listMyChatHistory","read_document":"readDocument","search":"search","search_people":"searchPeople"}}',
organization: '{"namespace":"organization","methods":{"list_my_activity":"listMyActivity","list_my_chat_history":"listMyChatHistory","read_document":"readDocument","search":"search","search_people":"searchPeople"}}',
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"}}',
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"}}}',
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"}}}',
Expand Down
1 change: 1 addition & 0 deletions apps/sim/blocks/sdk-names/organization.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"namespace": "organization",
"methods": {
"list_my_activity": "listMyActivity",
"list_my_chat_history": "listMyChatHistory",
"read_document": "readDocument",
"search": "search",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
copilotMessages,
member,
organization,
organizationSearchIntegration,
user,
workflow,
workspace,
Expand All @@ -24,7 +25,10 @@ import { executeOrganizationSearchTool } from '@/lib/internal/organization-searc
import type { InternalToolOperationContext } from '@/lib/internal/tool-operations/types'
import { listDepartments, listPeople } from '@/lib/people/application/use-cases'

vi.hoisted(() => vi.stubEnv('PEOPLE', 'true'))
vi.hoisted(() => {
vi.stubEnv('PEOPLE', 'true')
vi.stubEnv('MY_ACTIVITY', 'true')
})

const { searchAvailable } = vi.hoisted(() => ({ searchAvailable: { value: true } }))
vi.mock('@/lib/knowledge/access/availability', async (importOriginal) => ({
Expand Down Expand Up @@ -193,6 +197,20 @@ describe('Organization Search tools in a workflow run', () => {
expect(body.questions.map((q: { question: string }) => q.question)).toEqual(['my question'])
})

it("lists the run's person's activity sources in the workflow's organization", async () => {
await db
.insert(organizationSearchIntegration)
.values({ organizationId, connectorType: 'slack', approved: true })
const response = await call(
runAs(memberUserId, organizationWorkflowId, organizationWorkspaceId),
{},
'organization_list_my_activity'
)
expect(response.status).toBe(200)
const body = await response.json()
expect(body.sources.map((source: { source: string }) => source.source)).toEqual(['slack'])
})

it('refuses a run in an organization without Search', async () => {
searchAvailable.value = false
try {
Expand All @@ -212,6 +230,7 @@ describe('Organization Search tools in a workflow run', () => {
it.each([
['organization_search_people', { query: colleagueName }],
['organization_list_my_chat_history', { startDate: '2026-11-01T00:00:00Z' }],
['organization_list_my_activity', {}],
] as const)(
'refuses a scheduled run of %s, which has no person to act as',
async (toolId, input) => {
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/lib/internal/organization-search/execute-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { createLogger } from '@sim/logger'
import { isPlainRecord } from '@sim/utils/object'
import { orchestrationFailureResponse } from '@/lib/api/server/orchestration-response'
import { RESOLVED_SECRET_PROVENANCE_FIELD } from '@/lib/execution/private-tool-metadata'
import { listOrganizationActivity } from '@/lib/internal/organization-search/list-my-activity'
import { listOrganizationChatHistory } from '@/lib/internal/organization-search/list-my-chat-history'
import { readOrganizationDocument } from '@/lib/internal/organization-search/read-document'
import { searchOrganization } from '@/lib/internal/organization-search/search'
Expand All @@ -27,6 +28,7 @@ const HANDLERS: Record<OrganizationSearchToolId, OrganizationSearchToolHandler>
organization_read_document: readOrganizationDocument,
organization_search_people: searchOrganizationPeople,
organization_list_my_chat_history: listOrganizationChatHistory,
organization_list_my_activity: listOrganizationActivity,
}

function failureResponse(toolId: string, error: unknown): Response {
Expand Down
24 changes: 24 additions & 0 deletions apps/sim/lib/internal/organization-search/list-my-activity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { listMyActivityMcpSchema } from '@/lib/api/contracts/knowledge/mcp'
import { respondWithResultProvenance } from '@/lib/internal/organization-search/provenance'
import type { OrganizationSearchToolHandler } from '@/lib/internal/organization-search/types'
import { parseInternalOperationInput } from '@/lib/internal/tool-operations/parse-contract-input'
import { listMyActivity } from '@/lib/sim-search/live/activity'

/** `list_my_activity`, as the Search MCP and Assistant tool of that name. */
export const listOrganizationActivity: OrganizationSearchToolHandler = async (call) => {
const parsed = parseInternalOperationInput({ body: listMyActivityMcpSchema }, call.input)
if (!parsed.success) return parsed.response
const input = parsed.data.body
return respondWithResultProvenance(call, undefined, (registry) =>
listMyActivity.execute({
principal: call.principal,
input: {
...input,
organizationId: call.principal.organizationId,
resultSecretRegistry: registry,
signal: call.signal,
},
request: { headers: call.operation.headers },
})
)
}
1 change: 1 addition & 0 deletions apps/sim/lib/internal/organization-search/tool-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const ORGANIZATION_SEARCH_TOOL_IDS = [
'organization_read_document',
'organization_search_people',
'organization_list_my_chat_history',
'organization_list_my_activity',
] as const

export type OrganizationSearchToolId = (typeof ORGANIZATION_SEARCH_TOOL_IDS)[number]
2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-ids.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-metadata.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-outputs.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions apps/sim/tools/organization/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { organizationListMyActivityTool } from '@/tools/organization/list_my_activity'
export { organizationListMyChatHistoryTool } from '@/tools/organization/list_my_chat_history'
export { organizationReadDocumentTool } from '@/tools/organization/read_document'
export { organizationSearchTool } from '@/tools/organization/search'
Expand Down
85 changes: 85 additions & 0 deletions apps/sim/tools/organization/list_my_activity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import type {
OrganizationListMyActivityParams,
OrganizationToolResponse,
} from '@/tools/organization/types'
import { organizationToolOutput, presentFields } from '@/tools/organization/utils'
import type { InternalToolConfig } from '@/tools/types'

/** Lists what the run's person did across their connected sources, as the Search MCP `list_my_activity` tool does. */
export const organizationListMyActivityTool: InternalToolConfig<
OrganizationListMyActivityParams,
OrganizationToolResponse
> = {
id: 'organization_list_my_activity',
name: 'Organization List My Activity',
description:
'List what the person running the workflow did across their connected sources in a date window, newest first: Slack messages and Gmail mail they sent or replied to, Google Calendar meetings they attended, Jira issues they created or are assigned, and Confluence pages they created or edited and comments they wrote. Defaults to the last 7 days; the window spans at most 92 days. When truncated is true, pass nextCursor as cursor with the same other arguments for the next page. sources reports each source, including the ones the person has not connected.',
version: '1.0.0',
effect: 'read',

params: {
startDate: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Inclusive start of the window, an ISO datetime with a timezone offset. Defaults to 7 days before endDate.',
},
endDate: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'Exclusive end of the window, an ISO datetime with a timezone offset. Defaults to now.',
},
source: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description:
'One source to read: slack, gmail, google_calendar, jira or confluence. Omit for every connected source.',
},
topK: {
type: 'number',
required: false,
visibility: 'user-or-llm',
description: 'Maximum entries on this page, 1 to 50; 25 by default.',
},
cursor: {
type: 'string',
required: false,
visibility: 'user-or-llm',
description: 'nextCursor from the previous page, with the same other arguments.',
},
},

operation: {
secretProvenance: { response: { incomplete: 'reject' } },
input: (params) =>
presentFields({
startDate: params.startDate,
endDate: params.endDate,
source: params.source,
topK: params.topK,
cursor: params.cursor,
}),
},

transformResponse: organizationToolOutput,

outputs: {
window: { type: 'json', description: 'The window read: startDate and endDate' },
items: {
type: 'array',
description:
'Activity entries, newest first: documentId, timestamp, source, action, title, url, collaborators, snippet',
},
truncated: { type: 'boolean', description: 'Whether more entries remain' },
nextCursor: { type: 'string', description: 'Cursor for the next page' },
coverage: { type: 'string', description: 'complete or partial' },
sources: {
type: 'array',
description: 'Each source’s status, with where to connect the ones not connected',
},
},
}
Loading
Loading