@uselemma/tracing 7.14.0 → 7.15.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 +73 -17
- package/dist/client.d.ts +50 -19
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +220 -137
- 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-delivery.d.ts +2 -8
- package/dist/debug-delivery.d.ts.map +1 -1
- package/dist/debug-delivery.js +5 -24
- package/dist/debug-delivery.js.map +1 -1
- package/dist/debug-mode.d.ts +9 -0
- package/dist/debug-mode.d.ts.map +1 -1
- package/dist/debug-mode.js +24 -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/debug-mode.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEBUG_VERIFY_REMOVED_MESSAGE = void 0;
|
|
3
4
|
exports.enableDebugMode = enableDebugMode;
|
|
4
5
|
exports.disableDebugMode = disableDebugMode;
|
|
5
6
|
exports.isDebugModeEnabled = isDebugModeEnabled;
|
|
6
7
|
exports.isDebugVerifyEnabled = isDebugVerifyEnabled;
|
|
8
|
+
exports.noteDebugVerifyRemovedOnce = noteDebugVerifyRemovedOnce;
|
|
9
|
+
exports.resetDebugVerifyNotice = resetDebugVerifyNotice;
|
|
7
10
|
exports.lemmaDebug = lemmaDebug;
|
|
11
|
+
const env_1 = require("./env");
|
|
8
12
|
let debugModeEnabled = false;
|
|
9
13
|
/** Accepts `"1"` (preferred) and `"true"` (backwards compatible). Case-sensitive. */
|
|
10
|
-
function
|
|
11
|
-
const value = process.env[name];
|
|
14
|
+
function isFlagOn(value) {
|
|
12
15
|
return value === "1" || value === "true";
|
|
13
16
|
}
|
|
14
17
|
function enableDebugMode() {
|
|
@@ -18,10 +21,27 @@ function disableDebugMode() {
|
|
|
18
21
|
debugModeEnabled = false;
|
|
19
22
|
}
|
|
20
23
|
function isDebugModeEnabled() {
|
|
21
|
-
return debugModeEnabled ||
|
|
24
|
+
return debugModeEnabled || isFlagOn((0, env_1.readEnv)(() => process.env.LEMMA_DEBUG));
|
|
22
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* `LEMMA_DEBUG_VERIFY` is still read, but it no longer makes a request: the
|
|
28
|
+
* SDK logs {@link DEBUG_VERIFY_REMOVED_MESSAGE} once instead.
|
|
29
|
+
*/
|
|
23
30
|
function isDebugVerifyEnabled() {
|
|
24
|
-
return
|
|
31
|
+
return isFlagOn((0, env_1.readEnv)(() => process.env.LEMMA_DEBUG_VERIFY));
|
|
32
|
+
}
|
|
33
|
+
exports.DEBUG_VERIFY_REMOVED_MESSAGE = 'arrival verification was removed, so LEMMA_DEBUG_VERIFY makes no request. A "trace sent" line with status 201 means Lemma ingest accepted the trace; confirm it on your project\'s Traces page in the Lemma dashboard.';
|
|
34
|
+
let debugVerifyRemovedNoted = false;
|
|
35
|
+
/** Logs {@link DEBUG_VERIFY_REMOVED_MESSAGE} once per process, in debug mode. */
|
|
36
|
+
function noteDebugVerifyRemovedOnce() {
|
|
37
|
+
if (debugVerifyRemovedNoted || !isDebugModeEnabled())
|
|
38
|
+
return;
|
|
39
|
+
debugVerifyRemovedNoted = true;
|
|
40
|
+
lemmaDebug("verify", exports.DEBUG_VERIFY_REMOVED_MESSAGE);
|
|
41
|
+
}
|
|
42
|
+
/** Forget the one-time note; used by tests that share one process. */
|
|
43
|
+
function resetDebugVerifyNotice() {
|
|
44
|
+
debugVerifyRemovedNoted = false;
|
|
25
45
|
}
|
|
26
46
|
function lemmaDebug(prefix, msg, data) {
|
|
27
47
|
if (!isDebugModeEnabled())
|
package/dist/debug-mode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-mode.js","sourceRoot":"","sources":["../src/debug-mode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug-mode.js","sourceRoot":"","sources":["../src/debug-mode.ts"],"names":[],"mappings":";;;AASA,0CAEC;AAED,4CAEC;AAED,gDAEC;AAMD,oDAEC;AAQD,gEAIC;AAGD,wDAEC;AAED,gCAOC;AArDD,+BAAgC;AAEhC,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B,qFAAqF;AACrF,SAAS,QAAQ,CAAC,KAAyB;IACzC,OAAO,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,MAAM,CAAC;AAC3C,CAAC;AAED,SAAgB,eAAe;IAC7B,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC;AAED,SAAgB,gBAAgB;IAC9B,gBAAgB,GAAG,KAAK,CAAC;AAC3B,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,gBAAgB,IAAI,QAAQ,CAAC,IAAA,aAAO,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB;IAClC,OAAO,QAAQ,CAAC,IAAA,aAAO,EAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACjE,CAAC;AAEY,QAAA,4BAA4B,GACvC,wNAAwN,CAAC;AAE3N,IAAI,uBAAuB,GAAG,KAAK,CAAC;AAEpC,iFAAiF;AACjF,SAAgB,0BAA0B;IACxC,IAAI,uBAAuB,IAAI,CAAC,kBAAkB,EAAE;QAAE,OAAO;IAC7D,uBAAuB,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,QAAQ,EAAE,oCAA4B,CAAC,CAAC;AACrD,CAAC;AAED,sEAAsE;AACtE,SAAgB,sBAAsB;IACpC,uBAAuB,GAAG,KAAK,CAAC;AAClC,CAAC;AAED,SAAgB,UAAU,CAAC,MAAc,EAAE,GAAW,EAAE,IAA8B;IACpF,IAAI,CAAC,kBAAkB,EAAE;QAAE,OAAO;IAClC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,KAAK,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,UAAU,MAAM,KAAK,GAAG,EAAE,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC"}
|
package/dist/delivery.d.ts
CHANGED
|
@@ -10,11 +10,24 @@ export declare const INGEST_STRICT_ATTEMPTS = 1;
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const INGEST_MAX_ATTEMPTS = 3;
|
|
12
12
|
/**
|
|
13
|
-
* Per-request timeout, the OTLP exporter default
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Per-request timeout, the OTLP exporter default, for a delivery no request
|
|
14
|
+
* waits on, and for `ingest()`. Ingest answers once the payload is stored and
|
|
15
|
+
* enqueued, so a healthy send finishes well inside it; without one, a
|
|
16
|
+
* stalled connection blocks the caller indefinitely.
|
|
16
17
|
*/
|
|
17
18
|
export declare const INGEST_REQUEST_TIMEOUT_MS = 10000;
|
|
19
|
+
/**
|
|
20
|
+
* Per-request timeout for a delivery the caller's request waits on. Two full
|
|
21
|
+
* attempts and their backoff fit inside the total below, which shortens the
|
|
22
|
+
* third.
|
|
23
|
+
*/
|
|
24
|
+
export declare const AWAITED_INGEST_REQUEST_TIMEOUT_MS = 4000;
|
|
25
|
+
/**
|
|
26
|
+
* Ceiling for a delivery the caller's request waits on, every attempt and
|
|
27
|
+
* backoff included, so a hung ingest endpoint adds at most this much to the
|
|
28
|
+
* request.
|
|
29
|
+
*/
|
|
30
|
+
export declare const AWAITED_INGEST_TOTAL_TIMEOUT_MS = 10000;
|
|
18
31
|
/**
|
|
19
32
|
* Delay before the first retry; each later retry doubles it. Jitter keeps
|
|
20
33
|
* clients that failed together from retrying in lockstep.
|
|
@@ -25,7 +38,21 @@ export declare const INGEST_RETRY_BASE_DELAY_MS = 500;
|
|
|
25
38
|
* rate-limited send cannot hold the caller's request for long.
|
|
26
39
|
*/
|
|
27
40
|
export declare const INGEST_RETRY_MAX_DELAY_MS = 2000;
|
|
28
|
-
|
|
41
|
+
/**
|
|
42
|
+
* What `ingest()` throws when Lemma rejects a trace with a non-2xx status.
|
|
43
|
+
* Any other failure, such as a network error or a timeout, is thrown
|
|
44
|
+
* unchanged.
|
|
45
|
+
*/
|
|
46
|
+
export declare class IngestError extends Error {
|
|
47
|
+
/** The HTTP status ingest answered with. */
|
|
48
|
+
readonly status: number;
|
|
49
|
+
/** Whether resending the same payload can succeed (408, 429 and 5xx). */
|
|
50
|
+
readonly retryable: boolean;
|
|
51
|
+
/** The response body, often JSON with a `detail` naming the problem. */
|
|
52
|
+
readonly body: string;
|
|
53
|
+
constructor(status: number, body: string);
|
|
54
|
+
}
|
|
55
|
+
export declare function ingestFailureHint(status: number, body: string): string | undefined;
|
|
29
56
|
/**
|
|
30
57
|
* Statuses where resending the same payload can succeed. A resend after a
|
|
31
58
|
* success the client never saw is harmless: ingest skips stored span IDs.
|
|
@@ -35,12 +62,25 @@ export declare function isRetryableIngestStatus(status: number): boolean;
|
|
|
35
62
|
export declare function parseRetryAfterMs(value: string | null): number | null;
|
|
36
63
|
/** Delay before retry number `retry` (1-based). */
|
|
37
64
|
export declare function ingestRetryDelayMs(retry: number, retryAfterMs: number | null, random?: () => number): number;
|
|
65
|
+
/** How many sends one delivery makes, and how long they may take. */
|
|
66
|
+
export type DeliveryBudget = {
|
|
67
|
+
maxAttempts: number;
|
|
68
|
+
requestTimeoutMs: number;
|
|
69
|
+
/** Ceiling for all attempts and backoff together. */
|
|
70
|
+
totalTimeoutMs: number;
|
|
71
|
+
};
|
|
72
|
+
/** A trace the caller created, which a request may be waiting on. */
|
|
73
|
+
export declare const AWAITED_DELIVERY: DeliveryBudget;
|
|
74
|
+
/** A trace the SDK sends after the run, which no request waits on. */
|
|
75
|
+
export declare const BACKGROUND_DELIVERY: DeliveryBudget;
|
|
76
|
+
/** `ingest()`: one send that throws, so the producer can retry. */
|
|
77
|
+
export declare const STRICT_DELIVERY: DeliveryBudget;
|
|
38
78
|
export declare function sleep(ms: number): Promise<void>;
|
|
39
79
|
/**
|
|
40
80
|
* Bound one ingest request, body read included. The race also covers a custom
|
|
41
81
|
* `fetch` that ignores the abort signal.
|
|
42
82
|
*/
|
|
43
|
-
export declare function withIngestTimeout<T>(run: (signal: AbortSignal) => Promise<T
|
|
83
|
+
export declare function withIngestTimeout<T>(run: (signal: AbortSignal) => Promise<T>, timeoutMs?: number): Promise<T>;
|
|
44
84
|
/** One POST of a serialized payload; the client owns the URL and credentials. */
|
|
45
85
|
export type PostIngest = (signal: AbortSignal) => Promise<Response>;
|
|
46
86
|
/** Identifiers on every delivery debug line. */
|
|
@@ -60,6 +100,9 @@ export type DeliveryResult = {
|
|
|
60
100
|
} | DeliveryFailure;
|
|
61
101
|
/** A payload that could not be built; nothing was sent. */
|
|
62
102
|
export declare function failedBeforeSending(error: unknown): DeliveryFailure;
|
|
63
|
-
/**
|
|
64
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Send within `budget`, backing off between retryable failures. No attempt
|
|
105
|
+
* outlives the total ceiling, and none starts once its backoff would reach it.
|
|
106
|
+
*/
|
|
107
|
+
export declare function deliver(post: PostIngest, log: DeliveryLogFields, budget: DeliveryBudget): Promise<DeliveryResult>;
|
|
65
108
|
//# sourceMappingURL=delivery.d.ts.map
|
package/dist/delivery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC;;;;GAIG;AACH,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"delivery.d.ts","sourceRoot":"","sources":["../src/delivery.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AACvD;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,QAAS,CAAC;AACtD;;;GAGG;AACH,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C;;;GAGG;AACH,eAAO,MAAM,yBAAyB,OAAQ,CAAC;AAE/C;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,4CAA4C;IAC5C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CAgBZ;AAED,iFAAiF;AACjF,MAAM,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEpE,gDAAgD;AAChD,MAAM,MAAM,iBAAiB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,MAAM,MAAM,eAAe,GAAG;IAC5B,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,OAAO,CAAC;IACf,wCAAwC;IACxC,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE,GAAG,eAAe,CAAC;AAEhF,2DAA2D;AAC3D,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,CAEnE;AA4FD;;;GAGG;AACH,wBAAsB,OAAO,CAC3B,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,iBAAiB,EACtB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,cAAc,CAAC,CAqBzB"}
|
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;;;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AAO,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,EAAE,IAAI,IAAI,CAAC;IAC9B,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,KAA8C,CAAC;QAC9D,IAAI,OAAO,MAAM,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACvC,OAAO,OAAO,CACZ,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EACzD,MAAM,CAAC,OAAO,CACf,CAAC;QACJ,CAAC;QACD,OAAO,eAAe,CAAC,KAAK,CAAC,CAAC;IACh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M,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":["../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,mB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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,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,2BAA2B,EAC3B,0BAA0B,EAC1B,oBAAoB,EACpB,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,8BAA8B,EACnC,KAAK,wBAAwB,EAC7B,KAAK,mBAAmB,EACxB,KAAK,2BAA2B,GACjC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,GACX,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,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,qBAAqB,EAC1B,KAAK,4BAA4B,GAClC,MAAM,aAAa,CAAC"}
|
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,gBAAgB,OAAA;AAChB,oGAAA,YAAY,OAAA;AACZ,6GAAA,qBAAqB,OAAA;AACrB,iGAAA,SAAS,OAAA;AACT,0GAAA,kBAAkB,OAAA;AAClB,oGAAA,YAAY,OAAA;AACZ,4GAAA,oBAAoB,OAAA;AACpB,4GAAA,oBAAoB,OAAA;AACpB,kGAAA,UAAU,OAAA;AAOZ,+
|
|
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;AAC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
/** 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"}
|