@arcships/aimux 0.3.0 → 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 +93 -25
- package/dist/error.js +51 -110
- package/dist/index.d.ts +55 -28
- package/dist/index.js +152 -103
- package/dist/native.d.ts +2 -0
- package/dist/native.js +46 -0
- package/dist/types/AiMuxError.d.ts +28 -10
- package/dist/types/ApiCallError.d.ts +26 -16
- package/dist/types/ApiCallError.js +0 -1
- package/dist/types/CallOptions.d.ts +1 -1
- package/dist/types/ContentPart.d.ts +6 -0
- package/dist/types/EmbeddingCallOptions.d.ts +9 -0
- package/dist/types/GenerateContent.d.ts +12 -1
- package/dist/types/HttpExchange.d.ts +12 -1
- package/dist/types/ImageCallOptions.d.ts +9 -0
- package/dist/types/OutcomeRecord.d.ts +5 -0
- package/dist/types/RawToolCall.d.ts +16 -0
- package/dist/types/RawToolCall.js +2 -0
- package/dist/types/RerankingCallOptions.d.ts +9 -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/SearchCallOptions.d.ts +9 -0
- package/dist/types/SpeechCallOptions.d.ts +9 -0
- package/dist/types/StreamPart.d.ts +12 -0
- package/dist/types/TimeoutConfiguration.d.ts +9 -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/TranscriptionCallOptions.d.ts +9 -0
- package/dist/types/VideoCallOptions.d.ts +16 -1
- 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 +5 -0
- package/index.d.ts +83 -7
- package/index.js +59 -54
- package/package.json +12 -12
|
@@ -6,9 +6,20 @@ import type { TimingRecord } from "./TimingRecord";
|
|
|
6
6
|
*/
|
|
7
7
|
export type HttpExchange = {
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
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.
|
|
10
17
|
*/
|
|
11
18
|
attempt: number;
|
|
19
|
+
/**
|
|
20
|
+
* HTTP exchange within the operation attempt, starting at 1.
|
|
21
|
+
*/
|
|
22
|
+
exchange_index: number;
|
|
12
23
|
request: HttpRecord;
|
|
13
24
|
/**
|
|
14
25
|
* None = 请求失败未获响应。
|
|
@@ -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`].
|
|
@@ -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
|
*/
|
|
@@ -7,6 +7,11 @@ export type OutcomeRecord = {
|
|
|
7
7
|
status: OutcomeStatus;
|
|
8
8
|
finish_reason: string | null;
|
|
9
9
|
error: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Lossless structured domain error. In particular, `RetryError.errors`
|
|
12
|
+
* keeps the complete attempt history rather than only its display text.
|
|
13
|
+
*/
|
|
14
|
+
error_value: JsonValue | null;
|
|
10
15
|
/**
|
|
11
16
|
* 序列化的 Usage。
|
|
12
17
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { JsonValue } from "./serde_json/JsonValue";
|
|
2
|
+
/**
|
|
3
|
+
* Provider-facing tool call before Core parses and validates its input.
|
|
4
|
+
*
|
|
5
|
+
* The wire shape matches [`ToolCall`] field for field, except that `input`
|
|
6
|
+
* is the provider's raw argument *text* rather than a parsed value.
|
|
7
|
+
*/
|
|
8
|
+
export type RawToolCall = {
|
|
9
|
+
tool_call_id: string;
|
|
10
|
+
tool_name: string;
|
|
11
|
+
input: string;
|
|
12
|
+
provider_executed?: boolean | null;
|
|
13
|
+
dynamic?: boolean | null;
|
|
14
|
+
thought_signature?: string | null;
|
|
15
|
+
provider_metadata?: JsonValue | null;
|
|
16
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RerankingDocuments } from "./RerankingDocuments";
|
|
2
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
2
3
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
4
|
/**
|
|
4
5
|
* Options passed to [`RerankingModel::do_rerank`].
|
|
@@ -18,6 +19,14 @@ export type RerankingCallOptions = {
|
|
|
18
19
|
* Optional limit: return only the top `n` documents.
|
|
19
20
|
*/
|
|
20
21
|
top_n: number | null;
|
|
22
|
+
/**
|
|
23
|
+
* Per-call retry override. `None` uses the model default.
|
|
24
|
+
*/
|
|
25
|
+
max_retries: number | null;
|
|
26
|
+
/**
|
|
27
|
+
* Per-call operation timeout.
|
|
28
|
+
*/
|
|
29
|
+
timeout: TimeoutConfiguration | null;
|
|
21
30
|
/**
|
|
22
31
|
* Additional provider-specific options, keyed by provider name.
|
|
23
32
|
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AiMuxError } from "./AiMuxError";
|
|
2
|
+
import type { RetryErrorReason } from "./RetryErrorReason";
|
|
3
|
+
/**
|
|
4
|
+
* Complete error history for a retried model operation.
|
|
5
|
+
*/
|
|
6
|
+
export type RetryError = {
|
|
7
|
+
reason: RetryErrorReason;
|
|
8
|
+
errors: Array<AiMuxError>;
|
|
9
|
+
};
|
|
@@ -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 [`SearchModel::do_search`].
|
|
@@ -31,6 +32,14 @@ export type SearchCallOptions = {
|
|
|
31
32
|
* Optional list of domains to exclude from results.
|
|
32
33
|
*/
|
|
33
34
|
exclude_domains: Array<string> | null;
|
|
35
|
+
/**
|
|
36
|
+
* Per-call retry override. `None` uses the model default.
|
|
37
|
+
*/
|
|
38
|
+
max_retries: number | null;
|
|
39
|
+
/**
|
|
40
|
+
* Per-call operation timeout.
|
|
41
|
+
*/
|
|
42
|
+
timeout: TimeoutConfiguration | null;
|
|
34
43
|
/**
|
|
35
44
|
* Additional provider-specific options, keyed by provider name.
|
|
36
45
|
*/
|
|
@@ -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
|
} | {
|
|
@@ -12,8 +12,17 @@ export type TimeoutConfiguration = {
|
|
|
12
12
|
* streaming, the whole stream), in milliseconds.
|
|
13
13
|
*/
|
|
14
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;
|
|
15
20
|
/**
|
|
16
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.
|
|
17
26
|
*/
|
|
18
27
|
first_chunk_ms: number | null;
|
|
19
28
|
/**
|
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
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AudioInput } from "./AudioInput";
|
|
2
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
2
3
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
3
4
|
/**
|
|
4
5
|
* Options passed to [`TranscriptionModel::do_generate`].
|
|
@@ -20,6 +21,14 @@ export type TranscriptionCallOptions = {
|
|
|
20
21
|
provider_options: {
|
|
21
22
|
[key in string]: JsonValue;
|
|
22
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;
|
|
23
32
|
/**
|
|
24
33
|
* Additional HTTP headers to send with the request.
|
|
25
34
|
*/
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { AspectRatio } from "./AspectRatio";
|
|
2
2
|
import type { Size } from "./Size";
|
|
3
|
+
import type { TimeoutConfiguration } from "./TimeoutConfiguration";
|
|
3
4
|
import type { VideoFile } from "./VideoFile";
|
|
4
5
|
import type { VideoFrameImage } from "./VideoFrameImage";
|
|
6
|
+
import type { VideoPollOptions } from "./VideoPollOptions";
|
|
5
7
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
6
8
|
/**
|
|
7
|
-
* Options passed to [`VideoModel::
|
|
9
|
+
* Options passed to [`VideoModel::do_start`] and [`VideoModel::do_status`].
|
|
8
10
|
*
|
|
9
11
|
* Aligned with V4 `VideoModelV4CallOptions`.
|
|
10
12
|
*/
|
|
@@ -60,6 +62,19 @@ export type VideoCallOptions = {
|
|
|
60
62
|
provider_options: {
|
|
61
63
|
[key in string]: JsonValue;
|
|
62
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Per-call retry override. `None` uses the model default.
|
|
67
|
+
*/
|
|
68
|
+
max_retries: number | null;
|
|
69
|
+
/**
|
|
70
|
+
* Per-call poll pacing override for the start/status flow. Unset fields
|
|
71
|
+
* fall back to the model's [`VideoModel::poll_config`].
|
|
72
|
+
*/
|
|
73
|
+
poll: VideoPollOptions | null;
|
|
74
|
+
/**
|
|
75
|
+
* Per-call operation timeout.
|
|
76
|
+
*/
|
|
77
|
+
timeout: TimeoutConfiguration | null;
|
|
63
78
|
/**
|
|
64
79
|
* Additional HTTP headers to send with the request.
|
|
65
80
|
*/
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-call poll pacing for video generation (AI SDK `generateVideo` `poll`).
|
|
3
|
+
*/
|
|
4
|
+
export type VideoPollOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Delay between consecutive status checks, in milliseconds.
|
|
7
|
+
*/
|
|
8
|
+
interval_ms: number | null;
|
|
9
|
+
/**
|
|
10
|
+
* Maximum total time to wait for completion, in milliseconds.
|
|
11
|
+
*/
|
|
12
|
+
timeout_ms: number | null;
|
|
13
|
+
};
|
|
@@ -3,7 +3,7 @@ import type { VideoResponse } from "./VideoResponse";
|
|
|
3
3
|
import type { Warning } from "./Warning";
|
|
4
4
|
import type { JsonValue } from "./serde_json/JsonValue";
|
|
5
5
|
/**
|
|
6
|
-
* The result of
|
|
6
|
+
* The final result of a video generation operation.
|
|
7
7
|
*
|
|
8
8
|
* Aligned with V4 `VideoModelV4Result`.
|
|
9
9
|
*/
|
package/dist/types.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export type * from './types/ProviderAuditSpec';
|
|
|
67
67
|
export type * from './types/ProviderFamily';
|
|
68
68
|
export type * from './types/ProviderRecord';
|
|
69
69
|
export type * from './types/ProviderTool';
|
|
70
|
+
export type * from './types/RawToolCall';
|
|
70
71
|
export type * from './types/ReasoningEffort';
|
|
71
72
|
export type * from './types/ReasoningMode';
|
|
72
73
|
export type * from './types/ReasoningPart';
|
|
@@ -84,6 +85,8 @@ export type * from './types/ResponseFormat';
|
|
|
84
85
|
export type * from './types/ResponseInfo';
|
|
85
86
|
export type * from './types/ResponseMetadata';
|
|
86
87
|
export type * from './types/ResponseRecord';
|
|
88
|
+
export type * from './types/RetryError';
|
|
89
|
+
export type * from './types/RetryErrorReason';
|
|
87
90
|
export type * from './types/Role';
|
|
88
91
|
export type * from './types/RuntimeModel';
|
|
89
92
|
export type * from './types/SearchCallOptions';
|
|
@@ -108,6 +111,7 @@ export type * from './types/TimingRecord';
|
|
|
108
111
|
export type * from './types/TokenUsage';
|
|
109
112
|
export type * from './types/Tool';
|
|
110
113
|
export type * from './types/ToolCall';
|
|
114
|
+
export type * from './types/ToolCallRepairReply';
|
|
111
115
|
export type * from './types/ToolChoice';
|
|
112
116
|
export type * from './types/ToolResult';
|
|
113
117
|
export type * from './types/TraceFilter';
|
|
@@ -133,6 +137,7 @@ export type * from './types/VideoFile';
|
|
|
133
137
|
export type * from './types/VideoFileData';
|
|
134
138
|
export type * from './types/VideoFrameImage';
|
|
135
139
|
export type * from './types/VideoFrameType';
|
|
140
|
+
export type * from './types/VideoPollOptions';
|
|
136
141
|
export type * from './types/VideoResponse';
|
|
137
142
|
export type * from './types/VideoResult';
|
|
138
143
|
export type * from './types/Warning';
|
package/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
/** Fallible native return — unwraps to `T` at runtime; failures reject/throw
|
|
3
|
+
/** Fallible native return — unwraps to `T` at runtime; core failures reject/throw the registered `AimuxError` subclass, while binding faults remain napi-rs plain `Error`s. */
|
|
4
4
|
export type AimuxResult<T> = T
|
|
5
|
-
/** Stream yield — a StreamPart JSON string at runtime; failures reject `next()` with a
|
|
5
|
+
/** Stream yield — a StreamPart JSON string at runtime; failures reject `next()` with a typed error. */
|
|
6
6
|
export type StreamItem = string
|
|
7
7
|
declare global {
|
|
8
8
|
interface __NapiRsAsyncGenerator<TOwner, T, TReturn, TNext> {
|
|
@@ -133,6 +133,15 @@ export declare class Model {
|
|
|
133
133
|
* Returns a JSON-serialized `ChatCompletion`. Works with any provider.
|
|
134
134
|
*/
|
|
135
135
|
generateTextAsOpenai(prompt: string, options?: string | undefined | null, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
136
|
+
/**
|
|
137
|
+
* Convert a serialized `GenerateTextResult` into a serialized
|
|
138
|
+
* `ChatCompletion` — the conversion half of `generateTextAsOpenai`.
|
|
139
|
+
*
|
|
140
|
+
* For repairing on the host (RFC-0035): patch the native result, then
|
|
141
|
+
* convert it, so the completion's tool calls are the repaired ones. This
|
|
142
|
+
* model only supplies the fallback model id.
|
|
143
|
+
*/
|
|
144
|
+
generateTextResultAsOpenai(resultJson: string): AimuxResult<string>
|
|
136
145
|
/**
|
|
137
146
|
* Stream text as OpenAI Chat Completion chunks.
|
|
138
147
|
*
|
|
@@ -235,9 +244,9 @@ export declare class TranscriptionSession {
|
|
|
235
244
|
* Push one binary audio chunk. Awaits while the internal channel is
|
|
236
245
|
* full (backpressure).
|
|
237
246
|
*/
|
|
238
|
-
pushAudio(data: Buffer): Promise<
|
|
247
|
+
pushAudio(data: Buffer): Promise<AimuxResult<undefined>>
|
|
239
248
|
/** Signal end-of-audio (idempotent). */
|
|
240
|
-
inputDone():
|
|
249
|
+
inputDone(): AimuxResult<undefined>
|
|
241
250
|
/**
|
|
242
251
|
* Pull the next transcription part (JSON string). Resolves `null` when
|
|
243
252
|
* the stream ended normally. Rejects on error — including a timeout
|
|
@@ -264,12 +273,47 @@ export declare class VideoModel {
|
|
|
264
273
|
generate(optsJson: string, bridge?: AbortBridge | undefined | null): Promise<string>
|
|
265
274
|
}
|
|
266
275
|
|
|
276
|
+
/**
|
|
277
|
+
* Register the canonical JS error constructors for this Node environment.
|
|
278
|
+
*
|
|
279
|
+
* Keeping the constructors in the environment, rather than a process-global,
|
|
280
|
+
* preserves class identity and keeps Worker environments isolated.
|
|
281
|
+
*/
|
|
282
|
+
export declare function __registerErrorClasses(constructors: object): void
|
|
283
|
+
|
|
267
284
|
/** Create an Anthropic model instance. */
|
|
268
285
|
export declare function anthropic(apiKey: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
269
286
|
|
|
270
287
|
/** Create an Anthropic-on-AWS language model instance (API key + region). */
|
|
271
288
|
export declare function anthropicAws(apiKey: string, region: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
272
289
|
|
|
290
|
+
/**
|
|
291
|
+
* Resolve one invalid tool call against a host's repair reply.
|
|
292
|
+
*
|
|
293
|
+
* `optsJson` is the same string the call was generated with; the tool set
|
|
294
|
+
* comes from it. `replyJson` is `{"type":"repaired","tool_call":{…}}`,
|
|
295
|
+
* `{"type":"unchanged"}`, or `{"type":"failed","message":"…"}`. Returns the
|
|
296
|
+
* resulting `ToolCall` JSON — valid, or invalid carrying a nested
|
|
297
|
+
* `ToolCallRepairError`.
|
|
298
|
+
*
|
|
299
|
+
* Options carrying no tools throw `InvalidArgumentError`: such a call is not
|
|
300
|
+
* repairable, and `toolCallRepairContext` already said so by returning
|
|
301
|
+
* `"null"`.
|
|
302
|
+
*/
|
|
303
|
+
export declare function applyToolCallRepair(toolCallJson: string, optsJson: string | undefined | null, replyJson: string): AimuxResult<string>
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Apply a repair reply to a serialized `GenerateTextResult` or
|
|
307
|
+
* `GenerateObjectResult`, rewriting both `tool_calls` and the matching
|
|
308
|
+
* `response_messages` tool-call part. `optsJson` is the same string the call
|
|
309
|
+
* was generated with.
|
|
310
|
+
*
|
|
311
|
+
* The OpenAI-shaped result has no equivalent: it carries no `invalid` /
|
|
312
|
+
* `error`, so repair is driven from the native result, which
|
|
313
|
+
* `Model.generateTextResultAsOpenai` then converts.
|
|
314
|
+
*/
|
|
315
|
+
export declare function applyToolCallRepairToResult(resultJson: string, optsJson: string | undefined | null, toolCallId: string, replyJson: string): AimuxResult<string>
|
|
316
|
+
|
|
273
317
|
/**
|
|
274
318
|
* Create an Azure OpenAI language model instance (API key + resource name).
|
|
275
319
|
*
|
|
@@ -354,8 +398,10 @@ export declare function initProxy(configJson: string): AimuxResult<undefined>
|
|
|
354
398
|
/**
|
|
355
399
|
* 启动录制(RFC-0023 P1/P2):把完整 `Recording` 写 JSONL 到 `{dir}/recordings.jsonl`
|
|
356
400
|
* (目录自动创建)。录制 **opt-in**;再次调用(不同 dir)替换 recorder。
|
|
401
|
+
* Throws `RecordingError` (`code` = `Init` / `OpenFile` / `Spawn`) when the
|
|
402
|
+
* recorder cannot be set up; the previous recorder, if any, stays in place.
|
|
357
403
|
*/
|
|
358
|
-
export declare function initRecording(dir: string):
|
|
404
|
+
export declare function initRecording(dir: string): AimuxResult<undefined>
|
|
359
405
|
|
|
360
406
|
/**
|
|
361
407
|
* 启动内存有界录制(RFC-0023 P6):`RingRecorder`,FIFO 淘汰,丢弃计数可查。
|
|
@@ -454,13 +500,23 @@ export declare function recordingFlush(): void
|
|
|
454
500
|
/** 停止录制:全局 recorder = None(新调用不再录制)。 */
|
|
455
501
|
export declare function recordingStop(): void
|
|
456
502
|
|
|
503
|
+
/**
|
|
504
|
+
* Flush the global recorder and **report write failures**: throws
|
|
505
|
+
* `RecordingError` (`code` = `WriterGone` / `FlushTimeout` / `Write`) when the
|
|
506
|
+
* data could not be confirmed on disk. `RecordingError` is its own class,
|
|
507
|
+
* not an `AimuxError`. Resolves normally when nothing is recording. The
|
|
508
|
+
* legacy `recordingFlush` stays and never reports.
|
|
509
|
+
*/
|
|
510
|
+
export declare function recordingTryFlush(): AimuxResult<undefined>
|
|
511
|
+
|
|
457
512
|
/**
|
|
458
513
|
* Register external OpenAI-compatible providers from a JSON config string
|
|
459
514
|
* (RFC-0020). Entries override same-named built-ins or add new ones.
|
|
460
515
|
*
|
|
461
516
|
* `configJson` shape: `{ "providers": [ { "name": "...", "base_url": "...", ... } ] }`.
|
|
462
|
-
*
|
|
463
|
-
*
|
|
517
|
+
* Malformed JSON text throws a plain `Error` (napi `InvalidArg`); a
|
|
518
|
+
* well-formed document the registry rejects (bad base_url scheme, empty
|
|
519
|
+
* name, unsupported protocol, wrong shape) throws `InvalidArgumentError`.
|
|
464
520
|
*/
|
|
465
521
|
export declare function registerProviders(configJson: string): AimuxResult<undefined>
|
|
466
522
|
|
|
@@ -485,6 +541,26 @@ export declare function startTranscriptionSession(model: TranscriptionModel, opt
|
|
|
485
541
|
/** Create a Tavily search model instance. */
|
|
486
542
|
export declare function tavilySearch(apiKey: string, baseUrl?: string | undefined | null): Promise<AimuxResult<SearchModel>>
|
|
487
543
|
|
|
544
|
+
/**
|
|
545
|
+
* Build the repair argument for one invalid tool call.
|
|
546
|
+
*
|
|
547
|
+
* `toolCallJson` is a `GenerateTextResult.tool_calls` entry with
|
|
548
|
+
* `invalid: true`. `prompt` and `optsJson` are **the same two strings the
|
|
549
|
+
* call was generated with** (`generateText` / `streamText`); messages,
|
|
550
|
+
* instructions, and the tool set are derived from them here, so no caller
|
|
551
|
+
* repeats that derivation.
|
|
552
|
+
*
|
|
553
|
+
* Returns `{tool_call, error, input_schema, tools, messages, instructions}`
|
|
554
|
+
* — the AI SDK `repairToolCall` argument, with `tool_call.input` the
|
|
555
|
+
* provider's raw argument text — or the JSON literal `"null"` when the
|
|
556
|
+
* options carried no tools: as in the AI SDK, a call made without a tool set
|
|
557
|
+
* is never repaired, and the caller skips it. `"null"` is a success.
|
|
558
|
+
*
|
|
559
|
+
* Pure and synchronous: no model, no network. Throws `InvalidArgumentError`
|
|
560
|
+
* when the call is not an invalid one.
|
|
561
|
+
*/
|
|
562
|
+
export declare function toolCallRepairContext(toolCallJson: string, prompt: string, optsJson?: string | undefined | null): AimuxResult<string>
|
|
563
|
+
|
|
488
564
|
/** Create a Vertex AI language model instance (GCP bearer token). */
|
|
489
565
|
export declare function vertex(accessToken: string, project: string, location: string, modelId: string, config?: string | ProviderConfig | undefined | null): Promise<AimuxResult<Model>>
|
|
490
566
|
|