@sentro/sdk 0.1.0 → 0.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 +120 -0
- package/package.json +12 -2
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# @sentro/sdk
|
|
2
|
+
|
|
3
|
+
**Error tracking and agent observability for AI agents.** TypeScript SDK for [Sentro](https://github.com/yzzztech/sentro).
|
|
4
|
+
|
|
5
|
+
Sentro is an open-source Sentry alternative built specifically for AI agents. This SDK gives you full observability into every run, step, tool call, and LLM call your agents make — plus traditional error tracking.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @sentro/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
### Error tracking
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Sentro } from '@sentro/sdk';
|
|
19
|
+
|
|
20
|
+
const sentro = new Sentro({ dsn: 'http://token@localhost:3000/api/ingest/proj_1' });
|
|
21
|
+
|
|
22
|
+
sentro.captureException(new Error('Payment failed'));
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Agent observability
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
const result = await sentro.trace('order-processor', {
|
|
29
|
+
goal: 'Process refund for order #456',
|
|
30
|
+
model: 'claude-sonnet-4-6',
|
|
31
|
+
}, async (run) => {
|
|
32
|
+
|
|
33
|
+
return await run.trace('Looking up order', async (step) => {
|
|
34
|
+
// Track tool calls
|
|
35
|
+
const order = await step.traceToolCall('database.query',
|
|
36
|
+
{ sql: 'SELECT * FROM orders WHERE id = 456' },
|
|
37
|
+
async () => db.query('SELECT * FROM orders WHERE id = 456')
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// Track LLM calls
|
|
41
|
+
const llm = step.llmCall({ model: 'claude-sonnet-4-6' });
|
|
42
|
+
const decision = await callLLM('Should we approve this refund?');
|
|
43
|
+
llm.end({ promptTokens: 150, completionTokens: 20, cost: 0.001 });
|
|
44
|
+
|
|
45
|
+
return decision;
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
// Automatically captures: duration, tokens, cost, success/failure
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Explicit API
|
|
52
|
+
|
|
53
|
+
For more control, use the explicit start/end API:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
const run = sentro.startRun({
|
|
57
|
+
agent: 'research-agent',
|
|
58
|
+
goal: 'Find recent papers',
|
|
59
|
+
model: 'gpt-4o',
|
|
60
|
+
trigger: 'api',
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
const step = run.step('Search for papers');
|
|
65
|
+
const llm = step.llmCall({ model: 'gpt-4o', provider: 'openai' });
|
|
66
|
+
const res = await openai.chat.completions.create({ ... });
|
|
67
|
+
await llm.end({
|
|
68
|
+
promptTokens: res.usage?.prompt_tokens,
|
|
69
|
+
completionTokens: res.usage?.completion_tokens,
|
|
70
|
+
});
|
|
71
|
+
await step.end();
|
|
72
|
+
await run.end({ status: 'success' });
|
|
73
|
+
} catch (err) {
|
|
74
|
+
await run.error(err instanceof Error ? err : new Error(String(err)));
|
|
75
|
+
throw err;
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Configuration
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
const sentro = new Sentro({
|
|
83
|
+
dsn: 'http://token@localhost:3000/api/ingest/proj_1',
|
|
84
|
+
capturePrompts: false, // set true to store prompt/response bodies
|
|
85
|
+
flushIntervalMs: 1000, // batch send every 1s
|
|
86
|
+
maxBatchSize: 100, // flush when buffer hits 100
|
|
87
|
+
defaultTags: {
|
|
88
|
+
env: 'production',
|
|
89
|
+
version: '1.0.0',
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
| Option | Type | Default | Description |
|
|
95
|
+
|--------|------|---------|-------------|
|
|
96
|
+
| `dsn` | string | required | Full DSN URL from your project settings |
|
|
97
|
+
| `capturePrompts` | boolean | `false` | Store prompt/response bodies verbatim |
|
|
98
|
+
| `flushIntervalMs` | number | `1000` | How often (ms) to flush the buffer |
|
|
99
|
+
| `maxBatchSize` | number | `100` | Max events per batch before immediate flush |
|
|
100
|
+
| `defaultTags` | Record\<string, string\> | — | Tags merged into every event |
|
|
101
|
+
|
|
102
|
+
## Graceful Shutdown
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
// Before process exit
|
|
106
|
+
await sentro.shutdown();
|
|
107
|
+
|
|
108
|
+
// In serverless environments
|
|
109
|
+
await sentro.flush();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Links
|
|
113
|
+
|
|
114
|
+
- **GitHub:** [github.com/yzzztech/sentro](https://github.com/yzzztech/sentro)
|
|
115
|
+
- **Docs:** Available at `/docs` when running Sentro
|
|
116
|
+
- **Python SDK:** `pip install sentro-sdk`
|
|
117
|
+
|
|
118
|
+
## License
|
|
119
|
+
|
|
120
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentro/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Error tracking and agent observability for AI agents — TypeScript SDK for Sentro",
|
|
4
5
|
"main": "dist/index.js",
|
|
5
6
|
"types": "dist/index.d.ts",
|
|
6
|
-
"files": ["dist"],
|
|
7
|
+
"files": ["dist", "README.md"],
|
|
8
|
+
"keywords": ["sentro", "observability", "error-tracking", "ai-agents", "llm", "tracing", "sentry-alternative"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/yzzztech/sentro.git",
|
|
13
|
+
"directory": "packages/sdk"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/yzzztech/sentro",
|
|
16
|
+
"bugs": "https://github.com/yzzztech/sentro/issues",
|
|
7
17
|
"scripts": {
|
|
8
18
|
"build": "tsc",
|
|
9
19
|
"test": "vitest run",
|