@opencode-ai/ai 0.0.0-dev-17929 → 0.0.0-dev-17944
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/protocols/index.d.ts +1 -0
- package/dist/protocols/index.js +1 -0
- package/dist/protocols/open-responses-channel.d.ts +0 -5
- package/dist/protocols/open-responses-channel.js +8 -1
- package/dist/protocols/{openai-responses-channel.d.ts → open-responses-continuation.d.ts} +1 -1
- package/dist/protocols/{openai-responses-channel.js → open-responses-continuation.js} +2 -2
- package/dist/protocols/open-responses.d.ts +51 -35
- package/dist/protocols/open-responses.js +62 -58
- package/dist/protocols/openai-compatible-responses.d.ts +8 -5
- package/dist/protocols/openai-responses.d.ts +80 -117
- package/dist/protocols/openai-responses.js +21 -68
- package/dist/protocols/utils/responses-hosted-tools.d.ts +27 -0
- package/dist/protocols/utils/responses-hosted-tools.js +32 -0
- package/dist/protocols/xai-responses.d.ts +174 -0
- package/dist/protocols/xai-responses.js +49 -0
- package/dist/provider-error.d.ts +1 -0
- package/dist/provider-error.js +4 -2
- package/dist/providers/amazon-bedrock-mantle.d.ts +8 -14
- package/dist/providers/azure.d.ts +8 -14
- package/dist/providers/google-vertex-responses.d.ts +8 -5
- package/dist/providers/openai-compatible-responses.d.ts +8 -5
- package/dist/providers/openai.d.ts +8 -14
- package/dist/providers/xai.d.ts +1 -135
- package/dist/providers/xai.js +4 -3
- package/dist/schema/errors.d.ts +1 -0
- package/dist/schema/errors.js +3 -0
- package/package.json +3 -3
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Protocol } from "../route/protocol.js";
|
|
2
|
+
import { OpenResponses } from "./open-responses.js";
|
|
3
|
+
export declare const protocol: Protocol<{
|
|
4
|
+
readonly input: readonly ({
|
|
5
|
+
readonly type: "reasoning";
|
|
6
|
+
readonly summary: readonly {
|
|
7
|
+
readonly type: "summary_text";
|
|
8
|
+
readonly text: string;
|
|
9
|
+
}[];
|
|
10
|
+
readonly id?: string | undefined;
|
|
11
|
+
readonly encrypted_content?: string | null | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
readonly type: "item_reference";
|
|
14
|
+
readonly id: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly role: "system";
|
|
17
|
+
readonly content: string;
|
|
18
|
+
} | {
|
|
19
|
+
readonly role: "developer";
|
|
20
|
+
readonly content: string;
|
|
21
|
+
} | {
|
|
22
|
+
readonly role: "user";
|
|
23
|
+
readonly content: readonly ({
|
|
24
|
+
readonly type: "input_image";
|
|
25
|
+
readonly image_url: string;
|
|
26
|
+
} | {
|
|
27
|
+
readonly type: "input_file";
|
|
28
|
+
readonly filename: string;
|
|
29
|
+
readonly file_data?: string | undefined;
|
|
30
|
+
readonly file_url?: string | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: "input_text";
|
|
33
|
+
readonly text: string;
|
|
34
|
+
})[];
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: "message";
|
|
37
|
+
readonly content: readonly {
|
|
38
|
+
readonly type: "output_text";
|
|
39
|
+
readonly text: string;
|
|
40
|
+
}[];
|
|
41
|
+
readonly role: "assistant";
|
|
42
|
+
readonly id?: string | undefined;
|
|
43
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: "function_call";
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly arguments: string;
|
|
48
|
+
readonly call_id: string;
|
|
49
|
+
readonly id?: string | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: "function_call_output";
|
|
52
|
+
readonly call_id: string;
|
|
53
|
+
readonly output: string | readonly ({
|
|
54
|
+
readonly type: "input_image";
|
|
55
|
+
readonly image_url: string;
|
|
56
|
+
} | {
|
|
57
|
+
readonly type: "input_file";
|
|
58
|
+
readonly filename: string;
|
|
59
|
+
readonly file_data?: string | undefined;
|
|
60
|
+
readonly file_url?: string | undefined;
|
|
61
|
+
} | {
|
|
62
|
+
readonly type: "input_text";
|
|
63
|
+
readonly text: string;
|
|
64
|
+
} | {
|
|
65
|
+
readonly type: "input_video";
|
|
66
|
+
readonly video_url: string;
|
|
67
|
+
})[];
|
|
68
|
+
})[];
|
|
69
|
+
readonly model: string;
|
|
70
|
+
readonly stream: true;
|
|
71
|
+
readonly metadata?: {
|
|
72
|
+
readonly [x: string]: string;
|
|
73
|
+
} | undefined;
|
|
74
|
+
readonly instructions?: string | undefined;
|
|
75
|
+
readonly reasoning?: {
|
|
76
|
+
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
77
|
+
readonly effort?: import("./utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
78
|
+
} | undefined;
|
|
79
|
+
readonly tools?: readonly {
|
|
80
|
+
readonly type: "function";
|
|
81
|
+
readonly description: string;
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly parameters: {
|
|
84
|
+
readonly [x: string]: unknown;
|
|
85
|
+
};
|
|
86
|
+
readonly strict?: boolean | undefined;
|
|
87
|
+
}[] | undefined;
|
|
88
|
+
readonly text?: {
|
|
89
|
+
readonly verbosity?: import("./utils/open-responses-options.js").TextVerbosity | undefined;
|
|
90
|
+
} | undefined;
|
|
91
|
+
readonly temperature?: number | undefined;
|
|
92
|
+
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
93
|
+
readonly type: "function";
|
|
94
|
+
readonly name: string;
|
|
95
|
+
} | {
|
|
96
|
+
readonly type: "allowed_tools";
|
|
97
|
+
readonly mode: "required" | "auto" | "none";
|
|
98
|
+
readonly tools: readonly {
|
|
99
|
+
readonly type: "function";
|
|
100
|
+
readonly name: string;
|
|
101
|
+
}[];
|
|
102
|
+
} | undefined;
|
|
103
|
+
readonly top_p?: number | undefined;
|
|
104
|
+
readonly store?: boolean | undefined;
|
|
105
|
+
readonly include?: readonly import("./utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
106
|
+
readonly truncation?: "auto" | "disabled" | undefined;
|
|
107
|
+
readonly stream_options?: {
|
|
108
|
+
readonly include_obfuscation?: boolean | undefined;
|
|
109
|
+
} | undefined;
|
|
110
|
+
readonly prompt_cache_key?: string | undefined;
|
|
111
|
+
readonly frequency_penalty?: number | undefined;
|
|
112
|
+
readonly presence_penalty?: number | undefined;
|
|
113
|
+
readonly safety_identifier?: string | undefined;
|
|
114
|
+
readonly top_logprobs?: number | undefined;
|
|
115
|
+
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
116
|
+
readonly max_output_tokens?: number | undefined;
|
|
117
|
+
readonly max_tool_calls?: number | undefined;
|
|
118
|
+
readonly parallel_tool_calls?: boolean | undefined;
|
|
119
|
+
}, string, {
|
|
120
|
+
readonly [x: string]: unknown;
|
|
121
|
+
readonly type: string;
|
|
122
|
+
readonly status?: unknown;
|
|
123
|
+
readonly code?: string | null | undefined;
|
|
124
|
+
readonly message?: string | undefined;
|
|
125
|
+
readonly headers?: unknown;
|
|
126
|
+
readonly text?: string | undefined;
|
|
127
|
+
readonly error?: {
|
|
128
|
+
readonly type?: string | null | undefined;
|
|
129
|
+
readonly code?: string | null | undefined;
|
|
130
|
+
readonly message?: string | null | undefined;
|
|
131
|
+
readonly param?: string | null | undefined;
|
|
132
|
+
} | null | undefined;
|
|
133
|
+
readonly item?: {
|
|
134
|
+
readonly [x: string]: unknown;
|
|
135
|
+
readonly type: string;
|
|
136
|
+
readonly id?: string | undefined;
|
|
137
|
+
readonly name?: string | undefined;
|
|
138
|
+
readonly arguments?: string | undefined;
|
|
139
|
+
readonly encrypted_content?: string | null | undefined;
|
|
140
|
+
readonly call_id?: string | undefined;
|
|
141
|
+
} | undefined;
|
|
142
|
+
readonly delta?: string | undefined;
|
|
143
|
+
readonly response?: {
|
|
144
|
+
readonly [x: string]: unknown;
|
|
145
|
+
readonly id?: string | undefined;
|
|
146
|
+
readonly error?: {
|
|
147
|
+
readonly type?: string | null | undefined;
|
|
148
|
+
readonly code?: string | null | undefined;
|
|
149
|
+
readonly message?: string | null | undefined;
|
|
150
|
+
readonly param?: string | null | undefined;
|
|
151
|
+
} | null | undefined;
|
|
152
|
+
readonly usage?: {
|
|
153
|
+
readonly input_tokens?: number | undefined;
|
|
154
|
+
readonly output_tokens?: number | undefined;
|
|
155
|
+
readonly output_tokens_details?: {
|
|
156
|
+
readonly reasoning_tokens?: number | undefined;
|
|
157
|
+
} | null | undefined;
|
|
158
|
+
readonly total_tokens?: number | undefined;
|
|
159
|
+
readonly input_tokens_details?: {
|
|
160
|
+
readonly cached_tokens?: number | undefined;
|
|
161
|
+
readonly cache_write_tokens?: number | undefined;
|
|
162
|
+
} | null | undefined;
|
|
163
|
+
} | null | undefined;
|
|
164
|
+
readonly service_tier?: string | null | undefined;
|
|
165
|
+
readonly incomplete_details?: {
|
|
166
|
+
readonly reason?: string | undefined;
|
|
167
|
+
} | null | undefined;
|
|
168
|
+
} | undefined;
|
|
169
|
+
readonly param?: string | null | undefined;
|
|
170
|
+
readonly status_code?: unknown;
|
|
171
|
+
readonly item_id?: string | undefined;
|
|
172
|
+
readonly summary_index?: number | undefined;
|
|
173
|
+
}, OpenResponses.ParserState>;
|
|
174
|
+
export * as XAIResponses from "./xai-responses.js";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { Protocol } from "../route/protocol.js";
|
|
3
|
+
import { OpenResponses } from "./open-responses.js";
|
|
4
|
+
import { ProviderShared } from "./shared.js";
|
|
5
|
+
import { ResponsesHostedTools } from "./utils/responses-hosted-tools.js";
|
|
6
|
+
const ADAPTER = "xai-responses";
|
|
7
|
+
const NAME = "xAI Responses";
|
|
8
|
+
const extension = {
|
|
9
|
+
id: ADAPTER,
|
|
10
|
+
name: NAME,
|
|
11
|
+
};
|
|
12
|
+
const HOSTED_TOOLS = {
|
|
13
|
+
web_search_call: { name: "web_search", input: (item) => item.action ?? {} },
|
|
14
|
+
x_search_call: { name: "x_search", input: (item) => item.action ?? {} },
|
|
15
|
+
file_search_call: { name: "file_search", input: (item) => ({ queries: item.queries ?? [] }) },
|
|
16
|
+
code_interpreter_call: {
|
|
17
|
+
name: "code_interpreter",
|
|
18
|
+
input: (item) => ({ code: item.code, container_id: item.container_id }),
|
|
19
|
+
},
|
|
20
|
+
image_generation_call: { name: "image_generation", input: () => ({}) },
|
|
21
|
+
mcp_call: {
|
|
22
|
+
name: "mcp",
|
|
23
|
+
input: (item) => ({ server_label: item.server_label, name: item.name, arguments: item.arguments }),
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const step = (state, event) => {
|
|
27
|
+
if (event.type === "response.reasoning_text.delta" || event.type === "response.reasoning_summary.delta")
|
|
28
|
+
return event.item_id
|
|
29
|
+
? Effect.succeed(OpenResponses.onReasoningDelta(state, event, event.item_id))
|
|
30
|
+
: ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
|
|
31
|
+
if (event.type === "response.reasoning_text.done" || event.type === "response.reasoning_summary.done")
|
|
32
|
+
return event.item_id
|
|
33
|
+
? Effect.succeed(OpenResponses.onReasoningDone(state, event))
|
|
34
|
+
: ProviderShared.eventError(ADAPTER, `${event.type} is missing item_id`);
|
|
35
|
+
if (event.type === "response.output_item.done" && event.item && ResponsesHostedTools.isItem(event.item, HOSTED_TOOLS))
|
|
36
|
+
return ResponsesHostedTools.onDone(state, event.item, HOSTED_TOOLS);
|
|
37
|
+
return OpenResponses.step(state, event);
|
|
38
|
+
};
|
|
39
|
+
export const protocol = Protocol.make({
|
|
40
|
+
id: ADAPTER,
|
|
41
|
+
body: OpenResponses.protocol.body,
|
|
42
|
+
stream: {
|
|
43
|
+
event: OpenResponses.protocol.stream.event,
|
|
44
|
+
initial: (request) => OpenResponses.initial(request, extension),
|
|
45
|
+
step,
|
|
46
|
+
terminal: OpenResponses.terminal,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
export * as XAIResponses from "./xai-responses.js";
|
package/dist/provider-error.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export interface ProviderFailure {
|
|
|
6
6
|
readonly message: string;
|
|
7
7
|
readonly status?: number | undefined;
|
|
8
8
|
readonly code?: string | undefined;
|
|
9
|
+
readonly rawBody?: string | undefined;
|
|
9
10
|
readonly retryAfterMs?: number | undefined;
|
|
10
11
|
readonly rateLimit?: HttpRateLimitDetails | undefined;
|
|
11
12
|
readonly http?: HttpContext | undefined;
|
package/dist/provider-error.js
CHANGED
|
@@ -56,11 +56,13 @@ const NETWORK_ERROR_TEXT = /network[-_\s]error/i;
|
|
|
56
56
|
// Keep HTTP failures and provider-reported stream failures on one typed path so
|
|
57
57
|
// session retry policy never needs provider-specific string matching.
|
|
58
58
|
export function classifyProviderFailure(input) {
|
|
59
|
-
const body = input.http?.body ?? "";
|
|
59
|
+
const body = input.http?.body ?? input.rawBody ?? "";
|
|
60
60
|
const codes = [input.code, ...providerCodes(body), ...providerCodes(input.message)]
|
|
61
61
|
.filter((code) => code !== undefined)
|
|
62
62
|
.map((code) => code.toLowerCase());
|
|
63
|
-
|
|
63
|
+
// Scan the raw payload too so signals missing from the summary message
|
|
64
|
+
// (e.g. overflow phrases nested in a JSON error body) still classify.
|
|
65
|
+
const text = [input.message, body].filter((value) => value.length > 0).join("\n");
|
|
64
66
|
const common = { message: input.message, providerMetadata: input.providerMetadata, http: input.http };
|
|
65
67
|
const clientScoped = input.status === undefined || (input.status >= 400 && input.status < 500);
|
|
66
68
|
if (clientScoped &&
|
|
@@ -141,8 +141,8 @@ export declare const routes: (RouteDef<{
|
|
|
141
141
|
} | {
|
|
142
142
|
readonly type: "input_file";
|
|
143
143
|
readonly filename: string;
|
|
144
|
-
readonly file_data
|
|
145
|
-
readonly
|
|
144
|
+
readonly file_data?: string | undefined;
|
|
145
|
+
readonly file_url?: string | undefined;
|
|
146
146
|
} | {
|
|
147
147
|
readonly type: "input_text";
|
|
148
148
|
readonly text: string;
|
|
@@ -155,7 +155,7 @@ export declare const routes: (RouteDef<{
|
|
|
155
155
|
}[];
|
|
156
156
|
readonly role: "assistant";
|
|
157
157
|
readonly id?: string | undefined;
|
|
158
|
-
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
158
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
159
159
|
} | {
|
|
160
160
|
readonly type: "function_call";
|
|
161
161
|
readonly name: string;
|
|
@@ -171,21 +171,15 @@ export declare const routes: (RouteDef<{
|
|
|
171
171
|
} | {
|
|
172
172
|
readonly type: "input_file";
|
|
173
173
|
readonly filename: string;
|
|
174
|
-
readonly file_data
|
|
175
|
-
readonly
|
|
174
|
+
readonly file_data?: string | undefined;
|
|
175
|
+
readonly file_url?: string | undefined;
|
|
176
176
|
} | {
|
|
177
177
|
readonly type: "input_text";
|
|
178
178
|
readonly text: string;
|
|
179
|
+
} | {
|
|
180
|
+
readonly type: "input_video";
|
|
181
|
+
readonly video_url: string;
|
|
179
182
|
})[];
|
|
180
|
-
} | {
|
|
181
|
-
readonly type: "message";
|
|
182
|
-
readonly content: readonly {
|
|
183
|
-
readonly type: "output_text";
|
|
184
|
-
readonly text: string;
|
|
185
|
-
}[];
|
|
186
|
-
readonly role: "assistant";
|
|
187
|
-
readonly id?: string | undefined;
|
|
188
|
-
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
189
183
|
})[];
|
|
190
184
|
readonly model: string;
|
|
191
185
|
readonly stream: true;
|
|
@@ -144,8 +144,8 @@ export declare const routes: (RouteDef<{
|
|
|
144
144
|
} | {
|
|
145
145
|
readonly type: "input_file";
|
|
146
146
|
readonly filename: string;
|
|
147
|
-
readonly file_data
|
|
148
|
-
readonly
|
|
147
|
+
readonly file_data?: string | undefined;
|
|
148
|
+
readonly file_url?: string | undefined;
|
|
149
149
|
} | {
|
|
150
150
|
readonly type: "input_text";
|
|
151
151
|
readonly text: string;
|
|
@@ -158,7 +158,7 @@ export declare const routes: (RouteDef<{
|
|
|
158
158
|
}[];
|
|
159
159
|
readonly role: "assistant";
|
|
160
160
|
readonly id?: string | undefined;
|
|
161
|
-
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
161
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
162
162
|
} | {
|
|
163
163
|
readonly type: "function_call";
|
|
164
164
|
readonly name: string;
|
|
@@ -174,21 +174,15 @@ export declare const routes: (RouteDef<{
|
|
|
174
174
|
} | {
|
|
175
175
|
readonly type: "input_file";
|
|
176
176
|
readonly filename: string;
|
|
177
|
-
readonly file_data
|
|
178
|
-
readonly
|
|
177
|
+
readonly file_data?: string | undefined;
|
|
178
|
+
readonly file_url?: string | undefined;
|
|
179
179
|
} | {
|
|
180
180
|
readonly type: "input_text";
|
|
181
181
|
readonly text: string;
|
|
182
|
+
} | {
|
|
183
|
+
readonly type: "input_video";
|
|
184
|
+
readonly video_url: string;
|
|
182
185
|
})[];
|
|
183
|
-
} | {
|
|
184
|
-
readonly type: "message";
|
|
185
|
-
readonly content: readonly {
|
|
186
|
-
readonly type: "output_text";
|
|
187
|
-
readonly text: string;
|
|
188
|
-
}[];
|
|
189
|
-
readonly role: "assistant";
|
|
190
|
-
readonly id?: string | undefined;
|
|
191
|
-
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
192
186
|
})[];
|
|
193
187
|
readonly model: string;
|
|
194
188
|
readonly stream: true;
|
|
@@ -44,8 +44,8 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
44
44
|
} | {
|
|
45
45
|
readonly type: "input_file";
|
|
46
46
|
readonly filename: string;
|
|
47
|
-
readonly file_data
|
|
48
|
-
readonly
|
|
47
|
+
readonly file_data?: string | undefined;
|
|
48
|
+
readonly file_url?: string | undefined;
|
|
49
49
|
} | {
|
|
50
50
|
readonly type: "input_text";
|
|
51
51
|
readonly text: string;
|
|
@@ -58,7 +58,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
58
58
|
}[];
|
|
59
59
|
readonly role: "assistant";
|
|
60
60
|
readonly id?: string | undefined;
|
|
61
|
-
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
61
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
62
62
|
} | {
|
|
63
63
|
readonly type: "function_call";
|
|
64
64
|
readonly name: string;
|
|
@@ -74,11 +74,14 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
74
74
|
} | {
|
|
75
75
|
readonly type: "input_file";
|
|
76
76
|
readonly filename: string;
|
|
77
|
-
readonly file_data
|
|
78
|
-
readonly
|
|
77
|
+
readonly file_data?: string | undefined;
|
|
78
|
+
readonly file_url?: string | undefined;
|
|
79
79
|
} | {
|
|
80
80
|
readonly type: "input_text";
|
|
81
81
|
readonly text: string;
|
|
82
|
+
} | {
|
|
83
|
+
readonly type: "input_video";
|
|
84
|
+
readonly video_url: string;
|
|
82
85
|
})[];
|
|
83
86
|
})[];
|
|
84
87
|
readonly model: string;
|
|
@@ -42,8 +42,8 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
42
42
|
} | {
|
|
43
43
|
readonly type: "input_file";
|
|
44
44
|
readonly filename: string;
|
|
45
|
-
readonly file_data
|
|
46
|
-
readonly
|
|
45
|
+
readonly file_data?: string | undefined;
|
|
46
|
+
readonly file_url?: string | undefined;
|
|
47
47
|
} | {
|
|
48
48
|
readonly type: "input_text";
|
|
49
49
|
readonly text: string;
|
|
@@ -56,7 +56,7 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
56
56
|
}[];
|
|
57
57
|
readonly role: "assistant";
|
|
58
58
|
readonly id?: string | undefined;
|
|
59
|
-
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
59
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
60
60
|
} | {
|
|
61
61
|
readonly type: "function_call";
|
|
62
62
|
readonly name: string;
|
|
@@ -72,11 +72,14 @@ export declare const routes: import("../route/client.js").Route<{
|
|
|
72
72
|
} | {
|
|
73
73
|
readonly type: "input_file";
|
|
74
74
|
readonly filename: string;
|
|
75
|
-
readonly file_data
|
|
76
|
-
readonly
|
|
75
|
+
readonly file_data?: string | undefined;
|
|
76
|
+
readonly file_url?: string | undefined;
|
|
77
77
|
} | {
|
|
78
78
|
readonly type: "input_text";
|
|
79
79
|
readonly text: string;
|
|
80
|
+
} | {
|
|
81
|
+
readonly type: "input_video";
|
|
82
|
+
readonly video_url: string;
|
|
80
83
|
})[];
|
|
81
84
|
})[];
|
|
82
85
|
readonly model: string;
|
|
@@ -129,8 +129,8 @@ export declare const routes: (Route<{
|
|
|
129
129
|
} | {
|
|
130
130
|
readonly type: "input_file";
|
|
131
131
|
readonly filename: string;
|
|
132
|
-
readonly file_data
|
|
133
|
-
readonly
|
|
132
|
+
readonly file_data?: string | undefined;
|
|
133
|
+
readonly file_url?: string | undefined;
|
|
134
134
|
} | {
|
|
135
135
|
readonly type: "input_text";
|
|
136
136
|
readonly text: string;
|
|
@@ -143,7 +143,7 @@ export declare const routes: (Route<{
|
|
|
143
143
|
}[];
|
|
144
144
|
readonly role: "assistant";
|
|
145
145
|
readonly id?: string | undefined;
|
|
146
|
-
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
146
|
+
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
147
147
|
} | {
|
|
148
148
|
readonly type: "function_call";
|
|
149
149
|
readonly name: string;
|
|
@@ -159,21 +159,15 @@ export declare const routes: (Route<{
|
|
|
159
159
|
} | {
|
|
160
160
|
readonly type: "input_file";
|
|
161
161
|
readonly filename: string;
|
|
162
|
-
readonly file_data
|
|
163
|
-
readonly
|
|
162
|
+
readonly file_data?: string | undefined;
|
|
163
|
+
readonly file_url?: string | undefined;
|
|
164
164
|
} | {
|
|
165
165
|
readonly type: "input_text";
|
|
166
166
|
readonly text: string;
|
|
167
|
+
} | {
|
|
168
|
+
readonly type: "input_video";
|
|
169
|
+
readonly video_url: string;
|
|
167
170
|
})[];
|
|
168
|
-
} | {
|
|
169
|
-
readonly type: "message";
|
|
170
|
-
readonly content: readonly {
|
|
171
|
-
readonly type: "output_text";
|
|
172
|
-
readonly text: string;
|
|
173
|
-
}[];
|
|
174
|
-
readonly role: "assistant";
|
|
175
|
-
readonly id?: string | undefined;
|
|
176
|
-
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
177
171
|
})[];
|
|
178
172
|
readonly model: string;
|
|
179
173
|
readonly stream: true;
|
package/dist/providers/xai.d.ts
CHANGED
|
@@ -111,141 +111,7 @@ export declare const routes: (Route<{
|
|
|
111
111
|
readonly reasoning_effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
112
112
|
readonly frequency_penalty?: number | undefined;
|
|
113
113
|
readonly presence_penalty?: number | undefined;
|
|
114
|
-
}, import("../route/transport/http.js").HttpPrepared<string>> | Route<
|
|
115
|
-
readonly input: readonly ({
|
|
116
|
-
readonly type: "reasoning";
|
|
117
|
-
readonly summary: readonly {
|
|
118
|
-
readonly type: "summary_text";
|
|
119
|
-
readonly text: string;
|
|
120
|
-
}[];
|
|
121
|
-
readonly id?: string | undefined;
|
|
122
|
-
readonly encrypted_content?: string | null | undefined;
|
|
123
|
-
} | {
|
|
124
|
-
readonly type: "item_reference";
|
|
125
|
-
readonly id: string;
|
|
126
|
-
} | {
|
|
127
|
-
readonly role: "system";
|
|
128
|
-
readonly content: string;
|
|
129
|
-
} | {
|
|
130
|
-
readonly role: "developer";
|
|
131
|
-
readonly content: string;
|
|
132
|
-
} | {
|
|
133
|
-
readonly role: "user";
|
|
134
|
-
readonly content: readonly ({
|
|
135
|
-
readonly type: "input_image";
|
|
136
|
-
readonly image_url: string;
|
|
137
|
-
} | {
|
|
138
|
-
readonly type: "input_file";
|
|
139
|
-
readonly filename: string;
|
|
140
|
-
readonly file_data: string;
|
|
141
|
-
readonly mime_type?: string | undefined;
|
|
142
|
-
} | {
|
|
143
|
-
readonly type: "input_text";
|
|
144
|
-
readonly text: string;
|
|
145
|
-
})[];
|
|
146
|
-
} | {
|
|
147
|
-
readonly type: "message";
|
|
148
|
-
readonly content: readonly {
|
|
149
|
-
readonly type: "output_text";
|
|
150
|
-
readonly text: string;
|
|
151
|
-
}[];
|
|
152
|
-
readonly role: "assistant";
|
|
153
|
-
readonly id?: string | undefined;
|
|
154
|
-
readonly phase?: "commentary" | "final_answer" | undefined;
|
|
155
|
-
} | {
|
|
156
|
-
readonly type: "function_call";
|
|
157
|
-
readonly name: string;
|
|
158
|
-
readonly arguments: string;
|
|
159
|
-
readonly call_id: string;
|
|
160
|
-
readonly id?: string | undefined;
|
|
161
|
-
} | {
|
|
162
|
-
readonly type: "function_call_output";
|
|
163
|
-
readonly call_id: string;
|
|
164
|
-
readonly output: string | readonly ({
|
|
165
|
-
readonly type: "input_image";
|
|
166
|
-
readonly image_url: string;
|
|
167
|
-
} | {
|
|
168
|
-
readonly type: "input_file";
|
|
169
|
-
readonly filename: string;
|
|
170
|
-
readonly file_data: string;
|
|
171
|
-
readonly mime_type?: string | undefined;
|
|
172
|
-
} | {
|
|
173
|
-
readonly type: "input_text";
|
|
174
|
-
readonly text: string;
|
|
175
|
-
})[];
|
|
176
|
-
} | {
|
|
177
|
-
readonly type: "message";
|
|
178
|
-
readonly content: readonly {
|
|
179
|
-
readonly type: "output_text";
|
|
180
|
-
readonly text: string;
|
|
181
|
-
}[];
|
|
182
|
-
readonly role: "assistant";
|
|
183
|
-
readonly id?: string | undefined;
|
|
184
|
-
readonly phase?: "commentary" | "final_answer" | null | undefined;
|
|
185
|
-
})[];
|
|
186
|
-
readonly model: string;
|
|
187
|
-
readonly stream: true;
|
|
188
|
-
readonly metadata?: {
|
|
189
|
-
readonly [x: string]: string;
|
|
190
|
-
} | undefined;
|
|
191
|
-
readonly instructions?: string | undefined;
|
|
192
|
-
readonly reasoning?: {
|
|
193
|
-
readonly summary?: "auto" | "concise" | "detailed" | undefined;
|
|
194
|
-
readonly effort?: import("../protocols/utils/open-responses-options.js").ReasoningEffort | undefined;
|
|
195
|
-
} | undefined;
|
|
196
|
-
readonly tools?: readonly ({
|
|
197
|
-
readonly type: "function";
|
|
198
|
-
readonly description: string;
|
|
199
|
-
readonly name: string;
|
|
200
|
-
readonly parameters: {
|
|
201
|
-
readonly [x: string]: unknown;
|
|
202
|
-
};
|
|
203
|
-
readonly strict?: boolean | undefined;
|
|
204
|
-
} | {
|
|
205
|
-
readonly type: "image_generation";
|
|
206
|
-
readonly size?: string | undefined;
|
|
207
|
-
readonly action?: "generate" | "auto" | "edit" | undefined;
|
|
208
|
-
readonly output_format?: "png" | "jpeg" | "webp" | undefined;
|
|
209
|
-
readonly quality?: "auto" | "low" | "medium" | "high" | undefined;
|
|
210
|
-
readonly background?: "auto" | "opaque" | "transparent" | undefined;
|
|
211
|
-
readonly output_compression?: number | undefined;
|
|
212
|
-
readonly input_fidelity?: "low" | "high" | undefined;
|
|
213
|
-
readonly partial_images?: number | undefined;
|
|
214
|
-
})[] | undefined;
|
|
215
|
-
readonly text?: {
|
|
216
|
-
readonly verbosity?: import("../protocols/utils/open-responses-options.js").TextVerbosity | undefined;
|
|
217
|
-
} | undefined;
|
|
218
|
-
readonly temperature?: number | undefined;
|
|
219
|
-
readonly tool_choice?: "required" | "auto" | "none" | {
|
|
220
|
-
readonly type: "function";
|
|
221
|
-
readonly name: string;
|
|
222
|
-
} | {
|
|
223
|
-
readonly type: "allowed_tools";
|
|
224
|
-
readonly mode: "required" | "auto" | "none";
|
|
225
|
-
readonly tools: readonly {
|
|
226
|
-
readonly type: "function";
|
|
227
|
-
readonly name: string;
|
|
228
|
-
}[];
|
|
229
|
-
} | {
|
|
230
|
-
readonly type: "image_generation";
|
|
231
|
-
} | undefined;
|
|
232
|
-
readonly top_p?: number | undefined;
|
|
233
|
-
readonly store?: boolean | undefined;
|
|
234
|
-
readonly include?: readonly import("../protocols/utils/open-responses-options.js").ResponseIncludable[] | undefined;
|
|
235
|
-
readonly truncation?: "auto" | "disabled" | undefined;
|
|
236
|
-
readonly stream_options?: {
|
|
237
|
-
readonly include_obfuscation?: boolean | undefined;
|
|
238
|
-
} | undefined;
|
|
239
|
-
readonly prompt_cache_key?: string | undefined;
|
|
240
|
-
readonly frequency_penalty?: number | undefined;
|
|
241
|
-
readonly presence_penalty?: number | undefined;
|
|
242
|
-
readonly safety_identifier?: string | undefined;
|
|
243
|
-
readonly top_logprobs?: number | undefined;
|
|
244
|
-
readonly service_tier?: "default" | "auto" | "flex" | "priority" | undefined;
|
|
245
|
-
readonly max_output_tokens?: number | undefined;
|
|
246
|
-
readonly max_tool_calls?: number | undefined;
|
|
247
|
-
readonly parallel_tool_calls?: boolean | undefined;
|
|
248
|
-
}, import("../protocols/open-responses-channel.js").Prepared>)[];
|
|
114
|
+
}, import("../route/transport/http.js").HttpPrepared<string>> | Route<unknown, import("../protocols/open-responses-channel.js").Prepared>)[];
|
|
249
115
|
export declare const configure: (input?: LanguageModelOptions) => {
|
|
250
116
|
id: string & import("effect/Brand").Brand<"AI.ProviderID">;
|
|
251
117
|
model: (modelID: string | ModelID) => import("../schema/options.js").LanguageModel<import("./open-responses-options.js").OpenResponsesOptionsInput>;
|
package/dist/providers/xai.js
CHANGED
|
@@ -5,7 +5,8 @@ import { HttpOptions, ProviderID } from "../schema/index.js";
|
|
|
5
5
|
import * as OpenAICompatibleProfiles from "./openai-compatible-profile.js";
|
|
6
6
|
import * as OpenAICompatibleChat from "../protocols/openai-compatible-chat.js";
|
|
7
7
|
import * as OpenAIChat from "../protocols/openai-chat.js";
|
|
8
|
-
import
|
|
8
|
+
import { OpenResponsesChannel } from "../protocols/open-responses-channel.js";
|
|
9
|
+
import { XAIResponses } from "../protocols/xai-responses.js";
|
|
9
10
|
import { XAIImages } from "../protocols/xai-images.js";
|
|
10
11
|
export const id = ProviderID.make("xai");
|
|
11
12
|
const RESPONSES_WEBSOCKET_ROTATE_AFTER_MS = 24 * 60 * 1000;
|
|
@@ -13,9 +14,9 @@ const responsesRoute = Route.make({
|
|
|
13
14
|
id: "openai-responses",
|
|
14
15
|
provider: id,
|
|
15
16
|
providerMetadataKey: "xai",
|
|
16
|
-
protocol:
|
|
17
|
+
protocol: XAIResponses.protocol,
|
|
17
18
|
endpoint: Endpoint.path("/responses", { baseURL: OpenAICompatibleProfiles.profiles.xai.baseURL }),
|
|
18
|
-
transport:
|
|
19
|
+
transport: OpenResponsesChannel.transport({
|
|
19
20
|
id: "openai-responses",
|
|
20
21
|
name: "xAI Responses",
|
|
21
22
|
rotateAfterMs: RESPONSES_WEBSOCKET_ROTATE_AFTER_MS,
|
package/dist/schema/errors.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ declare const AIError_base: Schema.Class<AIError, Schema.TaggedStruct<"AI.Error"
|
|
|
140
140
|
readonly module: Schema.String;
|
|
141
141
|
readonly method: Schema.String;
|
|
142
142
|
readonly reason: Schema.toTaggedUnion<"_tag", readonly [typeof InvalidRequestReason, typeof NoRouteReason, typeof AuthenticationReason, typeof RateLimitReason, typeof QuotaExceededReason, typeof ContentPolicyReason, typeof ProviderInternalReason, typeof TransportReason, typeof InvalidProviderOutputReason, typeof UnknownProviderReason]>;
|
|
143
|
+
readonly body: Schema.optional<Schema.String>;
|
|
143
144
|
}>, import("effect/Cause").YieldableError>;
|
|
144
145
|
export declare class AIError extends AIError_base {
|
|
145
146
|
readonly cause: InvalidRequestReason | NoRouteReason | AuthenticationReason | RateLimitReason | QuotaExceededReason | ContentPolicyReason | ProviderInternalReason | TransportReason | InvalidProviderOutputReason | UnknownProviderReason;
|
package/dist/schema/errors.js
CHANGED
|
@@ -137,6 +137,9 @@ export class AIError extends Schema.TaggedError()("AI.Error", {
|
|
|
137
137
|
module: Schema.String,
|
|
138
138
|
method: Schema.String,
|
|
139
139
|
reason: AIErrorReason,
|
|
140
|
+
// Raw provider payload as a string, so classified failures never lose the
|
|
141
|
+
// original error detail even when the pretty message is a summary.
|
|
142
|
+
body: Schema.optional(Schema.String),
|
|
140
143
|
}) {
|
|
141
144
|
cause = this.reason;
|
|
142
145
|
get message() {
|