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
16 changes: 8 additions & 8 deletions apps/docs/content/docs/integrations/cloudtrail.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,14 @@ List the CloudTrail Lake event data stores in the account for the current Region
| `eventDataStores` | array | Event data stores in the account for the current Region |
| ↳ `eventDataStoreArn` | string | ARN of the event data store |
| ↳ `name` | string | Name of the event data store |
| ↳ `status` | string | CREATED, ENABLED, PENDING_DELETION, or an ingestion state |
| ↳ `advancedEventSelectors` | array | Advanced event selectors that define what the store ingests |
| ↳ `multiRegionEnabled` | boolean | Whether the store collects events from all Regions |
| ↳ `organizationEnabled` | boolean | Whether the store collects events for the organization |
| ↳ `retentionPeriod` | number | Retention period in days |
| ↳ `terminationProtectionEnabled` | boolean | Whether termination protection is enabled |
| ↳ `createdTimestamp` | string | When the store was created \(ISO 8601\) |
| ↳ `updatedTimestamp` | string | When the store was last updated \(ISO 8601\) |
| ↳ `status` | string | Store status. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `advancedEventSelectors` | array | Advanced event selectors. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `multiRegionEnabled` | boolean | Whether the store is multi-Region. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `organizationEnabled` | boolean | Whether the store is an organization store. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `retentionPeriod` | number | Retention period in days. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `terminationProtectionEnabled` | boolean | Whether termination protection is enabled. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `createdTimestamp` | string | Creation time. AWS no longer returns it from this list; read it with Get Event Data Store |
| ↳ `updatedTimestamp` | string | Last update time. AWS no longer returns it from this list; read it with Get Event Data Store |
| `nextToken` | string | Pagination token for the next page of event data stores |

</ReferenceDetails>
Expand Down
69 changes: 69 additions & 0 deletions apps/sim/blocks/blocks/aws-stale-inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,23 @@ import { awsDynamodbScanContract } from '@/lib/api/contracts/tools/aws/dynamodb-
import { awsIamCreateUserContract } from '@/lib/api/contracts/tools/aws/iam-create-user'
import { awsIamListPoliciesContract } from '@/lib/api/contracts/tools/aws/iam-list-policies'
import { awsSesSendTemplatedEmailContract } from '@/lib/api/contracts/tools/aws/ses-send-templated-email'
import { awsSqsListMessageMoveTasksContract } from '@/lib/api/contracts/tools/aws/sqs-list-message-move-tasks'
import { awsSsmGetParametersByPathContract } from '@/lib/api/contracts/tools/aws/ssm-get-parameters-by-path'
import { CloudFormationBlock } from '@/blocks/blocks/cloudformation'
import { DynamoDBBlock } from '@/blocks/blocks/dynamodb'
import { IAMBlock } from '@/blocks/blocks/iam'
import { SESBlock } from '@/blocks/blocks/ses'
import { SQSBlock } from '@/blocks/blocks/sqs'
import { SSMBlock } from '@/blocks/blocks/ssm'
import type { BlockConfig } from '@/blocks/types'
import { createChangeSetTool } from '@/tools/cloudformation/create_change_set'
import { scanTool } from '@/tools/dynamodb/scan'
import { createUserTool } from '@/tools/iam/create_user'
import { listPoliciesTool } from '@/tools/iam/list_policies'
import { sendTemplatedEmailTool } from '@/tools/ses/send_templated_email'
import { listMessageMoveTasksTool } from '@/tools/sqs/list_message_move_tasks'
import { receiveMessageTool } from '@/tools/sqs/receive_message'
import { getParametersByPathTool } from '@/tools/ssm/get_parameters_by_path'

const AWS = { region: 'us-east-1', accessKeyId: 'AKIAEXAMPLE', secretAccessKey: 'secret' }

Expand Down Expand Up @@ -104,4 +111,66 @@ describe('AWS blocks keep stale subBlock values out of tool input', () => {
})
).toThrow('Tags must be a list of {"key", "value"} entries or a JSON object')
})

