Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion convex.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"node": {
"nodeVersion": "24"
"nodeVersion": "20"
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:

cat package.json | jq '.devDependencies["@types/node"], .engines.node' 2>/dev/null || grep -A5 -B5 "@types/node" package.json

Repository: ssdeanx/AgentStack

Length of output: 83


🏁 Script executed:

cat convex.json | head -20

Repository: ssdeanx/AgentStack

Length of output: 170


🏁 Script executed:

# Search for potential Node 22+ specific APIs being used
rg -n "fs\.promises|crypto|util|stream" --type=ts --type=tsx --type=js --type=jsx -A1 | head -50

Repository: ssdeanx/AgentStack

Length of output: 89


🏁 Script executed:

# Check for imports that might use Node 22+ specific features
rg "import.*from.*['\"]node:" --type=ts --type=tsx --type=js --type=jsx

Repository: ssdeanx/AgentStack

Length of output: 89


🏁 Script executed:

# Find TypeScript files and search for potentially version-specific imports/APIs
find . -type f \( -name "*.ts" -o -name "*.js" \) ! -path "./node_modules/*" -exec grep -l "import.*from.*['\"]node:" {} \; 2>/dev/null

Repository: ssdeanx/AgentStack

Length of output: 1394


🏁 Script executed:

# Search for crypto, fs, stream, util usage which may have Node 22+ specific APIs
rg "from ['\"]node:" --type=ts --type=js 2>/dev/null || rg "from ['\"]node:" 2>/dev/null | head -20

Repository: ssdeanx/AgentStack

Length of output: 4907


🏁 Script executed:

# Check if there are any TypeScript files using Node.js native modules
rg "require.*['\"]node:" --type=ts --type=js 2>/dev/null || rg "require.*['\"]node:" 2>/dev/null | head -20

Repository: ssdeanx/AgentStack

Length of output: 985


Align @types/node version with Node 20 target for consistency.

The @types/node dependency is set to ^22.19.7 (Node 22.x types) while the runtime target is Node 20. While the codebase currently uses only compatible APIs (fs/promises, stream/promises, path, os, stream—all available in Node 20.9.0), this version mismatch creates unnecessary risk: developers could inadvertently use Node 22-specific APIs at compile time without runtime guarantees.

Update @types/node to ^20.x to maintain alignment with the declared minimum Node version.

🤖 Prompt for AI Agents
In `@convex.json` at line 3, The project declares "nodeVersion": "20" but the dev
dependency `@types/node` is pinned to Node 22.x; update the `@types/node` entry in
your package.json devDependencies to a Node 20-compatible range (e.g. ^20.x) so
compile-time types match the runtime target, then run npm/yarn install and
update lockfile; verify no other references require Node 22 types.

},
"$schema": "./node_modules/convex/schemas/convex.schema.json"
}
44 changes: 39 additions & 5 deletions convex/_generated/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

/* eslint-disable */
/**
* Generated `api` utility.
*
Expand All @@ -8,8 +8,42 @@
* @module
*/

import type { AnyApi, AnyComponents } from "convex/server";
import type * as mastra_storage from "../mastra/storage.js";

import type {
ApiFromModules,
FilterApi,
FunctionReference,
} from "convex/server";

declare const fullApi: ApiFromModules<{
"mastra/storage": typeof mastra_storage;
}>;

/**
* A utility for referencing Convex functions in your app's public API.
*
* Usage:
* ```js
* const myFunctionReference = api.myModule.myFunction;
* ```
*/
export declare const api: FilterApi<
typeof fullApi,
FunctionReference<any, "public">
>;

/**
* A utility for referencing Convex functions in your app's internal API.
*
* Usage:
* ```js
* const myFunctionReference = internal.myModule.myFunction;
* ```
*/
export declare const internal: FilterApi<
typeof fullApi,
FunctionReference<any, "internal">
>;

