@elizaos/plugin-knowledge 1.0.1 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +186 -1
  2. package/package.json +157 -2
package/README.md CHANGED
@@ -197,9 +197,194 @@ The document processing flow follows these steps regardless of database type:
197
197
  - Rate limiting to respect provider limitations
198
198
  - Support for multiple LLM providers
199
199
 
200
+ ## API Routes
201
+
202
+ The Knowledge plugin provides a comprehensive REST API for managing knowledge documents. All routes are prefixed with `/api/agents/{agentId}/plugins/knowledge`.
203
+
204
+ ### Knowledge Panel UI
205
+
206
+ #### GET `/display`
207
+ Access the web-based knowledge management interface.
208
+
209
+ - **URL**: `/api/agents/{agentId}/plugins/knowledge/display`
210
+ - **Method**: GET
211
+ - **Public**: Yes
212
+ - **Description**: Serves the HTML frontend for managing knowledge documents
213
+ - **Response**: HTML page with embedded configuration
214
+
215
+ ### Document Management
216
+
217
+ #### POST `/documents` - Upload Knowledge
218
+ Upload files or URLs to create knowledge documents.
219
+
220
+ **File Upload:**
221
+ ```bash
222
+ curl -X POST \
223
+ "/api/agents/{agentId}/plugins/knowledge/documents" \
224
+ -H "Content-Type: multipart/form-data" \
225
+ -F "files=@document.pdf" \
226
+ -F "documentId=optional-custom-id" \
227
+ -F "worldId=optional-world-id"
228
+ ```
229
+
230
+ **URL Upload:**
231
+ ```bash
232
+ curl -X POST \
233
+ "/api/agents/{agentId}/plugins/knowledge/documents" \
234
+ -H "Content-Type: application/json" \
235
+ -d '{
236
+ "fileUrls": ["https://example.com/document.pdf"],
237
+ "worldId": "optional-world-id"
238
+ }'
239
+ ```
240
+
241
+ **Request Parameters:**
242
+ - `files`: File(s) to upload (multipart)
243
+ - `fileUrl` or `fileUrls`: URL(s) to fetch content from (JSON)
244
+ - `documentId` or `documentIds`: Optional custom document IDs
245
+ - `worldId`: Optional world ID for scoping
246
+
247
+ **Response:**
248
+ ```json
249
+ {
250
+ "success": true,
251
+ "data": [
252
+ {
253
+ "id": "document-uuid",
254
+ "filename": "document.pdf",
255
+ "status": "success",
256
+ "fragmentCount": 15,
257
+ "createdAt": 1703123456789
258
+ }
259
+ ]
260
+ }
261
+ ```
262
+
263
+ **Supported File Types:**
264
+ - **Documents**: PDF, DOC, DOCX
265
+ - **Text**: TXT, MD, HTML, JSON, XML, YAML
266
+ - **Code**: JS, TS, PY, JAVA, C, CPP, CS, PHP, RB, GO, RS, and more
267
+ - **Config**: INI, CFG, CONF, ENV
268
+ - **Data**: CSV, TSV, LOG
269
+
270
+ #### GET `/documents` - List Documents
271
+ Retrieve all knowledge documents.
272
+
273
+ ```bash
274
+ curl "/api/agents/{agentId}/plugins/knowledge/documents?limit=20&before=1703123456789&includeEmbedding=false"
275
+ ```
276
+
277
+ **Query Parameters:**
278
+ - `limit`: Number of documents to return (default: 20)
279
+ - `before`: Timestamp for pagination (default: current time)
280
+ - `includeEmbedding`: Include embedding data (default: false)
281
+ - `fileUrls`: Filter by specific URLs (comma-separated)
282
+
283
+ **Response:**
284
+ ```json
285
+ {
286
+ "success": true,
287
+ "data": {
288
+ "memories": [
289
+ {
290
+ "id": "document-uuid",
291
+ "content": { "text": "..." },
292
+ "metadata": {
293
+ "type": "document",
294
+ "title": "Document Title",
295
+ "filename": "document.pdf",
296
+ "fileType": "application/pdf",
297
+ "fileSize": 1024,
298
+ "timestamp": 1703123456789,
299
+ "source": "upload"
300
+ },
301
+ "createdAt": 1703123456789
302
+ }
303
+ ],
304
+ "urlFiltered": false,
305
+ "totalFound": 1,
306
+ "totalRequested": 0
307
+ }
308
+ }
309
+ ```
310
+
311
+ #### GET `/documents/:knowledgeId` - Get Specific Document
312
+ Retrieve a specific knowledge document by ID.
313
+
314
+ ```bash
315
+ curl "/api/agents/{agentId}/plugins/knowledge/documents/{documentId}"
316
+ ```
317
+
318
+ **Response:**
319
+ ```json
320
+ {
321
+ "success": true,
322
+ "data": {
323
+ "document": {
324
+ "id": "document-uuid",
325
+ "content": { "text": "..." },
326
+ "metadata": { "..." },
327
+ "createdAt": 1703123456789
328
+ }
329
+ }
330
+ }
331
+ ```
332
+
333
+ #### DELETE `/documents/:knowledgeId` - Delete Document
334
+ Delete a knowledge document and all its fragments.
335
+
336
+ ```bash
337
+ curl -X DELETE "/api/agents/{agentId}/plugins/knowledge/documents/{documentId}"
338
+ ```
339
+
340
+ **Response:**
341
+ ```json
342
+ {
343
+ "success": true,
344
+ "data": null
345
+ }
346
+ ```
347
+
348
+ ### Knowledge Fragments
349
+
350
+ #### GET `/knowledges` - List Knowledge Chunks
351
+ Retrieve knowledge fragments/chunks for detailed analysis or graph view.
352
+
353
+ ```bash
354
+ curl "/api/agents/{agentId}/plugins/knowledge/knowledges?limit=100&documentId=optional-filter"
355
+ ```
356
+
357
+ **Query Parameters:**
358
+ - `limit`: Number of chunks to return (default: 100)
359
+ - `before`: Timestamp for pagination (default: current time)
360
+ - `documentId`: Filter chunks by parent document ID
361
+
362
+ **Response:**
363
+ ```json
364
+ {
365
+ "success": true,
366
+ "data": {
367
+ "chunks": [
368
+ {
369
+ "id": "fragment-uuid",
370
+ "content": { "text": "chunk content..." },
371
+ "metadata": {
372
+ "type": "fragment",
373
+ "documentId": "parent-document-uuid",
374
+ "position": 0,
375
+ "timestamp": 1703123456789
376
+ },
377
+ "embedding": [0.1, 0.2, ...], // If included
378
+ "createdAt": 1703123456789
379
+ }
380
+ ]
381
+ }
382
+ }
383
+ ```
384
+
200
385
  ## Usage
