Skip to content

feat: add email-agent kit — AI-powered email verifier and reply drafter#246

Merged
akshatvirmani merged 15 commits into
Lamatic:mainfrom
kr1shnaakhurana:feat/email-agent
Jul 20, 2026
Merged

feat: add email-agent kit — AI-powered email verifier and reply drafter#246
akshatvirmani merged 15 commits into
Lamatic:mainfrom
kr1shnaakhurana:feat/email-agent

Conversation

@kr1shnaakhurana

@kr1shnaakhurana kr1shnaakhurana commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the Email Agent kit — an AI-powered email workspace built on Lamatic with two flows:

  1. Email Verifier — Analyzes emails for legitimacy, intent, urgency. Returns verdict (legit/suspicious/spam) with confidence score and reasons.
  2. Email Replier — Drafts context-aware professional replies using verification summary as context (sequential pipeline).

What's Included

  • lamatic.config.ts — Kit metadata
  • flows/ — Verifier + replier flow definitions
  • prompts/ — LLM system prompts
  • apps/ — Next.js 16 dashboard (verify + reply modes, dark mode, shadcn/ui)

How It Works

User inputs email → Verifier flow → verdict JSON → (for reply) Replier flow → draft reply

Field Value
Author Krishna Khurana
Version 1.0.0
Tags email, verification, reply, support
  • Adds Email Agent Kit v1.0.0 with a Lamatic-based backend and a Next.js 16 dashboard that supports two modes:
    • Email Verifier: takes sender, subject, body, runs an LLM to produce a structured legitimacy analysis, and returns it as Markdown.
    • Email Replier: drafts a professional reply using the email content plus a Verification Audit (verdict, confidence, reasons)—running verification first when those fields aren’t provided.
  • Adds kit configuration/docs/env and prompts/LLM wiring:
    • kits/email-agent/lamatic.config.ts
    • kits/email-agent/README.md
    • kits/email-agent/agent.md
    • kits/email-agent/constitutions/default.md
    • kits/email-agent/.env.example
    • kits/email-agent/.gitignore
    • kits/email-agent/prompts/email-verifier_generate-text_system.md
    • kits/email-agent/prompts/email-replier_generate-text_system.md
    • kits/email-agent/model-configs/email-verifier_generate-text.ts
    • kits/email-agent/model-configs/email-replier_generate-text.ts
  • Adds Lamatic flow definitions (authored as TS; no flow.json in this kit):
    • kits/email-agent/flows/email-verifier.ts
      • Node types used: triggerNodedynamicNode (LLM) → dynamicNode (GraphQL response)
      • Edges used: defaultEdge + responseEdge
      • How it works: API trigger provides sender/subject/body to the LLM (“Verify Email”); LLM output is mapped into response output.
    • kits/email-agent/flows/email-replier.ts
      • Node types used: triggerNodedynamicNode (LLM) → dynamicNode (GraphQL response)
      • Edges used: defaultEdge + responseEdge
      • How it works: API trigger accepts sender/subject/body plus optional verdict/confidence/reasons; LLM (“Draft Reply”) injects a “Verification Audit”; LLM output is mapped into response output.
  • Adds Next.js dashboard app, UI components, and orchestration:
    • kits/email-agent/apps/.env.example
    • kits/email-agent/apps/.gitignore
    • kits/email-agent/apps/package.json
    • kits/email-agent/apps/package-lock.json
    • kits/email-agent/apps/tsconfig.json
    • kits/email-agent/apps/next-env.d.ts
    • kits/email-agent/apps/next.config.mjs
    • kits/email-agent/apps/postcss.config.mjs
    • kits/email-agent/apps/components.json
    • kits/email-agent/apps/orchestrate.js (sequential verifierreplier orchestration; mode: "sync", expects output)
    • kits/email-agent/apps/actions/orchestrate.ts (verifyEmail, replyEmail; formats/parses verifier output; reuses verification inputs when provided)
    • kits/email-agent/apps/test-api.js (manual GraphQL executeWorkflow tester for the verifier)
    • kits/email-agent/apps/app/layout.tsx
    • kits/email-agent/apps/app/page.tsx (verify/reply UI, loading/error handling, copy/reset, Markdown rendering for verification)
    • kits/email-agent/apps/app/globals.css (Tailwind light/dark design tokens)
    • kits/email-agent/apps/components/header.tsx
    • kits/email-agent/apps/components/theme-provider.tsx
    • kits/email-agent/apps/components/ui/button.tsx
    • kits/email-agent/apps/components/ui/card.tsx
    • kits/email-agent/apps/components/ui/input.tsx
    • kits/email-agent/apps/components/ui/label.tsx
    • kits/email-agent/apps/components/ui/select.tsx
    • kits/email-agent/apps/components/ui/textarea.tsx
    • kits/email-agent/apps/lib/lamatic-client.ts (env validation + lamaticClient)
    • kits/email-agent/apps/lib/utils.ts (cn Tailwind class merger)

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 58ba657d-9efb-4b83-be58-d33f9e7bdf16

