opsveritas-sdk 0.3.0 → 0.3.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 +79 -79
- package/dist/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
# opsveritas-sdk
|
|
2
|
-
|
|
3
|
-
Monitor your AI agents in **three lines of code**. Tracks tokens, cost, latency, model, and silent failures (200 OK with empty output) — and routes alerts to Slack / Email / Teams via [OpsVeritas AI Agents Control Tower](https://agents.opsveritas.com).
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm install opsveritas-sdk
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
## Quick start (3 lines)
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import { OpsVeritas } from 'opsveritas-sdk';
|
|
13
|
-
|
|
14
|
-
OpsVeritas.init('<your-ingest-key>'); // key from Settings → Integrations
|
|
15
|
-
const client = OpsVeritas.wrap(new OpenAI(), { agentName: 'Support Bot' });
|
|
16
|
-
// use `client` exactly as before — runs appear in your dashboard automatically
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Works the same for Anthropic and Gemini clients. Prefer manual control? Wrap a function:
|
|
20
|
-
|
|
21
|
-
```ts
|
|
22
|
-
await OpsVeritas.trace('Nightly Report', async () => runReport());
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## LangChain (one line)
|
|
26
|
-
|
|
27
|
-
Attach the handler to any LangChain chat model, LLM or chain — every call reports token / cost / latency / silent-failure automatically:
|
|
28
|
-
|
|
29
|
-
```ts
|
|
30
|
-
import { ChatOpenAI } from '@langchain/openai';
|
|
31
|
-
import { OpsVeritas } from 'opsveritas-sdk';
|
|
32
|
-
|
|
33
|
-
OpsVeritas.init('<your-ingest-key>');
|
|
34
|
-
const model = new ChatOpenAI({ callbacks: [OpsVeritas.langchain('My Agent')] });
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
No extra dependency — it's a plain LangChain callback handler. Works with any LangChain-backed provider (OpenAI, Anthropic, Gemini, Groq…). Inside `OpsVeritas.run(...)` the handler aggregates into a single execution instead of double-counting.
|
|
38
|
-
|
|
39
|
-
## What data is sent
|
|
40
|
-
|
|
41
|
-
By design the SDK sends **metadata only, plus a short output snippet** — never your prompts/inputs:
|
|
42
|
-
|
|
43
|
-
| Sent | Detail |
|
|
44
|
-
|------|--------|
|
|
45
|
-
| ✅ Metadata | agent name, status, timestamps, duration, token counts, model, cost, tool-call count |
|
|
46
|
-
| ⚠️ Output snippet | first 300 chars of the response (`output_summary`) — powers silent-failure detection |
|
|
47
|
-
| ⚠️ Error message | the exception text, if a call fails |
|
|
48
|
-
| ❌ Prompts / inputs | **never sent** — only token counts |
|
|
49
|
-
|
|
50
|
-
### Metadata-only mode (for regulated / client data)
|
|
51
|
-
|
|
52
|
-
Drop the output snippet and redact error text so **no response content ever leaves your environment** — token/cost/latency metadata still flows:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
OpsVeritas.init('<your-ingest-key>', { metadataOnly: true });
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Or set the environment variable:
|
|
59
|
-
|
|
60
|
-
```bash
|
|
61
|
-
OPSVERITAS_METADATA_ONLY=true
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Reliability
|
|
65
|
-
|
|
66
|
-
Telemetry is **non-blocking and fire-and-forget** — it never throws into your code and never slows your agent. If the ingest endpoint is briefly unreachable, sends are **retried with backoff** and **buffered in memory** (bounded), then flushed on the next event — so a transient outage doesn't lose telemetry.
|
|
67
|
-
|
|
68
|
-
## Configuration
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
OpsVeritas.init(apiKey, {
|
|
72
|
-
endpoint, // optional — defaults to https://agents.opsveritas.com
|
|
73
|
-
metadataOnly, // optional — default false; when true, no response content is sent
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## License
|
|
78
|
-
|
|
79
|
-
MIT
|
|
1
|
+
# opsveritas-sdk
|
|
2
|
+
|
|
3
|
+
Monitor your AI agents in **three lines of code**. Tracks tokens, cost, latency, model, and silent failures (200 OK with empty output) — and routes alerts to Slack / Email / Teams via [OpsVeritas AI Agents Control Tower](https://agents.opsveritas.com).
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install opsveritas-sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick start (3 lines)
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { OpsVeritas } from 'opsveritas-sdk';
|
|
13
|
+
|
|
14
|
+
OpsVeritas.init('<your-ingest-key>'); // key from Settings → Integrations
|
|
15
|
+
const client = OpsVeritas.wrap(new OpenAI(), { agentName: 'Support Bot' });
|
|
16
|
+
// use `client` exactly as before — runs appear in your dashboard automatically
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Works the same for Anthropic and Gemini clients. Prefer manual control? Wrap a function:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
await OpsVeritas.trace('Nightly Report', async () => runReport());
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## LangChain (one line)
|
|
26
|
+
|
|
27
|
+
Attach the handler to any LangChain chat model, LLM or chain — every call reports token / cost / latency / silent-failure automatically:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { ChatOpenAI } from '@langchain/openai';
|
|
31
|
+
import { OpsVeritas } from 'opsveritas-sdk';
|
|
32
|
+
|
|
33
|
+
OpsVeritas.init('<your-ingest-key>');
|
|
34
|
+
const model = new ChatOpenAI({ callbacks: [OpsVeritas.langchain('My Agent')] });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
No extra dependency — it's a plain LangChain callback handler. Works with any LangChain-backed provider (OpenAI, Anthropic, Gemini, Groq…). Inside `OpsVeritas.run(...)` the handler aggregates into a single execution instead of double-counting.
|
|
38
|
+
|
|
39
|
+
## What data is sent
|
|
40
|
+
|
|
41
|
+
By design the SDK sends **metadata only, plus a short output snippet** — never your prompts/inputs:
|
|
42
|
+
|
|
43
|
+
| Sent | Detail |
|
|
44
|
+
|------|--------|
|
|
45
|
+
| ✅ Metadata | agent name, status, timestamps, duration, token counts, model, cost, tool-call count |
|
|
46
|
+
| ⚠️ Output snippet | first 300 chars of the response (`output_summary`) — powers silent-failure detection |
|
|
47
|
+
| ⚠️ Error message | the exception text, if a call fails |
|
|
48
|
+
| ❌ Prompts / inputs | **never sent** — only token counts |
|
|
49
|
+
|
|
50
|
+
### Metadata-only mode (for regulated / client data)
|
|
51
|
+
|
|
52
|
+
Drop the output snippet and redact error text so **no response content ever leaves your environment** — token/cost/latency metadata still flows:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
OpsVeritas.init('<your-ingest-key>', { metadataOnly: true });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Or set the environment variable:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
OPSVERITAS_METADATA_ONLY=true
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Reliability
|
|
65
|
+
|
|
66
|
+
Telemetry is **non-blocking and fire-and-forget** — it never throws into your code and never slows your agent. If the ingest endpoint is briefly unreachable, sends are **retried with backoff** and **buffered in memory** (bounded), then flushed on the next event — so a transient outage doesn't lose telemetry.
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
OpsVeritas.init(apiKey, {
|
|
72
|
+
endpoint, // optional — defaults to https://agents.opsveritas.com
|
|
73
|
+
metadataOnly, // optional — default false; when true, no response content is sent
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -356,17 +356,18 @@ async function trace(agentName, fn, options) {
|
|
|
356
356
|
|
|
357
357
|
// src/wrap.ts
|
|
358
358
|
var PATCHED = /* @__PURE__ */ Symbol("opsveritas.patched");
|
|
359
|
+
var OUTPUT_SUMMARY_MAX = 3e3;
|
|
359
360
|
function extractOutput(resp) {
|
|
360
361
|
if (!resp) return void 0;
|
|
361
362
|
const choices = resp.choices;
|
|
362
363
|
if (Array.isArray(choices) && choices[0]) {
|
|
363
364
|
const content = choices[0].message?.content;
|
|
364
|
-
if (typeof content === "string" && content.trim()) return content.slice(0,
|
|
365
|
+
if (typeof content === "string" && content.trim()) return content.slice(0, OUTPUT_SUMMARY_MAX);
|
|
365
366
|
}
|
|
366
367
|
const blocks = resp.content;
|
|
367
368
|
if (Array.isArray(blocks)) {
|
|
368
369
|
const tb = blocks.find((b) => b.type === "text");
|
|
369
|
-
if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0,
|
|
370
|
+
if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0, OUTPUT_SUMMARY_MAX);
|
|
370
371
|
}
|
|
371
372
|
return void 0;
|
|
372
373
|
}
|
|
@@ -575,7 +576,7 @@ function extractText(output) {
|
|
|
575
576
|
const c = gen?.message?.content;
|
|
576
577
|
if (typeof c === "string") t = c;
|
|
577
578
|
}
|
|
578
|
-
if (typeof t === "string" && t.trim()) return t.slice(0,
|
|
579
|
+
if (typeof t === "string" && t.trim()) return t.slice(0, 3e3);
|
|
579
580
|
}
|
|
580
581
|
}
|
|
581
582
|
} catch {
|
package/dist/index.mjs
CHANGED
|
@@ -324,17 +324,18 @@ async function trace(agentName, fn, options) {
|
|
|
324
324
|
|
|
325
325
|
// src/wrap.ts
|
|
326
326
|
var PATCHED = /* @__PURE__ */ Symbol("opsveritas.patched");
|
|
327
|
+
var OUTPUT_SUMMARY_MAX = 3e3;
|
|
327
328
|
function extractOutput(resp) {
|
|
328
329
|
if (!resp) return void 0;
|
|
329
330
|
const choices = resp.choices;
|
|
330
331
|
if (Array.isArray(choices) && choices[0]) {
|
|
331
332
|
const content = choices[0].message?.content;
|
|
332
|
-
if (typeof content === "string" && content.trim()) return content.slice(0,
|
|
333
|
+
if (typeof content === "string" && content.trim()) return content.slice(0, OUTPUT_SUMMARY_MAX);
|
|
333
334
|
}
|
|
334
335
|
const blocks = resp.content;
|
|
335
336
|
if (Array.isArray(blocks)) {
|
|
336
337
|
const tb = blocks.find((b) => b.type === "text");
|
|
337
|
-
if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0,
|
|
338
|
+
if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0, OUTPUT_SUMMARY_MAX);
|
|
338
339
|
}
|
|
339
340
|
return void 0;
|
|
340
341
|
}
|
|
@@ -543,7 +544,7 @@ function extractText(output) {
|
|
|
543
544
|
const c = gen?.message?.content;
|
|
544
545
|
if (typeof c === "string") t = c;
|
|
545
546
|
}
|
|
546
|
-
if (typeof t === "string" && t.trim()) return t.slice(0,
|
|
547
|
+
if (typeof t === "string" && t.trim()) return t.slice(0, 3e3);
|
|
547
548
|
}
|
|
548
549
|
}
|
|
549
550
|
} catch {
|