xray-sdk 0.1.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/README.md +426 -0
- package/dist/XRay.d.ts +30 -0
- package/dist/XRay.js +95 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +21 -0
- package/dist/reasoning/config.d.ts +8 -0
- package/dist/reasoning/config.js +16 -0
- package/dist/reasoning/generator.d.ts +12 -0
- package/dist/reasoning/generator.js +119 -0
- package/dist/reasoning/queue.d.ts +57 -0
- package/dist/reasoning/queue.js +309 -0
- package/dist/storage/DatabaseStorage.d.ts +21 -0
- package/dist/storage/DatabaseStorage.js +177 -0
- package/dist/storage/MemoryStorage.d.ts +9 -0
- package/dist/storage/MemoryStorage.js +35 -0
- package/dist/types/index.d.ts +59 -0
- package/dist/types/index.js +3 -0
- package/package.json +46 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoryStorage = void 0;
|
|
4
|
+
class MemoryStorage {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.executions = new Map();
|
|
7
|
+
}
|
|
8
|
+
async saveExecution(execution) {
|
|
9
|
+
this.executions.set(execution.executionId, JSON.parse(JSON.stringify(execution)));
|
|
10
|
+
console.log(`[XRay Memory] ✅ Saved execution ${execution.executionId}`);
|
|
11
|
+
}
|
|
12
|
+
async getExecutionById(executionId) {
|
|
13
|
+
const execution = this.executions.get(executionId);
|
|
14
|
+
return execution ? JSON.parse(JSON.stringify(execution)) : undefined;
|
|
15
|
+
}
|
|
16
|
+
async getAllExecutions() {
|
|
17
|
+
return Array.from(this.executions.values()).map(e => JSON.parse(JSON.stringify(e)));
|
|
18
|
+
}
|
|
19
|
+
async updateStepReasoning(executionId, stepName, reasoning) {
|
|
20
|
+
const execution = this.executions.get(executionId);
|
|
21
|
+
if (!execution) {
|
|
22
|
+
throw new Error(`Execution ${executionId} not found`);
|
|
23
|
+
}
|
|
24
|
+
const step = execution.steps.find(s => s.name === stepName);
|
|
25
|
+
if (!step) {
|
|
26
|
+
throw new Error(`Step ${stepName} not found in execution ${executionId}`);
|
|
27
|
+
}
|
|
28
|
+
step.reasoning = reasoning;
|
|
29
|
+
console.log(`[XRay Memory] ✅ Updated reasoning for ${executionId}/${stepName}`);
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
this.executions.clear();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.MemoryStorage = MemoryStorage;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface Execution {
|
|
2
|
+
executionId: string;
|
|
3
|
+
projectId?: string;
|
|
4
|
+
startedAt: string;
|
|
5
|
+
endedAt?: string;
|
|
6
|
+
metadata?: Record<string, any>;
|
|
7
|
+
steps: Step[];
|
|
8
|
+
finalOutcome?: any;
|
|
9
|
+
}
|
|
10
|
+
export interface Step {
|
|
11
|
+
name: string;
|
|
12
|
+
input?: any;
|
|
13
|
+
output?: any;
|
|
14
|
+
error?: string;
|
|
15
|
+
timestamp?: string;
|
|
16
|
+
startedAt?: string;
|
|
17
|
+
endedAt?: string;
|
|
18
|
+
durationMs?: number;
|
|
19
|
+
reasoning?: string;
|
|
20
|
+
metadata?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
export interface ReasoningJob {
|
|
23
|
+
id: string;
|
|
24
|
+
executionId: string;
|
|
25
|
+
stepName: string;
|
|
26
|
+
attempt: number;
|
|
27
|
+
status: 'pending' | 'processing' | 'completed' | 'failed';
|
|
28
|
+
createdAt: string;
|
|
29
|
+
startedAt?: string;
|
|
30
|
+
completedAt?: string;
|
|
31
|
+
error?: string;
|
|
32
|
+
nextRetryAt?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface QueueStats {
|
|
35
|
+
pending: number;
|
|
36
|
+
processing: number;
|
|
37
|
+
completed: number;
|
|
38
|
+
failed: number;
|
|
39
|
+
totalJobs: number;
|
|
40
|
+
}
|
|
41
|
+
export interface XRayConfig {
|
|
42
|
+
projectId?: string;
|
|
43
|
+
storage?: StorageProvider;
|
|
44
|
+
autoReasoning?: boolean;
|
|
45
|
+
reasoningConfig?: ReasoningConfig;
|
|
46
|
+
}
|
|
47
|
+
export interface ReasoningConfig {
|
|
48
|
+
autoProcess: boolean;
|
|
49
|
+
concurrency: number;
|
|
50
|
+
maxRetries: number;
|
|
51
|
+
retryDelays: number[];
|
|
52
|
+
debug: boolean;
|
|
53
|
+
}
|
|
54
|
+
export interface StorageProvider {
|
|
55
|
+
saveExecution(execution: Execution): Promise<void>;
|
|
56
|
+
getExecutionById(executionId: string): Promise<Execution | undefined>;
|
|
57
|
+
getAllExecutions(): Promise<Execution[]>;
|
|
58
|
+
updateStepReasoning(executionId: string, stepName: string, reasoning: string): Promise<void>;
|
|
59
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "xray-sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lightweight execution tracing for LLM pipelines with automatic reasoning generation",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"dev": "tsc --watch",
|
|
14
|
+
"prepublishOnly": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"observability",
|
|
18
|
+
"tracing",
|
|
19
|
+
"llm",
|
|
20
|
+
"pipeline",
|
|
21
|
+
"monitoring",
|
|
22
|
+
"xray",
|
|
23
|
+
"execution-tracking"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"p-queue": "^8.0.0"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"@prisma/client": "^5.22.0",
|
|
32
|
+
"openai": "^6.0.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"@prisma/client": {
|
|
36
|
+
"optional": true
|
|
37
|
+
},
|
|
38
|
+
"openai": {
|
|
39
|
+
"optional": true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"typescript": "^5.0.0",
|
|
44
|
+
"@types/node": "^20.0.0"
|
|
45
|
+
}
|
|
46
|
+
}
|