@ai-sdk/openai 3.0.0-beta.110 → 3.0.0-beta.112
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 +14 -0
- package/dist/index.js +109 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +109 -21
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +108 -20
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +108 -20
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/internal/index.js
CHANGED
|
@@ -3221,6 +3221,19 @@ var openaiResponsesChunkSchema = (0, import_provider_utils23.lazySchema)(
|
|
|
3221
3221
|
item_id: import_v416.z.string(),
|
|
3222
3222
|
summary_index: import_v416.z.number()
|
|
3223
3223
|
}),
|
|
3224
|
+
import_v416.z.object({
|
|
3225
|
+
type: import_v416.z.literal("response.apply_patch_call_operation_diff.delta"),
|
|
3226
|
+
item_id: import_v416.z.string(),
|
|
3227
|
+
output_index: import_v416.z.number(),
|
|
3228
|
+
delta: import_v416.z.string(),
|
|
3229
|
+
obfuscation: import_v416.z.string().nullish()
|
|
3230
|
+
}),
|
|
3231
|
+
import_v416.z.object({
|
|
3232
|
+
type: import_v416.z.literal("response.apply_patch_call_operation_diff.done"),
|
|
3233
|
+
item_id: import_v416.z.string(),
|
|
3234
|
+
output_index: import_v416.z.number(),
|
|
3235
|
+
diff: import_v416.z.string()
|
|
3236
|
+
}),
|
|
3224
3237
|
import_v416.z.object({
|
|
3225
3238
|
type: import_v416.z.literal("error"),
|
|
3226
3239
|
sequence_number: import_v416.z.number(),
|
|
@@ -4952,24 +4965,40 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
4952
4965
|
providerExecuted: true
|
|
4953
4966
|
});
|
|
4954
4967
|
} else if (value.item.type === "apply_patch_call") {
|
|
4968
|
+
const { call_id: callId, operation } = value.item;
|
|
4955
4969
|
ongoingToolCalls[value.output_index] = {
|
|
4956
4970
|
toolName: toolNameMapping.toCustomToolName("apply_patch"),
|
|
4957
|
-
toolCallId:
|
|
4971
|
+
toolCallId: callId,
|
|
4972
|
+
applyPatch: {
|
|
4973
|
+
// delete_file doesn't have diff
|
|
4974
|
+
hasDiff: operation.type === "delete_file",
|
|
4975
|
+
endEmitted: operation.type === "delete_file"
|
|
4976
|
+
}
|
|
4958
4977
|
};
|
|
4959
|
-
|
|
4978
|
+
controller.enqueue({
|
|
4979
|
+
type: "tool-input-start",
|
|
4980
|
+
id: callId,
|
|
4981
|
+
toolName: toolNameMapping.toCustomToolName("apply_patch")
|
|
4982
|
+
});
|
|
4983
|
+
if (operation.type === "delete_file") {
|
|
4984
|
+
const inputString = JSON.stringify({
|
|
4985
|
+
callId,
|
|
4986
|
+
operation
|
|
4987
|
+
});
|
|
4960
4988
|
controller.enqueue({
|
|
4961
|
-
type: "tool-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4989
|
+
type: "tool-input-delta",
|
|
4990
|
+
id: callId,
|
|
4991
|
+
delta: inputString
|
|
4992
|
+
});
|
|
4993
|
+
controller.enqueue({
|
|
4994
|
+
type: "tool-input-end",
|
|
4995
|
+
id: callId
|
|
4996
|
+
});
|
|
4997
|
+
} else {
|
|
4998
|
+
controller.enqueue({
|
|
4999
|
+
type: "tool-input-delta",
|
|
5000
|
+
id: callId,
|
|
5001
|
+
delta: `{"callId":"${escapeJSONDelta(callId)}","operation":{"type":"${escapeJSONDelta(operation.type)}","path":"${escapeJSONDelta(operation.path)}","diff":"`
|
|
4973
5002
|
});
|
|
4974
5003
|
}
|
|
4975
5004
|
} else if (value.item.type === "shell_call") {
|
|
@@ -5122,11 +5151,30 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5122
5151
|
} else if (value.item.type === "mcp_list_tools") {
|
|
5123
5152
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5124
5153
|
} else if (value.item.type === "apply_patch_call") {
|
|
5125
|
-
ongoingToolCalls[value.output_index]
|
|
5126
|
-
if (value.item.
|
|
5154
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
5155
|
+
if ((toolCall == null ? void 0 : toolCall.applyPatch) && !toolCall.applyPatch.endEmitted && value.item.operation.type !== "delete_file") {
|
|
5156
|
+
if (!toolCall.applyPatch.hasDiff) {
|
|
5157
|
+
controller.enqueue({
|
|
5158
|
+
type: "tool-input-delta",
|
|
5159
|
+
id: toolCall.toolCallId,
|
|
5160
|
+
delta: escapeJSONDelta(value.item.operation.diff)
|
|
5161
|
+
});
|
|
5162
|
+
}
|
|
5163
|
+
controller.enqueue({
|
|
5164
|
+
type: "tool-input-delta",
|
|
5165
|
+
id: toolCall.toolCallId,
|
|
5166
|
+
delta: '"}}'
|
|
5167
|
+
});
|
|
5168
|
+
controller.enqueue({
|
|
5169
|
+
type: "tool-input-end",
|
|
5170
|
+
id: toolCall.toolCallId
|
|
5171
|
+
});
|
|
5172
|
+
toolCall.applyPatch.endEmitted = true;
|
|
5173
|
+
}
|
|
5174
|
+
if (toolCall && value.item.status === "completed") {
|
|
5127
5175
|
controller.enqueue({
|
|
5128
5176
|
type: "tool-call",
|
|
5129
|
-
toolCallId:
|
|
5177
|
+
toolCallId: toolCall.toolCallId,
|
|
5130
5178
|
toolName: toolNameMapping.toCustomToolName("apply_patch"),
|
|
5131
5179
|
input: JSON.stringify({
|
|
5132
5180
|
callId: value.item.call_id,
|
|
@@ -5139,6 +5187,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5139
5187
|
}
|
|
5140
5188
|
});
|
|
5141
5189
|
}
|
|
5190
|
+
ongoingToolCalls[value.output_index] = void 0;
|
|
5142
5191
|
} else if (value.item.type === "mcp_approval_request") {
|
|
5143
5192
|
ongoingToolCalls[value.output_index] = void 0;
|
|
5144
5193
|
} else if (value.item.type === "local_shell_call") {
|
|
@@ -5206,6 +5255,38 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5206
5255
|
delta: value.delta
|
|
5207
5256
|
});
|
|
5208
5257
|
}
|
|
5258
|
+
} else if (isResponseApplyPatchCallOperationDiffDeltaChunk(value)) {
|
|
5259
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
5260
|
+
if (toolCall == null ? void 0 : toolCall.applyPatch) {
|
|
5261
|
+
controller.enqueue({
|
|
5262
|
+
type: "tool-input-delta",
|
|
5263
|
+
id: toolCall.toolCallId,
|
|
5264
|
+
delta: escapeJSONDelta(value.delta)
|
|
5265
|
+
});
|
|
5266
|
+
toolCall.applyPatch.hasDiff = true;
|
|
5267
|
+
}
|
|
5268
|
+
} else if (isResponseApplyPatchCallOperationDiffDoneChunk(value)) {
|
|
5269
|
+
const toolCall = ongoingToolCalls[value.output_index];
|
|
5270
|
+
if ((toolCall == null ? void 0 : toolCall.applyPatch) && !toolCall.applyPatch.endEmitted) {
|
|
5271
|
+
if (!toolCall.applyPatch.hasDiff) {
|
|
5272
|
+
controller.enqueue({
|
|
5273
|
+
type: "tool-input-delta",
|
|
5274
|
+
id: toolCall.toolCallId,
|
|
5275
|
+
delta: escapeJSONDelta(value.diff)
|
|
5276
|
+
});
|
|
5277
|
+
toolCall.applyPatch.hasDiff = true;
|
|
5278
|
+
}
|
|
5279
|
+
controller.enqueue({
|
|
5280
|
+
type: "tool-input-delta",
|
|
5281
|
+
id: toolCall.toolCallId,
|
|
5282
|
+
delta: '"}}'
|
|
5283
|
+
});
|
|
5284
|
+
controller.enqueue({
|
|
5285
|
+
type: "tool-input-end",
|
|
5286
|
+
id: toolCall.toolCallId
|
|
5287
|
+
});
|
|
5288
|
+
toolCall.applyPatch.endEmitted = true;
|
|
5289
|
+
}
|
|
5209
5290
|
} else if (isResponseImageGenerationCallPartialImageChunk(value)) {
|
|
5210
5291
|
controller.enqueue({
|
|
5211
5292
|
type: "tool-result",
|
|
@@ -5222,9 +5303,7 @@ var OpenAIResponsesLanguageModel = class {
|
|
|
5222
5303
|
controller.enqueue({
|
|
5223
5304
|
type: "tool-input-delta",
|
|
5224
5305
|
id: toolCall.toolCallId,
|
|
5225
|
-
|
|
5226
|
-
// To escape it, we use JSON.stringify and slice to remove the outer quotes.
|
|
5227
|
-
delta: JSON.stringify(value.delta).slice(1, -1)
|
|
5306
|
+
delta: escapeJSONDelta(value.delta)
|
|
5228
5307
|
});
|
|
5229
5308
|
}
|
|
5230
5309
|
} else if (isResponseCodeInterpreterCallCodeDoneChunk(value)) {
|
|
@@ -5444,6 +5523,12 @@ function isResponseCodeInterpreterCallCodeDeltaChunk(chunk) {
|
|
|
5444
5523
|
function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
|
|
5445
5524
|
return chunk.type === "response.code_interpreter_call_code.done";
|
|
5446
5525
|
}
|
|
5526
|
+
function isResponseApplyPatchCallOperationDiffDeltaChunk(chunk) {
|
|
5527
|
+
return chunk.type === "response.apply_patch_call_operation_diff.delta";
|
|
5528
|
+
}
|
|
5529
|
+
function isResponseApplyPatchCallOperationDiffDoneChunk(chunk) {
|
|
5530
|
+
return chunk.type === "response.apply_patch_call_operation_diff.done";
|
|
5531
|
+
}
|
|
5447
5532
|
function isResponseOutputItemAddedChunk(chunk) {
|
|
5448
5533
|
return chunk.type === "response.output_item.added";
|
|
5449
5534
|
}
|
|
@@ -5474,6 +5559,9 @@ function mapWebSearchOutput(action) {
|
|
|
5474
5559
|
};
|
|
5475
5560
|
}
|
|
5476
5561
|
}
|
|
5562
|
+
function escapeJSONDelta(delta) {
|
|
5563
|
+
return JSON.stringify(delta).slice(1, -1);
|
|
5564
|
+
}
|
|
5477
5565
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5478
5566
|
0 && (module.exports = {
|
|
5479
5567
|
OpenAIChatLanguageModel,
|