retrace-sdk 0.13.3 → 0.14.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/dist/config.d.ts +4 -0
- package/dist/config.js +1 -0
- package/dist/telemetry.js +1 -1
- package/dist/trace.js +10 -1
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ export interface Config {
|
|
|
32
32
|
* the fail-closed timeout verdict. 0 = trip immediately. (The auto path is synchronous, so the
|
|
33
33
|
* poll runs in the background and a denial/timeout trips the NEXT span.) */
|
|
34
34
|
enforcementHoldWaitSeconds: number;
|
|
35
|
+
/** Environment indicator sent with every trace as `metadata.environment`. Set to "sandbox" to
|
|
36
|
+
* record into the auto-expiring sandbox data-namespace instead of production (the server also
|
|
37
|
+
* accepts an `X-Retrace-Environment` header). Env: RETRACE_ENVIRONMENT. */
|
|
38
|
+
environment: string | undefined;
|
|
35
39
|
}
|
|
36
40
|
export declare function configure(opts: Partial<Config>): Config;
|
|
37
41
|
export declare function requireApiKey(): string;
|
package/dist/config.js
CHANGED
|
@@ -13,6 +13,7 @@ const config = {
|
|
|
13
13
|
maxUsdPerRun: process.env.RETRACE_MAX_USD_PER_RUN ? parseFloat(process.env.RETRACE_MAX_USD_PER_RUN) : undefined,
|
|
14
14
|
serverEnforcement: ["true", "1", "yes"].includes((process.env.RETRACE_SERVER_ENFORCEMENT || "").toLowerCase()),
|
|
15
15
|
enforcementHoldWaitSeconds: process.env.RETRACE_ENFORCEMENT_HOLD_WAIT_SECONDS ? parseInt(process.env.RETRACE_ENFORCEMENT_HOLD_WAIT_SECONDS, 10) : 0,
|
|
16
|
+
environment: process.env.RETRACE_ENVIRONMENT || undefined,
|
|
16
17
|
};
|
|
17
18
|
config.wsUrl = config.baseUrl.replace("https://", "wss://").replace("http://", "ws://");
|
|
18
19
|
export function configure(opts) {
|
package/dist/telemetry.js
CHANGED
|
@@ -14,7 +14,7 @@ import { getConfig } from "./config.js";
|
|
|
14
14
|
const ANON_ID = Math.random().toString(16).slice(2, 18);
|
|
15
15
|
const DISABLED = new Set(["0", "false", "no", "off"]);
|
|
16
16
|
// Keep in sync with package.json version.
|
|
17
|
-
const SDK_VERSION = "0.
|
|
17
|
+
const SDK_VERSION = "0.14.0";
|
|
18
18
|
function enabled() {
|
|
19
19
|
return !DISABLED.has((process.env.RETRACE_TELEMETRY ?? "1").trim().toLowerCase());
|
|
20
20
|
}
|
package/dist/trace.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { genId, nowIso, utcNow } from "./utils.js";
|
|
2
|
+
import { getConfig } from "./config.js";
|
|
2
3
|
export var SpanType;
|
|
3
4
|
(function (SpanType) {
|
|
4
5
|
SpanType["LLM_CALL"] = "llm_call";
|
|
@@ -106,5 +107,13 @@ export class TraceBuilder {
|
|
|
106
107
|
setProjectId(id) { this.data.project_id = id; }
|
|
107
108
|
setSessionId(id) { this.data.session_id = id; }
|
|
108
109
|
setMetadata(m) { this.data.metadata = m; }
|
|
109
|
-
toDict() {
|
|
110
|
+
toDict() {
|
|
111
|
+
// Tag the run's environment (e.g. "sandbox") from config as metadata.environment so the server
|
|
112
|
+
// routes it to the matching data-namespace. Explicit per-trace metadata.environment always wins.
|
|
113
|
+
const env = getConfig().environment;
|
|
114
|
+
if (env && !(this.data.metadata && "environment" in this.data.metadata)) {
|
|
115
|
+
this.data.metadata = { ...(this.data.metadata || {}), environment: env };
|
|
116
|
+
}
|
|
117
|
+
return this.data;
|
|
118
|
+
}
|
|
110
119
|
}
|