📥 Commits

Reviewing files that changed from the base of the PR and between 35f91da and 811add0.

📒 Files selected for processing (1)
  • kits/email-agent/apps/actions/orchestrate.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

Changes

The Email Agent kit adds Lamatic verifier and replier workflows, credentialed execution, a Next.js dashboard for submitting emails and viewing results, and setup documentation and configuration.

Changes

Email Agent

Layer / File(s) Summary
Email workflow definitions
kits/email-agent/constitutions/default.md, kits/email-agent/flows/*, kits/email-agent/model-configs/*, kits/email-agent/prompts/*
Defines verifier and replier flows, LLM nodes, prompts, model references, input schemas, output mappings, and behavioral rules.
Workflow execution integration
kits/email-agent/apps/actions/orchestrate.ts, kits/email-agent/apps/orchestrate.js, kits/email-agent/apps/lib/*, kits/email-agent/apps/test-api.js
Configures workflow execution, validates credentials, formats verification results, drafts replies, and provides an API test script.
Next.js dashboard interface
kits/email-agent/apps/app/*, kits/email-agent/apps/components/*, kits/email-agent/apps/lib/utils.ts
Adds the email workspace UI, mode switching, form validation, result rendering, copy/reset actions, theme styling, reusable controls, navigation, and class-name utilities.
Kit packaging and setup
kits/email-agent/README.md, kits/email-agent/agent.md, kits/email-agent/lamatic.config.ts, kits/email-agent/apps/package.json, kits/email-agent/apps/tsconfig.json, kits/email-agent/apps/next.config.mjs, kits/email-agent/apps/postcss.config.mjs, kits/email-agent/apps/components.json, kits/email-agent/.env.example, kits/email-agent/**/.gitignore, kits/email-agent/apps/next-env.d.ts
Documents installation and environment setup, declares kit metadata and workflow steps, configures the application toolchain, and ignores local or generated artifacts.

Suggested reviewers: amanintech, d-pamneja

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the kit summary, but it omits the required PR Checklist sections, validation items, and repository-specific confirmations. Add the PR Checklist sections from the template and explicitly confirm scope, no secrets, file structure, local validation, and review comments resolved.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding the Email Agent kit with verifier and reply drafter flows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

:robot_face: AgentKit Structural Validation

No contribution files detected in this PR.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
putComment timed out

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
kits/email-agent/constitutions/default.md (1)

1-18: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update the template generator to resolve formatting warnings.

Good morning, Agent. Our analysts have intercepted several MD022 (blanks-around-headings) warnings within this document. Based on learnings, this file is auto-generated from a template. Your mission, should you choose to accept it, is to infiltrate the template/source level and ensure blank lines are added after headings so all future kits inherit the corrected formatting rather than patching just this file.

