@arcships/aimux 0.1.0 → 0.1.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/aimux.darwin-arm64.node +0 -0
- package/aimux.linux-x64-gnu.node +0 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +78 -0
- package/dist/types/AiMuxError.d.ts +34 -0
- package/dist/types/AiMuxError.js +3 -0
- package/dist/types/AspectRatio.d.ts +11 -0
- package/dist/types/AspectRatio.js +3 -0
- package/dist/types/AudioChunk.d.ts +8 -0
- package/dist/types/AudioChunk.js +3 -0
- package/dist/types/AudioData.d.ts +11 -0
- package/dist/types/AudioData.js +3 -0
- package/dist/types/AudioInput.d.ts +8 -0
- package/dist/types/AudioInput.js +3 -0
- package/dist/types/CallOptions.d.ts +80 -0
- package/dist/types/CallOptions.js +2 -0
- package/dist/types/ContentPart.d.ts +77 -0
- package/dist/types/ContentPart.js +2 -0
- package/dist/types/EmbeddingCallOptions.d.ts +24 -0
- package/dist/types/EmbeddingCallOptions.js +2 -0
- package/dist/types/EmbeddingResponse.d.ts +16 -0
- package/dist/types/EmbeddingResponse.js +2 -0
- package/dist/types/EmbeddingResult.d.ts +33 -0
- package/dist/types/EmbeddingResult.js +2 -0
- package/dist/types/EmbeddingUsage.d.ts +9 -0
- package/dist/types/EmbeddingUsage.js +3 -0
- package/dist/types/FileBytes.d.ts +12 -0
- package/dist/types/FileBytes.js +3 -0
- package/dist/types/FileData.d.ts +25 -0
- package/dist/types/FileData.js +2 -0
- package/dist/types/FinishReason.d.ts +14 -0
- package/dist/types/FinishReason.js +2 -0
- package/dist/types/FinishReasonUnified.d.ts +4 -0
- package/dist/types/FinishReasonUnified.js +3 -0
- package/dist/types/FunctionTool.d.ts +35 -0
- package/dist/types/FunctionTool.js +2 -0
- package/dist/types/GenerateContent.d.ts +33 -0
- package/dist/types/GenerateContent.js +2 -0
- package/dist/types/GenerateResult.d.ts +45 -0
- package/dist/types/GenerateResult.js +2 -0
- package/dist/types/GenerateTextOptions.d.ts +38 -0
- package/dist/types/GenerateTextOptions.js +2 -0
- package/dist/types/GenerateTextResult.d.ts +34 -0
- package/dist/types/GenerateTextResult.js +2 -0
- package/dist/types/ImageCallOptions.d.ts +54 -0
- package/dist/types/ImageCallOptions.js +2 -0
- package/dist/types/ImageFile.d.ts +25 -0
- package/dist/types/ImageFile.js +2 -0
- package/dist/types/ImageFileData.d.ts +8 -0
- package/dist/types/ImageFileData.js +3 -0
- package/dist/types/ImageOutputs.d.ts +14 -0
- package/dist/types/ImageOutputs.js +3 -0
- package/dist/types/ImageResponse.d.ts +19 -0
- package/dist/types/ImageResponse.js +3 -0
- package/dist/types/ImageResult.d.ts +34 -0
- package/dist/types/ImageResult.js +2 -0
- package/dist/types/ImageUsage.d.ts +19 -0
- package/dist/types/ImageUsage.js +3 -0
- package/dist/types/InputAudioFormat.d.ts +13 -0
- package/dist/types/InputAudioFormat.js +3 -0
- package/dist/types/LanguageModelPromptMessage.d.ts +20 -0
- package/dist/types/LanguageModelPromptMessage.js +2 -0
- package/dist/types/MessageContent.d.ts +5 -0
- package/dist/types/MessageContent.js +2 -0
- package/dist/types/ModelId.d.ts +7 -0
- package/dist/types/ModelId.js +3 -0
- package/dist/types/ModelMessage.d.ts +9 -0
- package/dist/types/ModelMessage.js +2 -0
- package/dist/types/ModelPrompt.d.ts +7 -0
- package/dist/types/ModelPrompt.js +2 -0
- package/dist/types/ProviderTool.d.ts +24 -0
- package/dist/types/ProviderTool.js +2 -0
- package/dist/types/ReasoningEffort.d.ts +7 -0
- package/dist/types/ReasoningEffort.js +3 -0
- package/dist/types/RequestInfo.d.ts +12 -0
- package/dist/types/RequestInfo.js +2 -0
- package/dist/types/RerankingCallOptions.d.ts +33 -0
- package/dist/types/RerankingCallOptions.js +2 -0
- package/dist/types/RerankingDocuments.d.ts +15 -0
- package/dist/types/RerankingDocuments.js +2 -0
- package/dist/types/RerankingRank.d.ts +13 -0
- package/dist/types/RerankingRank.js +3 -0
- package/dist/types/RerankingResponse.d.ts +28 -0
- package/dist/types/RerankingResponse.js +2 -0
- package/dist/types/RerankingResult.d.ts +31 -0
- package/dist/types/RerankingResult.js +2 -0
- package/dist/types/ResponseFormat.d.ts +11 -0
- package/dist/types/ResponseFormat.js +2 -0
- package/dist/types/ResponseInfo.d.ts +30 -0
- package/dist/types/ResponseInfo.js +2 -0
- package/dist/types/ResponseMetadata.d.ts +8 -0
- package/dist/types/ResponseMetadata.js +3 -0
- package/dist/types/Role.d.ts +4 -0
- package/dist/types/Role.js +3 -0
- package/dist/types/SearchCallOptions.d.ts +46 -0
- package/dist/types/SearchCallOptions.js +2 -0
- package/dist/types/SearchResponse.d.ts +16 -0
- package/dist/types/SearchResponse.js +2 -0
- package/dist/types/SearchResult.d.ts +32 -0
- package/dist/types/SearchResult.js +2 -0
- package/dist/types/SearchResultItem.d.ts +33 -0
- package/dist/types/SearchResultItem.js +2 -0
- package/dist/types/Size.d.ts +11 -0
- package/dist/types/Size.js +3 -0
- package/dist/types/SpeechCallOptions.d.ts +47 -0
- package/dist/types/SpeechCallOptions.js +2 -0
- package/dist/types/SpeechRequest.d.ts +10 -0
- package/dist/types/SpeechRequest.js +2 -0
- package/dist/types/SpeechResponse.d.ts +24 -0
- package/dist/types/SpeechResponse.js +2 -0
- package/dist/types/SpeechResult.d.ts +34 -0
- package/dist/types/SpeechResult.js +2 -0
- package/dist/types/StreamPart.d.ts +104 -0
- package/dist/types/StreamPart.js +2 -0
- package/dist/types/TokenUsage.d.ts +29 -0
- package/dist/types/TokenUsage.js +3 -0
- package/dist/types/Tool.d.ts +12 -0
- package/dist/types/Tool.js +2 -0
- package/dist/types/ToolCall.d.ts +18 -0
- package/dist/types/ToolCall.js +2 -0
- package/dist/types/ToolChoice.d.ts +12 -0
- package/dist/types/ToolChoice.js +3 -0
- package/dist/types/ToolResult.d.ts +14 -0
- package/dist/types/ToolResult.js +2 -0
- package/dist/types/UploadFileCallOptions.d.ts +27 -0
- package/dist/types/UploadFileCallOptions.js +2 -0
- package/dist/types/UploadFileData.d.ts +17 -0
- package/dist/types/UploadFileData.js +2 -0
- package/dist/types/UploadFileResult.d.ts +35 -0
- package/dist/types/UploadFileResult.js +2 -0
- package/dist/types/Usage.d.ts +8 -0
- package/dist/types/Usage.js +2 -0
- package/dist/types/VideoCallOptions.d.ts +69 -0
- package/dist/types/VideoCallOptions.js +2 -0
- package/dist/types/VideoData.d.ts +22 -0
- package/dist/types/VideoData.js +3 -0
- package/dist/types/VideoFile.d.ts +29 -0
- package/dist/types/VideoFile.js +2 -0
- package/dist/types/VideoFileData.d.ts +8 -0
- package/dist/types/VideoFileData.js +3 -0
- package/dist/types/VideoFrameImage.d.ts +17 -0
- package/dist/types/VideoFrameImage.js +2 -0
- package/dist/types/VideoFrameType.d.ts +6 -0
- package/dist/types/VideoFrameType.js +3 -0
- package/dist/types/VideoResponse.d.ts +19 -0
- package/dist/types/VideoResponse.js +3 -0
- package/dist/types/VideoResult.d.ts +29 -0
- package/dist/types/VideoResult.js +2 -0
- package/dist/types/Warning.d.ts +23 -0
- package/dist/types/Warning.js +3 -0
- package/dist/types/serde_json/JsonValue.d.ts +3 -0
- package/dist/types/serde_json/JsonValue.js +3 -0
- package/dist/types.d.ts +73 -0
- package/dist/types.js +5 -0
- package/package.json +8 -6
- package/src/index.ts +0 -134
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* How the model should format its response.
|
|
4
|
+
*/
|
|
5
|
+
export type ResponseFormat = "Text" | {
|
|
6
|
+
"Json": {
|
|
7
|
+
schema: JsonValue | null;
|
|
8
|
+
name: string | null;
|
|
9
|
+
description: string | null;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Response information for telemetry and debugging.
|
|
4
|
+
*
|
|
5
|
+
* Aligned with the `response` object that appears on most V4 model results.
|
|
6
|
+
* All fields are optional because different providers populate different
|
|
7
|
+
* subsets; traits whose TS spec marks `response` as required use
|
|
8
|
+
* `ResponseInfo` directly, while those that mark it optional use
|
|
9
|
+
* `Option<ResponseInfo>`.
|
|
10
|
+
*/
|
|
11
|
+
export type ResponseInfo = {
|
|
12
|
+
/**
|
|
13
|
+
* Timestamp for the start of the generated response (ISO 8601 string).
|
|
14
|
+
*/
|
|
15
|
+
timestamp: string | null;
|
|
16
|
+
/**
|
|
17
|
+
* The ID of the model that was used to generate the response.
|
|
18
|
+
*/
|
|
19
|
+
model_id: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Response headers.
|
|
22
|
+
*/
|
|
23
|
+
headers: {
|
|
24
|
+
[key in string]: string;
|
|
25
|
+
} | null;
|
|
26
|
+
/**
|
|
27
|
+
* The response body (opaque JSON).
|
|
28
|
+
*/
|
|
29
|
+
body: JsonValue | null;
|
|
30
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Options passed to [`SearchModel::do_search`].
|
|
4
|
+
*/
|
|
5
|
+
export type SearchCallOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* The search query string.
|
|
8
|
+
*/
|
|
9
|
+
query: string;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum number of results to return.
|
|
12
|
+
*/
|
|
13
|
+
max_results: number | null;
|
|
14
|
+
/**
|
|
15
|
+
* Whether to include raw page content in results.
|
|
16
|
+
*
|
|
17
|
+
* Provider support varies; providers that cannot honor this should
|
|
18
|
+
* issue a warning rather than erroring.
|
|
19
|
+
*/
|
|
20
|
+
include_raw_content: boolean | null;
|
|
21
|
+
/**
|
|
22
|
+
* Optional time range filter (e.g. `"day"`, `"week"`, `"month"`,
|
|
23
|
+
* `"year"`). Provider support varies.
|
|
24
|
+
*/
|
|
25
|
+
time_range: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* Optional list of domains to include in results.
|
|
28
|
+
*/
|
|
29
|
+
include_domains: Array<string> | null;
|
|
30
|
+
/**
|
|
31
|
+
* Optional list of domains to exclude from results.
|
|
32
|
+
*/
|
|
33
|
+
exclude_domains: Array<string> | null;
|
|
34
|
+
/**
|
|
35
|
+
* Additional provider-specific options, keyed by provider name.
|
|
36
|
+
*/
|
|
37
|
+
provider_options: {
|
|
38
|
+
[key in string]: JsonValue;
|
|
39
|
+
} | null;
|
|
40
|
+
/**
|
|
41
|
+
* Additional HTTP headers to send with the request.
|
|
42
|
+
*/
|
|
43
|
+
headers: {
|
|
44
|
+
[key in string]: string;
|
|
45
|
+
} | null;
|
|
46
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Optional response information for a search call.
|
|
4
|
+
*/
|
|
5
|
+
export type SearchResponse = {
|
|
6
|
+
/**
|
|
7
|
+
* Response headers.
|
|
8
|
+
*/
|
|
9
|
+
headers: {
|
|
10
|
+
[key in string]: string;
|
|
11
|
+
} | null;
|
|
12
|
+
/**
|
|
13
|
+
* The response body (opaque JSON).
|
|
14
|
+
*/
|
|
15
|
+
body: JsonValue | null;
|
|
16
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SearchResponse } from "./SearchResponse";
|
|
2
|
+
import type { SearchResultItem } from "./SearchResultItem";
|
|
3
|
+
import type { Warning } from "./Warning";
|
|
4
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
5
|
+
/**
|
|
6
|
+
* The result of [`SearchModel::do_search`].
|
|
7
|
+
*/
|
|
8
|
+
export type SearchResult = {
|
|
9
|
+
/**
|
|
10
|
+
* Ordered list of search results.
|
|
11
|
+
*/
|
|
12
|
+
results: Array<SearchResultItem>;
|
|
13
|
+
/**
|
|
14
|
+
* An optional direct answer / summary (some providers return
|
|
15
|
+
* an AI-generated answer alongside results).
|
|
16
|
+
*/
|
|
17
|
+
answer: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Additional provider-specific metadata.
|
|
20
|
+
*/
|
|
21
|
+
provider_metadata: {
|
|
22
|
+
[key in string]: JsonValue;
|
|
23
|
+
} | null;
|
|
24
|
+
/**
|
|
25
|
+
* Warnings for the call.
|
|
26
|
+
*/
|
|
27
|
+
warnings: Array<Warning>;
|
|
28
|
+
/**
|
|
29
|
+
* Optional response information for debugging.
|
|
30
|
+
*/
|
|
31
|
+
response: SearchResponse | null;
|
|
32
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* A single search result item.
|
|
4
|
+
*/
|
|
5
|
+
export type SearchResultItem = {
|
|
6
|
+
/**
|
|
7
|
+
* The title of the result (e.g. page title).
|
|
8
|
+
*/
|
|
9
|
+
title: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* The URL of the result.
|
|
12
|
+
*/
|
|
13
|
+
url: string | null;
|
|
14
|
+
/**
|
|
15
|
+
* A snippet/summary of the result content.
|
|
16
|
+
*/
|
|
17
|
+
content: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Raw page content (when `include_raw_content` is requested and
|
|
20
|
+
* supported by the provider).
|
|
21
|
+
*/
|
|
22
|
+
raw_content: string | null;
|
|
23
|
+
/**
|
|
24
|
+
* A relevance score (0.0–1.0) if the provider returns one.
|
|
25
|
+
*/
|
|
26
|
+
score: number | null;
|
|
27
|
+
/**
|
|
28
|
+
* Provider-specific metadata for this result.
|
|
29
|
+
*/
|
|
30
|
+
provider_metadata: {
|
|
31
|
+
[key in string]: JsonValue;
|
|
32
|
+
} | null;
|
|
33
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image/video size in `{width}x{height}` format (e.g. `"1024x1024"`).
|
|
3
|
+
*
|
|
4
|
+
* Newtype that enforces the `WxH` format used by V4 image `size` and video
|
|
5
|
+
* `resolution` options. Aligned with the TS template-literal type
|
|
6
|
+
* `` `${number}x${number}` ``.
|
|
7
|
+
*/
|
|
8
|
+
export type Size = {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Options passed to [`SpeechModel::do_generate`].
|
|
4
|
+
*
|
|
5
|
+
* Aligned with V4 `SpeechModelV4CallOptions`.
|
|
6
|
+
*/
|
|
7
|
+
export type SpeechCallOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* Text to convert to speech.
|
|
10
|
+
*/
|
|
11
|
+
text: string;
|
|
12
|
+
/**
|
|
13
|
+
* The voice to use (provider-specific voice ID, name, or other
|
|
14
|
+
* identifier).
|
|
15
|
+
*/
|
|
16
|
+
voice: string | null;
|
|
17
|
+
/**
|
|
18
|
+
* The desired output format for the audio, e.g. `"mp3"`, `"wav"`.
|
|
19
|
+
*/
|
|
20
|
+
output_format: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Instructions for the speech generation, e.g.
|
|
23
|
+
* `"Speak in a slow and steady tone"`.
|
|
24
|
+
*/
|
|
25
|
+
instructions: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The speed of the speech generation.
|
|
28
|
+
*/
|
|
29
|
+
speed: number | null;
|
|
30
|
+
/**
|
|
31
|
+
* The language for speech generation (ISO 639-1 code, e.g. `"en"`, or
|
|
32
|
+
* `"auto"` for automatic detection). Provider support varies.
|
|
33
|
+
*/
|
|
34
|
+
language: string | null;
|
|
35
|
+
/**
|
|
36
|
+
* Additional provider-specific options, keyed by provider name.
|
|
37
|
+
*/
|
|
38
|
+
provider_options: {
|
|
39
|
+
[key in string]: JsonValue;
|
|
40
|
+
} | null;
|
|
41
|
+
/**
|
|
42
|
+
* Additional HTTP headers to send with the request.
|
|
43
|
+
*/
|
|
44
|
+
headers: {
|
|
45
|
+
[key in string]: string;
|
|
46
|
+
} | null;
|
|
47
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Response information for a speech call.
|
|
4
|
+
*/
|
|
5
|
+
export type SpeechResponse = {
|
|
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,34 @@
|
|
|
1
|
+
import type { AudioData } from "./AudioData";
|
|
2
|
+
import type { SpeechRequest } from "./SpeechRequest";
|
|
3
|
+
import type { SpeechResponse } from "./SpeechResponse";
|
|
4
|
+
import type { Warning } from "./Warning";
|
|
5
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
6
|
+
/**
|
|
7
|
+
* The result of [`SpeechModel::do_generate`].
|
|
8
|
+
*
|
|
9
|
+
* Aligned with V4 `SpeechModelV4Result`.
|
|
10
|
+
*/
|
|
11
|
+
export type SpeechResult = {
|
|
12
|
+
/**
|
|
13
|
+
* Generated audio (base64 string or binary data).
|
|
14
|
+
*/
|
|
15
|
+
audio: AudioData;
|
|
16
|
+
/**
|
|
17
|
+
* Warnings for the call, e.g. unsupported settings.
|
|
18
|
+
*/
|
|
19
|
+
warnings: Array<Warning>;
|
|
20
|
+
/**
|
|
21
|
+
* Optional request information for telemetry and debugging.
|
|
22
|
+
*/
|
|
23
|
+
request: SpeechRequest | null;
|
|
24
|
+
/**
|
|
25
|
+
* Response information for telemetry and debugging.
|
|
26
|
+
*/
|
|
27
|
+
response: SpeechResponse;
|
|
28
|
+
/**
|
|
29
|
+
* Additional provider-specific metadata, keyed by provider name.
|
|
30
|
+
*/
|
|
31
|
+
provider_metadata: {
|
|
32
|
+
[key in string]: JsonValue;
|
|
33
|
+
} | null;
|
|
34
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { AiMuxError } from "./AiMuxError";
|
|
2
|
+
import type { FinishReason } from "./FinishReason";
|
|
3
|
+
import type { Usage } from "./Usage";
|
|
4
|
+
import type { Warning } from "./Warning";
|
|
5
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
6
|
+
/**
|
|
7
|
+
* A single chunk in the stream returned by `do_stream`.
|
|
8
|
+
*/
|
|
9
|
+
export type StreamPart = {
|
|
10
|
+
"TextStart": {
|
|
11
|
+
id: string;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
"TextDelta": {
|
|
15
|
+
id: string;
|
|
16
|
+
delta: string;
|
|
17
|
+
};
|
|
18
|
+
} | {
|
|
19
|
+
"TextEnd": {
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
} | {
|
|
23
|
+
"StreamStart": {
|
|
24
|
+
warnings: Array<Warning>;
|
|
25
|
+
};
|
|
26
|
+
} | {
|
|
27
|
+
"Finish": {
|
|
28
|
+
finish_reason: FinishReason;
|
|
29
|
+
usage: Usage;
|
|
30
|
+
provider_metadata: JsonValue | null;
|
|
31
|
+
};
|
|
32
|
+
} | {
|
|
33
|
+
"Error": {
|
|
34
|
+
error: AiMuxError;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
"ToolInputStart": {
|
|
38
|
+
id: string;
|
|
39
|
+
tool_name: string;
|
|
40
|
+
};
|
|
41
|
+
} | {
|
|
42
|
+
"ToolInputDelta": {
|
|
43
|
+
id: string;
|
|
44
|
+
delta: string;
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
"ToolInputEnd": {
|
|
48
|
+
id: string;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
"ToolCall": {
|
|
52
|
+
tool_call_id: string;
|
|
53
|
+
tool_name: string;
|
|
54
|
+
input: JsonValue;
|
|
55
|
+
};
|
|
56
|
+
} | {
|
|
57
|
+
"ToolResult": {
|
|
58
|
+
tool_call_id: string;
|
|
59
|
+
tool_name: string;
|
|
60
|
+
output: JsonValue;
|
|
61
|
+
};
|
|
62
|
+
} | {
|
|
63
|
+
"ReasoningStart": {
|
|
64
|
+
id: string;
|
|
65
|
+
/**
|
|
66
|
+
* Provider-specific metadata (e.g. xAI `itemId`).
|
|
67
|
+
*/
|
|
68
|
+
provider_metadata: JsonValue | null;
|
|
69
|
+
};
|
|
70
|
+
} | {
|
|
71
|
+
"ReasoningDelta": {
|
|
72
|
+
id: string;
|
|
73
|
+
delta: string;
|
|
74
|
+
/**
|
|
75
|
+
* Provider-specific metadata (e.g. xAI `itemId`).
|
|
76
|
+
*/
|
|
77
|
+
provider_metadata: JsonValue | null;
|
|
78
|
+
};
|
|
79
|
+
} | {
|
|
80
|
+
"ReasoningEnd": {
|
|
81
|
+
id: string;
|
|
82
|
+
/**
|
|
83
|
+
* Provider-specific metadata (e.g. xAI `itemId`, `reasoningEncryptedContent`).
|
|
84
|
+
*/
|
|
85
|
+
provider_metadata: JsonValue | null;
|
|
86
|
+
};
|
|
87
|
+
} | {
|
|
88
|
+
"ResponseMetadata": {
|
|
89
|
+
id: string | null;
|
|
90
|
+
timestamp: string | null;
|
|
91
|
+
model_id: string | null;
|
|
92
|
+
};
|
|
93
|
+
} | {
|
|
94
|
+
"Source": {
|
|
95
|
+
id: string;
|
|
96
|
+
source_type: string;
|
|
97
|
+
url: string | null;
|
|
98
|
+
title: string | null;
|
|
99
|
+
};
|
|
100
|
+
} | {
|
|
101
|
+
"Raw": {
|
|
102
|
+
raw_value: JsonValue;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token usage detail (with cache breakdown).
|
|
3
|
+
*/
|
|
4
|
+
export type TokenUsage = {
|
|
5
|
+
/**
|
|
6
|
+
* Total tokens.
|
|
7
|
+
*/
|
|
8
|
+
total: number | null;
|
|
9
|
+
/**
|
|
10
|
+
* Tokens that were not served from cache.
|
|
11
|
+
*/
|
|
12
|
+
no_cache: number | null;
|
|
13
|
+
/**
|
|
14
|
+
* Tokens served from cache (read).
|
|
15
|
+
*/
|
|
16
|
+
cache_read: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* Tokens written to cache.
|
|
19
|
+
*/
|
|
20
|
+
cache_write: number | null;
|
|
21
|
+
/**
|
|
22
|
+
* Text (non-reasoning) tokens (output side).
|
|
23
|
+
*/
|
|
24
|
+
text: number | null;
|
|
25
|
+
/**
|
|
26
|
+
* Reasoning tokens (output side).
|
|
27
|
+
*/
|
|
28
|
+
reasoning: number | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FunctionTool } from "./FunctionTool";
|
|
2
|
+
import type { ProviderTool } from "./ProviderTool";
|
|
3
|
+
/**
|
|
4
|
+
* A tool that can be either a user-defined function tool or a
|
|
5
|
+
* provider-defined tool. Mirrors the V4
|
|
6
|
+
* `Array<LanguageModelV4FunctionTool | LanguageModelV4ProviderTool>`.
|
|
7
|
+
*/
|
|
8
|
+
export type Tool = {
|
|
9
|
+
"type": "function";
|
|
10
|
+
} & FunctionTool | {
|
|
11
|
+
"type": "provider";
|
|
12
|
+
} & ProviderTool;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* A tool call requested by the model.
|
|
4
|
+
*/
|
|
5
|
+
export type ToolCall = {
|
|
6
|
+
/**
|
|
7
|
+
* Provider-assigned call id.
|
|
8
|
+
*/
|
|
9
|
+
tool_call_id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Tool name.
|
|
12
|
+
*/
|
|
13
|
+
tool_name: string;
|
|
14
|
+
/**
|
|
15
|
+
* Arguments as a JSON value (usually an object).
|
|
16
|
+
*/
|
|
17
|
+
input: JsonValue;
|
|
18
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How the model should choose tools.
|
|
3
|
+
*
|
|
4
|
+
* Wire format aligns with Vercel AI SDK `toolChoice`:
|
|
5
|
+
* `"auto" | "none" | "required" | { "type": "tool", "toolName": "..." }`.
|
|
6
|
+
* This is a mixed tagged/untagged shape (unit variants as bare strings,
|
|
7
|
+
* `Tool` variant as a tagged object), so serde is implemented by hand.
|
|
8
|
+
*/
|
|
9
|
+
export type ToolChoice = "auto" | "none" | "required" | {
|
|
10
|
+
type: "tool";
|
|
11
|
+
toolName: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* The result of executing a tool call, to be sent back to the model.
|
|
4
|
+
*/
|
|
5
|
+
export type ToolResult = {
|
|
6
|
+
/**
|
|
7
|
+
* Must match the corresponding `ToolCall::tool_call_id`.
|
|
8
|
+
*/
|
|
9
|
+
tool_call_id: string;
|
|
10
|
+
/**
|
|
11
|
+
* The tool's output (usually a JSON-serializable value or plain text).
|
|
12
|
+
*/
|
|
13
|
+
output: JsonValue;
|
|
14
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UploadFileData } from "./UploadFileData";
|
|
2
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
|
+
/**
|
|
4
|
+
* Options passed to [`Files::upload_file`].
|
|
5
|
+
*
|
|
6
|
+
* Aligned with V4 `FilesV4UploadFileCallOptions`.
|
|
7
|
+
*/
|
|
8
|
+
export type UploadFileCallOptions = {
|
|
9
|
+
/**
|
|
10
|
+
* The file data (raw bytes/base64 or inline text).
|
|
11
|
+
*/
|
|
12
|
+
data: UploadFileData;
|
|
13
|
+
/**
|
|
14
|
+
* The IANA media type of the file, e.g. `"application/pdf"`.
|
|
15
|
+
*/
|
|
16
|
+
media_type: string;
|
|
17
|
+
/**
|
|
18
|
+
* The filename of the file.
|
|
19
|
+
*/
|
|
20
|
+
filename: string | null;
|
|
21
|
+
/**
|
|
22
|
+
* Additional provider-specific options, keyed by provider name.
|
|
23
|
+
*/
|
|
24
|
+
provider_options: {
|
|
25
|
+
[key in string]: JsonValue;
|
|
26
|
+
} | null;
|
|
27
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FileBytes } from "./FileBytes";
|
|
2
|
+
/**
|
|
3
|
+
* File data accepted by [`Files::upload_file`].
|
|
4
|
+
*
|
|
5
|
+
* The V4 spec restricts upload input to the `data` and `text` variants of
|
|
6
|
+
* `SharedV4FileData` (URLs and provider references are not valid uploads), so
|
|
7
|
+
* this is a dedicated two-variant enum rather than the full [`crate::shared::FileData`].
|
|
8
|
+
*/
|
|
9
|
+
export type UploadFileData = {
|
|
10
|
+
"Data": {
|
|
11
|
+
data: FileBytes;
|
|
12
|
+
};
|
|
13
|
+
} | {
|
|
14
|
+
"Text": {
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
};
|