retrace-sdk 0.13.2 → 0.13.3

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 CHANGED
@@ -15,7 +15,7 @@ Requires Node.js 20+. ESM-only package.
15
15
  ```typescript
16
16
  import { configure, trace } from "retrace-sdk";
17
17
 
18
- configure({ apiKey: "rt_live_..." }); // Get your key at retraceai.tech/settings
18
+ configure({ apiKey: "rt_..." }); // Get your key at retraceai.tech/settings
19
19
 
20
20
  const myAgent = trace(async (prompt: string) => {
21
21
  const response = await openai.chat.completions.create({
@@ -44,7 +44,7 @@ No extra setup needed. Install the provider SDK alongside `retrace-sdk`.
44
44
  import { configure } from "retrace-sdk";
45
45
 
46
46
  configure({
47
- apiKey: "rt_live_...", // or RETRACE_API_KEY env var
47
+ apiKey: "rt_...", // or RETRACE_API_KEY env var
48
48
  baseUrl: "https://api.retraceai.tech",
49
49
  projectId: "...", // or RETRACE_PROJECT_ID env var
50
50
  });
@@ -74,7 +74,7 @@ Mark a function as resumable to enable full cascade replay from the dashboard:
74
74
  ```typescript
75
75
  import { configure, trace } from "retrace-sdk";
76
76
 
77
- configure({ apiKey: "rt_live_..." });
77
+ configure({ apiKey: "rt_..." });
78
78
 
79
79
  const myAgent = trace(async (prompt: string) => {
80
80
  const plan = await planner(prompt);
@@ -101,7 +101,7 @@ Hard ceilings that stop a runaway agent before the next call. Local limits are e
101
101
  import { configure, RetraceEnforcementError } from "retrace-sdk";
102
102
 
103
103
  configure({
104
- apiKey: "rt_live_...",
104
+ apiKey: "rt_...",
105
105
  maxStepsPerRun: 50,
106
106
  maxUsdPerRun: 2.0,
107
107
  serverEnforcement: true, // optional: also consult server policies
@@ -141,7 +141,7 @@ writeGoldenCassette("golden.json", { recorder });
141
141
  ## Sampling
142
142
 
143
143
  ```typescript
144
- configure({ apiKey: "rt_live_...", sampleRate: 0.1 }); // Record 10% of traces
144
+ configure({ apiKey: "rt_...", sampleRate: 0.1 }); // Record 10% of traces
145
145
  ```
146
146
 
147
147
  ## Changelog
package/dist/config.js CHANGED
@@ -16,8 +16,8 @@ const config = {
16
16
  };
17
17
  config.wsUrl = config.baseUrl.replace("https://", "wss://").replace("http://", "ws://");
18
18
  export function configure(opts) {
19
- if (opts.apiKey && !opts.apiKey.startsWith("rt_live_")) {
20
- throw new Error("Invalid Retrace API key. Keys must start with 'rt_live_'. Get yours at https://retraceai.tech/settings");
19
+ if (opts.apiKey && (!opts.apiKey.startsWith("rt_") || opts.apiKey.startsWith("rt_live_") || opts.apiKey.startsWith("rt_test_"))) {
20
+ throw new Error("Invalid Retrace API key. Keys must start with 'rt_'. Get yours at https://retraceai.tech/settings");
21
21
  }
22
22
  Object.assign(config, opts);
23
23
  if (opts.baseUrl && !opts.wsUrl) {
@@ -30,11 +30,12 @@ export function configure(opts) {
30
30
  if (config.enabled) {
31
31
  void import("./interceptors/install.js").then((m) => m.ensureInterceptorsInstalled()).catch(() => { });
32
32
  }
33
+ void import("./telemetry.js").then((m) => m.track("configure")).catch(() => { });
33
34
  return config;
34
35
  }
35
36
  export function requireApiKey() {
36
37
  if (!config.apiKey) {
37
- throw new Error("Retrace API key required. Call configure({ apiKey: 'rt_live_...' }) or set RETRACE_API_KEY. Get yours at https://retraceai.tech/settings");
38
+ throw new Error("Retrace API key required. Call configure({ apiKey: 'rt_...' }) or set RETRACE_API_KEY. Get yours at https://retraceai.tech/settings");
38
39
  }
39
40
  return config.apiKey;
40
41
  }
@@ -0,0 +1 @@
1
+ export declare function track(event: string, fields?: Record<string, string | number | boolean>): void;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Anonymous, opt-out diagnostic telemetry.
3
+ *
4
+ * Sends NO user code, API keys, prompts, responses, or personal information — only the SDK version,
5
+ * the runtime/OS family, an anonymous per-process id, and event/error *categories* — to the Retrace
6
+ * API's internal log ingest (forwarded to the centralized logging platform under
7
+ * service="sdk-typescript"). Fire-and-forget; never blocks, never throws.
8
+ *
9
+ * Disable entirely with RETRACE_TELEMETRY=0 (also accepts false/no/off).
10
+ */
11
+ import os from "node:os";
12
+ import { getConfig } from "./config.js";
13
+ // Per-process random id — anonymous, not linked to any account, user, or machine identity.
14
+ const ANON_ID = Math.random().toString(16).slice(2, 18);
15
+ const DISABLED = new Set(["0", "false", "no", "off"]);
16
+ // Keep in sync with package.json version.
17
+ const SDK_VERSION = "0.13.3";
18
+ function enabled() {
19
+ return !DISABLED.has((process.env.RETRACE_TELEMETRY ?? "1").trim().toLowerCase());
20
+ }
21
+ export function track(event, fields = {}) {
22
+ if (!enabled())
23
+ return;
24
+ try {
25
+ const base = (getConfig().baseUrl || "https://api.retraceai.tech").replace(/\/$/, "");
26
+ const body = JSON.stringify({
27
+ service: "sdk-typescript",
28
+ events: [
29
+ {
30
+ level: "info",
31
+ message: `sdk-typescript ${event}`,
32
+ event,
33
+ sdk_version: SDK_VERSION,
34
+ node: process.version,
35
+ os: os.platform(),
36
+ anon_id: ANON_ID,
37
+ ...fields,
38
+ },
39
+ ],
40
+ });
41
+ // Fire-and-forget; never block or throw.
42
+ void fetch(`${base}/api/v1/internal/logs`, {
43
+ method: "POST",
44
+ headers: { "Content-Type": "application/json" },
45
+ body,
46
+ }).catch(() => { });
47
+ }
48
+ catch {
49
+ /* telemetry must never affect the user's program */
50
+ }
51
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "retrace-sdk",
3
- "version": "0.13.2",
3
+ "version": "0.13.3",
4
4
  "description": "The execution replay engine for AI agents. Record, replay, fork, and share agent executions.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",