@aigne/example-mcp-sqlite 1.7.2 → 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/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
package/README.md CHANGED
@@ -111,7 +111,7 @@ The following example demonstrates how to interact with an SQLite database:
111
111
  ```typescript
112
112
  import assert from "node:assert";
113
113
  import { join } from "node:path";
114
- import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
114
+ import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
115
115
  import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
116
116
 
117
117
  const { OPENAI_API_KEY } = process.env;
@@ -126,9 +126,9 @@ const sqlite = await MCPAgent.from({
126
126
  args: ["-q", "mcp-server-sqlite", "--db-path", join(process.cwd(), "usages.db")],
127
127
  });
128
128
 
129
- const engine = new ExecutionEngine({
129
+ const aigne = new AIGNE({
130
130
  model,
131
- tools: [sqlite],
131
+ skills: [sqlite],
132
132
  });
133
133
 
134
134
  const agent = AIAgent.from({
@@ -136,26 +136,26 @@ const agent = AIAgent.from({
136
136
  });
137
137
 
138
138
  console.log(
139
- await engine.call(agent, "create a product table with columns name description and createdAt"),
139
+ await aigne.invoke(agent, "create a product table with columns name description and createdAt"),
140
140
  );
141
141
  // output:
142
142
  // {
143
143
  // $message: "The product table has been created successfully with the columns: `name`, `description`, and `createdAt`.",
144
144
  // }
145
145
 
146
- console.log(await engine.call(agent, "create 10 products for test"));
146
+ console.log(await aigne.invoke(agent, "create 10 products for test"));
147
147
  // output:
148
148
  // {
149
149
  // $message: "I have successfully created 10 test products in the database. Here are the products that were added:\n\n1. Product 1: $10.99 - Description for Product 1\n2. Product 2: $15.99 - Description for Product 2\n3. Product 3: $20.99 - Description for Product 3\n4. Product 4: $25.99 - Description for Product 4\n5. Product 5: $30.99 - Description for Product 5\n6. Product 6: $35.99 - Description for Product 6\n7. Product 7: $40.99 - Description for Product 7\n8. Product 8: $45.99 - Description for Product 8\n9. Product 9: $50.99 - Description for Product 9\n10. Product 10: $55.99 - Description for Product 10\n\nIf you need any further assistance or operations, feel free to ask!",
150
150
  // }
151
151
 
152
- console.log(await engine.call(agent, "how many products?"));
152
+ console.log(await aigne.invoke(agent, "how many products?"));
153
153
  // output:
154
154
  // {
155
155
  // $message: "There are 10 products in the database.",
156
156
  // }
157
157
 
158
- await engine.shutdown();
158
+ await aigne.shutdown();
159
159
  ```
160
160
 
161
161
  ## License
package/index.test.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { expect, test } from "bun:test";
2
+ import { runExampleTest } from "@aigne/test-utils/run-example-test.js";
3
+
4
+ test(
5
+ "should successfully run the mcp-sqlite",
6
+ async () => {
7
+ const { code } = await runExampleTest();
8
+ expect(code).toBe(0);
9
+ },
10
+ { timeout: 600000 },
11
+ );
package/index.ts CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import { join } from "node:path";
4
4
  import { runChatLoopInTerminal } from "@aigne/cli/utils/run-chat-loop.js";
5
- import { AIAgent, ExecutionEngine, MCPAgent, PromptBuilder } from "@aigne/core";
5
+ import { AIAgent, AIGNE, MCPAgent, PromptBuilder } from "@aigne/core";
6
6
  import { loadModel } from "@aigne/core/loader/index.js";
7
7
  import { logger } from "@aigne/core/utils/logger.js";
8
8
 
@@ -20,12 +20,12 @@ const sqlite = await MCPAgent.from({
20
20
  ],
21
21
  });
22
22
 
23
- const prompt = await sqlite.prompts["mcp-demo"]?.call({ topic: "product service" });
23
+ const prompt = await sqlite.prompts["mcp-demo"]?.invoke({ topic: "product service" });
24
24
  if (!prompt) throw new Error("Prompt mcp-demo not found");
25
25
 
