Skip to content

fix: bundle bug & browser click flash #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 20, 2025
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
21 changes: 10 additions & 11 deletions apps/agent-tars/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const keepModules = new Set([
'@mixmark-io/domino',
'@modelcontextprotocol/sdk',
]);
const needSubDependencies = ['@modelcontextprotocol/sdk'];
const needSubDependencies = ['@tavily/core', '@modelcontextprotocol/sdk'];
const keepLanguages = new Set(['en', 'en_GB', 'en-US', 'en_US']);
const ignorePattern = new RegExp(
`^/node_modules/(?!${[...keepModules].join('|')})`,
Expand Down Expand Up @@ -95,13 +95,13 @@ async function cleanSources(
const moduleRoot = getModuleRoot(projectRoot, item);

if (fs.existsSync(moduleRoot)) {
console.log('copy_current_node_modules', moduleRoot);
// console.log('copy_current_node_modules', moduleRoot);
return cp(moduleRoot, path.join(buildPath, 'node_modules', item), {
recursive: true,
});
}
} catch (error) {
console.error('copy_current_node_modules', error);
console.error('copy_current_node_modules_error', error);
return;
}

Expand All @@ -116,21 +116,20 @@ async function cleanSources(
console.log('subDependencies', subDependencies);
await Promise.all(
subDependencies.map((subDependency) => {
console.log(
'target_dir',
path.join(buildPath, 'node_modules', subDependency.name),
);
const targetDir = path.join(
buildPath,
'node_modules',
subDependency.name,
);
const sourceDir = subDependency.path;
if (!fs.existsSync(targetDir) && fs.existsSync(sourceDir)) {
console.log('copy_current_node_modules', sourceDir);
return cp(sourceDir, targetDir, {
recursive: true,
});
try {
return cp(sourceDir, targetDir, {
recursive: true,
});
} catch (e) {
console.error('copy_current_node_modules_error', sourceDir, e);
}
}
return;
}),
Expand Down
4 changes: 2 additions & 2 deletions apps/agent-tars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
}
},
"dependencies": {
"@tavily/core": "0.3.1",
"@agent-infra/mcp-server-commands": "workspace:*",
"@agent-infra/mcp-server-filesystem": "workspace:*",
"@agent-infra/mcp-server-browser": "workspace:*",
"@tavily/core": "0.3.1"
"@agent-infra/mcp-server-browser": "workspace:*"
},
"devDependencies": {
"@modelcontextprotocol/sdk": "^1.7.0",
Expand Down
4 changes: 1 addition & 3 deletions apps/ui-tars/forge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,12 @@ async function cleanSources(
const moduleRoot = getModuleRoot(projectRoot, item);

if (fs.existsSync(moduleRoot)) {
console.log('copy_current_node_modules', moduleRoot);
return cp(moduleRoot, path.join(buildPath, 'node_modules', item), {
recursive: true,
});
}
} catch (error) {
console.error('copy_current_node_modules', error);
console.error('copy_current_node_modules_error', error);
return;
}

Expand All @@ -133,7 +132,6 @@ async function cleanSources(
}

if (fs.existsSync(subDependency.path)) {
console.log('copy_current_node_modules', subDependency.path);
return cp(
subDependency.path,
path.join(buildPath, 'node_modules', subDependency.name),
Expand Down
10 changes: 5 additions & 5 deletions packages/agent-infra/mcp-servers/browser/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,13 @@ const handleToolCall: Client['callTool'] = async ({
}

try {
let elementNode = selectorMap?.get(Number(args?.index));
const elementNode = selectorMap?.get(Number(args?.index));

if (elementNode?.highlightIndex !== undefined) {
await removeHighlights(page);
const { selectorMap: newSelectorMap } =
(await buildDomTree(page)) || {};
elementNode = newSelectorMap?.get(Number(args?.index));
// const { selectorMap: newSelectorMap } =
// (await buildDomTree(page)) || {};
// elementNode = newSelectorMap?.get(Number(args?.index));
}

const element = await locateElement(page, elementNode!);
Expand All @@ -641,7 +641,7 @@ const handleToolCall: Client['callTool'] = async ({
await Promise.race([
element.click(),
new Promise((_, reject) =>
setTimeout(() => reject(new Error('Click timeout')), 2000),
setTimeout(() => reject(new Error('Click timeout')), 10000),
),
]);
return {
Expand Down
28 changes: 21 additions & 7 deletions packages/common/electron-build/src/getPackageDependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,26 @@ import { dirname } from 'path';
import { findUpSync } from './findUp';

export const getModuleRoot = (cwd: string, pkgName: string): string => {
const moduleEntryPath = dirname(
require.resolve(`${pkgName}/package.json`, {
paths: [cwd || process.cwd()],
}),
);

let moduleEntryPath;
try {
moduleEntryPath = dirname(
require.resolve(`${pkgName}/package.json`, {
paths: [cwd || process.cwd()],
}),
);
} catch (error) {
moduleEntryPath = dirname(
require.resolve(pkgName, {
paths: [cwd || process.cwd()],
}),
);
console.warn(
'Failed to read package.json:',
error,
'new_entry_path',
moduleEntryPath,
);
}
let pkgPath = findUpSync('package.json', {
cwd: moduleEntryPath,
});
Expand Down Expand Up @@ -71,7 +85,7 @@ export async function getExternalPkgsDependencies(
for (const pkgName of pkgNames) {
try {
const moduleRoot = getModuleRoot(cwd, pkgName);
console.log('moduleRoot', moduleRoot);
// console.log('moduleRoot', moduleRoot);

const walker = new Walker(moduleRoot);
// These are private so it's quite nasty!
Expand Down