@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.
package/dist/index.d.mts CHANGED
@@ -1,212 +1,8 @@
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://api.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
- interface RequestEvent {
67
- type: 'request';
68
- method: string;
69
- path: string;
70
- endpoint?: string;
71
- statusCode: number;
72
- responseTimeMs: number;
73
- payment?: PaymentInfo;
74
- /** Agent identifier */
75
- agentId?: string;
76
- /** Task identifier for grouping actions */
77
- taskId?: string;
78
- /** Custom metadata */
79
- metadata?: Record<string, unknown>;
80
- timestamp: string;
81
- ip?: string;
82
- userAgent?: string;
83
- }
84
- interface PaymentInfo {
85
- /** Payment amount */
86
- amount: string;
87
- /** Currency (e.g., "USDC") */
88
- currency: string;
89
- /** Payer wallet address */
90
- wallet: string;
91
- /** Payment status */
92
- status: 'success' | 'failed' | 'pending';
93
- /** Transaction hash if available */
94
- txHash?: string;
95
- /** Facilitator URL */
96
- facilitator?: string;
97
- }
98
- interface HeartbeatEvent {
99
- type: 'heartbeat';
100
- agentId: string;
101
- status: 'healthy' | 'degraded' | 'error';
102
- metadata?: Record<string, unknown>;
103
- timestamp: string;
104
- }
105
- interface TaskOutcome {
106
- type: 'task_outcome';
107
- agentId?: string;
108
- taskId: string;
109
- success: boolean;
110
- durationMs?: number;
111
- cost?: number;
112
- metadata?: Record<string, unknown>;
113
- timestamp: string;
114
- }
115
- interface LLMUsageEvent {
116
- type: 'llm_usage';
117
- agentId?: string;
118
- taskId?: string;
119
- model: string;
120
- provider: string;
121
- inputTokens: number;
122
- outputTokens: number;
123
- totalTokens: number;
124
- costUsd?: number;
125
- durationMs?: number;
126
- metadata?: Record<string, unknown>;
127
- timestamp: string;
128
- }
129
- interface BatchPayload {
130
- events: (RequestEvent | HeartbeatEvent | TaskOutcome | LLMUsageEvent)[];
131
- sdk: {
132
- name: string;
133
- version: string;
134
- };
135
- sentAt: string;
136
- }
137
- interface RequestInfo {
138
- method: string;
139
- path: string;
140
- url: string;
141
- headers: Record<string, string | string[] | undefined>;
142
- ip?: string;
143
- }
144
- interface ResponseInfo {
145
- statusCode: number;
146
- headers: Record<string, string | string[] | undefined>;
147
- }
148
- interface Analytix402Client {
149
- /**
150
- * Track a request event
151
- */
152
- track(event: RequestEvent): void;
153
- /**
154
- * Flush all queued events immediately
155
- */
156
- flush(): Promise<void>;
157
- /**
158
- * Shutdown the client gracefully
159
- */
160
- shutdown(): Promise<void>;
161
- /**
162
- * Send a heartbeat signal
163
- */
164
- heartbeat(status?: 'healthy' | 'degraded' | 'error', metadata?: Record<string, unknown>): void;
165
- /**
166
- * Report a task outcome
167
- */
168
- reportOutcome(taskId: string, success: boolean, options?: {
169
- durationMs?: number;
170
- cost?: number;
171
- metadata?: Record<string, unknown>;
172
- }): void;
173
- /**
174
- * Start a task and return a task tracker
175
- */
176
- startTask(taskId?: string): TaskTracker;
177
- /** Track LLM token usage */
178
- trackLLM(usage: {
179
- model: string;
180
- provider: string;
181
- inputTokens: number;
182
- outputTokens: number;
183
- costUsd?: number;
184
- durationMs?: number;
185
- taskId?: string;
186
- metadata?: Record<string, unknown>;
187
- }): void;
188
- }
189
- interface TaskTracker {
190
- taskId: string;
191
- /** End the task and report outcome */
192
- end(success: boolean, metadata?: Record<string, unknown>): void;
193
- }
194
- interface ExpressRequest {
195
- method: string;
196
- path: string;
197
- originalUrl: string;
198
- url: string;
199
- headers: Record<string, string | string[] | undefined>;
200
- ip?: string;
201
- get(name: string): string | undefined;
202
- }
203
- interface ExpressResponse {
204
- statusCode: number;
205
- getHeader(name: string): string | number | string[] | undefined;
206
- on(event: string, callback: () => void): void;
207
- }
208
- type ExpressNextFunction = (err?: unknown) => void;
209
- type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
1
+ import { A as Analytix402Config, E as ExpressMiddleware, a as Analytix402Client } from './types-C67qDpYb.mjs';
2
+ export { b as AgentActionRow, c as AgentHeartbeatRow, d as AgentRow, e as AgentStatus, B as BatchPayload, f as BreakerAction, g as BreakerType, C as CircuitBreakerRow, h as ExpressNextFunction, i as ExpressRequest, j as ExpressResponse, H as HeartbeatEvent, L as LLMUsageEvent, P as PaymentInfo, R as RequestEvent, k as RequestInfo, l as ResponseInfo, T as TaskOutcome, m as TaskTracker, n as TransactionRow, o as TransactionStatus, p as TransactionType } from './types-C67qDpYb.mjs';
3
+ export { OpenAIWrapperOptions, withAnalytix as withAnalytixOpenAI } from './wrappers/openai.mjs';
4
+ export { AnthropicWrapperOptions, withAnalytix as withAnalytixAnthropic } from './wrappers/anthropic.mjs';
5
+ export { Analytix402Fetch, FetchWrapperOptions, createAnalytix402Fetch } from './wrappers/fetch.mjs';
210
6
 
