retrace-sdk 0.13.0 → 0.13.2
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 +3 -3
- package/dist/config.js +3 -3
- package/dist/errors.js +1 -1
- package/dist/transport.js +5 -2
- package/package.json +2 -2
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
|
|
18
|
+
configure({ apiKey: "rt_live_..." }); // 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({
|
|
@@ -45,7 +45,7 @@ import { configure } from "retrace-sdk";
|
|
|
45
45
|
|
|
46
46
|
configure({
|
|
47
47
|
apiKey: "rt_live_...", // or RETRACE_API_KEY env var
|
|
48
|
-
baseUrl: "https://api
|
|
48
|
+
baseUrl: "https://api.retraceai.tech",
|
|
49
49
|
projectId: "...", // or RETRACE_PROJECT_ID env var
|
|
50
50
|
});
|
|
51
51
|
```
|
|
@@ -183,6 +183,6 @@ configure({ apiKey: "rt_live_...", sampleRate: 0.1 }); // Record 10% of traces
|
|
|
183
183
|
|
|
184
184
|
## Links
|
|
185
185
|
|
|
186
|
-
- [Documentation](https://
|
|
186
|
+
- [Documentation](https://retraceai.tech/docs)
|
|
187
187
|
- [GitHub](https://github.com/yash1511-bogam/retrace)
|
|
188
188
|
- [npm](https://www.npmjs.com/package/retrace-sdk)
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const config = {
|
|
2
2
|
apiKey: process.env.RETRACE_API_KEY || "",
|
|
3
|
-
baseUrl: process.env.RETRACE_BASE_URL || "https://api
|
|
3
|
+
baseUrl: process.env.RETRACE_BASE_URL || "https://api.retraceai.tech",
|
|
4
4
|
wsUrl: "",
|
|
5
5
|
projectId: process.env.RETRACE_PROJECT_ID || undefined,
|
|
6
6
|
enabled: !["false", "0"].includes((process.env.RETRACE_ENABLED || "true").toLowerCase()),
|
|
@@ -17,7 +17,7 @@ const config = {
|
|
|
17
17
|
config.wsUrl = config.baseUrl.replace("https://", "wss://").replace("http://", "ws://");
|
|
18
18
|
export function configure(opts) {
|
|
19
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://
|
|
20
|
+
throw new Error("Invalid Retrace API key. Keys must start with 'rt_live_'. Get yours at https://retraceai.tech/settings");
|
|
21
21
|
}
|
|
22
22
|
Object.assign(config, opts);
|
|
23
23
|
if (opts.baseUrl && !opts.wsUrl) {
|
|
@@ -34,7 +34,7 @@ export function configure(opts) {
|
|
|
34
34
|
}
|
|
35
35
|
export function requireApiKey() {
|
|
36
36
|
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://
|
|
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
38
|
}
|
|
39
39
|
return config.apiKey;
|
|
40
40
|
}
|
package/dist/errors.js
CHANGED
|
@@ -5,7 +5,7 @@ export class RetraceAuthError extends RetraceError {
|
|
|
5
5
|
constructor(message = "Invalid or missing API key") { super(message); this.name = "RetraceAuthError"; }
|
|
6
6
|
}
|
|
7
7
|
export class RetraceCreditsExhaustedError extends RetraceError {
|
|
8
|
-
constructor(message = "Monthly trace limit reached. Upgrade at
|
|
8
|
+
constructor(message = "Monthly trace limit reached. Upgrade at retraceai.tech/pricing") { super(message); this.name = "RetraceCreditsExhaustedError"; }
|
|
9
9
|
}
|
|
10
10
|
export class RetraceConnectionError extends RetraceError {
|
|
11
11
|
constructor(message = "Failed to connect to Retrace API") { super(message); this.name = "RetraceConnectionError"; }
|
package/dist/transport.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import WebSocket from "ws";
|
|
2
2
|
import { getConfig } from "./config.js";
|
|
3
3
|
import { classifyServerSignal } from "./errors.js";
|
|
4
|
+
// Client identifier sent on every request so the backend can attribute SDK usage/version.
|
|
5
|
+
// Keep in sync with package.json on release.
|
|
6
|
+
const CLIENT_ID = "typescript-sdk/0.13.2";
|
|
4
7
|
export class WSTransport {
|
|
5
8
|
ws = null;
|
|
6
9
|
connected = false;
|
|
@@ -265,7 +268,7 @@ export class WSTransport {
|
|
|
265
268
|
try {
|
|
266
269
|
await fetch(`${cfg.baseUrl}/api/v1/traces`, {
|
|
267
270
|
method: "POST",
|
|
268
|
-
headers: { "x-retrace-key": cfg.apiKey, "Content-Type": "application/json" },
|
|
271
|
+
headers: { "x-retrace-key": cfg.apiKey, "Content-Type": "application/json", "x-retrace-client": CLIENT_ID },
|
|
269
272
|
body,
|
|
270
273
|
keepalive: true,
|
|
271
274
|
signal: ctrl.signal,
|
|
@@ -310,7 +313,7 @@ export class HTTPTransport {
|
|
|
310
313
|
try {
|
|
311
314
|
const res = await fetch(url, {
|
|
312
315
|
method: "POST",
|
|
313
|
-
headers: { "x-retrace-key": cfg.apiKey, "Content-Type": "application/json" },
|
|
316
|
+
headers: { "x-retrace-key": cfg.apiKey, "Content-Type": "application/json", "x-retrace-client": CLIENT_ID },
|
|
314
317
|
body: payload,
|
|
315
318
|
});
|
|
316
319
|
if (res.ok)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "retrace-sdk",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2",
|
|
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",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"url": "https://github.com/yash1511-bogam/retrace-sdk",
|
|
32
32
|
"directory": "packages/sdk-typescript"
|
|
33
33
|
},
|
|
34
|
-
"homepage": "https://
|
|
34
|
+
"homepage": "https://retraceai.tech/docs/sdk-typescript",
|
|
35
35
|
"keywords": [
|
|
36
36
|
"ai",
|
|
37
37
|
"agent",
|