26
- const engine = new ExecutionEngine({
26
+ const aigne = new AIGNE({
27
27
  model,
28
- tools: [sqlite],
28
+ skills: [sqlite],
29
29
  });
30
30
 
31
31
  const agent = AIAgent.from({
@@ -33,7 +33,7 @@ const agent = AIAgent.from({
33
33
  memory: true,
34
34
  });
35
35
 
36
- const userAgent = engine.call(agent);
36
+ const userAgent = aigne.invoke(agent);
37
37
 
38
38
  await runChatLoopInTerminal(userAgent, {
39
39
  initialCall: {},
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@aigne/example-mcp-sqlite",
3
- "version": "1.7.2",
3
+ "version": "1.9.0",
4
4
  "description": "A demonstration of using AIGNE Framework and Sqlite MCP Server to interact with a SQLite database",
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-sqlite",
7
- "license": "ISC",
7
+ "license": "MIT",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "git+https://github.com/AIGNE-io/aigne-framework"
@@ -18,11 +18,15 @@
18
18
  "dependencies": {
19
19
  "openai": "^4.94.0",
20
20
  "zod": "^3.24.2",
21
- "@aigne/cli": "^1.6.0",
22
- "@aigne/core": "^1.10.0"
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",
26
- "lint": "tsc --noEmit"
29
+ "lint": "tsc --noEmit",
30
+ "test:llm": "bun test"
27
31
  }
28
32
  }
package/usages.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import assert from "node:assert";
2
2
  import { join } from "node:path";
3
- import { AIAgent, ExecutionEngine, MCPAgent } from "@aigne/core";
3
+ import { AIAgent, AIGNE, MCPAgent } from "@aigne/core";
4
4
  import { OpenAIChatModel } from "@aigne/core/models/openai-chat-model.js";
5
5
 
6
6
  const { OPENAI_API_KEY } = process.env;
@@ -15,9 +15,9 @@ const sqlite = await MCPAgent.from({
15
15
  args: ["-q", "mcp-server-sqlite", "--db-path", join(process.cwd(), "usages.db")],
16
16
  });
17
17
 
18
- const engine = new ExecutionEngine({
18
+ const aigne = new AIGNE({
19
19
  model,
20
- tools: [sqlite],
20
+ skills: [sqlite],
21
21
  });
22
22
 
23
23
  const agent = AIAgent.from({
@@ -25,23 +25,23 @@ const agent = AIAgent.from({
25
25
  });
26
26
 
27
27
  console.log(
28
- await engine.call(agent, "create a product table with columns name description and createdAt"),
28
+ await aigne.invoke(agent, "create a product table with columns name description and createdAt"),
29
29
  );
30
30
  // output:
31
31
  // {
32
32
  // $message: "The product table has been created successfully with the columns: `name`, `description`, and `createdAt`.",
33
33
  // }
34
34
 
35
- console.log(await engine.call(agent, "create 10 products for test"));
35
+ console.log(await aigne.invoke(agent, "create 10 products for test"));
36
36
  // output:
37
37
  // {
38
38
  // $message: "I have successfully created 10 test products in the database. Here are the products that were added:\n\n1. Product 1: $10.99 - Description for Product 1\n2. Product 2: $15.99 - Description for Product 2\n3. Product 3: $20.99 - Description for Product 3\n4. Product 4: $25.99 - Description for Product 4\n5. Product 5: $30.99 - Description for Product 5\n6. Product 6: $35.99 - Description for Product 6\n7. Product 7: $40.99 - Description for Product 7\n8. Product 8: $45.99 - Description for Product 8\n9. Product 9: $50.99 - Description for Product 9\n10. Product 10: $55.99 - Description for Product 10\n\nIf you need any further assistance or operations, feel free to ask!",
39
39
  // }
40
40
 
41
- console.log(await engine.call(agent, "how many products?"));
41
+ console.log(await aigne.invoke(agent, "how many products?"));
42
42
  // output:
43
43
  // {
44
44
  // $message: "There are 10 products in the database.",
45
45
  // }
46
46
 
47
- await engine.shutdown();
47
+ await aigne.shutdown();