@analytix402/sdk 0.1.1 → 0.1.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.
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Analytix402 SDK Types
3
+ */
4
+ interface Analytix402Config {
5
+ /**
6
+ * Your Analytix402 API key (starts with ax_live_ or ax_test_)
7
+ */
8
+ apiKey: string;
9
+ /**
10
+ * Base URL for the Analytix402 API
11
+ * @default "https://analytix402.com"
12
+ */
13
+ baseUrl?: string;
14
+ /**
15
+ * Enable debug logging
16
+ * @default false
17
+ */
18
+ debug?: boolean;
19
+ /**
20
+ * Maximum number of events to batch before sending
21
+ * @default 100
22
+ */
23
+ batchSize?: number;
24
+ /**
25
+ * Maximum time (ms) to wait before flushing events
26
+ * @default 5000
27
+ */
28
+ flushInterval?: number;
29
+ /**
30
+ * Maximum number of retry attempts for failed requests
31
+ * @default 3
32
+ */
33
+ maxRetries?: number;
34
+ /**
35
+ * Maximum events to queue when offline
36
+ * @default 1000
37
+ */
38
+ maxQueueSize?: number;
39
+ /**
40
+ * Request timeout in milliseconds
41
+ * @default 10000
42
+ */
43
+ timeout?: number;
44
+ /**
45
+ * Paths to exclude from tracking (supports wildcards)
46
+ * @default ["/health", "/healthz", "/ready", "/metrics"]
47
+ */
48
+ excludePaths?: string[];
49
+ /**
50
+ * Custom function to extract endpoint name from request
51
+ */
52
+ getEndpointName?: (req: RequestInfo) => string;
53
+ /**
54
+ * Custom function to determine if request should be tracked
55
+ */
56
+ shouldTrack?: (req: RequestInfo) => boolean;
57
+ /**
58
+ * Agent identifier for multi-agent tracking
59
+ */
60
+ agentId?: string;
61
+ /**
62
+ * Agent friendly name
63
+ */
64
+ agentName?: string;
65
+ /**
66
+ * Automatically send a heartbeat on client creation to register
67
+ * the agent in the dashboard immediately.
68
+ * @default false
69
+ */
70
+ autoConnect?: boolean;
71
+ /**
72
+ * Interval in milliseconds to send periodic heartbeats.
73
+ * Set to 0 to disable. Requires agentId.
74
+ * @default 0
75
+ */
76
+ heartbeatIntervalMs?: number;
77
+ }
78
+ interface RequestEvent {
79
+ type: 'request';
80
+ method: string;
81
+ path: string;
82
+ endpoint?: string;
83
+ statusCode: number;
84
+ responseTimeMs: number;
85
+ payment?: PaymentInfo;
86
+ /** Agent identifier */
87
+ agentId?: string;
88
+ /** Task identifier for grouping actions */
89
+ taskId?: string;
90
+ /** Custom metadata */
91
+ metadata?: Record<string, unknown>;
92
+ timestamp: string;
93
+ ip?: string;
94
+ userAgent?: string;
95
+ }
96
+ interface PaymentInfo {
97
+ /** Payment amount */
98
+ amount: string;
99
+ /** Currency (e.g., "USDC") */
100
+ currency: string;
101
+ /** Payer wallet address */
102
+ wallet: string;
103
+ /** Payment status */
104
+ status: 'success' | 'failed' | 'pending';
105
+ /** Transaction hash if available */
106
+ txHash?: string;
107
+ /** Facilitator URL */
108
+ facilitator?: string;
109
+ }
110
+ interface HeartbeatEvent {
111
+ type: 'heartbeat';
112
+ agentId: string;
113
+ status: 'healthy' | 'degraded' | 'error';
114
+ metadata?: Record<string, unknown>;
115
+ timestamp: string;
116
+ }
117
+ interface TaskOutcome {
118
+ type: 'task_outcome';
119
+ agentId?: string;
120
+ taskId: string;
121
+ success: boolean;
122
+ durationMs?: number;
123
+ cost?: number;
124
+ metadata?: Record<string, unknown>;
125
+ timestamp: string;
126
+ }
127
+ interface LLMUsageEvent {
128
+ type: 'llm_usage';
129
+ agentId?: string;
130
+ taskId?: string;
131
+ model: string;
132
+ provider: string;
133
+ inputTokens: number;
134
+ outputTokens: number;
135
+ totalTokens: number;
136
+ costUsd?: number;
137
+ durationMs?: number;
138
+ metadata?: Record<string, unknown>;
139
+ timestamp: string;
140
+ }
141
+ interface BatchPayload {
142
+ events: (RequestEvent | HeartbeatEvent | TaskOutcome | LLMUsageEvent)[];
143
+ sdk: {
144
+ name: string;
145
+ version: string;
146
+ };
147
+ sentAt: string;
148
+ }
149
+ interface RequestInfo {
150
+ method: string;
151
+ path: string;
152
+ url: string;
153
+ headers: Record<string, string | string[] | undefined>;
154
+ ip?: string;
155
+ }
156
+ interface ResponseInfo {
157
+ statusCode: number;
158
+ headers: Record<string, string | string[] | undefined>;
159
+ }
160
+ interface Analytix402Client {
161
+ /**
162
+ * Track a request event
163
+ */
164
+ track(event: RequestEvent): void;
165
+ /**
166
+ * Flush all queued events immediately
167
+ */
168
+ flush(): Promise<void>;
169
+ /**
170
+ * Shutdown the client gracefully
171
+ */
172
+ shutdown(): Promise<void>;
173
+ /**
174
+ * Send a heartbeat signal
175
+ */
176
+ heartbeat(status?: 'healthy' | 'degraded' | 'error', metadata?: Record<string, unknown>): void;
177
+ /**
178
+ * Report a task outcome
179
+ */
180
+ reportOutcome(taskId: string, success: boolean, options?: {
181
+ durationMs?: number;
182
+ cost?: number;
183
+ metadata?: Record<string, unknown>;
184
+ }): void;
185
+ /**
186
+ * Start a task and return a task tracker
187
+ */
188
+ startTask(taskId?: string): TaskTracker;
189
+ /** Track LLM token usage */
190
+ trackLLM(usage: {
191
+ model: string;
192
+ provider: string;
193
+ inputTokens: number;
194
+ outputTokens: number;
195
+ costUsd?: number;
196
+ durationMs?: number;
197
+ taskId?: string;
198
+ metadata?: Record<string, unknown>;
199
+ }): void;
200
+ }
201
+ interface TaskTracker {
202
+ taskId: string;
203
+ /** End the task and report outcome */
204
+ end(success: boolean, metadata?: Record<string, unknown>): void;
205
+ }
206
+ interface ExpressRequest {
207
+ method: string;
208
+ path: string;
209
+ originalUrl: string;
210
+ url: string;
211
+ headers: Record<string, string | string[] | undefined>;
212
+ ip?: string;
213
+ get(name: string): string | undefined;
214
+ }
215
+ interface ExpressResponse {
216
+ statusCode: number;
217
+ getHeader(name: string): string | number | string[] | undefined;
218
+ on(event: string, callback: () => void): void;
219
+ }
220
+ type ExpressNextFunction = (err?: unknown) => void;
221
+ type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
222
+ type AgentStatus = 'active' | 'paused' | 'killed';
223
+ type BreakerType = 'spend_limit' | 'rate_limit' | 'error_limit';
224
+ type BreakerAction = 'block' | 'alert' | 'throttle';
225
+ type TransactionType = 'deposit' | 'withdrawal' | 'spend' | 'earning' | 'allocation';
226
+ type TransactionStatus = 'pending' | 'confirmed' | 'failed';
227
+ interface AgentRow {
228
+ id: string;
229
+ user_id: string;
230
+ agent_id: string;
231
+ name: string | null;
232
+ description: string | null;
233
+ status: AgentStatus;
234
+ balance: number;
235
+ total_requests: number;
236
+ total_spent: number;
237
+ error_rate: number;
238
+ avg_response_time: number;
239
+ last_seen_at: string | null;
240
+ first_seen_at: string;
241
+ created_at: string;
242
+ updated_at: string;
243
+ metadata: Record<string, unknown>;
244
+ }
245
+ interface AgentActionRow {
246
+ id: string;
247
+ user_id: string;
248
+ agent_db_id: string;
249
+ action_type: string;
250
+ task_id: string | null;
251
+ details: Record<string, unknown>;
252
+ created_at: string;
253
+ }
254
+ interface AgentHeartbeatRow {
255
+ id: string;
256
+ user_id: string;
257
+ agent_db_id: string;
258
+ status: 'healthy' | 'degraded' | 'error';
259
+ metadata: Record<string, unknown>;
260
+ created_at: string;
261
+ }
262
+ interface CircuitBreakerRow {
263
+ id: string;
264
+ user_id: string;
265
+ agent_db_id: string | null;
266
+ breaker_type: BreakerType;
267
+ threshold: number;
268
+ window_minutes: number;
269
+ action: BreakerAction;
270
+ enabled: boolean;
271
+ tripped: boolean;
272
+ tripped_at: string | null;
273
+ reset_at: string | null;
274
+ created_at: string;
275
+ updated_at: string;
276
+ }
277
+ interface TransactionRow {
278
+ id: string;
279
+ user_id: string;
280
+ type: TransactionType;
281
+ amount: number;
282
+ description: string | null;
283
+ agent_id: string | null;
284
+ tx_hash: string | null;
285
+ chain: string | null;
286
+ status: TransactionStatus;
287
+ created_at: string;
288
+ }
289
+
290
+ export type { Analytix402Config as A, BatchPayload as B, CircuitBreakerRow as C, ExpressMiddleware as E, HeartbeatEvent as H, LLMUsageEvent as L, PaymentInfo as P, RequestEvent as R, TaskOutcome as T, Analytix402Client as a, AgentActionRow as b, AgentHeartbeatRow as c, AgentRow as d, AgentStatus as e, BreakerAction as f, BreakerType as g, ExpressNextFunction as h, ExpressRequest as i, ExpressResponse as j, RequestInfo as k, ResponseInfo as l, TaskTracker as m, TransactionRow as n, TransactionStatus as o, TransactionType as p };
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Analytix402 SDK Types
3
+ */
4
+ interface Analytix402Config {
5
+ /**
6
+ * Your Analytix402 API key (starts with ax_live_ or ax_test_)
7
+ */
8
+ apiKey: string;
9
+ /**
10
+ * Base URL for the Analytix402 API
11
+ * @default "https://analytix402.com"
12
+ */
13
+ baseUrl?: string;
14
+ /**
15
+ * Enable debug logging
16
+ * @default false
17
+ */
18
+ debug?: boolean;
19
+ /**
20
+ * Maximum number of events to batch before sending
21
+ * @default 100
22
+ */
23
+ batchSize?: number;
24
+ /**
25
+ * Maximum time (ms) to wait before flushing events
26
+ * @default 5000
27
+ */
28
+ flushInterval?: number;
29
+ /**
30
+ * Maximum number of retry attempts for failed requests
31
+ * @default 3
32
+ */
33
+ maxRetries?: number;
34
+ /**
35
+ * Maximum events to queue when offline
36
+ * @default 1000
37
+ */
38
+ maxQueueSize?: number;
39
+ /**
40
+ * Request timeout in milliseconds
41
+ * @default 10000
42
+ */
43
+ timeout?: number;
44
+ /**
45
+ * Paths to exclude from tracking (supports wildcards)
46
+ * @default ["/health", "/healthz", "/ready", "/metrics"]
47
+ */
48
+ excludePaths?: string[];
49
+ /**
50
+ * Custom function to extract endpoint name from request
51
+ */
52
+ getEndpointName?: (req: RequestInfo) => string;
53
+ /**
54
+ * Custom function to determine if request should be tracked
55
+ */
56
+ shouldTrack?: (req: RequestInfo) => boolean;
57
+ /**
58
+ * Agent identifier for multi-agent tracking
59
+ */
60
+ agentId?: string;
61
+ /**
62
+ * Agent friendly name
63
+ */
64
+ agentName?: string;
65
+ /**
66
+ * Automatically send a heartbeat on client creation to register
67
+ * the agent in the dashboard immediately.
68
+ * @default false
69
+ */
70
+ autoConnect?: boolean;
71
+ /**
72
+ * Interval in milliseconds to send periodic heartbeats.
73
+ * Set to 0 to disable. Requires agentId.
74
+ * @default 0
75
+ */
76
+ heartbeatIntervalMs?: number;
77
+ }
78
+ interface RequestEvent {
79
+ type: 'request';
80
+ method: string;
81
+ path: string;
82
+ endpoint?: string;
83
+ statusCode: number;
84
+ responseTimeMs: number;
85
+ payment?: PaymentInfo;
86
+ /** Agent identifier */
87
+ agentId?: string;
88
+ /** Task identifier for grouping actions */
89
+ taskId?: string;
90
+ /** Custom metadata */
91
+ metadata?: Record<string, unknown>;
92
+ timestamp: string;
93
+ ip?: string;
94
+ userAgent?: string;
95
+ }
96
+ interface PaymentInfo {
97
+ /** Payment amount */
98
+ amount: string;
99
+ /** Currency (e.g., "USDC") */
100
+ currency: string;
101
+ /** Payer wallet address */
102
+ wallet: string;
103
+ /** Payment status */
104
+ status: 'success' | 'failed' | 'pending';
105
+ /** Transaction hash if available */
106
+ txHash?: string;
107
+ /** Facilitator URL */
108
+ facilitator?: string;
109
+ }
110
+ interface HeartbeatEvent {
111
+ type: 'heartbeat';
112
+ agentId: string;
113
+ status: 'healthy' | 'degraded' | 'error';
114
+ metadata?: Record<string, unknown>;
115
+ timestamp: string;
116
+ }
117
+ interface TaskOutcome {
118
+ type: 'task_outcome';
119
+ agentId?: string;
120
+ taskId: string;
121
+ success: boolean;
122
+ durationMs?: number;
123
+ cost?: number;
124
+ metadata?: Record<string, unknown>;
125
+ timestamp: string;
126
+ }
127
+ interface LLMUsageEvent {
128
+ type: 'llm_usage';
129
+ agentId?: string;
130
+ taskId?: string;
131
+ model: string;
132
+ provider: string;
133
+ inputTokens: number;
134
+ outputTokens: number;
135
+ totalTokens: number;
136
+ costUsd?: number;
137
+ durationMs?: number;
138
+ metadata?: Record<string, unknown>;
139
+ timestamp: string;
140
+ }
141
+ interface BatchPayload {
142
+ events: (RequestEvent | HeartbeatEvent | TaskOutcome | LLMUsageEvent)[];
143
+ sdk: {
144
+ name: string;
145
+ version: string;
146
+ };
147
+ sentAt: string;
148
+ }
149
+ interface RequestInfo {
150
+ method: string;
151
+ path: string;
152
+ url: string;
153
+ headers: Record<string, string | string[] | undefined>;
154
+ ip?: string;
155
+ }
156
+ interface ResponseInfo {
157
+ statusCode: number;
158
+ headers: Record<string, string | string[] | undefined>;
159
+ }
160
+ interface Analytix402Client {
161
+ /**
162
+ * Track a request event
163
+ */
164
+ track(event: RequestEvent): void;
165
+ /**
166
+ * Flush all queued events immediately
167
+ */
168
+ flush(): Promise<void>;
169
+ /**
170
+ * Shutdown the client gracefully
171
+ */
172
+ shutdown(): Promise<void>;
173
+ /**
174
+ * Send a heartbeat signal
175
+ */
176
+ heartbeat(status?: 'healthy' | 'degraded' | 'error', metadata?: Record<string, unknown>): void;
177
+ /**
178
+ * Report a task outcome
179
+ */
180
+ reportOutcome(taskId: string, success: boolean, options?: {
181
+ durationMs?: number;
182
+ cost?: number;
183
+ metadata?: Record<string, unknown>;
184
+ }): void;
185
+ /**
186
+ * Start a task and return a task tracker
187
+ */
188
+ startTask(taskId?: string): TaskTracker;
189
+ /** Track LLM token usage */
190
+ trackLLM(usage: {
191
+ model: string;
192
+ provider: string;
193
+ inputTokens: number;
194
+ outputTokens: number;
195
+ costUsd?: number;
196
+ durationMs?: number;
197
+ taskId?: string;
198
+ metadata?: Record<string, unknown>;
199
+ }): void;
200
+ }
201
+ interface TaskTracker {
202
+ taskId: string;
203
+ /** End the task and report outcome */
204
+ end(success: boolean, metadata?: Record<string, unknown>): void;
205
+ }
206
+ interface ExpressRequest {
207
+ method: string;
208
+ path: string;
209
+ originalUrl: string;
210
+ url: string;
211
+ headers: Record<string, string | string[] | undefined>;
212
+ ip?: string;
213
+ get(name: string): string | undefined;
214
+ }
215
+ interface ExpressResponse {
216
+ statusCode: number;
217
+ getHeader(name: string): string | number | string[] | undefined;
218
+ on(event: string, callback: () => void): void;
219
+ }
220
+ type ExpressNextFunction = (err?: unknown) => void;
221
+ type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
222
+ type AgentStatus = 'active' | 'paused' | 'killed';
223
+ type BreakerType = 'spend_limit' | 'rate_limit' | 'error_limit';
224
+ type BreakerAction = 'block' | 'alert' | 'throttle';
225
+ type TransactionType = 'deposit' | 'withdrawal' | 'spend' | 'earning' | 'allocation';
226
+ type TransactionStatus = 'pending' | 'confirmed' | 'failed';
227
+ interface AgentRow {
228
+ id: string;
229
+ user_id: string;
230
+ agent_id: string;
231
+ name: string | null;
232
+ description: string | null;
233
+ status: AgentStatus;
234
+ balance: number;
235
+ total_requests: number;
236
+ total_spent: number;
237
+ error_rate: number;
238
+ avg_response_time: number;
239
+ last_seen_at: string | null;
240
+ first_seen_at: string;
241
+ created_at: string;
242
+ updated_at: string;
243
+ metadata: Record<string, unknown>;
244
+ }
245
+ interface AgentActionRow {
246
+ id: string;
247
+ user_id: string;
248
+ agent_db_id: string;
249
+ action_type: string;
250
+ task_id: string | null;
251
+ details: Record<string, unknown>;
252
+ created_at: string;
253
+ }
254
+ interface AgentHeartbeatRow {
255
+ id: string;
256
+ user_id: string;
257
+ agent_db_id: string;
258
+ status: 'healthy' | 'degraded' | 'error';
259
+ metadata: Record<string, unknown>;
260
+ created_at: string;
261
+ }
262
+ interface CircuitBreakerRow {
263
+ id: string;
264
+ user_id: string;
265
+ agent_db_id: string | null;
266
+ breaker_type: BreakerType;
267
+ threshold: number;
268
+ window_minutes: number;
269
+ action: BreakerAction;
270
+ enabled: boolean;
271
+ tripped: boolean;
272
+ tripped_at: string | null;
273
+ reset_at: string | null;
274
+ created_at: string;
275
+ updated_at: string;
276
+ }
277
+ interface TransactionRow {
278
+ id: string;
279
+ user_id: string;
280
+ type: TransactionType;
281
+ amount: number;
282
+ description: string | null;
283
+ agent_id: string | null;
284
+ tx_hash: string | null;
285
+ chain: string | null;
286
+ status: TransactionStatus;
287
+ created_at: string;
288
+ }
289
+
290
+ export type { Analytix402Config as A, BatchPayload as B, CircuitBreakerRow as C, ExpressMiddleware as E, HeartbeatEvent as H, LLMUsageEvent as L, PaymentInfo as P, RequestEvent as R, TaskOutcome as T, Analytix402Client as a, AgentActionRow as b, AgentHeartbeatRow as c, AgentRow as d, AgentStatus as e, BreakerAction as f, BreakerType as g, ExpressNextFunction as h, ExpressRequest as i, ExpressResponse as j, RequestInfo as k, ResponseInfo as l, TaskTracker as m, TransactionRow as n, TransactionStatus as o, TransactionType as p };
@@ -0,0 +1,67 @@
1
+ import { A as Analytix402Config, a as Analytix402Client } from '../types-C67qDpYb.mjs';
2
+
3
+ /**
4
+ * Analytix402 Anthropic Wrapper
5
+ *
6
+ * Auto-instruments Anthropic SDK calls to track LLM usage,
7
+ * costs, and latency through Analytix402.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import Anthropic from '@anthropic-ai/sdk';
12
+ * import { withAnalytix } from '@analytix402/sdk/anthropic';
13
+ *
14
+ * const anthropic = withAnalytix(new Anthropic(), {
15
+ * apiKey: 'ax_live_your_key_here',
16
+ * });
17
+ *
18
+ * // All calls are now auto-tracked
19
+ * const msg = await anthropic.messages.create({
20
+ * model: 'claude-sonnet-4-5-20250929',
21
+ * max_tokens: 1024,
22
+ * messages: [{ role: 'user', content: 'Hello' }],
23
+ * });
24
+ * ```
25
+ */
26
+
27
+ /** Minimal Anthropic SDK shape — avoids hard dependency on the @anthropic-ai/sdk package. */
28
+ interface AnthropicUsage {
29
+ input_tokens: number;
30
+ output_tokens: number;
31
+ }
32
+ interface AnthropicMessage {
33
+ id?: string;
34
+ model?: string;
35
+ type?: string;
36
+ usage?: AnthropicUsage;
37
+ [key: string]: unknown;
38
+ }
39
+ interface AnthropicMessages {
40
+ create(body: Record<string, unknown>, options?: Record<string, unknown>): Promise<AnthropicMessage>;
41
+ }
42
+ interface AnthropicLike {
43
+ messages: AnthropicMessages;
44
+ [key: string]: unknown;
45
+ }
46
+ interface AnthropicWrapperOptions extends Analytix402Config {
47
+ /**
48
+ * Override cost table (USD per 1 million tokens).
49
+ * Keys are model names; values have `input` and `output` fields.
50
+ */
51
+ costPerMillionTokens?: Record<string, {
52
+ input: number;
53
+ output: number;
54
+ }>;
55
+ }
56
+ /**
57
+ * Wrap an Anthropic SDK instance to auto-track LLM usage via Analytix402.
58
+ *
59
+ * Returns a proxied instance — the original is not mutated.
60
+ */
61
+ declare function withAnalytix<T extends AnthropicLike>(anthropic: T, options: AnthropicWrapperOptions): T;
62
+ /**
63
+ * Access the Analytix402 client from a wrapped Anthropic instance.
64
+ */
65
+ declare function getAnalytixClient(anthropic: AnthropicLike): Analytix402Client | undefined;
66
+
67
+ export { type AnthropicWrapperOptions, getAnalytixClient, withAnalytix };
@@ -0,0 +1,67 @@
1
+ import { A as Analytix402Config, a as Analytix402Client } from '../types-C67qDpYb.js';
2
+
3
+ /**
4
+ * Analytix402 Anthropic Wrapper
5
+ *
6
+ * Auto-instruments Anthropic SDK calls to track LLM usage,
7
+ * costs, and latency through Analytix402.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * import Anthropic from '@anthropic-ai/sdk';
12
+ * import { withAnalytix } from '@analytix402/sdk/anthropic';
13
+ *
14
+ * const anthropic = withAnalytix(new Anthropic(), {
15
+ * apiKey: 'ax_live_your_key_here',
16
+ * });
17
+ *
18
+ * // All calls are now auto-tracked
19
+ * const msg = await anthropic.messages.create({
20
+ * model: 'claude-sonnet-4-5-20250929',
21
+ * max_tokens: 1024,
22
+ * messages: [{ role: 'user', content: 'Hello' }],
23
+ * });
24
+ * ```
25
+ */
26
+
27
+ /** Minimal Anthropic SDK shape — avoids hard dependency on the @anthropic-ai/sdk package. */
28
+ interface AnthropicUsage {
29
+ input_tokens: number;
30
+ output_tokens: number;
31
+ }
32
+ interface AnthropicMessage {
33
+ id?: string;
34
+ model?: string;
35
+ type?: string;
36
+ usage?: AnthropicUsage;
37
+ [key: string]: unknown;
38
+ }
39
+ interface AnthropicMessages {
40
+ create(body: Record<string, unknown>, options?: Record<string, unknown>): Promise<AnthropicMessage>;
41
+ }
42
+ interface AnthropicLike {
43
+ messages: AnthropicMessages;
44
+ [key: string]: unknown;
45
+ }
46
+ interface AnthropicWrapperOptions extends Analytix402Config {
47
+ /**
48
+ * Override cost table (USD per 1 million tokens).
49
+ * Keys are model names; values have `input` and `output` fields.
50
+ */
51
+ costPerMillionTokens?: Record<string, {
52
+ input: number;
53
+ output: number;
54
+ }>;
55
+ }
56
+ /**
57
+ * Wrap an Anthropic SDK instance to auto-track LLM usage via Analytix402.
58
+ *
59
+ * Returns a proxied instance — the original is not mutated.
60
+ */
61
+ declare function withAnalytix<T extends AnthropicLike>(anthropic: T, options: AnthropicWrapperOptions): T;
62
+ /**
63
+ * Access the Analytix402 client from a wrapped Anthropic instance.
64
+ */
65
+ declare function getAnalytixClient(anthropic: AnthropicLike): Analytix402Client | undefined;
66
+
67
+ export { type AnthropicWrapperOptions, getAnalytixClient, withAnalytix };