This message will self-destruct in five seconds.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/constitutions/default.md` around lines 1 - 18, Update the
source template used to generate the default constitution, rather than editing
the generated default.md directly, and ensure every heading in the generated
output has a blank line after it to satisfy MD022. Preserve the existing heading
content and generation behavior.

Source: Learnings

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 55-57: Update the result extraction in
kits/email-agent/apps/actions/orchestrate.ts at lines 55-57 to use
resData?.result?.output, at line 101 to use verifierRes?.result?.output if that
reconnaissance step remains, and at lines 118-119 to use
replierRes?.result?.output; preserve the surrounding missing-report handling.
- Line 4: Update the import in orchestrate.ts to use ../../lamatic.config
instead of ../orchestrate.js, ensuring the action reads step definitions from
the parent kit’s configuration.
- Around line 83-115: Remove the verifier workflow lookup, validation,
execution, response extraction, and summary-generation logic from replyEmail.
Start directly with the replier execution using only the configured
replierFlow.workflowId and the supported sender, subject, and body payload
fields; also remove the unused summary and email variables and related logging.

In `@kits/email-agent/apps/app/layout.tsx`:
- Around line 6-23: Update RootLayout to apply both initialized font variables,
_geist and _geistMono, to the body className alongside the existing font-sans
and antialiased classes, ensuring the loaded typography assets are injected into
the document.

In `@kits/email-agent/apps/app/page.tsx`:
- Around line 18-20: Replace the sender, subject, and body useState form
management with react-hook-form’s useForm configured with zodResolver and a zod
schema. Update the form fields and submission flow to use the form registration,
validation, and errors while preserving the existing form behavior.

In `@kits/email-agent/apps/components/ui/button.tsx`:
- Around line 39-58: Add React.forwardRef and displayName to Button in
kits/email-agent/apps/components/ui/button.tsx:39-58, forwarding the ref to the
selected button or Slot component; wrap Card, CardHeader, CardTitle,
CardDescription, CardAction, CardContent, and CardFooter similarly in
kits/email-agent/apps/components/ui/card.tsx:5-82; wrap Label in
kits/email-agent/apps/components/ui/label.tsx:8-22, forwarding each ref to its
underlying element and exposing the corresponding displayName.

In `@kits/email-agent/apps/components/ui/input.tsx`:
- Around line 5-19: Wrap the exposed Input component in React.forwardRef while
preserving its props and className handling; apply the same ref-forwarding
pattern to Textarea in kits/email-agent/apps/components/ui/textarea.tsx (lines
5-16) and SelectTrigger plus the other exposed Select subcomponents in
kits/email-agent/apps/components/ui/select.tsx (lines 27-51). Ensure each
forwarded ref targets its underlying DOM element and existing behavior remains
unchanged.

In `@kits/email-agent/apps/next.config.mjs`:
- Around line 3-5: Remove the ignoreBuildErrors setting from the Next.js
typescript configuration so builds perform normal TypeScript verification.
Update the visible typescript configuration block in next.config.mjs without
adding another bypass or changing unrelated build settings.

In `@kits/email-agent/apps/package.json`:
- Around line 53-61: Pin the lamatic and react-markdown dependencies in
package.json to specific stable versions instead of the latest tag, preserving
the existing dependency declarations and using versions compatible with the
application.
- Line 46: Remove the autoprefixer dependency entry from the package manifest,
leaving the remaining dependencies unchanged. Do not add or modify PostCSS
configuration, since the existing setup does not reference autoprefixer.

In `@kits/email-agent/apps/test-api.js`:
- Around line 3-5: Remove the unused config import from test-api.js and update
its execution directive to invoke Node with the built-in --env-file option
targeting .env.local, while preserving the script entry point.

In `@kits/email-agent/apps/tsconfig.json`:
- Around line 36-39: Remove the two redundant malformed Windows-style
".next\\dev/types/**/*.ts" entries from the tsconfig include list, leaving the
single valid forward-slash ".next/dev/types/**/*.ts" directive unchanged.

---

Outside diff comments:
In `@kits/email-agent/constitutions/default.md`:
- Around line 1-18: Update the source template used to generate the default
constitution, rather than editing the generated default.md directly, and ensure
every heading in the generated output has a blank line after it to satisfy
MD022. Preserve the existing heading content and generation behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 16e57db4-06b5-4795-ad74-905eea0112a6

📥 Commits

Reviewing files that changed from the base of the PR and between aabc909 and 0122aab.

⛔ Files ignored due to path filters (1)
  • kits/email-agent/apps/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (35)
  • kits/email-agent/.gitignore
  • kits/email-agent/README.md
  • kits/email-agent/agent.md
  • kits/email-agent/apps/.env.example
  • kits/email-agent/apps/.gitignore
  • kits/email-agent/apps/actions/orchestrate.ts
  • kits/email-agent/apps/app/globals.css
  • kits/email-agent/apps/app/layout.tsx
  • kits/email-agent/apps/app/page.tsx
  • kits/email-agent/apps/components.json
  • kits/email-agent/apps/components/header.tsx
  • kits/email-agent/apps/components/theme-provider.tsx
  • kits/email-agent/apps/components/ui/button.tsx
  • kits/email-agent/apps/components/ui/card.tsx
  • kits/email-agent/apps/components/ui/input.tsx
  • kits/email-agent/apps/components/ui/label.tsx
  • kits/email-agent/apps/components/ui/select.tsx
  • kits/email-agent/apps/components/ui/textarea.tsx
  • kits/email-agent/apps/lib/lamatic-client.ts
  • kits/email-agent/apps/lib/utils.ts
  • kits/email-agent/apps/next-env.d.ts
  • kits/email-agent/apps/next.config.mjs
  • kits/email-agent/apps/orchestrate.js
  • kits/email-agent/apps/package.json
  • kits/email-agent/apps/postcss.config.mjs
  • kits/email-agent/apps/test-api.js
  • kits/email-agent/apps/tsconfig.json
  • kits/email-agent/constitutions/default.md
  • kits/email-agent/flows/email-replier.ts
  • kits/email-agent/flows/email-verifier.ts
  • kits/email-agent/lamatic.config.ts
  • kits/email-agent/model-configs/email-replier_generate-text.ts
  • kits/email-agent/model-configs/email-verifier_generate-text.ts
  • kits/email-agent/prompts/email-replier_generate-text_system.md
  • kits/email-agent/prompts/email-verifier_generate-text_system.md

Comment thread kits/email-agent/apps/actions/orchestrate.ts Outdated
Comment thread kits/email-agent/apps/actions/orchestrate.ts Outdated
Comment thread kits/email-agent/apps/actions/orchestrate.ts Outdated
Comment thread kits/email-agent/apps/app/layout.tsx
Comment thread kits/email-agent/apps/app/page.tsx
Comment thread kits/email-agent/apps/next.config.mjs
Comment thread kits/email-agent/apps/package.json
Comment thread kits/email-agent/apps/package.json
Comment thread kits/email-agent/apps/test-api.js Outdated
Comment thread kits/email-agent/apps/tsconfig.json Outdated
@akshatvirmani

Copy link
Copy Markdown
Contributor

@kr1shnaakhurana please fix the comments above

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
kits/email-agent/flows/email-replier.ts (1)

67-80: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Mission: route the verifier payload into the reply draft. kits/email-agent/flows/email-replier.ts:67-80 still only accepts sender, subject, and body, and kits/email-agent/apps/actions/orchestrate.ts only forwards summary, so verdict, confidence, and reasons never reach the reply prompt. Thread those fields through both stages.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/flows/email-replier.ts` around lines 67 - 80, Extend the
`inputs` definition in `email-replier.ts` to accept the verifier fields
`verdict`, `confidence`, and `reasons` alongside the existing email fields, then
update the forwarding logic in `orchestrate.ts` to pass those values into the
reply draft flow rather than forwarding only `summary`.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/email-agent/flows/email-replier.ts`:
- Around line 67-80: Extend the `inputs` definition in `email-replier.ts` to
accept the verifier fields `verdict`, `confidence`, and `reasons` alongside the
existing email fields, then update the forwarding logic in `orchestrate.ts` to
pass those values into the reply draft flow rather than forwarding only
`summary`.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: e01dfd7c-6c84-4595-a5ce-2d5f7062c53a

📥 Commits

Reviewing files that changed from the base of the PR and between dfed743 and 27bc4f3.

📒 Files selected for processing (7)
  • kits/email-agent/apps/app/page.tsx
  • kits/email-agent/apps/components/header.tsx
  • kits/email-agent/apps/next-env.d.ts
  • kits/email-agent/apps/test-api.js
  • kits/email-agent/apps/tsconfig.json
  • kits/email-agent/flows/email-replier.ts
  • kits/email-agent/flows/email-verifier.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
kits/email-agent/apps/orchestrate.js (1)

4-38: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align orchestrator configuration with flow specifications.

Agent, intel indicates our orchestrator config is out of sync with the updated flow definitions:

  1. The output key is the correct extraction target for both flows, not response. Update expectedOutput and outputSchema to match.
  2. The replier flow no longer utilizes the summary and email input fields. Scrub them from the inputSchema to prevent smuggling ghost variables.
🕵️ Proposed mission patch
     verifier: {
       name: "Email Verifier",
       workflowId: process.env.EMAIL_VERIFIER_FLOW_ID,
       description: "Verifies and analyzes email sender, subject, and content.",
       mode: "sync",
-      expectedOutput: "response",
+      expectedOutput: "output",
       inputSchema: {
         sender: "string",
         subject: "string",
         body: "string"
       },
       outputSchema: {
-        response: "string"
+        output: "string"
       }
     },
     replier: {
       name: "Email Replier",
       workflowId: process.env.EMAIL_REPLIER_FLOW_ID,
       description: "Generates context-aware reply drafts to inbound emails.",
       mode: "sync",
-      expectedOutput: "response",
+      expectedOutput: "output",
       inputSchema: {
         sender: "string",
         subject: "string",
         body: "string",
-        summary: "string",
-        email: "string",   // combined string: {{email}} in prompt
         verdict: "string",
         confidence: "number",
         reasons: "array"
       },
       outputSchema: {
-        response: "string"
+        output: "string"
       }
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/orchestrate.js` around lines 4 - 38, Update both the
verifier and replier configurations to use output as the expectedOutput value
and outputSchema key instead of response. In the replier inputSchema, remove the
obsolete summary and email fields while preserving all remaining inputs.
kits/email-agent/apps/actions/orchestrate.ts (1)

