@2434addy/agentledger-sdk 0.2.0 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +120 -120
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,120 +1,120 @@
1
- # @agentledger/sdk
2
-
3
- TypeScript SDK for AgentLedger — track, audit, and monitor your AI agents.
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm install @agentledger/sdk
9
- ```
10
-
11
- ## Quick Start
12
-
13
- ```typescript
14
- import { AgentLedger } from '@agentledger/sdk'
15
-
16
- const al = new AgentLedger({ apiKey: 'al_live_sk_...' })
17
-
18
- // Create an agent
19
- const agent = await al.createAgent({
20
- name: 'My Assistant',
21
- description: 'Customer support bot',
22
- modelProvider: 'anthropic',
23
- modelId: 'claude-sonnet-4-6',
24
- })
25
-
26
- // Create a session
27
- const session = await al.createSession({ agentId: agent.id })
28
-
29
- // Track events (batched automatically)
30
- al.track({
31
- agentId: agent.id,
32
- sessionId: session.id,
33
- category: 'llm_call',
34
- level: 'info',
35
- message: 'Called Claude API',
36
- metadata: { prompt: 'Hello world' },
37
- })
38
-
39
- // Send all queued events now
40
- await al.flush()
41
- ```
42
-
43
- ## API
44
-
45
- ### `new AgentLedger(config)`
46
-
47
- | Option | Type | Default | Description |
48
- | --------------- | -------- | ------------------------------------------ | ------------------------ |
49
- | `apiKey` | `string` | *required* | Your API key |
50
- | `baseUrl` | `string` | `https://api.agentledger.io/api/v1` | API base URL |
51
- | `timeout` | `number` | `5000` | Request timeout (ms) |
52
- | `flushInterval` | `number` | `5000` | Auto-flush interval (ms) |
53
- | `maxBatchSize` | `number` | `50` | Max events per batch |
54
- | `debug` | `boolean`| `false` | Log warnings to console |
55
-
56
- ### `al.createAgent(input)`
57
-
58
- Create a registered agent.
59
-
60
- ```typescript
61
- const agent = await al.createAgent({
62
- name: 'Email Agent',
63
- modelProvider: 'openai',
64
- modelId: 'gpt-4o',
65
- })
66
- ```
67
-
68
- ### `al.createSession(input)`
69
-
70
- Start a new session for an agent.
71
-
72
- ```typescript
73
- const session = await al.createSession({ agentId: agent.id })
74
- ```
75
-
76
- ### `al.track(event)`
77
-
78
- Queue an event for batched sending. Fires immediately when the batch reaches `maxBatchSize`.
79
-
80
- ```typescript
81
- al.track({
82
- agentId: agent.id,
83
- sessionId: session.id,
84
- category: 'llm_call',
85
- level: 'info',
86
- message: 'Generated response',
87
- metadata: { model: 'claude-sonnet-4-6' },
88
- tokensInput: 150,
89
- tokensOutput: 420,
90
- latencyMs: 1200,
91
- })
92
- ```
93
-
94
- ### `al.flush()`
95
-
96
- Send all queued events immediately. Returns the created events.
97
-
98
- ```typescript
99
- const events = await al.flush()
100
- ```
101
-
102
- ### `al.shutdown()`
103
-
104
- Stop the auto-flush timer and send remaining events. Call before process exit.
105
-
106
- ```typescript
107
- process.on('beforeExit', () => al.shutdown())
108
- ```
109
-
110
- ## Event Categories
111
-
112
- `agent_lifecycle` | `llm_call` | `tool_invocation` | `user_action` | `system` | `security` | `guardrail`
113
-
114
- ## Event Levels
115
-
116
- `debug` | `info` | `warn` | `error` | `fatal`
117
-
118
- ## License
119
-
120
- MIT
1
+ # @agentledger/sdk
2
+
3
+ TypeScript SDK for AgentLedger — track, audit, and monitor your AI agents.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @agentledger/sdk
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { AgentLedger } from '@agentledger/sdk'
15
+
16
+ const al = new AgentLedger({ apiKey: 'al_live_sk_...' })
17
+
18
+ // Create an agent
19
+ const agent = await al.createAgent({
20
+ name: 'My Assistant',
21
+ description: 'Customer support bot',
22
+ modelProvider: 'anthropic',
23
+ modelId: 'claude-sonnet-4-6',
24
+ })
25
+
26
+ // Create a session
27
+ const session = await al.createSession({ agentId: agent.id })
28
+
29
+ // Track events (batched automatically)
30
+ al.track({
31
+ agentId: agent.id,
32
+ sessionId: session.id,
33
+ category: 'llm_call',
34
+ level: 'info',
35
+ message: 'Called Claude API',
36
+ payload: { prompt: 'Hello world' },
37
+ })
38
+
39
+ // Send all queued events now
40
+ await al.flush()
41
+ ```
42
+
43
+ ## API
44
+
45
+ ### `new AgentLedger(config)`
46
+
47
+ | Option | Type | Default | Description |
48
+ | --------------- | -------- | ------------------------------------------ | ------------------------ |
49
+ | `apiKey` | `string` | *required* | Your API key |
50
+ | `baseUrl` | `string` | `https://api.agentledger.io/api/v1` | API base URL |
51
+ | `timeout` | `number` | `5000` | Request timeout (ms) |
52
+ | `flushInterval` | `number` | `5000` | Auto-flush interval (ms) |
53
+ | `maxBatchSize` | `number` | `50` | Max events per batch |
54
+ | `debug` | `boolean`| `false` | Log warnings to console |
55
+
56
+ ### `al.createAgent(input)`
57
+
58
+ Create a registered agent.
59
+
60
+ ```typescript
61
+ const agent = await al.createAgent({
62
+ name: 'Email Agent',
63
+ modelProvider: 'openai',
64
+ modelId: 'gpt-4o',
65
+ })
66
+ ```
67
+
68
+ ### `al.createSession(input)`
69
+
70
+ Start a new session for an agent.
71
+
72
+ ```typescript
73
+ const session = await al.createSession({ agentId: agent.id })
74
+ ```
75
+
76
+ ### `al.track(event)`
77
+
78
+ Queue an event for batched sending. Fires immediately when the batch reaches `maxBatchSize`.
79
+
80
+ ```typescript
81
+ al.track({
82
+ agentId: agent.id,
83
+ sessionId: session.id,
84
+ category: 'llm_call',
85
+ level: 'info',
86
+ message: 'Generated response',
87
+ payload: { model: 'claude-sonnet-4-6' },
88
+ tokensInput: 150,
89
+ tokensOutput: 420,
90
+ latencyMs: 1200,
91
+ })
92
+ ```
93
+
94
+ ### `al.flush()`
95
+
96
+ Send all queued events immediately. Returns the created events.
97
+
98
+ ```typescript
99
+ const events = await al.flush()
100
+ ```
101
+
102
+ ### `al.shutdown()`
103
+
104
+ Stop the auto-flush timer and send remaining events. Call before process exit.
105
+
106
+ ```typescript
107
+ process.on('beforeExit', () => al.shutdown())
108
+ ```
109
+
110
+ ## Event Categories
111
+
112
+ `agent_lifecycle` | `llm_call` | `tool_invocation` | `user_action` | `system` | `security` | `guardrail`
113
+
114
+ ## Event Levels
115
+
116
+ `debug` | `info` | `warn` | `error` | `fatal`
117
+
118
+ ## License
119
+
120
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@2434addy/agentledger-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "TypeScript SDK for AgentLedger — track, audit, and monitor your AI agents.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",