Skip to content

feat: update configuration files and improve type checking#41

Merged
ssdeanx merged 2 commits intomainfrom
develop
Dec 12, 2025
Merged

feat: update configuration files and improve type checking#41
ssdeanx merged 2 commits intomainfrom
develop

Conversation

@ssdeanx
Copy link
Owner

@ssdeanx ssdeanx commented Dec 12, 2025

  • Removed Langfuse configuration from .env.example and added Lamina configuration.
  • Updated eslint.config.js to ignore specific TypeScript declaration files.
  • Refactored next.config.ts for better readability of serverExternalPackages.
  • Modified index.ts to integrate Laminar API key for observability.
  • Enhanced tsconfig.json to include additional type definitions and exclude unnecessary files.

Summary by Sourcery

Integrate Laminar-based observability and tighten TypeScript configuration and linting around problematic declaration files.

New Features:

  • Enable OpenTelemetry tracing via a Laminar-backed exporter configured with a project API key.

Enhancements:

  • Reorganize Next.js serverExternalPackages for improved readability and maintainability.
  • Broaden tsconfig include patterns to cover additional source, style, utility, and type declaration paths while excluding specific problematic declaration files from type checking.
  • Expand ESLint ignore patterns to skip TypeScript declaration files known to cause unsupported syntax or noise in linting.
  • Update environment variable examples to drop Langfuse settings in favor of Laminar configuration.

- Removed Langfuse configuration from .env.example and added Lamina configuration.
- Updated eslint.config.js to ignore specific TypeScript declaration files.
- Refactored next.config.ts for better readability of serverExternalPackages.
- Modified index.ts to integrate Laminar API key for observability.
- Enhanced tsconfig.json to include additional type definitions and exclude unnecessary files.
Copilot AI review requested due to automatic review settings December 12, 2025 11:09
@continue
Copy link

continue bot commented Dec 12, 2025

All Green - Keep your PRs mergeable

Learn more

All Green is an AI agent that automatically:

✅ Addresses code review comments

✅ Fixes failing CI checks

✅ Resolves merge conflicts

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 12, 2025

Reviewer's Guide

Configures observability to use Laminar via OtelExporter, refactors Next.js serverExternalPackages for readability, and tightens TypeScript/ESLint configuration to better control which files are type-checked and linted while excluding problematic declaration files.

Sequence diagram for Laminar-based observability via OtelExporter

sequenceDiagram
    participant Client
    participant NextApp
    participant Mastra
    participant Observability
    participant OtelExporter
    participant LaminarAPI

    Client->>NextApp: HTTP request
    NextApp->>Mastra: Handle request and operations
    Mastra->>Observability: Create and record trace spans
    Observability->>OtelExporter: Export spans with serviceName my-service
    OtelExporter->>OtelExporter: Attach laminar apiKey from LMNR_PROJECT_API_KEY
    OtelExporter->>OtelExporter: Add resourceAttributes deployment.environment=dev
    OtelExporter->>LaminarAPI: Send trace data using laminar provider
    LaminarAPI-->>OtelExporter: Acknowledge receipt
    OtelExporter-->>Observability: Export result
    Observability-->>Mastra: Trace export completed
    Mastra-->>NextApp: Operation result
    NextApp-->>Client: HTTP response
Loading

Class diagram for Mastra observability configuration with Laminar

classDiagram
    class Mastra {
        +Observability observability
        +configureObservability(observability)
    }

    class Observability {
        +string defaultEnabled
        +string configs
        +setConfig(key, value)
    }

    class OtelExporter {
        +string serviceName
        +string providerType
        +string laminarApiKey
        +string logger
        +string deploymentEnvironment
        +exportTraces(spans)
    }

    class LaminarProviderConfig {
        +string apiKey
        +string teamId
    }

    Mastra --> Observability : has
    Observability --> OtelExporter : uses
    OtelExporter --> LaminarProviderConfig : configures
Loading

File-Level Changes

Change Details Files
Switch observability configuration from MLflow/Langfuse-style endpoint to Laminar using OtelExporter.
  • Commented out the default disabled observability configuration
  • Replaced custom MLflow HTTP/protobuf exporter config with Laminar provider configuration using LMNR_PROJECT_API_KEY (and optional teamId)
  • Updated serviceName to a generic "my-service" and added logger and resourceAttributes (deployment.environment) to the OtelExporter setup
src/mastra/index.ts
Refactor Next.js serverExternalPackages for clarity and maintainability.
  • Reformatted serverExternalPackages into a multi-line, alphabetized array of package patterns
  • Kept the set of external dependencies functionally equivalent while improving readability
next.config.ts
Tighten TypeScript project configuration to better scope type-checking and exclude problematic files.
  • Expanded include globs to cover additional .d.ts files and utility/style directories
  • Documented intentional exclusion of tests from the main typecheck run to avoid pulling in unsupported node_modules declarations
  • Added explicit excludes for specific problematic .d.ts files in node_modules