export declare const api: AnyApi;
export declare const internal: AnyApi;
export declare const components: AnyComponents;
export declare const components: {};
4 changes: 2 additions & 2 deletions convex/mastra/storage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { mastraStorage } from '@mastra/convex/server'
import { mastraStorage } from '@mastra/convex/server';

export const handle = mastraStorage
export const handle = mastraStorage;
25 changes: 19 additions & 6 deletions convex/schema.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { defineSchema, defineTable } from 'convex/server';
import { v } from 'convex/values';
import {
mastraDocumentsTable,
mastraThreadsTable,
mastraMessagesTable,
mastraResourcesTable,
mastraScoresTable,
mastraThreadsTable,
mastraVectorIndexesTable,
mastraVectorsTable,
mastraWorkflowSnapshotsTable,
} from '@mastra/convex'
import { defineSchema } from 'convex/server'
mastraDocumentsTable,
} from '@mastra/convex/schema';

// Explicitly define mastra_workflow_snapshots to ensure the `id` field exists
// (some downstream Convex schema variants omit `id` which causes an invalid
// index declaration during Convex schema push).
const mastraWorkflowSnapshotsTable = defineTable({
id: v.string(),
workflow_name: v.string(),
run_id: v.string(),
resourceId: v.optional(v.string()),
snapshot: v.any(),
createdAt: v.string(),
updatedAt: v.string(),
}).index('by_record_id', ['id']).index('by_workflow_run', ['workflow_name', 'run_id']).index('by_workflow', ['workflow_name']).index('by_resource', ['resourceId']).index('by_created', ['createdAt']);
Comment on lines +16 to +24
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Inconsistent field naming and long line length.

  1. Naming inconsistency: Fields mix snake_case (workflow_name, run_id) and camelCase (resourceId, createdAt, updatedAt). Consider aligning to a consistent convention.

  2. Line 24 readability: The chained .index() calls create a very long line. Consider splitting for readability.

  3. v.any() for snapshot: This bypasses type safety. If the snapshot structure is known, consider defining a more specific validator.

♻️ Suggested refactor for readability
-const mastraWorkflowSnapshotsTable = defineTable({
-  id: v.string(),
-  workflow_name: v.string(),
-  run_id: v.string(),
-  resourceId: v.optional(v.string()),
-  snapshot: v.any(),
-  createdAt: v.string(),
-  updatedAt: v.string(),
-}).index('by_record_id', ['id']).index('by_workflow_run', ['workflow_name', 'run_id']).index('by_workflow', ['workflow_name']).index('by_resource', ['resourceId']).index('by_created', ['createdAt']);
+const mastraWorkflowSnapshotsTable = defineTable({
+  id: v.string(),
+  workflow_name: v.string(),
+  run_id: v.string(),
+  resource_id: v.optional(v.string()),
+  snapshot: v.any(),
+  created_at: v.string(),
+  updated_at: v.string(),
+})
+  .index('by_record_id', ['id'])
+  .index('by_workflow_run', ['workflow_name', 'run_id'])
+  .index('by_workflow', ['workflow_name'])
+  .index('by_resource', ['resource_id'])
+  .index('by_created', ['created_at']);

Note: If changing field names to snake_case, ensure any code consuming this table is updated accordingly.


export default defineSchema({
mastra_threads: mastraThreadsTable,
Expand All @@ -19,4 +32,4 @@ export default defineSchema({
mastra_vector_indexes: mastraVectorIndexesTable,
mastra_vectors: mastraVectorsTable,
mastra_documents: mastraDocumentsTable,
})
});
11 changes: 6 additions & 5 deletions mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { MDXComponents } from 'mdx/types'
import type { ReactNode } from 'react'
import Link from 'next/link'

// Custom components that work with MDX plugins
Expand Down Expand Up @@ -47,7 +48,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
// Links with hover effects
a: ({ href, children }) => (
<Link
href={href ?? '#'}
href={typeof href === 'string' ? href : '#'}
className="font-medium text-primary underline underline-offset-4 hover:text-primary/80 transition-colors"
>
{children}
Expand Down Expand Up @@ -75,8 +76,8 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
),

