-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
54 lines (49 loc) · 1.25 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* 🤘 Welcome to Stagehand!
*
* You probably DON'T NEED TO BE IN THIS FILE
*
* You're probably instead looking for the main() function in main.ts
*
* This is run when you do npm run start; it just calls main()
*
*/
import { Stagehand } from "@browserbasehq/stagehand";
import StagehandConfig from "./stagehand.config.js";
import chalk from "chalk";
import { main } from "./main.js";
import boxen from "boxen";
async function run() {
const stagehand = new Stagehand({
...StagehandConfig,
});
await stagehand.init();
if (StagehandConfig.env === "BROWSERBASE" && stagehand.browserbaseSessionID) {
console.log(
boxen(
`View this session live in your browser: \n${chalk.blue(
`https://browserbase.com/sessions/${stagehand.browserbaseSessionID}`
)}`,
{
title: "Browserbase",
padding: 1,
margin: 3,
}
)
);
}
const page = stagehand.page;
const context = stagehand.context;
await main({
page,
context,
stagehand,
});
await stagehand.close();
console.log(
`\n🤘 Thanks for using Stagehand! Create an issue if you have any feedback: ${chalk.blue(
"https://github.com/browserbase/stagehand/issues/new"
)}\n`
);
}
run();