d25d482dc2
Publish CLI Package / publish-npm (push) Waiting to run
Publish Python SDK / publish-pypi (push) Waiting to run
Publish TypeScript SDK / publish-npm (push) Waiting to run
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
116 lines
3.7 KiB
TypeScript
116 lines
3.7 KiB
TypeScript
import type {
|
|
MicrosoftAdListGroupsParams,
|
|
MicrosoftAdListGroupsResponse,
|
|
} from '@/tools/microsoft_ad/types'
|
|
import { GROUP_OUTPUT_PROPERTIES } from '@/tools/microsoft_ad/types'
|
|
import { assertGraphNextPageUrl, getGraphNextPageUrl } from '@/tools/sharepoint/utils'
|
|
import type { ToolConfig } from '@/tools/types'
|
|
|
|
export const listGroupsTool: ToolConfig<
|
|
MicrosoftAdListGroupsParams,
|
|
MicrosoftAdListGroupsResponse
|
|
> = {
|
|
id: 'microsoft_ad_list_groups',
|
|
name: 'List Azure AD Groups',
|
|
description: 'List groups in Azure AD (Microsoft Entra ID)',
|
|
version: '1.0.0',
|
|
errorExtractor: 'nested-error-object',
|
|
oauth: {
|
|
required: true,
|
|
provider: 'microsoft-ad',
|
|
},
|
|
params: {
|
|
accessToken: {
|
|
type: 'string',
|
|
required: true,
|
|
visibility: 'hidden',
|
|
description: 'Microsoft Graph API access token',
|
|
},
|
|
top: {
|
|
type: 'number',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Maximum number of groups to return (default 100, max 999)',
|
|
},
|
|
filter: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'OData filter expression (e.g., "securityEnabled eq true")',
|
|
},
|
|
search: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description: 'Search string to filter groups by displayName or description',
|
|
},
|
|
nextLink: {
|
|
type: 'string',
|
|
required: false,
|
|
visibility: 'user-or-llm',
|
|
description:
|
|
'Continuation URL from a previous response\'s "nextLink" output, used to fetch the next page of results',
|
|
},
|
|
},
|
|
request: {
|
|
url: (params) => {
|
|
if (params.nextLink) return assertGraphNextPageUrl(params.nextLink)
|
|
const queryParts: string[] = []
|
|
queryParts.push(
|
|
'$select=id,displayName,description,mail,mailEnabled,mailNickname,securityEnabled,groupTypes,visibility,createdDateTime'
|
|
)
|
|
if (params.top) queryParts.push(`$top=${params.top}`)
|
|
if (params.filter) queryParts.push(`$filter=${encodeURIComponent(params.filter)}`)
|
|
if (params.search) {
|
|
const term = params.search.replace(/\\/g, '\\\\').replace(/"/g, '\\"')
|
|
queryParts.push(
|
|
`$search=${encodeURIComponent(`"displayName:${term}" OR "description:${term}"`)}`
|
|
)
|
|
queryParts.push('$count=true')
|
|
}
|
|
return `https://graph.microsoft.com/v1.0/groups?${queryParts.join('&')}`
|
|
},
|
|
method: 'GET',
|
|
headers: (params) => ({
|
|
Authorization: `Bearer ${params.accessToken}`,
|
|
ConsistencyLevel: 'eventual',
|
|
}),
|
|
},
|
|
transformResponse: async (response: Response) => {
|
|
const data = await response.json()
|
|
const groups = (data.value ?? []).map((group: Record<string, unknown>) => ({
|
|
id: group.id ?? null,
|
|
displayName: group.displayName ?? null,
|
|
description: group.description ?? null,
|
|
mail: group.mail ?? null,
|
|
mailEnabled: group.mailEnabled ?? null,
|
|
mailNickname: group.mailNickname ?? null,
|
|
securityEnabled: group.securityEnabled ?? null,
|
|
groupTypes: group.groupTypes ?? [],
|
|
visibility: group.visibility ?? null,
|
|
createdDateTime: group.createdDateTime ?? null,
|
|
}))
|
|
return {
|
|
success: true,
|
|
output: {
|
|
groups,
|
|
groupCount: groups.length,
|
|
nextLink: getGraphNextPageUrl(data) ?? null,
|
|
},
|
|
}
|
|
},
|
|
outputs: {
|
|
groups: {
|
|
type: 'array',
|
|
description: 'List of groups',
|
|
properties: GROUP_OUTPUT_PROPERTIES,
|
|
},
|
|
groupCount: { type: 'number', description: 'Number of groups returned' },
|
|
nextLink: {
|
|
type: 'string',
|
|
description: 'Continuation URL for the next page of results, or null if there are no more',
|
|
optional: true,
|
|
},
|
|
},
|
|
}
|