@aigne/example-mcp-puppeteer 1.8.0 → 1.9.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 +5 -5
- package/index.test.ts +10 -4
- package/index.ts +4 -4
- package/package.json +6 -3
- package/usages.ts +5 -5
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ The following example demonstrates how to extract content from a website:
|
|
|
105
105
|
|
|
106
106
|
```typescript
|
|
107
107
|
import assert from "node:assert";
|
|
108
|
-
import { AIAgent,
|
|
108
|
+
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
109
109
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
110
110
|
|
|
111
111
|
const { OPENAI_API_KEY } = process.env;
|
|
@@ -120,9 +120,9 @@ const puppeteerMCPAgent = await MCPAgent.from({
|
|
|
120
120
|
args: ["-y", "@modelcontextprotocol/server-puppeteer"],
|
|
121
121
|
});
|
|
122
122
|
|
|
123
|
-
const
|
|
123
|
+
const aigne = new AIGNE({
|
|
124
124
|
model,
|
|
125
|
-
|
|
125
|
+
skills: [puppeteerMCPAgent],
|
|
126
126
|
});
|
|
127
127
|
|
|
128
128
|
const agent = AIAgent.from({
|
|
@@ -133,7 +133,7 @@ const agent = AIAgent.from({
|
|
|
133
133
|
`,
|
|
134
134
|
});
|
|
135
135
|
|
|
136
|
-
const result = await
|
|
136
|
+
const result = await aigne.invoke(agent, "extract content from https://www.arcblock.io");
|
|
137
137
|
|
|
138
138
|
console.log(result);
|
|
139
139
|
// output:
|
|
@@ -141,7 +141,7 @@ console.log(result);
|
|
|
141
141
|
// $message: "The content extracted from the website [ArcBlock](https://www.arcblock.io) is as follows:\n\n---\n\n**Redefining Software Architect and Ecosystems**\n\nA total solution for building decentralized applications ...",
|
|
142
142
|
// }
|
|
143
143
|
|
|
144
|
-
await
|
|
144
|
+
await aigne.shutdown();
|
|
145
145
|
```
|
|
146
146
|
|
|
147
147
|
## License
|
package/index.test.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { test } from "bun:test";
|
|
1
|
+
import { expect, test } from "bun:test";
|
|
2
|
+
import { runExampleTest } from "@aigne/test-utils/run-example-test.js";
|
|
2
3
|
|
|
3
|
-
test(
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
test(
|
|
5
|
+
"should successfully run the mcp-puppeteer",
|
|
6
|
+
async () => {
|
|
7
|
+
const { code } = await runExampleTest();
|
|
8
|
+
expect(code).toBe(0);
|
|
9
|
+
},
|
|
10
|
+
{ timeout: 600000 },
|
|
11
|
+
);
|
package/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bunwrapper
|
|
2
2
|
|
|
3
3
|
import { runChatLoopInTerminal } from "@aigne/cli/utils/run-chat-loop.js";
|
|
4
|
-
import { AIAgent,
|
|
4
|
+
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
5
5
|
import { loadModel } from "@aigne/core/loader/index.js";
|
|
6
6
|
import { logger } from "@aigne/core/utils/logger.js";
|
|
7
7
|
|
|
@@ -15,9 +15,9 @@ const puppeteer = await MCPAgent.from({
|
|
|
15
15
|
env: process.env as Record<string, string>,
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
const
|
|
18
|
+
const aigne = new AIGNE({
|
|
19
19
|
model,
|
|
20
|
-
|
|
20
|
+
skills: [puppeteer],
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
const agent = AIAgent.from({
|
|
@@ -30,7 +30,7 @@ const agent = AIAgent.from({
|
|
|
30
30
|
memory: true,
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
const userAgent =
|
|
33
|
+
const userAgent = aigne.invoke(agent);
|
|
34
34
|
|
|
35
35
|
await runChatLoopInTerminal(userAgent, {
|
|
36
36
|
welcome:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aigne/example-mcp-puppeteer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.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",
|
|
@@ -18,8 +18,11 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"openai": "^4.94.0",
|
|
20
20
|
"zod": "^3.24.2",
|
|
21
|
-
"@aigne/cli": "^1.
|
|
22
|
-
"@aigne/core": "^1.
|
|
21
|
+
"@aigne/cli": "^1.8.0",
|
|
22
|
+
"@aigne/core": "^1.12.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@aigne/test-utils": "^0.1.0"
|
|
23
26
|
},
|
|
24
27
|
"scripts": {
|
|
25
28
|
"start": "bun run index.ts",
|
package/usages.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import assert from "node:assert";
|
|
2
|
-
import { AIAgent,
|
|
2
|
+
import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
|
|
3
3
|
import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
|
|
4
4
|
|
|
5
5
|
const { OPENAI_API_KEY } = process.env;
|
|
@@ -14,9 +14,9 @@ const puppeteerMCPAgent = await MCPAgent.from({
|
|
|
14
14
|
args: ["-y", "@modelcontextprotocol/server-puppeteer"],
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const aigne = new AIGNE({
|
|
18
18
|
model,
|
|
19
|
-
|
|
19
|
+
skills: [puppeteerMCPAgent],
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
const agent = AIAgent.from({
|
|
@@ -27,7 +27,7 @@ const agent = AIAgent.from({
|
|
|
27
27
|
`,
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
const result = await
|
|
30
|
+
const result = await aigne.invoke(agent, "extract content from https://www.arcblock.io");
|
|
31
31
|
|
|
32
32
|
console.log(result);
|
|
33
33
|
// output:
|
|
@@ -35,4 +35,4 @@ console.log(result);
|
|
|
35
35
|
// $message: "The content extracted from the website [ArcBlock](https://www.arcblock.io) is as follows:\n\n---\n\n**Redefining Software Architect and Ecosystems**\n\nA total solution for building decentralized applications ...",
|
|
36
36
|
// }
|
|
37
37
|
|
|
38
|
-
await
|
|
38
|
+
await aigne.shutdown();
|