@cortexa/core 1.1.0 → 1.1.1
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 +80 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
- [Architecture](#architecture)
|
|
24
24
|
- [Supported Databases](#supported-databases)
|
|
25
25
|
- [CLI Reference](#cli-reference)
|
|
26
|
+
- [REST API](#rest-api)
|
|
26
27
|
- [Configuration](#configuration)
|
|
27
28
|
- [Requirements](#requirements)
|
|
28
29
|
- [Contributing](#contributing)
|
|
@@ -307,6 +308,85 @@ npm install @powersync/mysql-zongji
|
|
|
307
308
|
| `cortexa actions` | View and manage action recommendations |
|
|
308
309
|
| `cortexa explain <type> <id>` | AI explanation of anomaly, insight, or event |
|
|
309
310
|
| `cortexa ask "<question>"` | Ask a natural language question |
|
|
311
|
+
| `cortexa serve` | Start REST API server (`--port`, `--host`) |
|
|
312
|
+
|
|
313
|
+
## REST API
|
|
314
|
+
|
|
315
|
+
Start the HTTP server to access Cortexa from any language (Python, Go, Ruby, etc.):
|
|
316
|
+
|
|
317
|
+
```bash
|
|
318
|
+
npx cortexa serve
|
|
319
|
+
# Cortexa API running at http://127.0.0.1:3210
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Options: `--port <port>` (default: 3210), `--host <host>` (default: 127.0.0.1), `--no-cors`.
|
|
323
|
+
|
|
324
|
+
### Endpoints
|
|
325
|
+
|
|
326
|
+
| Method | Endpoint | Description |
|
|
327
|
+
|--------|----------|-------------|
|
|
328
|
+
| GET | `/api/status` | Connection status |
|
|
329
|
+
| GET | `/api/entities` | List classified entities |
|
|
330
|
+
| GET | `/api/relationships` | List entity relationships |
|
|
331
|
+
| GET | `/api/events` | List change events (`?entity=`, `?last=`) |
|
|
332
|
+
| GET | `/api/baselines` | Learned rate baselines |
|
|
333
|
+
| GET | `/api/anomalies` | Detected anomalies (`?severity=`, `?entity=`) |
|
|
334
|
+
| GET | `/api/insights` | State analysis insights (`?entity=`, `?severity=`) |
|
|
335
|
+
| GET | `/api/transitions` | Transition statistics (`?entity=`) |
|
|
336
|
+
| GET | `/api/correlations` | Cross-entity correlations |
|
|
337
|
+
| GET | `/api/distributions` | Value distributions (`?entity=`) |
|
|
338
|
+
| GET | `/api/graph` | Knowledge graph summary |
|
|
339
|
+
| GET | `/api/graph/export` | Full graph as JSON |
|
|
340
|
+
| GET | `/api/graph/entity/:name` | Entity intelligence |
|
|
341
|
+
| GET | `/api/actions` | Recommendations (`?status=`, `?action=`) |
|
|
342
|
+
| POST | `/api/discover` | Trigger schema discovery |
|
|
343
|
+
| POST | `/api/explain` | AI explanation (`{ type, id }`) |
|
|
344
|
+
| POST | `/api/ask` | Natural language question (`{ question }`) |
|
|
345
|
+
| POST | `/api/watch` | Start watching (`{ interval, once }`) |
|
|
346
|
+
| POST | `/api/unwatch` | Stop watching |
|
|
347
|
+
| POST | `/api/actions/:id/approve` | Approve recommendation |
|
|
348
|
+
| POST | `/api/actions/:id/reject` | Reject recommendation |
|
|
349
|
+
|
|
350
|
+
All responses return `{ ok: boolean, data?: ..., error?: string }`.
|
|
351
|
+
|
|
352
|
+
### Examples
|
|
353
|
+
|
|
354
|
+
```bash
|
|
355
|
+
# Get anomalies
|
|
356
|
+
curl http://localhost:3210/api/anomalies?severity=high
|
|
357
|
+
|
|
358
|
+
# Ask a question
|
|
359
|
+
curl -X POST http://localhost:3210/api/ask \
|
|
360
|
+
-H "Content-Type: application/json" \
|
|
361
|
+
-d '{"question": "Why did order activity spike today?"}'
|
|
362
|
+
|
|
363
|
+
# Explain an anomaly
|
|
364
|
+
curl -X POST http://localhost:3210/api/explain \
|
|
365
|
+
-H "Content-Type: application/json" \
|
|
366
|
+
-d '{"type": "anomaly", "id": 1}'
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
```python
|
|
370
|
+
# Python example
|
|
371
|
+
import requests
|
|
372
|
+
|
|
373
|
+
r = requests.get("http://localhost:3210/api/anomalies", params={"severity": "high"})
|
|
374
|
+
print(r.json()["data"])
|
|
375
|
+
|
|
376
|
+
r = requests.post("http://localhost:3210/api/ask", json={"question": "Are orders healthy?"})
|
|
377
|
+
print(r.json()["data"]["answer"])
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Programmatic usage
|
|
381
|
+
|
|
382
|
+
```ts
|
|
383
|
+
import { CortexaServer } from '@cortexa/core';
|
|
384
|
+
|
|
385
|
+
const server = new CortexaServer(config, { port: 3210, cors: true });
|
|
386
|
+
await server.start();
|
|
387
|
+
// ... later
|
|
388
|
+
await server.stop();
|
|
389
|
+
```
|
|
310
390
|
|
|
311
391
|
## Configuration
|
|
312
392
|
|