lightrace 0.1.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 +93 -0
- package/dist/client.d.ts +71 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +116 -0
- package/dist/client.js.map +1 -0
- package/dist/exporter.d.ts +31 -0
- package/dist/exporter.d.ts.map +1 -0
- package/dist/exporter.js +88 -0
- package/dist/exporter.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/langchain.d.ts +74 -0
- package/dist/integrations/langchain.d.ts.map +1 -0
- package/dist/integrations/langchain.js +337 -0
- package/dist/integrations/langchain.js.map +1 -0
- package/dist/observation.d.ts +58 -0
- package/dist/observation.d.ts.map +1 -0
- package/dist/observation.js +105 -0
- package/dist/observation.js.map +1 -0
- package/dist/security.d.ts +20 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +46 -0
- package/dist/security.js.map +1 -0
- package/dist/tool-client.d.ts +32 -0
- package/dist/tool-client.d.ts.map +1 -0
- package/dist/tool-client.js +186 -0
- package/dist/tool-client.js.map +1 -0
- package/dist/trace.d.ts +25 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +163 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +85 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +66 -0
- package/dist/utils.js.map +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lightrace Contributors
|
|
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,93 @@
|
|
|
1
|
+
# lightrace-js
|
|
2
|
+
|
|
3
|
+
Lightweight LLM tracing SDK for TypeScript/JavaScript with remote tool invocation.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
yarn add lightrace
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { Lightrace, trace } from "lightrace";
|
|
15
|
+
|
|
16
|
+
const lt = new Lightrace({
|
|
17
|
+
publicKey: "pk-lt-demo",
|
|
18
|
+
secretKey: "sk-lt-demo",
|
|
19
|
+
host: "http://localhost:3002",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
// Root trace
|
|
23
|
+
const runAgent = trace("run-agent", async (query: string) => {
|
|
24
|
+
const results = await search(query);
|
|
25
|
+
return results;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Span
|
|
29
|
+
const search = trace("search", { type: "span" }, async (query: string) => {
|
|
30
|
+
return ["result1", "result2"];
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Generation (LLM call)
|
|
34
|
+
const generate = trace(
|
|
35
|
+
"generate",
|
|
36
|
+
{ type: "generation", model: "gpt-4o" },
|
|
37
|
+
async (prompt: string) => {
|
|
38
|
+
return "LLM response";
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// Tool — remotely invocable from the Lightrace UI
|
|
43
|
+
const weatherLookup = trace("weather", { type: "tool" }, async (input: { city: string }) => {
|
|
44
|
+
return { temp: 72, unit: "F" };
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// Tool — traced but NOT remotely invocable
|
|
48
|
+
const readFile = trace("read-file", { type: "tool", invoke: false }, async (path: string) => {
|
|
49
|
+
return "file contents";
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
await runAgent("hello");
|
|
53
|
+
lt.flush();
|
|
54
|
+
await lt.shutdown();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## `trace()` API
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Root trace (no options)
|
|
61
|
+
trace(name, fn);
|
|
62
|
+
|
|
63
|
+
// With options
|
|
64
|
+
trace(name, options, fn);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Options
|
|
68
|
+
|
|
69
|
+
| Option | Type | Default | Description |
|
|
70
|
+
| ------------- | --------- | ----------- | -------------------------------------------------------- |
|
|
71
|
+
| `type` | `string` | `undefined` | `"span"`, `"generation"`, `"tool"`, `"chain"`, `"event"` |
|
|
72
|
+
| `invoke` | `boolean` | `true` | For `type: "tool"`: register for remote invocation |
|
|
73
|
+
| `model` | `string` | `undefined` | For `type: "generation"`: LLM model name |
|
|
74
|
+
| `inputSchema` | `ZodType` | `undefined` | Optional Zod schema for tool input |
|
|
75
|
+
| `metadata` | `Record` | `undefined` | Static metadata attached to every call |
|
|
76
|
+
|
|
77
|
+
## Compatibility
|
|
78
|
+
|
|
79
|
+
Lightrace server also accepts traces from Langfuse Python/JS SDKs.
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
yarn install
|
|
85
|
+
yarn test
|
|
86
|
+
yarn typecheck
|
|
87
|
+
yarn lint
|
|
88
|
+
yarn format
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Lightrace SDK client.
|
|
3
|
+
*/
|
|
4
|
+
import { BatchExporter } from "./exporter.js";
|
|
5
|
+
import { Observation } from "./observation.js";
|
|
6
|
+
import type { UsageDetails } from "./types.js";
|
|
7
|
+
export interface LightraceOptions {
|
|
8
|
+
publicKey?: string;
|
|
9
|
+
secretKey?: string;
|
|
10
|
+
host?: string;
|
|
11
|
+
flushAt?: number;
|
|
12
|
+
flushInterval?: number;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
/** Default user ID for all traces. */
|
|
16
|
+
userId?: string;
|
|
17
|
+
/** Default session ID for all traces. */
|
|
18
|
+
sessionId?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class Lightrace {
|
|
21
|
+
private static instance;
|
|
22
|
+
private exporter;
|
|
23
|
+
private enabled;
|
|
24
|
+
private host;
|
|
25
|
+
private publicKey;
|
|
26
|
+
private secretKey;
|
|
27
|
+
/** Default user ID for all traces. */
|
|
28
|
+
readonly userId: string | undefined;
|
|
29
|
+
/** Default session ID for all traces. */
|
|
30
|
+
readonly sessionId: string | undefined;
|
|
31
|
+
constructor(options?: LightraceOptions);
|
|
32
|
+
static getInstance(): Lightrace | null;
|
|
33
|
+
/** Get the exporter (used by Observation). */
|
|
34
|
+
getExporter(): BatchExporter | null;
|
|
35
|
+
flush(): void;
|
|
36
|
+
shutdown(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Create a span observation imperatively.
|
|
39
|
+
*/
|
|
40
|
+
span(opts: {
|
|
41
|
+
name: string;
|
|
42
|
+
input?: unknown;
|
|
43
|
+
metadata?: Record<string, unknown>;
|
|
44
|
+
traceId?: string;
|
|
45
|
+
parentObservationId?: string;
|
|
46
|
+
}): Observation;
|
|
47
|
+
/**
|
|
48
|
+
* Create a generation observation imperatively.
|
|
49
|
+
*/
|
|
50
|
+
generation(opts: {
|
|
51
|
+
name: string;
|
|
52
|
+
input?: unknown;
|
|
53
|
+
model?: string;
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
usage?: UsageDetails;
|
|
56
|
+
traceId?: string;
|
|
57
|
+
parentObservationId?: string;
|
|
58
|
+
}): Observation;
|
|
59
|
+
/**
|
|
60
|
+
* Create an event observation imperatively (auto-ended).
|
|
61
|
+
*/
|
|
62
|
+
event(opts: {
|
|
63
|
+
name: string;
|
|
64
|
+
input?: unknown;
|
|
65
|
+
metadata?: Record<string, unknown>;
|
|
66
|
+
traceId?: string;
|
|
67
|
+
parentObservationId?: string;
|
|
68
|
+
}): Observation;
|
|
69
|
+
private _createObservation;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,MAAM,C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AAK,CAAC,EAAE,OAAO,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,KAAK,CAAC,EAAE,YAAY,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,WAAW;IAIf;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE;QACV,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACnC,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,GAAG,WAAW;IAMf,OAAO,CAAC,kBAAkB;CAqD3B"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Lightrace SDK client.
|
|
3
|
+
*/
|
|
4
|
+
import { BatchExporter } from "./exporter.js";
|
|
5
|
+
import { _setExporter, _setClientDefaults, _getTraceContext } from "./trace.js";
|
|
6
|
+
import { Observation } from "./observation.js";
|
|
7
|
+
import { generateId } from "./utils.js";
|
|
8
|
+
export class Lightrace {
|
|
9
|
+
static instance = null;
|
|
10
|
+
exporter = null;
|
|
11
|
+
enabled;
|
|
12
|
+
host;
|
|
13
|
+
publicKey;
|
|
14
|
+
secretKey;
|
|
15
|
+
/** Default user ID for all traces. */
|
|
16
|
+
userId;
|
|
17
|
+
/** Default session ID for all traces. */
|
|
18
|
+
sessionId;
|
|
19
|
+
constructor(options = {}) {
|
|
20
|
+
this.publicKey = options.publicKey ?? process.env.LIGHTRACE_PUBLIC_KEY ?? "";
|
|
21
|
+
this.secretKey = options.secretKey ?? process.env.LIGHTRACE_SECRET_KEY ?? "";
|
|
22
|
+
this.host = (options.host ?? process.env.LIGHTRACE_HOST ?? "http://localhost:3002").replace(/\/$/, "");
|
|
23
|
+
this.enabled = options.enabled !== false;
|
|
24
|
+
this.userId = options.userId;
|
|
25
|
+
this.sessionId = options.sessionId;
|
|
26
|
+
if (!this.enabled)
|
|
27
|
+
return;
|
|
28
|
+
this.exporter = new BatchExporter({
|
|
29
|
+
host: this.host,
|
|
30
|
+
publicKey: this.publicKey,
|
|
31
|
+
secretKey: this.secretKey,
|
|
32
|
+
flushAt: options.flushAt,
|
|
33
|
+
flushInterval: options.flushInterval,
|
|
34
|
+
timeout: options.timeout,
|
|
35
|
+
});
|
|
36
|
+
_setExporter(this.exporter);
|
|
37
|
+
_setClientDefaults({ userId: this.userId, sessionId: this.sessionId });
|
|
38
|
+
Lightrace.instance = this;
|
|
39
|
+
}
|
|
40
|
+
static getInstance() {
|
|
41
|
+
return Lightrace.instance;
|
|
42
|
+
}
|
|
43
|
+
/** Get the exporter (used by Observation). */
|
|
44
|
+
getExporter() {
|
|
45
|
+
return this.exporter;
|
|
46
|
+
}
|
|
47
|
+
flush() {
|
|
48
|
+
this.exporter?.flush();
|
|
49
|
+
}
|
|
50
|
+
async shutdown() {
|
|
51
|
+
if (this.exporter) {
|
|
52
|
+
await this.exporter.shutdown();
|
|
53
|
+
_setExporter(null);
|
|
54
|
+
}
|
|
55
|
+
Lightrace.instance = null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Create a span observation imperatively.
|
|
59
|
+
*/
|
|
60
|
+
span(opts) {
|
|
61
|
+
return this._createObservation("span", opts);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Create a generation observation imperatively.
|
|
65
|
+
*/
|
|
66
|
+
generation(opts) {
|
|
67
|
+
return this._createObservation("generation", opts);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create an event observation imperatively (auto-ended).
|
|
71
|
+
*/
|
|
72
|
+
event(opts) {
|
|
73
|
+
const obs = this._createObservation("event", opts);
|
|
74
|
+
obs.end();
|
|
75
|
+
return obs;
|
|
76
|
+
}
|
|
77
|
+
_createObservation(type, opts) {
|
|
78
|
+
const exporter = this.exporter;
|
|
79
|
+
// Resolve trace context: explicit > ALS context > create new root trace
|
|
80
|
+
const ctx = _getTraceContext();
|
|
81
|
+
let traceId = opts.traceId ?? ctx?.traceId;
|
|
82
|
+
const parentObservationId = opts.parentObservationId ?? ctx?.observationId ?? undefined;
|
|
83
|
+
// If no trace context, create an implicit root trace
|
|
84
|
+
if (!traceId) {
|
|
85
|
+
traceId = generateId();
|
|
86
|
+
// Emit root trace event
|
|
87
|
+
if (exporter) {
|
|
88
|
+
exporter.enqueue({
|
|
89
|
+
id: generateId(),
|
|
90
|
+
type: "trace-create",
|
|
91
|
+
timestamp: new Date().toISOString(),
|
|
92
|
+
body: {
|
|
93
|
+
id: traceId,
|
|
94
|
+
name: opts.name,
|
|
95
|
+
timestamp: new Date().toISOString(),
|
|
96
|
+
userId: this.userId,
|
|
97
|
+
sessionId: this.sessionId,
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const obs = new Observation({
|
|
103
|
+
traceId,
|
|
104
|
+
type,
|
|
105
|
+
name: opts.name,
|
|
106
|
+
exporter,
|
|
107
|
+
input: opts.input,
|
|
108
|
+
model: opts.model,
|
|
109
|
+
metadata: opts.metadata,
|
|
110
|
+
usage: opts.usage,
|
|
111
|
+
parentObservationId: parentObservationId ?? undefined,
|
|
112
|
+
});
|
|
113
|
+
return obs;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC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,EAAE,CAAC;QAC/B,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,GAAG,EAAE,OAAO,CAAC;QAC3C,MAAM,mBAAmB,GAAG,IAAI,CAAC,mBAAmB,IAAI,GAAG,EAAE,aAAa,IAAI,SAAS,CAAC;QAExF,qDAAqD;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO,GAAG,UAAU,EAAE,CAAC;YACvB,wBAAwB;YACxB,IAAI,QAAQ,EAAE,CAAC;gBACb,QAAQ,CAAC,OAAO,CAAC;oBACf,EAAE,EAAE,UAAU,EAAE;oBAChB,IAAI,EAAE,cAAc;oBACpB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;oBACnC,IAAI,EAAE;wBACJ,EAAE,EAAE,OAAO;wBACX,IAAI,EAAE,IAAI,CAAC,IAAI;wBACf,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;wBACnC,MAAM,EAAE,IAAI,CAAC,MAAM;wBACnB,SAAS,EAAE,IAAI,CAAC,SAAS;qBAC1B;iBACF,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC;YAC1B,OAAO;YACP,IAAI;YACJ,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ;YACR,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,mBAAmB,EAAE,mBAAmB,IAAI,SAAS;SACtD,CAAC,CAAC;QAEH,OAAO,GAAG,CAAC;IACb,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { TraceEvent } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Batch exporter that sends events to the lightrace ingestion endpoint.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BatchExporter {
|
|
6
|
+
private queue;
|
|
7
|
+
private endpoint;
|
|
8
|
+
private authHeader;
|
|
9
|
+
private flushAt;
|
|
10
|
+
private flushInterval;
|
|
11
|
+
private timeout;
|
|
12
|
+
private maxRetries;
|
|
13
|
+
private timer;
|
|
14
|
+
private running;
|
|
15
|
+
constructor(options: {
|
|
16
|
+
host: string;
|
|
17
|
+
publicKey: string;
|
|
18
|
+
secretKey: string;
|
|
19
|
+
flushAt?: number;
|
|
20
|
+
flushInterval?: number;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
maxRetries?: number;
|
|
23
|
+
});
|
|
24
|
+
enqueue(event: TraceEvent): void;
|
|
25
|
+
flush(): void;
|
|
26
|
+
shutdown(): Promise<void>;
|
|
27
|
+
private doFlush;
|
|
28
|
+
private sendWithRetry;
|
|
29
|
+
private delay;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=exporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exporter.d.ts","sourceRoot":"","sources":["../src/exporter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,KAAK,CAA+C;IAC5D,OAAO,CAAC,OAAO,CAAQ;gBAEX,OAAO,EAAE;QACnB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB;IAmBD,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAOhC,KAAK,IAAI,IAAI;IAIP,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAS/B,OAAO,CAAC,OAAO;YASD,aAAa;IA8B3B,OAAO,CAAC,KAAK;CAGd"}
|
package/dist/exporter.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch exporter that sends events to the lightrace ingestion endpoint.
|
|
3
|
+
*/
|
|
4
|
+
export class BatchExporter {
|
|
5
|
+
queue = [];
|
|
6
|
+
endpoint;
|
|
7
|
+
authHeader;
|
|
8
|
+
flushAt;
|
|
9
|
+
flushInterval;
|
|
10
|
+
timeout;
|
|
11
|
+
maxRetries;
|
|
12
|
+
timer = null;
|
|
13
|
+
running = true;
|
|
14
|
+
constructor(options) {
|
|
15
|
+
const host = options.host.replace(/\/$/, "");
|
|
16
|
+
this.endpoint = `${host}/api/public/ingestion`;
|
|
17
|
+
this.authHeader = `Basic ${btoa(`${options.publicKey}:${options.secretKey}`)}`;
|
|
18
|
+
this.flushAt = options.flushAt ?? 50;
|
|
19
|
+
this.flushInterval = options.flushInterval ?? 5.0;
|
|
20
|
+
this.timeout = options.timeout ?? 10_000;
|
|
21
|
+
this.maxRetries = options.maxRetries ?? 2;
|
|
22
|
+
this.timer = setInterval(() => {
|
|
23
|
+
if (this.running)
|
|
24
|
+
this.doFlush();
|
|
25
|
+
}, this.flushInterval * 1000);
|
|
26
|
+
// Don't keep the process alive just for flushing
|
|
27
|
+
if (this.timer && typeof this.timer === "object" && "unref" in this.timer) {
|
|
28
|
+
this.timer.unref();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
enqueue(event) {
|
|
32
|
+
this.queue.push(event);
|
|
33
|
+
if (this.queue.length >= this.flushAt) {
|
|
34
|
+
this.doFlush();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
flush() {
|
|
38
|
+
this.doFlush();
|
|
39
|
+
}
|
|
40
|
+
async shutdown() {
|
|
41
|
+
this.running = false;
|
|
42
|
+
if (this.timer) {
|
|
43
|
+
clearInterval(this.timer);
|
|
44
|
+
this.timer = null;
|
|
45
|
+
}
|
|
46
|
+
this.doFlush();
|
|
47
|
+
}
|
|
48
|
+
doFlush() {
|
|
49
|
+
if (this.queue.length === 0)
|
|
50
|
+
return;
|
|
51
|
+
const batch = this.queue.splice(0);
|
|
52
|
+
const payload = { batch };
|
|
53
|
+
// Fire and forget with retry
|
|
54
|
+
this.sendWithRetry(payload, 0);
|
|
55
|
+
}
|
|
56
|
+
async sendWithRetry(payload, attempt) {
|
|
57
|
+
try {
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
60
|
+
const resp = await fetch(this.endpoint, {
|
|
61
|
+
method: "POST",
|
|
62
|
+
headers: {
|
|
63
|
+
Authorization: this.authHeader,
|
|
64
|
+
"Content-Type": "application/json",
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(payload),
|
|
67
|
+
signal: controller.signal,
|
|
68
|
+
});
|
|
69
|
+
clearTimeout(timeoutId);
|
|
70
|
+
if (resp.ok || resp.status < 500)
|
|
71
|
+
return;
|
|
72
|
+
if (attempt < this.maxRetries) {
|
|
73
|
+
await this.delay(2 ** attempt * 1000);
|
|
74
|
+
return this.sendWithRetry(payload, attempt + 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
if (attempt < this.maxRetries) {
|
|
79
|
+
await this.delay(2 ** attempt * 1000);
|
|
80
|
+
return this.sendWithRetry(payload, attempt + 1);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
delay(ms) {
|
|
85
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL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oBACP,aAAa,EAAE,IAAI,CAAC,UAAU;oBAC9B,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBAC7B,MAAM,EAAE,UAAU,CAAC,MAAM;aAC1B,CAAC,CAAC;YAEH,YAAY,CAAC,SAAS,CAAC,CAAC;YAExB,IAAI,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG;gBAAE,OAAO;YACzC,IAAI,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC;gBACtC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;gBAC9B,MAAM,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,OAAO,GAAG,IAAI,CAAC,CAAC;gBACtC,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Lightrace } from "./client.js";
|
|
2
|
+
export type { LightraceOptions } from "./client.js";
|
|
3
|
+
export { trace } from "./trace.js";
|
|
4
|
+
export { Observation } from "./observation.js";
|
|
5
|
+
export type { TraceOptions, ObservationType, UsageDetails } from "./types.js";
|
|
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,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangChain/LangGraph integration for Lightrace.
|
|
3
|
+
*
|
|
4
|
+
* Extends `BaseCallbackHandler` from `@langchain/core` to automatically
|
|
5
|
+
* capture chains, LLM calls, tool invocations, and retriever operations
|
|
6
|
+
* as Lightrace trace observations.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { LightraceCallbackHandler } from "lightrace/integrations/langchain";
|
|
11
|
+
*
|
|
12
|
+
* const handler = new LightraceCallbackHandler({ userId: "user-123" });
|
|
13
|
+
* const result = await chain.invoke(inputs, { callbacks: [handler] });
|
|
14
|
+
* console.log(handler.lastTraceId);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
import { BaseCallbackHandler } from "@langchain/core/callbacks/base";
|
|
18
|
+
import type { Serialized } from "@langchain/core/load/serializable";
|
|
19
|
+
import type { LLMResult } from "@langchain/core/outputs";
|
|
20
|
+
import type { BaseMessage } from "@langchain/core/messages";
|
|
21
|
+
import type { DocumentInterface } from "@langchain/core/documents";
|
|
22
|
+
import { Lightrace } from "../client.js";
|
|
23
|
+
export interface LightraceCallbackHandlerOptions {
|
|
24
|
+
/** User ID to attach to the root trace. */
|
|
25
|
+
userId?: string;
|
|
26
|
+
/** Session ID to attach to the root trace. */
|
|
27
|
+
sessionId?: string;
|
|
28
|
+
/** Override name for the root trace. */
|
|
29
|
+
traceName?: string;
|
|
30
|
+
/** Additional metadata to attach to the root trace. */
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
/** Provide a Lightrace client instance. If omitted, uses Lightrace.getInstance(). */
|
|
33
|
+
client?: Lightrace;
|
|
34
|
+
}
|
|
35
|
+
export declare class LightraceCallbackHandler extends BaseCallbackHandler {
|
|
36
|
+
name: string;
|
|
37
|
+
private runs;
|
|
38
|
+
private runParents;
|
|
39
|
+
private completionStartTimes;
|
|
40
|
+
private rootRunId;
|
|
41
|
+
private _traceId;
|
|
42
|
+
private userId?;
|
|
43
|
+
private sessionId?;
|
|
44
|
+
private traceName?;
|
|
45
|
+
private rootMetadata?;
|
|
46
|
+
private exporter;
|
|
47
|
+
/** The trace ID from the most recently completed root run. */
|
|
48
|
+
lastTraceId: string | null;
|
|
49
|
+
constructor(opts?: LightraceCallbackHandlerOptions);
|
|
50
|
+
private getParentObservationId;
|
|
51
|
+
private emit;
|
|
52
|
+
private emitObservation;
|
|
53
|
+
private extractModelName;
|
|
54
|
+
private isAgent;
|
|
55
|
+
private registerRun;
|
|
56
|
+
private endRun;
|
|
57
|
+
handleChainStart(chain: Serialized, inputs: Record<string, unknown>, runId: string, parentRunId?: string, tags?: string[], metadata?: Record<string, unknown>): Promise<void>;
|
|
58
|
+
handleChainEnd(outputs: Record<string, unknown>, runId: string, _parentRunId?: string): Promise<void>;
|
|
59
|
+
handleChainError(error: Error, runId: string, _parentRunId?: string): Promise<void>;
|
|
60
|
+
handleLLMStart(llm: Serialized, prompts: string[], runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, _tags?: string[], metadata?: Record<string, unknown>): Promise<void>;
|
|
61
|
+
handleChatModelStart(llm: Serialized, messages: BaseMessage[][], runId: string, parentRunId?: string, _extraParams?: Record<string, unknown>, _tags?: string[], metadata?: Record<string, unknown>): Promise<void>;
|
|
62
|
+
handleLLMEnd(output: LLMResult, runId: string, _parentRunId?: string): Promise<void>;
|
|
63
|
+
handleLLMNewToken(_token: string, _idx: unknown, runId: string): Promise<void>;
|
|
64
|
+
handleLLMError(error: Error, runId: string, _parentRunId?: string): Promise<void>;
|
|
65
|
+
handleToolStart(tool: Serialized, input: string, runId: string, parentRunId?: string, _tags?: string[], metadata?: Record<string, unknown>): Promise<void>;
|
|
66
|
+
handleToolEnd(output: string, runId: string, _parentRunId?: string): Promise<void>;
|
|
67
|
+
handleToolError(error: Error, runId: string, _parentRunId?: string): Promise<void>;
|
|
68
|
+
handleRetrieverStart(retriever: Serialized, query: string, runId: string, parentRunId?: string, _tags?: string[], metadata?: Record<string, unknown>): Promise<void>;
|
|
69
|
+
handleRetrieverEnd(documents: DocumentInterface[], runId: string, _parentRunId?: string): Promise<void>;
|
|
70
|
+
handleRetrieverError(error: Error, runId: string, _parentRunId?: string): Promise<void>;
|
|
71
|
+
/** Get the current active trace ID (null if no run is active). */
|
|
72
|
+
get traceId(): string | null;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=langchain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain.d.ts","sourceRoot":"","sources":["../../src/integrations/langchain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,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