Repository navigation
feat(organization-search): run organization search tools in workflows as the run's person #10534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
005565e
feat(organization-search): run organization search tools in workflows…
waleedlatif1 58c683a
fix(organization-search): gate workflow tools on Search, project peop…
waleedlatif1 7cb4967
fix(organization-search): carry document and modified-date filters an…
waleedlatif1 558995c
chore(organization-search): renumber the tool_name check migration af…
waleedlatif1 b652360
fix(organization-search): keep model-supplied document filters and re…
waleedlatif1 bd964cf
fix(organization-search): import blockFieldOrToolArg, document the to…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,273 @@ | ||
| import { OrganizationSearchIcon } from '@/components/icons' | ||
| import type { BlockConfig } from '@/blocks/types' | ||
| import { | ||
| blockFieldOrToolArg, | ||
| mapperOperation, | ||
| parseOptionalJsonInput, | ||
| parseOptionalNumberInput, | ||
| } from '@/blocks/utils' | ||
|
|
||
| /** Operations, keyed by the Search MCP tool they run; each runs the tool `organization_<id>`. */ | ||
| const OPERATIONS = [ | ||
| { label: 'Search', id: 'search' }, | ||
| { label: 'Read Document', id: 'read_document' }, | ||
| { label: 'Search People', id: 'search_people' }, | ||
| ] as const | ||
|
|
||
| const OPERATION_IDS = new Set<string>(OPERATIONS.map((operation) => operation.id)) | ||
|
|
||
| /** Organization Search: the Search MCP tools as one workflow block, run as the run's person. */ | ||
| export const OrganizationBlock: BlockConfig = { | ||
| type: 'organization', | ||
| name: 'Organization Search', | ||
| description: 'Search your organization’s sources and people directory', | ||
| longDescription: | ||
| 'Search the organization’s connected sources through their live APIs, read the documents they return, and look people up in the People directory. 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. | ||
| - Runs started by a schedule, a webhook, or a workspace API key have no person to search as, and fail. | ||
| `, | ||
| bgColor: '#2563EB', | ||
| icon: OrganizationSearchIcon, | ||
| canvasPresentation: { | ||
| defaultTitle: 'Organization Search', | ||
| sentences: { | ||
| byOperation: { | ||
| search: [ | ||
| 'Search organization sources', | ||
| { text: 'for', field: 'query' }, | ||
| { text: 'in', field: 'source' }, | ||
| ], | ||
| read_document: [{ text: 'Read', field: 'documentId', core: true }], | ||
| search_people: ['Find people', { text: 'matching', field: 'query' }], | ||
| }, | ||
| }, | ||
| }, | ||
| category: 'blocks', | ||
| docsLink: 'https://docs.sim.ai/integrations/organization', | ||
| subBlocks: [ | ||
| { | ||
| id: 'operation', | ||
| title: 'Operation', | ||
| type: 'dropdown', | ||
| options: [...OPERATIONS], | ||
| value: () => 'search', | ||
| }, | ||
| { | ||
| id: 'query', | ||
| title: 'Query', | ||
| type: 'long-input', | ||
| placeholder: 'What to look for', | ||
| condition: { field: 'operation', value: ['search', 'search_people'] }, | ||
| }, | ||
| { | ||
| id: 'source', | ||
| title: 'Source', | ||
| type: 'short-input', | ||
| placeholder: 'slack, jira, confluence, google_drive, gitlab…', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'startDate', | ||
| title: 'Start Date', | ||
| type: 'short-input', | ||
| placeholder: '2026-01-01T00:00:00-08:00 (inclusive)', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'endDate', | ||
| title: 'End Date', | ||
| type: 'short-input', | ||
| placeholder: '2026-02-01T00:00:00-08:00 (exclusive)', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'modifiedAfter', | ||
| title: 'Modified After', | ||
| type: 'short-input', | ||
| placeholder: '2026-01-01T00:00:00Z', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'modifiedBefore', | ||
| title: 'Modified Before', | ||
| type: 'short-input', | ||
| placeholder: '2026-02-01T00:00:00Z', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'searchDocumentIds', | ||
| title: 'Only Documents', | ||
| type: 'long-input', | ||
| placeholder: 'documentIds from an earlier search, one per line', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'sortBy', | ||
| title: 'Sort By', | ||
| type: 'dropdown', | ||
| options: [ | ||
| { label: 'Relevance', id: 'relevance' }, | ||
| { label: 'Newest', id: 'newest' }, | ||
| { label: 'Oldest', id: 'oldest' }, | ||
| ], | ||
| value: () => 'relevance', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'involving', | ||
| title: 'Involving', | ||
| type: 'short-input', | ||
| placeholder: '"me" or a colleague’s email', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'nativeQueries', | ||
| title: 'Native Queries', | ||
| type: 'code', | ||
| language: 'json', | ||
| placeholder: | ||
| '[{ "provider": "jira", "accountId": "…", "query": "project = ENG", "cursor": "…" }]', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'topK', | ||
| title: 'Max Results', | ||
| type: 'short-input', | ||
| placeholder: '20', | ||
| condition: { field: 'operation', value: 'search' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'documentId', | ||
|
waleedlatif1 marked this conversation as resolved.
Resolved
|
||
| title: 'Document', | ||
| type: 'short-input', | ||
| placeholder: 'A documentId from Search, or a link to the item', | ||
| condition: { field: 'operation', value: 'read_document' }, | ||
| }, | ||
| { | ||
| id: 'documentIds', | ||
| title: 'Documents', | ||
| type: 'long-input', | ||
| placeholder: 'Up to 10 documentIds or links, one per line, read together instead of Document', | ||
| condition: { field: 'operation', value: 'read_document' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'startChunkIndex', | ||
| title: 'Start Chunk Index', | ||
| type: 'short-input', | ||
| placeholder: 'next.startChunkIndex from a previous read', | ||
| condition: { field: 'operation', value: 'read_document' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'startOffset', | ||
| title: 'Start Offset', | ||
| type: 'short-input', | ||
| placeholder: 'next.startOffset from a previous read', | ||
| condition: { field: 'operation', value: 'read_document' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'personId', | ||
| title: 'Person ID', | ||
| type: 'short-input', | ||
| placeholder: 'A personId from an earlier result', | ||
| condition: { field: 'operation', value: 'search_people' }, | ||
| mode: 'advanced', | ||
| }, | ||
| { | ||
| id: 'cursor', | ||
| title: 'Cursor', | ||
| type: 'short-input', | ||
| placeholder: 'nextCursor from the previous page', | ||
| condition: { field: 'operation', value: 'search_people' }, | ||
| mode: 'advanced', | ||
| }, | ||
| ], | ||
| tools: { | ||
| access: OPERATIONS.map((operation) => `organization_${operation.id}`), | ||
| config: { | ||
| tool: (params) => `organization_${params.operation || 'search'}`, | ||
| params: (params, context) => { | ||
| const operation = mapperOperation(params, context) || 'search' | ||
| if (!OPERATION_IDS.has(operation)) | ||
| throw new Error(`Unsupported Organization Search operation: ${operation}`) | ||
| if (operation === 'read_document' && !params.documentId === !params.documentIds) | ||
| throw new Error('Read Document needs either a Document or a list of Documents') | ||
| return { | ||
| ...params, | ||
|
waleedlatif1 marked this conversation as resolved.
Resolved
|
||
| ...(operation === 'search' | ||
| ? { | ||
| documentIds: blockFieldOrToolArg( | ||
|
waleedlatif1 marked this conversation as resolved.
Resolved
|
||
| context, | ||
| params.searchDocumentIds, | ||
| params.documentIds | ||
| ), | ||
| } | ||
| : {}), | ||
| topK: parseOptionalNumberInput(params.topK, 'Max Results'), | ||
| nativeQueries: parseOptionalJsonInput(params.nativeQueries, 'Native Queries'), | ||
| startChunkIndex: parseOptionalNumberInput(params.startChunkIndex, 'Start Chunk Index'), | ||
| startOffset: parseOptionalNumberInput(params.startOffset, 'Start Offset'), | ||
| } | ||
| }, | ||
| }, | ||
| }, | ||
| inputs: { | ||
| operation: { type: 'string', description: 'Operation to perform' }, | ||
| query: { type: 'string', description: 'Search terms, or words from a person’s profile' }, | ||
| source: { type: 'string', description: 'Only this source' }, | ||
| startDate: { type: 'string', description: 'Inclusive lower date bound (ISO datetime)' }, | ||
| endDate: { type: 'string', description: 'Exclusive upper date bound (ISO datetime)' }, | ||
| sortBy: { type: 'string', description: 'relevance, newest, or oldest' }, | ||
| involving: { type: 'string', description: '"me" or a colleague’s email' }, | ||
| nativeQueries: { | ||
| type: 'json', | ||
| description: 'Provider-language queries and continuation cursors', | ||
| }, | ||
| topK: { type: 'number', description: 'Maximum results' }, | ||
| modifiedAfter: { type: 'string', description: 'Only documents modified after (ISO datetime)' }, | ||
| modifiedBefore: { | ||
| type: 'string', | ||
| description: 'Only documents modified before (ISO datetime)', | ||
| }, | ||
| searchDocumentIds: { type: 'string', description: 'Search only these documentIds' }, | ||
| documentId: { type: 'string', description: 'Document to read' }, | ||
| documentIds: { type: 'string', description: 'Documents to read together' }, | ||
| 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' }, | ||
| }, | ||
| outputs: { | ||
| results: { type: 'array', description: 'Search: matching documents with passages' }, | ||
| retrieval: { type: 'json', description: 'Search: whether retrieval was complete' }, | ||
| live: { type: 'json', description: 'Search: per-account status and cursors' }, | ||
| documentId: { type: 'string', description: 'Read Document: the document read' }, | ||
| title: { type: 'string', description: 'Read Document: document title' }, | ||
| citationUrl: { type: 'string', description: 'Read Document: link to the document' }, | ||
| chunks: { type: 'array', description: 'Read Document: the text read' }, | ||
| hasMore: { type: 'boolean', description: 'Read Document: whether more remains' }, | ||
| next: { type: 'json', description: 'Read Document: where to continue' }, | ||
| documents: { | ||
| type: 'array', | ||
| description: 'Read Document: each document of a multi-document read, or its error', | ||
| }, | ||
| people: { type: 'array', description: 'Search People: matching people' }, | ||
| person: { type: 'json', description: 'Search People: the one matching person' }, | ||
| nextCursor: { type: 'string', description: 'Search People: cursor for the next page' }, | ||
| note: { type: 'string', description: 'Search People: guidance when no one matches' }, | ||
| }, | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "namespace": "organization", | ||
| "methods": { | ||
| "read_document": "readDocument", | ||
| "search": "search", | ||
| "search_people": "searchPeople" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.