aistatus 0.0.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,202 @@
1
+ declare enum Status {
2
+ OPERATIONAL = "operational",
3
+ DEGRADED = "degraded",
4
+ DOWN = "down",
5
+ UNKNOWN = "unknown"
6
+ }
7
+ type MessageRole = "system" | "user" | "assistant" | "tool";
8
+ interface ChatMessage {
9
+ role: MessageRole | (string & {});
10
+ content: string;
11
+ name?: string;
12
+ toolCallId?: string;
13
+ }
14
+ interface ProviderConfig {
15
+ slug: string;
16
+ adapterType: string;
17
+ apiKey?: string;
18
+ env?: string;
19
+ baseUrl?: string;
20
+ aliases?: string[];
21
+ headers?: Record<string, string>;
22
+ }
23
+ interface RouteConfig {
24
+ tier?: string;
25
+ model?: string;
26
+ prefer?: string[];
27
+ allowFallback?: boolean;
28
+ providerTimeout?: number;
29
+ }
30
+ interface ProviderCallOptions {
31
+ maxTokens?: number;
32
+ temperature?: number;
33
+ topP?: number;
34
+ providerOptions?: Record<string, unknown>;
35
+ headers?: Record<string, string>;
36
+ signal?: AbortSignal;
37
+ }
38
+ interface RouteOptions extends ProviderCallOptions {
39
+ model?: string;
40
+ tier?: string;
41
+ system?: string;
42
+ allowFallback?: boolean;
43
+ timeout?: number;
44
+ prefer?: string[];
45
+ [key: string]: unknown;
46
+ }
47
+ interface Alternative {
48
+ slug: string;
49
+ name: string;
50
+ status: Status;
51
+ suggestedModel: string;
52
+ }
53
+ declare class CheckResult {
54
+ provider: string;
55
+ status: Status;
56
+ statusDetail: string | null;
57
+ model: string | null;
58
+ alternatives: Alternative[];
59
+ constructor(init: {
60
+ provider: string;
61
+ status: Status;
62
+ statusDetail?: string | null;
63
+ model?: string | null;
64
+ alternatives?: Alternative[];
65
+ });
66
+ get isAvailable(): boolean;
67
+ }
68
+ interface ModelInfo {
69
+ id: string;
70
+ name: string;
71
+ providerSlug: string;
72
+ contextLength: number;
73
+ modality: string;
74
+ promptPrice: number;
75
+ completionPrice: number;
76
+ }
77
+ interface ProviderStatus {
78
+ slug: string;
79
+ name: string;
80
+ status: Status;
81
+ statusDetail: string | null;
82
+ modelCount: number;
83
+ }
84
+ interface RouteResponseInit {
85
+ content: string;
86
+ modelUsed: string;
87
+ providerUsed: string;
88
+ wasFallback: boolean;
89
+ fallbackReason?: string | null;
90
+ inputTokens?: number;
91
+ outputTokens?: number;
92
+ costUsd?: number;
93
+ raw?: unknown;
94
+ }
95
+ declare class RouteResponse {
96
+ content: string;
97
+ modelUsed: string;
98
+ providerUsed: string;
99
+ wasFallback: boolean;
100
+ fallbackReason: string | null;
101
+ inputTokens: number;
102
+ outputTokens: number;
103
+ costUsd: number;
104
+ raw: unknown;
105
+ constructor(init: RouteResponseInit);
106
+ toString(): string;
107
+ }
108
+
109
+ declare abstract class ProviderAdapter {
110
+ readonly config: ProviderConfig;
111
+ constructor(config: ProviderConfig);
112
+ get slug(): string;
113
+ get aliases(): string[];
114
+ supportsProvider(slug: string): boolean;
115
+ stripProvider(modelId: string): string;
116
+ abstract call(modelId: string, messages: ChatMessage[], timeoutSeconds: number, options: ProviderCallOptions): Promise<RouteResponse>;
117
+ }
118
+ type ProviderAdapterConstructor = new (config: ProviderConfig) => ProviderAdapter;
119
+ declare function registerAdapterType(typeName: string, ctor: ProviderAdapterConstructor): void;
120
+ declare function createAdapter(config: ProviderConfig): ProviderAdapter;
121
+
122
+ declare class StatusAPI {
123
+ private readonly baseUrl;
124
+ private readonly timeoutMs;
125
+ constructor(baseUrl?: string, timeoutSeconds?: number);
126
+ checkProvider(slug: string): Promise<CheckResult>;
127
+ checkModel(modelId: string): Promise<CheckResult>;
128
+ acheckProvider(slug: string): Promise<CheckResult>;
129
+ acheckModel(modelId: string): Promise<CheckResult>;
130
+ providers(): Promise<ProviderStatus[]>;
131
+ model(modelId: string): Promise<ModelInfo | null>;
132
+ searchModels(query: string): Promise<ModelInfo[]>;
133
+ private get;
134
+ private parseCheck;
135
+ private parseProviderStatus;
136
+ private parseModel;
137
+ }
138
+
139
+ declare class AIStatusError extends Error {
140
+ constructor(message: string);
141
+ }
142
+ declare class AllProvidersDown extends AIStatusError {
143
+ readonly tried: string[];
144
+ constructor(tried: string[]);
145
+ }
146
+ declare class ProviderCallFailed extends AIStatusError {
147
+ readonly provider: string;
148
+ readonly model: string;
149
+ readonly cause: unknown;
150
+ constructor(provider: string, model: string, cause: unknown);
151
+ }
152
+ declare class NoBudgetMatch extends AIStatusError {
153
+ readonly maxCost: number;
154
+ readonly tier: string;
155
+ constructor(maxCost: number, tier: string);
156
+ }
157
+ declare class ProviderNotConfigured extends AIStatusError {
158
+ readonly provider: string;
159
+ readonly envName?: string;
160
+ constructor(provider: string, envName?: string);
161
+ }
162
+ declare class ProviderNotInstalled extends AIStatusError {
163
+ readonly provider: string;
164
+ readonly packageName?: string;
165
+ constructor(provider: string, packageName?: string);
166
+ }
167
+ declare class CheckAPIUnreachable extends AIStatusError {
168
+ constructor();
169
+ }
170
+
171
+ interface RouterOptions {
172
+ baseUrl?: string;
173
+ checkTimeout?: number;
174
+ providers?: string[];
175
+ autoDiscover?: boolean;
176
+ }
177
+ declare class Router {
178
+ readonly api: StatusAPI;
179
+ private readonly adapters;
180
+ private readonly adapterIndex;
181
+ private readonly tiers;
182
+ constructor(options?: RouterOptions);
183
+ registerProvider(config: ProviderConfig): void;
184
+ addTier(name: string, models: string[]): void;
185
+ route(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
186
+ aroute(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
187
+ private autoDiscover;
188
+ private indexAdapter;
189
+ private normalizeMessages;
190
+ private extractCallOptions;
191
+ private resolveModel;
192
+ private guessProvider;
193
+ private sortAndBindCandidates;
194
+ private routeModel;
195
+ private routeTier;
196
+ }
197
+
198
+ declare const VERSION = "0.0.2";
199
+ declare function route(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
200
+ declare function aroute(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
201
+
202
+ export { AIStatusError, AllProvidersDown, type Alternative, type ChatMessage, CheckAPIUnreachable, CheckResult, type MessageRole, type ModelInfo, NoBudgetMatch, ProviderAdapter, ProviderCallFailed, type ProviderCallOptions, type ProviderConfig, ProviderNotConfigured, ProviderNotInstalled, type ProviderStatus, type RouteConfig, type RouteOptions, RouteResponse, Router, type RouterOptions, Status, StatusAPI, VERSION, aroute, createAdapter, registerAdapterType, route };
@@ -0,0 +1,202 @@
1
+ declare enum Status {
2
+ OPERATIONAL = "operational",
3
+ DEGRADED = "degraded",
4
+ DOWN = "down",
5
+ UNKNOWN = "unknown"
6
+ }
7
+ type MessageRole = "system" | "user" | "assistant" | "tool";
8
+ interface ChatMessage {
9
+ role: MessageRole | (string & {});
10
+ content: string;
11
+ name?: string;
12
+ toolCallId?: string;
13
+ }
14
+ interface ProviderConfig {
15
+ slug: string;
16
+ adapterType: string;
17
+ apiKey?: string;
18
+ env?: string;
19
+ baseUrl?: string;
20
+ aliases?: string[];
21
+ headers?: Record<string, string>;
22
+ }
23
+ interface RouteConfig {
24
+ tier?: string;
25
+ model?: string;
26
+ prefer?: string[];
27
+ allowFallback?: boolean;
28
+ providerTimeout?: number;
29
+ }
30
+ interface ProviderCallOptions {
31
+ maxTokens?: number;
32
+ temperature?: number;
33
+ topP?: number;
34
+ providerOptions?: Record<string, unknown>;
35
+ headers?: Record<string, string>;
36
+ signal?: AbortSignal;
37
+ }
38
+ interface RouteOptions extends ProviderCallOptions {
39
+ model?: string;
40
+ tier?: string;
41
+ system?: string;
42
+ allowFallback?: boolean;
43
+ timeout?: number;
44
+ prefer?: string[];
45
+ [key: string]: unknown;
46
+ }
47
+ interface Alternative {
48
+ slug: string;
49
+ name: string;
50
+ status: Status;
51
+ suggestedModel: string;
52
+ }
53
+ declare class CheckResult {
54
+ provider: string;
55
+ status: Status;
56
+ statusDetail: string | null;
57
+ model: string | null;
58
+ alternatives: Alternative[];
59
+ constructor(init: {
60
+ provider: string;
61
+ status: Status;
62
+ statusDetail?: string | null;
63
+ model?: string | null;
64
+ alternatives?: Alternative[];
65
+ });
66
+ get isAvailable(): boolean;
67
+ }
68
+ interface ModelInfo {
69
+ id: string;
70
+ name: string;
71
+ providerSlug: string;
72
+ contextLength: number;
73
+ modality: string;
74
+ promptPrice: number;
75
+ completionPrice: number;
76
+ }
77
+ interface ProviderStatus {
78
+ slug: string;
79
+ name: string;
80
+ status: Status;
81
+ statusDetail: string | null;
82
+ modelCount: number;
83
+ }
84
+ interface RouteResponseInit {
85
+ content: string;
86
+ modelUsed: string;
87
+ providerUsed: string;
88
+ wasFallback: boolean;
89
+ fallbackReason?: string | null;
90
+ inputTokens?: number;
91
+ outputTokens?: number;
92
+ costUsd?: number;
93
+ raw?: unknown;
94
+ }
95
+ declare class RouteResponse {
96
+ content: string;
97
+ modelUsed: string;
98
+ providerUsed: string;
99
+ wasFallback: boolean;
100
+ fallbackReason: string | null;
101
+ inputTokens: number;
102
+ outputTokens: number;
103
+ costUsd: number;
104
+ raw: unknown;
105
+ constructor(init: RouteResponseInit);
106
+ toString(): string;
107
+ }
108
+
109
+ declare abstract class ProviderAdapter {
110
+ readonly config: ProviderConfig;
111
+ constructor(config: ProviderConfig);
112
+ get slug(): string;
113
+ get aliases(): string[];
114
+ supportsProvider(slug: string): boolean;
115
+ stripProvider(modelId: string): string;
116
+ abstract call(modelId: string, messages: ChatMessage[], timeoutSeconds: number, options: ProviderCallOptions): Promise<RouteResponse>;
117
+ }
118
+ type ProviderAdapterConstructor = new (config: ProviderConfig) => ProviderAdapter;
119
+ declare function registerAdapterType(typeName: string, ctor: ProviderAdapterConstructor): void;
120
+ declare function createAdapter(config: ProviderConfig): ProviderAdapter;
121
+
122
+ declare class StatusAPI {
123
+ private readonly baseUrl;
124
+ private readonly timeoutMs;
125
+ constructor(baseUrl?: string, timeoutSeconds?: number);
126
+ checkProvider(slug: string): Promise<CheckResult>;
127
+ checkModel(modelId: string): Promise<CheckResult>;
128
+ acheckProvider(slug: string): Promise<CheckResult>;
129
+ acheckModel(modelId: string): Promise<CheckResult>;
130
+ providers(): Promise<ProviderStatus[]>;
131
+ model(modelId: string): Promise<ModelInfo | null>;
132
+ searchModels(query: string): Promise<ModelInfo[]>;
133
+ private get;
134
+ private parseCheck;
135
+ private parseProviderStatus;
136
+ private parseModel;
137
+ }
138
+
139
+ declare class AIStatusError extends Error {
140
+ constructor(message: string);
141
+ }
142
+ declare class AllProvidersDown extends AIStatusError {
143
+ readonly tried: string[];
144
+ constructor(tried: string[]);
145
+ }
146
+ declare class ProviderCallFailed extends AIStatusError {
147
+ readonly provider: string;
148
+ readonly model: string;
149
+ readonly cause: unknown;
150
+ constructor(provider: string, model: string, cause: unknown);
151
+ }
152
+ declare class NoBudgetMatch extends AIStatusError {
153
+ readonly maxCost: number;
154
+ readonly tier: string;
155
+ constructor(maxCost: number, tier: string);
156
+ }
157
+ declare class ProviderNotConfigured extends AIStatusError {
158
+ readonly provider: string;
159
+ readonly envName?: string;
160
+ constructor(provider: string, envName?: string);
161
+ }
162
+ declare class ProviderNotInstalled extends AIStatusError {
163
+ readonly provider: string;
164
+ readonly packageName?: string;
165
+ constructor(provider: string, packageName?: string);
166
+ }
167
+ declare class CheckAPIUnreachable extends AIStatusError {
168
+ constructor();
169
+ }
170
+
171
+ interface RouterOptions {
172
+ baseUrl?: string;
173
+ checkTimeout?: number;
174
+ providers?: string[];
175
+ autoDiscover?: boolean;
176
+ }
177
+ declare class Router {
178
+ readonly api: StatusAPI;
179
+ private readonly adapters;
180
+ private readonly adapterIndex;
181
+ private readonly tiers;
182
+ constructor(options?: RouterOptions);
183
+ registerProvider(config: ProviderConfig): void;
184
+ addTier(name: string, models: string[]): void;
185
+ route(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
186
+ aroute(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
187
+ private autoDiscover;
188
+ private indexAdapter;
189
+ private normalizeMessages;
190
+ private extractCallOptions;
191
+ private resolveModel;
192
+ private guessProvider;
193
+ private sortAndBindCandidates;
194
+ private routeModel;
195
+ private routeTier;
196
+ }
197
+
198
+ declare const VERSION = "0.0.2";
199
+ declare function route(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
200
+ declare function aroute(messages: string | ChatMessage[], options?: RouteOptions): Promise<RouteResponse>;
201
+
202
+ export { AIStatusError, AllProvidersDown, type Alternative, type ChatMessage, CheckAPIUnreachable, CheckResult, type MessageRole, type ModelInfo, NoBudgetMatch, ProviderAdapter, ProviderCallFailed, type ProviderCallOptions, type ProviderConfig, ProviderNotConfigured, ProviderNotInstalled, type ProviderStatus, type RouteConfig, type RouteOptions, RouteResponse, Router, type RouterOptions, Status, StatusAPI, VERSION, aroute, createAdapter, registerAdapterType, route };