@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.
@@ -11671,7 +11671,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
11671
11671
  var _a92;
11672
11672
  return (_a92 = indexBrowserExports.getContext().headers) == null ? void 0 : _a92["x-vercel-id"];
11673
11673
  }
11674
- var VERSION$6 = "3.0.55";
11674
+ var VERSION$6 = "3.0.58";
11675
11675
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
11676
11676
  function createGatewayProvider(options = {}) {
11677
11677
  var _a92, _b9;
@@ -13193,6 +13193,17 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
13193
13193
  }
13194
13194
  };
13195
13195
  _a19 = symbol19;
13196
+ function asArray(value) {
13197
+ return value === void 0 ? [] : Array.isArray(value) ? value : [value];
13198
+ }
13199
+ async function notify(options) {
13200
+ for (const callback of asArray(options.callbacks)) {
13201
+ try {
13202
+ await callback(options.event);
13203
+ } catch (_ignored) {
13204
+ }
13205
+ }
13206
+ }
13196
13207
  function formatWarning({
13197
13208
  warning,
13198
13209
  provider,
@@ -13493,7 +13504,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
13493
13504
  }
13494
13505
  return void 0;
13495
13506
  }
13496
- var VERSION$4 = "6.0.99";
13507
+ var VERSION$4 = "6.0.104";
13497
13508
  var download = async ({
13498
13509
  url: url2,
13499
13510
  maxBytes,
@@ -13601,9 +13612,6 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
13601
13612
  }
13602
13613
  return convertUint8ArrayToBase64$1(content);
13603
13614
  }
