@arcships/aimux 0.5.0 → 0.6.1
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/README.md +92 -0
- package/dist/error.d.ts +28 -137
- package/dist/error.js +71 -100
- package/dist/generated/ops.d.ts +75 -0
- package/dist/generated/ops.js +80 -0
- package/dist/generated/types.d.ts +5613 -0
- package/dist/{types/CallOptions.js → generated/types.js} +1 -0
- package/dist/index.d.ts +144 -211
- package/dist/index.js +314 -344
- package/dist/native.d.ts +29 -1
- package/dist/native.js +99 -29
- package/dist/types.d.ts +1 -144
- package/dist/types.js +0 -3
- package/index.d.ts +21 -545
- package/index.js +57 -112
- package/package.json +16 -13
- package/dist/types/AiMuxError.d.ts +0 -66
- package/dist/types/AiMuxError.js +0 -2
- package/dist/types/ApiCallError.d.ts +0 -75
- package/dist/types/ApiCallError.js +0 -2
- package/dist/types/AspectRatio.d.ts +0 -11
- package/dist/types/AspectRatio.js +0 -3
- package/dist/types/AudioChunk.d.ts +0 -8
- package/dist/types/AudioChunk.js +0 -3
- package/dist/types/AudioData.d.ts +0 -11
- package/dist/types/AudioData.js +0 -3
- package/dist/types/AudioInput.d.ts +0 -8
- package/dist/types/AudioInput.js +0 -3
- package/dist/types/BreakKind.d.ts +0 -1
- package/dist/types/BreakKind.js +0 -3
- package/dist/types/CallOptions.d.ts +0 -117
- package/dist/types/CatalogueSource.d.ts +0 -4
- package/dist/types/CatalogueSource.js +0 -3
- package/dist/types/ChatCompletion.d.ts +0 -16
- package/dist/types/ChatCompletion.js +0 -2
- package/dist/types/ChatCompletionChoice.d.ts +0 -8
- package/dist/types/ChatCompletionChoice.js +0 -2
- package/dist/types/ChatCompletionChunk.d.ts +0 -15
- package/dist/types/ChatCompletionChunk.js +0 -2
- package/dist/types/ChatCompletionChunkChoice.d.ts +0 -8
- package/dist/types/ChatCompletionChunkChoice.js +0 -2
- package/dist/types/ChatCompletionChunkFunction.d.ts +0 -4
- package/dist/types/ChatCompletionChunkFunction.js +0 -3
- package/dist/types/ChatCompletionChunkToolCall.d.ts +0 -7
- package/dist/types/ChatCompletionChunkToolCall.js +0 -2
- package/dist/types/ChatCompletionDelta.d.ts +0 -7
- package/dist/types/ChatCompletionDelta.js +0 -2
- package/dist/types/ChatCompletionFunction.d.ts +0 -4
- package/dist/types/ChatCompletionFunction.js +0 -3
- package/dist/types/ChatCompletionMessage.d.ts +0 -9
- package/dist/types/ChatCompletionMessage.js +0 -2
- package/dist/types/ChatCompletionToolCall.d.ts +0 -6
- package/dist/types/ChatCompletionToolCall.js +0 -2
- package/dist/types/ChatCompletionUsage.d.ts +0 -9
- package/dist/types/ChatCompletionUsage.js +0 -2
- package/dist/types/CompletionTokensDetails.d.ts +0 -3
- package/dist/types/CompletionTokensDetails.js +0 -3
- package/dist/types/ContentPart.d.ts +0 -112
- package/dist/types/ContentPart.js +0 -2
- package/dist/types/EmbeddingCallOptions.d.ts +0 -33
- package/dist/types/EmbeddingCallOptions.js +0 -2
- package/dist/types/EmbeddingResponse.d.ts +0 -16
- package/dist/types/EmbeddingResponse.js +0 -2
- package/dist/types/EmbeddingResult.d.ts +0 -33
- package/dist/types/EmbeddingResult.js +0 -2
- package/dist/types/EmbeddingUsage.d.ts +0 -9
- package/dist/types/EmbeddingUsage.js +0 -3
- package/dist/types/FileBytes.d.ts +0 -12
- package/dist/types/FileBytes.js +0 -3
- package/dist/types/FileData.d.ts +0 -25
- package/dist/types/FileData.js +0 -2
- package/dist/types/FilePart.d.ts +0 -8
- package/dist/types/FilePart.js +0 -2
- package/dist/types/Fingerprint.d.ts +0 -21
- package/dist/types/Fingerprint.js +0 -3
- package/dist/types/FinishReason.d.ts +0 -14
- package/dist/types/FinishReason.js +0 -2
- package/dist/types/FinishReasonUnified.d.ts +0 -4
- package/dist/types/FinishReasonUnified.js +0 -3
- package/dist/types/FunctionTool.d.ts +0 -35
- package/dist/types/FunctionTool.js +0 -2
- package/dist/types/GenerateContent.d.ts +0 -88
- package/dist/types/GenerateContent.js +0 -2
- package/dist/types/GenerateObjectResult.d.ts +0 -48
- package/dist/types/GenerateObjectResult.js +0 -2
- package/dist/types/GenerateResult.d.ts +0 -45
- package/dist/types/GenerateResult.js +0 -2
- package/dist/types/GenerateTextOptions.d.ts +0 -62
- package/dist/types/GenerateTextOptions.js +0 -2
- package/dist/types/GenerateTextResult.d.ts +0 -81
- package/dist/types/GenerateTextResult.js +0 -2
- package/dist/types/HttpExchange.d.ts +0 -34
- package/dist/types/HttpExchange.js +0 -2
- package/dist/types/HttpRecord.d.ts +0 -12
- package/dist/types/HttpRecord.js +0 -3
- package/dist/types/ImageCallOptions.d.ts +0 -63
- package/dist/types/ImageCallOptions.js +0 -2
- package/dist/types/ImageFile.d.ts +0 -25
- package/dist/types/ImageFile.js +0 -2
- package/dist/types/ImageFileData.d.ts +0 -8
- package/dist/types/ImageFileData.js +0 -3
- package/dist/types/ImageOutputs.d.ts +0 -14
- package/dist/types/ImageOutputs.js +0 -3
- package/dist/types/ImageResponse.d.ts +0 -19
- package/dist/types/ImageResponse.js +0 -3
- package/dist/types/ImageResult.d.ts +0 -34
- package/dist/types/ImageResult.js +0 -2
- package/dist/types/ImageUsage.d.ts +0 -19
- package/dist/types/ImageUsage.js +0 -3
- package/dist/types/InputAudioFormat.d.ts +0 -13
- package/dist/types/InputAudioFormat.js +0 -3
- package/dist/types/InputRecord.d.ts +0 -16
- package/dist/types/InputRecord.js +0 -2
- package/dist/types/LanguageModelPromptMessage.d.ts +0 -20
- package/dist/types/LanguageModelPromptMessage.js +0 -2
- package/dist/types/MessageContent.d.ts +0 -5
- package/dist/types/MessageContent.js +0 -2
- package/dist/types/Modality.d.ts +0 -4
- package/dist/types/Modality.js +0 -3
- package/dist/types/ModelCapabilities.d.ts +0 -21
- package/dist/types/ModelCapabilities.js +0 -3
- package/dist/types/ModelCost.d.ts +0 -10
- package/dist/types/ModelCost.js +0 -3
- package/dist/types/ModelId.d.ts +0 -7
- package/dist/types/ModelId.js +0 -3
- package/dist/types/ModelLimits.d.ts +0 -17
- package/dist/types/ModelLimits.js +0 -3
- package/dist/types/ModelMessage.d.ts +0 -9
- package/dist/types/ModelMessage.js +0 -2
- package/dist/types/ModelModalities.d.ts +0 -8
- package/dist/types/ModelModalities.js +0 -2
- package/dist/types/ModelPrompt.d.ts +0 -7
- package/dist/types/ModelPrompt.js +0 -2
- package/dist/types/ModelSpec.d.ts +0 -33
- package/dist/types/ModelSpec.js +0 -2
- package/dist/types/ModelType.d.ts +0 -4
- package/dist/types/ModelType.js +0 -3
- package/dist/types/OutcomeRecord.d.ts +0 -19
- package/dist/types/OutcomeRecord.js +0 -2
- package/dist/types/OutcomeStatus.d.ts +0 -4
- package/dist/types/OutcomeStatus.js +0 -3
- package/dist/types/PrefixBreak.d.ts +0 -11
- package/dist/types/PrefixBreak.js +0 -2
- package/dist/types/PromptTokensDetails.d.ts +0 -4
- package/dist/types/PromptTokensDetails.js +0 -3
- package/dist/types/ProviderAuditSpec.d.ts +0 -33
- package/dist/types/ProviderAuditSpec.js +0 -2
- package/dist/types/ProviderFamily.d.ts +0 -5
- package/dist/types/ProviderFamily.js +0 -3
- package/dist/types/ProviderName.d.ts +0 -258
- package/dist/types/ProviderName.js +0 -262
- package/dist/types/ProviderRecord.d.ts +0 -30
- package/dist/types/ProviderRecord.js +0 -2
- package/dist/types/ProviderTool.d.ts +0 -24
- package/dist/types/ProviderTool.js +0 -2
- package/dist/types/RawToolCall.d.ts +0 -16
- package/dist/types/RawToolCall.js +0 -2
- package/dist/types/ReasoningEffort.d.ts +0 -7
- package/dist/types/ReasoningEffort.js +0 -3
- package/dist/types/ReasoningMode.d.ts +0 -4
- package/dist/types/ReasoningMode.js +0 -3
- package/dist/types/ReasoningPart.d.ts +0 -9
- package/dist/types/ReasoningPart.js +0 -3
- package/dist/types/ReasoningSpec.d.ts +0 -39
- package/dist/types/ReasoningSpec.js +0 -2
- package/dist/types/ReasoningVisibility.d.ts +0 -4
- package/dist/types/ReasoningVisibility.js +0 -3
- package/dist/types/Recording.d.ts +0 -56
- package/dist/types/Recording.js +0 -2
- package/dist/types/RequestCacheHints.d.ts +0 -9
- package/dist/types/RequestCacheHints.js +0 -3
- package/dist/types/RequestInfo.d.ts +0 -12
- package/dist/types/RequestInfo.js +0 -2
- package/dist/types/RerankingCallOptions.d.ts +0 -42
- package/dist/types/RerankingCallOptions.js +0 -2
- package/dist/types/RerankingDocuments.d.ts +0 -15
- package/dist/types/RerankingDocuments.js +0 -2
- package/dist/types/RerankingRank.d.ts +0 -13
- package/dist/types/RerankingRank.js +0 -3
- package/dist/types/RerankingResponse.d.ts +0 -28
- package/dist/types/RerankingResponse.js +0 -2
- package/dist/types/RerankingResult.d.ts +0 -31
- package/dist/types/RerankingResult.js +0 -2
- package/dist/types/ResponseFormat.d.ts +0 -11
- package/dist/types/ResponseFormat.js +0 -2
- package/dist/types/ResponseInfo.d.ts +0 -30
- package/dist/types/ResponseInfo.js +0 -2
- package/dist/types/ResponseMetadata.d.ts +0 -8
- package/dist/types/ResponseMetadata.js +0 -3
- package/dist/types/ResponseRecord.d.ts +0 -13
- package/dist/types/ResponseRecord.js +0 -3
- package/dist/types/RetryError.d.ts +0 -9
- package/dist/types/RetryError.js +0 -2
- package/dist/types/RetryErrorReason.d.ts +0 -4
- package/dist/types/RetryErrorReason.js +0 -3
- package/dist/types/Role.d.ts +0 -4
- package/dist/types/Role.js +0 -3
- package/dist/types/RuntimeModel.d.ts +0 -22
- package/dist/types/RuntimeModel.js +0 -3
- package/dist/types/SearchCallOptions.d.ts +0 -55
- package/dist/types/SearchCallOptions.js +0 -2
- package/dist/types/SearchResponse.d.ts +0 -16
- package/dist/types/SearchResponse.js +0 -2
- package/dist/types/SearchResult.d.ts +0 -32
- package/dist/types/SearchResult.js +0 -2
- package/dist/types/SearchResultItem.d.ts +0 -33
- package/dist/types/SearchResultItem.js +0 -2
- package/dist/types/SessionCall.d.ts +0 -20
- package/dist/types/SessionCall.js +0 -3
- package/dist/types/SessionChainView.d.ts +0 -10
- package/dist/types/SessionChainView.js +0 -2
- package/dist/types/SessionSource.d.ts +0 -4
- package/dist/types/SessionSource.js +0 -3
- package/dist/types/SessionStepStat.d.ts +0 -27
- package/dist/types/SessionStepStat.js +0 -2
- package/dist/types/SessionView.d.ts +0 -16
- package/dist/types/SessionView.js +0 -2
- package/dist/types/Size.d.ts +0 -11
- package/dist/types/Size.js +0 -3
- package/dist/types/SourcePart.d.ts +0 -9
- package/dist/types/SourcePart.js +0 -3
- package/dist/types/SpeechCallOptions.d.ts +0 -56
- package/dist/types/SpeechCallOptions.js +0 -2
- package/dist/types/SpeechRequest.d.ts +0 -10
- package/dist/types/SpeechRequest.js +0 -2
- package/dist/types/SpeechResponse.d.ts +0 -24
- package/dist/types/SpeechResponse.js +0 -2
- package/dist/types/SpeechResult.d.ts +0 -34
- package/dist/types/SpeechResult.js +0 -2
- package/dist/types/StreamPart.d.ts +0 -173
- package/dist/types/StreamPart.js +0 -2
- package/dist/types/StreamTextResultAggregated.d.ts +0 -74
- package/dist/types/StreamTextResultAggregated.js +0 -2
- package/dist/types/TimeoutConfiguration.d.ts +0 -32
- package/dist/types/TimeoutConfiguration.js +0 -3
- package/dist/types/TimingRecord.d.ts +0 -7
- package/dist/types/TimingRecord.js +0 -3
- package/dist/types/TokenUsage.d.ts +0 -29
- package/dist/types/TokenUsage.js +0 -3
- package/dist/types/Tool.d.ts +0 -12
- package/dist/types/Tool.js +0 -2
- package/dist/types/ToolCall.d.ts +0 -48
- package/dist/types/ToolCall.js +0 -2
- package/dist/types/ToolCallRepairReply.d.ts +0 -19
- package/dist/types/ToolCallRepairReply.js +0 -2
- package/dist/types/ToolChoice.d.ts +0 -12
- package/dist/types/ToolChoice.js +0 -3
- package/dist/types/ToolResult.d.ts +0 -22
- package/dist/types/ToolResult.js +0 -2
- package/dist/types/TraceFilter.d.ts +0 -9
- package/dist/types/TraceFilter.js +0 -3
- package/dist/types/TraceRecord.d.ts +0 -54
- package/dist/types/TraceRecord.js +0 -2
- package/dist/types/TraceStats.d.ts +0 -20
- package/dist/types/TraceStats.js +0 -3
- package/dist/types/TranscriptionCallOptions.d.ts +0 -38
- package/dist/types/TranscriptionCallOptions.js +0 -2
- package/dist/types/TranscriptionRequest.d.ts +0 -9
- package/dist/types/TranscriptionRequest.js +0 -3
- package/dist/types/TranscriptionResponse.d.ts +0 -24
- package/dist/types/TranscriptionResponse.js +0 -2
- package/dist/types/TranscriptionResult.d.ts +0 -46
- package/dist/types/TranscriptionResult.js +0 -2
- package/dist/types/TranscriptionSegment.d.ts +0 -17
- package/dist/types/TranscriptionSegment.js +0 -3
- package/dist/types/TranscriptionStreamPart.d.ts +0 -70
- package/dist/types/TranscriptionStreamPart.js +0 -2
- package/dist/types/UploadFileCallOptions.d.ts +0 -27
- package/dist/types/UploadFileCallOptions.js +0 -2
- package/dist/types/UploadFileData.d.ts +0 -17
- package/dist/types/UploadFileData.js +0 -2
- package/dist/types/UploadFileResult.d.ts +0 -35
- package/dist/types/UploadFileResult.js +0 -2
- package/dist/types/Usage.d.ts +0 -13
- package/dist/types/Usage.js +0 -2
- package/dist/types/UsageSnapshot.d.ts +0 -18
- package/dist/types/UsageSnapshot.js +0 -2
- package/dist/types/Verdict.d.ts +0 -23
- package/dist/types/Verdict.js +0 -2
- package/dist/types/VerdictConfidence.d.ts +0 -4
- package/dist/types/VerdictConfidence.js +0 -3
- package/dist/types/VerdictKind.d.ts +0 -4
- package/dist/types/VerdictKind.js +0 -3
- package/dist/types/VideoCallOptions.d.ts +0 -84
- package/dist/types/VideoCallOptions.js +0 -2
- package/dist/types/VideoData.d.ts +0 -22
- package/dist/types/VideoData.js +0 -3
- package/dist/types/VideoFile.d.ts +0 -29
- package/dist/types/VideoFile.js +0 -2
- package/dist/types/VideoFileData.d.ts +0 -8
- package/dist/types/VideoFileData.js +0 -3
- package/dist/types/VideoFrameImage.d.ts +0 -17
- package/dist/types/VideoFrameImage.js +0 -2
- package/dist/types/VideoFrameType.d.ts +0 -6
- package/dist/types/VideoFrameType.js +0 -3
- package/dist/types/VideoPollOptions.d.ts +0 -13
- package/dist/types/VideoPollOptions.js +0 -3
- package/dist/types/VideoResponse.d.ts +0 -19
- package/dist/types/VideoResponse.js +0 -3
- package/dist/types/VideoResult.d.ts +0 -29
- package/dist/types/VideoResult.js +0 -2
- package/dist/types/Warning.d.ts +0 -23
- package/dist/types/Warning.js +0 -3
- package/dist/types/serde_json/JsonValue.d.ts +0 -3
- package/dist/types/serde_json/JsonValue.js +0 -3
package/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
|
|
4
|
-
export type AimuxResult<T> = T
|
|
5
|
-
/** Stream yield — a StreamPart JSON string at runtime; failures reject `next()` with a typed error. */
|
|
6
|
-
export type StreamItem = string
|
|
3
|
+
export type WireResult<T> = T
|
|
7
4
|
declare global {
|
|
8
5
|
interface __NapiRsAsyncGenerator<TOwner, T, TReturn, TNext> {
|
|
9
6
|
next(...[value]: [] | [TNext]): globalThis.Promise<globalThis.IteratorResult<T, TReturn | undefined>>
|
|
@@ -13,556 +10,35 @@ declare global {
|
|
|
13
10
|
}
|
|
14
11
|
}
|
|
15
12
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* const bridge = signal ? new AbortBridge(signal) : undefined
|
|
26
|
-
* await model.generateText(prompt, options, bridge)
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare class AbortBridge {
|
|
30
|
-
constructor(signal: AbortSignal)
|
|
31
|
-
/** Returns `true` once the underlying JS signal has been aborted. */
|
|
32
|
-
aborted(): boolean
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export declare class EmbeddingModel {
|
|
36
|
-
/**
|
|
37
|
-
* Generate embeddings. `values_json` is a JSON array of strings.
|
|
38
|
-
* Returns JSON-serialized EmbeddingResult.
|
|
39
|
-
*/
|
|
40
|
-
embed(valuesJson: string, optsJson?: string | undefined | null): Promise<string>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export declare class Files {
|
|
44
|
-
/**
|
|
45
|
-
* Upload a file. `data_base64` is base64-encoded file content,
|
|
46
|
-
* `media_type` is e.g. "application/pdf", `opts_json` is optional
|
|
47
|
-
* (may contain filename, provider_options).
|
|
48
|
-
* Returns JSON-serialized UploadFileResult (contains provider file ID).
|
|
49
|
-
*/
|
|
50
|
-
uploadFile(dataBase64: string, mediaType: string, optsJson?: string | undefined | null): Promise<string>
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export declare class ImageModel {
|
|
54
|
-
/**
|
|
55
|
-
* Generate images. `opts_json` is JSON-serialized ImageCallOptions.
|
|
56
|
-
* `bridge` — optional `AbortBridge`; aborting the wrapped signal cancels
|
|
57
|
-
* the call. Returns JSON-serialized ImageResult (images as base64 in JSON).
|
|
58
|
-
*/
|
|
59
|
-
generate(optsJson: string, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
60
|
-
}
|
|
61
|
-
|
|
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
|
|
96
|
-
/**
|
|
97
|
-
* Generate text (non-streaming).
|
|
98
|
-
*
|
|
99
|
-
* `prompt` — a JSON string: bare prompt (`"text"` or `[{...}]`) or `{"prompt": ...}`.
|
|
100
|
-
* `options` — optional JSON-serialized `GenerateTextOptions`.
|
|
101
|
-
* `bridge` — optional `AbortBridge` (wrap a JS `AbortSignal` in one);
|
|
102
|
-
* aborting the signal cancels the call.
|
|
103
|
-
* Returns a JSON-serialized `GenerateTextResult`.
|
|
104
|
-
*/
|
|
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>
|
|
123
|
-
/**
|
|
124
|
-
* Stream text from the model.
|
|
125
|
-
*
|
|
126
|
-
* Returns an `AsyncGenerator<string>` yielding `StreamPart` JSON strings.
|
|
127
|
-
* Use `for await (const part of model.streamText(...))` to consume.
|
|
128
|
-
*/
|
|
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
|
-
* Convert a serialized `GenerateTextResult` into a serialized
|
|
138
|
-
* `ChatCompletion` — the conversion half of `generateTextAsOpenai`.
|
|
139
|
-
*
|
|
140
|
-
* For repairing on the host (RFC-0035): patch the native result, then
|
|
141
|
-
* convert it, so the completion's tool calls are the repaired ones. This
|
|
142
|
-
* model only supplies the fallback model id.
|
|
143
|
-
*/
|
|
144
|
-
generateTextResultAsOpenai(resultJson: string): AimuxResult<string>
|
|
145
|
-
/**
|
|
146
|
-
* Stream text as OpenAI Chat Completion chunks.
|
|
147
|
-
*
|
|
148
|
-
* Returns an `AsyncGenerator<string>` yielding `ChatCompletionChunk` JSON
|
|
149
|
-
* strings. Works with any provider.
|
|
150
|
-
*/
|
|
151
|
-
streamTextAsOpenai(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<AsyncGenerator<string>>
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* A provider handle — created by `createProvider`, supports `listModels()`
|
|
156
|
-
* (runtime discovery) and `model()` (build a model from a discovered id).
|
|
157
|
-
*
|
|
158
|
-
* ```ts
|
|
159
|
-
* const p = await createProvider('deepseek', apiKey)
|
|
160
|
-
* const models = await p.listModels()
|
|
161
|
-
* const model = await p.model(models[0].id)
|
|
162
|
-
* const result = await generateText(model, 'Hello')
|
|
163
|
-
* ```
|
|
164
|
-
*/
|
|
165
|
-
export declare class ProviderHandle {
|
|
166
|
-
/**
|
|
167
|
-
* List models available on this provider (runtime discovery via the
|
|
168
|
-
* provider's `/models` endpoint). Returns a JSON array of sparse
|
|
169
|
-
* `RuntimeModel` (id / owned_by / created) — **no community enrichment**.
|
|
170
|
-
* To supplement with model specs (context length, capabilities, reasoning),
|
|
171
|
-
* call `getModelSpecs` separately and merge in the host (RFC-0027).
|
|
172
|
-
*/
|
|
173
|
-
listModels(): Promise<AimuxResult<string>>
|
|
174
|
-
/**
|
|
175
|
-
* Build a language model from a discovered model id. Returns a `Model`
|
|
176
|
-
* usable with `generateText` / `streamText`.
|
|
177
|
-
*/
|
|
178
|
-
model(modelId: string): Promise<AimuxResult<Model>>
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export declare class RerankingModel {
|
|
182
|
-
/**
|
|
183
|
-
* Rerank documents. `query` is the search query, `docs_json` is a JSON
|
|
184
|
-
* array of documents, `opts_json` is optional JSON options.
|
|
185
|
-
* `bridge` — optional `AbortBridge`; aborting the wrapped signal cancels
|
|
186
|
-
* the call. Returns JSON-serialized RerankingResult.
|
|
187
|
-
*/
|
|
188
|
-
rerank(query: string, docsJson: string, optsJson?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export declare class SearchModel {
|
|
192
|
-
/**
|
|
193
|
-
* Search. `query` is the search query, `opts_json` is optional JSON options.
|
|
194
|
-
* `bridge` — optional `AbortBridge`; aborting the wrapped signal cancels
|
|
195
|
-
* the call. Returns JSON-serialized SearchResult.
|
|
196
|
-
*/
|
|
197
|
-
search(query: string, optsJson?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export declare class SpeechModel {
|
|
201
|
-
/**
|
|
202
|
-
* Generate speech audio. `opts_json` is JSON-serialized SpeechCallOptions.
|
|
203
|
-
* `bridge` — optional `AbortBridge`; aborting the wrapped signal cancels
|
|
204
|
-
* the call. Returns JSON-serialized SpeechResult (audio as base64 in JSON).
|
|
205
|
-
*/
|
|
206
|
-
generate(optsJson: string, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
13
|
+
/** An Abort handle; dropping it releases the handle without signalling shared work. */
|
|
14
|
+
export declare class Abort {
|
|
15
|
+
constructor(runtime: Runtime, signal?: AbortSignal)
|
|
16
|
+
get handle(): string
|
|
17
|
+
signal(): void
|
|
18
|
+
close(): void
|
|
19
|
+
get aborted(): boolean
|
|
207
20
|
}
|
|
208
21
|
|
|
209
22
|
/**
|
|
210
|
-
* AsyncGenerator that yields StreamPart JSON strings.
|
|
211
|
-
*
|
|
212
|
-
* The stream is started eagerly in `stream_text()` — a tokio task drives
|
|
213
|
-
* the Rust Stream and sends each chunk through a channel. `next()` simply
|
|
214
|
-
* receives from the channel.
|
|
215
|
-
*
|
|
216
23
|
* This type implements JavaScript's async iterable protocol.
|
|
217
24
|
* It can be used with `for await...of` loops.
|
|
218
25
|
*
|
|
219
26
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
|
|
220
27
|
*/
|
|
221
|
-
export declare class
|
|
222
|
-
|
|
223
|
-
[globalThis.Symbol.asyncIterator](): globalThis.__NapiRsAsyncGenerator<StreamTextGenerator, StreamItem, void, undefined>
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
export declare class TranscriptionModel {
|
|
227
|
-
/**
|
|
228
|
-
* Transcribe audio. `audio_base64` is base64-encoded audio data.
|
|
229
|
-
* `media_type` is e.g. "audio/mp3". `opts_json` is optional JSON options.
|
|
230
|
-
* `bridge` — optional `AbortBridge`; aborting the wrapped signal cancels
|
|
231
|
-
* the call. Returns JSON-serialized TranscriptionResult.
|
|
232
|
-
*/
|
|
233
|
-
generate(audioBase64: string, mediaType: string, optsJson?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* A live streaming-transcription session (RFC-0028). Push audio chunks with
|
|
238
|
-
* `pushAudio`, mark end-of-audio with `inputDone`, then pull transcription
|
|
239
|
-
* parts with `nextPart`. Mirrors the C-ABI session shape, built natively on
|
|
240
|
-
* core channels.
|
|
241
|
-
*/
|
|
242
|
-
export declare class TranscriptionSession {
|
|
243
|
-
/**
|
|
244
|
-
* Push one binary audio chunk. Awaits while the internal channel is
|
|
245
|
-
* full (backpressure).
|
|
246
|
-
*/
|
|
247
|
-
pushAudio(data: Buffer): Promise<AimuxResult<undefined>>
|
|
248
|
-
/** Signal end-of-audio (idempotent). */
|
|
249
|
-
inputDone(): AimuxResult<undefined>
|
|
250
|
-
/**
|
|
251
|
-
* Pull the next transcription part (JSON string). Resolves `null` when
|
|
252
|
-
* the stream ended normally. Rejects on error — including a timeout
|
|
253
|
-
* (no part within `timeoutMs`; the session stays live, call again).
|
|
254
|
-
* `timeoutMs`: >0 wait at most; 0 immediate poll; negative OR omitted
|
|
255
|
-
* = wait indefinitely.
|
|
256
|
-
*/
|
|
257
|
-
nextPart(timeoutMs?: number | undefined | null): Promise<AimuxResult<string | undefined | null>>
|
|
258
|
-
/**
|
|
259
|
-
* Terminate the session (aborts the driver). The object becomes inert;
|
|
260
|
-
* further `pushAudio`/`nextPart` fail. Call this promptly — GC teardown
|
|
261
|
-
* drops the channels (which eventually tears the driver down) but never
|
|
262
|
-
* fires the abort token.
|
|
263
|
-
*/
|
|
264
|
-
close(): void
|
|
265
|
-
}
|
|
28
|
+
export declare class FrameIterator {
|
|
266
29
|
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Generate video. `opts_json` is JSON-serialized VideoCallOptions.
|
|
270
|
-
* `bridge` — optional `AbortBridge`; aborting the wrapped signal cancels
|
|
271
|
-
* the call. Returns JSON-serialized VideoResult (typically contains a URL).
|
|
272
|
-
*/
|
|
273
|
-
generate(optsJson: string, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
30
|
+
[globalThis.Symbol.asyncIterator](): globalThis.__NapiRsAsyncGenerator<FrameIterator, WireResult<string>, void, undefined>
|
|
274
31
|
}
|
|
275
32
|
|
|
276
|
-
/**
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
/**
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
/** Create an Anthropic-on-AWS language model instance (API key + region). */
|
|
288
|
-
export declare function anthropicAws(apiKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Resolve one invalid tool call against a host's repair reply.
|
|
292
|
-
*
|
|
293
|
-
* `optsJson` is the same string the call was generated with; the tool set
|
|
294
|
-
* comes from it. `replyJson` is `{"type":"repaired","tool_call":{…}}`,
|
|
295
|
-
* `{"type":"unchanged"}`, or `{"type":"failed","message":"…"}`. Returns the
|
|
296
|
-
* resulting `ToolCall` JSON — valid, or invalid carrying a nested
|
|
297
|
-
* `ToolCallRepairError`.
|
|
298
|
-
*
|
|
299
|
-
* Options carrying no tools throw `InvalidArgumentError`: such a call is not
|
|
300
|
-
* repairable, and `toolCallRepairContext` already said so by returning
|
|
301
|
-
* `"null"`.
|
|
302
|
-
*/
|
|
303
|
-
export declare function applyToolCallRepair(toolCallJson: string, optsJson: string | undefined | null, replyJson: string): AimuxResult<string>
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* Apply a repair reply to a serialized `GenerateTextResult` or
|
|
307
|
-
* `GenerateObjectResult`, rewriting both `tool_calls` and the matching
|
|
308
|
-
* `response_messages` tool-call part. `optsJson` is the same string the call
|
|
309
|
-
* was generated with.
|
|
310
|
-
*
|
|
311
|
-
* The OpenAI-shaped result has no equivalent: it carries no `invalid` /
|
|
312
|
-
* `error`, so repair is driven from the native result, which
|
|
313
|
-
* `Model.generateTextResultAsOpenai` then converts.
|
|
314
|
-
*/
|
|
315
|
-
export declare function applyToolCallRepairToResult(resultJson: string, optsJson: string | undefined | null, toolCallId: string, replyJson: string): AimuxResult<string>
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Create an Azure OpenAI language model instance (API key + resource name).
|
|
319
|
-
*
|
|
320
|
-
* The deployment name is passed as `model_id`; `api_version` is optional.
|
|
321
|
-
*/
|
|
322
|
-
export declare function azure(apiKey: string, resourceName: string, deployment: string, apiVersion?: string | undefined | null, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
323
|
-
|
|
324
|
-
/** Create a Bedrock language model instance (AWS SigV4 credentials). */
|
|
325
|
-
export declare function bedrock(accessKeyId: string, secretAccessKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
326
|
-
|
|
327
|
-
/** Create a Cohere language model instance. */
|
|
328
|
-
export declare function cohere(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
329
|
-
|
|
330
|
-
/** Create a Cohere embedding model instance. */
|
|
331
|
-
export declare function cohereEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<EmbeddingModel>>
|
|
332
|
-
|
|
333
|
-
/** Create a Cohere reranking model instance. */
|
|
334
|
-
export declare function cohereReranking(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<RerankingModel>>
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Create a **provider handle** (RFC-0027) for a registry-backed provider.
|
|
338
|
-
*
|
|
339
|
-
* Unlike `provider()` (which binds to a single model_id), this returns a
|
|
340
|
-
* `ProviderHandle` that supports `listModels()` and `model()`.
|
|
341
|
-
*
|
|
342
|
-
* `api_key` may be empty/null to read the provider's env var from the
|
|
343
|
-
* registry entry.
|
|
344
|
-
*/
|
|
345
|
-
export declare function createProvider(name: string, apiKey?: string | undefined | null, config?: ProviderConfig | undefined | null): Promise<AimuxResult<ProviderHandle>>
|
|
346
|
-
|
|
347
|
-
/** Create a DeepSeek model instance (registry-backed since RFC-0017 phase 4). */
|
|
348
|
-
export declare function deepseek(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* Fetch the community model catalogue (anya2a). Returns a JSON-serialized
|
|
352
|
-
* `Catalogue` (provider → model_id → ModelSpec). Thin fetch — no caching.
|
|
353
|
-
* `source_url` may be null for the default endpoint.
|
|
354
|
-
*/
|
|
355
|
-
export declare function getModelSpecs(sourceUrl?: string | undefined | null): Promise<AimuxResult<string>>
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* Create a Google Gemini language model instance.
|
|
359
|
-
*
|
|
360
|
-
* Google speaks the native `generateContent` protocol (not OpenAI-compatible),
|
|
361
|
-
* so it is **not** registry-backed — `provider("google", ...)` fails with
|
|
362
|
-
* `NoSuchProvider`. This factory is the only entry point.
|
|
363
|
-
*/
|
|
364
|
-
export declare function google(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
365
|
-
|
|
366
|
-
/** Create a Google embedding model instance. */
|
|
367
|
-
export declare function googleEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<EmbeddingModel>>
|
|
368
|
-
|
|
369
|
-
/** Create a Google image model instance. */
|
|
370
|
-
export declare function googleImage(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<ImageModel>>
|
|
371
|
-
|
|
372
|
-
/** Create a Google video model instance. */
|
|
373
|
-
export declare function googleVideo(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<VideoModel>>
|
|
374
|
-
|
|
375
|
-
/**
|
|
376
|
-
* 初始化全局日志(RFC-0014)。幂等:多次调用无副作用;宿主已自建
|
|
377
|
-
* subscriber 时 no-op。级别:off|error|warn|info|debug|trace(空串回退
|
|
378
|
-
* warn)。`AIMUX_LOG` / `AIMUX_LOG_LEVEL` 环境变量优先级更高。
|
|
379
|
-
* 日志输出到 stderr。
|
|
380
|
-
*/
|
|
381
|
-
export declare function initLogging(level: string): void
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Set the global proxy configuration (M6, RFC-0016). Must be called before
|
|
385
|
-
* the first `generateText` / `streamText` call; a no-op if the shared HTTP
|
|
386
|
-
* client is already initialised (the shared client is lazily built on first
|
|
387
|
-
* use and locked for the process lifetime).
|
|
388
|
-
*
|
|
389
|
-
* `configJson` shape: `{ "http_url": "...", "https_url": "...", "all_url":
|
|
390
|
-
* "...", "no_proxy": "..." }` (all fields optional; omitting all is equivalent
|
|
391
|
-
* to relying on the `HTTP_PROXY` / `HTTPS_PROXY` / `ALL_PROXY` / `NO_PROXY`
|
|
392
|
-
* env vars).
|
|
393
|
-
*
|
|
394
|
-
* Throws on invalid JSON.
|
|
395
|
-
*/
|
|
396
|
-
export declare function initProxy(configJson: string): AimuxResult<undefined>
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* 启动录制(RFC-0023 P1/P2):把完整 `Recording` 写 JSONL 到 `{dir}/recordings.jsonl`
|
|
400
|
-
* (目录自动创建)。录制 **opt-in**;再次调用(不同 dir)替换 recorder。
|
|
401
|
-
* Throws `RecordingError` (`code` = `Init` / `OpenFile` / `Spawn`) when the
|
|
402
|
-
* recorder cannot be set up; the previous recorder, if any, stays in place.
|
|
403
|
-
*/
|
|
404
|
-
export declare function initRecording(dir: string): AimuxResult<undefined>
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* 启动内存有界录制(RFC-0023 P6):`RingRecorder`,FIFO 淘汰,丢弃计数可查。
|
|
408
|
-
*
|
|
409
|
-
* `cap` 可省略:省略时使用库默认容量(等价于 FFI `aimux_init_recording_ring_default()`;
|
|
410
|
-
* 本绑定直接依赖 aimux-core 而非 aimux-ffi,故调用等价 core API `RingRecorder::default()`)。
|
|
411
|
-
* 显式传 `cap == 0` 抛错(与其余语言一致),`cap > 0` 启动指定容量的有界 ring。
|
|
412
|
-
*/
|
|
413
|
-
export declare function initRecordingRing(cap?: number | undefined | null): AimuxResult<undefined>
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* Enable/disable the global session inferer (RFC-0024, opt-in, off by
|
|
417
|
-
* default). Explicit `sessionId` values always win regardless of this.
|
|
418
|
-
*/
|
|
419
|
-
export declare function initSessionInfer(enabled: boolean): void
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Register the global session store (RFC-0024). Replaces any previous one.
|
|
423
|
-
* Until called, calls are not grouped and the session query functions return
|
|
424
|
-
* empty results.
|
|
425
|
-
*/
|
|
426
|
-
export declare function initSessionStore(): void
|
|
427
|
-
|
|
428
|
-
/** Query: all known sessions (RFC-0024), as a JSON-serialized `SessionView[]`. */
|
|
429
|
-
export declare function listSessions(): AimuxResult<string>
|
|
430
|
-
|
|
431
|
-
/** Create a Mistral language model instance. */
|
|
432
|
-
export declare function mistral(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
433
|
-
|
|
434
|
-
export declare function moa(references: Array<Model>, aggregator: Model, configJson?: string | undefined | null): AimuxResult<Model>
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* 从录制 JSONL 创建 mock 回放模型(RFC-0023 P3):按输入匹配录制响应,
|
|
438
|
-
* **不发真实 API**。返回的 `Model` 可用于 `generateText` / `streamText`。
|
|
439
|
-
*/
|
|
440
|
-
export declare function mockReplay(recordingsJsonl: string): AimuxResult<Model>
|
|
441
|
-
|
|
442
|
-
/** Create an OpenAI model instance. */
|
|
443
|
-
export declare function openai(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
444
|
-
|
|
445
|
-
/** Create an OpenAI embedding model instance. */
|
|
446
|
-
export declare function openaiEmbedding(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<EmbeddingModel>>
|
|
447
|
-
|
|
448
|
-
/** Create OpenAI files manager. */
|
|
449
|
-
export declare function openaiFiles(apiKey: string, baseUrl?: string | undefined | null): Promise<AimuxResult<Files>>
|
|
450
|
-
|
|
451
|
-
/** Create an OpenAI image model instance. */
|
|
452
|
-
export declare function openaiImage(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<ImageModel>>
|
|
453
|
-
|
|
454
|
-
/** Create an OpenAI speech (TTS) model instance. */
|
|
455
|
-
export declare function openaiSpeech(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<SpeechModel>>
|
|
456
|
-
|
|
457
|
-
/** Create an OpenAI transcription model instance. */
|
|
458
|
-
export declare function openaiTranscription(apiKey: string, modelId: string, baseUrl?: string | undefined | null): Promise<AimuxResult<TranscriptionModel>>
|
|
459
|
-
|
|
460
|
-
/**
|
|
461
|
-
* Create a language model from the built-in registry by provider name
|
|
462
|
-
* (RFC-0017 phase 4). `api_key` may be empty/null to read the provider's env
|
|
463
|
-
* var from the registry entry.
|
|
464
|
-
*/
|
|
465
|
-
export declare function provider(name: string, apiKey: string | undefined | null, modelId: string, config?: ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
466
|
-
|
|
467
|
-
/**
|
|
468
|
-
* Optional provider configuration accepted by factory functions.
|
|
469
|
-
*
|
|
470
|
-
* Passed as the 3rd argument to `openai()` / `anthropic()` / `deepseek()`.
|
|
471
|
-
* For backward compatibility a bare string is still accepted (treated as
|
|
472
|
-
* `baseUrl`). See RFC-0017.
|
|
473
|
-
*/
|
|
474
|
-
export interface ProviderConfig {
|
|
475
|
-
/** Base URL for API calls (e.g. a relay/proxy endpoint). */
|
|
476
|
-
baseUrl?: string
|
|
477
|
-
/**
|
|
478
|
-
* Extra HTTP headers merged into every request, as a JSON object string
|
|
479
|
-
* (e.g. `'{"X-Custom":"value"}'`).
|
|
480
|
-
*/
|
|
481
|
-
headers?: string
|
|
482
|
-
/** OpenAI organization ID (sent via `OpenAI-Organization` header). */
|
|
483
|
-
organization?: string
|
|
484
|
-
/** OpenAI project ID (sent via `OpenAI-Project` header). */
|
|
485
|
-
project?: string
|
|
486
|
-
/** Override the provider's retry count. `0` disables retries. */
|
|
487
|
-
maxRetries?: number
|
|
488
|
-
/**
|
|
489
|
-
* Provider-level request body overrides as a JSON string (deep-merged
|
|
490
|
-
* into every request). Per-call `bodyOverrides` in GenerateTextOptions
|
|
491
|
-
* takes precedence. Pass a JSON object string, e.g.
|
|
492
|
-
* `'{"enable_thinking": false}'`.
|
|
493
|
-
*/
|
|
494
|
-
bodyOverrides?: string
|
|
33
|
+
/** All Runtime instances in one napi Env share one unforgeable Owner::Node. */
|
|
34
|
+
export declare class Runtime {
|
|
35
|
+
constructor()
|
|
36
|
+
/** Nonblocking release for explicit disposal and JS finalization. */
|
|
37
|
+
dropHandle(id: string): WireResult<undefined>
|
|
38
|
+
manifestJson(): WireResult<string>
|
|
39
|
+
manifestDigest(): string
|
|
40
|
+
call(id: string, op: string, paramsJson: string, abort?: Abort | undefined | null): Promise<string>
|
|
41
|
+
/** Copy the caller's buffer on the JS thread before returning the Promise. */
|
|
42
|
+
operationPush(id: string, data: Uint8Array): Promise<void>
|
|
43
|
+
stream(id: string, op: string, paramsJson: string, abort?: Abort | undefined | null): Promise<FrameIterator>
|
|
495
44
|
}
|
|
496
|
-
|
|
497
|
-
/** 刷盘全局 recorder(阻塞至 JSONL 落盘;ring 模式为 no-op)。 */
|
|
498
|
-
export declare function recordingFlush(): void
|
|
499
|
-
|
|
500
|
-
/** 停止录制:全局 recorder = None(新调用不再录制)。 */
|
|
501
|
-
export declare function recordingStop(): void
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* Flush the global recorder and **report write failures**: throws
|
|
505
|
-
* `RecordingError` (`code` = `WriterGone` / `FlushTimeout` / `Write`) when the
|
|
506
|
-
* data could not be confirmed on disk. `RecordingError` is its own class,
|
|
507
|
-
* not an `AimuxError`. Resolves normally when nothing is recording. The
|
|
508
|
-
* legacy `recordingFlush` stays and never reports.
|
|
509
|
-
*/
|
|
510
|
-
export declare function recordingTryFlush(): AimuxResult<undefined>
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Register external OpenAI-compatible providers from a JSON config string
|
|
514
|
-
* (RFC-0020). Entries override same-named built-ins or add new ones.
|
|
515
|
-
*
|
|
516
|
-
* `configJson` shape: `{ "providers": [ { "name": "...", "base_url": "...", ... } ] }`.
|
|
517
|
-
* Malformed JSON text throws a plain `Error` (napi `InvalidArg`); a
|
|
518
|
-
* well-formed document the registry rejects (bad base_url scheme, empty
|
|
519
|
-
* name, unsupported protocol, wrong shape) throws `InvalidArgumentError`.
|
|
520
|
-
*/
|
|
521
|
-
export declare function registerProviders(configJson: string): AimuxResult<undefined>
|
|
522
|
-
|
|
523
|
-
export declare function router(models: Array<Model>, configJson?: string | undefined | null): AimuxResult<Model>
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Query: all calls of a session (RFC-0024), as a JSON-serialized
|
|
527
|
-
* `SessionCall[]` (ordered by step). Empty array if the session is unknown
|
|
528
|
-
* or no store is registered.
|
|
529
|
-
*/
|
|
530
|
-
export declare function sessionCalls(sessionId: string): AimuxResult<string>
|
|
531
|
-
|
|
532
|
-
/**
|
|
533
|
-
* Start a streaming transcription session. `opts_json` (optional):
|
|
534
|
-
* `{ "input_audio_format": {"format_type","rate"}, "provider_options",
|
|
535
|
-
* "headers", "include_raw_chunks" }`. `bridge` — optional AbortSignal; firing
|
|
536
|
-
* it aborts the session. The returned parts are JSON-serialized
|
|
537
|
-
* `TranscriptionStreamPart`s.
|
|
538
|
-
*/
|
|
539
|
-
export declare function startTranscriptionSession(model: TranscriptionModel, optsJson?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<AimuxResult<TranscriptionSession>>
|
|
540
|
-
|
|
541
|
-
/** Create a Tavily search model instance. */
|
|
542
|
-
export declare function tavilySearch(apiKey: string, baseUrl?: string | undefined | null): Promise<AimuxResult<SearchModel>>
|
|
543
|
-
|
|
544
|
-
/**
|
|
545
|
-
* Build the repair argument for one invalid tool call.
|
|
546
|
-
*
|
|
547
|
-
* `toolCallJson` is a `GenerateTextResult.tool_calls` entry with
|
|
548
|
-
* `invalid: true`. `prompt` and `optsJson` are **the same two strings the
|
|
549
|
-
* call was generated with** (`generateText` / `streamText`); messages,
|
|
550
|
-
* instructions, and the tool set are derived from them here, so no caller
|
|
551
|
-
* repeats that derivation.
|
|
552
|
-
*
|
|
553
|
-
* Returns `{tool_call, error, input_schema, tools, messages, instructions}`
|
|
554
|
-
* — the AI SDK `repairToolCall` argument, with `tool_call.input` the
|
|
555
|
-
* provider's raw argument text — or the JSON literal `"null"` when the
|
|
556
|
-
* options carried no tools: as in the AI SDK, a call made without a tool set
|
|
557
|
-
* is never repaired, and the caller skips it. `"null"` is a success.
|
|
558
|
-
*
|
|
559
|
-
* Pure and synchronous: no model, no network. Throws `InvalidArgumentError`
|
|
560
|
-
* when the call is not an invalid one.
|
|
561
|
-
*/
|
|
562
|
-
export declare function toolCallRepairContext(toolCallJson: string, prompt: string, optsJson?: string | undefined | null): AimuxResult<string>
|
|
563
|
-
|
|
564
|
-
/** Create a Vertex AI language model instance (GCP bearer token). */
|
|
565
|
-
export declare function vertex(accessToken: string, project: string, location: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
566
|
-
|
|
567
|
-
/** Create an xAI language model instance. */
|
|
568
|
-
export declare function xai(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|