tsconfig.json
Align ESLint ignore patterns with TypeScript excludes for problematic declaration files and generated content.
  • Extended ignores to include the same problematic .d.ts files that are excluded in tsconfig
  • Maintained existing ignores for docs, UI components, docker, and spec directories to reduce lint noise
eslint.config.js
Update environment example to reflect move from Langfuse to Laminar configuration.
  • Removed Langfuse-related configuration entries
  • Added Lamina/Laminar-related configuration variables (e.g., project API key) to match new observability setup
.env.example

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link

coderabbitai bot commented Dec 12, 2025

Caution

Review failed

The pull request is closed.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Summary by CodeRabbit

  • Chores

    • Switched observability provider and updated environment config keys.
    • Expanded Next.js external package list and improved TypeScript/ESLint config to reduce noise.
  • New Features

    • Chat now streams UI-friendly messages and supports nested-agent chats.
    • Messages show grouped tool invocations, a tool-progress panel, and Mastra data panels.
    • Added a dashboard JSON configuration for analytics.
  • Improvements

    • More robust parsing of tool/network data and consistent web-scraper progress reporting.
    • Message send is now non-blocking to improve responsiveness.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Replaces Langfuse with Lamina config and Otel/TraceLoop exporter, expands serverExternalPackages and ESLint ignore entries, adjusts TypeScript include/exclude patterns, and introduces multiple chat UI, streaming, tooling, and network-data handling changes including grouped tool rendering and standardized data-tool-progress payloads.

Changes

