@warlock.js/ai-openai 5.44.0 → 5.45.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/CHANGELOG.md +7 -0
- package/cjs/index.cjs +36 -4
- package/cjs/index.cjs.map +1 -1
- package/esm/known-context-windows.mjs +9 -0
- package/esm/known-context-windows.mjs.map +1 -1
- package/esm/model.mjs +1 -0
- package/esm/model.mjs.map +1 -1
- package/esm/responses-model.d.mts.map +1 -1
- package/esm/responses-model.mjs +2 -1
- package/esm/responses-model.mjs.map +1 -1
- package/esm/utils/to-openai-messages.mjs +2 -2
- package/esm/utils/to-openai-messages.mjs.map +1 -1
- package/esm/utils/to-responses-input.mjs +24 -3
- package/esm/utils/to-responses-input.mjs.map +1 -1
- package/llms-full.txt +4 -0
- package/package.json +3 -3
- package/skills/SKILL.md +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to `@warlock.js/ai-openai` are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
|
|
6
6
|
|
|
7
|
+
## 5.45.0 - 2026-11-05
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- With `api: "responses"` on the OpenAI provider, image parts in a tool result are sent as `input_image` items in the `function_call_output` (`capabilities.toolResultImages: true`). Chat Completions and the OpenAI-compatible providers send the text `[image omitted: provider cannot read images in tool results]` and report `false`.
|
|
12
|
+
- `capabilities.contextWindow` is reported for more direct-OpenAI ids: `gpt-5.x` and `gpt-6` (400K, the documented gpt-5 figure; set `contextWindow` for a larger window), `gpt-4`, `gpt-4-turbo`, `gpt-3.5-turbo`, `chatgpt-4o`, `o3-mini`, `o3-pro` and `o1-pro`.
|
|
13
|
+
|
|
7
14
|
## 5.44.0 - 2026-11-05
|
|
8
15
|
|
|
9
16
|
### Added
|
package/cjs/index.cjs
CHANGED
|
@@ -740,7 +740,7 @@ function toOpenAIMessages(messages, cacheBreakpoints = 0) {
|
|
|
740
740
|
return addPromptCacheBreakpoints(messages.map((m) => {
|
|
741
741
|
if (m.role === "tool") return {
|
|
742
742
|
role: "tool",
|
|
743
|
-
content:
|
|
743
|
+
content: (0, _warlock_js_ai.toolResultText)(m.content),
|
|
744
744
|
tool_call_id: m.toolCallId ?? ""
|
|
745
745
|
};
|
|
746
746
|
if (m.role === "assistant" && m.toolCalls && m.toolCalls.length > 0) return {
|
|
@@ -948,7 +948,7 @@ function toToolParameters(input) {
|
|
|
948
948
|
* ]);
|
|
949
949
|
* // { instructions: "Be brief.", input: [{ role: "user", content: "Hi" }] }
|
|
950
950
|
*/
|
|
951
|
-
function toResponsesInput(messages, model) {
|
|
951
|
+
function toResponsesInput(messages, model, toolImages = false) {
|
|
952
952
|
const input = [];
|
|
953
953
|
let instructions;
|
|
954
954
|
let instructionsTaken = false;
|
|
@@ -970,7 +970,7 @@ function toResponsesInput(messages, model) {
|
|
|
970
970
|
input.push({
|
|
971
971
|
type: "function_call_output",
|
|
972
972
|
call_id: message.toolCallId ?? "",
|
|
973
|
-
output:
|
|
973
|
+
output: toToolOutput(message.content, toolImages)
|
|
974
974
|
});
|
|
975
975
|
continue;
|
|
976
976
|
}
|
|
@@ -1006,6 +1006,27 @@ function toResponsesInput(messages, model) {
|
|
|
1006
1006
|
input
|
|
1007
1007
|
};
|
|
1008
1008
|
}
|
|
1009
|
+
/**
|
|
1010
|
+
* A `function_call_output` value: the string, or (when the model reads tool
|
|
1011
|
+
* images) an array of `input_text` / `input_image` items. Otherwise images
|
|
1012
|
+
* degrade to the placeholder text.
|
|
1013
|
+
*/
|
|
1014
|
+
function toToolOutput(content, toolImages) {
|
|
1015
|
+
if (typeof content === "string") return content;
|
|
1016
|
+
if (!toolImages) return (0, _warlock_js_ai.toolResultText)(content);
|
|
1017
|
+
return content.flatMap((part) => {
|
|
1018
|
+
if (part.type === "text") return [{
|
|
1019
|
+
type: "input_text",
|
|
1020
|
+
text: part.text
|
|
1021
|
+
}];
|
|
1022
|
+
if (part.type === "image") return [{
|
|
1023
|
+
type: "input_image",
|
|
1024
|
+
image_url: toImageUrl(part.source),
|
|
1025
|
+
detail: "auto"
|
|
1026
|
+
}];
|
|
1027
|
+
return [];
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1009
1030
|
/** Map a resolved `ContentPart` to a Responses input content part (text and images only). */
|
|
1010
1031
|
function toResponsesContentPart(part) {
|
|
1011
1032
|
if (part.type === "text") return {
|
|
@@ -1411,6 +1432,14 @@ function compatibleSearchParams(provider, options) {
|
|
|
1411
1432
|
//#region ../../packages/ai-openai/src/known-context-windows.ts
|
|
1412
1433
|
const PREFIX_WINDOWS = [
|
|
1413
1434
|
["gpt-5-", 4e5],
|
|
1435
|
+
["gpt-5.", 4e5],
|
|
1436
|
+
["gpt-6", 4e5],
|
|
1437
|
+
["gpt-4-turbo", 128e3],
|
|
1438
|
+
["gpt-3.5-turbo", 16385],
|
|
1439
|
+
["chatgpt-4o", 128e3],
|
|
1440
|
+
["o3-mini", 2e5],
|
|
1441
|
+
["o3-pro", 2e5],
|
|
1442
|
+
["o1-pro", 2e5],
|
|
1414
1443
|
["gpt-4.1", 1047576],
|
|
1415
1444
|
["gpt-5-chat", 128e3],
|
|
1416
1445
|
["gpt-4o", 128e3],
|
|
@@ -1429,6 +1458,7 @@ const PREFIX_WINDOWS = [
|
|
|
1429
1458
|
function inferContextWindow(modelName) {
|
|
1430
1459
|
const id = modelName.toLowerCase();
|
|
1431
1460
|
if (id === "gpt-5") return 4e5;
|
|
1461
|
+
if (id === "gpt-4") return 8192;
|
|
1432
1462
|
let best;
|
|
1433
1463
|
for (const entry of PREFIX_WINDOWS) if (id.startsWith(entry[0]) && (!best || entry[0].length > best[0].length)) best = entry;
|
|
1434
1464
|
return best?.[1];
|
|
@@ -1600,6 +1630,7 @@ var OpenAIResponsesModel = class {
|
|
|
1600
1630
|
...window !== void 0 ? { contextWindow: window } : {},
|
|
1601
1631
|
structuredOutput: config.structuredOutput ?? inferStructuredOutput(config.responseFormat),
|
|
1602
1632
|
vision: config.vision ?? inferVisionCapability(config.name),
|
|
1633
|
+
toolResultImages: provider === "openai",
|
|
1603
1634
|
reasoning: config.reasoning ?? inferReasoningCapability(config.name),
|
|
1604
1635
|
promptCaching: true,
|
|
1605
1636
|
pdf: false,
|
|
@@ -1804,7 +1835,7 @@ var OpenAIResponsesModel = class {
|
|
|
1804
1835
|
* applies EVEN with tools attached - that is the point of this API.
|
|
1805
1836
|
*/
|
|
1806
1837
|
buildRequest(messages, options) {
|
|
1807
|
-
const { instructions, input } = toResponsesInput(messages, this.name);
|
|
1838
|
+
const { instructions, input } = toResponsesInput(messages, this.name, this.capabilities.toolResultImages === true);
|
|
1808
1839
|
const tools = this.buildTools(options);
|
|
1809
1840
|
const toolChoice = tools ? toResponsesToolChoice(options?.toolChoice) : void 0;
|
|
1810
1841
|
const maxTokens = options?.maxTokens ?? this.config.maxTokens;
|
|
@@ -2004,6 +2035,7 @@ var OpenAIModel = class {
|
|
|
2004
2035
|
...window !== void 0 ? { contextWindow: window } : {},
|
|
2005
2036
|
structuredOutput: config.structuredOutput ?? inferStructuredOutput(config.responseFormat),
|
|
2006
2037
|
vision: config.vision ?? inferVisionCapability(config.name),
|
|
2038
|
+
toolResultImages: false,
|
|
2007
2039
|
reasoning: config.reasoning ?? inferReasoningCapability(config.name),
|
|
2008
2040
|
promptCaching: this.provider === "openai",
|
|
2009
2041
|
pdf: config.pdf ?? false,
|