it('SQS receive ignores the change-visibility timeout', () => {
const params = executorParams(SQSBlock, {
...AWS,
operation: 'receive_message',
queueUrl: 'https://sqs.us-east-1.amazonaws.com/123456789012/orders',
visibilityTimeout: '43200',
})
const body = receiveMessageTool.operation.input(params as never) as Record<string, unknown>
expect(body.visibilityTimeout).toBeUndefined()
})

it('SQS list move tasks ignores the list queues max results', () => {
const params = executorParams(SQSBlock, {
...AWS,
operation: 'list_message_move_tasks',
sourceArn: 'arn:aws:sqs:us-east-1:123456789012:orders-dlq',
maxResults: '1000',
})
const body = listMessageMoveTasksTool.operation.input(params as never) as Record<
string,
unknown
>
expect(body.maxResults).toBeUndefined()
expect(awsSqsListMessageMoveTasksContract.body?.safeParse(body).success).toBe(true)
})

it('SSM get parameters by path ignores the list max results', () => {
const params = executorParams(SSMBlock, {
...AWS,
operation: 'get_parameters_by_path',
parameterPath: '/app',
maxResults: '50',
})
const body = getParametersByPathTool.operation.input(params as never) as Record<string, unknown>
expect(body.maxResults).toBeUndefined()
expect(awsSsmGetParametersByPathContract.body?.safeParse(body).success).toBe(true)
})

