@arcships/aimux 0.2.1 → 0.5.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 +139 -0
- package/dist/error.js +114 -0
- package/dist/index.d.ts +162 -8
- package/dist/index.js +334 -28
- package/dist/native.d.ts +2 -0
- package/dist/native.js +46 -0
- package/dist/types/AiMuxError.d.ts +45 -13
- package/dist/types/AiMuxError.js +0 -1
- package/dist/types/ApiCallError.d.ts +75 -0
- package/dist/types/ApiCallError.js +2 -0
- package/dist/types/BreakKind.d.ts +1 -0
- package/dist/types/BreakKind.js +3 -0
- package/dist/types/CallOptions.d.ts +28 -2
- 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/ContentPart.d.ts +6 -0
- package/dist/types/EmbeddingCallOptions.d.ts +9 -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/GenerateContent.d.ts +12 -1
- 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 +34 -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 +10 -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 +19 -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/RawToolCall.d.ts +16 -0
- package/dist/types/RawToolCall.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/RerankingCallOptions.d.ts +9 -0
- package/dist/types/ResponseRecord.d.ts +13 -0
- package/dist/types/ResponseRecord.js +3 -0
- package/dist/types/RetryError.d.ts +9 -0
- package/dist/types/RetryError.js +2 -0
- package/dist/types/RetryErrorReason.d.ts +4 -0
- package/dist/types/RetryErrorReason.js +3 -0
- package/dist/types/RuntimeModel.d.ts +22 -0
- package/dist/types/RuntimeModel.js +3 -0
- package/dist/types/SearchCallOptions.d.ts +9 -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/SpeechCallOptions.d.ts +9 -0
- package/dist/types/StreamPart.d.ts +12 -0
- package/dist/types/StreamTextResultAggregated.d.ts +74 -0
- package/dist/types/StreamTextResultAggregated.js +2 -0
- package/dist/types/TimeoutConfiguration.d.ts +19 -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/ToolCall.d.ts +16 -1
- package/dist/types/ToolCallRepairReply.d.ts +19 -0
- package/dist/types/ToolCallRepairReply.js +2 -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 +38 -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 +17 -2
- package/dist/types/VideoPollOptions.d.ts +13 -0
- package/dist/types/VideoPollOptions.js +3 -0
- package/dist/types/VideoResult.d.ts +1 -1
- package/dist/types.d.ts +71 -1
- package/dist/types.js +3 -3
- package/index.d.ts +332 -25
- package/index.js +77 -54
- package/package.json +13 -12
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { LanguageModelPromptMessage } from "./LanguageModelPromptMessage";
|
|
2
2
|
import type { ReasoningEffort } from "./ReasoningEffort";
|
|
3
3
|
import type { ResponseFormat } from "./ResponseFormat";
|
|
4
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
4
5
|
import type { Tool } from "./Tool";
|
|
5
6
|
import type { ToolChoice } from "./ToolChoice";
|
|
6
7
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
@@ -51,7 +52,7 @@ export type CallOptions = {
|
|
|
51
52
|
/**
|
|
52
53
|
* Seed for reproducibility.
|
|
53
54
|
*/
|
|
54
|
-
seed:
|
|
55
|
+
seed: number | null;
|
|
55
56
|
/**
|
|
56
57
|
* Tools available to the model (function tools and/or provider-defined tools).
|
|
57
58
|
*/
|
|
@@ -85,7 +86,32 @@ export type CallOptions = {
|
|
|
85
86
|
body_overrides: JsonValue | null;
|
|
86
87
|
/**
|
|
87
88
|
* Per-call retry count override. `None` uses the provider's configured
|
|
88
|
-
*
|
|
89
|
+
* Core operation retry. `Some(0)` disables retries.
|
|
89
90
|
*/
|
|
90
91
|
max_retries: number | null;
|
|
92
|
+
/**
|
|
93
|
+
* Per-call timeout configuration (total / first-chunk / chunk idle).
|
|
94
|
+
* `None` = no timeouts (provider defaults still apply at the HTTP layer).
|
|
95
|
+
*/
|
|
96
|
+
timeout: TimeoutConfiguration | null;
|
|
97
|
+
/**
|
|
98
|
+
* Session identifier, for grouping consecutive calls into a session
|
|
99
|
+
* (observability, see RFC-0024). Explicit values take precedence; when
|
|
100
|
+
* `None` and the optional session inferer is enabled, one may be inferred.
|
|
101
|
+
* Orthogonal to RFC-0019 session-affinity headers: this field is for
|
|
102
|
+
* local grouping, while session headers in `headers` are for upstream
|
|
103
|
+
* routing — both may share an id value but travel different paths.
|
|
104
|
+
*/
|
|
105
|
+
session_id: string | null;
|
|
106
|
+
/**
|
|
107
|
+
* Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid).
|
|
108
|
+
* When `Some(true)`, streaming providers yield one `Raw` part per JSON
|
|
109
|
+
* SSE event, carrying the **parsed JSON payload** of the event, emitted
|
|
110
|
+
* before the parsed parts. Excludes the `[DONE]` sentinel; unparsable
|
|
111
|
+
* chunks emit only `Error`. `null`/`Some(false)` = off.
|
|
112
|
+
* Currently honored by the OpenAI-compatible family (openai / azure /
|
|
113
|
+
* openai-compatible registry providers); other provider families ignore
|
|
114
|
+
* it for now (RFC-0016 M2).
|
|
115
|
+
*/
|
|
116
|
+
include_raw_chunks: boolean | null;
|
|
91
117
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChatCompletionChoice } from "./ChatCompletionChoice";
|
|
2
|
+
import type { ChatCompletionUsage } from "./ChatCompletionUsage";
|
|
3
|
+
/**
|
|
4
|
+
* A complete Chat Completion response (non-streaming).
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the OpenAI `chat.completion` object.
|
|
7
|
+
*/
|
|
8
|
+
export type ChatCompletion = {
|
|
9
|
+
id: string;
|
|
10
|
+
object: string;
|
|
11
|
+
created: bigint;
|
|
12
|
+
model: string;
|
|
13
|
+
choices: Array<ChatCompletionChoice>;
|
|
14
|
+
usage: ChatCompletionUsage;
|
|
15
|
+
system_fingerprint: string | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChatCompletionMessage } from "./ChatCompletionMessage";
|
|
2
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
|
+
export type ChatCompletionChoice = {
|
|
4
|
+
index: number;
|
|
5
|
+
message: ChatCompletionMessage;
|
|
6
|
+
finish_reason: string | null;
|
|
7
|
+
logprobs: JsonValue | null;
|
|
8
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChatCompletionChunkChoice } from "./ChatCompletionChunkChoice";
|
|
2
|
+
import type { ChatCompletionUsage } from "./ChatCompletionUsage";
|
|
3
|
+
/**
|
|
4
|
+
* A single Chat Completion chunk (streaming).
|
|
5
|
+
*
|
|
6
|
+
* Mirrors the OpenAI `chat.completion.chunk` object.
|
|
7
|
+
*/
|
|
8
|
+
export type ChatCompletionChunk = {
|
|
9
|
+
id: string;
|
|
10
|
+
object: string;
|
|
11
|
+
created: bigint;
|
|
12
|
+
model: string;
|
|
13
|
+
choices: Array<ChatCompletionChunkChoice>;
|
|
14
|
+
usage: ChatCompletionUsage | null;
|
|
15
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChatCompletionDelta } from "./ChatCompletionDelta";
|
|
2
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
|
+
export type ChatCompletionChunkChoice = {
|
|
4
|
+
index: number;
|
|
5
|
+
delta: ChatCompletionDelta;
|
|
6
|
+
finish_reason: string | null;
|
|
7
|
+
logprobs: JsonValue | null;
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ChatCompletionToolCall } from "./ChatCompletionToolCall";
|
|
2
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
|
+
export type ChatCompletionMessage = {
|
|
4
|
+
role: string;
|
|
5
|
+
content: string | null;
|
|
6
|
+
reasoning_content: string | null;
|
|
7
|
+
tool_calls: Array<ChatCompletionToolCall> | null;
|
|
8
|
+
annotations: Array<JsonValue> | null;
|
|
9
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CompletionTokensDetails } from "./CompletionTokensDetails";
|
|
2
|
+
import type { PromptTokensDetails } from "./PromptTokensDetails";
|
|
3
|
+
export type ChatCompletionUsage = {
|
|
4
|
+
prompt_tokens: number;
|
|
5
|
+
completion_tokens: number;
|
|
6
|
+
total_tokens: number;
|
|
7
|
+
prompt_tokens_details: PromptTokensDetails | null;
|
|
8
|
+
completion_tokens_details: CompletionTokensDetails | null;
|
|
9
|
+
};
|
|
@@ -57,6 +57,12 @@ export type ContentPart = {
|
|
|
57
57
|
* Arguments as a JSON value (usually an object).
|
|
58
58
|
*/
|
|
59
59
|
input: JsonValue;
|
|
60
|
+
/**
|
|
61
|
+
* Whether the tool call is executed by the provider rather than by
|
|
62
|
+
* the client. This is part of the prompt contract because providers
|
|
63
|
+
* need it to replay server tool calls on a later turn.
|
|
64
|
+
*/
|
|
65
|
+
provider_executed?: boolean | null;
|
|
60
66
|
/**
|
|
61
67
|
* Provider-assigned thought signature (e.g. Google Gemini
|
|
62
68
|
* `thoughtSignature`). Must be echoed back verbatim on the follow-up
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
1
2
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
3
|
/**
|
|
3
4
|
* Options passed to [`EmbeddingModel::do_embed`].
|
|
@@ -9,6 +10,14 @@ export type EmbeddingCallOptions = {
|
|
|
9
10
|
* List of text values to generate embeddings for.
|
|
10
11
|
*/
|
|
11
12
|
values: Array<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Per-call retry override. `None` uses the model default.
|
|
15
|
+
*/
|
|
16
|
+
max_retries: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Per-call operation timeout.
|
|
19
|
+
*/
|
|
20
|
+
timeout: TimeoutConfiguration | null;
|
|
12
21
|
/**
|
|
13
22
|
* Additional provider-specific options, keyed by provider name.
|
|
14
23
|
*/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialized-wire fingerprint stored in a `TraceRecord` (hex strings —
|
|
3
|
+
* `u128` is not JSON-serializable).
|
|
4
|
+
*/
|
|
5
|
+
export type Fingerprint = {
|
|
6
|
+
/**
|
|
7
|
+
* 128-bit hash of the whole denoised body (hex).
|
|
8
|
+
*/
|
|
9
|
+
body_hash: string;
|
|
10
|
+
len_bytes: bigint;
|
|
11
|
+
block_size: bigint;
|
|
12
|
+
/**
|
|
13
|
+
* Block-hash chain (hex), one entry per block.
|
|
14
|
+
*/
|
|
15
|
+
block_hashes: Array<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Token estimate — byte proxy `len_bytes / 4` when no tokenizer is
|
|
18
|
+
* attached (RFC-0015 §4.1: W capped at one block in this mode).
|
|
19
|
+
*/
|
|
20
|
+
token_estimate: bigint;
|
|
21
|
+
};
|
|
@@ -12,7 +12,18 @@ export type GenerateContent = {
|
|
|
12
12
|
"ToolCall": {
|
|
13
13
|
tool_call_id: string;
|
|
14
14
|
tool_name: string;
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The model's raw argument text, exactly as the provider delivered
|
|
17
|
+
* it (possibly malformed). Providers never parse it — `generate_text`
|
|
18
|
+
* owns parsing, schema validation, and repair.
|
|
19
|
+
*
|
|
20
|
+
* Always serializes as a JSON string. Deserializes a JSON string
|
|
21
|
+
* (the current wire shape) unchanged, and also re-serializes the
|
|
22
|
+
* pre-refactor shape — an already-parsed JSON value — to its compact
|
|
23
|
+
* JSON text, so a `GenerateResult` persisted before this field
|
|
24
|
+
* became a `String` keeps loading. See docs/api/gaps.md §9.
|
|
25
|
+
*/
|
|
26
|
+
input: string;
|
|
16
27
|
/**
|
|
17
28
|
* Whether the tool call will be executed by the provider.
|
|
18
29
|
* If false/unset, the tool call is executed by the client.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { FinishReason } from "./FinishReason";
|
|
2
|
+
import type { GenerateTextResult } from "./GenerateTextResult";
|
|
3
|
+
import type { ResponseMetadata } from "./ResponseMetadata";
|
|
4
|
+
import type { Usage } from "./Usage";
|
|
5
|
+
import type { Warning } from "./Warning";
|
|
6
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
7
|
+
/**
|
|
8
|
+
* Result of `generate_object` (user-facing, M12). The parsed JSON object plus
|
|
9
|
+
* convenience fields from the underlying `generate_text` call.
|
|
10
|
+
*/
|
|
11
|
+
export type GenerateObjectResult = {
|
|
12
|
+
/**
|
|
13
|
+
* The parsed JSON object returned by the model.
|
|
14
|
+
*/
|
|
15
|
+
object: JsonValue;
|
|
16
|
+
/**
|
|
17
|
+
* Why generation stopped.
|
|
18
|
+
*/
|
|
19
|
+
finish_reason: FinishReason;
|
|
20
|
+
/**
|
|
21
|
+
* Raw provider-specific finish reason string.
|
|
22
|
+
*/
|
|
23
|
+
raw_finish_reason: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Token usage.
|
|
26
|
+
*/
|
|
27
|
+
usage: Usage;
|
|
28
|
+
/**
|
|
29
|
+
* Warnings from the provider.
|
|
30
|
+
*/
|
|
31
|
+
warnings: Array<Warning>;
|
|
32
|
+
/**
|
|
33
|
+
* Concatenated reasoning text (if the model produced reasoning/thinking).
|
|
34
|
+
*/
|
|
35
|
+
reasoning: string | null;
|
|
36
|
+
/**
|
|
37
|
+
* Provider-specific metadata (e.g. Anthropic cache info).
|
|
38
|
+
*/
|
|
39
|
+
provider_metadata: JsonValue | null;
|
|
40
|
+
/**
|
|
41
|
+
* Response metadata (id, timestamp, model_id).
|
|
42
|
+
*/
|
|
43
|
+
response: ResponseMetadata;
|
|
44
|
+
/**
|
|
45
|
+
* The full `generate_text` result (for advanced use).
|
|
46
|
+
*/
|
|
47
|
+
raw: GenerateTextResult;
|
|
48
|
+
};
|
|
@@ -19,7 +19,7 @@ export type GenerateTextOptions = {
|
|
|
19
19
|
presence_penalty: number | null;
|
|
20
20
|
frequency_penalty: number | null;
|
|
21
21
|
response_format: ResponseFormat | null;
|
|
22
|
-
seed:
|
|
22
|
+
seed: number | null;
|
|
23
23
|
tools: Array<Tool> | null;
|
|
24
24
|
tool_choice: ToolChoice | null;
|
|
25
25
|
headers: {
|
|
@@ -48,4 +48,15 @@ export type GenerateTextOptions = {
|
|
|
48
48
|
* Per-call timeout configuration (total / first-chunk / chunk idle).
|
|
49
49
|
*/
|
|
50
50
|
timeout: TimeoutConfiguration | null;
|
|
51
|
+
/**
|
|
52
|
+
* Session identifier, for grouping consecutive calls into a session
|
|
53
|
+
* (observability, see RFC-0024). Orthogonal to RFC-0019 session-affinity
|
|
54
|
+
* headers. When `None` and the optional session inferer is enabled, one
|
|
55
|
+
* may be inferred from prompt-prefix continuation.
|
|
56
|
+
*/
|
|
57
|
+
session_id: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Emit raw provider stream chunks as `StreamPart::Raw` (debugging aid).
|
|
60
|
+
*/
|
|
61
|
+
include_raw_chunks: boolean | null;
|
|
51
62
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { FilePart } from "./FilePart";
|
|
1
2
|
import type { FinishReason } from "./FinishReason";
|
|
2
3
|
import type { GenerateResult } from "./GenerateResult";
|
|
4
|
+
import type { ModelMessage } from "./ModelMessage";
|
|
5
|
+
import type { ReasoningPart } from "./ReasoningPart";
|
|
6
|
+
import type { ResponseMetadata } from "./ResponseMetadata";
|
|
7
|
+
import type { SourcePart } from "./SourcePart";
|
|
3
8
|
import type { ToolCall } from "./ToolCall";
|
|
4
9
|
import type { Usage } from "./Usage";
|
|
5
10
|
import type { Warning } from "./Warning";
|
|
11
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
6
12
|
/**
|
|
7
13
|
* Result of `generate_text` (user-facing).
|
|
8
14
|
*/
|
|
@@ -31,4 +37,45 @@ export type GenerateTextResult = {
|
|
|
31
37
|
* Raw provider result (for advanced use).
|
|
32
38
|
*/
|
|
33
39
|
raw: GenerateResult;
|
|
40
|
+
/**
|
|
41
|
+
* Reasoning / thinking segments from the model.
|
|
42
|
+
*/
|
|
43
|
+
reasoning: Array<ReasoningPart>;
|
|
44
|
+
/**
|
|
45
|
+
* Concatenated reasoning text (convenience for `reasoning.iter().map(text).join("")`).
|
|
46
|
+
*/
|
|
47
|
+
reasoning_text: string;
|
|
48
|
+
/**
|
|
49
|
+
* Sources / citations (search-preview models).
|
|
50
|
+
*/
|
|
51
|
+
sources: Array<SourcePart>;
|
|
52
|
+
/**
|
|
53
|
+
* Files generated by the model.
|
|
54
|
+
*/
|
|
55
|
+
files: Array<FilePart>;
|
|
56
|
+
/**
|
|
57
|
+
* Assistant messages ready to append to the prompt for the next turn
|
|
58
|
+
* (solves the multi-turn "manually build assistant message" footgun).
|
|
59
|
+
*/
|
|
60
|
+
response_messages: Array<ModelMessage>;
|
|
61
|
+
/**
|
|
62
|
+
* The raw provider-specific finish reason string (e.g. "stop",
|
|
63
|
+
* "end_turn", "safety"). Useful when `finish_reason.unified` is `Other`.
|
|
64
|
+
*/
|
|
65
|
+
raw_finish_reason: string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Provider-specific metadata (e.g. Anthropic cache info). Mirrored from
|
|
68
|
+
* `raw.provider_metadata` for top-level convenience.
|
|
69
|
+
*/
|
|
70
|
+
provider_metadata: JsonValue | null;
|
|
71
|
+
/**
|
|
72
|
+
* Response metadata (id, timestamp, model_id). Mirrored from
|
|
73
|
+
* `raw.response` for top-level convenience.
|
|
74
|
+
*/
|
|
75
|
+
response: ResponseMetadata;
|
|
76
|
+
/**
|
|
77
|
+
* Total token usage across all steps. In single-step mode (aimux's
|
|
78
|
+
* default), `total_usage` equals `usage`. Provided for AI SDK parity.
|
|
79
|
+
*/
|
|
80
|
+
total_usage: Usage;
|
|
34
81
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HttpRecord } from "./HttpRecord";
|
|
2
|
+
import type { ResponseRecord } from "./ResponseRecord";
|
|
3
|
+
import type { TimingRecord } from "./TimingRecord";
|
|
4
|
+
/**
|
|
5
|
+
* ③ HTTP 侧:单次 attempt 的 wire 交换。
|
|
6
|
+
*/
|
|
7
|
+
export type HttpExchange = {
|
|
8
|
+
/**
|
|
9
|
+
* Composite step this exchange belongs to (e.g. `router[0]:openai/gpt-4o`
|
|
10
|
+
* or `moa.ref[1]:...`). `None` for a plain, non-composite operation.
|
|
11
|
+
*/
|
|
12
|
+
step?: string | null;
|
|
13
|
+
/**
|
|
14
|
+
* Core operation attempt, starting at 1. Attempt numbers are unique
|
|
15
|
+
* across the whole call, including composite child steps, so
|
|
16
|
+
* `(attempt, exchange_index)` alone still identifies an exchange.
|
|
17
|
+
*/
|
|
18
|
+
attempt: number;
|
|
19
|
+
/**
|
|
20
|
+
* HTTP exchange within the operation attempt, starting at 1.
|
|
21
|
+
*/
|
|
22
|
+
exchange_index: number;
|
|
23
|
+
request: HttpRecord;
|
|
24
|
+
/**
|
|
25
|
+
* None = 请求失败未获响应。
|
|
26
|
+
*/
|
|
27
|
+
response: ResponseRecord | null;
|
|
28
|
+
timing: TimingRecord;
|
|
29
|
+
error: string | null;
|
|
30
|
+
/**
|
|
31
|
+
* 流式:该 exchange 是否已终结(收到 response 补全)。非流式恒 true。
|
|
32
|
+
*/
|
|
33
|
+
finalized: boolean;
|
|
34
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type HttpRecord = {
|
|
2
|
+
method: string;
|
|
3
|
+
url: string;
|
|
4
|
+
/**
|
|
5
|
+
* 敏感头(authorization/cookie/含 api-key/key/x-amz-security-token 等)已脱敏为 "\[REDACTED\]"。
|
|
6
|
+
*/
|
|
7
|
+
headers: Array<[string, string]>;
|
|
8
|
+
/**
|
|
9
|
+
* 明文(脱敏后);None = 无 body。
|
|
10
|
+
*/
|
|
11
|
+
body: string | null;
|
|
12
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AspectRatio } from "./AspectRatio";
|
|
2
2
|
import type { ImageFile } from "./ImageFile";
|
|
3
3
|
import type { Size } from "./Size";
|
|
4
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
4
5
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
5
6
|
/**
|
|
6
7
|
* Options passed to [`ImageModel::do_generate`].
|
|
@@ -30,7 +31,7 @@ export type ImageCallOptions = {
|
|
|
30
31
|
/**
|
|
31
32
|
* Seed for deterministic generation. `None` uses the provider's default.
|
|
32
33
|
*/
|
|
33
|
-
seed:
|
|
34
|
+
seed: number | null;
|
|
34
35
|
/**
|
|
35
36
|
* Images for image editing or variation generation.
|
|
36
37
|
*/
|
|
@@ -45,6 +46,14 @@ export type ImageCallOptions = {
|
|
|
45
46
|
provider_options: {
|
|
46
47
|
[key in string]: JsonValue;
|
|
47
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* Per-call retry override. `None` uses the model default.
|
|
51
|
+
*/
|
|
52
|
+
max_retries: number | null;
|
|
53
|
+
/**
|
|
54
|
+
* Per-call operation timeout.
|
|
55
|
+
*/
|
|
56
|
+
timeout: TimeoutConfiguration | null;
|
|
48
57
|
/**
|
|
49
58
|
* Additional HTTP headers to send with the request.
|
|
50
59
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LanguageModelPromptMessage } from "./LanguageModelPromptMessage";
|
|
2
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
|
+
/**
|
|
4
|
+
* ① 输入侧:完整调用参数,足以重建 generate_text 调用。
|
|
5
|
+
*/
|
|
6
|
+
export type InputRecord = {
|
|
7
|
+
/**
|
|
8
|
+
* 完整 prompt(消息数组,含 ContentPart::Image 等多模态)。
|
|
9
|
+
*/
|
|
10
|
+
prompt: Array<LanguageModelPromptMessage>;
|
|
11
|
+
/**
|
|
12
|
+
* 序列化的 CallOptions(abort_signal/call_id 已 serde skip);
|
|
13
|
+
* headers/provider_options/body_overrides 已递归脱敏。
|
|
14
|
+
*/
|
|
15
|
+
options: JsonValue;
|
|
16
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-level capability flags (more precise than provider-level `supports_*`).
|
|
3
|
+
*/
|
|
4
|
+
export type ModelCapabilities = {
|
|
5
|
+
/**
|
|
6
|
+
* Supports function/tool calling.
|
|
7
|
+
*/
|
|
8
|
+
tool_call: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Supports structured / JSON-schema output.
|
|
11
|
+
*/
|
|
12
|
+
structured_output: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Accepts a `temperature` parameter.
|
|
15
|
+
*/
|
|
16
|
+
temperature: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Accepts multimodal attachments (image/audio/pdf input).
|
|
19
|
+
*/
|
|
20
|
+
attachment: boolean;
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pricing (advisory, read-only metadata). Units follow the source catalog
|
|
3
|
+
* (anya2a uses USD per 1M tokens).
|
|
4
|
+
*/
|
|
5
|
+
export type ModelCost = {
|
|
6
|
+
input?: number | null;
|
|
7
|
+
output?: number | null;
|
|
8
|
+
cache_read?: number | null;
|
|
9
|
+
cache_write?: number | null;
|
|
10
|
+
};
|