@opentiny/next-sdk 0.2.5 → 0.2.6

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.
@@ -11667,7 +11667,7 @@ async function getVercelRequestId() {
11667
11667
  var _a92;
11668
11668
  return (_a92 = indexBrowserExports.getContext().headers) == null ? void 0 : _a92["x-vercel-id"];
11669
11669
  }
11670
- var VERSION$6 = "3.0.55";
11670
+ var VERSION$6 = "3.0.58";
11671
11671
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
11672
11672
  function createGatewayProvider(options = {}) {
11673
11673
  var _a92, _b9;
@@ -12800,6 +12800,17 @@ var RetryError = class extends AISDKError$1 {
12800
12800
  }
12801
12801
  };
12802
12802
  _a19 = symbol19;
12803
+ function asArray(value) {
12804
+ return value === void 0 ? [] : Array.isArray(value) ? value : [value];
12805
+ }
12806
+ async function notify(options) {
12807
+ for (const callback of asArray(options.callbacks)) {
12808
+ try {
12809
+ await callback(options.event);
12810
+ } catch (_ignored) {
12811
+ }
12812
+ }
12813
+ }
12803
12814
  function formatWarning({
12804
12815
  warning,
12805
12816
  provider,
@@ -13100,7 +13111,7 @@ function detectMediaType({
13100
13111
  }
13101
13112
  return void 0;
13102
13113
  }
13103
- var VERSION$4 = "6.0.99";
13114
+ var VERSION$4 = "6.0.104";
13104
13115
  var download = async ({
13105
13116
  url: url2,
13106
13117
  maxBytes,
@@ -13208,9 +13219,6 @@ function convertDataContentToBase64String(content) {
13208
13219
  }
13209
13220
  return convertUint8ArrayToBase64$1(content);
13210
13221
  }
13211
- function asArray(value) {
13212
- return value === void 0 ? [] : Array.isArray(value) ? value : [value];
13213
- }
13214
13222
  async function convertToLanguageModelPrompt({
13215
13223
  prompt,
13216
13224
  supportedUrls,
@@ -14577,10 +14585,7 @@ async function executeToolCall({
14577
14585
  tracer,
14578
14586
  fn: async (span) => {
14579
14587
  let output;
14580
- try {
14581
- await (onToolCallStart == null ? void 0 : onToolCallStart(baseCallbackEvent));
14582
- } catch (_ignored) {
14583
- }
14588
+ await notify({ event: baseCallbackEvent, callbacks: onToolCallStart });
14584
14589
  const startTime = now();
14585
14590
  try {
14586
14591
  const stream = executeTool({
@@ -14607,15 +14612,15 @@ async function executeToolCall({
14607
14612
  }
14608
14613
  } catch (error) {
14609
14614
  const durationMs2 = now() - startTime;
14610
- try {
14611
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
14615
+ await notify({
14616
+ event: {
14612
14617
  ...baseCallbackEvent,
14613
14618
  success: false,
14614
14619
  error,
14615
14620
  durationMs: durationMs2
14616
- }));
14617
- } catch (_ignored) {
14618
- }
14621
+ },
14622
+ callbacks: onToolCallFinish
14623
+ });
14619
14624
  recordErrorOnSpan(span, error);
14620
14625
  return {
14621
14626
  type: "tool-error",
@@ -14628,15 +14633,15 @@ async function executeToolCall({
14628
14633
  };
14629
14634
  }
14630
14635
  const durationMs = now() - startTime;
14631
- try {
14632
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
14636
+ await notify({
14637
+ event: {
14633
14638
  ...baseCallbackEvent,
14634
14639
  success: true,
14635
14640
  output,
14636
14641
  durationMs
14637
- }));
14638
- } catch (_ignored) {
14639
- }
14642
+ },
14643
+ callbacks: onToolCallFinish
14644
+ });
14640
14645
  try {
14641
14646
  span.setAttributes(
14642
14647
  await selectTelemetryAttributes({
@@ -15799,8 +15804,8 @@ async function generateText({
15799
15804
  prompt,
15800
15805
  messages
15801
15806
  });
15802
- try {
15803
- await (onStart == null ? void 0 : onStart({
15807
+ await notify({
15808
+ event: {
15804
15809
  model: modelInfo,
15805
15810
  system,
15806
15811
  prompt,
@@ -15827,9 +15832,9 @@ async function generateText({
15827
15832
  functionId: telemetry == null ? void 0 : telemetry.functionId,
15828
15833
  metadata: telemetry == null ? void 0 : telemetry.metadata,
15829
15834
  experimental_context
15830
- }));
15831
- } catch (_ignored) {
15832
- }
15835
+ },
15836
+ callbacks: onStart
15837
+ });
15833
15838
  const tracer = getTracer(telemetry);
15834
15839
  try {
15835
15840
  return await recordSpan({
@@ -15979,8 +15984,8 @@ async function generateText({
15979
15984
  providerOptions,
15980
15985
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
15981
15986
  );
15982
- try {
15983
- await (onStepStart == null ? void 0 : onStepStart({
15987
+ await notify({
15988
+ event: {
15984
15989
  stepNumber: steps.length,
15985
15990
  model: stepModelInfo,
15986
15991
  system: stepSystem,
@@ -15999,9 +16004,9 @@ async function generateText({
15999
16004
  functionId: telemetry == null ? void 0 : telemetry.functionId,
16000
16005
  metadata: telemetry == null ? void 0 : telemetry.metadata,
16001
16006
  experimental_context
16002
- }));
16003
- } catch (_ignored) {
16004
- }
16007
+ },
16008
+ callbacks: onStepStart
16009
+ });
16005
16010
  currentModelResponse = await retry(
16006
16011
  () => {
16007
16012
  var _a22;
@@ -16246,7 +16251,7 @@ async function generateText({
16246
16251
  model: stepModelInfo.modelId
16247
16252
  });
16248
16253
  steps.push(currentStepResult);
16249
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
16254
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
16250
16255
  } finally {
16251
16256
  if (stepTimeoutId != null) {
16252
16257
  clearTimeout(stepTimeoutId);
@@ -16298,34 +16303,37 @@ async function generateText({
16298
16303
  cachedInputTokens: void 0
16299
16304
  }
16300
16305
  );
16301
- await (onFinish == null ? void 0 : onFinish({
16302
- stepNumber: lastStep.stepNumber,
16303
- model: lastStep.model,
16304
- functionId: lastStep.functionId,
16305
- metadata: lastStep.metadata,
16306
- experimental_context: lastStep.experimental_context,
16307
- finishReason: lastStep.finishReason,
16308
- rawFinishReason: lastStep.rawFinishReason,
16309
- usage: lastStep.usage,
16310
- content: lastStep.content,
16311
- text: lastStep.text,
16312
- reasoningText: lastStep.reasoningText,
16313
- reasoning: lastStep.reasoning,
16314
- files: lastStep.files,
16315
- sources: lastStep.sources,
16316
- toolCalls: lastStep.toolCalls,
16317
- staticToolCalls: lastStep.staticToolCalls,
16318
- dynamicToolCalls: lastStep.dynamicToolCalls,
16319
- toolResults: lastStep.toolResults,
16320
- staticToolResults: lastStep.staticToolResults,
16321
- dynamicToolResults: lastStep.dynamicToolResults,
16322
- request: lastStep.request,
16323
- response: lastStep.response,
16324
- warnings: lastStep.warnings,
16325
- providerMetadata: lastStep.providerMetadata,
16326
- steps,
16327
- totalUsage
16328
- }));
16306
+ await notify({
16307
+ event: {
16308
+ stepNumber: lastStep.stepNumber,
16309
+ model: lastStep.model,
16310
+ functionId: lastStep.functionId,
16311
+ metadata: lastStep.metadata,
16312
+ experimental_context: lastStep.experimental_context,
16313
+ finishReason: lastStep.finishReason,
16314
+ rawFinishReason: lastStep.rawFinishReason,
16315
+ usage: lastStep.usage,
16316
+ content: lastStep.content,
16317
+ text: lastStep.text,
16318
+ reasoningText: lastStep.reasoningText,
16319
+ reasoning: lastStep.reasoning,
16320
+ files: lastStep.files,
16321
+ sources: lastStep.sources,
16322
+ toolCalls: lastStep.toolCalls,
16323
+ staticToolCalls: lastStep.staticToolCalls,
16324
+ dynamicToolCalls: lastStep.dynamicToolCalls,
16325
+ toolResults: lastStep.toolResults,
16326
+ staticToolResults: lastStep.staticToolResults,
16327
+ dynamicToolResults: lastStep.dynamicToolResults,
16328
+ request: lastStep.request,
16329
+ response: lastStep.response,
16330
+ warnings: lastStep.warnings,
16331
+ providerMetadata: lastStep.providerMetadata,
16332
+ steps,
16333
+ totalUsage
16334
+ },
16335
+ callbacks: onFinish
16336
+ });
16329
16337
  let resolvedOutput;
16330
16338
  if (lastStep.finishReason === "stop") {
16331
16339
  const outputSpecification = output != null ? output : text();
@@ -17068,7 +17076,9 @@ function processUIMessageStream({
17068
17076
  break;
17069
17077
  }
17070
17078
  case "tool-input-error": {
17071
- if (chunk.dynamic) {
17079
+ const existingPart = state.message.parts.filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
17080
+ const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
17081
+ if (isDynamic) {
17072
17082
  updateDynamicToolPart({
17073
17083
  toolCallId: chunk.toolCallId,
17074
17084
  toolName: chunk.toolName,
@@ -18133,7 +18143,7 @@ var DefaultStreamTextResult = class {
18133
18143
  },
18134
18144
  providerMetadata: part.providerMetadata
18135
18145
  });
18136
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
18146
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
18137
18147
  logWarnings({
18138
18148
  warnings: recordedWarnings,
18139
18149
  provider: modelInfo.provider,
@@ -18168,34 +18178,37 @@ var DefaultStreamTextResult = class {
18168
18178
  self2._totalUsage.resolve(totalUsage);
18169
18179
  self2._steps.resolve(recordedSteps);
18170
18180
  const finalStep = recordedSteps[recordedSteps.length - 1];
18171
- await (onFinish == null ? void 0 : onFinish({
18172
- stepNumber: finalStep.stepNumber,
18173
- model: finalStep.model,
18174
- functionId: finalStep.functionId,
18175
- metadata: finalStep.metadata,
18176
- experimental_context: finalStep.experimental_context,
18177
- finishReason: finalStep.finishReason,
18178
- rawFinishReason: finalStep.rawFinishReason,
18179
- totalUsage,
18180
- usage: finalStep.usage,
18181
- content: finalStep.content,
18182
- text: finalStep.text,
18183
- reasoningText: finalStep.reasoningText,
18184
- reasoning: finalStep.reasoning,
18185
- files: finalStep.files,
18186
- sources: finalStep.sources,
18187
- toolCalls: finalStep.toolCalls,
18188
- staticToolCalls: finalStep.staticToolCalls,
18189
- dynamicToolCalls: finalStep.dynamicToolCalls,
18190
- toolResults: finalStep.toolResults,
18191
- staticToolResults: finalStep.staticToolResults,
18192
- dynamicToolResults: finalStep.dynamicToolResults,
18193
- request: finalStep.request,
18194
- response: finalStep.response,
18195
- warnings: finalStep.warnings,
18196
- providerMetadata: finalStep.providerMetadata,
18197
- steps: recordedSteps
18198
- }));
18181
+ await notify({
18182
+ event: {
18183
+ stepNumber: finalStep.stepNumber,
18184
+ model: finalStep.model,
18185
+ functionId: finalStep.functionId,
18186
+ metadata: finalStep.metadata,
18187
+ experimental_context: finalStep.experimental_context,
18188
+ finishReason: finalStep.finishReason,
18189
+ rawFinishReason: finalStep.rawFinishReason,
18190
+ totalUsage,
18191
+ usage: finalStep.usage,
18192
+ content: finalStep.content,
18193
+ text: finalStep.text,
18194
+ reasoningText: finalStep.reasoningText,
18195
+ reasoning: finalStep.reasoning,
18196
+ files: finalStep.files,
18197
+ sources: finalStep.sources,
18198
+ toolCalls: finalStep.toolCalls,
18199
+ staticToolCalls: finalStep.staticToolCalls,
18200
+ dynamicToolCalls: finalStep.dynamicToolCalls,
18201
+ toolResults: finalStep.toolResults,
18202
+ staticToolResults: finalStep.staticToolResults,
18203
+ dynamicToolResults: finalStep.dynamicToolResults,
18204
+ request: finalStep.request,
18205
+ response: finalStep.response,
18206
+ warnings: finalStep.warnings,
18207
+ providerMetadata: finalStep.providerMetadata,
18208
+ steps: recordedSteps
18209
+ },
18210
+ callbacks: onFinish
18211
+ });
18199
18212
  rootSpan.setAttributes(
18200
18213
  await selectTelemetryAttributes({
18201
18214
  telemetry,
@@ -18323,8 +18336,8 @@ var DefaultStreamTextResult = class {
18323
18336
  prompt,
18324
18337
  messages
18325
18338
  });
18326
- try {
18327
- await (onStart == null ? void 0 : onStart({
18339
+ await notify({
18340
+ event: {
18328
18341
  model: modelInfo,
18329
18342
  system,
18330
18343
  prompt,
@@ -18350,9 +18363,9 @@ var DefaultStreamTextResult = class {
18350
18363
  include,
18351
18364
  ...callbackTelemetryProps,
18352
18365
  experimental_context
18353
- }));
18354
- } catch (_ignored) {
18355
- }
18366
+ },
18367
+ callbacks: onStart
18368
+ });
18356
18369
  const initialMessages = initialPrompt.messages;
18357
18370
  const initialResponseMessages = [];
18358
18371
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -18533,8 +18546,8 @@ var DefaultStreamTextResult = class {
18533
18546
  providerOptions,
18534
18547
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
18535
18548
  );
18536
- try {
18537
- await (onStepStart == null ? void 0 : onStepStart({
18549
+ await notify({
18550
+ event: {
18538
18551
  stepNumber: recordedSteps.length,
18539
18552
  model: stepModelInfo,
18540
18553
  system: stepSystem,
@@ -18552,9 +18565,9 @@ var DefaultStreamTextResult = class {
18552
18565
  include,
18553
18566
  ...callbackTelemetryProps,
18554
18567
  experimental_context
18555
- }));
18556
- } catch (_ignored) {
18557
- }
18568
+ },
18569
+ callbacks: onStepStart
18570
+ });
18558
18571
  const {
18559
18572
  result: { stream: stream2, response, request },
18560
18573
  doStreamSpan,
@@ -25217,7 +25230,7 @@ var OpenAIChatLanguageModel = class {
25217
25230
  for (const toolCallDelta of delta.tool_calls) {
25218
25231
  const index = toolCallDelta.index;
25219
25232
  if (toolCalls[index] == null) {
25220
- if (toolCallDelta.type !== "function") {
25233
+ if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
25221
25234
  throw new InvalidResponseDataError$1({
25222
25235
  data: toolCallDelta,
25223
25236
  message: `Expected 'function' type.`
@@ -25911,6 +25924,7 @@ var modelMaxImagesPerCall = {
25911
25924
  "chatgpt-image-latest": 10
25912
25925
  };
25913
25926
  var defaultResponseFormatPrefixes = [
25927
+ "chatgpt-image-",
25914
25928
  "gpt-image-1-mini",
25915
25929
  "gpt-image-1.5",
25916
25930
  "gpt-image-1"
@@ -26680,7 +26694,7 @@ async function convertToOpenAIResponsesInput({
26680
26694
  hasShellTool = false,
26681
26695
  hasApplyPatchTool = false
26682
26696
  }) {
26683
- var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
26697
+ var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
26684
26698
  const input = [];
26685
26699
  const warnings = [];
26686
26700
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -26761,7 +26775,9 @@ async function convertToOpenAIResponsesInput({
26761
26775
  for (const part of content) {
26762
26776
  switch (part.type) {
26763
26777
  case "text": {
26764
- const id2 = (_b9 = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName]) == null ? void 0 : _b9.itemId;
26778
+ const providerOpts = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName];
26779
+ const id2 = providerOpts == null ? void 0 : providerOpts.itemId;
26780
+ const phase = providerOpts == null ? void 0 : providerOpts.phase;
26765
26781
  if (hasConversation && id2 != null) {
26766
26782
  break;
26767
26783
  }
@@ -26772,12 +26788,13 @@ async function convertToOpenAIResponsesInput({
26772
26788
  input.push({
26773
26789
  role: "assistant",
26774
26790
  content: [{ type: "output_text", text: part.text }],
26775
- id: id2
26791
+ id: id2,
26792
+ ...phase != null && { phase }
26776
26793
  });
26777
26794
  break;
26778
26795
  }
26779
26796
  case "tool-call": {
26780
- const id2 = (_g = (_d = (_c = part.providerOptions) == null ? void 0 : _c[providerOptionsName]) == null ? void 0 : _d.itemId) != null ? _g : (_f = (_e = part.providerMetadata) == null ? void 0 : _e[providerOptionsName]) == null ? void 0 : _f.itemId;
26797
+ const id2 = (_f = (_c = (_b9 = part.providerOptions) == null ? void 0 : _b9[providerOptionsName]) == null ? void 0 : _c.itemId) != null ? _f : (_e = (_d = part.providerMetadata) == null ? void 0 : _d[providerOptionsName]) == null ? void 0 : _e.itemId;
26781
26798
  if (hasConversation && id2 != null) {
26782
26799
  break;
26783
26800
  }
@@ -26888,7 +26905,7 @@ async function convertToOpenAIResponsesInput({
26888
26905
  break;
26889
26906
  }
26890
26907
  if (store) {
26891
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
26908
+ const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
26892
26909
  input.push({ type: "item_reference", id: itemId });
26893
26910
  } else {
26894
26911
  warnings.push({
@@ -26948,10 +26965,26 @@ async function convertToOpenAIResponsesInput({
26948
26965
  }
26949
26966
  }
26950
26967
  } else {
26951
- warnings.push({
26952
- type: "other",
26953
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
26954
- });
26968
+ const encryptedContent = providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent;
26969
+ if (encryptedContent != null) {
26970
+ const summaryParts = [];
26971
+ if (part.text.length > 0) {
26972
+ summaryParts.push({
26973
+ type: "summary_text",
26974
+ text: part.text
26975
+ });
26976
+ }
26977
+ input.push({
26978
+ type: "reasoning",
26979
+ encrypted_content: encryptedContent,
26980
+ summary: summaryParts
26981
+ });
26982
+ } else {
26983
+ warnings.push({
26984
+ type: "other",
26985
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
26986
+ });
26987
+ }
26955
26988
  }
26956
26989
  break;
26957
26990
  }
@@ -26982,7 +27015,7 @@ async function convertToOpenAIResponsesInput({
26982
27015
  }
26983
27016
  const output = part.output;
26984
27017
  if (output.type === "execution-denied") {
26985
- const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
27018
+ const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
26986
27019
  if (approvalId) {
26987
27020
  continue;
26988
27021
  }
@@ -27041,7 +27074,7 @@ async function convertToOpenAIResponsesInput({
27041
27074
  contentValue = output.value;
27042
27075
  break;
27043
27076
  case "execution-denied":
27044
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
27077
+ contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
27045
27078
  break;
27046
27079
  case "json":
27047
27080
  case "error-json":
@@ -27168,7 +27201,8 @@ var openaiResponsesChunkSchema = lazySchema(
27168
27201
  item: discriminatedUnion("type", [
27169
27202
  object$1({
27170
27203
  type: literal("message"),
27171
- id: string()
27204
+ id: string(),
27205
+ phase: _enum$1(["commentary", "final_answer"]).nullish()
27172
27206
  }),
27173
27207
  object$1({
27174
27208
  type: literal("reasoning"),
@@ -27285,7 +27319,8 @@ var openaiResponsesChunkSchema = lazySchema(
27285
27319
  item: discriminatedUnion("type", [
27286
27320
  object$1({
27287
27321
  type: literal("message"),
27288
- id: string()
27322
+ id: string(),
27323
+ phase: _enum$1(["commentary", "final_answer"]).nullish()
27289
27324
  }),
27290
27325
  object$1({
27291
27326
  type: literal("reasoning"),
@@ -27597,6 +27632,7 @@ var openaiResponsesResponseSchema = lazySchema(
27597
27632
  type: literal("message"),
27598
27633
  role: literal("assistant"),
27599
27634
  id: string(),
27635
+ phase: _enum$1(["commentary", "final_answer"]).nullish(),
27600
27636
  content: array$1(
27601
27637
  object$1({
27602
27638
  type: literal("output_text"),
@@ -28648,6 +28684,7 @@ var OpenAIResponsesLanguageModel = class {
28648
28684
  }
28649
28685
  const providerMetadata2 = {
28650
28686
  itemId: part.id,
28687
+ ...part.phase != null && { phase: part.phase },
28651
28688
  ...contentPart.annotations.length > 0 && {
28652
28689
  annotations: contentPart.annotations
28653
28690
  }
@@ -28962,6 +28999,7 @@ var OpenAIResponsesLanguageModel = class {
28962
28999
  let responseId = null;
28963
29000
  const ongoingToolCalls = {};
28964
29001
  const ongoingAnnotations = [];
29002
+ let activeMessagePhase;
28965
29003
  let hasFunctionCall = false;
28966
29004
  const activeReasoning = {};
28967
29005
  let serviceTier;
@@ -28972,7 +29010,7 @@ var OpenAIResponsesLanguageModel = class {
28972
29010
  controller.enqueue({ type: "stream-start", warnings });
28973
29011
  },
28974
29012
  transform(chunk, controller) {
28975
- var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D;
29013
+ var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F;
28976
29014
  if (options.includeRawChunks) {
28977
29015
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
28978
29016
  }
@@ -29113,12 +29151,16 @@ var OpenAIResponsesLanguageModel = class {
29113
29151
  } else if (value.item.type === "shell_call_output") ;
29114
29152
  else if (value.item.type === "message") {
29115
29153
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
29154
+ activeMessagePhase = (_a10 = value.item.phase) != null ? _a10 : void 0;
29116
29155
  controller.enqueue({
29117
29156
  type: "text-start",
29118
29157
  id: value.item.id,
29119
29158
  providerMetadata: {
29120
29159
  [providerOptionsName]: {
29121
- itemId: value.item.id
29160
+ itemId: value.item.id,
29161
+ ...value.item.phase != null && {
29162
+ phase: value.item.phase
29163
+ }
29122
29164
  }
29123
29165
  }
29124
29166
  });
@@ -29133,19 +29175,22 @@ var OpenAIResponsesLanguageModel = class {
29133
29175
  providerMetadata: {
29134
29176
  [providerOptionsName]: {
29135
29177
  itemId: value.item.id,
29136
- reasoningEncryptedContent: (_a10 = value.item.encrypted_content) != null ? _a10 : null
29178
+ reasoningEncryptedContent: (_b9 = value.item.encrypted_content) != null ? _b9 : null
29137
29179
  }
29138
29180
  }
29139
29181
  });
29140
29182
  }
29141
29183
  } else if (isResponseOutputItemDoneChunk(value)) {
29142
29184
  if (value.item.type === "message") {
29185
+ const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
29186
+ activeMessagePhase = void 0;
29143
29187
  controller.enqueue({
29144
29188
  type: "text-end",
29145
29189
  id: value.item.id,
29146
29190
  providerMetadata: {
29147
29191
  [providerOptionsName]: {
29148
29192
  itemId: value.item.id,
29193
+ ...phase != null && { phase },
29149
29194
  ...ongoingAnnotations.length > 0 && {
29150
29195
  annotations: ongoingAnnotations
29151
29196
  }
@@ -29210,13 +29255,13 @@ var OpenAIResponsesLanguageModel = class {
29210
29255
  toolName: toolNameMapping.toCustomToolName("file_search"),
29211
29256
  result: {
29212
29257
  queries: value.item.queries,
29213
- results: (_c = (_b9 = value.item.results) == null ? void 0 : _b9.map((result) => ({
29258
+ results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
29214
29259
  attributes: result.attributes,
29215
29260
  fileId: result.file_id,
29216
29261
  filename: result.filename,
29217
29262
  score: result.score,
29218
29263
  text: result.text
29219
- }))) != null ? _c : null
29264
+ }))) != null ? _e : null
29220
29265
  }
29221
29266
  });
29222
29267
  } else if (value.item.type === "code_interpreter_call") {
@@ -29240,10 +29285,10 @@ var OpenAIResponsesLanguageModel = class {
29240
29285
  });
29241
29286
  } else if (value.item.type === "mcp_call") {
29242
29287
  ongoingToolCalls[value.output_index] = void 0;
29243
- const approvalRequestId = (_d = value.item.approval_request_id) != null ? _d : void 0;
29244
- const aliasedToolCallId = approvalRequestId != null ? (_f = (_e = approvalRequestIdToDummyToolCallIdFromStream.get(
29288
+ const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
29289
+ const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
29245
29290
  approvalRequestId
29246
- )) != null ? _e : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _f : value.item.id : value.item.id;
29291
+ )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
29247
29292
  const toolName = `mcp.${value.item.name}`;
29248
29293
  controller.enqueue({
29249
29294
  type: "tool-call",
@@ -29313,8 +29358,8 @@ var OpenAIResponsesLanguageModel = class {
29313
29358
  ongoingToolCalls[value.output_index] = void 0;
29314
29359
  } else if (value.item.type === "mcp_approval_request") {
29315
29360
  ongoingToolCalls[value.output_index] = void 0;
29316
- const dummyToolCallId = (_i = (_h = (_g = self2.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId$1();
29317
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : value.item.id;
29361
+ const dummyToolCallId = (_k = (_j = (_i = self2.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId$1();
29362
+ const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
29318
29363
  approvalRequestIdToDummyToolCallIdFromStream.set(
29319
29364
  approvalRequestId,
29320
29365
  dummyToolCallId
@@ -29403,7 +29448,7 @@ var OpenAIResponsesLanguageModel = class {
29403
29448
  providerMetadata: {
29404
29449
  [providerOptionsName]: {
29405
29450
  itemId: value.item.id,
29406
- reasoningEncryptedContent: (_k = value.item.encrypted_content) != null ? _k : null
29451
+ reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
29407
29452
  }
29408
29453
  }
29409
29454
  });
@@ -29507,7 +29552,7 @@ var OpenAIResponsesLanguageModel = class {
29507
29552
  id: value.item_id,
29508
29553
  delta: value.delta
29509
29554
  });
29510
- if (((_m = (_l = options.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.logprobs) && value.logprobs) {
29555
+ if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
29511
29556
  logprobs.push(value.logprobs);
29512
29557
  }
29513
29558
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -29536,7 +29581,7 @@ var OpenAIResponsesLanguageModel = class {
29536
29581
  providerMetadata: {
29537
29582
  [providerOptionsName]: {
29538
29583
  itemId: value.item_id,
29539
- reasoningEncryptedContent: (_o = (_n = activeReasoning[value.item_id]) == null ? void 0 : _n.encryptedContent) != null ? _o : null
29584
+ reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
29540
29585
  }
29541
29586
  }
29542
29587
  });
@@ -29570,10 +29615,10 @@ var OpenAIResponsesLanguageModel = class {
29570
29615
  } else if (isResponseFinishedChunk(value)) {
29571
29616
  finishReason = {
29572
29617
  unified: mapOpenAIResponseFinishReason({
29573
- finishReason: (_p = value.response.incomplete_details) == null ? void 0 : _p.reason,
29618
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
29574
29619
  hasFunctionCall
29575
29620
  }),
29576
- raw: (_r = (_q = value.response.incomplete_details) == null ? void 0 : _q.reason) != null ? _r : void 0
29621
+ raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
29577
29622
  };
29578
29623
  usage = value.response.usage;
29579
29624
  if (typeof value.response.service_tier === "string") {
@@ -29585,7 +29630,7 @@ var OpenAIResponsesLanguageModel = class {
29585
29630
  controller.enqueue({
29586
29631
  type: "source",
29587
29632
  sourceType: "url",
29588
- id: (_u = (_t = (_s = self2.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId$1(),
29633
+ id: (_w = (_v = (_u = self2.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId$1(),
29589
29634
  url: value.annotation.url,
29590
29635
  title: value.annotation.title
29591
29636
  });
@@ -29593,7 +29638,7 @@ var OpenAIResponsesLanguageModel = class {
29593
29638
  controller.enqueue({
29594
29639
  type: "source",
29595
29640
  sourceType: "document",
29596
- id: (_x = (_w = (_v = self2.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : generateId$1(),
29641
+ id: (_z = (_y = (_x = self2.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId$1(),
29597
29642
  mediaType: "text/plain",
29598
29643
  title: value.annotation.filename,
29599
29644
  filename: value.annotation.filename,
@@ -29609,7 +29654,7 @@ var OpenAIResponsesLanguageModel = class {
29609
29654
  controller.enqueue({
29610
29655
  type: "source",
29611
29656
  sourceType: "document",
29612
- id: (_A = (_z = (_y = self2.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId$1(),
29657
+ id: (_C = (_B = (_A = self2.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId$1(),
29613
29658
  mediaType: "text/plain",
29614
29659
  title: value.annotation.filename,
29615
29660
  filename: value.annotation.filename,
@@ -29625,7 +29670,7 @@ var OpenAIResponsesLanguageModel = class {
29625
29670
  controller.enqueue({
29626
29671
  type: "source",
29627
29672
  sourceType: "document",
29628
- id: (_D = (_C = (_B = self2.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId$1(),
29673
+ id: (_F = (_E = (_D = self2.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId$1(),
29629
29674
  mediaType: "application/octet-stream",
29630
29675
  title: value.annotation.file_id,
29631
29676
  filename: value.annotation.file_id,
@@ -30060,7 +30105,7 @@ var OpenAITranscriptionModel = class {
30060
30105
  };
30061
30106
  }
30062
30107
  };
30063
- var VERSION$2 = "3.0.33";
30108
+ var VERSION$2 = "3.0.36";
30064
30109
  function createOpenAI(options = {}) {
30065
30110
  var _a10, _b9;
30066
30111
  const baseURL = (_a10 = withoutTrailingSlash$1(