// Code blocks and inline code - these work with rehype-highlight
code: ({ children, className }) => {
const isInline = !className?.includes('language-')
code: ({ children, className }: { children?: ReactNode; className?: string }) => {
const isInline = typeof className !== 'string' || !className.includes('language-')
return isInline ? (
<code className="relative rounded bg-muted px-1.5 py-0.5 font-mono text-sm text-foreground">
{children}
Expand Down Expand Up @@ -116,9 +117,9 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
),

// Images with responsive design
img: ({ src, alt, title }) => (
img: ({ src, alt, title }: { src?: string; alt?: string; title?: string }) => (
<img
src={src}
src={src ?? undefined}
alt={alt ?? ''}
title={title}
className="my-4 rounded-lg border border-border"
Expand Down
50 changes: 48 additions & 2 deletions next.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import createMDX from '@next/mdx'
import MonacoWebpackPlugin from 'monaco-editor-webpack-plugin'
import type { NextConfig } from 'next'
import type { Configuration } from 'webpack'

const nextConfig: NextConfig = {
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
Expand Down Expand Up @@ -38,7 +39,7 @@ const nextConfig: NextConfig = {
typedRoutes: false,
reactStrictMode: true,
distDir: '.next',
webpack: (config, { isServer }) => {
webpack: (config: Configuration, { isServer }) => {
if (!isServer) {
config.plugins = config.plugins ?? []
config.plugins.push(
Comment on lines +42 to 45
Copy link

Choose a reason for hiding this comment

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

issue (bug_risk): Alias normalization may break valid webpack alias configurations and change behavior.

Forcing resolve.alias into Record<string, string | string[]> drops support for valid webpack alias shapes (e.g. false, { name, alias, onlyModule }, path-like objects). Examples:

  • { react: false } becomes the string "false", no longer disabling resolution.
  • Array-style aliases become a plain object of stringified entries.
  • Non-string values (e.g. path objects) are stringified and may no longer work.

If you only need serialization (e.g. for Turbopack/worker cloning), consider a narrower transformation: handle only known-problematic values (like functions) or specific keys you must sanitize, and otherwise preserve the original alias structure. The current approach risks silently changing module resolution and causing hard-to-diagnose build/runtime issues.

Expand All @@ -52,10 +53,55 @@ const nextConfig: NextConfig = {
],
})
)

// Sanitize resolve.alias so values are serializable for Turbopack/worker cloning
// Ensure resolve exists and normalize alias values to strings/arrays of strings
const existingResolve = config.resolve ?? {}
const aliasObj = (existingResolve as unknown as Record<string, unknown>).alias ?? {}
if (typeof aliasObj === 'object' && aliasObj !== null) {
const normalized: Record<string, string | string[]> = {}
for (const [k, v] of Object.entries(aliasObj as Record<string, unknown>)) {
if (Array.isArray(v)) {
normalized[k] = v.map((x) => String(x))
} else if (typeof v === 'object' && v !== null) {
// For objects, stringify to avoid '[object Object]' implicit string coercion
try {
normalized[k] = JSON.stringify(v)
} catch {
normalized[k] = ''
}
} else if (typeof v === 'function') {
// For functions, prefer the function name to avoid serializing the entire function
// Narrow to an object with an optional name property to avoid using the broad Function type
const fnName = (v as { name?: string })?.name ?? ''
Comment on lines +75 to +76
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The type casting (v as { name?: string }) is used to narrow the function type for accessing the name property. While this works, it would be clearer to explicitly check if v is a function before accessing its name property using a type guard like typeof v === 'function' (which is already checked in the outer condition), and then TypeScript should allow accessing v.name directly.

Suggested change
// Narrow to an object with an optional name property to avoid using the broad Function type
const fnName = (v as { name?: string })?.name ?? ''
const fnName = v.name ?? ''

Copilot uses AI. Check for mistakes.
normalized[k] = fnName
} else if (v === null || v === undefined) {
// Keep null/undefined normalized to an empty string
normalized[k] = ''
} else {
// At this point, expect primitives (string/number/boolean/symbol/bigint).
// Guard against objects to avoid default Object stringification '[object Object]'.
const t = typeof v
if (t === 'string' || t === 'number' || t === 'boolean' || t === 'symbol' || t === 'bigint') {
// Narrow the type for the linter to avoid base-to-string coercion warnings
normalized[k] = String(v as string | number | boolean | symbol | bigint)
} else {
// Fallback for unexpected non-serializable values
try {
normalized[k] = JSON.stringify(v)
} catch {
normalized[k] = ''
}
}
}
}
config.resolve = { ...existingResolve, alias: normalized } as Configuration['resolve']
}
Comment on lines +56 to +99
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Alias normalization may silently break module resolution.

The normalization logic handles edge cases but may produce unexpected behavior:

  1. Object aliases (line 69): JSON.stringify produces a JSON string, not a valid module path. If an alias was { exact: true, path: './foo' }, it becomes '{"exact":true,"path":"./foo"}'.

  2. Function aliases (line 76-77): Extracting only the function name loses the actual resolution logic entirely.

  3. Silent failures: Empty string fallbacks (lines 71, 80, 93) suppress errors, making debugging difficult when aliases break.

Consider logging warnings when non-serializable aliases are encountered so issues are surfaced during development.

💡 Suggested improvement: Add warnings for non-serializable aliases
                    } else if (typeof v === 'object' && v !== null) {
-                        // For objects, stringify to avoid '[object Object]' implicit string coercion
-                        try {
-                            normalized[k] = JSON.stringify(v)
-                        } catch {
-                            normalized[k] = ''
-                        }
+                        // Object aliases cannot be serialized - warn and skip
+                        console.warn(`[next.config] Webpack alias "${k}" is an object and cannot be serialized for Turbopack. Skipping.`)
+                        continue
                    } else if (typeof v === 'function') {
-                        // For functions, prefer the function name to avoid serializing the entire function
-                        // Narrow to an object with an optional name property to avoid using the broad Function type
-                        const fnName = (v as { name?: string })?.name ?? ''
-                        normalized[k] = fnName
+                        // Function aliases cannot be serialized - warn and skip
+                        console.warn(`[next.config] Webpack alias "${k}" is a function and cannot be serialized for Turbopack. Skipping.`)
+                        continue
📝 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
// Sanitize resolve.alias so values are serializable for Turbopack/worker cloning
// Ensure resolve exists and normalize alias values to strings/arrays of strings
const existingResolve = config.resolve ?? {}
const aliasObj = (existingResolve as unknown as Record<string, unknown>).alias ?? {}
if (typeof aliasObj === 'object' && aliasObj !== null) {
const normalized: Record<string, string | string[]> = {}
for (const [k, v] of Object.entries(aliasObj as Record<string, unknown>)) {
if (Array.isArray(v)) {
normalized[k] = v.map((x) => String(x))
} else if (typeof v === 'object' && v !== null) {
// For objects, stringify to avoid '[object Object]' implicit string coercion
try {
normalized[k] = JSON.stringify(v)
} catch {
normalized[k] = ''
}
} else if (typeof v === 'function') {
// For functions, prefer the function name to avoid serializing the entire function
// Narrow to an object with an optional name property to avoid using the broad Function type
const fnName = (v as { name?: string })?.name ?? ''
normalized[k] = fnName
} else if (v === null || v === undefined) {
// Keep null/undefined normalized to an empty string
normalized[k] = ''
} else {
// At this point, expect primitives (string/number/boolean/symbol/bigint).
// Guard against objects to avoid default Object stringification '[object Object]'.
const t = typeof v
if (t === 'string' || t === 'number' || t === 'boolean' || t === 'symbol' || t === 'bigint') {
// Narrow the type for the linter to avoid base-to-string coercion warnings
normalized[k] = String(v as string | number | boolean | symbol | bigint)
} else {
// Fallback for unexpected non-serializable values
try {
normalized[k] = JSON.stringify(v)
} catch {
normalized[k] = ''
}
}
}
}
config.resolve = { ...existingResolve, alias: normalized } as Configuration['resolve']
}
// Sanitize resolve.alias so values are serializable for Turbopack/worker cloning
// Ensure resolve exists and normalize alias values to strings/arrays of strings
const existingResolve = config.resolve ?? {}
const aliasObj = (existingResolve as unknown as Record<string, unknown>).alias ?? {}
if (typeof aliasObj === 'object' && aliasObj !== null) {
const normalized: Record<string, string | string[]> = {}
for (const [k, v] of Object.entries(aliasObj as Record<string, unknown>)) {
if (Array.isArray(v)) {
normalized[k] = v.map((x) => String(x))
} else if (typeof v === 'object' && v !== null) {
// Object aliases cannot be serialized - warn and skip
console.warn(`[next.config] Webpack alias "${k}" is an object and cannot be serialized for Turbopack. Skipping.`)
continue
} else if (typeof v === 'function') {
// Function aliases cannot be serialized - warn and skip
console.warn(`[next.config] Webpack alias "${k}" is a function and cannot be serialized for Turbopack. Skipping.`)
continue
} else if (v === null || v === undefined) {
// Keep null/undefined normalized to an empty string
normalized[k] = ''
} else {
// At this point, expect primitives (string/number/boolean/symbol/bigint).
// Guard against objects to avoid default Object stringification '[object Object]'.
const t = typeof v
if (t === 'string' || t === 'number' || t === 'boolean' || t === 'symbol' || t === 'bigint') {
// Narrow the type for the linter to avoid base-to-string coercion warnings
normalized[k] = String(v as string | number | boolean | symbol | bigint)
} else {
// Fallback for unexpected non-serializable values
try {
normalized[k] = JSON.stringify(v)
} catch {
normalized[k] = ''
}
}
}
}
config.resolve = { ...existingResolve, alias: normalized } as Configuration['resolve']
}
🤖 Prompt for AI Agents
In `@next.config.ts` around lines 56 - 99, The alias normalization logic converts
non-serializable values (objects, functions, etc.) to strings or empty strings
without alerting developers to potentially broken module resolution. Add warning
logs when normalizing object alias values (when stringify-ing objects), function
alias values (when extracting function names), and when falling back to empty
strings for unsupported types. These warnings should be logged using an
appropriate logger to help surface alias transformation issues during
development, making it clear to users that their webpack resolve.alias
configuration may not work as expected after normalization.

}

return config
},

typescript: {
ignoreBuildErrors: true,
Comment on lines 105 to 106
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Consider enabling TypeScript build errors in production.

ignoreBuildErrors: true suppresses all TypeScript errors during build. This can mask legitimate type issues that slip into production. Consider enabling build errors at least for CI/production builds.

🤖 Prompt for AI Agents
In `@next.config.ts` around lines 105 - 106, The Next.js config currently sets
typescript.ignoreBuildErrors: true which suppresses TypeScript build errors;
change this so CI/production builds do not ignore errors by making
ignoreBuildErrors conditional (e.g., false when process.env.CI is set or
NODE_ENV === 'production') and only allow true for local/dev runs, updating the
typescript.ignoreBuildErrors setting in next.config.ts (refer to the
typescript.ignoreBuildErrors key) so that production/CI builds fail on
TypeScript errors instead of silently ignoring them.

tsconfigPath: './tsconfig.json',
Expand Down Expand Up @@ -92,7 +138,7 @@ const nextConfig: NextConfig = {
// optimizeCss: true,
esmExternals: true,
scrollRestoration: true,
// cpus: 16,
// cpus: 16,
// cssChunking: true,
// craCompat: true,
// validateRSCRequestHeaders: true,
Expand Down
Loading
Loading