@aigne/example-mcp-puppeteer 1.4.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/index.ts +6 -11
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ AI ->> User: The content is as follows: ...
|
|
|
56
56
|
## Prerequisites
|
|
57
57
|
|
|
58
58
|
- [Node.js](https://nodejs.org) and npm installed on your machine
|
|
59
|
+
- [Bun](https://bun.sh) installed on your machine
|
|
59
60
|
- [OpenAI API key](https://platform.openai.com/api-keys) used to interact with OpenAI API
|
|
60
61
|
- [Pnpm](https://pnpm.io) [Optional] if you want to run the example from source code
|
|
61
62
|
|
package/index.ts
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env npx -y bun
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { AIAgent, ExecutionEngine, MCPAgent
|
|
5
|
-
import {
|
|
3
|
+
import { runChatLoopInTerminal } from "@aigne/cli/utils/run-chat-loop.js";
|
|
4
|
+
import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
|
|
5
|
+
import { loadModel } from "@aigne/core/loader/index.js";
|
|
6
6
|
import { logger } from "@aigne/core/utils/logger.js";
|
|
7
|
-
import { runChatLoopInTerminal } from "@aigne/core/utils/run-chat-loop.js";
|
|
8
|
-
|
|
9
|
-
const { OPENAI_API_KEY } = process.env;
|
|
10
|
-
assert(OPENAI_API_KEY, "Please set the OPENAI_API_KEY environment variable");
|
|
11
7
|
|
|
12
8
|
logger.enable(`aigne:mcp,${process.env.DEBUG}`);
|
|
13
9
|
|
|
14
|
-
const model =
|
|
15
|
-
apiKey: OPENAI_API_KEY,
|
|
16
|
-
});
|
|
10
|
+
const model = await loadModel();
|
|
17
11
|
|
|
18
12
|
const puppeteer = await MCPAgent.from({
|
|
19
13
|
command: "npx",
|
|
20
14
|
args: ["-y", "@modelcontextprotocol/server-puppeteer"],
|
|
15
|
+
env: process.env as Record<string, string>,
|
|
21
16
|
});
|
|
22
17
|
|
|
23
18
|
const engine = new ExecutionEngine({
|
|
@@ -26,6 +21,7 @@ const engine = new ExecutionEngine({
|
|
|
26
21
|
});
|
|
27
22
|
|
|
28
23
|
const agent = AIAgent.from({
|
|
24
|
+
name: "example_puppeteer",
|
|
29
25
|
instructions: `\
|
|
30
26
|
## Steps to extract content from a website
|
|
31
27
|
1. navigate to the url
|
|
@@ -40,7 +36,6 @@ await runChatLoopInTerminal(userAgent, {
|
|
|
40
36
|
welcome:
|
|
41
37
|
"Hello! I'm a chatbot that can extract content from a website. Try asking me a question!",
|
|
42
38
|
defaultQuestion: "What is the content of https://www.arcblock.io",
|
|
43
|
-
onResponse: (response) => console.log(getMessage(response)),
|
|
44
39
|
});
|
|
45
40
|
|
|
46
41
|
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-mcp-puppeteer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A demonstration of using AIGNE Framework and Puppeteer MCP Server to extract content from websites using Puppeteer",
|
|
5
5
|
"author": "Arcblock <blocklet@arcblock.io> https://github.com/blocklet",
|
|
6
6
|
"homepage": "https://github.com/AIGNE-io/aigne-framework/tree/main/examples/mcp-puppeteer",
|
|
@@ -16,12 +16,13 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"openai": "^4.
|
|
19
|
+
"openai": "^4.94.0",
|
|
20
20
|
"zod": "^3.24.2",
|
|
21
|
-
"@aigne/
|
|
21
|
+
"@aigne/cli": "^1.3.0",
|
|
22
|
+
"@aigne/core": "^1.8.0"
|
|
22
23
|
},
|
|
23
24
|
"scripts": {
|
|
24
|
-
"start": "
|
|
25
|
+
"start": "bun run index.ts",
|
|
25
26
|
"lint": "tsc --noEmit"
|
|
26
27
|
}
|
|
27
28
|
}
|