100-134: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Abort transmission of ghost variables.

Agent, our latest intel confirms that the email-replier flow has evolved and no longer utilizes the summary and email variables in its prompt. Scrub these fields and their setup logic from your execution payload to keep our communications lean and untraceable.

🕵️ Proposed mission patch
-    // Extract verifier payload fields — if object, pull individual fields; else use as-is
+    // Extract verifier payload fields
     const verifierResponse = verifierRes?.result?.response
     let verdict = ""
     let confidence = 0
     let reasons: string[] = []
-    let summary = ""
 
     if (typeof verifierResponse === "object" && verifierResponse !== null) {
       const r = verifierResponse as {
         verdict?: string
         confidence?: number
         reasons?: string[]
-        summary?: string
       }
       verdict = r.verdict ?? ""
       confidence = r.confidence ?? 0
       reasons = r.reasons ?? []
-      summary = r.summary ?? ""
-    } else {
-      summary = String(verifierResponse ?? "")
     }
 
-    // Step 2: Run replier — generate-reply prompt uses {{email}} single variable
-    const emailText = `From: ${sender}\nSubject: ${subject}\n\n${body}`
-    console.log("[Email Agent] Step 2 — Running replier with email:", emailText)
+    // Step 2: Run replier
+    console.log("[Email Agent] Step 2 — Running replier...")
     const replierRes = await lamaticClient.executeFlow(replierFlow.workflowId, {
       sender,
       subject,
       body,
-      summary,
-      email: emailText,  // matches {{email}} in generate-reply_llmnode-934_user_1.md
       verdict,
       confidence,
       reasons,
     })
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/actions/orchestrate.ts` around lines 100 - 134, Remove
the unused summary extraction and emailText construction from the orchestration
flow, including the summary and email fields passed to replierFlow.executeFlow.
Keep the verifier fields verdict, confidence, and reasons, along with sender,
subject, and body, unchanged in the replier payload.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 100-134: Remove the unused summary extraction and emailText
construction from the orchestration flow, including the summary and email fields
passed to replierFlow.executeFlow. Keep the verifier fields verdict, confidence,
and reasons, along with sender, subject, and body, unchanged in the replier
payload.

In `@kits/email-agent/apps/orchestrate.js`:
- Around line 4-38: Update both the verifier and replier configurations to use
output as the expectedOutput value and outputSchema key instead of response. In
the replier inputSchema, remove the obsolete summary and email fields while
preserving all remaining inputs.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: a384d8d9-1145-4cfa-a2a5-31e6e44d2aaf

📥 Commits

Reviewing files that changed from the base of the PR and between 27bc4f3 and a7bbe47.

📒 Files selected for processing (3)
  • kits/email-agent/apps/actions/orchestrate.ts
  • kits/email-agent/apps/orchestrate.js
  • kits/email-agent/flows/email-replier.ts

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

I’ve gone through all the review comments and fixed everything I could find. Pushed the latest changes as well. If I’ve missed anything specific, just let me know and I’ll update it.

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai review

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

@coderabbitai resolve

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved and changes approved.

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

@akshatvirmani

@kr1shnaakhurana

kr1shnaakhurana commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@amanintech @d-pamneja I've completed all the requested changes in my PR. Kindly review and approve it if everything looks good.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @kr1shnaakhurana! 👋

Before this PR can be reviewed by maintainers, please resolve all comments and requested changes from the CodeRabbit automated review.

Steps to follow:

  1. Read through all CodeRabbit comments carefully
  2. Address each issue raised (or reply explaining why you disagree)
  3. Push your fixes as new commits
  4. Once all issues are resolved, comment here so we can re-review

This helps keep the review process efficient for everyone. Thank you! 🙏

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

heyy, i have done all the things and now coderabbit also approved my repo

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 91-98: Update replyEmail to execute the email-verifier flow before
email-replier, extract its verdict, confidence, and reasons output, and include
those values alongside sender, subject, and body in the replierRes payload. Use
the existing workflow ID and Lamatic execution patterns in orchestrate.ts,
preserving the replier flow invocation after verification completes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 4d950072-cca2-4273-bc3d-ff6d9b925af3

📥 Commits

Reviewing files that changed from the base of the PR and between 1b6d77c and 5fb703f.

📒 Files selected for processing (1)
  • kits/email-agent/apps/actions/orchestrate.ts

Comment thread kits/email-agent/apps/actions/orchestrate.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
kits/email-agent/apps/actions/orchestrate.ts (2)

19-27: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Mission update: Defend against void intel.

Agent, if the LLM hallucinates and returns exactly "null", JSON.parse will evaluate it to a literal null. Attempting to read r.verdict immediately after will trigger a fatal TypeError and crash the extraction process. Your mission is to secure this vector by providing a safe fallback.

🕵️ Proposed mission patch
-  const r = parsed as {
+  const r = (parsed || {}) as {
     verdict?: string
     confidence?: number
     reasons?: string[]
     summary?: string
   }
 
   const verdictEmoji =
     r.verdict === "legit" ? "✅" : r.verdict === "suspicious" ? "⚠️" : "🚫"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/actions/orchestrate.ts` around lines 19 - 27, Guard the
