@arcships/aimux 0.2.0 → 0.3.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.
Files changed (149) hide show
  1. package/LICENSE +21 -0
  2. package/dist/error.d.ts +71 -0
  3. package/dist/error.js +173 -0
  4. package/dist/index.d.ts +132 -5
  5. package/dist/index.js +282 -24
  6. package/dist/types/AiMuxError.d.ts +29 -15
  7. package/dist/types/AiMuxError.js +0 -1
  8. package/dist/types/ApiCallError.d.ts +65 -0
  9. package/dist/types/ApiCallError.js +3 -0
  10. package/dist/types/BreakKind.d.ts +1 -0
  11. package/dist/types/BreakKind.js +3 -0
  12. package/dist/types/CallOptions.d.ts +27 -1
  13. package/dist/types/CatalogueSource.d.ts +4 -0
  14. package/dist/types/CatalogueSource.js +3 -0
  15. package/dist/types/ChatCompletion.d.ts +16 -0
  16. package/dist/types/ChatCompletion.js +2 -0
  17. package/dist/types/ChatCompletionChoice.d.ts +8 -0
  18. package/dist/types/ChatCompletionChoice.js +2 -0
  19. package/dist/types/ChatCompletionChunk.d.ts +15 -0
  20. package/dist/types/ChatCompletionChunk.js +2 -0
  21. package/dist/types/ChatCompletionChunkChoice.d.ts +8 -0
  22. package/dist/types/ChatCompletionChunkChoice.js +2 -0
  23. package/dist/types/ChatCompletionChunkFunction.d.ts +4 -0
  24. package/dist/types/ChatCompletionChunkFunction.js +3 -0
  25. package/dist/types/ChatCompletionChunkToolCall.d.ts +7 -0
  26. package/dist/types/ChatCompletionChunkToolCall.js +2 -0
  27. package/dist/types/ChatCompletionDelta.d.ts +7 -0
  28. package/dist/types/ChatCompletionDelta.js +2 -0
  29. package/dist/types/ChatCompletionFunction.d.ts +4 -0
  30. package/dist/types/ChatCompletionFunction.js +3 -0
  31. package/dist/types/ChatCompletionMessage.d.ts +9 -0
  32. package/dist/types/ChatCompletionMessage.js +2 -0
  33. package/dist/types/ChatCompletionToolCall.d.ts +6 -0
  34. package/dist/types/ChatCompletionToolCall.js +2 -0
  35. package/dist/types/ChatCompletionUsage.d.ts +9 -0
  36. package/dist/types/ChatCompletionUsage.js +2 -0
  37. package/dist/types/CompletionTokensDetails.d.ts +3 -0
  38. package/dist/types/CompletionTokensDetails.js +3 -0
  39. package/dist/types/FilePart.d.ts +8 -0
  40. package/dist/types/FilePart.js +2 -0
  41. package/dist/types/Fingerprint.d.ts +21 -0
  42. package/dist/types/Fingerprint.js +3 -0
  43. package/dist/types/GenerateObjectResult.d.ts +48 -0
  44. package/dist/types/GenerateObjectResult.js +2 -0
  45. package/dist/types/GenerateTextOptions.d.ts +12 -1
  46. package/dist/types/GenerateTextResult.d.ts +47 -0
  47. package/dist/types/HttpExchange.d.ts +23 -0
  48. package/dist/types/HttpExchange.js +2 -0
  49. package/dist/types/HttpRecord.d.ts +12 -0
  50. package/dist/types/HttpRecord.js +3 -0
  51. package/dist/types/ImageCallOptions.d.ts +1 -1
  52. package/dist/types/InputRecord.d.ts +16 -0
  53. package/dist/types/InputRecord.js +2 -0
  54. package/dist/types/Modality.d.ts +4 -0
  55. package/dist/types/Modality.js +3 -0
  56. package/dist/types/ModelCapabilities.d.ts +21 -0
  57. package/dist/types/ModelCapabilities.js +3 -0
  58. package/dist/types/ModelCost.d.ts +10 -0
  59. package/dist/types/ModelCost.js +3 -0
  60. package/dist/types/ModelLimits.d.ts +17 -0
  61. package/dist/types/ModelLimits.js +3 -0
  62. package/dist/types/ModelModalities.d.ts +8 -0
  63. package/dist/types/ModelModalities.js +2 -0
  64. package/dist/types/ModelSpec.d.ts +33 -0
  65. package/dist/types/ModelSpec.js +2 -0
  66. package/dist/types/ModelType.d.ts +4 -0
  67. package/dist/types/ModelType.js +3 -0
  68. package/dist/types/OutcomeRecord.d.ts +14 -0
  69. package/dist/types/OutcomeRecord.js +2 -0
  70. package/dist/types/OutcomeStatus.d.ts +4 -0
  71. package/dist/types/OutcomeStatus.js +3 -0
  72. package/dist/types/PrefixBreak.d.ts +11 -0
  73. package/dist/types/PrefixBreak.js +2 -0
  74. package/dist/types/PromptTokensDetails.d.ts +4 -0
  75. package/dist/types/PromptTokensDetails.js +3 -0
  76. package/dist/types/ProviderAuditSpec.d.ts +33 -0
  77. package/dist/types/ProviderAuditSpec.js +2 -0
  78. package/dist/types/ProviderFamily.d.ts +5 -0
  79. package/dist/types/ProviderFamily.js +3 -0
  80. package/dist/types/ProviderName.d.ts +1 -0
  81. package/dist/types/ProviderName.js +1 -0
  82. package/dist/types/ProviderRecord.d.ts +30 -0
  83. package/dist/types/ProviderRecord.js +2 -0
  84. package/dist/types/ReasoningMode.d.ts +4 -0
  85. package/dist/types/ReasoningMode.js +3 -0
  86. package/dist/types/ReasoningPart.d.ts +9 -0
  87. package/dist/types/ReasoningPart.js +3 -0
  88. package/dist/types/ReasoningSpec.d.ts +39 -0
  89. package/dist/types/ReasoningSpec.js +2 -0
  90. package/dist/types/ReasoningVisibility.d.ts +4 -0
  91. package/dist/types/ReasoningVisibility.js +3 -0
  92. package/dist/types/Recording.d.ts +56 -0
  93. package/dist/types/Recording.js +2 -0
  94. package/dist/types/RequestCacheHints.d.ts +9 -0
  95. package/dist/types/RequestCacheHints.js +3 -0
  96. package/dist/types/ResponseRecord.d.ts +13 -0
  97. package/dist/types/ResponseRecord.js +3 -0
  98. package/dist/types/RuntimeModel.d.ts +22 -0
  99. package/dist/types/RuntimeModel.js +3 -0
  100. package/dist/types/SessionCall.d.ts +20 -0
  101. package/dist/types/SessionCall.js +3 -0
  102. package/dist/types/SessionChainView.d.ts +10 -0
  103. package/dist/types/SessionChainView.js +2 -0
  104. package/dist/types/SessionSource.d.ts +4 -0
  105. package/dist/types/SessionSource.js +3 -0
  106. package/dist/types/SessionStepStat.d.ts +27 -0
  107. package/dist/types/SessionStepStat.js +2 -0
  108. package/dist/types/SessionView.d.ts +16 -0
  109. package/dist/types/SessionView.js +2 -0
  110. package/dist/types/SourcePart.d.ts +9 -0
  111. package/dist/types/SourcePart.js +3 -0
  112. package/dist/types/StreamTextResultAggregated.d.ts +74 -0
  113. package/dist/types/StreamTextResultAggregated.js +2 -0
  114. package/dist/types/TimeoutConfiguration.d.ts +10 -0
  115. package/dist/types/TimeoutConfiguration.js +1 -0
  116. package/dist/types/TimingRecord.d.ts +7 -0
  117. package/dist/types/TimingRecord.js +3 -0
  118. package/dist/types/TraceFilter.d.ts +9 -0
  119. package/dist/types/TraceFilter.js +3 -0
  120. package/dist/types/TraceRecord.d.ts +54 -0
  121. package/dist/types/TraceRecord.js +2 -0
  122. package/dist/types/TraceStats.d.ts +20 -0
  123. package/dist/types/TraceStats.js +3 -0
  124. package/dist/types/TranscriptionCallOptions.d.ts +29 -0
  125. package/dist/types/TranscriptionCallOptions.js +2 -0
  126. package/dist/types/TranscriptionRequest.d.ts +9 -0
  127. package/dist/types/TranscriptionRequest.js +3 -0
  128. package/dist/types/TranscriptionResponse.d.ts +24 -0
  129. package/dist/types/TranscriptionResponse.js +2 -0
  130. package/dist/types/TranscriptionResult.d.ts +46 -0
  131. package/dist/types/TranscriptionResult.js +2 -0
  132. package/dist/types/TranscriptionSegment.d.ts +17 -0
  133. package/dist/types/TranscriptionSegment.js +3 -0
  134. package/dist/types/TranscriptionStreamPart.d.ts +70 -0
  135. package/dist/types/TranscriptionStreamPart.js +2 -0
  136. package/dist/types/UsageSnapshot.d.ts +18 -0
  137. package/dist/types/UsageSnapshot.js +2 -0
  138. package/dist/types/Verdict.d.ts +23 -0
  139. package/dist/types/Verdict.js +2 -0
  140. package/dist/types/VerdictConfidence.d.ts +4 -0
  141. package/dist/types/VerdictConfidence.js +3 -0
  142. package/dist/types/VerdictKind.d.ts +4 -0
  143. package/dist/types/VerdictKind.js +3 -0
  144. package/dist/types/VideoCallOptions.d.ts +1 -1
  145. package/dist/types.d.ts +66 -1
  146. package/dist/types.js +3 -3
  147. package/index.d.ts +322 -53
  148. package/index.js +81 -54
  149. package/package.json +9 -8
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 arcships
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Aimux error hierarchy (aligned with Vercel AI SDK style).
3
+ *
4
+ * ```ts
5
+ * try {
6
+ * await generateText(model, '...')
7
+ * } catch (e) {
8
+ * if (e instanceof APICallError) {
9
+ * // Classification is the status field (AI SDK APICallError.statusCode):
10
+ * // e.status === 429 → rate limited (e.retryMs), 401 → auth, 404 → model
11
+ * } else if (e instanceof AimuxError) {
12
+ * // any engine / binding failure
13
+ * }
14
+ * }
15
+ * ```
16
+ *
17
+ * Distinct from the ts-rs wire type `AiMuxError` used inside `StreamPart`.
18
+ */
19
+ export declare class AimuxError extends Error {
20
+ /** Core variant name, e.g. `'InvalidArgument'`. */
21
+ readonly code: string;
22
+ readonly status: number;
23
+ readonly retryMs: number;
24
+ /** Stored retry verdict (`APICallError.isRetryable` analogue). */
25
+ readonly retryable: boolean;
26
+ /** Provider's machine-readable error code (e.g. `'rate_limit_exceeded'`). */
27
+ readonly providerCode?: string;
28
+ /** Raw error response body, verbatim (AI SDK `APICallError.responseBody`). */
29
+ readonly responseBody?: string;
30
+ /** Provider-assigned request id (`x-request-id` / `request-id` header). */
31
+ readonly requestId?: string;
32
+ /**
33
+ * Lossless externally-tagged serde JSON of the core `AiMuxError`,
34
+ * e.g. `'{"ApiCall":{"status_code":429,"retry_after_ms":1500,...}}'`.
35
+ * Absent when the error did not originate from a core `AiMuxError`.
36
+ */
37
+ readonly errorValue?: string;
38
+ constructor(message: string, status?: number, retryMs?: number, retryable?: boolean);
39
+ /** Rebuild from a native throw (or already-wrapped instance). */
40
+ static fromNative(err: unknown): AimuxError;
41
+ }
42
+ export declare class APICallError extends AimuxError {
43
+ }
44
+ export declare class JSONParseError extends AimuxError {
45
+ }
46
+ export declare class InvalidResponseDataError extends AimuxError {
47
+ }
48
+ export declare class ToolError extends AimuxError {
49
+ }
50
+ export declare class InvalidArgumentError extends AimuxError {
51
+ }
52
+ export declare class InvalidPromptError extends AimuxError {
53
+ }
54
+ export declare class TokenExpiredError extends AimuxError {
55
+ }
56
+ export declare class UnsupportedFunctionalityError extends AimuxError {
57
+ }
58
+ export declare class NoSuchModelError extends AimuxError {
59
+ }
60
+ export declare class NoSuchProviderError extends AimuxError {
61
+ }
62
+ export declare class TimeoutError extends AimuxError {
63
+ }
64
+ /** Request aborted (not DOM `AbortError`). */
65
+ export declare class RequestAbortedError extends AimuxError {
66
+ constructor(message?: string, status?: number, retryMs?: number, retryable?: boolean);
67
+ }
68
+ export declare class OtherError extends AimuxError {
69
+ }
70
+ /** Wrap an async native call so throws are typed `AimuxError` subclasses. */
71
+ export declare function withAimuxError<T>(fn: () => Promise<T>): Promise<T>;
package/dist/error.js ADDED
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ /**
3
+ * Aimux error hierarchy (aligned with Vercel AI SDK style).
4
+ *
5
+ * ```ts
6
+ * try {
7
+ * await generateText(model, '...')
8
+ * } catch (e) {
9
+ * if (e instanceof APICallError) {
10
+ * // Classification is the status field (AI SDK APICallError.statusCode):
11
+ * // e.status === 429 → rate limited (e.retryMs), 401 → auth, 404 → model
12
+ * } else if (e instanceof AimuxError) {
13
+ * // any engine / binding failure
14
+ * }
15
+ * }
16
+ * ```
17
+ *
18
+ * Distinct from the ts-rs wire type `AiMuxError` used inside `StreamPart`.
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.OtherError = exports.RequestAbortedError = exports.TimeoutError = exports.NoSuchProviderError = exports.NoSuchModelError = exports.UnsupportedFunctionalityError = exports.TokenExpiredError = exports.InvalidPromptError = exports.InvalidArgumentError = exports.ToolError = exports.InvalidResponseDataError = exports.JSONParseError = exports.APICallError = exports.AimuxError = void 0;
22
+ exports.withAimuxError = withAimuxError;
23
+ class AimuxError extends Error {
24
+ constructor(message, status = -1, retryMs = -1, retryable = false) {
25
+ super(message);
26
+ this.name = new.target.name;
27
+ this.code = CODE_BY_NAME.get(this.name) ?? 'Other';
28
+ this.status = status;
29
+ this.retryMs = retryMs;
30
+ this.retryable = retryable;
31
+ Object.setPrototypeOf(this, new.target.prototype);
32
+ const capture = Error
33
+ .captureStackTrace;
34
+ if (capture)
35
+ capture(this, new.target);
36
+ }
37
+ /** Rebuild from a native throw (or already-wrapped instance). */
38
+ static fromNative(err) {
39
+ if (err instanceof AimuxError) {
40
+ return err;
41
+ }
42
+ let message = String(err);
43
+ let code = 'Other';
44
+ let status = -1;
45
+ let retryMs = -1;
46
+ let retryable = false;
47
+ let providerCode;
48
+ let responseBody;
49
+ let requestId;
50
+ let errorValue;
51
+ if (err instanceof Error) {
52
+ message = err.message;
53
+ const any = err;
54
+ if (typeof any.status === 'number')
55
+ status = any.status;
56
+ if (typeof any.retryMs === 'number')
57
+ retryMs = any.retryMs;
58
+ if (typeof any.retryable === 'boolean')
59
+ retryable = any.retryable;
60
+ if (typeof any.providerCode === 'string')
61
+ providerCode = any.providerCode;
62
+ if (typeof any.responseBody === 'string')
63
+ responseBody = any.responseBody;
64
+ if (typeof any.requestId === 'string')
65
+ requestId = any.requestId;
66
+ if (typeof any.errorValue === 'string')
67
+ errorValue = any.errorValue;
68
+ if (typeof any.code === 'string' && any.code.length > 0) {
69
+ code = any.code;
70
+ }
71
+ else if (typeof any.name === 'string') {
72
+ // Native sets name to e.g. "APICallError"
73
+ code = CODE_BY_NAME.get(any.name) ?? 'Other';
74
+ }
75
+ }
76
+ const wrapped = createByCode(code, message, status, retryMs, retryable);
77
+ if (providerCode !== undefined) {
78
+ ;
79
+ wrapped.providerCode = providerCode;
80
+ }
81
+ if (responseBody !== undefined) {
82
+ ;
83
+ wrapped.responseBody = responseBody;
84
+ }
85
+ if (requestId !== undefined) {
86
+ ;
87
+ wrapped.requestId = requestId;
88
+ }
89
+ if (errorValue !== undefined) {
90
+ ;
91
+ wrapped.errorValue = errorValue;
92
+ }
93
+ if (err instanceof Error) {
94
+ ;
95
+ wrapped.cause = err;
96
+ }
97
+ return wrapped;
98
+ }
99
+ }
100
+ exports.AimuxError = AimuxError;
101
+ class APICallError extends AimuxError {
102
+ }
103
+ exports.APICallError = APICallError;
104
+ class JSONParseError extends AimuxError {
105
+ }
106
+ exports.JSONParseError = JSONParseError;
107
+ class InvalidResponseDataError extends AimuxError {
108
+ }
109
+ exports.InvalidResponseDataError = InvalidResponseDataError;
110
+ class ToolError extends AimuxError {
111
+ }
112
+ exports.ToolError = ToolError;
113
+ class InvalidArgumentError extends AimuxError {
114
+ }
115
+ exports.InvalidArgumentError = InvalidArgumentError;
116
+ class InvalidPromptError extends AimuxError {
117
+ }
118
+ exports.InvalidPromptError = InvalidPromptError;
119
+ class TokenExpiredError extends AimuxError {
120
+ }
121
+ exports.TokenExpiredError = TokenExpiredError;
122
+ class UnsupportedFunctionalityError extends AimuxError {
123
+ }
124
+ exports.UnsupportedFunctionalityError = UnsupportedFunctionalityError;
125
+ class NoSuchModelError extends AimuxError {
126
+ }
127
+ exports.NoSuchModelError = NoSuchModelError;
128
+ class NoSuchProviderError extends AimuxError {
129
+ }
130
+ exports.NoSuchProviderError = NoSuchProviderError;
131
+ class TimeoutError extends AimuxError {
132
+ }
133
+ exports.TimeoutError = TimeoutError;
134
+ /** Request aborted (not DOM `AbortError`). */
135
+ class RequestAbortedError extends AimuxError {
136
+ constructor(message = 'request aborted', status = -1, retryMs = -1, retryable = false) {
137
+ super(message, status, retryMs, retryable);
138
+ }
139
+ }
140
+ exports.RequestAbortedError = RequestAbortedError;
141
+ class OtherError extends AimuxError {
142
+ }
143
+ exports.OtherError = OtherError;
144
+ /** Core variant name → error class (single source for lookups below). */
145
+ const CLASS_BY_CODE = {
146
+ ApiCall: APICallError,
147
+ JsonParse: JSONParseError,
148
+ InvalidResponseData: InvalidResponseDataError,
149
+ Tool: ToolError,
150
+ InvalidArgument: InvalidArgumentError,
151
+ InvalidPrompt: InvalidPromptError,
152
+ TokenExpired: TokenExpiredError,
153
+ UnsupportedFunctionality: UnsupportedFunctionalityError,
154
+ NoSuchModel: NoSuchModelError,
155
+ NoSuchProvider: NoSuchProviderError,
156
+ Timeout: TimeoutError,
157
+ Aborted: RequestAbortedError,
158
+ Other: OtherError,
159
+ };
160
+ const CODE_BY_NAME = new Map(Object.entries(CLASS_BY_CODE).map(([code, cls]) => [cls.name, code]));
161
+ function createByCode(code, message, status, retryMs, retryable) {
162
+ const Cls = CLASS_BY_CODE[code] ?? AimuxError;
163
+ return new Cls(message, status, retryMs, retryable);
164
+ }
165
+ /** Wrap an async native call so throws are typed `AimuxError` subclasses. */
166
+ async function withAimuxError(fn) {
167
+ try {
168
+ return await fn();
169
+ }
170
+ catch (e) {
171
+ throw AimuxError.fromNative(e);
172
+ }
173
+ }
package/dist/index.d.ts CHANGED
@@ -1,8 +1,28 @@
1
- import type { Model } from '../index.js';
2
- import type { GenerateTextOptions, GenerateTextResult, StreamPart, ModelMessage, Tool, ToolChoice, ToolCall, ToolResult, Usage, FinishReason, Warning, Role, MessageContent, ContentPart, ResponseFormat, ReasoningEffort, AiMuxError, GenerateResult, FunctionTool } from './types';
3
- export { Model, StreamTextGenerator, AbortBridge, openai, anthropic, deepseek, google, cohere, mistral, xai, bedrock, vertex, anthropicAws, azure, provider, } from '../index.js';
4
- export type { ProviderName } from './types/ProviderName';
5
- export type { GenerateTextOptions, GenerateTextResult, StreamPart, ModelMessage, Tool, ToolChoice, ToolCall, ToolResult, Usage, FinishReason, Warning, Role, MessageContent, ContentPart, ResponseFormat, ReasoningEffort, AiMuxError, GenerateResult, FunctionTool, };
1
+ import * as native from '../index.js';
2
+ import type { Model, ProviderConfig, ProviderHandle as RawProviderHandle } from '../index.js';
3
+ import type { GenerateTextOptions, GenerateTextResult, StreamPart, ModelMessage, Tool, ToolChoice, ToolCall, ToolResult, Usage, FinishReason, Warning, Role, MessageContent, ContentPart, ResponseFormat, ReasoningEffort, GenerateResult, FunctionTool, SessionCall, SessionSource, SessionView, ChatCompletion, ChatCompletionChunk, ModelSpec, RuntimeModel } from './types';
4
+ export { AimuxError, APICallError, JSONParseError, InvalidResponseDataError, ToolError, InvalidArgumentError, InvalidPromptError, TokenExpiredError, UnsupportedFunctionalityError, NoSuchModelError, NoSuchProviderError, TimeoutError, RequestAbortedError, OtherError, withAimuxError, } from './error.ts';
5
+ export { Model, StreamTextGenerator, AbortBridge, initLogging, initSessionStore, initSessionInfer, } from '../index.js';
6
+ export declare const sessionCalls: (sessionId: string) => string;
7
+ export declare const listSessions: () => string;
8
+ export declare const mockReplay: (recordingsJsonl: string) => native.Model;
9
+ export declare const router: (models: native.Model[], configJson?: string | null | undefined) => native.Model;
10
+ export declare const moa: (references: native.Model[], aggregator: native.Model, configJson?: string | null | undefined) => native.Model;
11
+ export declare const openai: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
12
+ export declare const anthropic: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
13
+ export declare const deepseek: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
14
+ export declare const google: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
15
+ export declare const cohere: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
16
+ export declare const mistral: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
17
+ export declare const xai: (apiKey: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
18
+ export declare const bedrock: (accessKeyId: string, secretAccessKey: string, region: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
19
+ export declare const vertex: (accessToken: string, project: string, location: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
20
+ export declare const anthropicAws: (apiKey: string, region: string, modelId: string, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
21
+ export declare const azure: (apiKey: string, resourceName: string, deployment: string, apiVersion?: string | null | undefined, config?: string | native.ProviderConfig | null | undefined) => Promise<native.Model>;
22
+ export declare const provider: (name: string, apiKey: string | null | undefined, modelId: string, config?: native.ProviderConfig | null | undefined) => Promise<native.Model>;
23
+ export type { ProviderHandle } from '../index.js';
24
+ export { ProviderName } from './types/ProviderName.ts';
25
+ export type { GenerateTextOptions, GenerateTextResult, StreamPart, ModelMessage, Tool, ToolChoice, ToolCall, ToolResult, Usage, FinishReason, Warning, Role, MessageContent, ContentPart, ResponseFormat, ReasoningEffort, GenerateResult, FunctionTool, SessionCall, SessionSource, SessionView, ChatCompletion, ChatCompletionChunk, ModelSpec, RuntimeModel, };
6
26
  /**
7
27
  * A raw napi `Model` instance returned by `openai()` / `anthropic()` / …
8
28
  *
@@ -55,3 +75,110 @@ export declare function generateText(model: RawModel, prompt: string | ModelMess
55
75
  * ```
56
76
  */
57
77
  export declare function streamText(model: RawModel, prompt: string | ModelMessage[], options?: GenerateTextOptions, signal?: AbortSignal): AsyncGenerator<StreamPart>;
78
+ /**
79
+ * All calls of a session, ordered by step (RFC-0024). Empty if the session
80
+ * is unknown or no store is registered.
81
+ *
82
+ * `initSessionStore()` / `initSessionInfer(enabled)` (raw napi, re-exported
83
+ * above) must be called first to register the store / opt-in inferer.
84
+ */
85
+ export declare function getSessionCalls(sessionId: string): SessionCall[];
86
+ /**
87
+ * All known sessions (RFC-0024).
88
+ */
89
+ export declare function getSessions(): SessionView[];
90
+ /**
91
+ * Generate text and return an OpenAI Chat Completion (non-streaming).
92
+ *
93
+ * Works with **any** provider — the result is always a standard OpenAI
94
+ * `ChatCompletion` object.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { openai, generateTextAsOpenai } from 'aimux'
99
+ * const model = await openai(apiKey, 'gpt-4o')
100
+ * const completion = await generateTextAsOpenai(model, 'What is Rust?')
101
+ * console.log(completion.choices[0].message.content)
102
+ * ```
103
+ */
104
+ export declare function generateTextAsOpenai(model: RawModel, prompt: string | ModelMessage[], options?: GenerateTextOptions, signal?: AbortSignal): Promise<ChatCompletion>;
105
+ /**
106
+ * Stream text as OpenAI Chat Completion chunks.
107
+ *
108
+ * Works with **any** provider — yields standard OpenAI `ChatCompletionChunk`
109
+ * objects. Pass `streamOptions` via `providerOptions.openai.stream_options`:
110
+ * `{ include_usage: true, include_reasoning: true }` (both default true).
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * import { openai, streamTextAsOpenai } from 'aimux'
115
+ * const model = await openai(apiKey, 'gpt-4o')
116
+ * for await (const chunk of streamTextAsOpenai(model, 'Write a haiku.')) {
117
+ * const delta = chunk.choices[0]?.delta?.content
118
+ * if (delta) process.stdout.write(delta)
119
+ * }
120
+ * ```
121
+ */
122
+ export declare function streamTextAsOpenai(model: RawModel, prompt: string | ModelMessage[], options?: GenerateTextOptions, signal?: AbortSignal): AsyncGenerator<ChatCompletionChunk>;
123
+ /**
124
+ * A typed wrapper around the raw napi `ProviderHandle` class. Created by
125
+ * {@link createProvider}, supports {@link ProviderHandleTyped.listModels} and
126
+ * {@link ProviderHandleTyped.model}.
127
+ *
128
+ * @example
129
+ * ```ts
130
+ * import { createProvider, generateText } from 'aimux'
131
+ * const p = await createProvider('deepseek', apiKey)
132
+ * const models = await p.listModels()
133
+ * const model = await p.model(models[0].id)
134
+ * const result = await generateText(model, 'Hello')
135
+ * ```
136
+ */
137
+ export declare class ProviderHandleTyped {
138
+ private readonly raw;
139
+ constructor(raw: RawProviderHandle);
140
+ /** List models available on this provider (runtime discovery + anya2a spec). */
141
+ listModels(): Promise<RuntimeModel[]>;
142
+ /** Build a language model from a discovered model id. */
143
+ model(modelId: string): Promise<RawModel>;
144
+ }
145
+ /**
146
+ * Create a **provider handle** (RFC-0027) for a registry-backed provider.
147
+ *
148
+ * Unlike `provider()` (which binds to a single modelId), this returns a handle
149
+ * that supports `listModels()` (runtime discovery) and `model()`.
150
+ *
151
+ * @param name - Provider name (e.g. `"deepseek"`, `"groq"`).
152
+ * @param apiKey - API key; omit/null to read the provider's env var.
153
+ * @param config - Optional provider config (baseUrl, headers, …).
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { createProvider, generateText } from 'aimux'
158
+ * const p = await createProvider('deepseek', process.env.DEEPSEEK_API_KEY)
159
+ * const models = await p.listModels()
160
+ * const model = await p.model(models[0].id)
161
+ * const result = await generateText(model, 'Hello')
162
+ * ```
163
+ */
164
+ export declare function createProvider(name: string, apiKey?: string, config?: ProviderConfig): Promise<ProviderHandleTyped>;
165
+ /**
166
+ * Fetch the community model catalogue (anya2a). Returns a `Catalogue` object
167
+ * with a `lookup(provider, modelId)` method. Thin fetch — no caching; the host
168
+ * decides how to persist/reuse the result.
169
+ *
170
+ * @param sourceUrl - Optional URL override (default = anya2a endpoint).
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * import { createProvider, getModelSpecs, generateText } from 'aimux'
175
+ * const [p, catalogue] = await Promise.all([
176
+ * createProvider('deepseek', apiKey),
177
+ * getModelSpecs(),
178
+ * ])
179
+ * const models = await p.listModels()
180
+ * const model = await p.model(models[0].id)
181
+ * const spec = catalogue.specs?.['deepseek']?.[models[0].id] // community portrait
182
+ * ```
183
+ */
184
+ export declare function getModelSpecs(sourceUrl?: string): Promise<unknown>;