@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.
@@ -31548,7 +31548,7 @@ async function getVercelRequestId() {
31548
31548
  var _a92;
31549
31549
  return (_a92 = indexBrowserExports.getContext().headers) == null ? void 0 : _a92["x-vercel-id"];
31550
31550
  }
31551
- var VERSION$6 = "3.0.55";
31551
+ var VERSION$6 = "3.0.58";
31552
31552
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
31553
31553
  function createGatewayProvider(options = {}) {
31554
31554
  var _a92, _b9;
@@ -32681,6 +32681,17 @@ var RetryError = class extends AISDKError$1 {
32681
32681
  }
32682
32682
  };
32683
32683
  _a19 = symbol19;
32684
+ function asArray(value) {
32685
+ return value === void 0 ? [] : Array.isArray(value) ? value : [value];
32686
+ }
32687
+ async function notify(options) {
32688
+ for (const callback of asArray(options.callbacks)) {
32689
+ try {
32690
+ await callback(options.event);
32691
+ } catch (_ignored) {
32692
+ }
32693
+ }
32694
+ }
32684
32695
  function formatWarning({
32685
32696
  warning,
32686
32697
  provider,
@@ -32981,7 +32992,7 @@ function detectMediaType({
32981
32992
  }
32982
32993
  return void 0;
32983
32994
  }
32984
- var VERSION$4 = "6.0.99";
32995
+ var VERSION$4 = "6.0.104";
32985
32996
  var download = async ({
32986
32997
  url: url2,
32987
32998
  maxBytes,
@@ -33089,9 +33100,6 @@ function convertDataContentToBase64String(content) {
33089
33100
  }
33090
33101
  return convertUint8ArrayToBase64$1(content);
33091
33102
  }
33092
- function asArray(value) {
33093
- return value === void 0 ? [] : Array.isArray(value) ? value : [value];
33094
- }
33095
33103
  async function convertToLanguageModelPrompt({
33096
33104
  prompt,
33097
33105
  supportedUrls,
@@ -34458,10 +34466,7 @@ async function executeToolCall({
34458
34466
  tracer,
34459
34467
  fn: async (span) => {
34460
34468
  let output;
34461
- try {
34462
- await (onToolCallStart == null ? void 0 : onToolCallStart(baseCallbackEvent));
34463
- } catch (_ignored) {
34464
- }
34469
+ await notify({ event: baseCallbackEvent, callbacks: onToolCallStart });
34465
34470
  const startTime = now();
34466
34471
  try {
34467
34472
  const stream = executeTool({
@@ -34488,15 +34493,15 @@ async function executeToolCall({
34488
34493
  }
34489
34494
  } catch (error) {
34490
34495
  const durationMs2 = now() - startTime;
34491
- try {
34492
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
34496
+ await notify({
34497
+ event: {
34493
34498
  ...baseCallbackEvent,
34494
34499
  success: false,
34495
34500
  error,
34496
34501
  durationMs: durationMs2
34497
- }));
34498
- } catch (_ignored) {
34499
- }
34502
+ },
34503
+ callbacks: onToolCallFinish
34504
+ });
34500
34505
  recordErrorOnSpan(span, error);
34501
34506
  return {
34502
34507
  type: "tool-error",
@@ -34509,15 +34514,15 @@ async function executeToolCall({
34509
34514
  };
34510
34515
  }
34511
34516
  const durationMs = now() - startTime;
34512
- try {
34513
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
34517
+ await notify({
34518
+ event: {
34514
34519
  ...baseCallbackEvent,
34515
34520
  success: true,
34516
34521
  output,
34517
34522
  durationMs
34518
- }));
34519
- } catch (_ignored) {
34520
- }
34523
+ },
34524
+ callbacks: onToolCallFinish
34525
+ });
34521
34526
  try {
34522
34527
  span.setAttributes(
34523
34528
  await selectTelemetryAttributes({
@@ -35680,8 +35685,8 @@ async function generateText({
35680
35685
  prompt,
35681
35686
  messages
35682
35687
  });
35683
- try {
35684
- await (onStart == null ? void 0 : onStart({
35688
+ await notify({
35689
+ event: {
35685
35690
  model: modelInfo,
35686
35691
  system,
35687
35692
  prompt,
@@ -35708,9 +35713,9 @@ async function generateText({
35708
35713
  functionId: telemetry == null ? void 0 : telemetry.functionId,
35709
35714
  metadata: telemetry == null ? void 0 : telemetry.metadata,
35710
35715
  experimental_context
35711
- }));
35712
- } catch (_ignored) {
35713
- }
35716
+ },
35717
+ callbacks: onStart
35718
+ });
35714
35719
  const tracer = getTracer(telemetry);
35715
35720
  try {
35716
35721
  return await recordSpan({
@@ -35860,8 +35865,8 @@ async function generateText({
35860
35865
  providerOptions,
35861
35866
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
35862
35867
  );
35863
- try {
35864
- await (onStepStart == null ? void 0 : onStepStart({
35868
+ await notify({
35869
+ event: {
35865
35870
  stepNumber: steps.length,
35866
35871
  model: stepModelInfo,
35867
35872
  system: stepSystem,
@@ -35880,9 +35885,9 @@ async function generateText({
35880
35885
  functionId: telemetry == null ? void 0 : telemetry.functionId,
35881
35886
  metadata: telemetry == null ? void 0 : telemetry.metadata,
35882
35887
  experimental_context
35883
- }));
35884
- } catch (_ignored) {
35885
- }
35888
+ },
35889
+ callbacks: onStepStart
35890
+ });
35886
35891
  currentModelResponse = await retry(
35887
35892
  () => {
35888
35893
  var _a22;
@@ -36127,7 +36132,7 @@ async function generateText({
36127
36132
  model: stepModelInfo.modelId
36128
36133
  });
36129
36134
  steps.push(currentStepResult);
36130
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
36135
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
36131
36136
  } finally {
36132
36137
  if (stepTimeoutId != null) {
36133
36138
  clearTimeout(stepTimeoutId);
@@ -36179,34 +36184,37 @@ async function generateText({
36179
36184
  cachedInputTokens: void 0
36180
36185
  }
36181
36186
  );
36182
- await (onFinish == null ? void 0 : onFinish({
36183
- stepNumber: lastStep.stepNumber,
36184
- model: lastStep.model,
36185
- functionId: lastStep.functionId,
36186
- metadata: lastStep.metadata,
36187
- experimental_context: lastStep.experimental_context,
36188
- finishReason: lastStep.finishReason,
36189
- rawFinishReason: lastStep.rawFinishReason,
36190
- usage: lastStep.usage,
36191
- content: lastStep.content,
36192
- text: lastStep.text,
36193
- reasoningText: lastStep.reasoningText,
36194
- reasoning: lastStep.reasoning,
36195
- files: lastStep.files,
36196
- sources: lastStep.sources,
36197
- toolCalls: lastStep.toolCalls,
36198
- staticToolCalls: lastStep.staticToolCalls,
36199
- dynamicToolCalls: lastStep.dynamicToolCalls,
36200
- toolResults: lastStep.toolResults,
36201
- staticToolResults: lastStep.staticToolResults,
36202
- dynamicToolResults: lastStep.dynamicToolResults,
36203
- request: lastStep.request,
36204
- response: lastStep.response,
36205
- warnings: lastStep.warnings,
36206
- providerMetadata: lastStep.providerMetadata,
36207
- steps,
36208
- totalUsage
36209
- }));
36187
+ await notify({
36188
+ event: {
36189
+ stepNumber: lastStep.stepNumber,
36190
+ model: lastStep.model,
36191
+ functionId: lastStep.functionId,
36192
+ metadata: lastStep.metadata,
36193
+ experimental_context: lastStep.experimental_context,
36194
+ finishReason: lastStep.finishReason,
36195
+ rawFinishReason: lastStep.rawFinishReason,
36196
+ usage: lastStep.usage,
36197
+ content: lastStep.content,
36198
+ text: lastStep.text,
36199
+ reasoningText: lastStep.reasoningText,
36200
+ reasoning: lastStep.reasoning,
36201
+ files: lastStep.files,
36202
+ sources: lastStep.sources,
36203
+ toolCalls: lastStep.toolCalls,
36204
+ staticToolCalls: lastStep.staticToolCalls,
36205
+ dynamicToolCalls: lastStep.dynamicToolCalls,
36206
+ toolResults: lastStep.toolResults,
36207
+ staticToolResults: lastStep.staticToolResults,
36208
+ dynamicToolResults: lastStep.dynamicToolResults,
36209
+ request: lastStep.request,
36210
+ response: lastStep.response,
36211
+ warnings: lastStep.warnings,
36212
+ providerMetadata: lastStep.providerMetadata,
36213
+ steps,
36214
+ totalUsage
36215
+ },
36216
+ callbacks: onFinish
36217
+ });
36210
36218
  let resolvedOutput;
36211
36219
  if (lastStep.finishReason === "stop") {
36212
36220
  const outputSpecification = output != null ? output : text();
@@ -36949,7 +36957,9 @@ function processUIMessageStream({
36949
36957
  break;
36950
36958
  }
36951
36959
  case "tool-input-error": {
36952
- if (chunk.dynamic) {
36960
+ const existingPart = state.message.parts.filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
36961
+ const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
36962
+ if (isDynamic) {
36953
36963
  updateDynamicToolPart({
36954
36964
  toolCallId: chunk.toolCallId,
36955
36965
  toolName: chunk.toolName,
@@ -38014,7 +38024,7 @@ var DefaultStreamTextResult = class {
38014
38024
  },
38015
38025
  providerMetadata: part.providerMetadata
38016
38026
  });
38017
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
38027
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
38018
38028
  logWarnings({
38019
38029
  warnings: recordedWarnings,
38020
38030
  provider: modelInfo.provider,
@@ -38049,34 +38059,37 @@ var DefaultStreamTextResult = class {
38049
38059
  self2._totalUsage.resolve(totalUsage);
38050
38060
  self2._steps.resolve(recordedSteps);
38051
38061
  const finalStep = recordedSteps[recordedSteps.length - 1];
38052
- await (onFinish == null ? void 0 : onFinish({
38053
- stepNumber: finalStep.stepNumber,
38054
- model: finalStep.model,
38055
- functionId: finalStep.functionId,
38056
- metadata: finalStep.metadata,
38057
- experimental_context: finalStep.experimental_context,
38058
- finishReason: finalStep.finishReason,
38059
- rawFinishReason: finalStep.rawFinishReason,
38060
- totalUsage,
38061
- usage: finalStep.usage,
38062
- content: finalStep.content,
38063
- text: finalStep.text,
38064
- reasoningText: finalStep.reasoningText,
38065
- reasoning: finalStep.reasoning,
38066
- files: finalStep.files,
38067
- sources: finalStep.sources,
38068
- toolCalls: finalStep.toolCalls,
38069
- staticToolCalls: finalStep.staticToolCalls,
38070
- dynamicToolCalls: finalStep.dynamicToolCalls,
38071
- toolResults: finalStep.toolResults,
38072
- staticToolResults: finalStep.staticToolResults,
38073
- dynamicToolResults: finalStep.dynamicToolResults,
38074
- request: finalStep.request,
38075
- response: finalStep.response,
38076
- warnings: finalStep.warnings,
38077
- providerMetadata: finalStep.providerMetadata,
38078
- steps: recordedSteps
38079
- }));
38062
+ await notify({
38063
+ event: {
38064
+ stepNumber: finalStep.stepNumber,
38065
+ model: finalStep.model,
38066
+ functionId: finalStep.functionId,
38067
+ metadata: finalStep.metadata,
38068
+ experimental_context: finalStep.experimental_context,
38069
+ finishReason: finalStep.finishReason,
38070
+ rawFinishReason: finalStep.rawFinishReason,
38071
+ totalUsage,
38072
+ usage: finalStep.usage,
38073
+ content: finalStep.content,
38074
+ text: finalStep.text,
38075
+ reasoningText: finalStep.reasoningText,
38076
+ reasoning: finalStep.reasoning,
38077
+ files: finalStep.files,
38078
+ sources: finalStep.sources,
38079
+ toolCalls: finalStep.toolCalls,
38080
+ staticToolCalls: finalStep.staticToolCalls,
38081
+ dynamicToolCalls: finalStep.dynamicToolCalls,
38082
+ toolResults: finalStep.toolResults,
38083
+ staticToolResults: finalStep.staticToolResults,
38084
+ dynamicToolResults: finalStep.dynamicToolResults,
38085
+ request: finalStep.request,
38086
+ response: finalStep.response,
38087
+ warnings: finalStep.warnings,
38088
+ providerMetadata: finalStep.providerMetadata,
38089
+ steps: recordedSteps
38090
+ },
38091
+ callbacks: onFinish
38092
+ });
38080
38093
  rootSpan.setAttributes(
38081
38094
  await selectTelemetryAttributes({
38082
38095
  telemetry,
@@ -38204,8 +38217,8 @@ var DefaultStreamTextResult = class {
38204
38217
  prompt,
38205
38218
  messages
38206
38219
  });
38207
- try {
38208
- await (onStart == null ? void 0 : onStart({
38220
+ await notify({
38221
+ event: {
38209
38222
  model: modelInfo,
38210
38223
  system,
38211
38224
  prompt,
@@ -38231,9 +38244,9 @@ var DefaultStreamTextResult = class {
38231
38244
  include,
38232
38245
  ...callbackTelemetryProps,
38233
38246
  experimental_context
38234
- }));
38235
- } catch (_ignored) {
38236
- }
38247
+ },
38248
+ callbacks: onStart
38249
+ });
38237
38250
  const initialMessages = initialPrompt.messages;
38238
38251
  const initialResponseMessages = [];
38239
38252
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -38414,8 +38427,8 @@ var DefaultStreamTextResult = class {
38414
38427
  providerOptions,
38415
38428
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
38416
38429
  );
38417
- try {
38418
- await (onStepStart == null ? void 0 : onStepStart({
38430
+ await notify({
38431
+ event: {
38419
38432
  stepNumber: recordedSteps.length,
38420
38433
  model: stepModelInfo,
38421
38434
  system: stepSystem,
@@ -38433,9 +38446,9 @@ var DefaultStreamTextResult = class {
38433
38446
  include,
38434
38447
  ...callbackTelemetryProps,
38435
38448
  experimental_context
38436
- }));
38437
- } catch (_ignored) {
38438
- }
38449
+ },
38450
+ callbacks: onStepStart
38451
+ });
38439
38452
  const {
38440
38453
  result: { stream: stream2, response, request },
38441
38454
  doStreamSpan,
@@ -42350,7 +42363,7 @@ var OpenAIChatLanguageModel = class {
42350
42363
  for (const toolCallDelta of delta.tool_calls) {
42351
42364
  const index = toolCallDelta.index;
42352
42365
  if (toolCalls[index] == null) {
42353
- if (toolCallDelta.type !== "function") {
42366
+ if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
42354
42367
  throw new InvalidResponseDataError$1({
42355
42368
  data: toolCallDelta,
42356
42369
  message: `Expected 'function' type.`
@@ -43044,6 +43057,7 @@ var modelMaxImagesPerCall = {
43044
43057
  "chatgpt-image-latest": 10
43045
43058
  };
43046
43059
  var defaultResponseFormatPrefixes = [
43060
+ "chatgpt-image-",
43047
43061
  "gpt-image-1-mini",
43048
43062
  "gpt-image-1.5",
43049
43063
  "gpt-image-1"
@@ -43813,7 +43827,7 @@ async function convertToOpenAIResponsesInput({
43813
43827
  hasShellTool = false,
43814
43828
  hasApplyPatchTool = false
43815
43829
  }) {
43816
- var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
43830
+ var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
43817
43831
  const input = [];
43818
43832
  const warnings = [];
43819
43833
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -43894,7 +43908,9 @@ async function convertToOpenAIResponsesInput({
43894
43908
  for (const part of content) {
43895
43909
  switch (part.type) {
43896
43910
  case "text": {
43897
- const id2 = (_b9 = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName]) == null ? void 0 : _b9.itemId;
43911
+ const providerOpts = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName];
43912
+ const id2 = providerOpts == null ? void 0 : providerOpts.itemId;
43913
+ const phase = providerOpts == null ? void 0 : providerOpts.phase;
43898
43914
  if (hasConversation && id2 != null) {
43899
43915
  break;
43900
43916
  }
@@ -43905,12 +43921,13 @@ async function convertToOpenAIResponsesInput({
43905
43921
  input.push({
43906
43922
  role: "assistant",
43907
43923
  content: [{ type: "output_text", text: part.text }],
43908
- id: id2
43924
+ id: id2,
43925
+ ...phase != null && { phase }
43909
43926
  });
43910
43927
  break;
43911
43928
  }
43912
43929
  case "tool-call": {
43913
- 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;
43930
+ 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;
43914
43931
  if (hasConversation && id2 != null) {
43915
43932
  break;
43916
43933
  }
@@ -44021,7 +44038,7 @@ async function convertToOpenAIResponsesInput({
44021
44038
  break;
44022
44039
  }
44023
44040
  if (store) {
44024
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
44041
+ const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
44025
44042
  input.push({ type: "item_reference", id: itemId });
44026
44043
  } else {
44027
44044
  warnings.push({
@@ -44081,10 +44098,26 @@ async function convertToOpenAIResponsesInput({
44081
44098
  }
44082
44099
  }
44083
44100
  } else {
44084
- warnings.push({
44085
- type: "other",
44086
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
44087
- });
44101
+ const encryptedContent = providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent;
44102
+ if (encryptedContent != null) {
44103
+ const summaryParts = [];
44104
+ if (part.text.length > 0) {
44105
+ summaryParts.push({
44106
+ type: "summary_text",
44107
+ text: part.text
44108
+ });
44109
+ }
44110
+ input.push({
44111
+ type: "reasoning",
44112
+ encrypted_content: encryptedContent,
44113
+ summary: summaryParts
44114
+ });
44115
+ } else {
44116
+ warnings.push({
44117
+ type: "other",
44118
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
44119
+ });
44120
+ }
44088
44121
  }
44089
44122
  break;
44090
44123
  }
@@ -44115,7 +44148,7 @@ async function convertToOpenAIResponsesInput({
44115
44148
  }
44116
44149
  const output = part.output;
44117
44150
  if (output.type === "execution-denied") {
44118
- const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
44151
+ const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
44119
44152
  if (approvalId) {
44120
44153
  continue;
44121
44154
  }
@@ -44174,7 +44207,7 @@ async function convertToOpenAIResponsesInput({
44174
44207
  contentValue = output.value;
44175
44208
  break;
44176
44209
  case "execution-denied":
44177
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
44210
+ contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
44178
44211
  break;
44179
44212
  case "json":
44180
44213
  case "error-json":
@@ -44301,7 +44334,8 @@ var openaiResponsesChunkSchema = lazySchema(
44301
44334
  item: discriminatedUnion("type", [
44302
44335
  object$2({
44303
44336
  type: literal("message"),
44304
- id: string()
44337
+ id: string(),
44338
+ phase: _enum(["commentary", "final_answer"]).nullish()
44305
44339
  }),
44306
44340
  object$2({
44307
44341
  type: literal("reasoning"),
@@ -44418,7 +44452,8 @@ var openaiResponsesChunkSchema = lazySchema(
44418
44452
  item: discriminatedUnion("type", [
44419
44453
  object$2({
44420
44454
  type: literal("message"),
44421
- id: string()
44455
+ id: string(),
44456
+ phase: _enum(["commentary", "final_answer"]).nullish()
44422
44457
  }),
44423
44458
  object$2({
44424
44459
  type: literal("reasoning"),
@@ -44730,6 +44765,7 @@ var openaiResponsesResponseSchema = lazySchema(
44730
44765
  type: literal("message"),
44731
44766
  role: literal("assistant"),
44732
44767
  id: string(),
44768
+ phase: _enum(["commentary", "final_answer"]).nullish(),
44733
44769
  content: array$1(
44734
44770
  object$2({
44735
44771
  type: literal("output_text"),
@@ -45781,6 +45817,7 @@ var OpenAIResponsesLanguageModel = class {
45781
45817
  }
45782
45818
  const providerMetadata2 = {
45783
45819
  itemId: part.id,
45820
+ ...part.phase != null && { phase: part.phase },
45784
45821
  ...contentPart.annotations.length > 0 && {
45785
45822
  annotations: contentPart.annotations
45786
45823
  }
@@ -46095,6 +46132,7 @@ var OpenAIResponsesLanguageModel = class {
46095
46132
  let responseId = null;
46096
46133
  const ongoingToolCalls = {};
46097
46134
  const ongoingAnnotations = [];
46135
+ let activeMessagePhase;
46098
46136
  let hasFunctionCall = false;
46099
46137
  const activeReasoning = {};
46100
46138
  let serviceTier;
@@ -46105,7 +46143,7 @@ var OpenAIResponsesLanguageModel = class {
46105
46143
  controller.enqueue({ type: "stream-start", warnings });
46106
46144
  },
46107
46145
  transform(chunk, controller) {
46108
- 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;
46146
+ 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;
46109
46147
  if (options.includeRawChunks) {
46110
46148
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
46111
46149
  }
@@ -46246,12 +46284,16 @@ var OpenAIResponsesLanguageModel = class {
46246
46284
  } else if (value.item.type === "shell_call_output") ;
46247
46285
  else if (value.item.type === "message") {
46248
46286
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
46287
+ activeMessagePhase = (_a10 = value.item.phase) != null ? _a10 : void 0;
46249
46288
  controller.enqueue({
46250
46289
  type: "text-start",
46251
46290
  id: value.item.id,
46252
46291
  providerMetadata: {
46253
46292
  [providerOptionsName]: {
46254
- itemId: value.item.id
46293
+ itemId: value.item.id,
46294
+ ...value.item.phase != null && {
46295
+ phase: value.item.phase
46296
+ }
46255
46297
  }
46256
46298
  }
46257
46299
  });
@@ -46266,19 +46308,22 @@ var OpenAIResponsesLanguageModel = class {
46266
46308
  providerMetadata: {
46267
46309
  [providerOptionsName]: {
46268
46310
  itemId: value.item.id,
46269
- reasoningEncryptedContent: (_a10 = value.item.encrypted_content) != null ? _a10 : null
46311
+ reasoningEncryptedContent: (_b9 = value.item.encrypted_content) != null ? _b9 : null
46270
46312
  }
46271
46313
  }
46272
46314
  });
46273
46315
  }
46274
46316
  } else if (isResponseOutputItemDoneChunk(value)) {
46275
46317
  if (value.item.type === "message") {
46318
+ const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
46319
+ activeMessagePhase = void 0;
46276
46320
  controller.enqueue({
46277
46321
  type: "text-end",
46278
46322
  id: value.item.id,
46279
46323
  providerMetadata: {
46280
46324
  [providerOptionsName]: {
46281
46325
  itemId: value.item.id,
46326
+ ...phase != null && { phase },
46282
46327
  ...ongoingAnnotations.length > 0 && {
46283
46328
  annotations: ongoingAnnotations
46284
46329
  }
@@ -46343,13 +46388,13 @@ var OpenAIResponsesLanguageModel = class {
46343
46388
  toolName: toolNameMapping.toCustomToolName("file_search"),
46344
46389
  result: {
46345
46390
  queries: value.item.queries,
46346
- results: (_c = (_b9 = value.item.results) == null ? void 0 : _b9.map((result) => ({
46391
+ results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
46347
46392
  attributes: result.attributes,
46348
46393
  fileId: result.file_id,
46349
46394
  filename: result.filename,
46350
46395
  score: result.score,
46351
46396
  text: result.text
46352
- }))) != null ? _c : null
46397
+ }))) != null ? _e : null
46353
46398
  }
46354
46399
  });
46355
46400
  } else if (value.item.type === "code_interpreter_call") {
@@ -46373,10 +46418,10 @@ var OpenAIResponsesLanguageModel = class {
46373
46418
  });
46374
46419
  } else if (value.item.type === "mcp_call") {
46375
46420
  ongoingToolCalls[value.output_index] = void 0;
46376
- const approvalRequestId = (_d = value.item.approval_request_id) != null ? _d : void 0;
46377
- const aliasedToolCallId = approvalRequestId != null ? (_f = (_e = approvalRequestIdToDummyToolCallIdFromStream.get(
46421
+ const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
46422
+ const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
46378
46423
  approvalRequestId
46379
- )) != null ? _e : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _f : value.item.id : value.item.id;
46424
+ )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
46380
46425
  const toolName = `mcp.${value.item.name}`;
46381
46426
  controller.enqueue({
46382
46427
  type: "tool-call",
@@ -46446,8 +46491,8 @@ var OpenAIResponsesLanguageModel = class {
46446
46491
  ongoingToolCalls[value.output_index] = void 0;
46447
46492
  } else if (value.item.type === "mcp_approval_request") {
46448
46493
  ongoingToolCalls[value.output_index] = void 0;
46449
- const dummyToolCallId = (_i = (_h = (_g = self2.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId$1();
46450
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : value.item.id;
46494
+ const dummyToolCallId = (_k = (_j = (_i = self2.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId$1();
46495
+ const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
46451
46496
  approvalRequestIdToDummyToolCallIdFromStream.set(
46452
46497
  approvalRequestId,
46453
46498
  dummyToolCallId
@@ -46536,7 +46581,7 @@ var OpenAIResponsesLanguageModel = class {
46536
46581
  providerMetadata: {
46537
46582
  [providerOptionsName]: {
46538
46583
  itemId: value.item.id,
46539
- reasoningEncryptedContent: (_k = value.item.encrypted_content) != null ? _k : null
46584
+ reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
46540
46585
  }
46541
46586
  }
46542
46587
  });
@@ -46640,7 +46685,7 @@ var OpenAIResponsesLanguageModel = class {
46640
46685
  id: value.item_id,
46641
46686
  delta: value.delta
46642
46687
  });
46643
- if (((_m = (_l = options.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.logprobs) && value.logprobs) {
46688
+ if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
46644
46689
  logprobs.push(value.logprobs);
46645
46690
  }
46646
46691
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -46669,7 +46714,7 @@ var OpenAIResponsesLanguageModel = class {
46669
46714
  providerMetadata: {
46670
46715
  [providerOptionsName]: {
46671
46716
  itemId: value.item_id,
46672
- reasoningEncryptedContent: (_o = (_n = activeReasoning[value.item_id]) == null ? void 0 : _n.encryptedContent) != null ? _o : null
46717
+ reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
46673
46718
  }
46674
46719
  }
46675
46720
  });
@@ -46703,10 +46748,10 @@ var OpenAIResponsesLanguageModel = class {
46703
46748
  } else if (isResponseFinishedChunk(value)) {
46704
46749
  finishReason = {
46705
46750
  unified: mapOpenAIResponseFinishReason({
46706
- finishReason: (_p = value.response.incomplete_details) == null ? void 0 : _p.reason,
46751
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
46707
46752
  hasFunctionCall
46708
46753
  }),
46709
- raw: (_r = (_q = value.response.incomplete_details) == null ? void 0 : _q.reason) != null ? _r : void 0
46754
+ raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
46710
46755
  };
46711
46756
  usage = value.response.usage;
46712
46757
  if (typeof value.response.service_tier === "string") {
@@ -46718,7 +46763,7 @@ var OpenAIResponsesLanguageModel = class {
46718
46763
  controller.enqueue({
46719
46764
  type: "source",
46720
46765
  sourceType: "url",
46721
- id: (_u = (_t = (_s = self2.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId$1(),
46766
+ id: (_w = (_v = (_u = self2.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId$1(),
46722
46767
  url: value.annotation.url,
46723
46768
  title: value.annotation.title
46724
46769
  });
@@ -46726,7 +46771,7 @@ var OpenAIResponsesLanguageModel = class {
46726
46771
  controller.enqueue({
46727
46772
  type: "source",
46728
46773
  sourceType: "document",
46729
- id: (_x = (_w = (_v = self2.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : generateId$1(),
46774
+ id: (_z = (_y = (_x = self2.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId$1(),
46730
46775
  mediaType: "text/plain",
46731
46776
  title: value.annotation.filename,
46732
46777
  filename: value.annotation.filename,
@@ -46742,7 +46787,7 @@ var OpenAIResponsesLanguageModel = class {
46742
46787
  controller.enqueue({
46743
46788
  type: "source",
46744
46789
  sourceType: "document",
46745
- id: (_A = (_z = (_y = self2.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId$1(),
46790
+ id: (_C = (_B = (_A = self2.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId$1(),
46746
46791
  mediaType: "text/plain",
46747
46792
  title: value.annotation.filename,
46748
46793
  filename: value.annotation.filename,
@@ -46758,7 +46803,7 @@ var OpenAIResponsesLanguageModel = class {
46758
46803
  controller.enqueue({
46759
46804
  type: "source",
46760
46805
  sourceType: "document",
46761
- id: (_D = (_C = (_B = self2.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId$1(),
46806
+ id: (_F = (_E = (_D = self2.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId$1(),
46762
46807
  mediaType: "application/octet-stream",
46763
46808
  title: value.annotation.file_id,
46764
46809
  filename: value.annotation.file_id,
@@ -47193,7 +47238,7 @@ var OpenAITranscriptionModel = class {
47193
47238
  };
47194
47239
  }
47195
47240
  };
47196
- var VERSION$2 = "3.0.33";
47241
+ var VERSION$2 = "3.0.36";
47197
47242
  function createOpenAI(options = {}) {
47198
47243
  var _a10, _b9;
47199
47244
  const baseURL = (_a10 = withoutTrailingSlash$1(
@@ -49702,10 +49747,10 @@ function getMainSkillPathByName(modules, name16) {
49702
49747
  }
49703
49748
  function createSkillTools(modules) {
49704
49749
  const getSkillContent = tool({
49705
- description: "根据技能名称或文档路径获取该技能的完整 Markdown 文档内容。传入 skillName(如 calculator)或 path(如 ./calculator/SKILL.md",
49750
+ description: "根据技能名称或文档路径获取该技能的完整文档内容。传入 skillName(如 calculator)或 path(如 ./calculator/SKILL.md)。支持 .md、.json、.xml 等各类文本格式文件。",
49706
49751
  inputSchema: objectType({
49707
49752
  skillName: stringType().optional().describe("技能名称,与目录名一致,如 calculator"),
49708
- path: stringType().optional().describe("文档相对路径,如 ./calculator/SKILL.md 或 ./product-guide/reference/xxx.md")
49753
+ path: stringType().optional().describe("文档相对路径,如 ./calculator/SKILL.md 或 ./product-guide/reference/xxx.json")
49709
49754
  }),
49710
49755
  execute: (args) => {
49711
49756
  const { skillName, path: pathArg } = args;