211
7
  /**
212
8
  * Analytix402 Express Middleware
@@ -233,4 +29,4 @@ declare function createAnalytix402Client(config: Analytix402Config): Analytix402
233
29
 
234
30
  declare function createClient(config: Analytix402Config): Analytix402Client;
235
31
 
236
- export { Analytix402, type Analytix402Client, type Analytix402Config, type BatchPayload, type ExpressMiddleware, type ExpressNextFunction, type ExpressRequest, type ExpressResponse, type HeartbeatEvent, type LLMUsageEvent, type PaymentInfo, type RequestEvent, type RequestInfo, type ResponseInfo, type TaskOutcome, type TaskTracker, analytix402, createAnalytix402Client, createClient };
32
+ export { Analytix402, Analytix402Client, Analytix402Config, ExpressMiddleware, analytix402, createAnalytix402Client, createClient };
package/dist/index.d.ts CHANGED
@@ -1,212 +1,8 @@
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://api.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
- interface RequestEvent {
67
- type: 'request';
68
- method: string;
69
- path: string;
70
- endpoint?: string;
71
- statusCode: number;
72
- responseTimeMs: number;
73
- payment?: PaymentInfo;
74
- /** Agent identifier */
75
- agentId?: string;
76
- /** Task identifier for grouping actions */
77
- taskId?: string;
78
- /** Custom metadata */
79
- metadata?: Record<string, unknown>;
80
- timestamp: string;
81
- ip?: string;
82
- userAgent?: string;
83
- }
84
- interface PaymentInfo {
85
- /** Payment amount */
86
- amount: string;
87
- /** Currency (e.g., "USDC") */
88
- currency: string;
89
- /** Payer wallet address */
90
- wallet: string;
91
- /** Payment status */
92
- status: 'success' | 'failed' | 'pending';
93
- /** Transaction hash if available */
94
- txHash?: string;
95
- /** Facilitator URL */
96
- facilitator?: string;
97
- }
98
- interface HeartbeatEvent {
99
- type: 'heartbeat';
100
- agentId: string;
101
- status: 'healthy' | 'degraded' | 'error';
102
- metadata?: Record<string, unknown>;
103
- timestamp: string;
104
- }
105
- interface TaskOutcome {
106
- type: 'task_outcome';
107
- agentId?: string;
108
- taskId: string;
109
- success: boolean;
110
- durationMs?: number;
111
- cost?: number;
112
- metadata?: Record<string, unknown>;
113
- timestamp: string;
114
- }
115
- interface LLMUsageEvent {
116
- type: 'llm_usage';
117
- agentId?: string;
118
- taskId?: string;
119
- model: string;
120
- provider: string;
121
- inputTokens: number;
122
- outputTokens: number;
123
- totalTokens: number;
124
- costUsd?: number;
125
- durationMs?: number;
126
- metadata?: Record<string, unknown>;
127
- timestamp: string;
128
- }
129
- interface BatchPayload {
130
- events: (RequestEvent | HeartbeatEvent | TaskOutcome | LLMUsageEvent)[];
131
- sdk: {
132
- name: string;
133
- version: string;
134
- };
135
- sentAt: string;
136
- }
137
- interface RequestInfo {
138
- method: string;
139
- path: string;
140
- url: string;
141
- headers: Record<string, string | string[] | undefined>;
142
- ip?: string;
143
- }
144
- interface ResponseInfo {
145
- statusCode: number;
146
- headers: Record<string, string | string[] | undefined>;
147
- }
148
- interface Analytix402Client {
149
- /**
150
- * Track a request event
151
- */
152
- track(event: RequestEvent): void;
153
- /**
154
- * Flush all queued events immediately
155
- */
156
- flush(): Promise<void>;
157
- /**
158
- * Shutdown the client gracefully
159
- */
160
- shutdown(): Promise<void>;
161
- /**
162
- * Send a heartbeat signal
163
- */
164
- heartbeat(status?: 'healthy' | 'degraded' | 'error', metadata?: Record<string, unknown>): void;
165
- /**
166
- * Report a task outcome
167
- */
168
- reportOutcome(taskId: string, success: boolean, options?: {
169
- durationMs?: number;
170
- cost?: number;
171
- metadata?: Record<string, unknown>;
172
- }): void;
173
- /**
174
- * Start a task and return a task tracker
175
- */
176
- startTask(taskId?: string): TaskTracker;
177
- /** Track LLM token usage */
178
- trackLLM(usage: {
179
- model: string;
180
- provider: string;
181
- inputTokens: number;
182
- outputTokens: number;
183
- costUsd?: number;
184
- durationMs?: number;
185
- taskId?: string;
186
- metadata?: Record<string, unknown>;
187
- }): void;
188
- }
189
- interface TaskTracker {
190
- taskId: string;
191
- /** End the task and report outcome */
192
- end(success: boolean, metadata?: Record<string, unknown>): void;
193
- }
194
- interface ExpressRequest {
195
- method: string;
196
- path: string;
197
- originalUrl: string;
198
- url: string;
199
- headers: Record<string, string | string[] | undefined>;
200
- ip?: string;
201
- get(name: string): string | undefined;
202
- }
203
- interface ExpressResponse {
204
- statusCode: number;
205
- getHeader(name: string): string | number | string[] | undefined;
206
- on(event: string, callback: () => void): void;
207
- }
208
- type ExpressNextFunction = (err?: unknown) => void;
209
- type ExpressMiddleware = (req: ExpressRequest, res: ExpressResponse, next: ExpressNextFunction) => void;
1
+ import { A as Analytix402Config, E as ExpressMiddleware, a as Analytix402Client } from './types-C67qDpYb.js';
2
+ export { b as AgentActionRow, c as AgentHeartbeatRow, d as AgentRow, e as AgentStatus, B as BatchPayload, f as BreakerAction, g as BreakerType, C as CircuitBreakerRow, h as ExpressNextFunction, i as ExpressRequest, j as ExpressResponse, H as HeartbeatEvent, L as LLMUsageEvent, P as PaymentInfo, R as RequestEvent, k as RequestInfo, l as ResponseInfo, T as TaskOutcome, m as TaskTracker, n as TransactionRow, o as TransactionStatus, p as TransactionType } from './types-C67qDpYb.js';
3
+ export { OpenAIWrapperOptions, withAnalytix as withAnalytixOpenAI } from './wrappers/openai.js';
4
+ export { AnthropicWrapperOptions, withAnalytix as withAnalytixAnthropic } from './wrappers/anthropic.js';
5
+ export { Analytix402Fetch, FetchWrapperOptions, createAnalytix402Fetch } from './wrappers/fetch.js';
210
6
 
211
7
  /**
212
8
  * Analytix402 Express Middleware
@@ -233,4 +29,4 @@ declare function createAnalytix402Client(config: Analytix402Config): Analytix402
233
29
 
234
30
  declare function createClient(config: Analytix402Config): Analytix402Client;
235
31
 
236
- export { Analytix402, type Analytix402Client, type Analytix402Config, type BatchPayload, type ExpressMiddleware, type ExpressNextFunction, type ExpressRequest, type ExpressResponse, type HeartbeatEvent, type LLMUsageEvent, type PaymentInfo, type RequestEvent, type RequestInfo, type ResponseInfo, type TaskOutcome, type TaskTracker, analytix402, createAnalytix402Client, createClient };
32
+ export { Analytix402, Analytix402Client, Analytix402Config, ExpressMiddleware, analytix402, createAnalytix402Client, createClient };