Skip to content

feat(cloudwatch): add mute and unmute alarm operations#4602

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
feat/mute-alarm-cw
May 14, 2026
Merged

feat(cloudwatch): add mute and unmute alarm operations#4602
TheodoreSpeaks merged 1 commit into
stagingfrom
feat/mute-alarm-cw

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

  • Add mute_alarm operation to the CloudWatch block (wraps DisableAlarmActions)
  • Add unmute_alarm operation (wraps EnableAlarmActions)
  • Both take comma-separated alarm names; share one subBlock via condition

Type of Change

  • New feature

Testing

Tested manually. bun run lint clean. bun run check:api-validation:strict passes (route baseline bumped 736 → 738).

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link
Copy Markdown

vercel Bot commented May 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 14, 2026 6:49pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented May 14, 2026

PR Summary

Medium Risk
Adds new internal API endpoints that accept AWS credentials and can disable/enable CloudWatch alarm actions, which is operationally sensitive despite input validation and auth checks.

Overview
Adds new CloudWatch tool operations to mute and unmute alarms by calling AWS DisableAlarmActions/EnableAlarmActions via two new internal POST routes (/api/tools/cloudwatch/mute-alarm and /api/tools/cloudwatch/unmute-alarm) with Zod contracts validating region, credentials, and up to 100 alarm names.

Updates the CloudWatch block to expose the new operations, parse comma-separated alarmNames, and returns success plus affected alarmNames; registers the new tools in the CloudWatch tool index/registry and bumps the API validation baseline route count (736 → 738).

Reviewed by Cursor Bugbot for commit bdb02ae. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 14, 2026

Greptile Summary

Adds mute_alarm and unmute_alarm operations to the CloudWatch block, wrapping the AWS DisableAlarmActions and EnableAlarmActions APIs respectively. Both operations share a single alarmNames subBlock (rendered for either operation via an array condition), parse comma-separated user input into an array before dispatch, and follow the established CloudWatch tool pattern end-to-end.

  • Two new API routes (/api/tools/cloudwatch/mute-alarm and /api/tools/cloudwatch/unmute-alarm), each with Zod-validated contracts, internal auth checks, and proper AWS client lifecycle management (client.destroy() in finally).
  • Two new tool definitions (cloudwatch_mute_alarm / cloudwatch_unmute_alarm) registered in the tool registry; credentials use user-only visibility and alarm names use user-or-llm as expected.
  • The Mute and Unmute Zod schemas, TypeScript param/response types, and tool files are structurally identical pairs — a shared base type or schema would reduce future drift risk.

Confidence Score: 4/5

The change is safe to merge; it adds two new isolated operations with no modifications to existing logic.

All new code follows established patterns for auth, validation, AWS client lifecycle, and tool registration. The only findings are style-level: the Mute and Unmute contracts, TypeScript types, and tool files are structurally identical, creating maintenance surface that a shared base type/schema would eliminate.

The contract files (cloudwatch-mute-alarm.ts, cloudwatch-unmute-alarm.ts) and types.ts contain duplicated definitions worth consolidating before they diverge.

Important Files Changed

Filename Overview
apps/sim/app/api/tools/cloudwatch/mute-alarm/route.ts New POST route wrapping DisableAlarmActions; follows existing CloudWatch route patterns with proper auth, contract validation, client lifecycle management, and error handling.
apps/sim/app/api/tools/cloudwatch/unmute-alarm/route.ts New POST route wrapping EnableAlarmActions; mirrors the mute-alarm route exactly with correct operation semantics.
apps/sim/blocks/blocks/cloudwatch.ts Adds mute_alarm/unmute_alarm to the operation dropdown, shared alarmNames subBlock with array condition, params transformation (comma-split → array), and tool routing; changes are clean and consistent with existing operations.
apps/sim/lib/api/contracts/tools/aws/cloudwatch-mute-alarm.ts New Zod contract for mute-alarm; schema is valid and includes region validation and alarm count cap (100), but is a byte-for-byte duplicate of the unmute contract.
apps/sim/lib/api/contracts/tools/aws/cloudwatch-unmute-alarm.ts New Zod contract for unmute-alarm; functionally identical to cloudwatch-mute-alarm.ts, creating the duplication flagged above.
apps/sim/tools/cloudwatch/types.ts Adds four new types for mute/unmute params and responses; Mute and Unmute variants are structurally identical, as flagged.
apps/sim/tools/cloudwatch/mute_alarm.ts Tool definition for cloudwatch_mute_alarm; credentials correctly use user-only visibility, alarmNames uses user-or-llm, transformResponse handles error and success paths correctly.
apps/sim/tools/cloudwatch/unmute_alarm.ts Tool definition for cloudwatch_unmute_alarm; mirrors mute_alarm.ts with correct EnableAlarmActions semantics.
apps/sim/tools/registry.ts Registers cloudwatch_mute_alarm and cloudwatch_unmute_alarm tools; straightforward additions in alphabetical order.
scripts/check-api-validation-contracts.ts Baseline bumped from 736 to 738 to account for the two new validated routes.

Sequence Diagram

sequenceDiagram
    participant UI as CloudWatch Block UI
    participant Block as cloudwatch.ts (params fn)
    participant Tool as mute_alarm / unmute_alarm tool
    participant Route as /api/tools/cloudwatch/mute-alarm (or unmute-alarm)
    participant AWS as AWS CloudWatch

    UI->>Block: "operation=mute_alarm, alarmNames="a,b""
    Block->>Block: split(",").map(trim).filter(Boolean) → ["a","b"]
    Block->>Tool: "{ awsRegion, awsAccessKeyId, awsSecretAccessKey, alarmNames: ["a","b"] }"
    Tool->>Route: "POST { region, accessKeyId, secretAccessKey, alarmNames }"
    Route->>Route: checkInternalAuth()
    Route->>Route: parseToolRequest (Zod validation)
    Route->>AWS: DisableAlarmActionsCommand (or EnableAlarmActionsCommand)
    AWS-->>Route: 200 OK (silent success even for unknown alarms)
    Route-->>Tool: "{ success: true, output: { success: true, alarmNames } }"
    Tool-->>Block: "{ success: true, output: { success: true, alarmNames } }"
Loading

Reviews (1): Last reviewed commit: "feat(cloudwatch): add mute and unmute al..." | Re-trigger Greptile

Comment thread apps/sim/lib/api/contracts/tools/aws/cloudwatch-mute-alarm.ts
Comment thread apps/sim/tools/cloudwatch/types.ts
@TheodoreSpeaks TheodoreSpeaks merged commit 4a9e248 into staging May 14, 2026
14 checks passed
@TheodoreSpeaks TheodoreSpeaks deleted the feat/mute-alarm-cw branch May 14, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant