Skip to content
Open
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
1 change: 1 addition & 0 deletions apps/docs/content/docs/integrations/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"onepassword",
"oracle_fusion_financials",
"oracledb",
"organization",
"otter",
"outlook",
"pagerduty",
Expand Down
14 changes: 14 additions & 0 deletions apps/docs/content/docs/integrations/organization.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Organization Search
description: Search your organization’s sources, people directory, and your own chat history and activity
integration:
type: "organization"
color: "#2563EB"
---


## Use the block [#usage-instructions]

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. Results are returned to the workflow and appear in its run logs, which other workspace members can read.


Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ describe('POST /api/resume/[workflowId]/[executionId]/[contextId]', () => {
contextId: CONTEXT_ID,
resumeInput: { approved: true },
userId: WORKSPACE_BILLING_OWNER_ID,
resumedBy: { subjectUserId: null },
allowedPauseKinds: ['human'],
})
})
Expand Down Expand Up @@ -460,6 +461,7 @@ describe('POST /api/resume/[workflowId]/[executionId]/[contextId]', () => {
contextId: CONTEXT_ID,
workspaceId: WORKSPACE_ID,
userId: 'current-api-key-user',
resumedBy: { subjectUserId: 'current-api-key-user' },
resumeInput: { approved: true },
isApiCaller: true,
pollingSurface: 'v2',
Expand Down
27 changes: 12 additions & 15 deletions apps/sim/blocks/blocks/organization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { OrganizationSearchIcon } from '@/components/icons'
import {
ORGANIZATION_SEARCH_OPERATIONS,
ORGANIZATION_SEARCH_TOOL_IDS,
organizationSearchToolId,
} from '@/lib/internal/organization-search/tool-ids'
import type { BlockConfig } from '@/blocks/types'
import {
blockFieldOrToolArg,
Expand All @@ -7,16 +12,7 @@ import {
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' },
{ 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))
const OPERATION_IDS = new Set<string>(ORGANIZATION_SEARCH_OPERATIONS.map(({ id }) => id))

/** Organization Search: the Search MCP tools as one workflow block, run as the run's person. */
export const OrganizationBlock: BlockConfig = {
Expand All @@ -25,12 +21,13 @@ export const OrganizationBlock: BlockConfig = {
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, 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.',
'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. Results are returned to the workflow and appear in its run logs, which other workspace members can read.',
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.
- Runs started by a schedule, a webhook, or a workspace API key have no person to search as, and fail; so does a run resumed by someone other than the person who started it.
- Results are returned to the workflow and appear in its run logs, which other workspace members can read. Pass on only what the workflow needs.
`,
bgColor: '#2563EB',
icon: OrganizationSearchIcon,
Expand Down Expand Up @@ -60,7 +57,7 @@ export const OrganizationBlock: BlockConfig = {
id: 'operation',
title: 'Operation',
type: 'dropdown',
options: [...OPERATIONS],
options: [...ORGANIZATION_SEARCH_OPERATIONS],
value: () => 'search',
},
{
Expand Down Expand Up @@ -286,9 +283,9 @@ export const OrganizationBlock: BlockConfig = {
},
],
tools: {
access: OPERATIONS.map((operation) => `organization_${operation.id}`),
access: [...ORGANIZATION_SEARCH_TOOL_IDS],
config: {
tool: (params) => `organization_${params.operation || 'search'}`,
tool: (params) => organizationSearchToolId(params.operation || 'search'),
params: (params, context) => {
const operation = mapperOperation(params, context) || 'search'
if (!OPERATION_IDS.has(operation))
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/executor/execution/snapshot-serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ function buildExecutionSnapshot(
/** Preserve the run-level agent-events opt-in across HITL pause/resume. */
agentEvents: metadataFromContext?.agentEvents === true ? true : undefined,
stopAfterBlockId: metadataFromContext?.stopAfterBlockId,
/** A resume by someone other than the run's person stays on the run for every later segment. */
resumedBy: metadataFromContext?.resumedBy,
}

const snapshot = new ExecutionSnapshot(
Expand Down
3 changes: 3 additions & 0 deletions apps/sim/executor/execution/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { NodeMetadata } from '@/executor/dag/types'
import type {
BlockLog,
BlockState,
ExecutionResumer,
ExecutorDelegationOrigin,
NormalizedBlockOutput,
StartBlockRunMetadata,
Expand Down Expand Up @@ -62,6 +63,8 @@ export interface ExecutionMetadata {
resumeTerminalNoop?: boolean
/** Other durable pauses remain after the current context resumes. */
resumeHasPendingPauses?: boolean
/** Who resumed this attempt, for operations that act as the run's person. */
resumedBy?: ExecutionResumer
/** Original workflow block ID, before loop/parallel sentinel resolution. */
stopAfterBlockId?: string
/** A resumed pause completed the stop target before the engine starts. */
Expand Down
13 changes: 13 additions & 0 deletions apps/sim/executor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export interface PausePoint {
response: any
registeredAt: string
resumeStatus: ResumeStatus
/** The caller who resumed this point, recorded when the resume is admitted. */
resumedBy?: ExecutionResumer
automaticResumeWaitingReason?: string
snapshotReady: boolean
parallelScope?: ParallelPauseScope
Expand Down Expand Up @@ -451,6 +453,17 @@ export interface ExecutorDelegationOrigin {
executionId?: string
principal?: WorkflowExecutionPrincipal
currentWorkflow?: WorkflowExecutionAuthority
/** Who resumed this run from a pause; absent for a run never resumed, or resumed on a timer. */
resumedBy?: ExecutionResumer
}

/**
* The caller who resumed a paused run: their Sim user, or `null` for a caller acting for no
* person (a workspace API key). Operations that act as the run's person refuse a run resumed by
* anyone else, so a resume cannot steer them as the person who started it.
*/
export interface ExecutionResumer {
subjectUserId: string | null
}

export interface ExecutionContext {
Expand Down
13 changes: 11 additions & 2 deletions apps/sim/hooks/use-integration-access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ export function useIntegrationAccessPolicy(
): IntegrationAccessPolicyState {
const enabled = options?.enabled ?? true
const blockOverlayVersion = useCustomBlockOverlayVersion()
const credentialGroupsEnabled = useOptionalWorkspaceHostContext()?.features?.credentialGroups
const hostFeatures = useOptionalWorkspaceHostContext()?.features
const credentialGroupsEnabled = hostFeatures?.credentialGroups
const organizationSearchEnabled = hostFeatures?.organizationSearch
const {
data: permissionData,
isSuccess: isPermissionReady,
Expand All @@ -85,8 +87,15 @@ export function useIntegrationAccessPolicy(
availability: availabilityData?.integrationAvailability ?? [],
visibility: overlayVisibility(),
credentialGroupsEnabled: credentialGroupsEnabled === true,
organizationSearchEnabled: organizationSearchEnabled === true,
}),
[permissionData?.config, availabilityData, credentialGroupsEnabled, blockOverlayVersion]
[
permissionData?.config,
availabilityData,
credentialGroupsEnabled,
organizationSearchEnabled,
blockOverlayVersion,
]
)

const oauthServiceAvailability = useMemo(
Expand Down
7 changes: 7 additions & 0 deletions apps/sim/lib/integrations/access.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function accessOf(
deploymentAllowlist?: string[] | null
availability?: IntegrationAvailabilityResponse[]
credentialGroupsEnabled?: boolean
organizationSearchEnabled?: boolean
groupConfig?: PermissionGroupConfig
}
): IntegrationAccess {
Expand All @@ -28,6 +29,7 @@ function accessOf(
availability: policy.availability ?? [],
visibility: null,
credentialGroupsEnabled: policy.credentialGroupsEnabled ?? true,
organizationSearchEnabled: policy.organizationSearchEnabled ?? true,
groupConfig: policy.groupConfig,
})
)
Expand Down Expand Up @@ -73,4 +75,9 @@ describe('resolveIntegrationAccess', () => {
it('denies credential groups where the feature is off, even when unrestricted', () => {
expect(accessOf('credential_group', { credentialGroupsEnabled: false })).toBe('denied')
})

it('denies Organization Search outside an organization with Search, even when unrestricted', () => {
expect(accessOf('organization', { organizationSearchEnabled: false })).toBe('denied')
expect(accessOf('organization', { organizationSearchEnabled: true })).toBe('available')
})
})
12 changes: 12 additions & 0 deletions apps/sim/lib/integrations/access.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export interface IntegrationAccessPolicy {
/** Deployment availability by lowercased block type, projected through the viewer's visibility. */
availability: ReadonlyMap<string, IntegrationAvailabilityResponse>
credentialGroupsEnabled: boolean
/**
* Organization Search is on for the workspace's organization and open to the viewer. This only
* hides the block; its use cases still refuse an organization without Search on the server.
*/
organizationSearchEnabled: boolean
groupConfig?: PermissionGroupConfig | null
}

Expand All @@ -61,6 +66,7 @@ interface IntegrationAccessPolicyInput {
availability: readonly IntegrationAvailabilityResponse[]
visibility: BlockVisibilityState | null
credentialGroupsEnabled: boolean
organizationSearchEnabled: boolean
groupConfig?: PermissionGroupConfig | null
}

Expand All @@ -70,6 +76,7 @@ export function createIntegrationAccessPolicy({
availability,
visibility,
credentialGroupsEnabled,
organizationSearchEnabled,
groupConfig,
}: IntegrationAccessPolicyInput): IntegrationAccessPolicy {
return {
Expand All @@ -82,6 +89,7 @@ export function createIntegrationAccessPolicy({
])
),
credentialGroupsEnabled,
organizationSearchEnabled,
groupConfig,
}
}
Expand All @@ -106,6 +114,10 @@ export function resolveIntegrationAccess(
if (normalizedBlockType === 'credential_group' && !policy.credentialGroupsEnabled) {
return 'denied'
}
// Organization Search runs only in an organization that has Search, for one of its members.
if (normalizedBlockType === 'organization' && !policy.organizationSearchEnabled) {
return 'denied'
}
const state = policy.availability.get(normalizedBlockType)?.state
const unconfigured =
isDeploymentGatedIntegrationType(normalizedBlockType) &&
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/lib/integrations/icon-mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ import {
OktaIcon,
OnePasswordIcon,
OracleIcon,
OrganizationSearchIcon,
OtterIcon,
OutlookIcon,
PackageSearchIcon,
Expand Down Expand Up @@ -585,6 +586,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
onepassword: OnePasswordIcon,
oracle_fusion_financials: OracleIcon,
oracledb: OracleIcon,
organization: OrganizationSearchIcon,
otter: OtterIcon,
otter_v2: OtterIcon,
outlook: OutlookIcon,
Expand Down
Loading