0xtrace 1.0.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/index.d.mts +14 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +19 -0
- package/src/index.ts +37 -0
- package/tsconfig.json +23 -0
- package/tsup.config.ts +12 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface TracePayload {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
stepIndex: number;
|
|
4
|
+
model: string;
|
|
5
|
+
messages: any[];
|
|
6
|
+
latencyMs: number;
|
|
7
|
+
tokensIn: number;
|
|
8
|
+
tokensOut: number;
|
|
9
|
+
estimatedCostUsd: number;
|
|
10
|
+
isStream?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function traceLlmCall(payload: TracePayload): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export { type TracePayload, traceLlmCall };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface TracePayload {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
stepIndex: number;
|
|
4
|
+
model: string;
|
|
5
|
+
messages: any[];
|
|
6
|
+
latencyMs: number;
|
|
7
|
+
tokensIn: number;
|
|
8
|
+
tokensOut: number;
|
|
9
|
+
estimatedCostUsd: number;
|
|
10
|
+
isStream?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function traceLlmCall(payload: TracePayload): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export { type TracePayload, traceLlmCall };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var l=(r,e)=>{for(var t in e)s(r,t,{get:e[t],enumerable:!0})},m=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of c(e))!i.call(r,o)&&o!==t&&s(r,o,{get:()=>e[o],enumerable:!(n=a(e,o))||n.enumerable});return r};var S=r=>m(s({},"__esModule",{value:!0}),r);var u={};l(u,{traceLlmCall:()=>d});module.exports=S(u);async function d(r){let e=process.env.UPSTASH_REDIS_REST_URL,t=process.env.UPSTASH_REDIS_REST_TOKEN;if(!(!e||!t))try{fetch(`${e}/lpush/0xtrace_queue`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({...r,timestamp:new Date().toISOString()})}).catch(n=>console.error(n))}catch(n){console.error(n)}}0&&(module.exports={traceLlmCall});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function o(n){let r=process.env.UPSTASH_REDIS_REST_URL,t=process.env.UPSTASH_REDIS_REST_TOKEN;if(!(!r||!t))try{fetch(`${r}/lpush/0xtrace_queue`,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify({...n,timestamp:new Date().toISOString()})}).catch(e=>console.error(e))}catch(e){console.error(e)}}export{o as traceLlmCall};
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "0xtrace",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"build": "tsup",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"author": "Sidhant Kumar",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@types/node": "^25.9.1",
|
|
16
|
+
"tsup": "^8.5.1",
|
|
17
|
+
"typescript": "^6.0.3"
|
|
18
|
+
}
|
|
19
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface TracePayload {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
stepIndex: number;
|
|
4
|
+
model: string;
|
|
5
|
+
messages: any[];
|
|
6
|
+
latencyMs: number;
|
|
7
|
+
tokensIn: number;
|
|
8
|
+
tokensOut: number;
|
|
9
|
+
estimatedCostUsd: number;
|
|
10
|
+
isStream?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// Import process for Node.js type support
|
|
15
|
+
|
|
16
|
+
export async function traceLlmCall(payload: TracePayload) {
|
|
17
|
+
const redisUrl = process.env.UPSTASH_REDIS_REST_URL;
|
|
18
|
+
const redisToken = process.env.UPSTASH_REDIS_REST_TOKEN;
|
|
19
|
+
|
|
20
|
+
if (!redisUrl || !redisToken) return;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
fetch(`${redisUrl}/lpush/0xtrace_queue`, {
|
|
24
|
+
method: "POST",
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${redisToken}`,
|
|
27
|
+
"Content-Type": "application/json",
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify({
|
|
30
|
+
...payload,
|
|
31
|
+
timestamp: new Date().toISOString(),
|
|
32
|
+
}),
|
|
33
|
+
}).catch((e) => console.error(e));
|
|
34
|
+
} catch (error) {
|
|
35
|
+
console.error(error);
|
|
36
|
+
}
|
|
37
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2022",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"forceConsistentCasingInFileNames": true,
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"types": [
|
|
12
|
+
"node"
|
|
13
|
+
],
|
|
14
|
+
"ignoreDeprecations": "6.0"
|
|
15
|
+
},
|
|
16
|
+
"include": [
|
|
17
|
+
"src/**/*"
|
|
18
|
+
],
|
|
19
|
+
"exclude": [
|
|
20
|
+
"node_modules",
|
|
21
|
+
"dist"
|
|
22
|
+
]
|
|
23
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// If the 'tsup' types are not available in this environment, suppress the import error
|
|
2
|
+
// to allow building without ambient module augmentation files.
|
|
3
|
+
// @ts-ignore: module 'tsup' may be missing in some environments
|
|
4
|
+
import { defineConfig } from "tsup";
|
|
5
|
+
|
|
6
|
+
export default (defineConfig as any)({
|
|
7
|
+
entry: ["src/index.ts"],
|
|
8
|
+
format: ["cjs", "esm"],
|
|
9
|
+
dts: true,
|
|
10
|
+
clean: true,
|
|
11
|
+
minify: true
|
|
12
|
+
});
|