@ai-sdk/openai 3.0.28 → 3.0.30
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/CHANGELOG.md +12 -0
- package/dist/index.d.mts +72 -1
- package/dist/index.d.ts +72 -1
- package/dist/index.js +283 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +283 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +30 -0
- package/dist/internal/index.d.ts +30 -0
- package/dist/internal/index.js +282 -12
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +282 -12
- package/dist/internal/index.mjs.map +1 -1
- package/docs/03-openai.mdx +129 -8
- package/package.json +3 -3
- package/src/image/openai-image-model.ts +46 -2
- package/src/responses/convert-to-openai-responses-input.ts +40 -7
- package/src/responses/openai-responses-api.ts +106 -1
- package/src/responses/openai-responses-language-model.ts +69 -1
- package/src/responses/openai-responses-prepare-tools.ts +114 -0
- package/src/tool/shell.ts +119 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/openai
|
|
2
2
|
|
|
3
|
+
## 3.0.30
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ff12133: feat(provider/openai): support native skills and hosted shell
|
|
8
|
+
|
|
9
|
+
## 3.0.29
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- e2ee705: feat: differentiate text vs image input tokens
|
|
14
|
+
|
|
3
15
|
## 3.0.28
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -293,6 +293,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
293
293
|
action: {
|
|
294
294
|
commands: string[];
|
|
295
295
|
};
|
|
296
|
+
} | {
|
|
297
|
+
type: "shell_call_output";
|
|
298
|
+
id: string;
|
|
299
|
+
call_id: string;
|
|
300
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
301
|
+
output: {
|
|
302
|
+
stdout: string;
|
|
303
|
+
stderr: string;
|
|
304
|
+
outcome: {
|
|
305
|
+
type: "timeout";
|
|
306
|
+
} | {
|
|
307
|
+
type: "exit";
|
|
308
|
+
exit_code: number;
|
|
309
|
+
};
|
|
310
|
+
}[];
|
|
296
311
|
};
|
|
297
312
|
} | {
|
|
298
313
|
type: "response.output_item.done";
|
|
@@ -439,6 +454,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
439
454
|
action: {
|
|
440
455
|
commands: string[];
|
|
441
456
|
};
|
|
457
|
+
} | {
|
|
458
|
+
type: "shell_call_output";
|
|
459
|
+
id: string;
|
|
460
|
+
call_id: string;
|
|
461
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
462
|
+
output: {
|
|
463
|
+
stdout: string;
|
|
464
|
+
stderr: string;
|
|
465
|
+
outcome: {
|
|
466
|
+
type: "timeout";
|
|
467
|
+
} | {
|
|
468
|
+
type: "exit";
|
|
469
|
+
exit_code: number;
|
|
470
|
+
};
|
|
471
|
+
}[];
|
|
442
472
|
};
|
|
443
473
|
} | {
|
|
444
474
|
type: "response.function_call_arguments.delta";
|
|
@@ -700,7 +730,48 @@ declare const openaiTools: {
|
|
|
700
730
|
exitCode: number;
|
|
701
731
|
};
|
|
702
732
|
}>;
|
|
703
|
-
}, {
|
|
733
|
+
}, {
|
|
734
|
+
environment?: {
|
|
735
|
+
type: "containerAuto";
|
|
736
|
+
fileIds?: string[];
|
|
737
|
+
memoryLimit?: "1g" | "4g" | "16g" | "64g";
|
|
738
|
+
networkPolicy?: {
|
|
739
|
+
type: "disabled";
|
|
740
|
+
} | {
|
|
741
|
+
type: "allowlist";
|
|
742
|
+
allowedDomains: string[];
|
|
743
|
+
domainSecrets?: Array<{
|
|
744
|
+
domain: string;
|
|
745
|
+
name: string;
|
|
746
|
+
value: string;
|
|
747
|
+
}>;
|
|
748
|
+
};
|
|
749
|
+
skills?: Array<{
|
|
750
|
+
type: "skillReference";
|
|
751
|
+
skillId: string;
|
|
752
|
+
version?: string;
|
|
753
|
+
} | {
|
|
754
|
+
type: "inline";
|
|
755
|
+
name: string;
|
|
756
|
+
description: string;
|
|
757
|
+
source: {
|
|
758
|
+
type: "base64";
|
|
759
|
+
mediaType: "application/zip";
|
|
760
|
+
data: string;
|
|
761
|
+
};
|
|
762
|
+
}>;
|
|
763
|
+
} | {
|
|
764
|
+
type: "containerReference";
|
|
765
|
+
containerId: string;
|
|
766
|
+
} | {
|
|
767
|
+
type?: "local";
|
|
768
|
+
skills?: Array<{
|
|
769
|
+
name: string;
|
|
770
|
+
description: string;
|
|
771
|
+
path: string;
|
|
772
|
+
}>;
|
|
773
|
+
};
|
|
774
|
+
}>;
|
|
704
775
|
/**
|
|
705
776
|
* Web search allows models to access up-to-date information from the internet
|
|
706
777
|
* and provide answers with sourced citations.
|
package/dist/index.d.ts
CHANGED
|
@@ -293,6 +293,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
293
293
|
action: {
|
|
294
294
|
commands: string[];
|
|
295
295
|
};
|
|
296
|
+
} | {
|
|
297
|
+
type: "shell_call_output";
|
|
298
|
+
id: string;
|
|
299
|
+
call_id: string;
|
|
300
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
301
|
+
output: {
|
|
302
|
+
stdout: string;
|
|
303
|
+
stderr: string;
|
|
304
|
+
outcome: {
|
|
305
|
+
type: "timeout";
|
|
306
|
+
} | {
|
|
307
|
+
type: "exit";
|
|
308
|
+
exit_code: number;
|
|
309
|
+
};
|
|
310
|
+
}[];
|
|
296
311
|
};
|
|
297
312
|
} | {
|
|
298
313
|
type: "response.output_item.done";
|
|
@@ -439,6 +454,21 @@ declare const openaiResponsesChunkSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
|
439
454
|
action: {
|
|
440
455
|
commands: string[];
|
|
441
456
|
};
|
|
457
|
+
} | {
|
|
458
|
+
type: "shell_call_output";
|
|
459
|
+
id: string;
|
|
460
|
+
call_id: string;
|
|
461
|
+
status: "completed" | "in_progress" | "incomplete";
|
|
462
|
+
output: {
|
|
463
|
+
stdout: string;
|
|
464
|
+
stderr: string;
|
|
465
|
+
outcome: {
|
|
466
|
+
type: "timeout";
|
|
467
|
+
} | {
|
|
468
|
+
type: "exit";
|
|
469
|
+
exit_code: number;
|
|
470
|
+
};
|
|
471
|
+
}[];
|
|
442
472
|
};
|
|
443
473
|
} | {
|
|
444
474
|
type: "response.function_call_arguments.delta";
|
|
@@ -700,7 +730,48 @@ declare const openaiTools: {
|
|
|
700
730
|
exitCode: number;
|
|
701
731
|
};
|
|
702
732
|
}>;
|
|
703
|
-
}, {
|
|
733
|
+
}, {
|
|
734
|
+
environment?: {
|
|
735
|
+
type: "containerAuto";
|
|
736
|
+
fileIds?: string[];
|
|
737
|
+
memoryLimit?: "1g" | "4g" | "16g" | "64g";
|
|
738
|
+
networkPolicy?: {
|
|
739
|
+
type: "disabled";
|
|
740
|
+
} | {
|
|
741
|
+
type: "allowlist";
|
|
742
|
+
allowedDomains: string[];
|
|
743
|
+
domainSecrets?: Array<{
|
|
744
|
+
domain: string;
|
|
745
|
+
name: string;
|
|
746
|
+
value: string;
|
|
747
|
+
}>;
|
|
748
|
+
};
|
|
749
|
+
skills?: Array<{
|
|
750
|
+
type: "skillReference";
|
|
751
|
+
skillId: string;
|
|
752
|
+
version?: string;
|
|
753
|
+
} | {
|
|
754
|
+
type: "inline";
|
|
755
|
+
name: string;
|
|
756
|
+
description: string;
|
|
757
|
+
source: {
|
|
758
|
+
type: "base64";
|
|
759
|
+
mediaType: "application/zip";
|
|
760
|
+
data: string;
|
|
761
|
+
};
|
|
762
|
+
}>;
|
|
763
|
+
} | {
|
|
764
|
+
type: "containerReference";
|
|
765
|
+
containerId: string;
|
|
766
|
+
} | {
|
|
767
|
+
type?: "local";
|
|
768
|
+
skills?: Array<{
|
|
769
|
+
name: string;
|
|
770
|
+
description: string;
|
|
771
|
+
path: string;
|
|
772
|
+
}>;
|
|
773
|
+
};
|
|
774
|
+
}>;
|
|
704
775
|
/**
|
|
705
776
|
* Web search allows models to access up-to-date information from the internet
|
|
706
777
|
* and provide answers with sourced citations.
|
package/dist/index.js
CHANGED
|
@@ -1852,15 +1852,20 @@ var OpenAIImageModel = class {
|
|
|
1852
1852
|
},
|
|
1853
1853
|
providerMetadata: {
|
|
1854
1854
|
openai: {
|
|
1855
|
-
images: response2.data.map((item) => {
|
|
1856
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1855
|
+
images: response2.data.map((item, index) => {
|
|
1856
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1857
1857
|
return {
|
|
1858
1858
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1859
1859
|
created: (_a2 = response2.created) != null ? _a2 : void 0,
|
|
1860
1860
|
size: (_b2 = response2.size) != null ? _b2 : void 0,
|
|
1861
1861
|
quality: (_c2 = response2.quality) != null ? _c2 : void 0,
|
|
1862
1862
|
background: (_d2 = response2.background) != null ? _d2 : void 0,
|
|
1863
|
-
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0
|
|
1863
|
+
outputFormat: (_e2 = response2.output_format) != null ? _e2 : void 0,
|
|
1864
|
+
...distributeTokenDetails(
|
|
1865
|
+
(_f2 = response2.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1866
|
+
index,
|
|
1867
|
+
response2.data.length
|
|
1868
|
+
)
|
|
1864
1869
|
};
|
|
1865
1870
|
})
|
|
1866
1871
|
}
|
|
@@ -1903,15 +1908,20 @@ var OpenAIImageModel = class {
|
|
|
1903
1908
|
},
|
|
1904
1909
|
providerMetadata: {
|
|
1905
1910
|
openai: {
|
|
1906
|
-
images: response.data.map((item) => {
|
|
1907
|
-
var _a2, _b2, _c2, _d2, _e2;
|
|
1911
|
+
images: response.data.map((item, index) => {
|
|
1912
|
+
var _a2, _b2, _c2, _d2, _e2, _f2;
|
|
1908
1913
|
return {
|
|
1909
1914
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {},
|
|
1910
1915
|
created: (_a2 = response.created) != null ? _a2 : void 0,
|
|
1911
1916
|
size: (_b2 = response.size) != null ? _b2 : void 0,
|
|
1912
1917
|
quality: (_c2 = response.quality) != null ? _c2 : void 0,
|
|
1913
1918
|
background: (_d2 = response.background) != null ? _d2 : void 0,
|
|
1914
|
-
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0
|
|
1919
|
+
outputFormat: (_e2 = response.output_format) != null ? _e2 : void 0,
|
|
1920
|
+
...distributeTokenDetails(
|
|
1921
|
+
(_f2 = response.usage) == null ? void 0 : _f2.input_tokens_details,
|
|
1922
|
+
index,
|
|
1923
|
+
response.data.length
|
|
1924
|
+
)
|
|
1915
1925
|
};
|
|
1916
1926
|
})
|
|
1917
1927
|
}
|
|
@@ -1919,6 +1929,23 @@ var OpenAIImageModel = class {
|
|
|
1919
1929
|
};
|
|
1920
1930
|
}
|
|
1921
1931
|
};
|
|
1932
|
+
function distributeTokenDetails(details, index, total) {
|
|
1933
|
+
if (details == null) {
|
|
1934
|
+
return {};
|
|
1935
|
+
}
|
|
1936
|
+
const result = {};
|
|
1937
|
+
if (details.image_tokens != null) {
|
|
1938
|
+
const base = Math.floor(details.image_tokens / total);
|
|
1939
|
+
const remainder = details.image_tokens - base * (total - 1);
|
|
1940
|
+
result.imageTokens = index === total - 1 ? remainder : base;
|
|
1941
|
+
}
|
|
1942
|
+
if (details.text_tokens != null) {
|
|
1943
|
+
const base = Math.floor(details.text_tokens / total);
|
|
1944
|
+
const remainder = details.text_tokens - base * (total - 1);
|
|
1945
|
+
result.textTokens = index === total - 1 ? remainder : base;
|
|
1946
|
+
}
|
|
1947
|
+
return result;
|
|
1948
|
+
}
|
|
1922
1949
|
async function fileToBlob(file) {
|
|
1923
1950
|
if (!file) return void 0;
|
|
1924
1951
|
if (file.type === "url") {
|
|
@@ -2154,6 +2181,67 @@ var shellOutputSchema = (0, import_provider_utils19.lazySchema)(
|
|
|
2154
2181
|
})
|
|
2155
2182
|
)
|
|
2156
2183
|
);
|
|
2184
|
+
var shellSkillsSchema = import_v414.z.array(
|
|
2185
|
+
import_v414.z.discriminatedUnion("type", [
|
|
2186
|
+
import_v414.z.object({
|
|
2187
|
+
type: import_v414.z.literal("skillReference"),
|
|
2188
|
+
skillId: import_v414.z.string(),
|
|
2189
|
+
version: import_v414.z.string().optional()
|
|
2190
|
+
}),
|
|
2191
|
+
import_v414.z.object({
|
|
2192
|
+
type: import_v414.z.literal("inline"),
|
|
2193
|
+
name: import_v414.z.string(),
|
|
2194
|
+
description: import_v414.z.string(),
|
|
2195
|
+
source: import_v414.z.object({
|
|
2196
|
+
type: import_v414.z.literal("base64"),
|
|
2197
|
+
mediaType: import_v414.z.literal("application/zip"),
|
|
2198
|
+
data: import_v414.z.string()
|
|
2199
|
+
})
|
|
2200
|
+
})
|
|
2201
|
+
])
|
|
2202
|
+
).optional();
|
|
2203
|
+
var shellArgsSchema = (0, import_provider_utils19.lazySchema)(
|
|
2204
|
+
() => (0, import_provider_utils19.zodSchema)(
|
|
2205
|
+
import_v414.z.object({
|
|
2206
|
+
environment: import_v414.z.union([
|
|
2207
|
+
import_v414.z.object({
|
|
2208
|
+
type: import_v414.z.literal("containerAuto"),
|
|
2209
|
+
fileIds: import_v414.z.array(import_v414.z.string()).optional(),
|
|
2210
|
+
memoryLimit: import_v414.z.enum(["1g", "4g", "16g", "64g"]).optional(),
|
|
2211
|
+
networkPolicy: import_v414.z.discriminatedUnion("type", [
|
|
2212
|
+
import_v414.z.object({ type: import_v414.z.literal("disabled") }),
|
|
2213
|
+
import_v414.z.object({
|
|
2214
|
+
type: import_v414.z.literal("allowlist"),
|
|
2215
|
+
allowedDomains: import_v414.z.array(import_v414.z.string()),
|
|
2216
|
+
domainSecrets: import_v414.z.array(
|
|
2217
|
+
import_v414.z.object({
|
|
2218
|
+
domain: import_v414.z.string(),
|
|
2219
|
+
name: import_v414.z.string(),
|
|
2220
|
+
value: import_v414.z.string()
|
|
2221
|
+
})
|
|
2222
|
+
).optional()
|
|
2223
|
+
})
|
|
2224
|
+
]).optional(),
|
|
2225
|
+
skills: shellSkillsSchema
|
|
2226
|
+
}),
|
|
2227
|
+
import_v414.z.object({
|
|
2228
|
+
type: import_v414.z.literal("containerReference"),
|
|
2229
|
+
containerId: import_v414.z.string()
|
|
2230
|
+
}),
|
|
2231
|
+
import_v414.z.object({
|
|
2232
|
+
type: import_v414.z.literal("local").optional(),
|
|
2233
|
+
skills: import_v414.z.array(
|
|
2234
|
+
import_v414.z.object({
|
|
2235
|
+
name: import_v414.z.string(),
|
|
2236
|
+
description: import_v414.z.string(),
|
|
2237
|
+
path: import_v414.z.string()
|
|
2238
|
+
})
|
|
2239
|
+
).optional()
|
|
2240
|
+
})
|
|
2241
|
+
]).optional()
|
|
2242
|
+
})
|
|
2243
|
+
)
|
|
2244
|
+
);
|
|
2157
2245
|
var shell = (0, import_provider_utils19.createProviderToolFactoryWithOutputSchema)({
|
|
2158
2246
|
id: "openai.shell",
|
|
2159
2247
|
inputSchema: shellInputSchema,
|
|
@@ -2668,8 +2756,32 @@ async function convertToOpenAIResponsesInput({
|
|
|
2668
2756
|
if (hasConversation) {
|
|
2669
2757
|
break;
|
|
2670
2758
|
}
|
|
2759
|
+
const resolvedResultToolName = toolNameMapping.toProviderToolName(
|
|
2760
|
+
part.toolName
|
|
2761
|
+
);
|
|
2762
|
+
if (hasShellTool && resolvedResultToolName === "shell") {
|
|
2763
|
+
if (part.output.type === "json") {
|
|
2764
|
+
const parsedOutput = await (0, import_provider_utils23.validateTypes)({
|
|
2765
|
+
value: part.output.value,
|
|
2766
|
+
schema: shellOutputSchema
|
|
2767
|
+
});
|
|
2768
|
+
input.push({
|
|
2769
|
+
type: "shell_call_output",
|
|
2770
|
+
call_id: part.toolCallId,
|
|
2771
|
+
output: parsedOutput.output.map((item) => ({
|
|
2772
|
+
stdout: item.stdout,
|
|
2773
|
+
stderr: item.stderr,
|
|
2774
|
+
outcome: item.outcome.type === "timeout" ? { type: "timeout" } : {
|
|
2775
|
+
type: "exit",
|
|
2776
|
+
exit_code: item.outcome.exitCode
|
|
2777
|
+
}
|
|
2778
|
+
}))
|
|
2779
|
+
});
|
|
2780
|
+
}
|
|
2781
|
+
break;
|
|
2782
|
+
}
|
|
2671
2783
|
if (store) {
|
|
2672
|
-
const itemId = (_j = (_i = (_h = part.
|
|
2784
|
+
const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
|
|
2673
2785
|
input.push({ type: "item_reference", id: itemId });
|
|
2674
2786
|
} else {
|
|
2675
2787
|
warnings.push({
|
|
@@ -3044,6 +3156,25 @@ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3044
3156
|
action: import_v419.z.object({
|
|
3045
3157
|
commands: import_v419.z.array(import_v419.z.string())
|
|
3046
3158
|
})
|
|
3159
|
+
}),
|
|
3160
|
+
import_v419.z.object({
|
|
3161
|
+
type: import_v419.z.literal("shell_call_output"),
|
|
3162
|
+
id: import_v419.z.string(),
|
|
3163
|
+
call_id: import_v419.z.string(),
|
|
3164
|
+
status: import_v419.z.enum(["in_progress", "completed", "incomplete"]),
|
|
3165
|
+
output: import_v419.z.array(
|
|
3166
|
+
import_v419.z.object({
|
|
3167
|
+
stdout: import_v419.z.string(),
|
|
3168
|
+
stderr: import_v419.z.string(),
|
|
3169
|
+
outcome: import_v419.z.discriminatedUnion("type", [
|
|
3170
|
+
import_v419.z.object({ type: import_v419.z.literal("timeout") }),
|
|
3171
|
+
import_v419.z.object({
|
|
3172
|
+
type: import_v419.z.literal("exit"),
|
|
3173
|
+
exit_code: import_v419.z.number()
|
|
3174
|
+
})
|
|
3175
|
+
])
|
|
3176
|
+
})
|
|
3177
|
+
)
|
|
3047
3178
|
})
|
|
3048
3179
|
])
|
|
3049
3180
|
}),
|
|
@@ -3223,6 +3354,25 @@ var openaiResponsesChunkSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3223
3354
|
action: import_v419.z.object({
|
|
3224
3355
|
commands: import_v419.z.array(import_v419.z.string())
|
|
3225
3356
|
})
|
|
3357
|
+
}),
|
|
3358
|
+
import_v419.z.object({
|
|
3359
|
+
type: import_v419.z.literal("shell_call_output"),
|
|
3360
|
+
id: import_v419.z.string(),
|
|
3361
|
+
call_id: import_v419.z.string(),
|
|
3362
|
+
status: import_v419.z.enum(["in_progress", "completed", "incomplete"]),
|
|
3363
|
+
output: import_v419.z.array(
|
|
3364
|
+
import_v419.z.object({
|
|
3365
|
+
stdout: import_v419.z.string(),
|
|
3366
|
+
stderr: import_v419.z.string(),
|
|
3367
|
+
outcome: import_v419.z.discriminatedUnion("type", [
|
|
3368
|
+
import_v419.z.object({ type: import_v419.z.literal("timeout") }),
|
|
3369
|
+
import_v419.z.object({
|
|
3370
|
+
type: import_v419.z.literal("exit"),
|
|
3371
|
+
exit_code: import_v419.z.number()
|
|
3372
|
+
})
|
|
3373
|
+
])
|
|
3374
|
+
})
|
|
3375
|
+
)
|
|
3226
3376
|
})
|
|
3227
3377
|
])
|
|
3228
3378
|
}),
|
|
@@ -3568,6 +3718,25 @@ var openaiResponsesResponseSchema = (0, import_provider_utils24.lazySchema)(
|
|
|
3568
3718
|
action: import_v419.z.object({
|
|
3569
3719
|
commands: import_v419.z.array(import_v419.z.string())
|
|
3570
3720
|
})
|
|
3721
|
+
}),
|
|
3722
|
+
import_v419.z.object({
|
|
3723
|
+
type: import_v419.z.literal("shell_call_output"),
|
|
3724
|
+
id: import_v419.z.string(),
|
|
3725
|
+
call_id: import_v419.z.string(),
|
|
3726
|
+
status: import_v419.z.enum(["in_progress", "completed", "incomplete"]),
|
|
3727
|
+
output: import_v419.z.array(
|
|
3728
|
+
import_v419.z.object({
|
|
3729
|
+
stdout: import_v419.z.string(),
|
|
3730
|
+
stderr: import_v419.z.string(),
|
|
3731
|
+
outcome: import_v419.z.discriminatedUnion("type", [
|
|
3732
|
+
import_v419.z.object({ type: import_v419.z.literal("timeout") }),
|
|
3733
|
+
import_v419.z.object({
|
|
3734
|
+
type: import_v419.z.literal("exit"),
|
|
3735
|
+
exit_code: import_v419.z.number()
|
|
3736
|
+
})
|
|
3737
|
+
])
|
|
3738
|
+
})
|
|
3739
|
+
)
|
|
3571
3740
|
})
|
|
3572
3741
|
])
|
|
3573
3742
|
).optional(),
|
|
@@ -3861,8 +4030,15 @@ async function prepareResponsesTools({
|
|
|
3861
4030
|
break;
|
|
3862
4031
|
}
|
|
3863
4032
|
case "openai.shell": {
|
|
4033
|
+
const args = await (0, import_provider_utils26.validateTypes)({
|
|
4034
|
+
value: tool.args,
|
|
4035
|
+
schema: shellArgsSchema
|
|
4036
|
+
});
|
|
3864
4037
|
openaiTools2.push({
|
|
3865
|
-
type: "shell"
|
|
4038
|
+
type: "shell",
|
|
4039
|
+
...args.environment && {
|
|
4040
|
+
environment: mapShellEnvironment(args.environment)
|
|
4041
|
+
}
|
|
3866
4042
|
});
|
|
3867
4043
|
break;
|
|
3868
4044
|
}
|
|
@@ -3992,6 +4168,52 @@ async function prepareResponsesTools({
|
|
|
3992
4168
|
}
|
|
3993
4169
|
}
|
|
3994
4170
|
}
|
|
4171
|
+
function mapShellEnvironment(environment) {
|
|
4172
|
+
if (environment.type === "containerReference") {
|
|
4173
|
+
const env2 = environment;
|
|
4174
|
+
return {
|
|
4175
|
+
type: "container_reference",
|
|
4176
|
+
container_id: env2.containerId
|
|
4177
|
+
};
|
|
4178
|
+
}
|
|
4179
|
+
if (environment.type === "containerAuto") {
|
|
4180
|
+
const env2 = environment;
|
|
4181
|
+
return {
|
|
4182
|
+
type: "container_auto",
|
|
4183
|
+
file_ids: env2.fileIds,
|
|
4184
|
+
memory_limit: env2.memoryLimit,
|
|
4185
|
+
network_policy: env2.networkPolicy == null ? void 0 : env2.networkPolicy.type === "disabled" ? { type: "disabled" } : {
|
|
4186
|
+
type: "allowlist",
|
|
4187
|
+
allowed_domains: env2.networkPolicy.allowedDomains,
|
|
4188
|
+
domain_secrets: env2.networkPolicy.domainSecrets
|
|
4189
|
+
},
|
|
4190
|
+
skills: mapShellSkills(env2.skills)
|
|
4191
|
+
};
|
|
4192
|
+
}
|
|
4193
|
+
const env = environment;
|
|
4194
|
+
return {
|
|
4195
|
+
type: "local",
|
|
4196
|
+
skills: env.skills
|
|
4197
|
+
};
|
|
4198
|
+
}
|
|
4199
|
+
function mapShellSkills(skills) {
|
|
4200
|
+
return skills == null ? void 0 : skills.map(
|
|
4201
|
+
(skill) => skill.type === "skillReference" ? {
|
|
4202
|
+
type: "skill_reference",
|
|
4203
|
+
skill_id: skill.skillId,
|
|
4204
|
+
version: skill.version
|
|
4205
|
+
} : {
|
|
4206
|
+
type: "inline",
|
|
4207
|
+
name: skill.name,
|
|
4208
|
+
description: skill.description,
|
|
4209
|
+
source: {
|
|
4210
|
+
type: "base64",
|
|
4211
|
+
media_type: skill.source.mediaType,
|
|
4212
|
+
data: skill.source.data
|
|
4213
|
+
}
|
|
4214
|
+
}
|
|
4215
|
+
);
|
|
4216
|
+
}
|
|
3995
4217
|
|
|
3996
4218
|
// src/responses/openai-responses-language-model.ts
|
|
3997
4219
|
function extractApprovalRequestIdToToolCallIdMapping(prompt) {
|
|
@@ -4037,7 +4259,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4037
4259
|
toolChoice,
|
|
4038
4260
|
responseFormat
|
|
4039
4261
|
}) {
|
|
4040
|
-
var _a, _b, _c, _d, _e, _f;
|
|
4262
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
4041
4263
|
const warnings = [];
|
|
4042
4264
|
const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
|
|
4043
4265
|
if (topK != null) {
|
|
@@ -4241,6 +4463,10 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4241
4463
|
tools,
|
|
4242
4464
|
toolChoice
|
|
4243
4465
|
});
|
|
4466
|
+
const shellToolEnvType = (_i = (_h = (_g = tools == null ? void 0 : tools.find(
|
|
4467
|
+
(tool) => tool.type === "provider" && tool.id === "openai.shell"
|
|
4468
|
+
)) == null ? void 0 : _g.args) == null ? void 0 : _h.environment) == null ? void 0 : _i.type;
|
|
4469
|
+
const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
|
|
4244
4470
|
return {
|
|
4245
4471
|
webSearchToolName,
|
|
4246
4472
|
args: {
|
|
@@ -4251,7 +4477,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4251
4477
|
warnings: [...warnings, ...toolWarnings],
|
|
4252
4478
|
store,
|
|
4253
4479
|
toolNameMapping,
|
|
4254
|
-
providerOptionsName
|
|
4480
|
+
providerOptionsName,
|
|
4481
|
+
isShellProviderExecuted
|
|
4255
4482
|
};
|
|
4256
4483
|
}
|
|
4257
4484
|
async doGenerate(options) {
|
|
@@ -4261,7 +4488,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4261
4488
|
warnings,
|
|
4262
4489
|
webSearchToolName,
|
|
4263
4490
|
toolNameMapping,
|
|
4264
|
-
providerOptionsName
|
|
4491
|
+
providerOptionsName,
|
|
4492
|
+
isShellProviderExecuted
|
|
4265
4493
|
} = await this.getArgs(options);
|
|
4266
4494
|
const url = this.config.url({
|
|
4267
4495
|
path: "/responses",
|
|
@@ -4361,6 +4589,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4361
4589
|
commands: part.action.commands
|
|
4362
4590
|
}
|
|
4363
4591
|
}),
|
|
4592
|
+
...isShellProviderExecuted && { providerExecuted: true },
|
|
4364
4593
|
providerMetadata: {
|
|
4365
4594
|
[providerOptionsName]: {
|
|
4366
4595
|
itemId: part.id
|
|
@@ -4369,6 +4598,24 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4369
4598
|
});
|
|
4370
4599
|
break;
|
|
4371
4600
|
}
|
|
4601
|
+
case "shell_call_output": {
|
|
4602
|
+
content.push({
|
|
4603
|
+
type: "tool-result",
|
|
4604
|
+
toolCallId: part.call_id,
|
|
4605
|
+
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
4606
|
+
result: {
|
|
4607
|
+
output: part.output.map((item) => ({
|
|
4608
|
+
stdout: item.stdout,
|
|
4609
|
+
stderr: item.stderr,
|
|
4610
|
+
outcome: item.outcome.type === "exit" ? {
|
|
4611
|
+
type: "exit",
|
|
4612
|
+
exitCode: item.outcome.exit_code
|
|
4613
|
+
} : { type: "timeout" }
|
|
4614
|
+
}))
|
|
4615
|
+
}
|
|
4616
|
+
});
|
|
4617
|
+
break;
|
|
4618
|
+
}
|
|
4372
4619
|
case "message": {
|
|
4373
4620
|
for (const contentPart of part.content) {
|
|
4374
4621
|
if (((_c = (_b = options.providerOptions) == null ? void 0 : _b[providerOptionsName]) == null ? void 0 : _c.logprobs) && contentPart.logprobs) {
|
|
@@ -4658,7 +4905,8 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4658
4905
|
webSearchToolName,
|
|
4659
4906
|
toolNameMapping,
|
|
4660
4907
|
store,
|
|
4661
|
-
providerOptionsName
|
|
4908
|
+
providerOptionsName,
|
|
4909
|
+
isShellProviderExecuted
|
|
4662
4910
|
} = await this.getArgs(options);
|
|
4663
4911
|
const { responseHeaders, value: response } = await (0, import_provider_utils27.postJsonToApi)({
|
|
4664
4912
|
url: this.config.url({
|
|
@@ -4837,6 +5085,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4837
5085
|
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
4838
5086
|
toolCallId: value.item.call_id
|
|
4839
5087
|
};
|
|
5088
|
+
} else if (value.item.type === "shell_call_output") {
|
|
4840
5089
|
} else if (value.item.type === "message") {
|
|
4841
5090
|
ongoingAnnotations.splice(0, ongoingAnnotations.length);
|
|
4842
5091
|
controller.enqueue({
|
|
@@ -5090,10 +5339,31 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5090
5339
|
commands: value.item.action.commands
|
|
5091
5340
|
}
|
|
5092
5341
|
}),
|
|
5342
|
+
...isShellProviderExecuted && {
|
|
5343
|
+
providerExecuted: true
|
|
5344
|
+
},
|
|
5093
5345
|
providerMetadata: {
|
|
5094
5346
|
[providerOptionsName]: { itemId: value.item.id }
|
|
5095
5347
|
}
|
|
5096
5348
|
});
|
|
5349
|
+
} else if (value.item.type === "shell_call_output") {
|
|
5350
|
+
controller.enqueue({
|
|
5351
|
+
type: "tool-result",
|
|
5352
|
+
toolCallId: value.item.call_id,
|
|
5353
|
+
toolName: toolNameMapping.toCustomToolName("shell"),
|
|
5354
|
+
result: {
|
|
5355
|
+
output: value.item.output.map(
|
|
5356
|
+
(item) => ({
|
|
5357
|
+
stdout: item.stdout,
|
|
5358
|
+
stderr: item.stderr,
|
|
5359
|
+
outcome: item.outcome.type === "exit" ? {
|
|
5360
|
+
type: "exit",
|
|
5361
|
+
exitCode: item.outcome.exit_code
|
|
5362
|
+
} : { type: "timeout" }
|
|
5363
|
+
})
|
|
5364
|
+
)
|
|
5365
|
+
}
|
|
5366
|
+
});
|
|
5097
5367
|
} else if (value.item.type === "reasoning") {
|
|
5098
5368
|
const activeReasoningPart = activeReasoning[value.item.id];
|
|
5099
5369
|
const summaryPartIndices = Object.entries(
|
|
@@ -5786,7 +6056,7 @@ var OpenAITranscriptionModel = class {
|
|
|
5786
6056
|
};
|
|
5787
6057
|
|
|
5788
6058
|
// src/version.ts
|
|
5789
|
-
var VERSION = true ? "3.0.
|
|
6059
|
+
var VERSION = true ? "3.0.30" : "0.0.0-test";
|
|
5790
6060
|
|
|
5791
6061
|
// src/openai-provider.ts
|
|
5792
6062
|
function createOpenAI(options = {}) {
|