@crevanta/stelvara-sdk 0.1.0-alpha.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 ADDED
@@ -0,0 +1,108 @@
1
+ # @crevanta/stelvara-sdk
2
+
3
+ TypeScript SDK for [Stelvara](https://stelvara.com) — AI Behavior Control Plane.
4
+
5
+ Send traces from your Node.js or browser applications to Stelvara for observability, policy compliance, and business outcome tracking.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @crevanta/stelvara-sdk
11
+ ```
12
+
13
+ ## Quickstart
14
+
15
+ ```typescript
16
+ import { init, captureTrace, tagOutcome, shutdown } from '@crevanta/stelvara-sdk';
17
+
18
+ // 1. Initialize
19
+ init({
20
+ apiKey: 'stv_live_your_api_key',
21
+ agentId: 'your-agent-uuid',
22
+ });
23
+
24
+ // 2. Capture a trace
25
+ const traceKey = captureTrace({
26
+ input: { user_message: 'What is my account balance?' },
27
+ model: { name: 'gpt-4', provider: 'openai' },
28
+ response: { text: 'Your balance is $1,234.56', tokens_used: 42 },
29
+ performance: { duration_ms: 320 },
30
+ });
31
+
32
+ // 3. Tag business outcomes
33
+ if (traceKey) {
34
+ await tagOutcome(traceKey, {
35
+ customer_satisfied: true,
36
+ resolution_type: 'automated',
37
+ });
38
+ }
39
+
40
+ // 4. Shutdown (flushes pending traces)
41
+ await shutdown();
42
+ ```
43
+
44
+ ## Class-Based Usage
45
+
46
+ For multi-agent setups or testing, use `StelvaraClient` directly:
47
+
48
+ ```typescript
49
+ import { StelvaraClient } from '@crevanta/stelvara-sdk';
50
+
51
+ const client = new StelvaraClient({
52
+ apiKey: 'stv_live_your_api_key',
53
+ agentId: 'your-agent-uuid',
54
+ });
55
+
56
+ const traceKey = client.captureTrace({
57
+ input: { user_message: 'Hello' },
58
+ });
59
+
60
+ await client.shutdown();
61
+ ```
62
+
63
+ ## Session Tracking & Trace Hierarchy
64
+
65
+ Track multi-turn conversations and parent/child trace relationships:
66
+
67
+ ```typescript
68
+ const traceKey = captureTrace(
69
+ { input: { user_message: 'Follow-up question' } },
70
+ {
71
+ sessionId: 'conversation-abc-123',
72
+ parentTraceId: 'parent-trace-uuid',
73
+ traceType: 'chat',
74
+ }
75
+ );
76
+ ```
77
+
78
+ ### Trace Types
79
+
80
+ - `completion` — Single LLM completion
81
+ - `chat` — Multi-turn chat interaction
82
+ - `agent_step` — One step in an agent workflow
83
+ - `tool_use` — Tool/function call
84
+ - `custom` — Custom trace type
85
+
86
+ ## Configuration
87
+
88
+ ```typescript
89
+ init({
90
+ apiKey: 'stv_live_...', // Required. API key (stv_ prefix).
91
+ agentId: 'uuid', // Required. Agent UUID.
92
+ endpoint: 'https://...', // Optional. Supabase Edge Functions URL.
93
+ bufferSize: 100, // Optional. Max buffered traces (default: 100).
94
+ batchSize: 50, // Optional. Traces per API batch (default: 50).
95
+ flushIntervalMs: 5000, // Optional. Flush interval in ms (default: 5000).
96
+ maxRetries: 3, // Optional. Retry attempts (default: 3).
97
+ enabled: true, // Optional. Kill switch (default: true).
98
+ });
99
+ ```
100
+
101
+ ## Requirements
102
+
103
+ - Node.js >= 18 (uses global `fetch`)
104
+ - Modern browsers with `fetch` support
105
+
106
+ ## License
107
+
108
+ MIT