201
386
 
202
- ### Basic Usage
387
+ ### Programmatic Usage
203
388
 
204
389
  ```typescript
205
390
  import { KnowledgeService } from '@elizaos/plugin-knowledge';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elizaos/plugin-knowledge",
3
3
  "description": "Plugin for Knowledge",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -74,5 +74,160 @@
74
74
  "resolutions": {
75
75
  "zod": "3.25.23"
76
76
  },
77
- "gitHead": "b165ad83e5f7a21bc1edbd83374ca087e3cd6b33"
77
+ "gitHead": "b165ad83e5f7a21bc1edbd83374ca087e3cd6b33",
78
+ "agentConfig": {
79
+ "pluginType": "elizaos:plugin:1.0.0",
80
+ "pluginParameters": {
81
+ "CTX_KNOWLEDGE_ENABLED": {
82
+ "type": "boolean",
83
+ "description": "Enables or disables contextual knowledge functionality; when set to 'true' additional text-generation settings are validated.",
84
+ "required": false,
85
+ "default": "false",
86
+ "sensitive": false
87
+ },
88
+ "EMBEDDING_PROVIDER": {
89
+ "type": "string",
90
+ "description": "Specifies which provider to use for generating embeddings (e.g., openai, google). If omitted the code assumes 'openai' through plugin-openai.",
91
+ "required": false,
92
+ "default": "openai",
93
+ "sensitive": false
94
+ },
95
+ "OPENAI_API_KEY": {
96
+ "type": "string",
97
+ "description": "API key used to authenticate requests to OpenAI services for embeddings or text generation.",
98
+ "required": false,
99
+ "sensitive": true
100
+ },
101
+ "OPENAI_EMBEDDING_MODEL": {
102
+ "type": "string",
103
+ "description": "Name of the OpenAI embedding model; also used as a fallback for TEXT_EMBEDDING_MODEL when EMBEDDING_PROVIDER defaults to openai.",
104
+ "required": false,
105
+ "sensitive": false
106
+ },
107
+ "TEXT_EMBEDDING_MODEL": {
108
+ "type": "string",
109
+ "description": "Embedding model name to use with the configured EMBEDDING_PROVIDER.",
110
+ "required": false,
111
+ "default": "text-embedding-3-small",
112
+ "sensitive": false
113
+ },
114
+ "EMBEDDING_DIMENSION": {
115
+ "type": "number",
116
+ "description": "Custom embedding dimension size.",
117
+ "required": false,
118
+ "default": 1536,
119
+ "sensitive": false
120
+ },
121
+ "OPENAI_EMBEDDING_DIMENSIONS": {
122
+ "type": "number",
123
+ "description": "Alternative variable to supply embedding dimension when using OpenAI.",
124
+ "required": false,
125
+ "default": 1536,
126
+ "sensitive": false
127
+ },
128
+ "TEXT_PROVIDER": {
129
+ "type": "string",
130
+ "description": "Provider to use for text generation when contextual knowledge is enabled (e.g., openai, anthropic, openrouter, google).",
131
+ "required": false,
132
+ "sensitive": false
133
+ },
134
+ "ANTHROPIC_API_KEY": {
135
+ "type": "string",
136
+ "description": "API key for Anthropic text generation models.",
137
+ "required": false,
138
+ "sensitive": true
139
+ },
140
+ "OPENROUTER_API_KEY": {
141
+ "type": "string",
142
+ "description": "API key for OpenRouter when using it as a text provider.",
143
+ "required": false,
144
+ "sensitive": true
145
+ },
146
+ "GOOGLE_API_KEY": {
147
+ "type": "string",
148
+ "description": "API key for Google AI services used for embeddings or text generation.",
149
+ "required": false,
150
+ "sensitive": true
151
+ },
152
+ "OPENAI_BASE_URL": {
153
+ "type": "string",
154
+ "description": "Custom base URL for routing OpenAI API requests (useful for proxies).",
155
+ "required": false,
156
+ "sensitive": false
157
+ },
158
+ "ANTHROPIC_BASE_URL": {
159
+ "type": "string",
160
+ "description": "Custom base URL for Anthropic API requests.",
161
+ "required": false,
162
+ "sensitive": false
163
+ },
164
+ "OPENROUTER_BASE_URL": {
165
+ "type": "string",
166
+ "description": "Custom base URL for OpenRouter API requests.",
167
+ "required": false,
168
+ "sensitive": false
169
+ },
170
+ "GOOGLE_BASE_URL": {
171
+ "type": "string",
172
+ "description": "Custom base URL for Google AI API requests.",
173
+ "required": false,
174
+ "sensitive": false
175
+ },
176
+ "TEXT_MODEL": {
177
+ "type": "string",
178
+ "description": "The specific text generation model to use with the selected TEXT_PROVIDER.",
179
+ "required": false,
180
+ "sensitive": false
181
+ },
182
+ "MAX_INPUT_TOKENS": {
183
+ "type": "number",
184
+ "description": "Maximum number of input tokens permitted per request.",
185
+ "required": false,
186
+ "default": 4000,
187
+ "sensitive": false
188
+ },
189
+ "MAX_OUTPUT_TOKENS": {
190
+ "type": "number",
191
+ "description": "Maximum number of output tokens that can be generated.",
192
+ "required": false,
193
+ "default": 4096,
194
+ "sensitive": false
195
+ },
196
+ "MAX_CONCURRENT_REQUESTS": {
197
+ "type": "number",
198
+ "description": "Upper bound on concurrent API requests for rate limiting.",
199
+ "required": false,
200
+ "default": 30,
201
+ "sensitive": false
202
+ },
203
+ "REQUESTS_PER_MINUTE": {
204
+ "type": "number",
205
+ "description": "Maximum number of API requests allowed per minute.",
206
+ "required": false,
207
+ "default": 60,
208
+ "sensitive": false
209
+ },
210
+ "TOKENS_PER_MINUTE": {
211
+ "type": "number",
212
+ "description": "Maximum number of tokens that can be processed per minute.",
213
+ "required": false,
214
+ "default": 150000,
215
+ "sensitive": false
216
+ },
217
+ "KNOWLEDGE_PATH": {
218
+ "type": "string",
219
+ "description": "Filesystem path where the knowledge loader searches for documents. Overrides the default ./docs directory.",
220
+ "required": false,
221
+ "default": "./docs",
222
+ "sensitive": false
223
+ },
224
+ "LOAD_DOCS_ON_STARTUP": {
225
+ "type": "boolean",
226
+ "description": "Controls whether the plugin should automatically load documents from the docs folder when the agent starts. Any value other than the string 'false' enables loading.",
227
+ "required": false,
228
+ "default": true,
229
+ "sensitive": false
230
+ }
231
+ }
232
+ }
78
233
  }