Cohort / File(s) Summary
Environment & Observability
\.env\.example, src/mastra/index.ts
Removed Langfuse keys and comments; added LMNR_PROJECT_API_KEY. Replaced Langfuse/MLflow exporter config with TraceLoop/Otel exporter configuration (apiKey, destinationId, exporters array, serviceName -> "my-service").
Build & Tooling
next\.config\.ts, eslint\.config\.js
Expanded serverExternalPackages with many scoped and unscoped packages (e.g., @mcpc-tech/*, @mastra/*, @openrouter/*, @supermemory/*, ai-sdk-provider-gemini-cli, playwright-core, re2, etc.). Added two ESLint ignore patterns for specific node_modules declaration files.
TypeScript config
tsconfig\.json
Added include patterns for declaration and utility files (src/mastra/types/**, types/**, utils/**, styles/**) and excluded certain declaration files and types/** from main typecheck to avoid conflicts.
Chat API & Streaming
app/api/chat/route.ts
Accepts id in request body; resolves agent ID dynamically (mastra.getAgent(agentId)); removes explicit format: "aisdk"; wraps agent stream with createUIMessageStream and toAISdkStream and returns a UI-friendly stream response.
Chat UI — Tools & Messages
app/chat/components/agent-tools.tsx, app/chat/components/chat-messages.tsx, app/chat/components/agent-web-preview.tsx, app/chat/components/chat-input.tsx, app/chat/components/nested-agent-chat.tsx
agent-tools: group tools by toolCallId, use latest item per group, dynamic tool name formatting, progress box. chat-messages: add Mastra data-* parts rendering, tool-progress panel, robust guards for parts/reasoning, web preview gating. agent-web-preview: prop param rename. chat-input: no longer awaits sendMessage. nested-agent-chat: new nested chat component.
Tool part mapping & providers
app/chat/helpers/tool-part-transform.ts, app/chat/providers/chat-context.tsx
tool-part-transform: defensive unwrapping of nested payloads, stronger typing, mapToToolState, returns DynamicToolUIPart
Networks
app/networks/providers/network-context.tsx
Enhanced routing step extraction from data-network and tool parts, mapRawStateToStatus helper, support for per-agent data payloads and dynamic-tool conversions to RoutingStep, more robust guards and fallbacks.
Tools
src/mastra/tools/web-scraper-tool.ts
Introduced centralized progressData helper and propagated toolCallId through all data-tool-progress events; standardized progress payloads across scrape steps.
Docs / Dashboards
docs/json.json
Added dashboard JSON configuration with multiple widgets, variables, and visualizations (tokens, latency, errors, agents, models, tools).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Client as Browser UI
participant Route as Next API Route (app/api/chat/route.ts)
participant Mastra as Mastra SDK / Agent
participant UIWrap as UI Stream Wrapper (createUIMessageStream / toAISdkStream)
Client->>Route: POST /api/chat { text, id? }
Route->>Mastra: mastra.getAgent(agentId) → getAgent
Route->>Mastra: agent.stream({ requestContext })
Mastra-->>Route: async iterator / ReadableStream (AI chunks)
Route->>UIWrap: wrap agent stream -> createUIMessageStream(...)/toAISdkStream(...)
UIWrap-->>Client: streamed UI-friendly chunks (write -> response)
Client-->>Client: render incoming messages and data-* parts

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Areas needing close attention:
    • app/chat/helpers/tool-part-transform.ts — defensive parsing and state mapping correctness.
    • app/chat/components/chat-messages.tsx & agent-tools.tsx — UI grouping, keys, and conditional rendering for new data-* parts and progress UI.
    • app/api/chat/route.ts — stream wrapping, handling both async iterator and ReadableStream shapes, and agent resolution logic.
    • src/mastra/index.ts — OTLP/TraceLoop exporter configuration correctness and secrets handling.

Possibly related PRs

Suggested reviewers

  • sourcery-ai

Poem

🐰 I hopped through configs, tidy and spry,
Replaced old traces with Lamina's sky,
Tools now report their hops and their cheer,
Streams wrap neatly for UI to hear,
A joyful twitch — the rabbits approve, hip-hop! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: update configuration files and improve type checking' accurately summarizes the main changes across multiple config files and tsconfig improvements.
Description check ✅ Passed The description is well-related to the changeset, providing a clear bulleted list of modifications to each affected file and explaining the overall objective of integrating Laminar observability.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b3e8ac9 and d122c2c.

📒 Files selected for processing (12)
  • app/api/chat/route.ts (2 hunks)
  • app/chat/components/agent-tools.tsx (2 hunks)
  • app/chat/components/agent-web-preview.tsx (1 hunks)
  • app/chat/components/chat-input.tsx (1 hunks)
  • app/chat/components/chat-messages.tsx (14 hunks)
  • app/chat/components/nested-agent-chat.tsx (1 hunks)
  • app/chat/helpers/tool-part-transform.ts (3 hunks)
  • app/chat/providers/chat-context.tsx (9 hunks)
  • app/networks/providers/network-context.tsx (2 hunks)
  • docs/json.json (1 hunks)
  • src/mastra/index.ts (1 hunks)
  • src/mastra/tools/web-scraper-tool.ts (5 hunks)

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 and usage tips.

@github-actions
Copy link

🤖 Hi @ssdeanx, I've received your request, and I'm working on it now! You can track my progress in the logs for more details.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ssdeanx, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on updating the project's configuration and improving its type-checking setup. It primarily involves switching the observability provider from Langfuse to Lamina, which necessitated changes in environment variable examples and the core observability integration. Additionally, the type-checking configuration has been refined to ensure better coverage and exclude problematic declaration files, contributing to a more robust development experience.

Highlights

  • Observability Provider Switch: The project has transitioned its observability integration from Langfuse to Lamina, involving updates to environment variables and the core observability setup in src/mastra/index.ts.
  • Improved Type Checking Configuration: The tsconfig.json has been enhanced to include additional type definitions and exclude specific problematic declaration files, while eslint.config.js now ignores certain TypeScript declaration files to prevent linting issues.
  • Configuration File Refinements: Configuration files like .env.example and next.config.ts have been updated for clarity and maintainability, including the removal of deprecated Langfuse settings and reformatting of package lists.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link

🤖 I'm sorry @ssdeanx, but I was unable to process your request. Please see the logs for more details.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • In src/mastra/index.ts, the default: { enabled: false } observability config is now commented out rather than removed or replaced; consider making the intended default behavior explicit (enabled vs disabled) via configuration instead of leaving commented code.
  • In tsconfig.json, types/**/*.d.ts appears twice in the include array and the inline comment about excluding tests no longer matches the actual include list; it would be clearer to deduplicate the pattern and update or relocate the comment so it accurately reflects the current configuration.
  • The ESLint and TypeScript configs both ignore specific declaration files under node_modules; if possible, prefer addressing these via parser/tsconfig options or local type shim declarations rather than hardcoding deep node_modules paths, which can be brittle to library updates.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `src/mastra/index.ts`, the `default: { enabled: false }` observability config is now commented out rather than removed or replaced; consider making the intended default behavior explicit (enabled vs disabled) via configuration instead of leaving commented code.
- In `tsconfig.json`, `types/**/*.d.ts` appears twice in the `include` array and the inline comment about excluding tests no longer matches the actual include list; it would be clearer to deduplicate the pattern and update or relocate the comment so it accurately reflects the current configuration.
- The ESLint and TypeScript configs both ignore specific declaration files under `node_modules`; if possible, prefer addressing these via parser/tsconfig options or local type shim declarations rather than hardcoding deep `node_modules` paths, which can be brittle to library updates.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates configuration files and improves type checking by replacing Langfuse with Lamina for observability, cleaning up next.config.ts, and refining TypeScript configurations. My review focuses on the new observability setup and tsconfig.json changes. I've identified a few areas for improvement in src/mastra/index.ts to make the new Laminar configuration more robust by validating the API key and using environment variables for service name and environment. Additionally, there's a redundant entry in tsconfig.json that can be removed. Overall, these are good changes that improve the project's configuration.

new OtelExporter({
provider: {
laminar: {
apiKey: process.env.LMNR_PROJECT_API_KEY,
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The LMNR_PROJECT_API_KEY environment variable is used directly. If it's not set, apiKey will be undefined, which could lead to runtime errors or silent failures in the observability setup. It's safer to validate that the environment variable is present before using it and fail fast if it's missing, or at least provide a default empty string ?? '' to avoid passing undefined.

}
}
})]
serviceName: "my-service",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The serviceName is set to a generic value "my-service". It would be more informative to use a specific name for this service, for example, the application name from package.json (agentstack) or an environment variable. This helps in identifying the service in the observability platform.

