Skip to content

Commit 988b8a4

Browse files
feat: increment version to 0.1.4 and formating
1 parent 8dc9cff commit 988b8a4

15 files changed

+116
-132
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@auto-browse/auto-browse",
3-
"version": "0.1.3",
3+
"version": "0.1.4",
44
"description": "AI-powered browser automation",
55
"author": "auto-browse",
66
"homepage": "https://www.auto-browse.com/",

src/llm.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ export function createLLMModel() {
1212
const provider = process.env.LLM_PROVIDER || 'openai';
1313
const model = process.env.AUTOBROWSE_LLM_MODEL || 'gpt-4o-mini';
1414

15-
if (provider === 'google')
16-
{
15+
if (provider === 'google') {
1716
return new ChatGoogleGenerativeAI({
1817
model: model,
1918
});
2019
}
2120

22-
if (provider === 'azure')
23-
{
21+
if (provider === 'azure') {
2422
return new AzureChatOpenAI({
2523
temperature: 0,
2624
maxRetries: 2,
@@ -32,24 +30,21 @@ export function createLLMModel() {
3230
});
3331
}
3432

35-
if (provider === 'anthropic')
36-
{
33+
if (provider === 'anthropic') {
3734
return new ChatAnthropic({
3835
model: model,
3936
temperature: 0,
4037
anthropicApiKey: process.env.ANTHROPIC_API_KEY,
4138
});
4239
}
4340

44-
if (provider === 'vertex')
45-
{
41+
if (provider === 'vertex') {
4642
return new ChatVertexAI({
4743
model: model,
4844
temperature: 0,
4945
});
5046
}
51-
if (provider === 'ollama')
52-
{
47+
if (provider === 'ollama') {
5348
return new ChatOllama({
5449
model: model,
5550
temperature: 0,

src/tools/browser_click.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ const clickSchema = z.object({
1818

1919
export const browser_click = tool(
2020
async ({ element, ref }) => {
21-
try
22-
{
21+
try {
2322
console.log(`[Click Tool] Starting operation:`, { element, ref });
2423
const result = await test.step(`Click "${element}"`, async () => {
2524
return await runAndWait(
@@ -32,10 +31,12 @@ export const browser_click = tool(
3231
true,
3332
);
3433
});
35-
console.log(`[Click Tool] Operation completed with result:`, result);
34+
console.log(
35+
`[Click Tool] Operation completed with result:`,
36+
result,
37+
);
3638
return result;
37-
} catch (error)
38-
{
39+
} catch (error) {
3940
const errorMessage = `Failed to click: ${error instanceof Error ? error.message : 'Unknown error'}`;
4041
console.error(`[Click Tool] Error:`, errorMessage);
4142
return errorMessage;

src/tools/browser_drag.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,31 @@ const dragSchema = z.object({
3232

3333
export const browser_drag = tool(
3434
async ({ startElement, startRef, endElement, endRef }) => {
35-
try
36-
{
35+
try {
3736
console.log(`[Drag Tool] Starting operation:`, {
3837
startElement,
3938
startRef,
4039
endElement,
4140
endRef,
4241
});
4342

44-
const result = await test.step(`Drag "${startElement}" to "${endElement}"`, async () => {
45-
return await runAndWait(
46-
context,
47-
`Dragged "${startElement}" to "${endElement}"`,
48-
async () => {
49-
const startLocator = context.refLocator(startRef);
50-
const endLocator = context.refLocator(endRef);
51-
await startLocator.dragTo(endLocator);
52-
},
53-
true,
54-
);
55-
});
43+
const result =
44+
await test.step(`Drag "${startElement}" to "${endElement}"`, async () => {
45+
return await runAndWait(
46+
context,
47+
`Dragged "${startElement}" to "${endElement}"`,
48+
async () => {
49+
const startLocator = context.refLocator(startRef);
50+
const endLocator = context.refLocator(endRef);
51+
await startLocator.dragTo(endLocator);
52+
},
53+
true,
54+
);
55+
});
5656

5757
console.log(`[Drag Tool] Operation completed with result:`, result);
5858
return result;
59-
} catch (error)
60-
{
59+
} catch (error) {
6160
const errorMessage = `Failed to drag: ${error instanceof Error ? error.message : 'Unknown error'}`;
6261
console.error(`[Drag Tool] Error:`, errorMessage);
6362
return errorMessage;

src/tools/browser_get_text.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,32 @@ const getTextSchema = z.object({
1818

1919
export const browser_get_text = tool(
2020
async ({ element, ref }) => {
21-
try
22-
{
21+
try {
2322
console.log(`[Get Text Tool] Starting operation:`, {
2423
element,
2524
ref,
2625
});
2726

28-
const result = await test.step(`Get text from "${element}"`, async () => {
29-
return await runAndWait(
30-
context,
31-
`Got text from "${element}"`,
32-
async () => {
33-
const locator = context.refLocator(ref);
34-
const text = (await locator.innerText()) || '';
35-
return text;
36-
},
37-
false,
38-
);
39-
});
27+
const result =
28+
await test.step(`Get text from "${element}"`, async () => {
29+
return await runAndWait(
30+
context,
31+
`Got text from "${element}"`,
32+
async () => {
33+
const locator = context.refLocator(ref);
34+
const text = (await locator.innerText()) || '';
35+
return text;
36+
},
37+
false,
38+
);
39+
});
4040

4141
console.log(
4242
`[Get Text Tool] Operation completed with result:`,
4343
result,
4444
);
4545
return result;
46-
} catch (error)
47-
{
46+
} catch (error) {
4847
const errorMessage = `Failed to get text: ${error instanceof Error ? error.message : 'Unknown error'}`;
4948
console.error(`[Get Text Tool] Error:`, errorMessage);
5049
return errorMessage;

src/tools/browser_go_back.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const goBackSchema = z.object({
1717

1818
export const browser_go_back = tool(
1919
async () => {
20-
try
21-
{
20+
try {
2221
console.log(`[Go Back Tool] Starting operation`);
2322

2423
const result = await test.step(`Go Back`, async () => {
@@ -34,8 +33,7 @@ export const browser_go_back = tool(
3433

3534
console.log(`[Go Back Tool] Operation completed`);
3635
return result;
37-
} catch (error)
38-
{
36+
} catch (error) {
3937
const errorMessage = `Failed to go back: ${error instanceof Error ? error.message : 'Unknown error'}`;
4038
console.error(`[Go Back Tool] Error:`, errorMessage);
4139
return errorMessage;

src/tools/browser_go_forward.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const goForwardSchema = z.object({
1717

1818
export const browser_go_forward = tool(
1919
async () => {
20-
try
21-
{
20+
try {
2221
console.log(`[Go Forward Tool] Starting operation`);
2322

2423
const result = await test.step(`Go Forward`, async () => {
@@ -34,8 +33,7 @@ export const browser_go_forward = tool(
3433

3534
console.log(`[Go Forward Tool] Operation completed`);
3635
return result;
37-
} catch (error)
38-
{
36+
} catch (error) {
3937
const errorMessage = `Failed to go forward: ${error instanceof Error ? error.message : 'Unknown error'}`;
4038
console.error(`[Go Forward Tool] Error:`, errorMessage);
4139
return errorMessage;

src/tools/browser_hover.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,26 @@ const hoverSchema = z.object({
1818

1919
export const browser_hover = tool(
2020
async ({ element, ref }) => {
21-
try
22-
{
21+
try {
2322
console.log(`[Hover Tool] Starting operation:`, { element, ref });
24-
const result = await test.step(`Hover over "${element}"`, async () => {
25-
return await runAndWait(
26-
context,
27-
`Hovered over "${element}"`,
28-
async () => {
29-
const locator = context.refLocator(ref);
30-
await locator.hover();
31-
},
32-
true,
33-
);
34-
});
23+
const result =
24+
await test.step(`Hover over "${element}"`, async () => {
25+
return await runAndWait(
26+
context,
27+
`Hovered over "${element}"`,
28+
async () => {
29+
const locator = context.refLocator(ref);
30+
await locator.hover();
31+
},
32+
true,
33+
);
34+
});
3535
console.log(
3636
`[Hover Tool] Operation completed with result:`,
3737
result,
3838
);
3939
return result;
40-
} catch (error)
41-
{
40+
} catch (error) {
4241
const errorMessage = `Failed to hover: ${error instanceof Error ? error.message : 'Unknown error'}`;
4342
console.error(`[Hover Tool] Error:`, errorMessage);
4443
return errorMessage;

src/tools/browser_navigate.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ const navigateSchema = z.object({
1010

1111
export const browser_navigate = tool(
1212
async ({ url }) => {
13-
try
14-
{
13+
try {
1514
console.log(`[Navigate Tool] Starting operation:`, { url });
1615
const result = await test.step(`Go to "${url}"`, async () => {
1716
return await runAndWait(
@@ -20,15 +19,16 @@ export const browser_navigate = tool(
2019
async (page) => {
2120
await page.goto(url, { waitUntil: 'domcontentloaded' });
2221
// Cap load event to 5 seconds, the page is operational at this point
23-
await page.waitForLoadState('load', { timeout: 5000 }).catch(() => { });
22+
await page
23+
.waitForLoadState('load', { timeout: 5000 })
24+
.catch(() => {});
2425
},
2526
true,
2627
);
2728
});
2829
console.log(`[Navigate Tool] Operation completed`);
2930
return result;
30-
} catch (error)
31-
{
31+
} catch (error) {
3232
const errorMessage = `Failed to navigate: ${error instanceof Error ? error.message : 'Unknown error'}`;
3333
console.error(`[Navigate Tool] Error:`, errorMessage);
3434
return errorMessage;
@@ -39,4 +39,4 @@ export const browser_navigate = tool(
3939
description: 'Navigate to a URL using Playwright',
4040
schema: navigateSchema,
4141
},
42-
);
42+
);

src/tools/browser_press_key.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ const pressKeySchema = z.object({
1717

1818
export const browser_press_key = tool(
1919
async ({ key }) => {
20-
try
21-
{
20+
try {
2221
console.log(`[Press Key Tool] Starting operation:`, { key });
2322
const result = await test.step(`Press key ${key}`, async () => {
2423
return await runAndWait(
@@ -32,8 +31,7 @@ export const browser_press_key = tool(
3231
});
3332
console.log(`[Press Key Tool] Operation completed`);
3433
return result;
35-
} catch (error)
36-
{
34+
} catch (error) {
3735
const errorMessage = `Failed to press key: ${error instanceof Error ? error.message : 'Unknown error'}`;
3836
console.error(`[Press Key Tool] Error:`, errorMessage);
3937
return errorMessage;

0 commit comments

Comments
 (0)