@uselemma/tracing 7.14.0 → 7.15.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 +73 -17
- package/dist/client.d.ts +49 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +204 -73
- package/dist/client.js.map +1 -1
- package/dist/coding-agent-backlog.d.ts +81 -0
- package/dist/coding-agent-backlog.d.ts.map +1 -0
- package/dist/coding-agent-backlog.js +239 -0
- package/dist/coding-agent-backlog.js.map +1 -0
- package/dist/coding-agent-delivery.d.ts +31 -0
- package/dist/coding-agent-delivery.d.ts.map +1 -0
- package/dist/coding-agent-delivery.js +97 -0
- package/dist/coding-agent-delivery.js.map +1 -0
- package/dist/coding-agent-queue.d.ts +74 -0
- package/dist/coding-agent-queue.d.ts.map +1 -0
- package/dist/coding-agent-queue.js +230 -0
- package/dist/coding-agent-queue.js.map +1 -0
- package/dist/coding-agent.d.ts +14 -0
- package/dist/coding-agent.d.ts.map +1 -1
- package/dist/coding-agent.js +52 -15
- package/dist/coding-agent.js.map +1 -1
- package/dist/debug-mode.d.ts.map +1 -1
- package/dist/debug-mode.js +4 -4
- package/dist/debug-mode.js.map +1 -1
- package/dist/delivery.d.ts +50 -7
- package/dist/delivery.d.ts.map +1 -1
- package/dist/delivery.js +117 -21
- package/dist/delivery.js.map +1 -1
- package/dist/env.d.ts +8 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +18 -0
- package/dist/env.js.map +1 -0
- package/dist/error-message.d.ts +10 -0
- package/dist/error-message.d.ts.map +1 -1
- package/dist/error-message.js +14 -0
- package/dist/error-message.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/integration-client.d.ts +20 -0
- package/dist/integration-client.d.ts.map +1 -0
- package/dist/integration-client.js +47 -0
- package/dist/integration-client.js.map +1 -0
- package/dist/langchain-context.d.ts +7 -0
- package/dist/langchain-context.d.ts.map +1 -0
- package/dist/langchain-context.js +28 -0
- package/dist/langchain-context.js.map +1 -0
- package/dist/langchain-eviction.d.ts +42 -0
- package/dist/langchain-eviction.d.ts.map +1 -0
- package/dist/langchain-eviction.js +56 -0
- package/dist/langchain-eviction.js.map +1 -0
- package/dist/langchain.d.ts +31 -13
- package/dist/langchain.d.ts.map +1 -1
- package/dist/langchain.js +74 -109
- package/dist/langchain.js.map +1 -1
- package/dist/mastra.d.ts +9 -11
- package/dist/mastra.d.ts.map +1 -1
- package/dist/mastra.js +40 -25
- package/dist/mastra.js.map +1 -1
- package/dist/openai-agents.d.ts +8 -0
- package/dist/openai-agents.d.ts.map +1 -1
- package/dist/openai-agents.js +17 -14
- package/dist/openai-agents.js.map +1 -1
- package/dist/serialize.d.ts +17 -0
- package/dist/serialize.d.ts.map +1 -0
- package/dist/serialize.js +143 -0
- package/dist/serialize.js.map +1 -0
- package/dist/stream-result.d.ts +33 -0
- package/dist/stream-result.d.ts.map +1 -0
- package/dist/stream-result.js +135 -0
- package/dist/stream-result.js.map +1 -0
- package/dist/vercel-ai-events.d.ts +308 -0
- package/dist/vercel-ai-events.d.ts.map +1 -0
- package/dist/vercel-ai-events.js +340 -0
- package/dist/vercel-ai-events.js.map +1 -0
- package/dist/vercel-ai-run.d.ts +171 -0
- package/dist/vercel-ai-run.d.ts.map +1 -0
- package/dist/vercel-ai-run.js +650 -0
- package/dist/vercel-ai-run.js.map +1 -0
- package/dist/vercel-ai.d.ts +36 -108
- package/dist/vercel-ai.d.ts.map +1 -1
- package/dist/vercel-ai.js +185 -882
- package/dist/vercel-ai.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/examples/vercel-ai-v6.ts +2 -2
- package/examples/vercel-ai-v7.ts +14 -16
- package/package.json +1 -1
package/dist/delivery.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.INGEST_RETRY_MAX_DELAY_MS = exports.INGEST_RETRY_BASE_DELAY_MS = exports.INGEST_REQUEST_TIMEOUT_MS = exports.INGEST_MAX_ATTEMPTS = exports.INGEST_STRICT_ATTEMPTS = void 0;
|
|
3
|
+
exports.STRICT_DELIVERY = exports.BACKGROUND_DELIVERY = exports.AWAITED_DELIVERY = exports.IngestError = exports.INGEST_RETRY_MAX_DELAY_MS = exports.INGEST_RETRY_BASE_DELAY_MS = exports.AWAITED_INGEST_TOTAL_TIMEOUT_MS = exports.AWAITED_INGEST_REQUEST_TIMEOUT_MS = exports.INGEST_REQUEST_TIMEOUT_MS = exports.INGEST_MAX_ATTEMPTS = exports.INGEST_STRICT_ATTEMPTS = void 0;
|
|
4
4
|
exports.ingestFailureHint = ingestFailureHint;
|
|
5
5
|
exports.isRetryableIngestStatus = isRetryableIngestStatus;
|
|
6
6
|
exports.parseRetryAfterMs = parseRetryAfterMs;
|
|
@@ -24,11 +24,24 @@ exports.INGEST_STRICT_ATTEMPTS = 1;
|
|
|
24
24
|
*/
|
|
25
25
|
exports.INGEST_MAX_ATTEMPTS = 3;
|
|
26
26
|
/**
|
|
27
|
-
* Per-request timeout, the OTLP exporter default
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* Per-request timeout, the OTLP exporter default, for a delivery no request
|
|
28
|
+
* waits on, and for `ingest()`. Ingest answers once the payload is stored and
|
|
29
|
+
* enqueued, so a healthy send finishes well inside it; without one, a
|
|
30
|
+
* stalled connection blocks the caller indefinitely.
|
|
30
31
|
*/
|
|
31
32
|
exports.INGEST_REQUEST_TIMEOUT_MS = 10_000;
|
|
33
|
+
/**
|
|
34
|
+
* Per-request timeout for a delivery the caller's request waits on. Two full
|
|
35
|
+
* attempts and their backoff fit inside the total below, which shortens the
|
|
36
|
+
* third.
|
|
37
|
+
*/
|
|
38
|
+
exports.AWAITED_INGEST_REQUEST_TIMEOUT_MS = 4_000;
|
|
39
|
+
/**
|
|
40
|
+
* Ceiling for a delivery the caller's request waits on, every attempt and
|
|
41
|
+
* backoff included, so a hung ingest endpoint adds at most this much to the
|
|
42
|
+
* request.
|
|
43
|
+
*/
|
|
44
|
+
exports.AWAITED_INGEST_TOTAL_TIMEOUT_MS = 10_000;
|
|
32
45
|
/**
|
|
33
46
|
* Delay before the first retry; each later retry doubles it. Jitter keeps
|
|
34
47
|
* clients that failed together from retrying in lockstep.
|
|
@@ -39,8 +52,33 @@ exports.INGEST_RETRY_BASE_DELAY_MS = 500;
|
|
|
39
52
|
* rate-limited send cannot hold the caller's request for long.
|
|
40
53
|
*/
|
|
41
54
|
exports.INGEST_RETRY_MAX_DELAY_MS = 2_000;
|
|
42
|
-
|
|
55
|
+
/**
|
|
56
|
+
* What `ingest()` throws when Lemma rejects a trace with a non-2xx status.
|
|
57
|
+
* Any other failure, such as a network error or a timeout, is thrown
|
|
58
|
+
* unchanged.
|
|
59
|
+
*/
|
|
60
|
+
class IngestError extends Error {
|
|
61
|
+
/** The HTTP status ingest answered with. */
|
|
62
|
+
status;
|
|
63
|
+
/** Whether resending the same payload can succeed (408, 429 and 5xx). */
|
|
64
|
+
retryable;
|
|
65
|
+
/** The response body, often JSON with a `detail` naming the problem. */
|
|
66
|
+
body;
|
|
67
|
+
constructor(status, body) {
|
|
68
|
+
super(`@uselemma/tracing: failed to ingest trace (${status})${body ? `: ${body}` : ""}`);
|
|
69
|
+
this.name = "IngestError";
|
|
70
|
+
this.status = status;
|
|
71
|
+
this.retryable = isRetryableIngestStatus(status);
|
|
72
|
+
this.body = body;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.IngestError = IngestError;
|
|
76
|
+
function ingestFailureHint(status, body) {
|
|
43
77
|
switch (status) {
|
|
78
|
+
case 400:
|
|
79
|
+
// A 400 is never retried, so the warning carries the `detail` ingest
|
|
80
|
+
// returns naming what it rejected.
|
|
81
|
+
return responseDetail(body) ?? "ingest rejected the payload as invalid";
|
|
44
82
|
case 401:
|
|
45
83
|
return "check LEMMA_API_KEY";
|
|
46
84
|
case 403:
|
|
@@ -53,6 +91,18 @@ function ingestFailureHint(status) {
|
|
|
53
91
|
return undefined;
|
|
54
92
|
}
|
|
55
93
|
}
|
|
94
|
+
function responseDetail(body) {
|
|
95
|
+
try {
|
|
96
|
+
const parsed = JSON.parse(body);
|
|
97
|
+
const detail = typeof parsed === "object" && parsed !== null && "detail" in parsed
|
|
98
|
+
? parsed.detail
|
|
99
|
+
: undefined;
|
|
100
|
+
return typeof detail === "string" && detail ? detail : undefined;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return undefined;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
56
106
|
/**
|
|
57
107
|
* Statuses where resending the same payload can succeed. A resend after a
|
|
58
108
|
* success the client never saw is harmless: ingest skips stored span IDs.
|
|
@@ -73,6 +123,24 @@ function ingestRetryDelayMs(retry, retryAfterMs, random = Math.random) {
|
|
|
73
123
|
const jittered = backoff / 2 + random() * (backoff / 2);
|
|
74
124
|
return Math.min(exports.INGEST_RETRY_MAX_DELAY_MS, Math.max(jittered, retryAfterMs ?? 0));
|
|
75
125
|
}
|
|
126
|
+
/** A trace the caller created, which a request may be waiting on. */
|
|
127
|
+
exports.AWAITED_DELIVERY = {
|
|
128
|
+
maxAttempts: exports.INGEST_MAX_ATTEMPTS,
|
|
129
|
+
requestTimeoutMs: exports.AWAITED_INGEST_REQUEST_TIMEOUT_MS,
|
|
130
|
+
totalTimeoutMs: exports.AWAITED_INGEST_TOTAL_TIMEOUT_MS,
|
|
131
|
+
};
|
|
132
|
+
/** A trace the SDK sends after the run, which no request waits on. */
|
|
133
|
+
exports.BACKGROUND_DELIVERY = {
|
|
134
|
+
maxAttempts: exports.INGEST_MAX_ATTEMPTS,
|
|
135
|
+
requestTimeoutMs: exports.INGEST_REQUEST_TIMEOUT_MS,
|
|
136
|
+
totalTimeoutMs: Number.POSITIVE_INFINITY,
|
|
137
|
+
};
|
|
138
|
+
/** `ingest()`: one send that throws, so the producer can retry. */
|
|
139
|
+
exports.STRICT_DELIVERY = {
|
|
140
|
+
maxAttempts: exports.INGEST_STRICT_ATTEMPTS,
|
|
141
|
+
requestTimeoutMs: exports.INGEST_REQUEST_TIMEOUT_MS,
|
|
142
|
+
totalTimeoutMs: Number.POSITIVE_INFINITY,
|
|
143
|
+
};
|
|
76
144
|
function sleep(ms) {
|
|
77
145
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
78
146
|
}
|
|
@@ -80,16 +148,16 @@ function sleep(ms) {
|
|
|
80
148
|
* Bound one ingest request, body read included. The race also covers a custom
|
|
81
149
|
* `fetch` that ignores the abort signal.
|
|
82
150
|
*/
|
|
83
|
-
async function withIngestTimeout(run) {
|
|
151
|
+
async function withIngestTimeout(run, timeoutMs = exports.INGEST_REQUEST_TIMEOUT_MS) {
|
|
84
152
|
const controller = new AbortController();
|
|
85
153
|
let timer;
|
|
86
154
|
const timedOut = new Promise((_, reject) => {
|
|
87
155
|
timer = setTimeout(() => {
|
|
88
|
-
const error = new Error(`ingest request timed out after ${
|
|
156
|
+
const error = new Error(`ingest request timed out after ${timeoutMs}ms`);
|
|
89
157
|
error.name = "TimeoutError";
|
|
90
158
|
controller.abort(error);
|
|
91
159
|
reject(error);
|
|
92
|
-
},
|
|
160
|
+
}, timeoutMs);
|
|
93
161
|
});
|
|
94
162
|
try {
|
|
95
163
|
return await Promise.race([run(controller.signal), timedOut]);
|
|
@@ -102,22 +170,40 @@ async function withIngestTimeout(run) {
|
|
|
102
170
|
function failedBeforeSending(error) {
|
|
103
171
|
return { ok: false, error, cause: `before sending: ${(0, error_message_1.describeError)(error)}` };
|
|
104
172
|
}
|
|
105
|
-
|
|
173
|
+
/**
|
|
174
|
+
* Names the total ceiling when it ended delivery, so a shortened last
|
|
175
|
+
* attempt doesn't read as Lemma failing fast.
|
|
176
|
+
*/
|
|
177
|
+
function failedAfter(attempts, attempt, stop, totalTimeoutMs) {
|
|
178
|
+
const ceiling = stop === "ceiling" ? ` (${totalTimeoutMs}ms delivery ceiling reached)` : "";
|
|
106
179
|
return {
|
|
107
180
|
ok: false,
|
|
108
181
|
error: attempt.error,
|
|
109
|
-
cause: `after ${attempts} attempt${attempts === 1 ? "" : "s"}: ${attempt.reason}`,
|
|
182
|
+
cause: `after ${attempts} attempt${attempts === 1 ? "" : "s"}: ${attempt.reason}${ceiling}`,
|
|
110
183
|
};
|
|
111
184
|
}
|
|
185
|
+
/** Why delivery stops after a failed attempt, or undefined to retry. */
|
|
186
|
+
function stopReason(attempt, attempts, maxAttempts, timing) {
|
|
187
|
+
if (!attempt.retryable)
|
|
188
|
+
return "rejected";
|
|
189
|
+
const now = Date.now();
|
|
190
|
+
if (now >= timing.deadline)
|
|
191
|
+
return "ceiling";
|
|
192
|
+
if (attempts >= maxAttempts)
|
|
193
|
+
return "attempts";
|
|
194
|
+
if (now + timing.delayMs >= timing.deadline)
|
|
195
|
+
return "ceiling";
|
|
196
|
+
return undefined;
|
|
197
|
+
}
|
|
112
198
|
/** Send once under the request timeout and classify the outcome. */
|
|
113
|
-
async function sendOnce(post, log) {
|
|
199
|
+
async function sendOnce(post, log, timeoutMs) {
|
|
114
200
|
try {
|
|
115
201
|
return await withIngestTimeout(async (signal) => {
|
|
116
202
|
const response = await post(signal);
|
|
117
203
|
if (response.ok)
|
|
118
204
|
return { ok: true, response };
|
|
119
205
|
const body = await response.text().catch(() => "");
|
|
120
|
-
const hint = ingestFailureHint(response.status);
|
|
206
|
+
const hint = ingestFailureHint(response.status, body);
|
|
121
207
|
(0, debug_mode_1.lemmaDebug)("client", "trace ingest failed", {
|
|
122
208
|
...log,
|
|
123
209
|
status: response.status,
|
|
@@ -125,14 +211,15 @@ async function sendOnce(post, log) {
|
|
|
125
211
|
...(0, debug_delivery_1.pickResponseHeaders)(response.headers),
|
|
126
212
|
...(hint ? { hint } : {}),
|
|
127
213
|
});
|
|
214
|
+
const error = new IngestError(response.status, body);
|
|
128
215
|
return {
|
|
129
216
|
ok: false,
|
|
130
|
-
error
|
|
217
|
+
error,
|
|
131
218
|
reason: `ingest returned ${response.status}${hint ? ` (${hint})` : ""}`,
|
|
132
|
-
retryable:
|
|
219
|
+
retryable: error.retryable,
|
|
133
220
|
retryAfterMs: parseRetryAfterMs(response.headers.get("retry-after")),
|
|
134
221
|
};
|
|
135
|
-
});
|
|
222
|
+
}, timeoutMs);
|
|
136
223
|
}
|
|
137
224
|
catch (error) {
|
|
138
225
|
(0, debug_mode_1.lemmaDebug)("client", "trace ingest failed", {
|
|
@@ -148,16 +235,25 @@ async function sendOnce(post, log) {
|
|
|
148
235
|
};
|
|
149
236
|
}
|
|
150
237
|
}
|
|
151
|
-
/**
|
|
152
|
-
|
|
238
|
+
/**
|
|
239
|
+
* Send within `budget`, backing off between retryable failures. No attempt
|
|
240
|
+
* outlives the total ceiling, and none starts once its backoff would reach it.
|
|
241
|
+
*/
|
|
242
|
+
async function deliver(post, log, budget) {
|
|
243
|
+
const { maxAttempts, requestTimeoutMs, totalTimeoutMs } = budget;
|
|
244
|
+
const deadline = Date.now() + totalTimeoutMs;
|
|
153
245
|
for (let attempts = 1;; attempts += 1) {
|
|
154
|
-
const
|
|
246
|
+
const timeoutMs = Math.min(requestTimeoutMs, deadline - Date.now());
|
|
247
|
+
const attempt = await sendOnce(post, log, timeoutMs);
|
|
155
248
|
if (attempt.ok)
|
|
156
249
|
return { ok: true, response: attempt.response };
|
|
157
|
-
if (!attempt.retryable || attempts >= maxAttempts) {
|
|
158
|
-
return failedAfter(attempts, attempt);
|
|
159
|
-
}
|
|
160
250
|
const delayMs = ingestRetryDelayMs(attempts, attempt.retryAfterMs);
|
|
251
|
+
const stop = stopReason(attempt, attempts, maxAttempts, {
|
|
252
|
+
deadline,
|
|
253
|
+
delayMs,
|
|
254
|
+
});
|
|
255
|
+
if (stop)
|
|
256
|
+
return failedAfter(attempts, attempt, stop, totalTimeoutMs);
|
|
161
257
|
(0, debug_mode_1.lemmaDebug)("client", "retrying trace ingest", {
|
|
162
258
|
...log,
|
|
163
259
|
attempt: attempts,
|
package/dist/delivery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"delivery.js","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":";;;AAqEA,8CAoBC;AAmBD,0DAEC;AAGD,8CAIC;AAGD,gDAWC;AA+BD,sBAEC;AAMD,8CAmBC;AAkBD,kDAEC;AAgGD,0BAyBC;AA1UD,qDAAuD;AACvD,6CAA0C;AAC1C,mDAAgE;AAEhE;;;GAGG;AACU,QAAA,sBAAsB,GAAG,CAAC,CAAC;AACxC;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,CAAC,CAAC;AACrC;;;;;GAKG;AACU,QAAA,yBAAyB,GAAG,MAAM,CAAC;AAChD;;;;GAIG;AACU,QAAA,iCAAiC,GAAG,KAAK,CAAC;AACvD;;;;GAIG;AACU,QAAA,+BAA+B,GAAG,MAAM,CAAC;AACtD;;;GAGG;AACU,QAAA,0BAA0B,GAAG,GAAG,CAAC;AAC9C;;;GAGG;AACU,QAAA,yBAAyB,GAAG,KAAK,CAAC;AAE/C;;;;GAIG;AACH,MAAa,WAAY,SAAQ,KAAK;IACpC,4CAA4C;IACnC,MAAM,CAAS;IACxB,yEAAyE;IAChE,SAAS,CAAU;IAC5B,wEAAwE;IAC/D,IAAI,CAAS;IAEtB,YAAY,MAAc,EAAE,IAAY;QACtC,KAAK,CACH,8CAA8C,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAClF,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,uBAAuB,CAAC,MAAM,CAAC,CAAC;QACjD,IAAI,CAAC,IAAI,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AC,GAAG,CAAC,gBAAgB,EAAE,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;QACpE,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QACrD,IAAI,OAAO,CAAC,EAAE;YAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;QAChE,MAAM,OAAO,GAAG,kBAAkB,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;QACnE,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE;YACtD,QAAQ;YACR,OAAO;SACR,CAAC,CAAC;QACH,IAAI,IAAI;YAAE,OAAO,WAAW,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACtE,IAAA,uBAAU,EAAC,QAAQ,EAAE,uBAAuB,EAAE;YAC5C,GAAG,GAAG;YACN,OAAO,EAAE,QAAQ;YACjB,WAAW;YACX,OAAO;SACR,CAAC,CAAC;QACH,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;AACH,CAAC"}
|
package/dist/env.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runs a `process.env` read, and returns undefined where the environment
|
|
3
|
+
* can't be read: the runtime has no `process` global, or denies access to
|
|
4
|
+
* it. Callers keep literal `process.env.NAME` reads, so a value a bundler
|
|
5
|
+
* inlined is still used.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readEnv(read: () => string | undefined): string | undefined;
|
|
8
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAM1E"}
|
package/dist/env.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readEnv = readEnv;
|
|
4
|
+
/**
|
|
5
|
+
* Runs a `process.env` read, and returns undefined where the environment
|
|
6
|
+
* can't be read: the runtime has no `process` global, or denies access to
|
|
7
|
+
* it. Callers keep literal `process.env.NAME` reads, so a value a bundler
|
|
8
|
+
* inlined is still used.
|
|
9
|
+
*/
|
|
10
|
+
function readEnv(read) {
|
|
11
|
+
try {
|
|
12
|
+
return read();
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=env.js.map
|
package/dist/env.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":";;AAMA,0BAMC;AAZD;;;;;GAKG;AACH,SAAgB,OAAO,CAAC,IAA8B;IACpD,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
package/dist/error-message.d.ts
CHANGED
|
@@ -19,4 +19,14 @@ export declare function describeError(error: unknown): string;
|
|
|
19
19
|
* failed, and only a nullish value means no failure happened.
|
|
20
20
|
*/
|
|
21
21
|
export declare function failureMessage(error: unknown): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* Close model calls still open when their failed run's trace is sent. A call
|
|
24
|
+
* that never returned gets the run's error. Calls that already completed are
|
|
25
|
+
* left as they are, and so is every call when the run reported no error: a
|
|
26
|
+
* trace sent while its run is still in progress (a shutdown, the idle TTL)
|
|
27
|
+
* says nothing about how its open calls will end.
|
|
28
|
+
*/
|
|
29
|
+
export declare function failOpenGenerations(handles: Iterable<{
|
|
30
|
+
failUnfinished(error: string, endedAt: Date): void;
|
|
31
|
+
} | undefined>, runError: string | undefined, endedAt: Date): void;
|
|
22
32
|
//# sourceMappingURL=error-message.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../src/error-message.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuB1D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE5D"}
|
|
1
|
+
{"version":3,"file":"error-message.d.ts","sourceRoot":"","sources":["../src/error-message.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAuB1D;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE5D;AAuED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,QAAQ,CACf;IAAE,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,GAAG,SAAS,CACnE,EACD,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,OAAO,EAAE,IAAI,QAId"}
|
package/dist/error-message.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.errorMessage = errorMessage;
|
|
4
4
|
exports.describeError = describeError;
|
|
5
5
|
exports.failureMessage = failureMessage;
|
|
6
|
+
exports.failOpenGenerations = failOpenGenerations;
|
|
6
7
|
/**
|
|
7
8
|
* Normalize anything that represents a failure into a human-readable message.
|
|
8
9
|
*
|
|
@@ -111,4 +112,17 @@ function safeText(value) {
|
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
const GENERIC_ERROR_NAME = "Error";
|
|
115
|
+
/**
|
|
116
|
+
* Close model calls still open when their failed run's trace is sent. A call
|
|
117
|
+
* that never returned gets the run's error. Calls that already completed are
|
|
118
|
+
* left as they are, and so is every call when the run reported no error: a
|
|
119
|
+
* trace sent while its run is still in progress (a shutdown, the idle TTL)
|
|
120
|
+
* says nothing about how its open calls will end.
|
|
121
|
+
*/
|
|
122
|
+
function failOpenGenerations(handles, runError, endedAt) {
|
|
123
|
+
if (!runError)
|
|
124
|
+
return;
|
|
125
|
+
for (const handle of handles)
|
|
126
|
+
handle?.failUnfinished(runError, endedAt);
|
|
127
|
+
}
|
|
114
128
|
//# sourceMappingURL=error-message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-message.js","sourceRoot":"","sources":["../src/error-message.ts"],"names":[],"mappings":";;AAQA,oCAuBC;AAOD,sCAEC;AAOD,wCAEC;
|
|
1
|
+
{"version":3,"file":"error-message.js","sourceRoot":"","sources":["../src/error-message.ts"],"names":[],"mappings":";;AAQA,oCAuBC;AAOD,sCAEC;AAOD,wCAEC;AA8ED,kDASC;AAxID;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,KAAc;IACzC,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IAE/B,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IACvD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,IAAI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,CAAC,kBAAkB,CAAC;AACxE,CAAC;AAED,gFAAgF;AAChF,SAAS,QAAQ,CAAC,KAAc;IAC9B,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,kBAAkB,GAAG,OAAO,CAAC;AAEnC;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,OAEC,EACD,QAA4B,EAC5B,OAAa;IAEb,IAAI,CAAC,QAAQ;QAAE,OAAO;IACtB,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,MAAM,EAAE,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export { Lemma, NoopSpanHandle, SpanHandle, TraceContext, TraceHandle, type DetachedGenerationOptions, type DetachedSpanOptions, type DetachedToolOptions, type GenerationOptions, type JsonValue, type LemmaClientOptions, type SdkIntegration, type SpanOptions, type OperationUsageResult, type TokenUsage, type ToolOptions, type TraceEndOptions, type TraceOptions, type DebugSmokeTestResult, type WireTokenUsage, attachResultUsage, normalizeTokenUsage, toWireTokenUsage, } from "./client";
|
|
2
2
|
export { attachTurn, applyTurnJournal, assembleTurn, parseTurnContextToken, startTurn, AttachedSpanHandle, AttachedTurn, TURN_CONTEXT_VERSION, TURN_JOURNAL_VERSION, TurnHandle, type TurnContextToken, type TurnJournal, type TurnJournalInput, type TurnJournalRecord, type TurnJournalSpan, } from "./turn";
|
|
3
|
-
export { codingAgentTurnTrace, completeCodingAgentTurn, recordCodingAgentToolResult, recordCodingAgentToolStart, startCodingAgentTurn, type CodingAgentHarnessId, type CodingAgentToolCall, type CodingAgentToolResult, type CodingAgentToolStart, type CodingAgentTurn, type CodingAgentTurnTrace, type CompleteCodingAgentTurnOptions, type CompletedCodingAgentTurn, type OpenCodingAgentTurn, type StartCodingAgentTurnOptions, } from "./coding-agent";
|
|
3
|
+
export { codingAgentTurnTrace, completeCodingAgentTurn, recordCodingAgentToolResult, recordCodingAgentToolStart, startCodingAgentTurn, type CodingAgentEarlierResponse, type CodingAgentHarnessId, type CodingAgentToolCall, type CodingAgentToolResult, type CodingAgentToolStart, type CodingAgentTurn, type CodingAgentTurnTrace, type CompleteCodingAgentTurnOptions, type CompletedCodingAgentTurn, type OpenCodingAgentTurn, type StartCodingAgentTurnOptions, } from "./coding-agent";
|
|
4
|
+
export { IngestError } from "./delivery";
|
|
4
5
|
export { normalizeRelease, RELEASE_MAX_LENGTH } from "./release";
|
|
5
6
|
export { disableDebugMode, enableDebugMode, isDebugModeEnabled, isDebugVerifyEnabled, lemmaDebug, } from "./debug-mode";
|
|
6
7
|
export { LangChainCallbackHandler, LemmaLangChainCallbackHandler, langChain, langGraph, type LangChainIntegrationOptions, type LemmaLangChainIntegrationOptions, type LemmaLangGraphIntegrationOptions, } from "./langchain";
|
|
7
8
|
export { LemmaMastraExporter, mastra, type LemmaMastraIntegrationOptions, type MastraErrorInfo, type MastraExportedSpan, type MastraIntegrationOptions, type MastraSpanType, type MastraTracingEvent, } from "./mastra";
|
|
8
9
|
export { openAIAgents, type OpenAIAgentsIntegrationOptions, type OpenAIAgentsSpan, type OpenAIAgentsSpanData, type OpenAIAgentsTrace, type OpenAIAgentsTracingProcessor, } from "./openai-agents";
|
|
9
|
-
export { vercelAI, type LemmaVercelAIIntegrationOptions, type VercelAIIntegrationOptions, type VercelAITelemetryIntegration, } from "./vercel-ai";
|
|
10
|
+
export { vercelAI, type LemmaVercelAIIntegrationOptions, type VercelAIIntegrationOptions, type VercelAICallTelemetry, type VercelAITelemetryIntegration, } from "./vercel-ai";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":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7B,SAAS,EACT,SAAS,EACT,KAAK,2BAA2B,EAChC,KAAK,gCAAgC,EACrC,KAAK,gCAAgC,GACtC,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,mBAAmB,EACnB,MAAM,EACN,KAAK,6BAA6B,EAClC,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,YAAY,EACZ,KAAK,8BAA8B,EACnC,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,KAAK,4BAA4B,GAClC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,QAAQ,EACR,KAAK,+BAA+B,EACpC,KAAK,0BAA0B,EAC/B,KAAK,4BAA4B,GAClC,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,cAAc,EACd,UAAU,EACV,YAAY,EACZ,WAAW,EACX,KAAK,yBAAyB,EAC9B,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,SAAS,EACT,kBAAkB,EAClB,YAAY,EACZ,oBAAoB,EACpB,oBAAoB,EACpB,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,gB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
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.vercelAI = exports.openAIAgents = exports.mastra = exports.LemmaMastraExporter = exports.langGraph = exports.langChain = exports.LemmaLangChainCallbackHandler = exports.LangChainCallbackHandler = exports.lemmaDebug = exports.isDebugVerifyEnabled = exports.isDebugModeEnabled = exports.enableDebugMode = exports.disableDebugMode = exports.RELEASE_MAX_LENGTH = exports.normalizeRelease = exports.startCodingAgentTurn = exports.recordCodingAgentToolStart = exports.recordCodingAgentToolResult = exports.completeCodingAgentTurn = exports.codingAgentTurnTrace = exports.TurnHandle = exports.TURN_JOURNAL_VERSION = exports.TURN_CONTEXT_VERSION = exports.AttachedTurn = exports.AttachedSpanHandle = exports.startTurn = exports.parseTurnContextToken = exports.assembleTurn = exports.applyTurnJournal = exports.attachTurn = exports.toWireTokenUsage = exports.normalizeTokenUsage = exports.attachResultUsage = exports.TraceHandle = exports.TraceContext = exports.SpanHandle = exports.NoopSpanHandle = exports.Lemma = void 0;
|
|
3
|
+
exports.vercelAI = exports.openAIAgents = exports.mastra = exports.LemmaMastraExporter = exports.langGraph = exports.langChain = exports.LemmaLangChainCallbackHandler = exports.LangChainCallbackHandler = exports.lemmaDebug = exports.isDebugVerifyEnabled = exports.isDebugModeEnabled = exports.enableDebugMode = exports.disableDebugMode = exports.RELEASE_MAX_LENGTH = exports.normalizeRelease = exports.IngestError = exports.startCodingAgentTurn = exports.recordCodingAgentToolStart = exports.recordCodingAgentToolResult = exports.completeCodingAgentTurn = exports.codingAgentTurnTrace = exports.TurnHandle = exports.TURN_JOURNAL_VERSION = exports.TURN_CONTEXT_VERSION = exports.AttachedTurn = exports.AttachedSpanHandle = exports.startTurn = exports.parseTurnContextToken = exports.assembleTurn = exports.applyTurnJournal = exports.attachTurn = exports.toWireTokenUsage = exports.normalizeTokenUsage = exports.attachResultUsage = exports.TraceHandle = exports.TraceContext = exports.SpanHandle = exports.NoopSpanHandle = exports.Lemma = void 0;
|
|
4
4
|
var client_1 = require("./client");
|
|
5
5
|
Object.defineProperty(exports, "Lemma", { enumerable: true, get: function () { return client_1.Lemma; } });
|
|
6
6
|
Object.defineProperty(exports, "NoopSpanHandle", { enumerable: true, get: function () { return client_1.NoopSpanHandle; } });
|
|
@@ -27,6 +27,8 @@ Object.defineProperty(exports, "completeCodingAgentTurn", { enumerable: true, ge
|
|
|
27
27
|
Object.defineProperty(exports, "recordCodingAgentToolResult", { enumerable: true, get: function () { return coding_agent_1.recordCodingAgentToolResult; } });
|
|
28
28
|
Object.defineProperty(exports, "recordCodingAgentToolStart", { enumerable: true, get: function () { return coding_agent_1.recordCodingAgentToolStart; } });
|
|
29
29
|
Object.defineProperty(exports, "startCodingAgentTurn", { enumerable: true, get: function () { return coding_agent_1.startCodingAgentTurn; } });
|
|
30
|
+
var delivery_1 = require("./delivery");
|
|
31
|
+
Object.defineProperty(exports, "IngestError", { enumerable: true, get: function () { return delivery_1.IngestError; } });
|
|
30
32
|
var release_1 = require("./release");
|
|
31
33
|
Object.defineProperty(exports, "normalizeRelease", { enumerable: true, get: function () { return release_1.normalizeRelease; } });
|
|
32
34
|
Object.defineProperty(exports, "RELEASE_MAX_LENGTH", { enumerable: true, get: function () { return release_1.RELEASE_MAX_LENGTH; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAwBkB;AAvBhB,+FAAA,KAAK,OAAA;AACL,wGAAA,cAAc,OAAA;AACd,oGAAA,UAAU,OAAA;AACV,sGAAA,YAAY,OAAA;AACZ,qGAAA,WAAW,OAAA;AAgBX,2GAAA,iBAAiB,OAAA;AACjB,6GAAA,mBAAmB,OAAA;AACnB,0GAAA,gBAAgB,OAAA;AAElB,+BAgBgB;AAfd,kGAAA,UAAU,OAAA;AACV,wGAAA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EZ,yCAQqB;AAPnB,qHAAA,wBAAwB,OAAA;AACxB,0HAAA,6BAA6B,OAAA;AAC7B,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AAKX,mCASkB;AARhB,6GAAA,mBAAmB,OAAA;AACnB,gGAAA,MAAM,OAAA;AAQR,iDAOyB;AANvB,6GAAA,YAAY,OAAA;AAOd,yCAMqB;AALnB,qGAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Lemma, type LemmaClientOptions } from "./client";
|
|
2
|
+
export type FrameworkIntegration = "vercelAI()" | "LemmaMastraExporter";
|
|
3
|
+
/** Client options every framework integration accepts. */
|
|
4
|
+
export type IntegrationClientOptions = Pick<LemmaClientOptions, "apiKey" | "projectId" | "baseUrl" | "fetch" | "release"> & {
|
|
5
|
+
lemma?: Lemma;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Return a getter for the client a framework integration sends with:
|
|
9
|
+
* `options.lemma`, or one built from the options and environment on first
|
|
10
|
+
* use.
|
|
11
|
+
*
|
|
12
|
+
* The getter never throws, because framework callbacks swallow or misreport
|
|
13
|
+
* a throw. Until construction succeeds it returns undefined and retries on
|
|
14
|
+
* the next call; the first failure, usually a missing `LEMMA_API_KEY` or
|
|
15
|
+
* `LEMMA_PROJECT_ID`, logs one `console.error` per process per integration.
|
|
16
|
+
*/
|
|
17
|
+
export declare function integrationClientGetter(integration: FrameworkIntegration, options: IntegrationClientOptions): () => Lemma | undefined;
|
|
18
|
+
/** Forget earlier reports; used by tests that share one process. */
|
|
19
|
+
export declare function resetIntegrationClientErrors(): void;
|
|
20
|
+
//# sourceMappingURL=integration-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-client.d.ts","sourceRoot":"","sources":["../src/integration-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,qBAAqB,CAAC;AAExE,0DAA0D;AAC1D,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,kBAAkB,EAClB,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CACzD,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAMtB;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,WAAW,EAAE,oBAAoB,EACjC,OAAO,EAAE,wBAAwB,GAChC,MAAM,KAAK,GAAG,SAAS,CAYzB;AAYD,oEAAoE;AACpE,wBAAgB,4BAA4B,IAAI,IAAI,CAEnD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.integrationClientGetter = integrationClientGetter;
|
|
4
|
+
exports.resetIntegrationClientErrors = resetIntegrationClientErrors;
|
|
5
|
+
const client_1 = require("./client");
|
|
6
|
+
const error_message_1 = require("./error-message");
|
|
7
|
+
// Process-wide, so a misconfigured deployment logs one line per integration
|
|
8
|
+
// instead of one per run.
|
|
9
|
+
const reportedIntegrations = new Set();
|
|
10
|
+
/**
|
|
11
|
+
* Return a getter for the client a framework integration sends with:
|
|
12
|
+
* `options.lemma`, or one built from the options and environment on first
|
|
13
|
+
* use.
|
|
14
|
+
*
|
|
15
|
+
* The getter never throws, because framework callbacks swallow or misreport
|
|
16
|
+
* a throw. Until construction succeeds it returns undefined and retries on
|
|
17
|
+
* the next call; the first failure, usually a missing `LEMMA_API_KEY` or
|
|
18
|
+
* `LEMMA_PROJECT_ID`, logs one `console.error` per process per integration.
|
|
19
|
+
*/
|
|
20
|
+
function integrationClientGetter(integration, options) {
|
|
21
|
+
const { lemma: provided, ...clientOptions } = options;
|
|
22
|
+
let lemma = provided;
|
|
23
|
+
return () => {
|
|
24
|
+
if (lemma)
|
|
25
|
+
return lemma;
|
|
26
|
+
try {
|
|
27
|
+
lemma = new client_1.Lemma(clientOptions);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
reportClientError(integration, error);
|
|
31
|
+
}
|
|
32
|
+
return lemma;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function reportClientError(integration, error) {
|
|
36
|
+
if (reportedIntegrations.has(integration))
|
|
37
|
+
return;
|
|
38
|
+
reportedIntegrations.add(integration);
|
|
39
|
+
// The client's own message names the missing variable or bad option.
|
|
40
|
+
const cause = (0, error_message_1.describeError)(error).replace(/^@uselemma\/tracing:\s*/, "");
|
|
41
|
+
console.error(`@uselemma/tracing: ${integration} can't send traces: ${cause}. Set LEMMA_API_KEY and LEMMA_PROJECT_ID (and LEMMA_BASE_URL if you use one) in this runtime's environment, or pass apiKey, projectId and baseUrl in its options. It drops traces until this is fixed; this error is logged once per process.`);
|
|
42
|
+
}
|
|
43
|
+
/** Forget earlier reports; used by tests that share one process. */
|
|
44
|
+
function resetIntegrationClientErrors() {
|
|
45
|
+
reportedIntegrations.clear();
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=integration-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integration-client.js","sourceRoot":"","sources":["../src/integration-client.ts"],"names":[],"mappings":";;AAyBA,0DAeC;AAaD,oEAEC;AAvDD,qCAA0D;AAC1D,mDAAgD;AAUhD,4EAA4E;AAC5E,0BAA0B;AAC1B,MAAM,oBAAoB,GAAG,IAAI,GAAG,EAAwB,CAAC;AAE7D;;;;;;;;;GASG;AACH,SAAgB,uBAAuB,CACrC,WAAiC,EACjC,OAAiC;IAEjC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IACtD,IAAI,KAAK,GAAG,QAAQ,CAAC;IACrB,OAAO,GAAG,EAAE;QACV,IAAI,KAAK;YAAE,OAAO,KAAK,CAAC;QACxB,IAAI,CAAC;YACH,KAAK,GAAG,IAAI,cAAK,CAAC,aAAa,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,iBAAiB,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,WAAiC,EAAE,KAAc;IAC1E,IAAI,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC;QAAE,OAAO;IAClD,oBAAoB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACtC,qEAAqE;IACrE,MAAM,KAAK,GAAG,IAAA,6BAAa,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IAC1E,OAAO,CAAC,KAAK,CACX,sBAAsB,WAAW,uBAAuB,KAAK,+OAA+O,CAC7S,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,SAAgB,4BAA4B;IAC1C,oBAAoB,CAAC,KAAK,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Install LangChain's AsyncLocalStorage when the runtime has one and nothing
|
|
3
|
+
* installed it yet. An existing instance is kept, as LangChain's own
|
|
4
|
+
* `initializeGlobalInstance` does.
|
|
5
|
+
*/
|
|
6
|
+
export declare function ensureLangChainAsyncContext(): void;
|
|
7
|
+
//# sourceMappingURL=langchain-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain-context.d.ts","sourceRoot":"","sources":["../src/langchain-context.ts"],"names":[],"mappings":"AA+BA;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,IAAI,CAOlD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureLangChainAsyncContext = ensureLangChainAsyncContext;
|
|
4
|
+
/**
|
|
5
|
+
* LangChain hands a parent run's callbacks to calls that don't pass `config`
|
|
6
|
+
* (a model call inside a chain step or a LangGraph node) through an
|
|
7
|
+
* AsyncLocalStorage it reads from this global. LangChain installs it only from
|
|
8
|
+
* Node-specific entries such as `@langchain/core/context` and LangGraph's Node
|
|
9
|
+
* entry, so plain `@langchain/core` and LangGraph's `browser` entry (what
|
|
10
|
+
* Workers and edge bundlers resolve) run those calls without callbacks, and
|
|
11
|
+
* they are never traced.
|
|
12
|
+
*/
|
|
13
|
+
const LANGCHAIN_ASYNC_LOCAL_STORAGE = Symbol.for("ls:tracing_async_local_storage");
|
|
14
|
+
/**
|
|
15
|
+
* Install LangChain's AsyncLocalStorage when the runtime has one and nothing
|
|
16
|
+
* installed it yet. An existing instance is kept, as LangChain's own
|
|
17
|
+
* `initializeGlobalInstance` does.
|
|
18
|
+
*/
|
|
19
|
+
function ensureLangChainAsyncContext() {
|
|
20
|
+
const runtime = globalThis;
|
|
21
|
+
if (runtime[LANGCHAIN_ASYNC_LOCAL_STORAGE] !== undefined)
|
|
22
|
+
return;
|
|
23
|
+
const Storage = runtime.AsyncLocalStorage ??
|
|
24
|
+
runtime.process?.getBuiltinModule?.("node:async_hooks")?.AsyncLocalStorage;
|
|
25
|
+
if (Storage)
|
|
26
|
+
runtime[LANGCHAIN_ASYNC_LOCAL_STORAGE] = new Storage();
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=langchain-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain-context.js","sourceRoot":"","sources":["../src/langchain-context.ts"],"names":[],"mappings":";;AAoCA,kEAOC;AA3CD;;;;;;;;GAQG;AACH,MAAM,6BAA6B,GAAG,MAAM,CAAC,GAAG,CAC9C,gCAAgC,CACjC,CAAC;AAoBF;;;;GAIG;AACH,SAAgB,2BAA2B;IACzC,MAAM,OAAO,GAAG,UAA4B,CAAC;IAC7C,IAAI,OAAO,CAAC,6BAA6B,CAAC,KAAK,SAAS;QAAE,OAAO;IACjE,MAAM,OAAO,GACX,OAAO,CAAC,iBAAiB;QACzB,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,CAAC,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;IAC7E,IAAI,OAAO;QAAE,OAAO,CAAC,6BAA6B,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;AACtE,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open-trace TTL for the LangChain handler. A root whose end callback never
|
|
3
|
+
* arrives (an abandoned stream, a cancelled run) would otherwise keep its
|
|
4
|
+
* trace and runs in memory, unsent, for the life of the process.
|
|
5
|
+
*
|
|
6
|
+
* Staleness is idle time, not age: last activity is the latest of the
|
|
7
|
+
* trace's open time, its latest run end and the start of any run still in
|
|
8
|
+
* flight (Python's `last_activity_at`), so a long agent loop that still emits
|
|
9
|
+
* callbacks is not evicted. Sweeps are interval-gated so frequent start
|
|
10
|
+
* callbacks stay cheap.
|
|
11
|
+
*/
|
|
12
|
+
type IdleTrace = {
|
|
13
|
+
ended: boolean;
|
|
14
|
+
openedAt: Date;
|
|
15
|
+
latestEnd?: Date;
|
|
16
|
+
};
|
|
17
|
+
type InFlightRun = {
|
|
18
|
+
owningTraceId: string;
|
|
19
|
+
startedAt: Date;
|
|
20
|
+
};
|
|
21
|
+
export type IdleTraceOptions = {
|
|
22
|
+
/**
|
|
23
|
+
* Send and drop an open trace that stays idle this long (no run starts or
|
|
24
|
+
* ends), such as an abandoned stream. Default: 2 hours. `null` disables.
|
|
25
|
+
*/
|
|
26
|
+
openTraceTtlMs?: number | null;
|
|
27
|
+
/** Minimum time between idle-trace sweeps, which run from start callbacks. Default: 5 minutes. */
|
|
28
|
+
evictionIntervalMs?: number;
|
|
29
|
+
};
|
|
30
|
+
export declare class IdleTraceSweeper {
|
|
31
|
+
private readonly ttlMs;
|
|
32
|
+
private readonly intervalMs;
|
|
33
|
+
private lastSweepAt;
|
|
34
|
+
constructor({ openTraceTtlMs, evictionIntervalMs, }: IdleTraceOptions);
|
|
35
|
+
/**
|
|
36
|
+
* Pass each open trace idle past the TTL to `evict`, with one warning that
|
|
37
|
+
* lists their root run IDs. Runs at most once per interval.
|
|
38
|
+
*/
|
|
39
|
+
sweep<T extends IdleTrace>(traces: ReadonlyMap<string, T>, runs: Iterable<InFlightRun>, evict: (rootRunId: string, trace: T) => void): void;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=langchain-eviction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"langchain-eviction.d.ts","sourceRoot":"","sources":["../src/langchain-eviction.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAKH,KAAK,SAAS,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,IAAI,CAAC;IAAC,SAAS,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AACtE,KAAK,WAAW,GAAG;IAAE,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,IAAI,CAAA;CAAE,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kGAAkG;IAClG,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgB;IACtC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,WAAW,CAA4B;gBAEnC,EACV,cAA0C,EAC1C,kBAAiD,GAClD,EAAE,gBAAgB;IAKnB;;;OAGG;IACH,KAAK,CAAC,CAAC,SAAS,SAAS,EACvB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,EAC9B,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC3B,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,GAC3C,IAAI;CA2BR"}
|