@arcships/aimux 0.2.1 → 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.
- package/dist/error.d.ts +71 -0
- package/dist/error.js +173 -0
- package/dist/index.d.ts +132 -5
- package/dist/index.js +281 -24
- package/dist/types/AiMuxError.d.ts +29 -15
- package/dist/types/AiMuxError.js +0 -1
- package/dist/types/ApiCallError.d.ts +65 -0
- package/dist/types/ApiCallError.js +3 -0
- package/dist/types/BreakKind.d.ts +1 -0
- package/dist/types/BreakKind.js +3 -0
- package/dist/types/CallOptions.d.ts +27 -1
- package/dist/types/CatalogueSource.d.ts +4 -0
- package/dist/types/CatalogueSource.js +3 -0
- package/dist/types/ChatCompletion.d.ts +16 -0
- package/dist/types/ChatCompletion.js +2 -0
- package/dist/types/ChatCompletionChoice.d.ts +8 -0
- package/dist/types/ChatCompletionChoice.js +2 -0
- package/dist/types/ChatCompletionChunk.d.ts +15 -0
- package/dist/types/ChatCompletionChunk.js +2 -0
- package/dist/types/ChatCompletionChunkChoice.d.ts +8 -0
- package/dist/types/ChatCompletionChunkChoice.js +2 -0
- package/dist/types/ChatCompletionChunkFunction.d.ts +4 -0
- package/dist/types/ChatCompletionChunkFunction.js +3 -0
- package/dist/types/ChatCompletionChunkToolCall.d.ts +7 -0
- package/dist/types/ChatCompletionChunkToolCall.js +2 -0
- package/dist/types/ChatCompletionDelta.d.ts +7 -0
- package/dist/types/ChatCompletionDelta.js +2 -0
- package/dist/types/ChatCompletionFunction.d.ts +4 -0
- package/dist/types/ChatCompletionFunction.js +3 -0
- package/dist/types/ChatCompletionMessage.d.ts +9 -0
- package/dist/types/ChatCompletionMessage.js +2 -0
- package/dist/types/ChatCompletionToolCall.d.ts +6 -0
- package/dist/types/ChatCompletionToolCall.js +2 -0
- package/dist/types/ChatCompletionUsage.d.ts +9 -0
- package/dist/types/ChatCompletionUsage.js +2 -0
- package/dist/types/CompletionTokensDetails.d.ts +3 -0
- package/dist/types/CompletionTokensDetails.js +3 -0
- package/dist/types/FilePart.d.ts +8 -0
- package/dist/types/FilePart.js +2 -0
- package/dist/types/Fingerprint.d.ts +21 -0
- package/dist/types/Fingerprint.js +3 -0
- package/dist/types/GenerateObjectResult.d.ts +48 -0
- package/dist/types/GenerateObjectResult.js +2 -0
- package/dist/types/GenerateTextOptions.d.ts +12 -1
- package/dist/types/GenerateTextResult.d.ts +47 -0
- package/dist/types/HttpExchange.d.ts +23 -0
- package/dist/types/HttpExchange.js +2 -0
- package/dist/types/HttpRecord.d.ts +12 -0
- package/dist/types/HttpRecord.js +3 -0
- package/dist/types/ImageCallOptions.d.ts +1 -1
- package/dist/types/InputRecord.d.ts +16 -0
- package/dist/types/InputRecord.js +2 -0
- package/dist/types/Modality.d.ts +4 -0
- package/dist/types/Modality.js +3 -0
- package/dist/types/ModelCapabilities.d.ts +21 -0
- package/dist/types/ModelCapabilities.js +3 -0
- package/dist/types/ModelCost.d.ts +10 -0
- package/dist/types/ModelCost.js +3 -0
- package/dist/types/ModelLimits.d.ts +17 -0
- package/dist/types/ModelLimits.js +3 -0
- package/dist/types/ModelModalities.d.ts +8 -0
- package/dist/types/ModelModalities.js +2 -0
- package/dist/types/ModelSpec.d.ts +33 -0
- package/dist/types/ModelSpec.js +2 -0
- package/dist/types/ModelType.d.ts +4 -0
- package/dist/types/ModelType.js +3 -0
- package/dist/types/OutcomeRecord.d.ts +14 -0
- package/dist/types/OutcomeRecord.js +2 -0
- package/dist/types/OutcomeStatus.d.ts +4 -0
- package/dist/types/OutcomeStatus.js +3 -0
- package/dist/types/PrefixBreak.d.ts +11 -0
- package/dist/types/PrefixBreak.js +2 -0
- package/dist/types/PromptTokensDetails.d.ts +4 -0
- package/dist/types/PromptTokensDetails.js +3 -0
- package/dist/types/ProviderAuditSpec.d.ts +33 -0
- package/dist/types/ProviderAuditSpec.js +2 -0
- package/dist/types/ProviderFamily.d.ts +5 -0
- package/dist/types/ProviderFamily.js +3 -0
- package/dist/types/ProviderRecord.d.ts +30 -0
- package/dist/types/ProviderRecord.js +2 -0
- package/dist/types/ReasoningMode.d.ts +4 -0
- package/dist/types/ReasoningMode.js +3 -0
- package/dist/types/ReasoningPart.d.ts +9 -0
- package/dist/types/ReasoningPart.js +3 -0
- package/dist/types/ReasoningSpec.d.ts +39 -0
- package/dist/types/ReasoningSpec.js +2 -0
- package/dist/types/ReasoningVisibility.d.ts +4 -0
- package/dist/types/ReasoningVisibility.js +3 -0
- package/dist/types/Recording.d.ts +56 -0
- package/dist/types/Recording.js +2 -0
- package/dist/types/RequestCacheHints.d.ts +9 -0
- package/dist/types/RequestCacheHints.js +3 -0
- package/dist/types/ResponseRecord.d.ts +13 -0
- package/dist/types/ResponseRecord.js +3 -0
- package/dist/types/RuntimeModel.d.ts +22 -0
- package/dist/types/RuntimeModel.js +3 -0
- package/dist/types/SessionCall.d.ts +20 -0
- package/dist/types/SessionCall.js +3 -0
- package/dist/types/SessionChainView.d.ts +10 -0
- package/dist/types/SessionChainView.js +2 -0
- package/dist/types/SessionSource.d.ts +4 -0
- package/dist/types/SessionSource.js +3 -0
- package/dist/types/SessionStepStat.d.ts +27 -0
- package/dist/types/SessionStepStat.js +2 -0
- package/dist/types/SessionView.d.ts +16 -0
- package/dist/types/SessionView.js +2 -0
- package/dist/types/SourcePart.d.ts +9 -0
- package/dist/types/SourcePart.js +3 -0
- package/dist/types/StreamTextResultAggregated.d.ts +74 -0
- package/dist/types/StreamTextResultAggregated.js +2 -0
- package/dist/types/TimeoutConfiguration.d.ts +10 -0
- package/dist/types/TimeoutConfiguration.js +1 -0
- package/dist/types/TimingRecord.d.ts +7 -0
- package/dist/types/TimingRecord.js +3 -0
- package/dist/types/TraceFilter.d.ts +9 -0
- package/dist/types/TraceFilter.js +3 -0
- package/dist/types/TraceRecord.d.ts +54 -0
- package/dist/types/TraceRecord.js +2 -0
- package/dist/types/TraceStats.d.ts +20 -0
- package/dist/types/TraceStats.js +3 -0
- package/dist/types/TranscriptionCallOptions.d.ts +29 -0
- package/dist/types/TranscriptionCallOptions.js +2 -0
- package/dist/types/TranscriptionRequest.d.ts +9 -0
- package/dist/types/TranscriptionRequest.js +3 -0
- package/dist/types/TranscriptionResponse.d.ts +24 -0
- package/dist/types/TranscriptionResponse.js +2 -0
- package/dist/types/TranscriptionResult.d.ts +46 -0
- package/dist/types/TranscriptionResult.js +2 -0
- package/dist/types/TranscriptionSegment.d.ts +17 -0
- package/dist/types/TranscriptionSegment.js +3 -0
- package/dist/types/TranscriptionStreamPart.d.ts +70 -0
- package/dist/types/TranscriptionStreamPart.js +2 -0
- package/dist/types/UsageSnapshot.d.ts +18 -0
- package/dist/types/UsageSnapshot.js +2 -0
- package/dist/types/Verdict.d.ts +23 -0
- package/dist/types/Verdict.js +2 -0
- package/dist/types/VerdictConfidence.d.ts +4 -0
- package/dist/types/VerdictConfidence.js +3 -0
- package/dist/types/VerdictKind.d.ts +4 -0
- package/dist/types/VerdictKind.js +3 -0
- package/dist/types/VideoCallOptions.d.ts +1 -1
- package/dist/types.d.ts +66 -1
- package/dist/types.js +3 -3
- package/index.d.ts +256 -25
- package/index.js +72 -54
- package/package.json +9 -8
package/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
+
/** Fallible native return — unwraps to `T` at runtime; failures reject/throw a structured error (see src/error.ts). */
|
|
4
|
+
export type AimuxResult<T> = T
|
|
5
|
+
/** Stream yield — a StreamPart JSON string at runtime; failures reject `next()` with a structured error. */
|
|
6
|
+
export type StreamItem = string
|
|
3
7
|
declare global {
|
|
4
8
|
interface __NapiRsAsyncGenerator<TOwner, T, TReturn, TNext> {
|
|
5
9
|
next(...[value]: [] | [TNext]): globalThis.Promise<globalThis.IteratorResult<T, TReturn | undefined>>
|
|
@@ -56,6 +60,39 @@ export declare class ImageModel {
|
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
export declare class Model {
|
|
63
|
+
/**
|
|
64
|
+
* Wrap this model in a cache-probe layer (RFC-0015). The returned
|
|
65
|
+
* model records fingerprints/verdicts on every call and exposes the
|
|
66
|
+
* `traceAggregate` / `traceSessionChain` / `traceExportJsonl` /
|
|
67
|
+
* `traceClear` queries.
|
|
68
|
+
*/
|
|
69
|
+
trace(): Model
|
|
70
|
+
/**
|
|
71
|
+
* Wrap this model in a cache-probe layer with the built-in rules
|
|
72
|
+
* auditor (RFC-0015 §4). `strict` = strict mode (self-hosted single
|
|
73
|
+
* instance); `false` = shared mode (safe default).
|
|
74
|
+
*/
|
|
75
|
+
traceAudited(strict: boolean): Model
|
|
76
|
+
/**
|
|
77
|
+
* Aggregated probe statistics (RFC-0015 §5.3), filtered by a JSON
|
|
78
|
+
* `TraceFilter` (optional). Returns a JSON `TraceStats[]` string.
|
|
79
|
+
*/
|
|
80
|
+
traceAggregate(filterJson?: string | undefined | null): AimuxResult<string>
|
|
81
|
+
/**
|
|
82
|
+
* One session's chain view (RFC-0015 §5.3). Returns a JSON
|
|
83
|
+
* `SessionChainView` string or an error when the session is unknown.
|
|
84
|
+
*/
|
|
85
|
+
traceSessionChain(sessionId: string): AimuxResult<string>
|
|
86
|
+
/**
|
|
87
|
+
* One session's per-step cache-hit trajectory (RFC-0024 §4.3). Returns
|
|
88
|
+
* a JSON array of `SessionStepStat` (empty when the session is unknown
|
|
89
|
+
* or the model is not traced).
|
|
90
|
+
*/
|
|
91
|
+
traceSessionTrajectory(sessionId: string): AimuxResult<string>
|
|
92
|
+
/** Export all probe records as JSONL (one `TraceRecord` per line). */
|
|
93
|
+
traceExportJsonl(): AimuxResult<string>
|
|
94
|
+
/** Clear all probe records of this traced model. */
|
|
95
|
+
traceClear(): void
|
|
59
96
|
/**
|
|
60
97
|
* Generate text (non-streaming).
|
|
61
98
|
*
|
|
@@ -66,6 +103,23 @@ export declare class Model {
|
|
|
66
103
|
* Returns a JSON-serialized `GenerateTextResult`.
|
|
67
104
|
*/
|
|
68
105
|
generateText(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
106
|
+
/**
|
|
107
|
+
* Generate a structured JSON object from the model (M12, RFC-0016).
|
|
108
|
+
*
|
|
109
|
+
* Same signature as [`Model::generate_text`]; returns a JSON-serialized
|
|
110
|
+
* `GenerateObjectResult`. Pass `response_format: { "Json": { ... } }`
|
|
111
|
+
* via `options` for schema control; the function applies JSON repair
|
|
112
|
+
* before parsing.
|
|
113
|
+
*/
|
|
114
|
+
generateObject(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
115
|
+
/**
|
|
116
|
+
* Consume a stream to completion and return the aggregated result
|
|
117
|
+
* (M11, RFC-0016).
|
|
118
|
+
*
|
|
119
|
+
* Drives `streamText` to completion and returns a JSON-serialized
|
|
120
|
+
* `StreamTextResultAggregated` (the fully-consumed stream summary).
|
|
121
|
+
*/
|
|
122
|
+
consumeStreamText(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
69
123
|
/**
|
|
70
124
|
* Stream text from the model.
|
|
71
125
|
*
|
|
@@ -73,6 +127,46 @@ export declare class Model {
|
|
|
73
127
|
* Use `for await (const part of model.streamText(...))` to consume.
|
|
74
128
|
*/
|
|
75
129
|
streamText(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<AsyncGenerator<string>>
|
|
130
|
+
/**
|
|
131
|
+
* Generate text and return an OpenAI Chat Completion (non-streaming).
|
|
132
|
+
*
|
|
133
|
+
* Returns a JSON-serialized `ChatCompletion`. Works with any provider.
|
|
134
|
+
*/
|
|
135
|
+
generateTextAsOpenai(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
136
|
+
/**
|
|
137
|
+
* Stream text as OpenAI Chat Completion chunks.
|
|
138
|
+
*
|
|
139
|
+
* Returns an `AsyncGenerator<string>` yielding `ChatCompletionChunk` JSON
|
|
140
|
+
* strings. Works with any provider.
|
|
141
|
+
*/
|
|
142
|
+
streamTextAsOpenai(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<AsyncGenerator<string>>
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* A provider handle — created by `createProvider`, supports `listModels()`
|
|
147
|
+
* (runtime discovery) and `model()` (build a model from a discovered id).
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* const p = await createProvider('deepseek', apiKey)
|
|
151
|
+
* const models = await p.listModels()
|
|
152
|
+
* const model = await p.model(models[0].id)
|
|
153
|
+
* const result = await generateText(model, 'Hello')
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare class ProviderHandle {
|
|
157
|
+
/**
|
|
158
|
+
* List models available on this provider (runtime discovery via the
|
|
159
|
+
* provider's `/models` endpoint). Returns a JSON array of sparse
|
|
160
|
+
* `RuntimeModel` (id / owned_by / created) — **no community enrichment**.
|
|
161
|
+
* To supplement with model specs (context length, capabilities, reasoning),
|
|
162
|
+
* call `getModelSpecs` separately and merge in the host (RFC-0027).
|
|
163
|
+
*/
|
|
164
|
+
listModels(): Promise<AimuxResult<string>>
|
|
165
|
+
/**
|
|
166
|
+
* Build a language model from a discovered model id. Returns a `Model`
|
|
167
|
+
* usable with `generateText` / `streamText`.
|
|
168
|
+
*/
|
|
169
|
+
model(modelId: string): Promise<AimuxResult<Model>>
|
|
76
170
|
}
|
|
77
171
|
|
|
78
172
|
export declare class RerankingModel {
|
|
@@ -117,7 +211,7 @@ export declare class SpeechModel {
|
|
|
117
211
|
*/
|
|
118
212
|
export declare class StreamTextGenerator {
|
|
119
213
|
|
|
120
|
-
[globalThis.Symbol.asyncIterator](): globalThis.__NapiRsAsyncGenerator<StreamTextGenerator,
|
|
214
|
+
[globalThis.Symbol.asyncIterator](): globalThis.__NapiRsAsyncGenerator<StreamTextGenerator, StreamItem, void, undefined>
|
|
121
215
|
}
|
|
122
216
|
|
|
123
217
|
export declare class TranscriptionModel {
|
|
@@ -130,6 +224,37 @@ export declare class TranscriptionModel {
|
|
|
130
224
|
generate(audioBase64: string, mediaType: string, optsJson?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
131
225
|
}
|
|
132
226
|
|
|
227
|
+
/**
|
|
228
|
+
* A live streaming-transcription session (RFC-0028). Push audio chunks with
|
|
229
|
+
* `pushAudio`, mark end-of-audio with `inputDone`, then pull transcription
|
|
230
|
+
* parts with `nextPart`. Mirrors the C-ABI session shape, built natively on
|
|
231
|
+
* core channels.
|
|
232
|
+
*/
|
|
233
|
+
export declare class TranscriptionSession {
|
|
234
|
+
/**
|
|
235
|
+
* Push one binary audio chunk. Awaits while the internal channel is
|
|
236
|
+
* full (backpressure).
|
|
237
|
+
*/
|
|
238
|
+
pushAudio(data: Buffer): Promise<void>
|
|
239
|
+
/** Signal end-of-audio (idempotent). */
|
|
240
|
+
inputDone(): void
|
|
241
|
+
/**
|
|
242
|
+
* Pull the next transcription part (JSON string). Resolves `null` when
|
|
243
|
+
* the stream ended normally. Rejects on error — including a timeout
|
|
244
|
+
* (no part within `timeoutMs`; the session stays live, call again).
|
|
245
|
+
* `timeoutMs`: >0 wait at most; 0 immediate poll; negative OR omitted
|
|
246
|
+
* = wait indefinitely.
|
|
247
|
+
*/
|
|
248
|
+
nextPart(timeoutMs?: number | undefined | null): Promise<AimuxResult<string | undefined | null>>
|
|
249
|
+
/**
|
|
250
|
+
* Terminate the session (aborts the driver). The object becomes inert;
|
|
251
|
+
* further `pushAudio`/`nextPart` fail. Call this promptly — GC teardown
|
|
252
|
+
* drops the channels (which eventually tears the driver down) but never
|
|
253
|
+
* fires the abort token.
|
|
254
|
+
*/
|
|
255
|
+
close(): void
|
|
256
|
+
}
|
|
257
|
+
|
|
133
258
|
export declare class VideoModel {
|
|
134
259
|
/**
|
|
135
260
|
* Generate video. `opts_json` is JSON-serialized VideoCallOptions.
|
|
@@ -140,50 +265,68 @@ export declare class VideoModel {
|
|
|
140
265
|
}
|
|
141
266
|
|
|
142
267
|
/** Create an Anthropic model instance. */
|
|
143
|
-
export declare function anthropic(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
268
|
+
export declare function anthropic(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
144
269
|
|
|
145
270
|
/** Create an Anthropic-on-AWS language model instance (API key + region). */
|
|
146
|
-
export declare function anthropicAws(apiKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
271
|
+
export declare function anthropicAws(apiKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
147
272
|
|
|
148
273
|
/**
|
|
149
274
|
* Create an Azure OpenAI language model instance (API key + resource name).
|
|
150
275
|
*
|
|
151
276
|
* The deployment name is passed as `model_id`; `api_version` is optional.
|
|
152
277
|
*/
|
|
153
|
-
export declare function azure(apiKey: string, resourceName: string, deployment: string, apiVersion?: string | undefined | null, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
278
|
+
export declare function azure(apiKey: string, resourceName: string, deployment: string, apiVersion?: string | undefined | null, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
154
279
|
|
|
155
280
|
/** Create a Bedrock language model instance (AWS SigV4 credentials). */
|
|
156
|
-
export declare function bedrock(accessKeyId: string, secretAccessKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
281
|
+
export declare function bedrock(accessKeyId: string, secretAccessKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
157
282
|
|
|
158
283
|
/** Create a Cohere language model instance. */
|
|
159
|
-
export declare function cohere(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
284
|
+
export declare function cohere(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
160
285
|
|
|
161
286
|
/** Create a Cohere embedding model instance. */
|
|
162
|
-
export declare function cohereEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<EmbeddingModel
|
|
287
|
+
export declare function cohereEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<EmbeddingModel>>
|
|
163
288
|
|
|
164
289
|
/** Create a Cohere reranking model instance. */
|
|
165
|
-
export declare function cohereReranking(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<RerankingModel
|
|
290
|
+
export declare function cohereReranking(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<RerankingModel>>
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Create a **provider handle** (RFC-0027) for a registry-backed provider.
|
|
294
|
+
*
|
|
295
|
+
* Unlike `provider()` (which binds to a single model_id), this returns a
|
|
296
|
+
* `ProviderHandle` that supports `listModels()` and `model()`.
|
|
297
|
+
*
|
|
298
|
+
* `api_key` may be empty/null to read the provider's env var from the
|
|
299
|
+
* registry entry.
|
|
300
|
+
*/
|
|
301
|
+
export declare function createProvider(name: string, apiKey?: string | undefined | null, config?: ProviderConfig | undefined | null): Promise<AimuxResult<ProviderHandle>>
|
|
166
302
|
|
|
167
303
|
/** Create a DeepSeek model instance (registry-backed since RFC-0017 phase 4). */
|
|
168
|
-
export declare function deepseek(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
304
|
+
export declare function deepseek(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Fetch the community model catalogue (anya2a). Returns a JSON-serialized
|
|
308
|
+
* `Catalogue` (provider → model_id → ModelSpec). Thin fetch — no caching.
|
|
309
|
+
* `source_url` may be null for the default endpoint.
|
|
310
|
+
*/
|
|
311
|
+
export declare function getModelSpecs(sourceUrl?: string | undefined | null): Promise<AimuxResult<string>>
|
|
169
312
|
|
|
170
313
|
/**
|
|
171
314
|
* Create a Google Gemini language model instance.
|
|
172
315
|
*
|
|
173
316
|
* Google speaks the native `generateContent` protocol (not OpenAI-compatible),
|
|
174
317
|
* so it is **not** registry-backed — `provider("google", ...)` fails with
|
|
175
|
-
* `
|
|
318
|
+
* `NoSuchProvider`. This factory is the only entry point.
|
|
176
319
|
*/
|
|
177
|
-
export declare function google(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
320
|
+
export declare function google(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
178
321
|
|
|
179
322
|
/** Create a Google embedding model instance. */
|
|
180
|
-
export declare function googleEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<EmbeddingModel
|
|
323
|
+
export declare function googleEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<EmbeddingModel>>
|
|
181
324
|
|
|
182
325
|
/** Create a Google image model instance. */
|
|
183
|
-
export declare function googleImage(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<ImageModel
|
|
326
|
+
export declare function googleImage(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<ImageModel>>
|
|
184
327
|
|
|
185
328
|
/** Create a Google video model instance. */
|
|
186
|
-
export declare function googleVideo(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<VideoModel
|
|
329
|
+
export declare function googleVideo(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<VideoModel>>
|
|
187
330
|
|
|
188
331
|
/**
|
|
189
332
|
* 初始化全局日志(RFC-0014)。幂等:多次调用无副作用;宿主已自建
|
|
@@ -193,33 +336,87 @@ export declare function googleVideo(apiKey: string, modelId: string, baseUrl?: s
|
|
|
193
336
|
*/
|
|
194
337
|
export declare function initLogging(level: string): void
|
|
195
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Set the global proxy configuration (M6, RFC-0016). Must be called before
|
|
341
|
+
* the first `generateText` / `streamText` call; a no-op if the shared HTTP
|
|
342
|
+
* client is already initialised (the shared client is lazily built on first
|
|
343
|
+
* use and locked for the process lifetime).
|
|
344
|
+
*
|
|
345
|
+
* `configJson` shape: `{ "http_url": "...", "https_url": "...", "all_url":
|
|
346
|
+
* "...", "no_proxy": "..." }` (all fields optional; omitting all is equivalent
|
|
347
|
+
* to relying on the `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY`
|
|
348
|
+
* env vars).
|
|
349
|
+
*
|
|
350
|
+
* Throws on invalid JSON.
|
|
351
|
+
*/
|
|
352
|
+
export declare function initProxy(configJson: string): AimuxResult<undefined>
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* 启动录制(RFC-0023 P1/P2):把完整 `Recording` 写 JSONL 到 `{dir}/recordings.jsonl`
|
|
356
|
+
* (目录自动创建)。录制 **opt-in**;再次调用(不同 dir)替换 recorder。
|
|
357
|
+
*/
|
|
358
|
+
export declare function initRecording(dir: string): void
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* 启动内存有界录制(RFC-0023 P6):`RingRecorder`,FIFO 淘汰,丢弃计数可查。
|
|
362
|
+
*
|
|
363
|
+
* `cap` 可省略:省略时使用库默认容量(等价于 FFI `aimux_init_recording_ring_default()`;
|
|
364
|
+
* 本绑定直接依赖 aimux-core 而非 aimux-ffi,故调用等价 core API `RingRecorder::default()`)。
|
|
365
|
+
* 显式传 `cap == 0` 抛错(与其余语言一致),`cap > 0` 启动指定容量的有界 ring。
|
|
366
|
+
*/
|
|
367
|
+
export declare function initRecordingRing(cap?: number | undefined | null): AimuxResult<undefined>
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* Enable/disable the global session inferer (RFC-0024, opt-in, off by
|
|
371
|
+
* default). Explicit `sessionId` values always win regardless of this.
|
|
372
|
+
*/
|
|
373
|
+
export declare function initSessionInfer(enabled: boolean): void
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Register the global session store (RFC-0024). Replaces any previous one.
|
|
377
|
+
* Until called, calls are not grouped and the session query functions return
|
|
378
|
+
* empty results.
|
|
379
|
+
*/
|
|
380
|
+
export declare function initSessionStore(): void
|
|
381
|
+
|
|
382
|
+
/** Query: all known sessions (RFC-0024), as a JSON-serialized `SessionView[]`. */
|
|
383
|
+
export declare function listSessions(): AimuxResult<string>
|
|
384
|
+
|
|
196
385
|
/** Create a Mistral language model instance. */
|
|
197
|
-
export declare function mistral(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
386
|
+
export declare function mistral(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
387
|
+
|
|
388
|
+
export declare function moa(references: Array<Model>, aggregator: Model, configJson?: string | undefined | null): AimuxResult<Model>
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* 从录制 JSONL 创建 mock 回放模型(RFC-0023 P3):按输入匹配录制响应,
|
|
392
|
+
* **不发真实 API**。返回的 `Model` 可用于 `generateText` / `streamText`。
|
|
393
|
+
*/
|
|
394
|
+
export declare function mockReplay(recordingsJsonl: string): AimuxResult<Model>
|
|
198
395
|
|
|
199
396
|
/** Create an OpenAI model instance. */
|
|
200
|
-
export declare function openai(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
397
|
+
export declare function openai(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
201
398
|
|
|
202
399
|
/** Create an OpenAI embedding model instance. */
|
|
203
|
-
export declare function openaiEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<EmbeddingModel
|
|
400
|
+
export declare function openaiEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<EmbeddingModel>>
|
|
204
401
|
|
|
205
402
|
/** Create OpenAI files manager. */
|
|
206
|
-
export declare function openaiFiles(apiKey: string, baseUrl?: string | undefined | null): Promise<Files
|
|
403
|
+
export declare function openaiFiles(apiKey: string, baseUrl?: string | undefined | null): Promise<AimuxResult<Files>>
|
|
207
404
|
|
|
208
405
|
/** Create an OpenAI image model instance. */
|
|
209
|
-
export declare function openaiImage(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<ImageModel
|
|
406
|
+
export declare function openaiImage(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<ImageModel>>
|
|
210
407
|
|
|
211
408
|
/** Create an OpenAI speech (TTS) model instance. */
|
|
212
|
-
export declare function openaiSpeech(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<SpeechModel
|
|
409
|
+
export declare function openaiSpeech(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<SpeechModel>>
|
|
213
410
|
|
|
214
411
|
/** Create an OpenAI transcription model instance. */
|
|
215
|
-
export declare function openaiTranscription(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<TranscriptionModel
|
|
412
|
+
export declare function openaiTranscription(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<TranscriptionModel>>
|
|
216
413
|
|
|
217
414
|
/**
|
|
218
415
|
* Create a language model from the built-in registry by provider name
|
|
219
416
|
* (RFC-0017 phase 4). `api_key` may be empty/null to read the provider's env
|
|
220
417
|
* var from the registry entry.
|
|
221
418
|
*/
|
|
222
|
-
export declare function provider(name: string, apiKey: string | undefined | null, modelId: string, config?: ProviderConfig | undefined | null): Promise<Model
|
|
419
|
+
export declare function provider(name: string, apiKey: string | undefined | null, modelId: string, config?: ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
223
420
|
|
|
224
421
|
/**
|
|
225
422
|
* Optional provider configuration accepted by factory functions.
|
|
@@ -251,11 +448,45 @@ export interface ProviderConfig {
|
|
|
251
448
|
bodyOverrides?: string
|
|
252
449
|
}
|
|
253
450
|
|
|
451
|
+
/** 刷盘全局 recorder(阻塞至 JSONL 落盘;ring 模式为 no-op)。 */
|
|
452
|
+
export declare function recordingFlush(): void
|
|
453
|
+
|
|
454
|
+
/** 停止录制:全局 recorder = None(新调用不再录制)。 */
|
|
455
|
+
export declare function recordingStop(): void
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* Register external OpenAI-compatible providers from a JSON config string
|
|
459
|
+
* (RFC-0020). Entries override same-named built-ins or add new ones.
|
|
460
|
+
*
|
|
461
|
+
* `configJson` shape: `{ "providers": [ { "name": "...", "base_url": "...", ... } ] }`.
|
|
462
|
+
* Throws on invalid JSON or validation failure (bad base_url scheme, empty
|
|
463
|
+
* name, unsupported protocol).
|
|
464
|
+
*/
|
|
465
|
+
export declare function registerProviders(configJson: string): AimuxResult<undefined>
|
|
466
|
+
|
|
467
|
+
export declare function router(models: Array<Model>, configJson?: string | undefined | null): AimuxResult<Model>
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Query: all calls of a session (RFC-0024), as a JSON-serialized
|
|
471
|
+
* `SessionCall[]` (ordered by step). Empty array if the session is unknown
|
|
472
|
+
* or no store is registered.
|
|
473
|
+
*/
|
|
474
|
+
export declare function sessionCalls(sessionId: string): AimuxResult<string>
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Start a streaming transcription session. `opts_json` (optional):
|
|
478
|
+
* `{ "input_audio_format": {"format_type","rate"}, "provider_options",
|
|
479
|
+
* "headers", "include_raw_chunks" }`. `bridge` — optional AbortSignal; firing
|
|
480
|
+
* it aborts the session. The returned parts are JSON-serialized
|
|
481
|
+
* `TranscriptionStreamPart`s.
|
|
482
|
+
*/
|
|
483
|
+
export declare function startTranscriptionSession(model: TranscriptionModel, optsJson?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<AimuxResult<TranscriptionSession>>
|
|
484
|
+
|
|
254
485
|
/** Create a Tavily search model instance. */
|
|
255
|
-
export declare function tavilySearch(apiKey: string, baseUrl?: string | undefined | null): Promise<SearchModel
|
|
486
|
+
export declare function tavilySearch(apiKey: string, baseUrl?: string | undefined | null): Promise<AimuxResult<SearchModel>>
|
|
256
487
|
|
|
257
488
|
/** Create a Vertex AI language model instance (GCP bearer token). */
|
|
258
|
-
export declare function vertex(accessToken: string, project: string, location: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
489
|
+
export declare function vertex(accessToken: string, project: string, location: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
259
490
|
|
|
260
491
|
/** Create an xAI language model instance. */
|
|
261
|
-
export declare function xai(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<Model
|
|
492
|
+
export declare function xai(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|