it('a blank stored limit still lets an Agent call pass its own limit', () => {
const sqs = SQSBlock.tools.config?.params?.(
{
...AWS,
receiveVisibilityTimeout: '',
visibilityTimeout: 30,
moveTaskMaxResults: '',
maxResults: 5,
},
{ operation: 'receive_message' }
)
expect(sqs?.visibilityTimeout).toBe(30)
const moveTasks = SQSBlock.tools.config?.params?.(
{ ...AWS, moveTaskMaxResults: '', maxResults: 5 },
{ operation: 'list_message_move_tasks' }
)
expect(moveTasks?.maxResults).toBe(5)
const ssm = SSMBlock.tools.config?.params?.(
{ ...AWS, pathMaxResults: '', maxResults: 5 },
{ operation: 'get_parameters_by_path' }
)
expect(ssm?.maxResults).toBe(5)
})
})
2 changes: 1 addition & 1 deletion apps/sim/blocks/blocks/cloudtrail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ export const CloudTrailBlockMeta = {
description:
'Run a SQL query against a CloudTrail Lake event data store, wait for it to finish, and return the rows. Use for aggregate audit questions that span more than 90 days.',
content:
'# Run Lake Query\n\nAnswer an aggregate audit question with CloudTrail Lake.\n\n## Steps\n1. List event data stores, or get one by ARN, to find the store ID to query and confirm its retention period.\n2. Compose the SQL, naming the event data store ID in the FROM clause.\n3. Start the query to obtain a query ID.\n4. Poll describe query with that query ID until the status is FINISHED, FAILED, CANCELLED, or TIMED_OUT.\n5. On FINISHED, fetch the query results with the same query ID, paging with the returned token until no token comes back.\n6. Cancel the query if it is no longer needed while still RUNNING.\n\n## Output\nThe result rows, plus the query ID, events matched, events scanned, and run time. On failure, surface the error message and the SQL that produced it.',
'# Run Lake Query\n\nAnswer an aggregate audit question with CloudTrail Lake.\n\n## Steps\n1. List event data stores to find the store to query, then get it by ARN to confirm its status and retention period.\n2. Compose the SQL, naming the event data store ID in the FROM clause.\n3. Start the query to obtain a query ID.\n4. Poll describe query with that query ID until the status is FINISHED, FAILED, CANCELLED, or TIMED_OUT.\n5. On FINISHED, fetch the query results with the same query ID, paging with the returned token until no token comes back.\n6. Cancel the query if it is no longer needed while still RUNNING.\n\n## Output\nThe result rows, plus the query ID, events matched, events scanned, and run time. On failure, surface the error message and the SQL that produced it.',
},
],
} as const satisfies BlockMeta
Expand Down
18 changes: 11 additions & 7 deletions apps/sim/blocks/blocks/codepipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,18 +411,22 @@ export const CodePipelineBlock: BlockConfig = {
const awsRegion = rest.awsRegion
const awsAccessKeyId = rest.awsAccessKeyId
const awsSecretAccessKey = rest.awsSecretAccessKey
const parsedMaxResults = parseOptionalNumberInput(maxResults, 'Max results', {
integer: true,
min: 1,
})
/** Parsed only by the list operations, so a value left in the hidden field never fails another one. */
const maxResultsParam = () => {
const parsed = parseOptionalNumberInput(maxResults, 'Max results', {
integer: true,
min: 1,
})
return parsed === undefined ? {} : { maxResults: parsed }
}

switch (operation) {
case 'list_pipelines':
return {
awsRegion,
awsAccessKeyId,
awsSecretAccessKey,
...(parsedMaxResults !== undefined && { maxResults: parsedMaxResults }),
...maxResultsParam(),
...(rest.nextToken && { nextToken: rest.nextToken }),
}

Expand Down Expand Up @@ -463,7 +467,7 @@ export const CodePipelineBlock: BlockConfig = {
awsAccessKeyId,
awsSecretAccessKey,
pipelineName: rest.pipelineName,
...(parsedMaxResults !== undefined && { maxResults: parsedMaxResults }),
...maxResultsParam(),
...(rest.nextToken && { nextToken: rest.nextToken }),
...(rest.succeededInStage && { succeededInStage: rest.succeededInStage }),
}
Expand All @@ -475,7 +479,7 @@ export const CodePipelineBlock: BlockConfig = {
awsSecretAccessKey,
pipelineName: rest.pipelineName,
...(rest.pipelineExecutionId && { pipelineExecutionId: rest.pipelineExecutionId }),
...(parsedMaxResults !== undefined && { maxResults: parsedMaxResults }),
...maxResultsParam(),
...(rest.nextToken && { nextToken: rest.nextToken }),
}

Expand Down
18 changes: 12 additions & 6 deletions apps/sim/blocks/blocks/sqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { getErrorMessage } from '@sim/utils/errors'
import { SQSIcon } from '@/components/icons'
import type { BlockConfig, BlockMeta } from '@/blocks/types'
import { AuthMode, IntegrationType } from '@/blocks/types'
import { mapperOperation, withSavedCredential } from '@/blocks/utils'
import { mapperOperation, toolCallArg, withSavedCredential } from '@/blocks/utils'

export const SQSBlock: BlockConfig = {
type: 'sqs',
Expand Down Expand Up @@ -605,6 +605,11 @@ export const SQSBlock: BlockConfig = {
},
params: (params, context) => {
const operation = mapperOperation(params, context)
/** A blank block-only field yields, on a tool call, the model's arg under the tool's name. */
const orToolArg = (blockValue: unknown, toolValue: unknown) =>
blockValue === undefined || blockValue === null || blockValue === ''
? toolCallArg(context, toolValue)
: blockValue

const parseJson = (value: unknown, fieldName: string) => {
if (value === undefined || value === null || value === '') return undefined
Expand Down Expand Up @@ -672,11 +677,10 @@ export const SQSBlock: BlockConfig = {
if (maxNumberOfMessages !== undefined) result.maxNumberOfMessages = maxNumberOfMessages
const waitTimeSeconds = parseInteger(params.waitTimeSeconds, 'waitTimeSeconds')
if (waitTimeSeconds !== undefined) result.waitTimeSeconds = waitTimeSeconds
const visibilityTimeout = parseInteger(
params.receiveVisibilityTimeout,
result.visibilityTimeout = parseInteger(
orToolArg(params.receiveVisibilityTimeout, params.visibilityTimeout),
'visibilityTimeout'
)
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
if (visibilityTimeout !== undefined) result.visibilityTimeout = visibilityTimeout
const messageAttributeNames = parseJson(
params.messageAttributeNames,
'messageAttributeNames'
Expand Down Expand Up @@ -791,8 +795,10 @@ export const SQSBlock: BlockConfig = {
}
case 'list_message_move_tasks': {
result.sourceArn = params.sourceArn
const maxResults = parseInteger(params.moveTaskMaxResults, 'maxResults')
if (maxResults !== undefined) result.maxResults = maxResults
result.maxResults = parseInteger(
orToolArg(params.moveTaskMaxResults, params.maxResults),
'maxResults'
)
Comment thread
waleedlatif1 marked this conversation as resolved.
Resolved
break
}
case 'cancel_message_move_task': {
Expand Down
25 changes: 13 additions & 12 deletions apps/sim/blocks/blocks/ssm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,11 @@ export const SSMBlock: BlockConfig = {
secretAccessKey: params.secretAccessKey,
}

/** A blank block-only field yields, on a tool call, the model's arg under the tool's name. */
const orToolArg = (blockValue: unknown, toolValue: unknown) =>
blockValue === undefined || blockValue === null || blockValue === ''
? toolCallArg(context, toolValue)
: blockValue
const setJson = (key: string, value: unknown) => {
const parsed = toParsedJson(value)
if (parsed !== undefined) result[key] = parsed
Expand Down Expand Up @@ -874,9 +879,8 @@ export const SSMBlock: BlockConfig = {
setBoolean('recursive', params.recursive)
setBoolean('withDecryption', params.withDecryption)
setJson('parameterFilters', params.parameterFilters)
setNumber(
'maxResults',
params.pathMaxResults ?? toolCallArg(context, params.maxResults)
result.maxResults = toOptionalNumber(
orToolArg(params.pathMaxResults, params.maxResults)
)
setString('nextToken', params.nextToken)
break
Expand Down Expand Up @@ -906,26 +910,23 @@ export const SSMBlock: BlockConfig = {
break
case 'describe_instance_information':
setJson('filters', params.instanceInfoFilters ?? toolCallArg(context, params.filters))
setNumber(
'maxResults',
params.instanceInfoMaxResults ?? toolCallArg(context, params.maxResults)
result.maxResults = toOptionalNumber(
orToolArg(params.instanceInfoMaxResults, params.maxResults)
)
setString('nextToken', params.nextToken)
break
case 'describe_instance_patches':
result.instanceId = params.instanceId
setJson('filters', params.patchFilters ?? toolCallArg(context, params.filters))
setNumber(
'maxResults',
params.patchMaxResults ?? toolCallArg(context, params.maxResults)
result.maxResults = toOptionalNumber(
orToolArg(params.patchMaxResults, params.maxResults)
)
setString('nextToken', params.nextToken)
break
case 'describe_instance_patch_states':
setJson('instanceIds', params.instanceIds)
setNumber(
'maxResults',
params.patchMaxResults ?? toolCallArg(context, params.maxResults)
result.maxResults = toOptionalNumber(
orToolArg(params.patchMaxResults, params.maxResults)
)
setString('nextToken', params.nextToken)
break
Expand Down
34 changes: 26 additions & 8 deletions apps/sim/tools/cloudtrail/list_event_data_stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,50 @@ export const listEventDataStoresTool: InternalToolConfig<
name: { type: 'string', description: 'Name of the event data store' },
status: {
type: 'string',
description: 'CREATED, ENABLED, PENDING_DELETION, or an ingestion state',
description:
'Store status. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
advancedEventSelectors: {
type: 'array',
description: 'Advanced event selectors that define what the store ingests',
description:
'Advanced event selectors. AWS no longer returns it from this list; read it with Get Event Data Store',
},
multiRegionEnabled: {
type: 'boolean',
description: 'Whether the store collects events from all Regions',
description:
'Whether the store is multi-Region. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
organizationEnabled: {
type: 'boolean',
description: 'Whether the store collects events for the organization',
description:
'Whether the store is an organization store. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
retentionPeriod: {
type: 'number',
description:
'Retention period in days. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
retentionPeriod: { type: 'number', description: 'Retention period in days' },
terminationProtectionEnabled: {
type: 'boolean',
description: 'Whether termination protection is enabled',
description:
'Whether termination protection is enabled. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
createdTimestamp: {
type: 'string',
description: 'When the store was created (ISO 8601)',
description:
'Creation time. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
updatedTimestamp: {
type: 'string',
description: 'When the store was last updated (ISO 8601)',
description:
'Last update time. AWS no longer returns it from this list; read it with Get Event Data Store',
optional: true,
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/tools/generated/tool-outputs.ts

Large diffs are not rendered by default.

Loading