@elizaos/plugin-web-search 0.1.7-alpha.2 → 0.1.7
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/dist/index.d.ts +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +31 -17
- package/Readme.md +0 -180
- package/tsup.config.ts +0 -21
package/package.json
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
2
|
+
"name": "@elizaos/plugin-web-search",
|
|
3
|
+
"version": "0.1.7",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"import": {
|
|
12
|
+
"@elizaos/source": "./src/index.ts",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@elizaos/core": "0.1.7",
|
|
23
|
+
"tsup": "8.3.5"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup --format esm --dts",
|
|
27
|
+
"dev": "tsup --format esm --dts --watch"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"whatwg-url": "7.1.0"
|
|
31
|
+
},
|
|
32
|
+
"gitHead": "e15421524dde4f2778b529effb212eebea8c98b6"
|
|
19
33
|
}
|
package/Readme.md
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
# Plugin Web Search
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The Web Search Plugin enables powerful and customizable web search capabilities, offering flexibility and ease of integration for modern applications.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
- Efficient search query handling.
|
|
10
|
-
- Configurable options for advanced customization.
|
|
11
|
-
- Optimized for performance and scalability.
|
|
12
|
-
|
|
13
|
-
## Handlers
|
|
14
|
-
|
|
15
|
-
### `search`
|
|
16
|
-
|
|
17
|
-
The `search` handler executes web search queries with specified parameters, returning results in a structured format.
|
|
18
|
-
|
|
19
|
-
#### Usage
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
import { WebSearch } from 'web-search-plugin';
|
|
23
|
-
|
|
24
|
-
const search = new WebSearch({
|
|
25
|
-
apiEndpoint: 'https://api.example.com/search',
|
|
26
|
-
timeout: 5000,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
const results = await search.query('example query', {
|
|
31
|
-
limit: 10,
|
|
32
|
-
sortBy: 'relevance',
|
|
33
|
-
});
|
|
34
|
-
console.log('Search Results:', results);
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error('Search failed:', error);
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
#### Features
|
|
41
|
-
|
|
42
|
-
- **Query Customization**: Specify query parameters such as `limit` and `sortBy`.
|
|
43
|
-
- **Error Handling**: Handles common search errors gracefully.
|
|
44
|
-
|
|
45
|
-
## Configuration
|
|
46
|
-
|
|
47
|
-
### Environment Variables
|
|
48
|
-
|
|
49
|
-
Set the following environment variables for optimal performance:
|
|
50
|
-
|
|
51
|
-
| Variable Name | Description |
|
|
52
|
-
| ---------------- | --------------------------------- |
|
|
53
|
-
| `API_ENDPOINT` | URL for the search API endpoint. |
|
|
54
|
-
| `SEARCH_TIMEOUT` | Timeout duration in milliseconds. |
|
|
55
|
-
|
|
56
|
-
Example `.env` file:
|
|
57
|
-
|
|
58
|
-
```env
|
|
59
|
-
API_ENDPOINT=https://api.example.com/search
|
|
60
|
-
SEARCH_TIMEOUT=5000
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### TypeScript Configuration
|
|
64
|
-
|
|
65
|
-
Ensure your `tsconfig.json` is properly configured:
|
|
66
|
-
|
|
67
|
-
```json
|
|
68
|
-
{
|
|
69
|
-
"compilerOptions": {
|
|
70
|
-
"target": "ESNext",
|
|
71
|
-
"module": "CommonJS",
|
|
72
|
-
"strict": true,
|
|
73
|
-
"esModuleInterop": true,
|
|
74
|
-
"skipLibCheck": true
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Example Workflow
|
|
80
|
-
|
|
81
|
-
Streamline your search operations with the following example:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import { WebSearch } from 'web-search-plugin';
|
|
85
|
-
|
|
86
|
-
const search = new WebSearch({ apiEndpoint: 'https://api.example.com/search' });
|
|
87
|
-
|
|
88
|
-
(async () => {
|
|
89
|
-
try {
|
|
90
|
-
// Execute a search query
|
|
91
|
-
const results = await search.query('example', { limit: 5 });
|
|
92
|
-
console.log('Search Results:', results);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.error('Error executing search:', error);
|
|
95
|
-
}
|
|
96
|
-
})();
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Local Testing
|
|
100
|
-
|
|
101
|
-
To test locally, you can set up a mock server for the API endpoint:
|
|
102
|
-
|
|
103
|
-
1. Install `json-server`:
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
npm install -g json-server
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
2. Create a `db.json` file with mock search data.
|
|
110
|
-
|
|
111
|
-
3. Start the mock server:
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
json-server --watch db.json --port 3000
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
4. Update your `.env` file:
|
|
118
|
-
```env
|
|
119
|
-
API_ENDPOINT=http://localhost:3000
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Common Issues
|
|
123
|
-
|
|
124
|
-
### "API endpoint not defined"
|
|
125
|
-
|
|
126
|
-
- Ensure the `API_ENDPOINT` is set in your environment variables.
|
|
127
|
-
|
|
128
|
-
### "Search query timeout"
|
|
129
|
-
|
|
130
|
-
- Increase the `SEARCH_TIMEOUT` value in the configuration.
|
|
131
|
-
|
|
132
|
-
## Dependencies
|
|
133
|
-
|
|
134
|
-
This plugin relies on the following:
|
|
135
|
-
|
|
136
|
-
- `axios` for HTTP requests.
|
|
137
|
-
- `dotenv` for managing environment variables.
|
|
138
|
-
|
|
139
|
-
## Development Guide
|
|
140
|
-
|
|
141
|
-
### Setup
|
|
142
|
-
|
|
143
|
-
1. Clone the repository:
|
|
144
|
-
|
|
145
|
-
```bash
|
|
146
|
-
git clone https://github.com/your-repo/web-search-plugin.git
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
2. Install dependencies:
|
|
150
|
-
```bash
|
|
151
|
-
npm install
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### Testing
|
|
155
|
-
|
|
156
|
-
Run tests with:
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
npm test
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### Contribution Guidelines
|
|
163
|
-
|
|
164
|
-
- Fork the repository.
|
|
165
|
-
- Create a feature branch.
|
|
166
|
-
- Submit a pull request with a clear description.
|
|
167
|
-
|
|
168
|
-
### Security Best Practices
|
|
169
|
-
|
|
170
|
-
- Validate user inputs to prevent injection attacks.
|
|
171
|
-
- Use HTTPS for secure API communication.
|
|
172
|
-
|
|
173
|
-
## Performance Optimization
|
|
174
|
-
|
|
175
|
-
- Use caching for frequently queried terms.
|
|
176
|
-
- Optimize query parameters for faster responses.
|
|
177
|
-
|
|
178
|
-
---
|
|
179
|
-
|
|
180
|
-
This documentation aims to streamline onboarding, reduce support queries, and enable faster adoption of the Web Search Plugin.
|
package/tsup.config.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from "tsup";
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
entry: ["src/index.ts"],
|
|
5
|
-
outDir: "dist",
|
|
6
|
-
sourcemap: true,
|
|
7
|
-
clean: true,
|
|
8
|
-
format: ["esm"], // Ensure you're targeting CommonJS
|
|
9
|
-
external: [
|
|
10
|
-
"dotenv", // Externalize dotenv to prevent bundling
|
|
11
|
-
"fs", // Externalize fs to use Node.js built-in module
|
|
12
|
-
"path", // Externalize other built-ins if necessary
|
|
13
|
-
"@reflink/reflink",
|
|
14
|
-
"@node-llama-cpp",
|
|
15
|
-
"https",
|
|
16
|
-
"http",
|
|
17
|
-
"agentkeepalive",
|
|
18
|
-
"zod",
|
|
19
|
-
// Add other modules you want to externalize
|
|
20
|
-
],
|
|
21
|
-
});
|