opsveritas-sdk 0.3.0 → 0.3.2

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 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.d.mts CHANGED
@@ -56,6 +56,8 @@ interface ExecutionPayload {
56
56
  error_message?: string | null;
57
57
  user_id?: string;
58
58
  output_summary?: string;
59
+ /** Set automatically by the SDK so the server can identify SDK vs raw-webhook ingestion. Not user-configurable. */
60
+ source?: 'sdk';
59
61
  }
60
62
 
61
63
  declare const OpsVeritas: {
package/dist/index.d.ts CHANGED
@@ -56,6 +56,8 @@ interface ExecutionPayload {
56
56
  error_message?: string | null;
57
57
  user_id?: string;
58
58
  output_summary?: string;
59
+ /** Set automatically by the SDK so the server can identify SDK vs raw-webhook ingestion. Not user-configurable. */
60
+ source?: 'sdk';
59
61
  }
60
62
 
61
63
  declare const OpsVeritas: {
package/dist/index.js CHANGED
@@ -117,7 +117,8 @@ async function sendExecution(payload) {
117
117
  return;
118
118
  }
119
119
  const { apiKey, endpoint, metadataOnly } = cfg;
120
- const body = metadataOnly ? scrubForMetadataOnly(payload) : payload;
120
+ const base = metadataOnly ? scrubForMetadataOnly(payload) : payload;
121
+ const body = { ...base, source: "sdk" };
121
122
  void flush(endpoint, apiKey);
122
123
  const ok = await deliver(endpoint, apiKey, body);
123
124
  if (!ok) enqueue(body);
@@ -356,17 +357,18 @@ async function trace(agentName, fn, options) {
356
357
 
357
358
  // src/wrap.ts
358
359
  var PATCHED = /* @__PURE__ */ Symbol("opsveritas.patched");
360
+ var OUTPUT_SUMMARY_MAX = 3e3;
359
361
  function extractOutput(resp) {
360
362
  if (!resp) return void 0;
361
363
  const choices = resp.choices;
362
364
  if (Array.isArray(choices) && choices[0]) {
363
365
  const content = choices[0].message?.content;
364
- if (typeof content === "string" && content.trim()) return content.slice(0, 300);
366
+ if (typeof content === "string" && content.trim()) return content.slice(0, OUTPUT_SUMMARY_MAX);
365
367
  }
366
368
  const blocks = resp.content;
367
369
  if (Array.isArray(blocks)) {
368
370
  const tb = blocks.find((b) => b.type === "text");
369
- if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0, 300);
371
+ if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0, OUTPUT_SUMMARY_MAX);
370
372
  }
371
373
  return void 0;
372
374
  }
@@ -575,7 +577,7 @@ function extractText(output) {
575
577
  const c = gen?.message?.content;
576
578
  if (typeof c === "string") t = c;
577
579
  }
578
- if (typeof t === "string" && t.trim()) return t.slice(0, 300);
580
+ if (typeof t === "string" && t.trim()) return t.slice(0, 3e3);
579
581
  }
580
582
  }
581
583
  } catch {
package/dist/index.mjs CHANGED
@@ -85,7 +85,8 @@ async function sendExecution(payload) {
85
85
  return;
86
86
  }
87
87
  const { apiKey, endpoint, metadataOnly } = cfg;
88
- const body = metadataOnly ? scrubForMetadataOnly(payload) : payload;
88
+ const base = metadataOnly ? scrubForMetadataOnly(payload) : payload;
89
+ const body = { ...base, source: "sdk" };
89
90
  void flush(endpoint, apiKey);
90
91
  const ok = await deliver(endpoint, apiKey, body);
91
92
  if (!ok) enqueue(body);
@@ -324,17 +325,18 @@ async function trace(agentName, fn, options) {
324
325
 
325
326
  // src/wrap.ts
326
327
  var PATCHED = /* @__PURE__ */ Symbol("opsveritas.patched");
328
+ var OUTPUT_SUMMARY_MAX = 3e3;
327
329
  function extractOutput(resp) {
328
330
  if (!resp) return void 0;
329
331
  const choices = resp.choices;
330
332
  if (Array.isArray(choices) && choices[0]) {
331
333
  const content = choices[0].message?.content;
332
- if (typeof content === "string" && content.trim()) return content.slice(0, 300);
334
+ if (typeof content === "string" && content.trim()) return content.slice(0, OUTPUT_SUMMARY_MAX);
333
335
  }
334
336
  const blocks = resp.content;
335
337
  if (Array.isArray(blocks)) {
336
338
  const tb = blocks.find((b) => b.type === "text");
337
- if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0, 300);
339
+ if (typeof tb?.text === "string" && tb.text.trim()) return tb.text.slice(0, OUTPUT_SUMMARY_MAX);
338
340
  }
339
341
  return void 0;
340
342
  }
@@ -543,7 +545,7 @@ function extractText(output) {
543
545
  const c = gen?.message?.content;
544
546
  if (typeof c === "string") t = c;
545
547
  }
546
- if (typeof t === "string" && t.trim()) return t.slice(0, 300);
548
+ if (typeof t === "string" && t.trim()) return t.slice(0, 3e3);
547
549
  }