13604
- function asArray(value) {
13605
- return value === void 0 ? [] : Array.isArray(value) ? value : [value];
13606
- }
13607
13615
  async function convertToLanguageModelPrompt({
13608
13616
  prompt,
13609
13617
  supportedUrls,
@@ -14970,10 +14978,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
14970
14978
  tracer,
14971
14979
  fn: async (span) => {
14972
14980
  let output;
14973
- try {
14974
- await (onToolCallStart == null ? void 0 : onToolCallStart(baseCallbackEvent));
14975
- } catch (_ignored) {
14976
- }
14981
+ await notify({ event: baseCallbackEvent, callbacks: onToolCallStart });
14977
14982
  const startTime = now();
14978
14983
  try {
14979
14984
  const stream = executeTool({
@@ -15000,15 +15005,15 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
15000
15005
  }
15001
15006
  } catch (error) {
15002
15007
  const durationMs2 = now() - startTime;
15003
- try {
15004
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
15008
+ await notify({
15009
+ event: {
15005
15010
  ...baseCallbackEvent,
15006
15011
  success: false,
15007
15012
  error,
15008
15013
  durationMs: durationMs2
15009
- }));
15010
- } catch (_ignored) {
15011
- }
15014
+ },
15015
+ callbacks: onToolCallFinish
15016
+ });
15012
15017
  recordErrorOnSpan(span, error);
15013
15018
  return {
15014
15019
  type: "tool-error",
@@ -15021,15 +15026,15 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
15021
15026
  };
15022
15027
  }
15023
15028
  const durationMs = now() - startTime;
15024
- try {
15025
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
15029
+ await notify({
15030
+ event: {
15026
15031
  ...baseCallbackEvent,
15027
15032
  success: true,
15028
15033
  output,
15029
15034
  durationMs
15030
- }));
15031
- } catch (_ignored) {
15032
- }
15035
+ },
15036
+ callbacks: onToolCallFinish
15037
+ });
15033
15038
  try {
15034
15039
  span.setAttributes(
15035
15040
  await selectTelemetryAttributes({
@@ -16192,8 +16197,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
16192
16197
  prompt,
16193
16198
  messages
16194
16199
  });
16195
- try {
16196
- await (onStart == null ? void 0 : onStart({
16200
+ await notify({
16201
+ event: {
16197
16202
  model: modelInfo,
16198
16203
  system,
16199
16204
  prompt,
@@ -16220,9 +16225,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
16220
16225
  functionId: telemetry == null ? void 0 : telemetry.functionId,
16221
16226
  metadata: telemetry == null ? void 0 : telemetry.metadata,
16222
16227
  experimental_context
16223
- }));
16224
- } catch (_ignored) {
16225
- }
16228
+ },
16229
+ callbacks: onStart
16230
+ });
16226
16231
  const tracer = getTracer(telemetry);
16227
16232
  try {
16228
16233
  return await recordSpan({
@@ -16372,8 +16377,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
16372
16377
  providerOptions,
16373
16378
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
16374
16379
  );
16375
- try {
16376
- await (onStepStart == null ? void 0 : onStepStart({
16380
+ await notify({
16381
+ event: {
16377
16382
  stepNumber: steps.length,
16378
16383
  model: stepModelInfo,
16379
16384
  system: stepSystem,
@@ -16392,9 +16397,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
16392
16397
  functionId: telemetry == null ? void 0 : telemetry.functionId,
16393
16398
  metadata: telemetry == null ? void 0 : telemetry.metadata,
16394
16399
  experimental_context
16395
- }));
16396
- } catch (_ignored) {
16397
- }
16400
+ },
16401
+ callbacks: onStepStart
16402
+ });
16398
16403
  currentModelResponse = await retry(
16399
16404
  () => {
16400
16405
  var _a22;
@@ -16639,7 +16644,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
16639
16644
  model: stepModelInfo.modelId
16640
16645
  });
16641
16646
  steps.push(currentStepResult);
16642
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
16647
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
16643
16648
  } finally {
16644
16649
  if (stepTimeoutId != null) {
16645
16650
  clearTimeout(stepTimeoutId);
@@ -16691,34 +16696,37 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
16691
16696
  cachedInputTokens: void 0
16692
16697
  }
16693
16698
  );
16694
- await (onFinish == null ? void 0 : onFinish({
16695
- stepNumber: lastStep.stepNumber,
16696
- model: lastStep.model,
16697
- functionId: lastStep.functionId,
16698
- metadata: lastStep.metadata,
16699
- experimental_context: lastStep.experimental_context,
16700
- finishReason: lastStep.finishReason,
16701
- rawFinishReason: lastStep.rawFinishReason,
16702
- usage: lastStep.usage,
16703
- content: lastStep.content,
16704
- text: lastStep.text,
16705
- reasoningText: lastStep.reasoningText,
16706
- reasoning: lastStep.reasoning,
16707
- files: lastStep.files,
16708
- sources: lastStep.sources,
16709
- toolCalls: lastStep.toolCalls,
16710
- staticToolCalls: lastStep.staticToolCalls,
16711
- dynamicToolCalls: lastStep.dynamicToolCalls,
16712
- toolResults: lastStep.toolResults,
16713
- staticToolResults: lastStep.staticToolResults,
16714
- dynamicToolResults: lastStep.dynamicToolResults,
16715
- request: lastStep.request,
16716
- response: lastStep.response,
16717
- warnings: lastStep.warnings,
16718
- providerMetadata: lastStep.providerMetadata,
16719
- steps,
16720
- totalUsage
16721
- }));
16699
+ await notify({
16700
+ event: {
16701
+ stepNumber: lastStep.stepNumber,
16702
+ model: lastStep.model,
16703
+ functionId: lastStep.functionId,
16704
+ metadata: lastStep.metadata,
16705
+ experimental_context: lastStep.experimental_context,
16706
+ finishReason: lastStep.finishReason,
16707
+ rawFinishReason: lastStep.rawFinishReason,
16708
+ usage: lastStep.usage,
16709
+ content: lastStep.content,
16710
+ text: lastStep.text,
16711
+ reasoningText: lastStep.reasoningText,
16712
+ reasoning: lastStep.reasoning,
16713
+ files: lastStep.files,
16714
+ sources: lastStep.sources,
16715
+ toolCalls: lastStep.toolCalls,
16716
+ staticToolCalls: lastStep.staticToolCalls,
16717
+ dynamicToolCalls: lastStep.dynamicToolCalls,
16718
+ toolResults: lastStep.toolResults,
16719
+ staticToolResults: lastStep.staticToolResults,
16720
+ dynamicToolResults: lastStep.dynamicToolResults,
16721
+ request: lastStep.request,
16722
+ response: lastStep.response,
16723
+ warnings: lastStep.warnings,
16724
+ providerMetadata: lastStep.providerMetadata,
16725
+ steps,
16726
+ totalUsage
16727
+ },
16728
+ callbacks: onFinish
16729
+ });
16722
16730
  let resolvedOutput;
16723
16731
  if (lastStep.finishReason === "stop") {
16724
16732
  const outputSpecification = output != null ? output : text();
@@ -17461,7 +17469,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
17461
17469
  break;
17462
17470
  }
17463
17471
  case "tool-input-error": {
17464
- if (chunk.dynamic) {
17472
+ const existingPart = state.message.parts.filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
17473
+ const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
17474
+ if (isDynamic) {
17465
17475
  updateDynamicToolPart({
17466
17476
  toolCallId: chunk.toolCallId,
17467
17477
  toolName: chunk.toolName,
@@ -18526,7 +18536,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
18526
18536
  },
18527
18537
  providerMetadata: part.providerMetadata
18528
18538
  });
18529
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
18539
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
18530
18540
  logWarnings({
18531
18541
  warnings: recordedWarnings,
18532
18542
  provider: modelInfo.provider,
@@ -18561,34 +18571,37 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
18561
18571
  self2._totalUsage.resolve(totalUsage);
18562
18572
  self2._steps.resolve(recordedSteps);
18563
18573
  const finalStep = recordedSteps[recordedSteps.length - 1];
18564
- await (onFinish == null ? void 0 : onFinish({
18565
- stepNumber: finalStep.stepNumber,
18566
- model: finalStep.model,
18567
- functionId: finalStep.functionId,
18568
- metadata: finalStep.metadata,
18569
- experimental_context: finalStep.experimental_context,
18570
- finishReason: finalStep.finishReason,
18571
- rawFinishReason: finalStep.rawFinishReason,
18572
- totalUsage,
18573
- usage: finalStep.usage,
18574
- content: finalStep.content,
18575
- text: finalStep.text,
18576
- reasoningText: finalStep.reasoningText,
18577
- reasoning: finalStep.reasoning,
18578
- files: finalStep.files,
18579
- sources: finalStep.sources,
18580
- toolCalls: finalStep.toolCalls,
18581
- staticToolCalls: finalStep.staticToolCalls,
18582
- dynamicToolCalls: finalStep.dynamicToolCalls,
18583
- toolResults: finalStep.toolResults,
18584
- staticToolResults: finalStep.staticToolResults,
18585
- dynamicToolResults: finalStep.dynamicToolResults,
18586
- request: finalStep.request,
18587
- response: finalStep.response,
18588
- warnings: finalStep.warnings,
18589
- providerMetadata: finalStep.providerMetadata,
18590
- steps: recordedSteps
18591
- }));
18574
+ await notify({
18575
+ event: {
18576
+ stepNumber: finalStep.stepNumber,
18577
+ model: finalStep.model,
18578
+ functionId: finalStep.functionId,
18579
+ metadata: finalStep.metadata,
18580
+ experimental_context: finalStep.experimental_context,
18581
+ finishReason: finalStep.finishReason,
18582
+ rawFinishReason: finalStep.rawFinishReason,
18583
+ totalUsage,
18584
+ usage: finalStep.usage,
18585
+ content: finalStep.content,
18586
+ text: finalStep.text,
18587
+ reasoningText: finalStep.reasoningText,
18588
+ reasoning: finalStep.reasoning,
18589
+ files: finalStep.files,
18590
+ sources: finalStep.sources,
18591
+ toolCalls: finalStep.toolCalls,
18592
+ staticToolCalls: finalStep.staticToolCalls,
18593
+ dynamicToolCalls: finalStep.dynamicToolCalls,
18594
+ toolResults: finalStep.toolResults,
18595
+ staticToolResults: finalStep.staticToolResults,
18596
+ dynamicToolResults: finalStep.dynamicToolResults,
18597
+ request: finalStep.request,
18598
+ response: finalStep.response,
18599
+ warnings: finalStep.warnings,
18600
+ providerMetadata: finalStep.providerMetadata,
18601
+ steps: recordedSteps
18602
+ },
18603
+ callbacks: onFinish
18604
+ });
18592
18605
  rootSpan.setAttributes(
18593
18606
  await selectTelemetryAttributes({
18594
18607
  telemetry,
@@ -18716,8 +18729,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
18716
18729
  prompt,
18717
18730
  messages
18718
18731
  });
18719
- try {
18720
- await (onStart == null ? void 0 : onStart({
18732
+ await notify({
18733
+ event: {
18721
18734
  model: modelInfo,
18722
18735
  system,
18723
18736
  prompt,
@@ -18743,9 +18756,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
18743
18756
  include,
18744
18757
  ...callbackTelemetryProps,
18745
18758
  experimental_context
18746
- }));
18747
- } catch (_ignored) {
18748
- }
18759
+ },
18760
+ callbacks: onStart
18761
+ });
18749
18762
  const initialMessages = initialPrompt.messages;
18750
18763
  const initialResponseMessages = [];
18751
18764
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -18926,8 +18939,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
18926
18939
  providerOptions,
18927
18940
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
18928
18941
  );
18929
- try {
18930
- await (onStepStart == null ? void 0 : onStepStart({
18942
+ await notify({
18943
+ event: {
18931
18944
  stepNumber: recordedSteps.length,
18932
18945
  model: stepModelInfo,
18933
18946
  system: stepSystem,
@@ -18945,9 +18958,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
18945
18958
  include,
18946
18959
  ...callbackTelemetryProps,
18947
18960
  experimental_context
18948
- }));
18949
- } catch (_ignored) {
18950
- }
18961
+ },
18962
+ callbacks: onStepStart
18963
+ });
18951
18964
  const {
18952
18965
  result: { stream: stream2, response, request },
18953
18966
  doStreamSpan,
@@ -25610,7 +25623,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
25610
25623
  for (const toolCallDelta of delta.tool_calls) {
25611
25624
  const index = toolCallDelta.index;
25612
25625
  if (toolCalls[index] == null) {
25613
- if (toolCallDelta.type !== "function") {
25626
+ if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
25614
25627
  throw new InvalidResponseDataError$1({
25615
25628
  data: toolCallDelta,
25616
25629
  message: `Expected 'function' type.`
@@ -26304,6 +26317,7 @@ ${user}:`]
26304
26317
  "chatgpt-image-latest": 10
26305
26318
  };
26306
26319
  var defaultResponseFormatPrefixes = [
26320
+ "chatgpt-image-",
26307
26321
  "gpt-image-1-mini",
26308
26322
  "gpt-image-1.5",
26309
26323
  "gpt-image-1"
@@ -27073,7 +27087,7 @@ ${user}:`]
27073
27087
  hasShellTool = false,
27074
27088
  hasApplyPatchTool = false
27075
27089
  }) {
27076
- var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
27090
+ var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
27077
27091
  const input = [];
27078
27092
  const warnings = [];
27079
27093
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -27154,7 +27168,9 @@ ${user}:`]
27154
27168
  for (const part of content) {
27155
27169
  switch (part.type) {
27156
27170
  case "text": {
27157
- const id2 = (_b9 = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName]) == null ? void 0 : _b9.itemId;
27171
+ const providerOpts = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName];
27172
+ const id2 = providerOpts == null ? void 0 : providerOpts.itemId;
27173
+ const phase = providerOpts == null ? void 0 : providerOpts.phase;
27158
27174
  if (hasConversation && id2 != null) {
27159
27175
  break;
27160
27176
  }
@@ -27165,12 +27181,13 @@ ${user}:`]
27165
27181
  input.push({
27166
27182
  role: "assistant",
27167
27183
  content: [{ type: "output_text", text: part.text }],
27168
- id: id2
27184
+ id: id2,
27185
+ ...phase != null && { phase }
27169
27186
  });
27170
27187
  break;
27171
27188
  }
27172
27189
  case "tool-call": {
27173
- 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;
27190
+ 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;
27174
27191
  if (hasConversation && id2 != null) {
27175
27192
  break;
27176
27193
  }
@@ -27281,7 +27298,7 @@ ${user}:`]
27281
27298
  break;
27282
27299
  }
27283
27300
  if (store) {
27284
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
27301
+ const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
27285
27302
  input.push({ type: "item_reference", id: itemId });
27286
27303
  } else {
27287
27304
  warnings.push({
@@ -27341,10 +27358,26 @@ ${user}:`]
27341
27358
  }
27342
27359
  }
27343
27360
  } else {
27344
- warnings.push({
27345
- type: "other",
27346
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
27347
- });
27361
+ const encryptedContent = providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent;
27362
+ if (encryptedContent != null) {
27363
+ const summaryParts = [];
27364
+ if (part.text.length > 0) {
27365
+ summaryParts.push({
27366
+ type: "summary_text",
27367
+ text: part.text
27368
+ });
27369
+ }
27370
+ input.push({
27371
+ type: "reasoning",
27372
+ encrypted_content: encryptedContent,
27373
+ summary: summaryParts
27374
+ });
27375
+ } else {
27376
+ warnings.push({
27377
+ type: "other",
27378
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
27379
+ });
27380
+ }
27348
27381
  }
27349
27382
  break;
27350
27383
  }
@@ -27375,7 +27408,7 @@ ${user}:`]
27375
27408
  }
27376
27409
  const output = part.output;
27377
27410
  if (output.type === "execution-denied") {
27378
- const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
27411
+ const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
27379
27412
  if (approvalId) {
27380
27413
  continue;
27381
27414
  }
@@ -27434,7 +27467,7 @@ ${user}:`]
27434
27467
  contentValue = output.value;
27435
27468
  break;
27436
27469
  case "execution-denied":
27437
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
27470
+ contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
27438
27471
  break;
27439
27472
  case "json":
27440
27473
  case "error-json":
@@ -27561,7 +27594,8 @@ ${user}:`]
27561
27594
  item: discriminatedUnion("type", [
27562
27595
  object$1({
27563
27596
  type: literal("message"),
27564
- id: string()
27597
+ id: string(),
27598
+ phase: _enum$1(["commentary", "final_answer"]).nullish()
27565
27599
  }),
27566
27600
  object$1({
27567
27601
  type: literal("reasoning"),
@@ -27678,7 +27712,8 @@ ${user}:`]
27678
27712
  item: discriminatedUnion("type", [
27679
27713
  object$1({
27680
27714
  type: literal("message"),
27681
- id: string()
27715
+ id: string(),
27716
+ phase: _enum$1(["commentary", "final_answer"]).nullish()
27682
27717
  }),
27683
27718
  object$1({
27684
27719
  type: literal("reasoning"),
@@ -27990,6 +28025,7 @@ ${user}:`]
27990
28025
  type: literal("message"),
27991
28026
  role: literal("assistant"),
27992
28027
  id: string(),
28028
+ phase: _enum$1(["commentary", "final_answer"]).nullish(),
27993
28029
  content: array$1(
27994
28030
  object$1({
27995
28031
  type: literal("output_text"),
@@ -29041,6 +29077,7 @@ ${user}:`]
29041
29077
  }
29042
29078
  const providerMetadata2 = {
29043
29079
  itemId: part.id,
29080
+ ...part.phase != null && { phase: part.phase },
29044
29081
  ...contentPart.annotations.length > 0 && {
29045
29082
  annotations: contentPart.annotations
29046
29083
  }
@@ -29355,6 +29392,7 @@ ${user}:`]
29355
29392
  let responseId = null;
29356
29393
  const ongoingToolCalls = {};
29357
29394
  const ongoingAnnotations = [];
29395
+ let activeMessagePhase;
29358
29396
  let hasFunctionCall = false;
29359
29397
  const activeReasoning = {};
29360
29398
  let serviceTier;
@@ -29365,7 +29403,7 @@ ${user}:`]
29365
29403
  controller.enqueue({ type: "stream-start", warnings });
29366
29404
  },
29367
29405
  transform(chunk, controller) {
29368
- 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;
29406
+ 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;
29369
29407
  if (options.includeRawChunks) {
29370
29408
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
29371
29409
  }
@@ -29506,12 +29544,16 @@ ${user}:`]
29506
29544
  } else if (value.item.type === "shell_call_output") ;
29507
29545
  else if (value.item.type === "message") {
29508
29546
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
29547
+ activeMessagePhase = (_a10 = value.item.phase) != null ? _a10 : void 0;
29509
29548
  controller.enqueue({
29510
29549
  type: "text-start",
29511
29550
  id: value.item.id,
29512
29551
  providerMetadata: {
29513
29552
  [providerOptionsName]: {
29514
- itemId: value.item.id
29553
+ itemId: value.item.id,
29554
+ ...value.item.phase != null && {
29555
+ phase: value.item.phase
29556
+ }
29515
29557
  }
29516
29558
  }
29517
29559
  });
@@ -29526,19 +29568,22 @@ ${user}:`]
29526
29568
  providerMetadata: {
29527
29569
  [providerOptionsName]: {
29528
29570
  itemId: value.item.id,
29529
- reasoningEncryptedContent: (_a10 = value.item.encrypted_content) != null ? _a10 : null
29571
+ reasoningEncryptedContent: (_b9 = value.item.encrypted_content) != null ? _b9 : null
29530
29572
  }
29531
29573
  }
29532
29574
  });
29533
29575
  }
29534
29576
  } else if (isResponseOutputItemDoneChunk(value)) {
29535
29577
  if (value.item.type === "message") {
29578
+ const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
29579
+ activeMessagePhase = void 0;
29536
29580
  controller.enqueue({
29537
29581
  type: "text-end",
29538
29582
  id: value.item.id,
29539
29583
  providerMetadata: {
29540
29584
  [providerOptionsName]: {
29541
29585
  itemId: value.item.id,
29586
+ ...phase != null && { phase },
29542
29587
  ...ongoingAnnotations.length > 0 && {
29543
29588
  annotations: ongoingAnnotations
29544
29589
  }
@@ -29603,13 +29648,13 @@ ${user}:`]
29603
29648
  toolName: toolNameMapping.toCustomToolName("file_search"),
29604
29649
  result: {
29605
29650
  queries: value.item.queries,
29606
- results: (_c = (_b9 = value.item.results) == null ? void 0 : _b9.map((result) => ({
29651
+ results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
29607
29652
  attributes: result.attributes,
29608
29653
  fileId: result.file_id,
29609
29654
  filename: result.filename,
29610
29655
  score: result.score,
29611
29656
  text: result.text
29612
- }))) != null ? _c : null
29657
+ }))) != null ? _e : null
29613
29658
  }
29614
29659
  });
29615
29660
  } else if (value.item.type === "code_interpreter_call") {
@@ -29633,10 +29678,10 @@ ${user}:`]
29633
29678
  });
29634
29679
  } else if (value.item.type === "mcp_call") {
29635
29680
  ongoingToolCalls[value.output_index] = void 0;
29636
- const approvalRequestId = (_d = value.item.approval_request_id) != null ? _d : void 0;
29637
- const aliasedToolCallId = approvalRequestId != null ? (_f = (_e = approvalRequestIdToDummyToolCallIdFromStream.get(
29681
+ const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
29682
+ const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
29638
29683
  approvalRequestId
29639
- )) != null ? _e : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _f : value.item.id : value.item.id;
29684
+ )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
29640
29685
  const toolName = `mcp.${value.item.name}`;
29641
29686
  controller.enqueue({
29642
29687
  type: "tool-call",
@@ -29706,8 +29751,8 @@ ${user}:`]
29706
29751
  ongoingToolCalls[value.output_index] = void 0;
29707
29752
  } else if (value.item.type === "mcp_approval_request") {
29708
29753
  ongoingToolCalls[value.output_index] = void 0;
29709
- const dummyToolCallId = (_i = (_h = (_g = self2.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId$1();
29710
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : value.item.id;
29754
+ const dummyToolCallId = (_k = (_j = (_i = self2.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId$1();
29755
+ const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
29711
29756
  approvalRequestIdToDummyToolCallIdFromStream.set(
29712
29757
  approvalRequestId,
29713
29758
  dummyToolCallId
@@ -29796,7 +29841,7 @@ ${user}:`]
29796
29841
  providerMetadata: {
29797
29842
  [providerOptionsName]: {
29798
29843
  itemId: value.item.id,
29799
- reasoningEncryptedContent: (_k = value.item.encrypted_content) != null ? _k : null
29844
+ reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
29800
29845
  }
29801
29846
  }
29802
29847
  });
@@ -29900,7 +29945,7 @@ ${user}:`]
29900
29945
  id: value.item_id,
29901
29946
  delta: value.delta
29902
29947
  });
29903
- if (((_m = (_l = options.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.logprobs) && value.logprobs) {
29948
+ if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
29904
29949
  logprobs.push(value.logprobs);
29905
29950
  }
29906
29951
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -29929,7 +29974,7 @@ ${user}:`]
29929
29974
  providerMetadata: {
29930
29975
  [providerOptionsName]: {
29931
29976
  itemId: value.item_id,
29932
- reasoningEncryptedContent: (_o = (_n = activeReasoning[value.item_id]) == null ? void 0 : _n.encryptedContent) != null ? _o : null
29977
+ reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
29933
29978
  }
29934
29979
  }
29935
29980
  });
