@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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ReasoningMode } from "./ReasoningMode";
|
|
2
|
+
import type { ReasoningVisibility } from "./ReasoningVisibility";
|
|
3
|
+
/**
|
|
4
|
+
* Reasoning / thinking portrait for a model (advisory).
|
|
5
|
+
*/
|
|
6
|
+
export type ReasoningSpec = {
|
|
7
|
+
/**
|
|
8
|
+
* Whether the model family supports reasoning at all.
|
|
9
|
+
*/
|
|
10
|
+
supported: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Whether reasoning should be on by default.
|
|
13
|
+
*/
|
|
14
|
+
default_enabled: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Primary control mode.
|
|
17
|
+
*/
|
|
18
|
+
mode: ReasoningMode | null;
|
|
19
|
+
/**
|
|
20
|
+
* Default effort level (when `mode` is Effort/Mixed).
|
|
21
|
+
*/
|
|
22
|
+
effort_default?: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Supported effort levels.
|
|
25
|
+
*/
|
|
26
|
+
effort_options?: Array<string>;
|
|
27
|
+
/**
|
|
28
|
+
* Minimum token budget (when `mode` is Budget/Mixed).
|
|
29
|
+
*/
|
|
30
|
+
budget_min?: number | null;
|
|
31
|
+
/**
|
|
32
|
+
* Interleaved reasoning (thinking blocks between tool calls).
|
|
33
|
+
*/
|
|
34
|
+
interleaved: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Output visibility.
|
|
37
|
+
*/
|
|
38
|
+
visibility: ReasoningVisibility | null;
|
|
39
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { HttpExchange } from "./HttpExchange";
|
|
2
|
+
import type { InputRecord } from "./InputRecord";
|
|
3
|
+
import type { OutcomeRecord } from "./OutcomeRecord";
|
|
4
|
+
import type { ProviderRecord } from "./ProviderRecord";
|
|
5
|
+
/**
|
|
6
|
+
* 一次完整调用的录制记录(三层 + call_id 关联)。
|
|
7
|
+
*/
|
|
8
|
+
export type Recording = {
|
|
9
|
+
/**
|
|
10
|
+
* 格式版本。
|
|
11
|
+
*/
|
|
12
|
+
schema: number;
|
|
13
|
+
/**
|
|
14
|
+
* 暴露逻辑调用 ID,关联三层。
|
|
15
|
+
*/
|
|
16
|
+
call_id: string;
|
|
17
|
+
/**
|
|
18
|
+
* ISO 8601 时间戳。
|
|
19
|
+
*/
|
|
20
|
+
recorded_at: string;
|
|
21
|
+
/**
|
|
22
|
+
* ① 输入侧:调用参数(prompt + options)。
|
|
23
|
+
*/
|
|
24
|
+
input: InputRecord;
|
|
25
|
+
/**
|
|
26
|
+
* ② 配置侧:provider 身份与配置。
|
|
27
|
+
*/
|
|
28
|
+
provider: ProviderRecord;
|
|
29
|
+
/**
|
|
30
|
+
* ③ HTTP 侧:实际 wire 交换(per-attempt 一条)。
|
|
31
|
+
*/
|
|
32
|
+
exchanges: Array<HttpExchange>;
|
|
33
|
+
/**
|
|
34
|
+
* 最终结果摘要(状态 + finish_reason + usage)。
|
|
35
|
+
*/
|
|
36
|
+
outcome: OutcomeRecord;
|
|
37
|
+
/**
|
|
38
|
+
* wire 是否完整(流式 body 未补全时为 false;由 writer 标记)。
|
|
39
|
+
*/
|
|
40
|
+
complete: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* 传输层封闭信号:层 B 声明"不再有 exchange"(P1:层 A 收尾自动发;
|
|
43
|
+
* P2:由层 B 发送)。false = 仍可能来 exchange(记录暂不可定稿)。
|
|
44
|
+
*/
|
|
45
|
+
transport_closed: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* 会话归组(RFC-0024 P3):所在会话 id。None = 未归组(无 session_id 且
|
|
48
|
+
* 推断关闭)。由 `Recorder::record_session` 填充,写入 InputRecord 之前
|
|
49
|
+
* 或之后均可(writer 端按 call_id 合并)。
|
|
50
|
+
*/
|
|
51
|
+
session_id?: string | null;
|
|
52
|
+
/**
|
|
53
|
+
* 会话内步号(0 起,由 SessionStore 分配)。与 `session_id` 同生命周期。
|
|
54
|
+
*/
|
|
55
|
+
step?: number | null;
|
|
56
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model entry returned by a provider's `/models` endpoint (the sparse,
|
|
3
|
+
* account-level truth of "what this key can call").
|
|
4
|
+
*
|
|
5
|
+
* Carries only what the provider returns — typically just `id`. Configuration
|
|
6
|
+
* comes from [`ModelSpec`] (community knowledge); the host merges the two as
|
|
7
|
+
* needed (RFC-0027). aimux itself does not combine them.
|
|
8
|
+
*/
|
|
9
|
+
export type RuntimeModel = {
|
|
10
|
+
/**
|
|
11
|
+
* Model identifier, e.g. `"gpt-4o"`.
|
|
12
|
+
*/
|
|
13
|
+
id: string;
|
|
14
|
+
/**
|
|
15
|
+
* `owned_by` field from OpenAI-compatible `/models` responses.
|
|
16
|
+
*/
|
|
17
|
+
owned_by?: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* `created` unix timestamp from OpenAI-compatible `/models` responses.
|
|
20
|
+
*/
|
|
21
|
+
created?: number | null;
|
|
22
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single call within a session (an index entry only — call content lives
|
|
3
|
+
* in Recording (RFC-0023) / TraceRecord (RFC-0015)).
|
|
4
|
+
*/
|
|
5
|
+
export type SessionCall = {
|
|
6
|
+
/**
|
|
7
|
+
* Call-level unique id. This is the association key for the future
|
|
8
|
+
* Recording / TraceRecord `call_id` (RFC-0015/0023): once those land,
|
|
9
|
+
* this field carries their value.
|
|
10
|
+
*/
|
|
11
|
+
call_id: string;
|
|
12
|
+
/**
|
|
13
|
+
* Step within the session (0-based).
|
|
14
|
+
*/
|
|
15
|
+
step: number;
|
|
16
|
+
/**
|
|
17
|
+
* When the call was recorded (RFC 3339 UTC, millisecond precision).
|
|
18
|
+
*/
|
|
19
|
+
recorded_at: string;
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PrefixBreak } from "./PrefixBreak";
|
|
2
|
+
/**
|
|
3
|
+
* Session chain view (append-only order + prefix stability, RFC-0015 §5.3).
|
|
4
|
+
*/
|
|
5
|
+
export type SessionChainView = {
|
|
6
|
+
session_id: string;
|
|
7
|
+
record_ids: Array<string>;
|
|
8
|
+
prefix_stability: number;
|
|
9
|
+
breaks: Array<PrefixBreak>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Verdict } from "./Verdict";
|
|
2
|
+
/**
|
|
3
|
+
* One step of a session's cache-hit trajectory (RFC-0024 §4.3).
|
|
4
|
+
*/
|
|
5
|
+
export type SessionStepStat = {
|
|
6
|
+
/**
|
|
7
|
+
* Step within the session (0-based, session order).
|
|
8
|
+
*/
|
|
9
|
+
step: number;
|
|
10
|
+
/**
|
|
11
|
+
* The call's id (association key into Recording / replay, RFC-0023).
|
|
12
|
+
*/
|
|
13
|
+
call_id: string;
|
|
14
|
+
/**
|
|
15
|
+
* Reported hit rate for this step (`cache_read / input_total`); `None`
|
|
16
|
+
* when the call carried no input/cache-read usage.
|
|
17
|
+
*/
|
|
18
|
+
hit_rate?: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Audit verdict (present only when an auditor is attached).
|
|
21
|
+
*/
|
|
22
|
+
verdict?: Verdict | null;
|
|
23
|
+
/**
|
|
24
|
+
* Error string for failed calls (failures are part of the session).
|
|
25
|
+
*/
|
|
26
|
+
error?: string | null;
|
|
27
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SessionCall } from "./SessionCall";
|
|
2
|
+
import type { SessionSource } from "./SessionSource";
|
|
3
|
+
/**
|
|
4
|
+
* Aggregated view of one session (session_id → ordered calls).
|
|
5
|
+
*/
|
|
6
|
+
export type SessionView = {
|
|
7
|
+
session_id: string;
|
|
8
|
+
/**
|
|
9
|
+
* Where the session id came from (first call's source).
|
|
10
|
+
*/
|
|
11
|
+
source: SessionSource;
|
|
12
|
+
/**
|
|
13
|
+
* Ordered calls (by step).
|
|
14
|
+
*/
|
|
15
|
+
calls: Array<SessionCall>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { FilePart } from "./FilePart";
|
|
2
|
+
import type { FinishReason } from "./FinishReason";
|
|
3
|
+
import type { ModelMessage } from "./ModelMessage";
|
|
4
|
+
import type { ReasoningPart } from "./ReasoningPart";
|
|
5
|
+
import type { ResponseMetadata } from "./ResponseMetadata";
|
|
6
|
+
import type { SourcePart } from "./SourcePart";
|
|
7
|
+
import type { ToolCall } from "./ToolCall";
|
|
8
|
+
import type { Usage } from "./Usage";
|
|
9
|
+
import type { Warning } from "./Warning";
|
|
10
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
11
|
+
/**
|
|
12
|
+
* Aggregated result of `stream_text().consume()` (M11). Mirrors
|
|
13
|
+
* `GenerateTextResult`'s user-facing fields (without `raw`, since streaming
|
|
14
|
+
* has no `GenerateResult` equivalent).
|
|
15
|
+
*/
|
|
16
|
+
export type StreamTextResultAggregated = {
|
|
17
|
+
/**
|
|
18
|
+
* The generated text (concatenated `TextDelta`).
|
|
19
|
+
*/
|
|
20
|
+
text: string;
|
|
21
|
+
/**
|
|
22
|
+
* Reasoning / thinking segments.
|
|
23
|
+
*/
|
|
24
|
+
reasoning: Array<ReasoningPart>;
|
|
25
|
+
/**
|
|
26
|
+
* Concatenated reasoning text.
|
|
27
|
+
*/
|
|
28
|
+
reasoning_text: string;
|
|
29
|
+
/**
|
|
30
|
+
* Tool calls requested by the model.
|
|
31
|
+
*/
|
|
32
|
+
tool_calls: Array<ToolCall>;
|
|
33
|
+
/**
|
|
34
|
+
* Sources / citations.
|
|
35
|
+
*/
|
|
36
|
+
sources: Array<SourcePart>;
|
|
37
|
+
/**
|
|
38
|
+
* Files generated by the model.
|
|
39
|
+
*/
|
|
40
|
+
files: Array<FilePart>;
|
|
41
|
+
/**
|
|
42
|
+
* Why generation stopped.
|
|
43
|
+
*/
|
|
44
|
+
finish_reason: FinishReason;
|
|
45
|
+
/**
|
|
46
|
+
* Raw provider-specific finish reason string.
|
|
47
|
+
*/
|
|
48
|
+
raw_finish_reason: string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Token usage.
|
|
51
|
+
*/
|
|
52
|
+
usage: Usage;
|
|
53
|
+
/**
|
|
54
|
+
* Total token usage across all steps. In single-step mode (aimux's
|
|
55
|
+
* default), `total_usage` equals `usage`. Provided for AI SDK parity.
|
|
56
|
+
*/
|
|
57
|
+
total_usage: Usage;
|
|
58
|
+
/**
|
|
59
|
+
* Warnings from the provider.
|
|
60
|
+
*/
|
|
61
|
+
warnings: Array<Warning>;
|
|
62
|
+
/**
|
|
63
|
+
* Provider-specific metadata from the Finish chunk.
|
|
64
|
+
*/
|
|
65
|
+
provider_metadata: JsonValue | null;
|
|
66
|
+
/**
|
|
67
|
+
* Response metadata (id, timestamp, model_id) if emitted by the stream.
|
|
68
|
+
*/
|
|
69
|
+
response: ResponseMetadata | null;
|
|
70
|
+
/**
|
|
71
|
+
* Assistant messages ready to append for the next turn.
|
|
72
|
+
*/
|
|
73
|
+
response_messages: Array<ModelMessage>;
|
|
74
|
+
};
|
|
@@ -7,7 +7,17 @@
|
|
|
7
7
|
* whole streamed response.
|
|
8
8
|
*/
|
|
9
9
|
export type TimeoutConfiguration = {
|
|
10
|
+
/**
|
|
11
|
+
* Overall timeout for the entire call (including retries and, for
|
|
12
|
+
* streaming, the whole stream), in milliseconds.
|
|
13
|
+
*/
|
|
10
14
|
total_ms: number | null;
|
|
15
|
+
/**
|
|
16
|
+
* Timeout waiting for the first stream chunk (streaming only).
|
|
17
|
+
*/
|
|
11
18
|
first_chunk_ms: number | null;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum idle time between consecutive stream chunks (streaming only).
|
|
21
|
+
*/
|
|
12
22
|
chunk_ms: number | null;
|
|
13
23
|
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Fingerprint } from "./Fingerprint";
|
|
2
|
+
import type { RequestCacheHints } from "./RequestCacheHints";
|
|
3
|
+
import type { UsageSnapshot } from "./UsageSnapshot";
|
|
4
|
+
import type { Verdict } from "./Verdict";
|
|
5
|
+
/**
|
|
6
|
+
* One probed call. Plaintext never persists — fingerprints only.
|
|
7
|
+
*/
|
|
8
|
+
export type TraceRecord = {
|
|
9
|
+
provider: string;
|
|
10
|
+
model: string;
|
|
11
|
+
request_id: string | null;
|
|
12
|
+
/**
|
|
13
|
+
* From `CallOptions.session_id` (RFC-0024) — explicit first, inference
|
|
14
|
+
* fallback; may also be the layer's default session.
|
|
15
|
+
*/
|
|
16
|
+
session_id: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Call-level unique id (association key for Recording / replay,
|
|
19
|
+
* RFC-0023).
|
|
20
|
+
*/
|
|
21
|
+
call_id: string;
|
|
22
|
+
/**
|
|
23
|
+
* When the call was sent (epoch ms).
|
|
24
|
+
*/
|
|
25
|
+
sent_at_unix_ms: number;
|
|
26
|
+
/**
|
|
27
|
+
* Client-side LCP token upper bound (block upper bound, byte-proxy
|
|
28
|
+
* len/4). `None` when no history matched. Consumed by `TraceStats`
|
|
29
|
+
* aggregation.
|
|
30
|
+
*/
|
|
31
|
+
lcp_token_upper?: bigint | null;
|
|
32
|
+
/**
|
|
33
|
+
* Time to first streamed token (ms). Non-streaming: `None`.
|
|
34
|
+
*/
|
|
35
|
+
ttft_ms: number | null;
|
|
36
|
+
fingerprint: Fingerprint;
|
|
37
|
+
usage: UsageSnapshot;
|
|
38
|
+
/**
|
|
39
|
+
* Response-side cache headers (e.g. `x-openrouter-cache-status`).
|
|
40
|
+
*/
|
|
41
|
+
response_cache_headers?: {
|
|
42
|
+
[key in string]: string;
|
|
43
|
+
} | null;
|
|
44
|
+
request_cache_hints?: RequestCacheHints | null;
|
|
45
|
+
/**
|
|
46
|
+
* Audit verdict (`None` when no auditor is attached — the default).
|
|
47
|
+
*/
|
|
48
|
+
verdict?: Verdict | null;
|
|
49
|
+
/**
|
|
50
|
+
* Error string when the call failed (still recorded: failures are part
|
|
51
|
+
* of the session).
|
|
52
|
+
*/
|
|
53
|
+
error?: string | null;
|
|
54
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aggregated statistics (RFC-0015 §5.2 — the two hit rates are reported
|
|
3
|
+
* side by side, never merged into a single number).
|
|
4
|
+
*/
|
|
5
|
+
export type TraceStats = {
|
|
6
|
+
provider: string;
|
|
7
|
+
model: string;
|
|
8
|
+
requests: bigint;
|
|
9
|
+
input_tokens_total: bigint;
|
|
10
|
+
claimed_cache_read_total: bigint;
|
|
11
|
+
claimed_cache_write_total: bigint;
|
|
12
|
+
reported_hit_rate: number | null;
|
|
13
|
+
client_upper_bound_hit_rate: number | null;
|
|
14
|
+
verdict_counts: {
|
|
15
|
+
[key in string]: bigint;
|
|
16
|
+
};
|
|
17
|
+
ttft_p50_ms: bigint | null;
|
|
18
|
+
ttft_p95_ms: bigint | null;
|
|
19
|
+
errors: bigint;
|
|
20
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AudioInput } from "./AudioInput";
|
|
2
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
|
+
/**
|
|
4
|
+
* Options passed to [`TranscriptionModel::do_generate`].
|
|
5
|
+
*
|
|
6
|
+
* Aligned with V4 `TranscriptionModelV4CallOptions`.
|
|
7
|
+
*/
|
|
8
|
+
export type TranscriptionCallOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* Audio data to transcribe (raw bytes or a base64-encoded string).
|
|
11
|
+
*/
|
|
12
|
+
audio: AudioInput;
|
|
13
|
+
/**
|
|
14
|
+
* The IANA media type of the audio data, e.g. `"audio/mp3"`.
|
|
15
|
+
*/
|
|
16
|
+
media_type: string;
|
|
17
|
+
/**
|
|
18
|
+
* Additional provider-specific options, keyed by provider name.
|
|
19
|
+
*/
|
|
20
|
+
provider_options: {
|
|
21
|
+
[key in string]: JsonValue;
|
|
22
|
+
} | null;
|
|
23
|
+
/**
|
|
24
|
+
* Additional HTTP headers to send with the request.
|
|
25
|
+
*/
|
|
26
|
+
headers: {
|
|
27
|
+
[key in string]: string;
|
|
28
|
+
} | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Response information for a transcription call.
|
|
4
|
+
*/
|
|
5
|
+
export type TranscriptionResponse = {
|
|
6
|
+
/**
|
|
7
|
+
* Timestamp for the start of the generated response (ISO 8601 string).
|
|
8
|
+
*/
|
|
9
|
+
timestamp: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The ID of the model that was used to generate the response.
|
|
12
|
+
*/
|
|
13
|
+
model_id: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Response headers.
|
|
16
|
+
*/
|
|
17
|
+
headers: {
|
|
18
|
+
[key in string]: string;
|
|
19
|
+
} | null;
|
|
20
|
+
/**
|
|
21
|
+
* Response body (opaque JSON).
|
|
22
|
+
*/
|
|
23
|
+
body: JsonValue | null;
|
|
24
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TranscriptionRequest } from "./TranscriptionRequest";
|
|
2
|
+
import type { TranscriptionResponse } from "./TranscriptionResponse";
|
|
3
|
+
import type { TranscriptionSegment } from "./TranscriptionSegment";
|
|
4
|
+
import type { Warning } from "./Warning";
|
|
5
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
6
|
+
/**
|
|
7
|
+
* The result of [`TranscriptionModel::do_generate`].
|
|
8
|
+
*
|
|
9
|
+
* Aligned with V4 `TranscriptionModelV4Result`.
|
|
10
|
+
*/
|
|
11
|
+
export type TranscriptionResult = {
|
|
12
|
+
/**
|
|
13
|
+
* The complete transcribed text from the audio.
|
|
14
|
+
*/
|
|
15
|
+
text: string;
|
|
16
|
+
/**
|
|
17
|
+
* Transcript segments with timing information.
|
|
18
|
+
*/
|
|
19
|
+
segments: Array<TranscriptionSegment>;
|
|
20
|
+
/**
|
|
21
|
+
* The detected language (ISO 639-1 code, e.g. `"en"`), if detected.
|
|
22
|
+
*/
|
|
23
|
+
language: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* The total duration of the audio in seconds, if determined.
|
|
26
|
+
*/
|
|
27
|
+
duration_in_seconds: number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
30
|
+
*/
|
|
31
|
+
warnings: Array<Warning>;
|
|
32
|
+
/**
|
|
33
|
+
* Optional request information for telemetry and debugging.
|
|
34
|
+
*/
|
|
35
|
+
request: TranscriptionRequest | null;
|
|
36
|
+
/**
|
|
37
|
+
* Response information for telemetry and debugging.
|
|
38
|
+
*/
|
|
39
|
+
response: TranscriptionResponse;
|
|
40
|
+
/**
|
|
41
|
+
* Additional provider-specific metadata, keyed by provider name.
|
|
42
|
+
*/
|
|
43
|
+
provider_metadata: {
|
|
44
|
+
[key in string]: JsonValue;
|
|
45
|
+
} | null;
|
|
46
|
+
};
|