548
550
  }
549
551
  } catch {
package/package.json CHANGED
@@ -1,57 +1,57 @@
1
- {
2
- "name": "opsveritas-sdk",
3
- "version": "0.3.0",
4
- "description": "Monitor your AI agents in 3 lines of code — tokens, cost, latency, and silent failures",
5
- "main": "dist/index.js",
6
- "module": "dist/index.mjs",
7
- "types": "dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.js",
12
- "types": "./dist/index.d.ts"
13
- }
14
- },
15
- "files": [
16
- "dist"
17
- ],
18
- "scripts": {
19
- "build": "tsup src/index.ts --format esm,cjs --dts --clean",
20
- "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
21
- "test": "jest"
22
- },
23
- "devDependencies": {
24
- "@types/jest": "^29.5.12",
25
- "@types/node": "^20.14.0",
26
- "jest": "^29.7.0",
27
- "ts-jest": "^29.1.5",
28
- "tsup": "^8.1.0",
29
- "typescript": "^5.4.5"
30
- },
31
- "peerDependencies": {
32
- "@anthropic-ai/sdk": ">=0.20.0",
33
- "@langchain/core": ">=0.2.0",
34
- "openai": ">=4.0.0"
35
- },
36
- "peerDependenciesMeta": {
37
- "@anthropic-ai/sdk": {
38
- "optional": true
39
- },
40
- "@langchain/core": {
41
- "optional": true
42
- },
43
- "openai": {
44
- "optional": true
45
- }
46
- },
47
- "keywords": [
48
- "ai",
49
- "agents",
50
- "monitoring",
51
- "observability",
52
- "openai",
53
- "anthropic",
54
- "langchain"
55
- ],
56
- "license": "MIT"
57
- }
1
+ {
2
+ "name": "opsveritas-sdk",
3
+ "version": "0.3.2",
4
+ "description": "Monitor your AI agents in 3 lines of code — tokens, cost, latency, and silent failures",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean",
20
+ "dev": "tsup src/index.ts --format esm,cjs --dts --watch",
21
+ "test": "jest"
22
+ },
23
+ "devDependencies": {
24
+ "@types/jest": "^29.5.12",
25
+ "@types/node": "^20.14.0",
26
+ "jest": "^29.7.0",
27
+ "ts-jest": "^29.1.5",
28
+ "tsup": "^8.1.0",
29
+ "typescript": "^5.4.5"
30
+ },
31
+ "peerDependencies": {
32
+ "@anthropic-ai/sdk": ">=0.20.0",
33
+ "@langchain/core": ">=0.2.0",
34
+ "openai": ">=4.0.0"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "@anthropic-ai/sdk": {
38
+ "optional": true
39
+ },
40
+ "@langchain/core": {
41
+ "optional": true
42
+ },
43
+ "openai": {
44
+ "optional": true
45
+ }
46
+ },
47
+ "keywords": [
48
+ "ai",
49
+ "agents",
50
+ "monitoring",
51
+ "observability",
52
+ "openai",
53
+ "anthropic",
54
+ "langchain"
55
+ ],
56
+ "license": "MIT"
57
+ }