@@ -29963,10 +30008,10 @@ ${user}:`]
29963
30008
  } else if (isResponseFinishedChunk(value)) {
29964
30009
  finishReason = {
29965
30010
  unified: mapOpenAIResponseFinishReason({
29966
- finishReason: (_p = value.response.incomplete_details) == null ? void 0 : _p.reason,
30011
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
29967
30012
  hasFunctionCall
29968
30013
  }),
29969
- raw: (_r = (_q = value.response.incomplete_details) == null ? void 0 : _q.reason) != null ? _r : void 0
30014
+ raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
29970
30015
  };
29971
30016
  usage = value.response.usage;
29972
30017
  if (typeof value.response.service_tier === "string") {
@@ -29978,7 +30023,7 @@ ${user}:`]
29978
30023
  controller.enqueue({
29979
30024
  type: "source",
29980
30025
  sourceType: "url",
29981
- id: (_u = (_t = (_s = self2.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId$1(),
30026
+ id: (_w = (_v = (_u = self2.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId$1(),
29982
30027
  url: value.annotation.url,
29983
30028
  title: value.annotation.title
29984
30029
  });
@@ -29986,7 +30031,7 @@ ${user}:`]
29986
30031
  controller.enqueue({
29987
30032
  type: "source",
29988
30033
  sourceType: "document",
29989
- id: (_x = (_w = (_v = self2.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : generateId$1(),
30034
+ id: (_z = (_y = (_x = self2.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId$1(),
29990
30035
  mediaType: "text/plain",
29991
30036
  title: value.annotation.filename,
29992
30037
  filename: value.annotation.filename,
@@ -30002,7 +30047,7 @@ ${user}:`]
30002
30047
  controller.enqueue({
30003
30048
  type: "source",
30004
30049
  sourceType: "document",
30005
- id: (_A = (_z = (_y = self2.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId$1(),
30050
+ id: (_C = (_B = (_A = self2.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId$1(),
30006
30051
  mediaType: "text/plain",
30007
30052
  title: value.annotation.filename,
30008
30053
  filename: value.annotation.filename,
@@ -30018,7 +30063,7 @@ ${user}:`]
30018
30063
  controller.enqueue({
30019
30064
  type: "source",
30020
30065
  sourceType: "document",
30021
- id: (_D = (_C = (_B = self2.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId$1(),
30066
+ id: (_F = (_E = (_D = self2.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId$1(),
30022
30067
  mediaType: "application/octet-stream",
30023
30068
  title: value.annotation.file_id,
30024
30069
  filename: value.annotation.file_id,
@@ -30453,7 +30498,7 @@ ${user}:`]
30453
30498
  };
30454
30499
  }
30455
30500
  };
30456
- var VERSION$2 = "3.0.33";
30501
+ var VERSION$2 = "3.0.36";
30457
30502
  function createOpenAI(options = {}) {
30458
30503
  var _a10, _b9;
30459
30504
  const baseURL = (_a10 = withoutTrailingSlash$1(