@elsium-ai/observe 0.1.6 → 0.2.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/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # @elsium-ai/observe
2
+
3
+ Observability, tracing, cost tracking, and audit trail for [ElsiumAI](https://github.com/elsium-ai/elsium-ai).
4
+
5
+ [![npm](https://img.shields.io/npm/v/@elsium-ai/observe.svg)](https://www.npmjs.com/package/@elsium-ai/observe)
6
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/elsium-ai/elsium-ai/blob/main/LICENSE)
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @elsium-ai/observe @elsium-ai/core
12
+ ```
13
+
14
+ ## What's Inside
15
+
16
+ - **Tracing** — Span-based tracing with nested context propagation
17
+ - **Cost Intelligence** — Budget tracking, projections, and loop detection
18
+ - **Audit Trail** — SHA-256 hash-chained events with tamper-proof integrity verification
19
+ - **Provenance Tracking** — Full lineage per traceId: prompt, model, config, input, output
20
+ - **Audit Middleware** — Drop-in middleware for automatic event recording
21
+
22
+ ## Usage
23
+
24
+ ```typescript
25
+ import { createAuditTrail, auditMiddleware, createProvenanceTracker, observe } from '@elsium-ai/observe'
26
+
27
+ // Hash-chained audit trail
28
+ const audit = createAuditTrail({ hashChain: true })
29
+
30
+ // Provenance tracking
31
+ const provenance = createProvenanceTracker()
32
+ provenance.record({ prompt, model, config, input, output, traceId })
33
+
34
+ // Tracing
35
+ const tracer = observe({ output: [], samplingRate: 1.0 })
36
+ const span = tracer.startSpan('request', 'llm-call')
37
+ // ... do work ...
38
+ span.end()
39
+ ```
40
+
41
+ ## Part of ElsiumAI
42
+
43
+ This package is the observability layer of the [ElsiumAI](https://github.com/elsium-ai/elsium-ai) framework. See the [full documentation](https://github.com/elsium-ai/elsium-ai) for guides and examples.
44
+
45
+ ## License
46
+
47
+ [MIT](https://github.com/elsium-ai/elsium-ai/blob/main/LICENSE)
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- // @bun
2
1
  // ../core/src/errors.ts
3
2
  class ElsiumError extends Error {
4
3
  code;
@@ -89,7 +88,7 @@ class ElsiumError extends Error {
89
88
  }
90
89
  }
91
90
  // ../core/src/utils.ts
92
- import { randomBytes } from "crypto";
91
+ import { randomBytes } from "node:crypto";
93
92
  function cryptoHex(bytes) {
94
93
  return randomBytes(bytes).toString("hex");
95
94
  }
@@ -675,7 +674,7 @@ function createMetrics(options) {
675
674
  };
676
675
  }
677
676
  // src/audit.ts
678
- import { createHash } from "crypto";
677
+ import { createHash } from "node:crypto";
679
678
  function computeEventHash(event, previousHash) {
680
679
  const content = JSON.stringify({
681
680
  id: event.id,
@@ -836,7 +835,7 @@ function auditMiddleware(auditTrail) {
836
835
  };
837
836
  }
838
837
  // src/provenance.ts
839
- import { createHash as createHash2 } from "crypto";
838
+ import { createHash as createHash2 } from "node:crypto";
840
839
  function sha256(input) {
841
840
  return createHash2("sha256").update(input).digest("hex");
842
841
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elsium-ai/observe",
3
- "version": "0.1.6",
3
+ "version": "0.2.0",
4
4
  "description": "Observability, tracing, and cost tracking for ElsiumAI",
5
5
  "license": "MIT",
6
6
  "author": "Eric Utrera <ebutrera9103@gmail.com>",
@@ -22,14 +22,13 @@
22
22
  "dist"
23
23
  ],
24
24
  "scripts": {
25
- "build": "bun build ./src/index.ts --outdir ./dist --target bun && bun x tsc -p tsconfig.build.json --emitDeclarationOnly",
25
+ "build": "bun build ./src/index.ts --outdir ./dist --target node && bun x tsc -p tsconfig.build.json --emitDeclarationOnly",
26
26
  "dev": "bun --watch src/index.ts"
27
27
  },
28
28
  "dependencies": {
29
29
  "@elsium-ai/core": "workspace:*"
30
30
  },
31
31
  "devDependencies": {
32
- "bun-types": "^1.3.0",
33
32
  "typescript": "^5.7.0"
34
33
  }
35
34
  }