agensights 0.3.0
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/LICENSE +21 -0
- package/README.md +257 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +131 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/instrument.d.ts +29 -0
- package/dist/instrument.d.ts.map +1 -0
- package/dist/instrument.js +63 -0
- package/dist/instrument.js.map +1 -0
- package/dist/trace.d.ts +52 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +137 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +46 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +45 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 AgenSights
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
# AgenSights TypeScript SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for [AgenSights](https://github.com/agensights/agensights-js) - AI Agent Observability.
|
|
4
|
+
|
|
5
|
+
Track LLM calls, tool invocations, and multi-step agent executions with zero-friction auto-instrumentation or manual tracking.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install agensights
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start — Auto-Instrumentation (Recommended)
|
|
14
|
+
|
|
15
|
+
Wrap your OpenAI client and every call is tracked automatically. Zero manual work.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import OpenAI from "openai";
|
|
19
|
+
import { instrumentOpenAI } from "agensights";
|
|
20
|
+
|
|
21
|
+
const openai = instrumentOpenAI(
|
|
22
|
+
new OpenAI({ apiKey: "sk-xxx" }),
|
|
23
|
+
{
|
|
24
|
+
agensightsApiKey: "sk-prod-xxx",
|
|
25
|
+
agentName: "support_bot", // optional — tags all events
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// This call is now automatically tracked (model, tokens, latency, errors)
|
|
30
|
+
const response = await openai.chat.completions.create({
|
|
31
|
+
model: "gpt-4o",
|
|
32
|
+
messages: [{ role: "user", content: "Hello!" }],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Flush on shutdown
|
|
36
|
+
await (openai as any)._agensights.close();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Environment Variables
|
|
40
|
+
|
|
41
|
+
You can configure the SDK via environment variables instead of passing options:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
export AGENSIGHTS_BASE_URL="https://api.agensights.dev/api/v1"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The SDK reads `AGENSIGHTS_BASE_URL` at startup. If set, it is used as the default base URL for all clients.
|
|
48
|
+
|
|
49
|
+
### What Gets Captured Automatically
|
|
50
|
+
|
|
51
|
+
| Field | Source |
|
|
52
|
+
|-------|--------|
|
|
53
|
+
| `model` | Response `model` (falls back to request `model`) |
|
|
54
|
+
| `inputTokens` | `response.usage.prompt_tokens` |
|
|
55
|
+
| `outputTokens` | `response.usage.completion_tokens` |
|
|
56
|
+
| `latencyMs` | Wall-clock time around the API call |
|
|
57
|
+
| `status` | `"success"` or `"error"` |
|
|
58
|
+
| `errorCode` | HTTP status code or error name on failure |
|
|
59
|
+
| `provider` | `"openai"` |
|
|
60
|
+
| `agentName` | From `InstrumentOptions.agentName` |
|
|
61
|
+
|
|
62
|
+
### Using an Existing AgenSights Client
|
|
63
|
+
|
|
64
|
+
If you already have an `AgenSights` instance, pass it directly instead of an API key:
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
import { AgenSights, instrumentOpenAI } from "agensights";
|
|
68
|
+
import OpenAI from "openai";
|
|
69
|
+
|
|
70
|
+
const as = new AgenSights({ apiKey: "sk-prod-xxx" });
|
|
71
|
+
const openai = instrumentOpenAI(new OpenAI({ apiKey: "sk-xxx" }), {
|
|
72
|
+
agensightsClient: as,
|
|
73
|
+
agentName: "support_bot",
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// ... use openai as normal ...
|
|
77
|
+
|
|
78
|
+
await as.close();
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Manual Tracking
|
|
82
|
+
|
|
83
|
+
For non-OpenAI providers or when you need full control:
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
import { AgenSights } from "agensights";
|
|
87
|
+
|
|
88
|
+
const client = new AgenSights({ apiKey: "sk-prod-xxx" });
|
|
89
|
+
|
|
90
|
+
// Track a single LLM call
|
|
91
|
+
client.trackLLM({
|
|
92
|
+
model: "gpt-4o",
|
|
93
|
+
inputTokens: 100,
|
|
94
|
+
outputTokens: 50,
|
|
95
|
+
latencyMs: 300,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Track a tool call
|
|
99
|
+
client.trackTool({
|
|
100
|
+
toolName: "web_search",
|
|
101
|
+
latencyMs: 150,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Flush and close when done
|
|
105
|
+
await client.close();
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Tracing
|
|
109
|
+
|
|
110
|
+
Group related LLM and tool calls under a single trace:
|
|
111
|
+
|
|
112
|
+
```typescript
|
|
113
|
+
const trace = client.startTrace("support_agent", "workflow-123");
|
|
114
|
+
|
|
115
|
+
trace.llmCall({
|
|
116
|
+
model: "gpt-4o",
|
|
117
|
+
inputTokens: 100,
|
|
118
|
+
outputTokens: 50,
|
|
119
|
+
latencyMs: 300,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
trace.toolCall({ toolName: "web_search", latencyMs: 150 });
|
|
123
|
+
trace.toolCall({ toolName: "db_lookup", latencyMs: 80 });
|
|
124
|
+
|
|
125
|
+
await trace.end();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
All events within a trace share the same `traceId`, making it easy to view the full execution flow in the AgenSights dashboard.
|
|
129
|
+
|
|
130
|
+
## Agent Hierarchy
|
|
131
|
+
|
|
132
|
+
Track multi-agent workflows with parent-child spans:
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
const trace = client.startTrace("pipeline", "wf-001");
|
|
136
|
+
|
|
137
|
+
const orchestrator = trace.agent("orchestrator");
|
|
138
|
+
|
|
139
|
+
// Sub-agents with automatic parent linking
|
|
140
|
+
const researcher = orchestrator.agent("researcher");
|
|
141
|
+
researcher.toolCall({ name: "web_search", latencyMs: 200 });
|
|
142
|
+
researcher.llmCall({ model: "gpt-4o", inputTokens: 100, outputTokens: 50, latencyMs: 300 });
|
|
143
|
+
|
|
144
|
+
const writer = orchestrator.agent("writer");
|
|
145
|
+
writer.llmCall({
|
|
146
|
+
model: "claude-3-5-sonnet",
|
|
147
|
+
inputTokens: 200,
|
|
148
|
+
outputTokens: 100,
|
|
149
|
+
latencyMs: 400,
|
|
150
|
+
provider: "anthropic",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
await trace.end();
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This produces a full trace tree in the dashboard:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
pipeline (trace)
|
|
160
|
+
└── orchestrator (agent)
|
|
161
|
+
├── researcher (agent)
|
|
162
|
+
│ ├── web_search (tool)
|
|
163
|
+
│ └── gpt-4o (llm)
|
|
164
|
+
└── writer (agent)
|
|
165
|
+
└── claude-3-5-sonnet (llm)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Configuration
|
|
169
|
+
|
|
170
|
+
### Environment Variables
|
|
171
|
+
|
|
172
|
+
| Variable | Description |
|
|
173
|
+
|----------|-------------|
|
|
174
|
+
| `AGENSIGHTS_BASE_URL` | Backend API base URL (default: `https://api.agensights.com/api/v1`) |
|
|
175
|
+
|
|
176
|
+
### Client Options
|
|
177
|
+
|
|
178
|
+
```typescript
|
|
179
|
+
const client = new AgenSights({
|
|
180
|
+
apiKey: "sk-prod-xxx", // Required
|
|
181
|
+
baseUrl: "https://api.agensights.dev/api/v1", // Or set AGENSIGHTS_BASE_URL env var
|
|
182
|
+
flushInterval: 5000, // Auto-flush every 5s (default)
|
|
183
|
+
flushSize: 100, // Auto-flush at 100 events (default)
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## API Reference
|
|
188
|
+
|
|
189
|
+
### `instrumentOpenAI(openaiClient, options)`
|
|
190
|
+
|
|
191
|
+
Monkey-patches `chat.completions.create` to automatically track every call. Returns the same client object.
|
|
192
|
+
|
|
193
|
+
| Option | Type | Required | Description |
|
|
194
|
+
|--------|------|----------|-------------|
|
|
195
|
+
| `agensightsApiKey` | string | * | API key for AgenSights (creates a new client) |
|
|
196
|
+
| `agensightsClient` | AgenSights | * | Existing AgenSights client instance |
|
|
197
|
+
| `agentName` | string | no | Tag all events with this agent name |
|
|
198
|
+
| `baseUrl` | string | no | Override AgenSights API base URL |
|
|
199
|
+
|
|
200
|
+
\* Provide either `agensightsApiKey` or `agensightsClient`.
|
|
201
|
+
|
|
202
|
+
### `client.trackLLM(params)`
|
|
203
|
+
|
|
204
|
+
Track an LLM call.
|
|
205
|
+
|
|
206
|
+
| Parameter | Type | Required | Default |
|
|
207
|
+
|---------------|----------|----------|-------------|
|
|
208
|
+
| `model` | string | yes | |
|
|
209
|
+
| `inputTokens` | number | yes | |
|
|
210
|
+
| `outputTokens`| number | yes | |
|
|
211
|
+
| `latencyMs` | number | yes | |
|
|
212
|
+
| `status` | string | no | `"success"` |
|
|
213
|
+
| `provider` | string | no | `null` |
|
|
214
|
+
| `errorCode` | string | no | `null` |
|
|
215
|
+
| `traceId` | string | no | auto |
|
|
216
|
+
| `agentName` | string | no | `null` |
|
|
217
|
+
|
|
218
|
+
### `client.trackTool(params)`
|
|
219
|
+
|
|
220
|
+
Track a tool call.
|
|
221
|
+
|
|
222
|
+
| Parameter | Type | Required | Default |
|
|
223
|
+
|-------------|----------|----------|-------------|
|
|
224
|
+
| `toolName` | string | yes | |
|
|
225
|
+
| `latencyMs` | number | yes | |
|
|
226
|
+
| `status` | string | no | `"success"` |
|
|
227
|
+
| `traceId` | string | no | auto |
|
|
228
|
+
| `agentName` | string | no | `null` |
|
|
229
|
+
|
|
230
|
+
### `client.startTrace(agentName, workflowId?)`
|
|
231
|
+
|
|
232
|
+
Returns a `Trace` instance. All calls made through the trace share the same `traceId`.
|
|
233
|
+
|
|
234
|
+
- `trace.llmCall(params)` — record an LLM call within the trace
|
|
235
|
+
- `trace.toolCall(params)` — record a tool call within the trace
|
|
236
|
+
- `trace.agent(name)` — create an `AgentSpan` for hierarchy tracking
|
|
237
|
+
- `trace.end()` — flush all trace events
|
|
238
|
+
|
|
239
|
+
### `AgentSpan`
|
|
240
|
+
|
|
241
|
+
Created via `trace.agent(name)` or `agent.agent(name)` for nesting.
|
|
242
|
+
|
|
243
|
+
- `agent.llmCall(params)` — LLM call as child of this agent
|
|
244
|
+
- `agent.toolCall(params)` — tool call as child of this agent
|
|
245
|
+
- `agent.agent(name)` — create a sub-agent
|
|
246
|
+
|
|
247
|
+
### `client.flush()`
|
|
248
|
+
|
|
249
|
+
Manually flush buffered events to the backend.
|
|
250
|
+
|
|
251
|
+
### `client.close()`
|
|
252
|
+
|
|
253
|
+
Flush remaining events and stop the background flush timer.
|
|
254
|
+
|
|
255
|
+
## License
|
|
256
|
+
|
|
257
|
+
MIT - see [LICENSE](LICENSE) for details.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Trace } from "./trace";
|
|
2
|
+
import type { AgenSightsEvent, AgenSightsOptions, TrackLLMParams, TrackToolParams } from "./types";
|
|
3
|
+
export declare class AgenSights {
|
|
4
|
+
private apiKey;
|
|
5
|
+
private baseUrl;
|
|
6
|
+
private flushInterval;
|
|
7
|
+
private flushSize;
|
|
8
|
+
private buffer;
|
|
9
|
+
private timer;
|
|
10
|
+
private closed;
|
|
11
|
+
constructor(options: AgenSightsOptions);
|
|
12
|
+
trackLLM(params: TrackLLMParams): void;
|
|
13
|
+
trackTool(params: TrackToolParams): void;
|
|
14
|
+
startTrace(agentName: string, workflowId?: string): Trace;
|
|
15
|
+
flush(): Promise<void>;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
/** Exposed for testing - returns a copy of the current buffer */
|
|
18
|
+
_getBuffer(): AgenSightsEvent[];
|
|
19
|
+
/** @internal Add a raw event to the buffer. Used by AgentSpan for hierarchy tracking. */
|
|
20
|
+
_addEvent(event: AgenSightsEvent): void;
|
|
21
|
+
private enqueue;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EACV,eAAe,EACf,iBAAiB,EACjB,cAAc,EACd,eAAe,EAChB,MAAM,SAAS,CAAC;AAQjB,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,MAAM,CAAS;gBAEX,OAAO,EAAE,iBAAiB;IAkBtC,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI;IA2BtC,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI;IA2BxC,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK;IAInD,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAS5B,iEAAiE;IACjE,UAAU,IAAI,eAAe,EAAE;IAI/B,yFAAyF;IACzF,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAIvC,OAAO,CAAC,OAAO;CAMhB"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgenSights = void 0;
|
|
4
|
+
const trace_1 = require("./trace");
|
|
5
|
+
const DEFAULT_BASE_URL = (typeof process !== "undefined" && process.env?.AGENSIGHTS_BASE_URL) ||
|
|
6
|
+
"https://api.agensights.com/api/v1";
|
|
7
|
+
const DEFAULT_FLUSH_INTERVAL = 5000;
|
|
8
|
+
const DEFAULT_FLUSH_SIZE = 100;
|
|
9
|
+
class AgenSights {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.buffer = [];
|
|
12
|
+
this.timer = null;
|
|
13
|
+
this.closed = false;
|
|
14
|
+
this.apiKey = options.apiKey;
|
|
15
|
+
this.baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
|
|
16
|
+
this.flushInterval = options.flushInterval ?? DEFAULT_FLUSH_INTERVAL;
|
|
17
|
+
this.flushSize = options.flushSize ?? DEFAULT_FLUSH_SIZE;
|
|
18
|
+
this.timer = setInterval(() => {
|
|
19
|
+
if (this.buffer.length > 0) {
|
|
20
|
+
this.flush().catch(() => { });
|
|
21
|
+
}
|
|
22
|
+
}, this.flushInterval);
|
|
23
|
+
// Allow the Node process to exit even if the timer is still running
|
|
24
|
+
if (this.timer && typeof this.timer === "object" && "unref" in this.timer) {
|
|
25
|
+
this.timer.unref();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
trackLLM(params) {
|
|
29
|
+
if (this.closed)
|
|
30
|
+
return;
|
|
31
|
+
const event = {
|
|
32
|
+
timestamp: new Date().toISOString(),
|
|
33
|
+
trace_id: params.traceId ?? generateId(),
|
|
34
|
+
span_id: generateId(),
|
|
35
|
+
parent_span_id: null,
|
|
36
|
+
type: "llm",
|
|
37
|
+
model: params.model,
|
|
38
|
+
provider: params.provider ?? null,
|
|
39
|
+
input_tokens: params.inputTokens,
|
|
40
|
+
output_tokens: params.outputTokens,
|
|
41
|
+
latency_ms: params.latencyMs,
|
|
42
|
+
status: params.status ?? "success",
|
|
43
|
+
error_code: params.errorCode ?? null,
|
|
44
|
+
metadata: {
|
|
45
|
+
agent_name: params.agentName ?? null,
|
|
46
|
+
workflow_id: null,
|
|
47
|
+
tool_name: null,
|
|
48
|
+
},
|
|
49
|
+
endpoint: null,
|
|
50
|
+
};
|
|
51
|
+
this.enqueue(event);
|
|
52
|
+
}
|
|
53
|
+
trackTool(params) {
|
|
54
|
+
if (this.closed)
|
|
55
|
+
return;
|
|
56
|
+
const event = {
|
|
57
|
+
timestamp: new Date().toISOString(),
|
|
58
|
+
trace_id: params.traceId ?? generateId(),
|
|
59
|
+
span_id: generateId(),
|
|
60
|
+
parent_span_id: null,
|
|
61
|
+
type: "tool",
|
|
62
|
+
model: null,
|
|
63
|
+
provider: null,
|
|
64
|
+
input_tokens: 0,
|
|
65
|
+
output_tokens: 0,
|
|
66
|
+
latency_ms: params.latencyMs,
|
|
67
|
+
status: params.status ?? "success",
|
|
68
|
+
error_code: null,
|
|
69
|
+
metadata: {
|
|
70
|
+
agent_name: params.agentName ?? null,
|
|
71
|
+
workflow_id: null,
|
|
72
|
+
tool_name: params.toolName,
|
|
73
|
+
},
|
|
74
|
+
endpoint: null,
|
|
75
|
+
};
|
|
76
|
+
this.enqueue(event);
|
|
77
|
+
}
|
|
78
|
+
startTrace(agentName, workflowId) {
|
|
79
|
+
return new trace_1.Trace(this, agentName, workflowId);
|
|
80
|
+
}
|
|
81
|
+
async flush() {
|
|
82
|
+
if (this.buffer.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
const events = this.buffer.splice(0);
|
|
85
|
+
const url = `${this.baseUrl}/ingest/events`;
|
|
86
|
+
const response = await fetch(url, {
|
|
87
|
+
method: "POST",
|
|
88
|
+
headers: {
|
|
89
|
+
"Content-Type": "application/json",
|
|
90
|
+
"X-API-Key": this.apiKey,
|
|
91
|
+
},
|
|
92
|
+
body: JSON.stringify({ events }),
|
|
93
|
+
});
|
|
94
|
+
if (!response.ok) {
|
|
95
|
+
const text = await response.text().catch(() => "");
|
|
96
|
+
throw new Error(`AgenSights flush failed (${response.status}): ${text}`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
async close() {
|
|
100
|
+
this.closed = true;
|
|
101
|
+
if (this.timer !== null) {
|
|
102
|
+
clearInterval(this.timer);
|
|
103
|
+
this.timer = null;
|
|
104
|
+
}
|
|
105
|
+
await this.flush();
|
|
106
|
+
}
|
|
107
|
+
/** Exposed for testing - returns a copy of the current buffer */
|
|
108
|
+
_getBuffer() {
|
|
109
|
+
return [...this.buffer];
|
|
110
|
+
}
|
|
111
|
+
/** @internal Add a raw event to the buffer. Used by AgentSpan for hierarchy tracking. */
|
|
112
|
+
_addEvent(event) {
|
|
113
|
+
this.enqueue(event);
|
|
114
|
+
}
|
|
115
|
+
enqueue(event) {
|
|
116
|
+
this.buffer.push(event);
|
|
117
|
+
if (this.buffer.length >= this.flushSize) {
|
|
118
|
+
this.flush().catch(() => { });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.AgenSights = AgenSights;
|
|
123
|
+
function generateId() {
|
|
124
|
+
const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
125
|
+
let result = "";
|
|
126
|
+
for (let i = 0; i < 16; i++) {
|
|
127
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
128
|
+
}
|
|
129
|
+
return result;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,mCAAgC;AAQhC,MAAM,gBAAgB,GACpB,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,mBAAmB,CAAC;IACpE,mCAAmC,CAAC;AACtC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAE/B,MAAa,UAAU;IASrB,YAAY,OAA0B;QAJ9B,WAAM,GAAsB,EAAE,CAAC;QAC/B,UAAK,GAA0C,IAAI,CAAC;QACpD,WAAM,GAAG,KAAK,CAAC;QAGrB,IAAI,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KAAK,CAAC,CAAC;QACxB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACzC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;CACF;AArID,gCAqIC;AAED,SAAS,UAAU;IACjB,MAAM,KAAK,GAAG,sCAAsC,CAAC;IACrD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { AgenSights } from "./client";
|
|
2
|
+
export { AgentSpan, Trace } from "./trace";
|
|
3
|
+
export { instrumentOpenAI } from "./instrument";
|
|
4
|
+
export type { AgenSightsEvent, AgenSightsOptions, EventMetadata, TrackLLMParams, TrackToolParams, } from "./types";
|
|
5
|
+
export type { InstrumentOptions } from "./instrument";
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.instrumentOpenAI = exports.Trace = exports.AgentSpan = exports.AgenSights = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "AgenSights", { enumerable: true, get: function () { return client_1.AgenSights; } });
|
|
6
|
+
var trace_1 = require("./trace");
|
|
7
|
+
Object.defineProperty(exports, "AgentSpan", { enumerable: true, get: function () { return trace_1.AgentSpan; } });
|
|
8
|
+
Object.defineProperty(exports, "Trace", { enumerable: true, get: function () { return trace_1.Trace; } });
|
|
9
|
+
var instrument_1 = require("./instrument");
|
|
10
|
+
Object.defineProperty(exports, "instrumentOpenAI", { enumerable: true, get: function () { return instrument_1.instrumentOpenAI; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AACnB,iCAA2C;AAAlC,kGAAA,SAAS,OAAA;AAAE,8FAAA,KAAK,OAAA;AACzB,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-instrumentation for LLM clients. Zero manual tracking needed.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { instrumentOpenAI } from "agensights";
|
|
6
|
+
* import OpenAI from "openai";
|
|
7
|
+
*
|
|
8
|
+
* const client = instrumentOpenAI(
|
|
9
|
+
* new OpenAI({ apiKey: "sk-xxx" }),
|
|
10
|
+
* { agensightsApiKey: "sk-dev-xxx" }
|
|
11
|
+
* );
|
|
12
|
+
* // All calls now automatically tracked
|
|
13
|
+
* await client.chat.completions.create({ model: "gpt-4o", messages: [...] });
|
|
14
|
+
*/
|
|
15
|
+
import { AgenSights } from "./client";
|
|
16
|
+
export interface InstrumentOptions {
|
|
17
|
+
agensightsApiKey?: string;
|
|
18
|
+
agensightsClient?: AgenSights;
|
|
19
|
+
agentName?: string;
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function instrumentOpenAI<T extends {
|
|
23
|
+
chat: {
|
|
24
|
+
completions: {
|
|
25
|
+
create: Function;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
}>(openaiClient: T, options: InstrumentOptions): T;
|
|
29
|
+
//# sourceMappingURL=instrument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.d.ts","sourceRoot":"","sources":["../src/instrument.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,MAAM,WAAW,iBAAiB;IAChC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,UAAU,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,gBAAgB,CAAC,CAAC,SAAS;IAAE,IAAI,EAAE;QAAE,WAAW,EAAE;YAAE,MAAM,EAAE,QAAQ,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,EACxF,YAAY,EAAE,CAAC,EACf,OAAO,EAAE,iBAAiB,GACzB,CAAC,CAgDH"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Auto-instrumentation for LLM clients. Zero manual tracking needed.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { instrumentOpenAI } from "agensights";
|
|
7
|
+
* import OpenAI from "openai";
|
|
8
|
+
*
|
|
9
|
+
* const client = instrumentOpenAI(
|
|
10
|
+
* new OpenAI({ apiKey: "sk-xxx" }),
|
|
11
|
+
* { agensightsApiKey: "sk-dev-xxx" }
|
|
12
|
+
* );
|
|
13
|
+
* // All calls now automatically tracked
|
|
14
|
+
* await client.chat.completions.create({ model: "gpt-4o", messages: [...] });
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.instrumentOpenAI = instrumentOpenAI;
|
|
18
|
+
const client_1 = require("./client");
|
|
19
|
+
function instrumentOpenAI(openaiClient, options) {
|
|
20
|
+
const asClient = options.agensightsClient || new client_1.AgenSights({
|
|
21
|
+
apiKey: options.agensightsApiKey,
|
|
22
|
+
baseUrl: options.baseUrl,
|
|
23
|
+
});
|
|
24
|
+
const originalCreate = openaiClient.chat.completions.create.bind(openaiClient.chat.completions);
|
|
25
|
+
openaiClient.chat.completions.create = async function (...args) {
|
|
26
|
+
const kwargs = args[0] || {};
|
|
27
|
+
const model = kwargs.model || "unknown";
|
|
28
|
+
const start = Date.now();
|
|
29
|
+
try {
|
|
30
|
+
const response = await originalCreate(...args);
|
|
31
|
+
const latencyMs = Date.now() - start;
|
|
32
|
+
const usage = response?.usage || {};
|
|
33
|
+
asClient.trackLLM({
|
|
34
|
+
model: response?.model || model,
|
|
35
|
+
inputTokens: usage.prompt_tokens || 0,
|
|
36
|
+
outputTokens: usage.completion_tokens || 0,
|
|
37
|
+
latencyMs,
|
|
38
|
+
status: "success",
|
|
39
|
+
provider: "openai",
|
|
40
|
+
agentName: options.agentName,
|
|
41
|
+
});
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
const latencyMs = Date.now() - start;
|
|
46
|
+
asClient.trackLLM({
|
|
47
|
+
model,
|
|
48
|
+
inputTokens: 0,
|
|
49
|
+
outputTokens: 0,
|
|
50
|
+
latencyMs,
|
|
51
|
+
status: "error",
|
|
52
|
+
errorCode: String(error?.status || error?.name || "unknown"),
|
|
53
|
+
provider: "openai",
|
|
54
|
+
agentName: options.agentName,
|
|
55
|
+
});
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
// Store reference for cleanup
|
|
60
|
+
openaiClient._agensights = asClient;
|
|
61
|
+
return openaiClient;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=instrument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../src/instrument.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;AAYH,4CAmDC;AA7DD,qCAAsC;AAUtC,SAAgB,gBAAgB,CAC9B,YAAe,EACf,OAA0B;IAE1B,MAAM,QAAQ,GAAG,OAAO,CAAC,gBAAgB,IAAI,IAAI,mBAAU,CAAC;QAC1D,MAAM,EAAE,OAAO,CAAC,gBAAiB;QACjC,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAEhG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,KAAK,WAAU,GAAG,IAAW;QAClE,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7B,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,SAAS,CAAC;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAEzB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;YAC/C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;YACrC,MAAM,KAAK,GAAG,QAAQ,EAAE,KAAK,IAAI,EAAE,CAAC;YAEpC,QAAQ,CAAC,QAAQ,CAAC;gBAChB,KAAK,EAAE,QAAQ,EAAE,KAAK,IAAI,KAAK;gBAC/B,WAAW,EAAE,KAAK,CAAC,aAAa,IAAI,CAAC;gBACrC,YAAY,EAAE,KAAK,CAAC,iBAAiB,IAAI,CAAC;gBAC1C,SAAS;gBACT,MAAM,EAAE,SAAS;gBACjB,QAAQ,EAAE,QAAQ;gBAClB,SAAS,EAAE,OAAO,CAAC,SAAS;aAC7B,CAAC,CAAC;YAEH,OAAO,QAAQ,CAAC;QAClB,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;YACrC,QAAQ,CAAC,QAAQ,CAAC;gBAChB,KAAK;gBACL,WAAW,EAAE,CAAC;gBACd,YAAY,EAAE,CAAC;gBACf,SAAS;gBACT,MAAM,EAAE,OAAO;gBACf,SAAS,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,IAAI,KAAK,EAAE,IAAI,IAAI,SAAS,CAAC;gBAC5D,QAAQ,EAAE,QAAQ;gBAClB,SAAS,EAAE,OAAO,CAAC,SAAS;aAC7B,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAQ,CAAC;IAET,8BAA8B;IAC7B,YAAoB,CAAC,WAAW,GAAG,QAAQ,CAAC;IAC7C,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/trace.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AgenSights } from "./client";
|
|
2
|
+
export declare class AgentSpan {
|
|
3
|
+
readonly spanId: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
private trace;
|
|
6
|
+
private parentSpanId;
|
|
7
|
+
constructor(trace: Trace, name: string, parentSpanId?: string | null);
|
|
8
|
+
/** Create a sub-agent (child span of this agent). */
|
|
9
|
+
agent(name: string): AgentSpan;
|
|
10
|
+
/** Record an LLM call as a child of this agent. */
|
|
11
|
+
llmCall(params: {
|
|
12
|
+
model: string;
|
|
13
|
+
inputTokens: number;
|
|
14
|
+
outputTokens: number;
|
|
15
|
+
latencyMs: number;
|
|
16
|
+
status?: "success" | "error";
|
|
17
|
+
provider?: string;
|
|
18
|
+
errorCode?: string;
|
|
19
|
+
}): string;
|
|
20
|
+
/** Record a tool call as a child of this agent. */
|
|
21
|
+
toolCall(params: {
|
|
22
|
+
name: string;
|
|
23
|
+
latencyMs: number;
|
|
24
|
+
status?: "success" | "error";
|
|
25
|
+
errorCode?: string;
|
|
26
|
+
}): string;
|
|
27
|
+
}
|
|
28
|
+
export declare class Trace {
|
|
29
|
+
readonly traceId: string;
|
|
30
|
+
private client;
|
|
31
|
+
private agentName;
|
|
32
|
+
private workflowId;
|
|
33
|
+
constructor(client: AgenSights, agentName: string, workflowId?: string);
|
|
34
|
+
/** Create a root-level agent span in this trace. */
|
|
35
|
+
agent(name: string): AgentSpan;
|
|
36
|
+
llmCall(params: {
|
|
37
|
+
model: string;
|
|
38
|
+
inputTokens: number;
|
|
39
|
+
outputTokens: number;
|
|
40
|
+
latencyMs: number;
|
|
41
|
+
status?: "success" | "error";
|
|
42
|
+
provider?: string;
|
|
43
|
+
errorCode?: string;
|
|
44
|
+
}): void;
|
|
45
|
+
toolCall(params: {
|
|
46
|
+
toolName: string;
|
|
47
|
+
latencyMs: number;
|
|
48
|
+
status?: "success" | "error";
|
|
49
|
+
}): void;
|
|
50
|
+
end(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAG3C,qBAAa,SAAS;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,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EAAE,MAAM,CAAC;QAClB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,GAAG,IAAI;IAcR,QAAQ,CAAC,MAAM,EAAE;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;KAC9B,GAAG,IAAI;IAUF,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAG3B"}
|
package/dist/trace.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Trace = exports.AgentSpan = void 0;
|
|
4
|
+
class AgentSpan {
|
|
5
|
+
constructor(trace, name, parentSpanId = null) {
|
|
6
|
+
this.spanId = generateId();
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.trace = trace;
|
|
9
|
+
this.parentSpanId = parentSpanId;
|
|
10
|
+
// Record agent span event
|
|
11
|
+
const event = {
|
|
12
|
+
timestamp: new Date().toISOString(),
|
|
13
|
+
trace_id: trace.traceId,
|
|
14
|
+
span_id: this.spanId,
|
|
15
|
+
parent_span_id: parentSpanId,
|
|
16
|
+
type: "agent",
|
|
17
|
+
model: null,
|
|
18
|
+
provider: null,
|
|
19
|
+
input_tokens: 0,
|
|
20
|
+
output_tokens: 0,
|
|
21
|
+
latency_ms: 0,
|
|
22
|
+
status: "success",
|
|
23
|
+
error_code: null,
|
|
24
|
+
metadata: {
|
|
25
|
+
agent_name: name,
|
|
26
|
+
workflow_id: trace["workflowId"],
|
|
27
|
+
tool_name: null,
|
|
28
|
+
},
|
|
29
|
+
endpoint: null,
|
|
30
|
+
};
|
|
31
|
+
trace["client"]._addEvent(event);
|
|
32
|
+
}
|
|
33
|
+
/** Create a sub-agent (child span of this agent). */
|
|
34
|
+
agent(name) {
|
|
35
|
+
return new AgentSpan(this.trace, name, this.spanId);
|
|
36
|
+
}
|
|
37
|
+
/** Record an LLM call as a child of this agent. */
|
|
38
|
+
llmCall(params) {
|
|
39
|
+
const spanId = generateId();
|
|
40
|
+
const event = {
|
|
41
|
+
timestamp: new Date().toISOString(),
|
|
42
|
+
trace_id: this.trace.traceId,
|
|
43
|
+
span_id: spanId,
|
|
44
|
+
parent_span_id: this.spanId,
|
|
45
|
+
type: "llm",
|
|
46
|
+
model: params.model,
|
|
47
|
+
provider: params.provider ?? null,
|
|
48
|
+
input_tokens: params.inputTokens,
|
|
49
|
+
output_tokens: params.outputTokens,
|
|
50
|
+
latency_ms: params.latencyMs,
|
|
51
|
+
status: params.status ?? "success",
|
|
52
|
+
error_code: params.errorCode ?? null,
|
|
53
|
+
metadata: {
|
|
54
|
+
agent_name: this.name,
|
|
55
|
+
workflow_id: this.trace["workflowId"],
|
|
56
|
+
tool_name: null,
|
|
57
|
+
},
|
|
58
|
+
endpoint: null,
|
|
59
|
+
};
|
|
60
|
+
this.trace["client"]._addEvent(event);
|
|
61
|
+
return spanId;
|
|
62
|
+
}
|
|
63
|
+
/** Record a tool call as a child of this agent. */
|
|
64
|
+
toolCall(params) {
|
|
65
|
+
const spanId = generateId();
|
|
66
|
+
const event = {
|
|
67
|
+
timestamp: new Date().toISOString(),
|
|
68
|
+
trace_id: this.trace.traceId,
|
|
69
|
+
span_id: spanId,
|
|
70
|
+
parent_span_id: this.spanId,
|
|
71
|
+
type: "tool",
|
|
72
|
+
model: null,
|
|
73
|
+
provider: null,
|
|
74
|
+
input_tokens: 0,
|
|
75
|
+
output_tokens: 0,
|
|
76
|
+
latency_ms: params.latencyMs,
|
|
77
|
+
status: params.status ?? "success",
|
|
78
|
+
error_code: params.errorCode ?? null,
|
|
79
|
+
metadata: {
|
|
80
|
+
agent_name: this.name,
|
|
81
|
+
workflow_id: this.trace["workflowId"],
|
|
82
|
+
tool_name: params.name,
|
|
83
|
+
},
|
|
84
|
+
endpoint: null,
|
|
85
|
+
};
|
|
86
|
+
this.trace["client"]._addEvent(event);
|
|
87
|
+
return spanId;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.AgentSpan = AgentSpan;
|
|
91
|
+
class Trace {
|
|
92
|
+
constructor(client, agentName, workflowId) {
|
|
93
|
+
this.client = client;
|
|
94
|
+
this.traceId = generateId();
|
|
95
|
+
this.agentName = agentName;
|
|
96
|
+
this.workflowId = workflowId ?? null;
|
|
97
|
+
}
|
|
98
|
+
/** Create a root-level agent span in this trace. */
|
|
99
|
+
agent(name) {
|
|
100
|
+
return new AgentSpan(this, name, null);
|
|
101
|
+
}
|
|
102
|
+
llmCall(params) {
|
|
103
|
+
this.client.trackLLM({
|
|
104
|
+
model: params.model,
|
|
105
|
+
inputTokens: params.inputTokens,
|
|
106
|
+
outputTokens: params.outputTokens,
|
|
107
|
+
latencyMs: params.latencyMs,
|
|
108
|
+
status: params.status,
|
|
109
|
+
provider: params.provider,
|
|
110
|
+
errorCode: params.errorCode,
|
|
111
|
+
traceId: this.traceId,
|
|
112
|
+
agentName: this.agentName,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
toolCall(params) {
|
|
116
|
+
this.client.trackTool({
|
|
117
|
+
toolName: params.toolName,
|
|
118
|
+
latencyMs: params.latencyMs,
|
|
119
|
+
status: params.status,
|
|
120
|
+
traceId: this.traceId,
|
|
121
|
+
agentName: this.agentName,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async end() {
|
|
125
|
+
await this.client.flush();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.Trace = Trace;
|
|
129
|
+
function generateId() {
|
|
130
|
+
const chars = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
131
|
+
let result = "";
|
|
132
|
+
for (let i = 0; i < 16; i++) {
|
|
133
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
134
|
+
}
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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zB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC5B,CAAC;CACF;AAzDD,sBAyDC;AAED,SAAS,UAAU;IACjB,MAAM,KAAK,GAAG,sCAAsC,CAAC;IACrD,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export interface EventMetadata {
|
|
2
|
+
agent_name: string | null;
|
|
3
|
+
workflow_id: string | null;
|
|
4
|
+
tool_name: string | null;
|
|
5
|
+
}
|
|
6
|
+
export interface AgenSightsEvent {
|
|
7
|
+
timestamp: string;
|
|
8
|
+
trace_id: string;
|
|
9
|
+
span_id: string;
|
|
10
|
+
parent_span_id: string | null;
|
|
11
|
+
type: "llm" | "tool" | "system" | "agent";
|
|
12
|
+
model: string | null;
|
|
13
|
+
provider: string | null;
|
|
14
|
+
input_tokens: number;
|
|
15
|
+
output_tokens: number;
|
|
16
|
+
latency_ms: number;
|
|
17
|
+
status: "success" | "error";
|
|
18
|
+
error_code: string | null;
|
|
19
|
+
metadata: EventMetadata;
|
|
20
|
+
endpoint: string | null;
|
|
21
|
+
}
|
|
22
|
+
export interface TrackLLMParams {
|
|
23
|
+
model: string;
|
|
24
|
+
inputTokens: number;
|
|
25
|
+
outputTokens: number;
|
|
26
|
+
latencyMs: number;
|
|
27
|
+
status?: "success" | "error";
|
|
28
|
+
provider?: string;
|
|
29
|
+
errorCode?: string;
|
|
30
|
+
traceId?: string;
|
|
31
|
+
agentName?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface TrackToolParams {
|
|
34
|
+
toolName: string;
|
|
35
|
+
latencyMs: number;
|
|
36
|
+
status?: "success" | "error";
|
|
37
|
+
traceId?: string;
|
|
38
|
+
agentName?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AgenSightsOptions {
|
|
41
|
+
apiKey: string;
|
|
42
|
+
baseUrl?: string;
|
|
43
|
+
flushInterval?: number;
|
|
44
|
+
flushSize?: number;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC1C,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "agensights",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "AgenSights SDK - AI Agent Observability. Zero-friction tracking for LLM calls, agents, and tools.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"LICENSE",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"llm",
|
|
19
|
+
"observability",
|
|
20
|
+
"ai-agents",
|
|
21
|
+
"monitoring",
|
|
22
|
+
"tracing",
|
|
23
|
+
"openai",
|
|
24
|
+
"anthropic",
|
|
25
|
+
"analytics"
|
|
26
|
+
],
|
|
27
|
+
"author": "AgenSights <support@agensights.dev>",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/agensights/agensights-js"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://docs.agensights.dev",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/agensights/agensights-js/issues"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18.0.0"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^20.19.39",
|
|
42
|
+
"typescript": "^5.0.0",
|
|
43
|
+
"vitest": "^2.0.0"
|
|
44
|
+
}
|
|
45
|
+
}
|