@ato-sdk/js 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.
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Core types for ATO SDK traces
3
+ */
4
+ interface AtoTrace {
5
+ id: string;
6
+ provider: string;
7
+ model: string;
8
+ inputTokens: number;
9
+ outputTokens: number;
10
+ cachedTokens: number;
11
+ totalTokens: number;
12
+ costUsd: number;
13
+ durationMs: number;
14
+ status: 'success' | 'error';
15
+ error?: string;
16
+ metadata: Record<string, unknown>;
17
+ timestamp: string;
18
+ sessionId?: string;
19
+ userId?: string;
20
+ tags?: string[];
21
+ }
22
+ interface AtoConfig {
23
+ /** ATO Cloud API key (from app.agentictool.ai/settings) */
24
+ apiKey?: string;
25
+ /** ATO Cloud endpoint (default: https://api.agentictool.ai) */
26
+ endpoint?: string;
27
+ /** Send traces in batches for performance (default: true) */
28
+ batching?: boolean;
29
+ /** Batch flush interval in ms (default: 5000) */
30
+ flushInterval?: number;
31
+ /** Max batch size before auto-flush (default: 50) */
32
+ maxBatchSize?: number;
33
+ /** Log traces to console for debugging (default: false) */
34
+ debug?: boolean;
35
+ /** Default tags applied to all traces */
36
+ defaultTags?: string[];
37
+ /** Default metadata applied to all traces */
38
+ defaultMetadata?: Record<string, unknown>;
39
+ /** Session ID for grouping traces */
40
+ sessionId?: string;
41
+ /** User ID for attribution */
42
+ userId?: string;
43
+ /** Disable sending to cloud (local logging only) */
44
+ localOnly?: boolean;
45
+ }
46
+ interface BatchPayload {
47
+ traces: AtoTrace[];
48
+ sdk: string;
49
+ sdkVersion: string;
50
+ sentAt: string;
51
+ }
52
+
53
+ /**
54
+ * ATO Client — manages trace collection and cloud sync
55
+ */
56
+
57
+ declare class AtoClient {
58
+ private config;
59
+ private queue;
60
+ private timer;
61
+ constructor(config?: AtoConfig);
62
+ /**
63
+ * Record a trace
64
+ */
65
+ capture(trace: AtoTrace): void;
66
+ /**
67
+ * Flush pending traces to ATO Cloud
68
+ */
69
+ flush(): Promise<void>;
70
+ /**
71
+ * Shutdown — flush remaining traces
72
+ */
73
+ shutdown(): Promise<void>;
74
+ getConfig(): AtoConfig;
75
+ }
76
+ /**
77
+ * Initialize the global ATO client
78
+ */
79
+ declare function init(config?: AtoConfig): AtoClient;
80
+ /**
81
+ * Get or create the global client
82
+ */
83
+ declare function getClient(): AtoClient;
84
+ /**
85
+ * Generate a unique trace ID
86
+ */
87
+ declare function generateTraceId(): string;
88
+
89
+ /**
90
+ * LLM model pricing (per 1M tokens)
91
+ * Updated: April 2026
92
+ */
93
+ interface ModelPricing {
94
+ input: number;
95
+ output: number;
96
+ cached?: number;
97
+ }
98
+ declare const MODEL_PRICING: Record<string, ModelPricing>;
99
+ /**
100
+ * Calculate cost for a given model and token usage
101
+ */
102
+ declare function calculateCost(model: string, inputTokens: number, outputTokens: number, cachedTokens?: number): number;
103
+
104
+ export { type AtoConfig as A, type BatchPayload as B, MODEL_PRICING as M, type AtoTrace as a, AtoClient as b, calculateCost as c, type ModelPricing as d, generateTraceId as e, getClient as g, init as i };
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@ato-sdk/js",
3
+ "version": "0.1.0",
4
+ "description": "Auto-capture LLM traces for ATO — works with Anthropic, OpenAI, and any LLM provider",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js",
12
+ "types": "./dist/index.d.ts"
13
+ },
14
+ "./anthropic": {
15
+ "import": "./dist/anthropic.mjs",
16
+ "require": "./dist/anthropic.js",
17
+ "types": "./dist/anthropic.d.ts"
18
+ },
19
+ "./openai": {
20
+ "import": "./dist/openai.mjs",
21
+ "require": "./dist/openai.js",
22
+ "types": "./dist/openai.d.ts"
23
+ }
24
+ },
25
+ "files": [
26
+ "dist"
27
+ ],
28
+ "scripts": {
29
+ "build": "tsup src/index.ts src/anthropic.ts src/openai.ts --format cjs,esm --dts --clean",
30
+ "dev": "tsup src/index.ts src/anthropic.ts src/openai.ts --format cjs,esm --dts --watch"
31
+ },
32
+ "keywords": [
33
+ "ato",
34
+ "llm",
35
+ "observability",
36
+ "tracing",
37
+ "anthropic",
38
+ "openai",
39
+ "claude",
40
+ "gpt",
41
+ "ai",
42
+ "monitoring",
43
+ "cost-tracking"
44
+ ],
45
+ "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/WillNigri/Agentic-Tool-Optimization"
49
+ },
50
+ "homepage": "https://agentictool.ai",
51
+ "devDependencies": {
52
+ "tsup": "^8.0.0",
53
+ "typescript": "^5.4.0"
54
+ },
55
+ "peerDependencies": {
56
+ "@anthropic-ai/sdk": ">=0.20.0",
57
+ "openai": ">=4.0.0"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "@anthropic-ai/sdk": { "optional": true },
61
+ "openai": { "optional": true }
62
+ }
63
+ }