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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions lib/client-stream-to-ai-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async function* asyncIterableFromReadableStream<T>(
try {
while (true) {
const { done, value } = await reader.read();
if (done) break;
if (done) {break;}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Use idiomatic brace formatting.

The formatting if (done) {break;} is unusual. For consistency with common style guides, either omit braces for single statements or use multi-line formatting.

Apply this diff for the single-statement style (more common in TypeScript):

-      if (done) {break;}
+      if (done) break;

Or use multi-line formatting if braces are required by your linter:

-      if (done) {break;}
+      if (done) {
+        break;
+      }
📝 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
if (done) {break;}
if (done) break;
🤖 Prompt for AI Agents
In lib/client-stream-to-ai-sdk.ts around line 42, the statement uses
unconventional single-line brace formatting ("if (done) {break;}"); change it to
the idiomatic single-statement style by removing the braces and placing the
break on the same line as the condition (i.e., "if (done) break;") so it matches
common TypeScript style and the project's linting conventions.

yield value;
}
} finally {
Expand All @@ -49,16 +49,16 @@ async function* asyncIterableFromReadableStream<T>(

/**
* Creates a streaming Response for Next.js API routes using server-side Mastra agent.
*
*
* IMPORTANT: This should be used in API 5stra instance,
* not the client SDK. The client SDK (MastraClient) is for frontend use only.
*
*
* @example
* ```ts
* // app/api/chat/route.ts
* import { mastra } from "@/src/mastra";
* import { createAgentStreamResponse } from "@/lib/server/agent-stream";
*
*
* export async function POST(req: Request) {
* const { messages, agentId, threadId, resourceId, memory } = await req.json();
* return createAgentStreamResponse(mastra, agentId, messages, {
Expand All @@ -68,7 +68,7 @@ async function* asyncIterableFromReadableStream<T>(
* });
* }
* ```
*
*
* @see https://mastra.ai/docs/frameworks/agentic-uis/ai-sdk
*/
export async function createAgentStreamResponse(
Expand All @@ -78,7 +78,7 @@ export async function createAgentStreamResponse(
options?: AgentStreamOptions
): Promise<Response> {
const agent = mastra.getAgent(agentId);

const streamOptions = {
format: options?.format ?? "aisdk",
threadId: options?.threadId,
Expand All @@ -100,12 +100,12 @@ export async function createAgentStreamResponse(
const uiMessageStream = createUIMessageStream({
execute: async ({ writer }) => {
const aiSdkResult = toAISdkFormat(stream, { from: "agent" });

// Handle both ReadableStream and AsyncIterable
const iterable: AsyncIterable<unknown> = isReadableStream(aiSdkResult)
? asyncIterableFromReadableStream(aiSdkResult)
: aiSdkResult;

for await (const value of iterable) {
writer.write(value as Parameters<typeof writer.write>[0]);
}
Expand All @@ -120,11 +120,11 @@ export async function createAgentStreamResponse(
* This export exists for backward compatibility only.
*/
export async function createMastraStreamResponse(
_client: unknown,
_options: StreamToAISdkOptions
client: unknown,
options: StreamToAISdkOptions
Comment on lines +123 to +124
Copy link

Choose a reason for hiding this comment

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

style: parameter names changed from _client and _options to client and options, but they're still unused in the function that throws an error - consider keeping the underscore prefix to indicate intentionally unused parameters

Suggested change
client: unknown,
options: StreamToAISdkOptions
_client: unknown,
_options: StreamToAISdkOptions
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/client-stream-to-ai-sdk.ts
Line: 123:124

Comment:
**style:** parameter names changed from `_client` and `_options` to `client` and `options`, but they're still unused in the function that throws an error - consider keeping the underscore prefix to indicate intentionally unused parameters

```suggestion
  _client: unknown,
  _options: StreamToAISdkOptions
```

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

Comment on lines +123 to +124
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, check if the file exists and view the function context
wc -l lib/client-stream-to-ai-sdk.ts

Repository: ssdeanx/AgentStack

Length of output: 96


🏁 Script executed:

# View the function containing lines 123-124 with context
sed -n '110,140p' lib/client-stream-to-ai-sdk.ts

Repository: ssdeanx/AgentStack

Length of output: 713


🏁 Script executed:

# Check for linting configuration
ls -la | grep -E "(eslint|prettier|tsconfig)"
cat tsconfig.json | grep -A 5 "compilerOptions"

Repository: ssdeanx/AgentStack

Length of output: 437


🏁 Script executed:

# Check if eslint is available and run it on the file
if command -v eslint &> /dev/null; then
  echo "=== ESLint check ==="
  eslint lib/client-stream-to-ai-sdk.ts 2>&1 | head -50
else
  echo "ESLint not found"
fi

Repository: ssdeanx/AgentStack

Length of output: 78


🏁 Script executed:

# View the complete tsconfig.json file
cat tsconfig.json

Repository: ssdeanx/AgentStack

Length of output: 1559


🏁 Script executed:

# Check if there are any compilation errors or warnings
if command -v tsc &> /dev/null; then
  echo "=== TypeScript compiler check ==="
  tsc --noEmit 2>&1 | grep -i "client\|options\|unused" | head -20
else
  echo "TypeScript compiler not available in sandbox"
fi

Repository: ssdeanx/AgentStack

Length of output: 106


🏁 Script executed:

# Search for other uses of _client or _options pattern in the codebase to understand the convention
rg "_client|_options" --type ts --type tsx -B 2 -A 2 | head -50

Repository: ssdeanx/AgentStack

Length of output: 89


🏁 Script executed:

# Double-check for unused variable warnings in the ESLint config
cat eslint.config.cjs | grep -A 5 -B 5 "no-unused"

Repository: ssdeanx/AgentStack

Length of output: 415


🏁 Script executed:

# Check git history to understand if underscores were actually removed in this PR
git log --oneline -n 20 lib/client-stream-to-ai-sdk.ts 2>/dev/null || echo "git log not available"

Repository: ssdeanx/AgentStack

Length of output: 126


Add underscore prefix to unused function parameters to suppress ESLint warnings.

The function parameters client and options are unused since the function immediately throws an error. ESLint is configured with @typescript-eslint/no-unused-vars set to 'warn', which will flag these unused parameters. The underscore prefix convention (_client, _options) is the standard way to indicate intentionally unused parameters and suppress this warning.

Change to:

export async function createMastraStreamResponse(
  _client: unknown,
  _options: StreamToAISdkOptions
): Promise<Response> {
🤖 Prompt for AI Agents
In lib/client-stream-to-ai-sdk.ts around lines 123-124, the exported function
createMastraStreamResponse currently declares parameters client and options but
immediately throws, leaving them unused and triggering ESLint no-unused-vars
warnings; rename the parameters to _client and _options (underscore-prefixed) to
mark them intentionally unused and suppress the ESLint warnings, keeping the
rest of the function unchanged.

Comment on lines +123 to +124
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The parameter names have been changed from _client and _options (indicating intentionally unused parameters) to client and options. Since these parameters are genuinely unused (the function only throws an error), they should retain the underscore prefix to indicate this is intentional, following TypeScript conventions.

Suggested change
client: unknown,
options: StreamToAISdkOptions
_client: unknown,
_options: StreamToAISdkOptions

Copilot uses AI. Check for mistakes.
): Promise<Response> {
throw new Error(
"createMastraStreamResponse is deprecated. Use createAgentStreamResponse with " +
"the server-side mastra instance instead. See: https://mastra.ai/docs/frameworks/agentic-uis/ai-sdk"
);
}
}
124 changes: 32 additions & 92 deletions src/mastra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ import { telephoneGameWorkflow } from './workflows/telephone-game';
import { weatherWorkflow } from './workflows/weather-workflow';
import { repoIngestionWorkflow } from './workflows/repo-ingestion-workflow';
import { specGenerationWorkflow } from './workflows/spec-generation-workflow';

import { ResearchRuntimeContext } from './agents/index';
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

This import appears unrelated to the PR purpose and seems to be unused. The ResearchRuntimeContext import from './agents/index' should be removed unless it's being used elsewhere in this file.

Suggested change
import { ResearchRuntimeContext } from './agents/index';

Copilot uses AI. Check for mistakes.
import { metadata } from '../../app/docs/layout';
Comment on lines +89 to +90
Copy link

Choose a reason for hiding this comment

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

syntax: unused imports - ResearchRuntimeContext and metadata are imported but never used

Suggested change
import { ResearchRuntimeContext } from './agents/index';
import { metadata } from '../../app/docs/layout';
import { specGenerationWorkflow } from './workflows/spec-generation-workflow';
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/mastra/index.ts
Line: 89:90

Comment:
**syntax:** unused imports - `ResearchRuntimeContext` and `metadata` are imported but never used

```suggestion
import { specGenerationWorkflow } from './workflows/spec-generation-workflow';
```

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

Comment on lines +89 to +90
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

These imports for ResearchRuntimeContext and metadata appear to be unused within the scope of this file's changes. To keep the codebase clean and avoid unnecessary dependencies, it's best to remove them if they are not needed.

Comment on lines +89 to +90
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:

#!/bin/bash
# Verify if ResearchRuntimeContext and metadata imports are used

echo "=== File content (focusing on imports and usage) ==="
# Show the imports first
head -95 src/mastra/index.ts | tail -10

echo -e "\n=== Searching for ResearchRuntimeContext usage (excluding import) ==="
rg -n "ResearchRuntimeContext" src/mastra/index.ts

echo -e "\n=== Searching for metadata variable usage (excluding import and object keys) ==="
rg -n "metadata" src/mastra/index.ts | head -30

Repository: ssdeanx/AgentStack

Length of output: 1017


Remove unused imports on lines 89-90.

The imports ResearchRuntimeContext and metadata are not used anywhere in this file. They should be removed to keep the codebase clean.

🤖 Prompt for AI Agents
In src/mastra/index.ts around lines 89-90, the imports "ResearchRuntimeContext"
and "metadata" are unused; remove these two named imports from the import
statements (or delete the whole import lines if they become empty) and save the
file so linters/formatters reflect the change; run the project linter/build to
confirm no remaining references.

Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

This import appears unrelated to the PR purpose and seems to be unused. The metadata import from '../../app/docs/layout' should be removed unless it's being used elsewhere in this file.

Suggested change
import { metadata } from '../../app/docs/layout';

Copilot uses AI. Check for mistakes.

export const mastra = new Mastra({
workflows: {
Expand Down Expand Up @@ -223,6 +224,36 @@ export const mastra = new Mastra({
},
server: {
apiRoutes: [
workflowRoute({
path: "/workflow/:workflowId",
includeTextStreamParts: true,
}),
networkRoute({
path: "/network/:agentId",
defaultOptions: {
memory: {
thread: {
id: 'network',
resourceId: 'network',
metadata: { agentId: ':agentId' }
},
resource: "network",
options: {
lastMessages: 500,
semanticRecall: true,
workingMemory: { enabled: true },
threads: { generateTitle: true }
}
},
Comment on lines +238 to +247
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): Network memory thread metadata and save-per-step behavior may not match the intended semantics.

Two specific checks for this networkRoute config:

  1. metadata: { agentId: ':agentId' } will persist the literal string ":agentId", not the route param value. If you plan to read agentId from metadata later, this likely needs to be the resolved param.
  2. The previous config had savePerStep: true in defaultOptions, but that’s now missing. If per‑step persistence is still required for network runs, please re‑add it; otherwise this is an intentional behavioral change that may affect any code assuming step‑level saves.

maxSteps: 200,
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Verify the high maxSteps value is intentional.

The maxSteps: 200 for the network route is 4x higher than the maxSteps: 50 used for chat routes. While networks may legitimately require more steps, this high value could impact API latency, resource consumption, and cost. Please verify this is intentional and consider documenting the rationale.

🤖 Prompt for AI Agents
In src/mastra/index.ts around line 248, the network route sets maxSteps: 200
which is much higher than the chat routes' maxSteps: 50; verify whether 200 is
intentional and either (A) if it is intentional, add an inline comment/docstring
near this setting explaining the rationale (why networks need 4x steps and the
expected trade-offs for latency/cost), or (B) if unintentional, reduce the value
to the intended threshold (e.g., 50 or a shared constant) and update any related
tests/configs to use the consistent maxSteps constant; ensure the final change
either documents the reason or consolidates the value into a shared constant for
clarity.

telemetry: {
isEnabled: true,
recordInputs: true,
recordOutputs: true,
},
includeRawChunks: true,
}
}),
Comment on lines +227 to +256
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

The workflow routes have been significantly reorganized and simplified in a way that appears unrelated to the PR's stated purpose of "refactoring tool imports and improving progress logging". The change from specific workflow paths (e.g., /workflow/weatherWorkflow) to a generic path pattern (/workflow/:workflowId) and the removal of workflow-specific route definitions is a major API design change that should be in a separate PR with proper discussion. This could break existing clients expecting the old routes.

Copilot uses AI. Check for mistakes.
chatRoute({
path: "/chat/:agentId",
defaultOptions: {
Expand Down Expand Up @@ -500,97 +531,6 @@ export const mastra = new Mastra({
sendReasoning: true,
sendSources: true,
}),
workflowRoute({
path: "/workflow/:agentId",
workflow: "specGenerationWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/weatherWorkflow",
workflow: "weatherWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/contentStudioWorkflow",
workflow: "contentStudioWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/contentlogWorkflow",
workflow: "changelogWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/contentReviewWorkflow",
workflow: "contentReviewWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/documentProcessingWorkflow",
workflow: "documentProcessingWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/financialReportWorkflow",
workflow: "financialReportWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/learningExtractionWorkflow",
workflow: "learningExtractionWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/researchSynthesisWorkflow",
workflow: "researchSynthesisWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/stockAnalysisWorkflow",
workflow: "stockAnalysisWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/telephoneGameWorkflow",
workflow: "telephoneGameWorkflow",
includeTextStreamParts: true,
}),
workflowRoute({
path: "/workflow/repoIngestionWorkflow",
workflow: "repoIngestionWorkflow",

}),
workflowRoute({
path: "/workflow/specGenerationWorkflow",
workflow: "specGenerationWorkflow",

}),
networkRoute({
path: "/network/:agentId",
defaultOptions: {
memory: {
thread: {
id: 'network',
resourceId: 'network',
},
resource: "network",
options: {
lastMessages: 500,
semanticRecall: true,
workingMemory: { enabled: true },
threads: { generateTitle: true }
}
},
maxSteps: 200,
telemetry: {
isEnabled: true,
recordInputs: true,
recordOutputs: true,
},
includeRawChunks: true,
savePerStep: true,
}
}),
],
// cors: {
// origin: ["*"], // Allow specific origins or '*' for all
Expand Down
25 changes: 13 additions & 12 deletions src/mastra/tools/alpha-vantage.tool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AISpanType, InternalSpans } from "@mastra/core/ai-tracing";
import { InferUITool, createTool } from "@mastra/core/tools";
import type { InferUITool} from "@mastra/core/tools";
import { createTool } from "@mastra/core/tools";
import { z } from "zod";

/**
Expand Down Expand Up @@ -63,11 +64,11 @@ export const alphaVantageCryptoTool = createTool({
tracingPolicy: { internal: InternalSpans.TOOL }
});

await writer?.write({ type: 'progress', data: { message: `📈 Fetching Alpha Vantage crypto data for ${context.symbol}/${context.market}` } });
await writer?.custom({ type: 'data-tool-progress', data: { message: `📈 Fetching Alpha Vantage crypto data for ${context.symbol}/${context.market}` } });
const apiKey = process.env.ALPHA_VANTAGE_API_KEY;

if (typeof apiKey !== "string" || apiKey.trim() === '') {
await writer?.write({ type: 'progress', data: { message: '❌ Missing ALPHA_VANTAGE_API_KEY' } });
await writer?.custom({ type: 'data-tool-progress', data: { message: '❌ Missing ALPHA_VANTAGE_API_KEY' } });
return {
data: null,
error: "ALPHA_VANTAGE_API_KEY environment variable is required"
Expand Down Expand Up @@ -95,7 +96,7 @@ export const alphaVantageCryptoTool = createTool({

const url = `https://www.alphavantage.co/query?${params.toString()}`;

await writer?.write({ type: 'progress', data: { message: '📡 Querying Alpha Vantage API...' } });
await writer?.custom({ type: 'data-tool-progress', data: { message: '📡 Querying Alpha Vantage API...' } });
const response = await fetch(url);

if (!response.ok) {
Expand Down Expand Up @@ -152,7 +153,7 @@ export const alphaVantageCryptoTool = createTool({
return null;
};

await writer?.write({ type: 'progress', data: { message: `✅ Crypto data ready for ${context.symbol}` } });
await writer?.custom({ type: 'data-tool-progress', data: { message: `✅ Crypto data ready for ${context.symbol}` } });
const result = {
data,
metadata: {
Expand All @@ -170,7 +171,7 @@ export const alphaVantageCryptoTool = createTool({

} catch (error) {
const errMsg = error instanceof Error ? error.message : "Unknown error occurred";
await writer?.write({ type: 'progress', data: { message: `❌ Crypto fetch error: ${errMsg}` } });
await writer?.custom({ type: 'data-tool-progress', data: { message: `❌ Crypto fetch error: ${errMsg}` } });
span?.error({ error: error instanceof Error ? error : new Error(errMsg), endSpan: true });
return {
data: null,
Expand Down Expand Up @@ -243,11 +244,11 @@ export const alphaVantageStockTool = createTool({
tracingPolicy: { internal: InternalSpans.TOOL }
});

await writer?.write({ type: 'progress', data: { message: `📈 Fetching Alpha Vantage stock data for ${context.symbol || 'symbol'}` } });
await writer?.custom({ type: 'data-tool-progress', data: { message: `📈 Fetching Alpha Vantage stock data for ${context.symbol || 'symbol'}` } });
const apiKey = process.env.ALPHA_VANTAGE_API_KEY;

if (typeof apiKey !== "string" || apiKey.trim() === '') {
await writer?.write({ type: 'progress', data: { message: '❌ Missing ALPHA_VANTAGE_API_KEY' } });
await writer?.custom({ type: 'data-tool-progress', data: { message: '❌ Missing ALPHA_VANTAGE_API_KEY' } });
return {
data: null,
error: "ALPHA_VANTAGE_API_KEY environment variable is required"
Expand Down Expand Up @@ -438,11 +439,11 @@ export const alphaVantageTool = createTool({
tracingPolicy: { internal: InternalSpans.TOOL }
});

await writer?.write({ type: 'data-tool-progress', data: { message: `💰 Fetching general Alpha Vantage data for ${context.function}` } });
await writer?.custom({ type: 'data-tool-progress', data: { message: `💰 Fetching general Alpha Vantage data for ${context.function}` } });
const apiKey = process.env.ALPHA_VANTAGE_API_KEY;

if (typeof apiKey !== "string" || apiKey.trim() === "") {
await writer?.write({ type: 'data-tool-progress', data: { message: '❌ Missing ALPHA_VANTAGE_API_KEY' } });
await writer?.custom({ type: 'data-tool-progress', data: { message: '❌ Missing ALPHA_VANTAGE_API_KEY' } });
return {
data: null,
error: "ALPHA_VANTAGE_API_KEY environment variable is required"
Expand Down Expand Up @@ -488,7 +489,7 @@ export const alphaVantageTool = createTool({
params.append("function", context.economic_indicator);
}

await writer?.write({ type: 'progress', data: { message: '📡 Querying Alpha Vantage API...' } });
await writer?.custom({ type: 'data-tool-progress', data: { message: '📡 Querying Alpha Vantage API...' } });

const url = `https://www.alphavantage.co/query?${params.toString()}`;

Expand Down Expand Up @@ -524,7 +525,7 @@ export const alphaVantageTool = createTool({

const metadataObj = metadata as unknown;

await writer?.write({ type: 'progress', data: { message: `✅ General data ready for ${context.function}` } });
await writer?.custom({ type: 'data-tool-progress', data: { message: `✅ General data ready for ${context.function}` } });

const result = {
data,
Expand Down
3 changes: 2 additions & 1 deletion src/mastra/tools/arxiv.tool.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { AISpanType, InternalSpans } from "@mastra/core/ai-tracing";
import { InferUITool, createTool } from "@mastra/core/tools";
import type { InferUITool} from "@mastra/core/tools";
import { createTool } from "@mastra/core/tools";
import { z } from "zod";

// In-memory counter to track tool calls per request
Expand Down
12 changes: 7 additions & 5 deletions src/mastra/tools/browser-tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
* Not working
*/
import { AISpanType, InternalSpans } from '@mastra/core/ai-tracing';
import { InferUITool, createTool } from "@mastra/core/tools";
import type { InferUITool} from "@mastra/core/tools";
import { createTool } from "@mastra/core/tools";
import { MDocument } from '@mastra/rag';
import { Browser, chromium } from 'playwright-core';
import type { Browser} from 'playwright-core';
import { chromium } from 'playwright-core';
import { z } from 'zod';
import { log } from '../config/logger';

// Browser instance cache for reuse
let browserInstance: Browser | null = null;

async function getBrowser(): Promise<Browser> {
if (!browserInstance || !browserInstance.isConnected()) {
if (!browserInstance?.isConnected()) {
browserInstance = await chromium.launch({
headless: true,
chromiumSandbox: false,
Expand Down Expand Up @@ -423,7 +425,7 @@ export const extractTablesTool = createTool({
bodyRows.forEach(row => {
const rowData: string[] = [];
row.querySelectorAll('td').forEach(cell => rowData.push(cell.textContent?.trim() ?? ''));
if (rowData.length > 0) rows.push(rowData);
if (rowData.length > 0) {rows.push(rowData);}
});

result.push({ headers, rows });
Expand Down Expand Up @@ -480,7 +482,7 @@ export const monitorPageTool = createTool({
const selector = context.selector ?? 'body';

await page.goto(context.url, { waitUntil: 'domcontentloaded' });
let previousContent = await page.$eval(selector, el => el.textContent ?? '');
const previousContent = await page.$eval(selector, el => el.textContent ?? '');
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

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

Changing previousContent from let to const is incorrect. This variable is reassigned later in the monitoring loop (line 494 or similar in the full code). Using const will cause a runtime error when attempting to reassign. Please revert this to let.

Copilot uses AI. Check for mistakes.

let checkCount = 0;
let changed = false;
Expand Down
Loading
Loading