Suggested change
serviceName: "my-service",
serviceName: process.env.OTEL_SERVICE_NAME ?? "agentstack",

logger: log,
resourceAttributes: {
// Optional OpenTelemetry Resource Attributes for the trace
["deployment.environment"]: "dev",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The deployment.environment is hardcoded to "dev". This is not ideal for different environments like staging or production. It would be better to source this value from an environment variable, such as NODE_ENV.

Suggested change
["deployment.environment"]: "dev",
["deployment.environment"]: process.env.NODE_ENV ?? "dev",

"tests/**/*.tsx"
// Tests are excluded from the main typecheck run to avoid typechecking test-only imports
// that may pull in declaration files with unsupported syntax from node_modules.
"types/**/*.d.ts",
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The path "types/**/*.d.ts" is included twice in the include array (the first inclusion is on line 54). While this doesn't cause an error, this entry is redundant and can be removed for clarity.

@greptile-apps
Copy link

greptile-apps bot commented Dec 12, 2025

Greptile Overview

Greptile Summary

This PR migrates the observability stack from Langfuse to Laminar and improves TypeScript type checking by excluding problematic declaration files.

  • Replaced Langfuse configuration with Laminar (LMNR_PROJECT_API_KEY) in environment and observability setup
  • Added specific node_modules declaration files to ESLint and TypeScript ignore lists to resolve type checking errors
  • Alphabetically sorted serverExternalPackages array in Next.js config for better maintainability
  • Enhanced tsconfig.json to include additional type definition directories (utils, styles, types)

Critical Issue: The default: { enabled: false } observability flag was commented out, which will enable observability by default and could cause startup failures if Laminar isn't properly configured.

Confidence Score: 2/5

  • This PR has a critical logic issue that could cause runtime failures
  • The commented-out default: { enabled: false } flag in the observability configuration will enable observability by default, potentially causing startup errors or unexpected trace sending if Laminar isn't configured. The rest of the changes are safe refactoring and configuration improvements.
  • Pay close attention to src/mastra/index.ts - the observability configuration change needs to be fixed before merging

Important Files Changed

File Analysis

Filename Score Overview
.env.example 5/5 Replaced Langfuse configuration with Laminar (LMNR_PROJECT_API_KEY)
eslint.config.js 5/5 Added specific node_modules declaration files to ignore list to resolve type checking issues
next.config.ts 5/5 Reformatted serverExternalPackages array alphabetically for better readability
src/mastra/index.ts 2/5 Migrated from Langfuse to Laminar observability provider, removed LangfuseExporter import, but commented out default disabled flag which could cause unintended behavior
tsconfig.json 4/5 Added more type definition paths (utils, styles, types dirs) and excluded problematic declaration files, though types/**/*.d.ts appears duplicated in include array

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Env as .env.example
    participant TS as TypeScript Config
    participant ESLint as ESLint Config
    participant Next as Next.js Config
    participant Mastra as Mastra Instance
    participant Laminar as Laminar Service

    Dev->>Env: Update environment variables
    Note over Env: Remove LANGFUSE_* vars<br/>Add LMNR_PROJECT_API_KEY

    Dev->>TS: Update tsconfig.json
    Note over TS: Add utils/, styles/, types/ dirs<br/>Exclude problematic .d.ts files

    Dev->>ESLint: Update eslint.config.js
    Note over ESLint: Ignore node_modules/@crawlee/<br/>and @mdx-js declaration files

    Dev->>Next: Refactor next.config.ts
    Note over Next: Alphabetize serverExternalPackages

    Dev->>Mastra: Update observability config
    Note over Mastra: Remove LangfuseExporter import<br/>Add Laminar OtelExporter<br/>⚠️ Comment out default disabled flag

    Mastra->>Mastra: Initialize with new config
    alt LMNR_PROJECT_API_KEY is set
        Mastra->>Laminar: Connect with API key
        Laminar-->>Mastra: Connection established
    else API key not set
        Mastra-xLaminar: ⚠️ Observability enabled but unconfigured
        Note over Mastra: Potential runtime error
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

logger: log,
observability: new Observability({
default: { enabled: false },
// default: { enabled: false },
Copy link

Choose a reason for hiding this comment

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

logic: Commenting out default: { enabled: false } will enable observability by default. If Laminar isn't configured, this could cause startup errors or send traces unexpectedly.

Suggested change
// default: { enabled: false },
default: { enabled: false },
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/mastra/index.ts
Line: 187:187

Comment:
**logic:** Commenting out `default: { enabled: false }` will enable observability by default. If Laminar isn't configured, this could cause startup errors or send traces unexpectedly.

```suggestion
    default: { enabled: false },
```

How can I resolve this? If you propose a fix, please make it concise.

Comment on lines 54 to 69
@@ -58,8 +64,10 @@
"hooks/**/*.tsx",
"pages/**/*.ts",
"pages/**/*.tsx",
"tests/**/*.ts",
"tests/**/*.tsx"
// Tests are excluded from the main typecheck run to avoid typechecking test-only imports
// that may pull in declaration files with unsupported syntax from node_modules.
"types/**/*.d.ts",
Copy link

Choose a reason for hiding this comment

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

style: types/**/*.d.ts appears twice in the include array (lines 54 and 69)

Suggested change
"types/**/*.d.ts",
"utils/**/*.ts",
"utils/**/*.tsx",
"styles/**/*.ts",
"styles/**/*.tsx",
Prompt To Fix With AI
This is a comment left during a code review.
Path: tsconfig.json
Line: 54:69

Comment:
**style:** `types/**/*.d.ts` appears twice in the include array (lines 54 and 69)

```suggestion
    "types/**/*.d.ts",
    "utils/**/*.ts",
    "utils/**/*.tsx",
    "styles/**/*.ts",
    "styles/**/*.tsx",
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bff9d08 and b3e8ac9.

📒 Files selected for processing (5)
  • .env.example (1 hunks)
  • eslint.config.js (1 hunks)
  • next.config.ts (1 hunks)
  • src/mastra/index.ts (1 hunks)
  • tsconfig.json (3 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
tsconfig*.json

📄 CodeRabbit inference engine (AGENTS.md)

Configure TypeScript with separate tsconfig.json for app (ES2022) and tsconfig.cli.json for CLI builds (CommonJS)

Files:

  • tsconfig.json
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

**/*.{js,jsx,ts,tsx}: Use next/dynamic for dynamic imports to load components only when needed, improving initial load time.
Use next/image component for automatic image optimization, including lazy loading and responsive images.
Use React.memo to prevent unnecessary re-renders of components.
Use the <Link prefetch> tag to prefetch pages that are likely to be visited.
Use getServerSideProps, getStaticProps, or server components for fetching data on the server-side.
Use SWR or React Query for client-side data fetching and caching.
Use CSS Modules, Styled Components, or Tailwind CSS for component-level styling. Prefer Tailwind CSS for rapid development.
Use React Context, Zustand, Jotai, or Recoil for managing global state. Avoid Redux unless necessary.
Use react-hook-form for managing forms and validation.
Only fetch the data that is needed by the component to avoid over-fetching.
Avoid long-running synchronous operations in the main thread to prevent blocking.
Always use setState or hooks to update state instead of mutating state directly.
Include a complete dependency array in useEffect hooks to prevent unexpected behavior.
Avoid writing server-side code in client components to prevent exposing secrets or causing unexpected behavior.
Use try...catch blocks for handling errors in asynchronous operations.
Implement error boundary components using getDerivedStateFromError or componentDidCatch lifecycle methods.
Sanitize user input to prevent Cross-Site Scripting (XSS) attacks. Be especially careful when rendering HTML directly from user input.
Store authentication tokens in HTTP-only cookies or local storage securely.
Implement role-based access control to restrict access to sensitive resources.
Clean up event listeners and timers in useEffect hooks to avoid memory leaks.
Only update state when necessary to reduce the number of re-renders and improve performance.
Use immutable data structures and avoid mutating data directly to prevent unexpected...

Files:

  • next.config.ts
  • src/mastra/index.ts
  • eslint.config.js
**/next.config.{js,ts}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

**/next.config.{js,ts}: Integrate linting and formatting into the build process to ensure consistent code.
Analyze bundle size using tools like webpack-bundle-analyzer to identify large dependencies.
Use tree shaking to remove unused code from bundles.

Files:

  • next.config.ts
**/*.{js,ts}

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

Use parameterized queries or an ORM to prevent SQL injection attacks.

Files:

  • next.config.ts
  • src/mastra/index.ts
  • eslint.config.js
**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}

📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)

**/*.{ts,tsx,js,jsx,py,java,cs,rb,go,rs,cpp,c,h,hpp,swift,kotlin,php,scala,clj,groovy,lua,sh,bash}: Write code that speaks for itself. Comment only when necessary to explain WHY, not WHAT. Avoid obvious comments that state what the code literally does.
Avoid redundant comments that simply repeat what the code is doing
Keep comments accurate and up-to-date with code changes. Remove or update outdated comments that no longer match the implementation.
Write comments for complex business logic that explain the WHY behind specific calculations or business rules
Document non-obvious algorithms with comments explaining the algorithm choice and its reasoning
Add comments explaining what regex patterns match, especially for complex patterns
Document API constraints, rate limits, gotchas, and external dependencies with explanatory comments
Avoid commenting out dead code. Use version control instead of maintaining commented code blocks.
Do not maintain code change history or modification logs as comments. Rely on git history and commit messages instead.
Avoid decorative divider comments (e.g., lines of equals signs or asterisks) for section separation
Ensure comments are placed appropriately above or adjacent to the code they describe
Write comments using proper grammar, spelling, and professional language
Prefer self-documenting code with clear variable/function names over adding comments to explain unclear code

Files:

  • next.config.ts
  • src/mastra/index.ts
  • eslint.config.js
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)

**/*.{ts,tsx,js,jsx}: Document public APIs with TSDoc/JSDoc comments including parameter descriptions, return types, examples, and thrown exceptions
Add TSDoc comments to configuration constants and environment variables explaining their source, reasoning, or constraints
Use TSDoc annotation tags (TODO, FIXME, HACK, NOTE, WARNING, PERF, SECURITY, BUG, REFACTOR, DEPRECATED) to mark special comments
Include file headers with @fileoverview, @author, @copyright, and @license tags to document file purpose and ownership
Document function parameters with @param tags, return values with @returns tags, and exceptions with @throws tags in TSDoc comments
Use @see tags in TSDoc comments to reference related functions, methods, or documentation
Include @example tags in public API documentation with code examples showing typical usage

**/*.{ts,tsx,js,jsx}: Use Mastra mcp tools (#mastradocs, #mastraChanges, #mastraexamples, #mastraBlog) for Mastra framework development to stay updated with latest features and best practices
When working with Next.js projects, always utilize the next-devtools-mcp server for all Next.js related queries

Files:

  • next.config.ts
  • src/mastra/index.ts
  • eslint.config.js
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/instructions/self-explanatory-code-commenting.instructions.md)

**/*.{ts,tsx}: Document interface and type definitions with TSDoc comments explaining their purpose and usage context
Document interface properties with /** */ comments explaining each field's purpose and constraints
Document generic type parameters with @template tags explaining what each type parameter represents
Use type guards with comments explaining the runtime validation logic being performed
Document advanced/complex TypeScript types with explanatory comments about their purpose and use cases

Files:

  • next.config.ts
  • src/mastra/index.ts
**/*.{css,tsx,ts}

📄 CodeRabbit inference engine (AGENTS.md)

Use Tailwind CSS 4 with oklch color variables for styling

Files:

  • next.config.ts
  • src/mastra/index.ts
src/mastra/index.ts

📄 CodeRabbit inference engine (src/AGENTS.md)

Enforce registration pattern in mastra/index.ts for AI orchestration modules composition

Files:

  • src/mastra/index.ts
src/mastra/**/*

📄 CodeRabbit inference engine (src/AGENTS.md)

mastra modules can import from utils, but must not import from app or cli (except types)

Files:

  • src/mastra/index.ts
**/.env*

📄 CodeRabbit inference engine (.github/instructions/next-js.instructions.md)

Use environment variables to store configuration values in the application.

Files:

  • .env.example
{.env*,**.github/workflows/**/*.{yml,yaml}}

📄 CodeRabbit inference engine (AGENTS.md)

Never commit API keys or secrets to the repo; use .env locally and secure env variables in CI/CD

Files:

  • .env.example
.env*

📄 CodeRabbit inference engine (AGENTS.md)

Environment configuration should include at minimum: SUPABASE/DATABASE_URL, GOOGLE_GENERATIVE_AI_API_KEY, and optional provider keys (OPENAI_API_KEY, ANTHROPIC_API_KEY, OPENROUTER_API_KEY)

Files:

  • .env.example
🧬 Code graph analysis (1)
src/mastra/index.ts (1)
src/mastra/config/logger.ts (1)
  • log (14-18)
🪛 dotenv-linter (4.0.0)
.env.example

[warning] 27-27: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: Sourcery review
  • GitHub Check: Codacy Security Scan
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
next.config.ts (1)

7-23: LGTM! Server external packages configuration is appropriate.

The expanded serverExternalPackages list correctly identifies packages that should remain external to the Next.js server bundle:

  • Mastra ecosystem packages (@mastra/*, @mcpc-tech/*, etc.)
  • Server-only utilities (playwright-core, pdf-parse, csv-parse, re2)
  • Packages requiring Node.js APIs (cheerio, jose, marked)

The wildcard patterns efficiently cover package scopes while keeping the configuration maintainable.

As per coding guidelines, consider analyzing the bundle size impact using webpack-bundle-analyzer to verify that bundling exclusions are optimal.

tsconfig.json (2)

53-58: LGTM! Type definition coverage expanded appropriately.

The new include patterns broaden TypeScript's type-checking scope to cover:

  • Mastra type definitions (src/mastra/types/**/*.d.ts)
  • Project-wide type definitions (types/**/*.d.ts)
  • Utility and style modules (utils/**/*, styles/**/*)

This aligns with the PR objective of improving type checking across the project.


85-87: Consistent exclusion of problematic node_modules declarations.

Excluding specific declaration files from both ESLint (eslint.config.js lines 26-27) and TypeScript compilation ensures these files with syntax issues don't break the build pipeline. This approach is acceptable for addressing upstream package issues.

eslint.config.js (1)

26-27: Remove this comment—these ignores are necessary and justified.

Both eslint.config.js and tsconfig.json explicitly exclude node_modules/@crawlee/http/internals/http-crawler.d.ts and node_modules/@mdx-js/loader/index.d.cts because these specific declaration files cause parsing or type-checking issues. The blanket node_modules/** ignore does not prevent these files from being processed. The explicit exclusions were added intentionally in a coordinated configuration update and are required for both ESLint and TypeScript to function correctly with these packages.

Comment on lines +26 to +27
# Lamina Configuration
LMNR_PROJECT_API_KEY='your_project_api_key_here'
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove quote characters from environment variable placeholder.

The migration from Langfuse to Lamina configuration looks correct. However, environment variable values in .env files should not include quote characters - they become part of the actual value when parsed.

Based on coding guidelines, environment variables should be stored without quotes. Apply this diff:

 # Lamina Configuration
-LMNR_PROJECT_API_KEY='your_project_api_key_here'
+LMNR_PROJECT_API_KEY=your_project_api_key_here

This aligns with the pattern used by other variables in this file (e.g., lines 4-5, 24).

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Lamina Configuration
LMNR_PROJECT_API_KEY='your_project_api_key_here'
# Lamina Configuration
LMNR_PROJECT_API_KEY=your_project_api_key_here
🧰 Tools
🪛 dotenv-linter (4.0.0)

[warning] 27-27: [QuoteCharacter] The value has quote characters (', ")

(QuoteCharacter)

🤖 Prompt for AI Agents
In .env.example around lines 26 to 27, the LMNR_PROJECT_API_KEY placeholder is
wrapped in single quotes which will become part of the value when parsed; remove
the quote characters so the line reads
LMNR_PROJECT_API_KEY=your_project_api_key_here to match other entries and avoid
embedding quotes in the environment value.

Comment on lines 190 to 205
serviceName: "my-service",
exporters: [
new OtelExporter({
provider: {
laminar: {
apiKey: process.env.LMNR_PROJECT_API_KEY,
// teamId: process.env.LAMINAR_TEAM_ID, // Optional, for backwards compatibility
},
},
logger: log,
resourceAttributes: {
// Optional OpenTelemetry Resource Attributes for the trace
["deployment.environment"]: "dev",
},
}),
],
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's examine the file and the specific lines mentioned
cat -n src/mastra/index.ts | head -220 | tail -50

Repository: ssdeanx/AgentStack

Length of output: 2200


🏁 Script executed:

# Check if .env.example exists and contains the referenced variable
find . -name ".env*" -type f | head -10

Repository: ssdeanx/AgentStack

Length of output: 76


🏁 Script executed:

# Search for service name patterns and Laminar references
rg "serviceName" src/ -A2 -B2 --type ts --type js

Repository: ssdeanx/AgentStack

Length of output: 564


🏁 Script executed:

# Check for Laminar/LMNR references in the codebase
rg -i "lmnr|laminar" src/ --type ts --type js -C2

Repository: ssdeanx/AgentStack

Length of output: 464


🏁 Script executed:

# Check .env.example content
cat -n .env.example | head -50

Repository: ssdeanx/AgentStack

Length of output: 2033


🏁 Script executed:

# Search for project name or app name patterns
rg "mastra-app|AgentStack" . -t json -t ts -t js --type-add json:match .json -C1

Repository: ssdeanx/AgentStack

Length of output: 17942


🏁 Script executed:

# Check package.json for project name
cat package.json | grep -A5 -B5 '"name"'

Repository: ssdeanx/AgentStack

Length of output: 374


🏁 Script executed:

# Search for other service configurations or naming patterns
rg "service" src/mastra/ -i --type ts -C1 | head -40

Repository: ssdeanx/AgentStack

Length of output: 2906


Replace placeholder service name with a descriptive identifier.

The Laminar OTEL exporter configuration is correctly structured with proper API key sourcing from LMNR_PROJECT_API_KEY and logger integration. However, the service name "my-service" (line 190) is a placeholder and should be replaced with a descriptive identifier that reflects your application. Consider aligning with your project naming conventions (e.g., "agentstack" matching your package.json name, or "mastra-app" as a service-specific identifier).

🤖 Prompt for AI Agents
In src/mastra/index.ts around lines 190 to 205, the exporter currently uses the
placeholder serviceName "my-service"; replace this with a descriptive identifier
that matches your project naming (for example the package.json "name" value like
"agentstack" or a service-specific value like "mastra-app"), or wire it to an
environment variable (e.g., process.env.SERVICE_NAME with a sensible fallback)
so the OTEL traces carry a meaningful service name consistent with your
deployment and naming conventions.

Comment on lines +67 to +69
// Tests are excluded from the main typecheck run to avoid typechecking test-only imports
// that may pull in declaration files with unsupported syntax from node_modules.
"types/**/*.d.ts",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove duplicate include entry and clarify comment.

Line 69 duplicates the types/**/*.d.ts pattern already included on line 54. Additionally, the comment mentions excluding tests from typechecking, but the entry below is an include pattern (not an exclude), and no test-specific patterns appear in the exclude section.

Apply this diff to remove the duplicate:

-    // Tests are excluded from the main typecheck run to avoid typechecking test-only imports
-    // that may pull in declaration files with unsupported syntax from node_modules.
-    "types/**/*.d.ts",
-

If test files need to be excluded, add patterns like **/*.test.ts, **/*.spec.ts to the exclude array instead.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Tests are excluded from the main typecheck run to avoid typechecking test-only imports
// that may pull in declaration files with unsupported syntax from node_modules.
"types/**/*.d.ts",
🤖 Prompt for AI Agents
In tsconfig.json around lines 67 to 69, remove the duplicate "types/**/*.d.ts"
include entry on line 69 and update the surrounding comment to reflect what the
entry does (or move the comment to the include block if it refers to types). If
the intent was to exclude tests from typechecking instead, add test glob
patterns such as "**/*.test.ts" and "**/*.spec.ts" to the "exclude" array rather
than leaving an inaccurate comment next to an include entry.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the observability provider from Langfuse to Laminar and improves TypeScript type checking by excluding problematic declaration files. The changes enhance configuration clarity by reformatting serverExternalPackages and adding explicit type inclusion paths in tsconfig.json.

Key Changes:

  • Migration from Langfuse to Laminar for observability tracking with updated environment variables and configuration
  • Improved type checking by excluding specific problematic TypeScript declaration files from both ESLint and TypeScript compilation
  • Enhanced code readability by alphabetically sorting serverExternalPackages in next.config.ts

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
.env.example Replaced Langfuse environment variables (LANGFUSE_SECRET_KEY, LANGFUSE_PUBLIC_KEY, LANGFUSE_BASE_URL) with Laminar configuration (LMNR_PROJECT_API_KEY)
eslint.config.js Added exclusions for two problematic node_modules declaration files (@crawlee/http and @mdx-js/loader) to prevent linting errors
next.config.ts Refactored serverExternalPackages from single-line to multi-line alphabetically sorted array for better readability
src/mastra/index.ts Replaced Langfuse exporter with Laminar's OtelExporter, updated service configuration, and removed Langfuse import
tsconfig.json Added explicit includes for types, utils, and styles directories; excluded problematic declaration files; added comment about test exclusion

new OtelExporter({
provider: {
laminar: {
apiKey: process.env.LMNR_PROJECT_API_KEY,
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Missing error handling for undefined API key. If LMNR_PROJECT_API_KEY is not set in the environment, this will pass undefined to the Laminar provider, which could cause runtime errors. Consider adding validation to ensure the API key is defined, or provide a fallback behavior with appropriate logging.

Suggested change
apiKey: process.env.LMNR_PROJECT_API_KEY,
apiKey: laminarApiKey,

Copilot uses AI. Check for mistakes.
logger: log,
resourceAttributes: {
// Optional OpenTelemetry Resource Attributes for the trace
["deployment.environment"]: "dev",
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Environment value is hardcoded as "dev". Consider using an environment variable like process.env.NODE_ENV or process.env.DEPLOYMENT_ENV to allow this to be configured for different deployment environments (development, staging, production).

Suggested change
["deployment.environment"]: "dev",
["deployment.environment"]: process.env.DEPLOYMENT_ENV || process.env.NODE_ENV || "development",

Copilot uses AI. Check for mistakes.
LANGFUSE_SECRET_KEY="sk-lf-your_secret_key_here"
LANGFUSE_PUBLIC_KEY="pk-lf-your_public_key_here"
LANGFUSE_BASE_URL="https://cloud.langfuse.com"
# Lamina Configuration
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

Typo in comment: "Lamina" should be "Laminar". The correct product name is "Laminar", not "Lamina".

Suggested change
# Lamina Configuration
# Laminar Configuration

Copilot uses AI. Check for mistakes.
logger: log,
observability: new Observability({
default: { enabled: false },
// default: { enabled: false },
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The commented-out line "default: { enabled: false }" should either be removed entirely or uncommented if it's needed. Leaving it commented creates ambiguity about the intended default observability behavior. Consider removing it if Laminar observability should be active by default, or uncomment it if observability should be opt-in.

Suggested change
// default: { enabled: false },

Copilot uses AI. Check for mistakes.
}
}
})]
serviceName: "my-service",
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

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

The service name "my-service" is a placeholder value that should be replaced with a meaningful name specific to this application. Consider using a descriptive name like "maestra-app" (as it was previously) or deriving it from an environment variable for better configurability.

Suggested change
serviceName: "my-service",
serviceName: process.env.MASTRA_SERVICE_NAME ?? "maestra-app",

Copilot uses AI. Check for mistakes.
- Removed multiple empty <code-changes> tags to clean up the code.
- Ensured consistency in the formatting of the changes section.
- Prepared the code for future updates by maintaining a clear structure.
@ssdeanx ssdeanx merged commit 59cc98b into main Dec 12, 2025
2 of 4 checks passed
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