parsed result before accessing r.verdict in the verdictEmoji logic: when
JSON.parse returns null, use an empty object fallback so property reads remain
safe. Preserve the existing emoji mapping for legit, suspicious, and all other
verdict values.

35-37: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Mission update: Fortify array extraction against unpredictable intel.

Agent, LLM outputs are notoriously unstable and might return a string instead of the expected array for the reasons field. Blindly trusting this intel shares a single root cause across operations and will lead to fatal exceptions or compromised payloads. Your mission, should you choose to accept it, is to defend the extraction with Array.isArray().

  • kits/email-agent/apps/actions/orchestrate.ts#L35-L37: Update the template string to use Array.isArray(r.reasons) ? r.reasons : [] before calling .map().
  • kits/email-agent/apps/actions/orchestrate.ts#L131-L133: Update the assignment to use finalReasons = Array.isArray(parsedResponse?.reasons) ? parsedResponse.reasons : [].
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/email-agent/apps/actions/orchestrate.ts` around lines 35 - 37, Guard
both reasons extraction sites in
kits/email-agent/apps/actions/orchestrate.ts:35-37 and
kits/email-agent/apps/actions/orchestrate.ts:131-133 with Array.isArray(). In
the template rendering, map only r.reasons when it is an array, otherwise use
[]; in the finalReasons assignment, use parsedResponse.reasons only when it is
an array, otherwise assign [].
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@kits/email-agent/apps/actions/orchestrate.ts`:
- Around line 19-27: Guard the parsed result before accessing r.verdict in the
verdictEmoji logic: when JSON.parse returns null, use an empty object fallback
so property reads remain safe. Preserve the existing emoji mapping for legit,
suspicious, and all other verdict values.
- Around line 35-37: Guard both reasons extraction sites in
kits/email-agent/apps/actions/orchestrate.ts:35-37 and
kits/email-agent/apps/actions/orchestrate.ts:131-133 with Array.isArray(). In
the template rendering, map only r.reasons when it is an array, otherwise use
[]; in the finalReasons assignment, use parsedResponse.reasons only when it is
an array, otherwise assign [].

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7c0b09d9-4030-4ece-9f04-90bb4ab2729c

📥 Commits

Reviewing files that changed from the base of the PR and between 5fb703f and 35f91da.

📒 Files selected for processing (1)
  • kits/email-agent/apps/actions/orchestrate.ts

@kr1shnaakhurana

Copy link
Copy Markdown
Contributor Author

@akshatvirmani done

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@akshatvirmani

Copy link
Copy Markdown
Contributor

/validate

@github-actions

Copy link
Copy Markdown
Contributor

📡 Running Studio validation — results will appear here shortly.

@github-actions

Copy link
Copy Markdown
Contributor

Studio Runtime Validation (Phase 2)

Studio validation passed. The kit loaded successfully in Lamatic Studio.

This PR is ready for final review and merge.

@akshatvirmani akshatvirmani added the tier-3 Pass label Jul 20, 2026
@akshatvirmani
akshatvirmani merged commit 2e82c29 into Lamatic:main Jul 20, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants