@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,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 [`SpeechModel::do_generate`].
|
|
@@ -38,6 +39,14 @@ export type SpeechCallOptions = {
|
|
|
38
39
|
provider_options: {
|
|
39
40
|
[key in string]: JsonValue;
|
|
40
41
|
} | null;
|
|
42
|
+
/**
|
|
43
|
+
* Per-call retry override. `None` uses the model default.
|
|
44
|
+
*/
|
|
45
|
+
max_retries: number | null;
|
|
46
|
+
/**
|
|
47
|
+
* Per-call operation timeout.
|
|
48
|
+
*/
|
|
49
|
+
timeout: TimeoutConfiguration | null;
|
|
41
50
|
/**
|
|
42
51
|
* Additional HTTP headers to send with the request.
|
|
43
52
|
*/
|
|
@@ -70,6 +70,10 @@ export type StreamPart = {
|
|
|
70
70
|
"ToolCall": {
|
|
71
71
|
tool_call_id: string;
|
|
72
72
|
tool_name: string;
|
|
73
|
+
/**
|
|
74
|
+
* Serialized argument text in a `Value::String` from `do_stream`;
|
|
75
|
+
* parsed input after `stream_text`.
|
|
76
|
+
*/
|
|
73
77
|
input: JsonValue;
|
|
74
78
|
/**
|
|
75
79
|
* Whether the tool call will be executed by the provider.
|
|
@@ -85,6 +89,14 @@ export type StreamPart = {
|
|
|
85
89
|
* turn when the tool result is sent.
|
|
86
90
|
*/
|
|
87
91
|
thought_signature?: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* Set by Core when the call remains invalid after optional repair.
|
|
94
|
+
*/
|
|
95
|
+
invalid?: boolean | null;
|
|
96
|
+
/**
|
|
97
|
+
* Typed lookup, parsing, schema, or repair failure.
|
|
98
|
+
*/
|
|
99
|
+
error?: AiMuxError | null;
|
|
88
100
|
provider_metadata?: JsonValue | null;
|
|
89
101
|
};
|
|
90
102
|
} | {
|
|
@@ -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,26 @@
|
|
|
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 for one generation step, including that step's attempts and
|
|
17
|
+
* retry backoff, in milliseconds. Aimux currently has one step.
|
|
18
|
+
*/
|
|
19
|
+
step_ms: number | null;
|
|
20
|
+
/**
|
|
21
|
+
* Timeout waiting for the first stream chunk (streaming only).
|
|
22
|
+
*
|
|
23
|
+
* Counted from operation start, so it also bounds stream establishment
|
|
24
|
+
* and any retries before the first semantic output: it is the
|
|
25
|
+
* user-perceived time-to-first-output budget, not a per-attempt timer.
|
|
26
|
+
*/
|
|
11
27
|
first_chunk_ms: number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Maximum idle time between consecutive stream chunks (streaming only).
|
|
30
|
+
*/
|
|
12
31
|
chunk_ms: number | null;
|
|
13
32
|
};
|
package/dist/types/ToolCall.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AiMuxError } from "./AiMuxError";
|
|
1
2
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
3
|
/**
|
|
3
4
|
* A tool call requested by the model.
|
|
@@ -12,7 +13,8 @@ export type ToolCall = {
|
|
|
12
13
|
*/
|
|
13
14
|
tool_name: string;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Parsed arguments, or the original string when `invalid` is true and the
|
|
17
|
+
* provider input was not valid JSON.
|
|
16
18
|
*/
|
|
17
19
|
input: JsonValue;
|
|
18
20
|
/**
|
|
@@ -30,4 +32,17 @@ export type ToolCall = {
|
|
|
30
32
|
* otherwise.
|
|
31
33
|
*/
|
|
32
34
|
thought_signature?: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Additional provider-specific metadata associated with this call.
|
|
37
|
+
*/
|
|
38
|
+
provider_metadata?: JsonValue | null;
|
|
39
|
+
/**
|
|
40
|
+
* Set when lookup, JSON parsing, or schema validation still failed after
|
|
41
|
+
* the optional repair attempt.
|
|
42
|
+
*/
|
|
43
|
+
invalid?: boolean | null;
|
|
44
|
+
/**
|
|
45
|
+
* Typed failure associated with an invalid tool call.
|
|
46
|
+
*/
|
|
47
|
+
error?: AiMuxError | null;
|
|
33
48
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { RawToolCall } from "./RawToolCall";
|
|
2
|
+
/**
|
|
3
|
+
* A host's answer to one tool-call repair request.
|
|
4
|
+
*
|
|
5
|
+
* The bindings cannot carry a [`ToolCallRepair`] closure, so a host instead
|
|
6
|
+
* reads the invalid call off the result, repairs it in its own language, and
|
|
7
|
+
* hands the answer back as this value. Wire shape:
|
|
8
|
+
* `{"type":"repaired","tool_call":{…}}`, `{"type":"unchanged"}`, or
|
|
9
|
+
* `{"type":"failed","message":"…"}`.
|
|
10
|
+
*/
|
|
11
|
+
export type ToolCallRepairReply = {
|
|
12
|
+
"type": "repaired";
|
|
13
|
+
tool_call: RawToolCall;
|
|
14
|
+
} | {
|
|
15
|
+
"type": "unchanged";
|
|
16
|
+
} | {
|
|
17
|
+
"type": "failed";
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
@@ -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,38 @@
|
|
|
1
|
+
import type { AudioInput } from "./AudioInput";
|
|
2
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
3
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
4
|
+
/**
|
|
5
|
+
* Options passed to [`TranscriptionModel::do_generate`].
|
|
6
|
+
*
|
|
7
|
+
* Aligned with V4 `TranscriptionModelV4CallOptions`.
|
|
8
|
+
*/
|
|
9
|
+
export type TranscriptionCallOptions = {
|
|
10
|
+
/**
|
|
11
|
+
* Audio data to transcribe (raw bytes or a base64-encoded string).
|
|
12
|
+
*/
|
|
13
|
+
audio: AudioInput;
|
|
14
|
+
/**
|
|
15
|
+
* The IANA media type of the audio data, e.g. `"audio/mp3"`.
|
|
16
|
+
*/
|
|
17
|
+
media_type: string;
|
|
18
|
+
/**
|
|
19
|
+
* Additional provider-specific options, keyed by provider name.
|
|
20
|
+
*/
|
|
21
|
+
provider_options: {
|
|
22
|
+
[key in string]: JsonValue;
|
|
23
|
+
} | null;
|
|
24
|
+
/**
|
|
25
|
+
* Per-call retry override. `None` uses the model default.
|
|
26
|
+
*/
|
|
27
|
+
max_retries: number | null;
|
|
28
|
+
/**
|
|
29
|
+
* Per-call operation timeout.
|
|
30
|
+
*/
|
|
31
|
+
timeout: TimeoutConfiguration | null;
|
|
32
|
+
/**
|
|
33
|
+
* Additional HTTP headers to send with the request.
|
|
34
|
+
*/
|
|
35
|
+
headers: {
|
|
36
|
+
[key in string]: string;
|
|
37
|
+
} | null;
|
|
38
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A transcript segment with timing information.
|
|
3
|
+
*/
|
|
4
|
+
export type TranscriptionSegment = {
|
|
5
|
+
/**
|
|
6
|
+
* The text content of this segment.
|
|
7
|
+
*/
|
|
8
|
+
text: string;
|
|
9
|
+
/**
|
|
10
|
+
* The start time of this segment in seconds.
|
|
11
|
+
*/
|
|
12
|
+
start_second: number;
|
|
13
|
+
/**
|
|
14
|
+
* The end time of this segment in seconds.
|
|
15
|
+
*/
|
|
16
|
+
end_second: number;
|
|
17
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { TranscriptionSegment } from "./TranscriptionSegment";
|
|
2
|
+
import type { Warning } from "./Warning";
|
|
3
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
4
|
+
/**
|
|
5
|
+
* A single chunk in the stream returned by `do_stream`.
|
|
6
|
+
*
|
|
7
|
+
* Aligned with V4 `TranscriptionModelV4StreamPart`.
|
|
8
|
+
*/
|
|
9
|
+
export type TranscriptionStreamPart = {
|
|
10
|
+
"StreamStart": {
|
|
11
|
+
warnings: Array<Warning>;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
"TranscriptDelta": {
|
|
15
|
+
id: string | null;
|
|
16
|
+
delta: string;
|
|
17
|
+
provider_metadata: {
|
|
18
|
+
[key in string]: JsonValue;
|
|
19
|
+
} | null;
|
|
20
|
+
};
|
|
21
|
+
} | {
|
|
22
|
+
"TranscriptPartial": {
|
|
23
|
+
id: string | null;
|
|
24
|
+
text: string;
|
|
25
|
+
start_second: number | null;
|
|
26
|
+
duration_in_seconds: number | null;
|
|
27
|
+
channel_index: number | null;
|
|
28
|
+
provider_metadata: {
|
|
29
|
+
[key in string]: JsonValue;
|
|
30
|
+
} | null;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
"TranscriptFinal": {
|
|
34
|
+
id: string | null;
|
|
35
|
+
text: string;
|
|
36
|
+
start_second: number | null;
|
|
37
|
+
end_second: number | null;
|
|
38
|
+
channel_index: number | null;
|
|
39
|
+
provider_metadata: {
|
|
40
|
+
[key in string]: JsonValue;
|
|
41
|
+
} | null;
|
|
42
|
+
};
|
|
43
|
+
} | {
|
|
44
|
+
"ResponseMetadata": {
|
|
45
|
+
timestamp: string | null;
|
|
46
|
+
model_id: string | null;
|
|
47
|
+
headers: {
|
|
48
|
+
[key in string]: string;
|
|
49
|
+
} | null;
|
|
50
|
+
body: JsonValue | null;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
"Finish": {
|
|
54
|
+
text: string;
|
|
55
|
+
segments: Array<TranscriptionSegment>;
|
|
56
|
+
language: string | null;
|
|
57
|
+
duration_in_seconds: number | null;
|
|
58
|
+
provider_metadata: {
|
|
59
|
+
[key in string]: JsonValue;
|
|
60
|
+
} | null;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
"Raw": {
|
|
64
|
+
raw_value: JsonValue;
|
|
65
|
+
};
|
|
66
|
+
} | {
|
|
67
|
+
"Error": {
|
|
68
|
+
error: JsonValue;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Token usage snapshot (7 flat fields + raw passthrough).
|
|
4
|
+
*/
|
|
5
|
+
export type UsageSnapshot = {
|
|
6
|
+
input_total: bigint | null;
|
|
7
|
+
input_no_cache: bigint | null;
|
|
8
|
+
cache_read: bigint | null;
|
|
9
|
+
cache_write: bigint | null;
|
|
10
|
+
output_total: bigint | null;
|
|
11
|
+
output_text: bigint | null;
|
|
12
|
+
output_reasoning: bigint | null;
|
|
13
|
+
/**
|
|
14
|
+
* Raw provider usage payload (opaque passthrough; numbers only — no
|
|
15
|
+
* prompt text).
|
|
16
|
+
*/
|
|
17
|
+
raw?: JsonValue | null;
|
|
18
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { VerdictConfidence } from "./VerdictConfidence";
|
|
2
|
+
import type { VerdictKind } from "./VerdictKind";
|
|
3
|
+
/**
|
|
4
|
+
* A verdict for one call.
|
|
5
|
+
*/
|
|
6
|
+
export type Verdict = {
|
|
7
|
+
kind: VerdictKind;
|
|
8
|
+
confidence: VerdictConfidence;
|
|
9
|
+
/**
|
|
10
|
+
* Violated rule ids (R-1.1 / R-1.2 / …).
|
|
11
|
+
*/
|
|
12
|
+
violated: Array<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Expected upper bound U (tokens).
|
|
15
|
+
*/
|
|
16
|
+
expected_max: bigint;
|
|
17
|
+
claimed: bigint;
|
|
18
|
+
/**
|
|
19
|
+
* Client-side LCP (bytes).
|
|
20
|
+
*/
|
|
21
|
+
lcp_bytes: bigint;
|
|
22
|
+
notes: Array<string>;
|
|
23
|
+
};
|