@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.
@@ -31552,7 +31552,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
31552
31552
  var _a92;
31553
31553
  return (_a92 = indexBrowserExports.getContext().headers) == null ? void 0 : _a92["x-vercel-id"];
31554
31554
  }
31555
- var VERSION$6 = "3.0.55";
31555
+ var VERSION$6 = "3.0.58";
31556
31556
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
31557
31557
  function createGatewayProvider(options = {}) {
31558
31558
  var _a92, _b9;
@@ -33074,6 +33074,17 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
33074
33074
  }
33075
33075
  };
33076
33076
  _a19 = symbol19;
33077
+ function asArray(value) {
33078
+ return value === void 0 ? [] : Array.isArray(value) ? value : [value];
33079
+ }
33080
+ async function notify(options) {
33081
+ for (const callback of asArray(options.callbacks)) {
33082
+ try {
33083
+ await callback(options.event);
33084
+ } catch (_ignored) {
33085
+ }
33086
+ }
33087
+ }
33077
33088
  function formatWarning({
33078
33089
  warning,
33079
33090
  provider,
@@ -33374,7 +33385,7 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
33374
33385
  }
33375
33386
  return void 0;
33376
33387
  }
33377
- var VERSION$4 = "6.0.99";
33388
+ var VERSION$4 = "6.0.104";
33378
33389
  var download = async ({
33379
33390
  url: url2,
33380
33391
  maxBytes,
@@ -33482,9 +33493,6 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
33482
33493
  }
33483
33494
  return convertUint8ArrayToBase64$1(content);
33484
33495
  }
33485
- function asArray(value) {
33486
- return value === void 0 ? [] : Array.isArray(value) ? value : [value];
33487
- }
33488
33496
  async function convertToLanguageModelPrompt({
33489
33497
  prompt,
33490
33498
  supportedUrls,
@@ -34851,10 +34859,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
34851
34859
  tracer,
34852
34860
  fn: async (span) => {
34853
34861
  let output;
34854
- try {
34855
- await (onToolCallStart == null ? void 0 : onToolCallStart(baseCallbackEvent));
34856
- } catch (_ignored) {
34857
- }
34862
+ await notify({ event: baseCallbackEvent, callbacks: onToolCallStart });
34858
34863
  const startTime = now();
34859
34864
  try {
34860
34865
  const stream = executeTool({
@@ -34881,15 +34886,15 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
34881
34886
  }
34882
34887
  } catch (error) {
34883
34888
  const durationMs2 = now() - startTime;
34884
- try {
34885
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
34889
+ await notify({
34890
+ event: {
34886
34891
  ...baseCallbackEvent,
34887
34892
  success: false,
34888
34893
  error,
34889
34894
  durationMs: durationMs2
34890
- }));
34891
- } catch (_ignored) {
34892
- }
34895
+ },
34896
+ callbacks: onToolCallFinish
34897
+ });
34893
34898
  recordErrorOnSpan(span, error);
34894
34899
  return {
34895
34900
  type: "tool-error",
@@ -34902,15 +34907,15 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
34902
34907
  };
34903
34908
  }
34904
34909
  const durationMs = now() - startTime;
34905
- try {
34906
- await (onToolCallFinish == null ? void 0 : onToolCallFinish({
34910
+ await notify({
34911
+ event: {
34907
34912
  ...baseCallbackEvent,
34908
34913
  success: true,
34909
34914
  output,
34910
34915
  durationMs
34911
- }));
34912
- } catch (_ignored) {
34913
- }
34916
+ },
34917
+ callbacks: onToolCallFinish
34918
+ });
34914
34919
  try {
34915
34920
  span.setAttributes(
34916
34921
  await selectTelemetryAttributes({
@@ -36073,8 +36078,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
36073
36078
  prompt,
36074
36079
  messages
36075
36080
  });
36076
- try {
36077
- await (onStart == null ? void 0 : onStart({
36081
+ await notify({
36082
+ event: {
36078
36083
  model: modelInfo,
36079
36084
  system,
36080
36085
  prompt,
@@ -36101,9 +36106,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
36101
36106
  functionId: telemetry == null ? void 0 : telemetry.functionId,
36102
36107
  metadata: telemetry == null ? void 0 : telemetry.metadata,
36103
36108
  experimental_context
36104
- }));
36105
- } catch (_ignored) {
36106
- }
36109
+ },
36110
+ callbacks: onStart
36111
+ });
36107
36112
  const tracer = getTracer(telemetry);
36108
36113
  try {
36109
36114
  return await recordSpan({
@@ -36253,8 +36258,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
36253
36258
  providerOptions,
36254
36259
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
36255
36260
  );
36256
- try {
36257
- await (onStepStart == null ? void 0 : onStepStart({
36261
+ await notify({
36262
+ event: {
36258
36263
  stepNumber: steps.length,
36259
36264
  model: stepModelInfo,
36260
36265
  system: stepSystem,
@@ -36273,9 +36278,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
36273
36278
  functionId: telemetry == null ? void 0 : telemetry.functionId,
36274
36279
  metadata: telemetry == null ? void 0 : telemetry.metadata,
36275
36280
  experimental_context
36276
- }));
36277
- } catch (_ignored) {
36278
- }
36281
+ },
36282
+ callbacks: onStepStart
36283
+ });
36279
36284
  currentModelResponse = await retry(
36280
36285
  () => {
36281
36286
  var _a22;
@@ -36520,7 +36525,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
36520
36525
  model: stepModelInfo.modelId
36521
36526
  });
36522
36527
  steps.push(currentStepResult);
36523
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
36528
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
36524
36529
  } finally {
36525
36530
  if (stepTimeoutId != null) {
36526
36531
  clearTimeout(stepTimeoutId);
@@ -36572,34 +36577,37 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
36572
36577
  cachedInputTokens: void 0
36573
36578
  }
36574
36579
  );
36575
- await (onFinish == null ? void 0 : onFinish({
36576
- stepNumber: lastStep.stepNumber,
36577
- model: lastStep.model,
36578
- functionId: lastStep.functionId,
36579
- metadata: lastStep.metadata,
36580
- experimental_context: lastStep.experimental_context,
36581
- finishReason: lastStep.finishReason,
36582
- rawFinishReason: lastStep.rawFinishReason,
36583
- usage: lastStep.usage,
36584
- content: lastStep.content,
36585
- text: lastStep.text,
36586
- reasoningText: lastStep.reasoningText,
36587
- reasoning: lastStep.reasoning,
36588
- files: lastStep.files,
36589
- sources: lastStep.sources,
36590
- toolCalls: lastStep.toolCalls,
36591
- staticToolCalls: lastStep.staticToolCalls,
36592
- dynamicToolCalls: lastStep.dynamicToolCalls,
36593
- toolResults: lastStep.toolResults,
36594
- staticToolResults: lastStep.staticToolResults,
36595
- dynamicToolResults: lastStep.dynamicToolResults,
36596
- request: lastStep.request,
36597
- response: lastStep.response,
36598
- warnings: lastStep.warnings,
36599
- providerMetadata: lastStep.providerMetadata,
36600
- steps,
36601
- totalUsage
36602
- }));
36580
+ await notify({
36581
+ event: {
36582
+ stepNumber: lastStep.stepNumber,
36583
+ model: lastStep.model,
36584
+ functionId: lastStep.functionId,
36585
+ metadata: lastStep.metadata,
36586
+ experimental_context: lastStep.experimental_context,
36587
+ finishReason: lastStep.finishReason,
36588
+ rawFinishReason: lastStep.rawFinishReason,
36589
+ usage: lastStep.usage,
36590
+ content: lastStep.content,
36591
+ text: lastStep.text,
36592
+ reasoningText: lastStep.reasoningText,
36593
+ reasoning: lastStep.reasoning,
36594
+ files: lastStep.files,
36595
+ sources: lastStep.sources,
36596
+ toolCalls: lastStep.toolCalls,
36597
+ staticToolCalls: lastStep.staticToolCalls,
36598
+ dynamicToolCalls: lastStep.dynamicToolCalls,
36599
+ toolResults: lastStep.toolResults,
36600
+ staticToolResults: lastStep.staticToolResults,
36601
+ dynamicToolResults: lastStep.dynamicToolResults,
36602
+ request: lastStep.request,
36603
+ response: lastStep.response,
36604
+ warnings: lastStep.warnings,
36605
+ providerMetadata: lastStep.providerMetadata,
36606
+ steps,
36607
+ totalUsage
36608
+ },
36609
+ callbacks: onFinish
36610
+ });
36603
36611
  let resolvedOutput;
36604
36612
  if (lastStep.finishReason === "stop") {
36605
36613
  const outputSpecification = output != null ? output : text();
@@ -37342,7 +37350,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
37342
37350
  break;
37343
37351
  }
37344
37352
  case "tool-input-error": {
37345
- if (chunk.dynamic) {
37353
+ const existingPart = state.message.parts.filter(isToolUIPart).find((p) => p.toolCallId === chunk.toolCallId);
37354
+ const isDynamic = existingPart != null ? existingPart.type === "dynamic-tool" : !!chunk.dynamic;
37355
+ if (isDynamic) {
37346
37356
  updateDynamicToolPart({
37347
37357
  toolCallId: chunk.toolCallId,
37348
37358
  toolName: chunk.toolName,
@@ -38407,7 +38417,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
38407
38417
  },
38408
38418
  providerMetadata: part.providerMetadata
38409
38419
  });
38410
- await (onStepFinish == null ? void 0 : onStepFinish(currentStepResult));
38420
+ await notify({ event: currentStepResult, callbacks: onStepFinish });
38411
38421
  logWarnings({
38412
38422
  warnings: recordedWarnings,
38413
38423
  provider: modelInfo.provider,
@@ -38442,34 +38452,37 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
38442
38452
  self2._totalUsage.resolve(totalUsage);
38443
38453
  self2._steps.resolve(recordedSteps);
38444
38454
  const finalStep = recordedSteps[recordedSteps.length - 1];
38445
- await (onFinish == null ? void 0 : onFinish({
38446
- stepNumber: finalStep.stepNumber,
38447
- model: finalStep.model,
38448
- functionId: finalStep.functionId,
38449
- metadata: finalStep.metadata,
38450
- experimental_context: finalStep.experimental_context,
38451
- finishReason: finalStep.finishReason,
38452
- rawFinishReason: finalStep.rawFinishReason,
38453
- totalUsage,
38454
- usage: finalStep.usage,
38455
- content: finalStep.content,
38456
- text: finalStep.text,
38457
- reasoningText: finalStep.reasoningText,
38458
- reasoning: finalStep.reasoning,
38459
- files: finalStep.files,
38460
- sources: finalStep.sources,
38461
- toolCalls: finalStep.toolCalls,
38462
- staticToolCalls: finalStep.staticToolCalls,
38463
- dynamicToolCalls: finalStep.dynamicToolCalls,
38464
- toolResults: finalStep.toolResults,
38465
- staticToolResults: finalStep.staticToolResults,
38466
- dynamicToolResults: finalStep.dynamicToolResults,
38467
- request: finalStep.request,
38468
- response: finalStep.response,
38469
- warnings: finalStep.warnings,
38470
- providerMetadata: finalStep.providerMetadata,
38471
- steps: recordedSteps
38472
- }));
38455
+ await notify({
38456
+ event: {
38457
+ stepNumber: finalStep.stepNumber,
38458
+ model: finalStep.model,
38459
+ functionId: finalStep.functionId,
38460
+ metadata: finalStep.metadata,
38461
+ experimental_context: finalStep.experimental_context,
38462
+ finishReason: finalStep.finishReason,
38463
+ rawFinishReason: finalStep.rawFinishReason,
38464
+ totalUsage,
38465
+ usage: finalStep.usage,
38466
+ content: finalStep.content,
38467
+ text: finalStep.text,
38468
+ reasoningText: finalStep.reasoningText,
38469
+ reasoning: finalStep.reasoning,
38470
+ files: finalStep.files,
38471
+ sources: finalStep.sources,
38472
+ toolCalls: finalStep.toolCalls,
38473
+ staticToolCalls: finalStep.staticToolCalls,
38474
+ dynamicToolCalls: finalStep.dynamicToolCalls,
38475
+ toolResults: finalStep.toolResults,
38476
+ staticToolResults: finalStep.staticToolResults,
38477
+ dynamicToolResults: finalStep.dynamicToolResults,
38478
+ request: finalStep.request,
38479
+ response: finalStep.response,
38480
+ warnings: finalStep.warnings,
38481
+ providerMetadata: finalStep.providerMetadata,
38482
+ steps: recordedSteps
38483
+ },
38484
+ callbacks: onFinish
38485
+ });
38473
38486
  rootSpan.setAttributes(
38474
38487
  await selectTelemetryAttributes({
38475
38488
  telemetry,
@@ -38597,8 +38610,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
38597
38610
  prompt,
38598
38611
  messages
38599
38612
  });
38600
- try {
38601
- await (onStart == null ? void 0 : onStart({
38613
+ await notify({
38614
+ event: {
38602
38615
  model: modelInfo,
38603
38616
  system,
38604
38617
  prompt,
@@ -38624,9 +38637,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
38624
38637
  include,
38625
38638
  ...callbackTelemetryProps,
38626
38639
  experimental_context
38627
- }));
38628
- } catch (_ignored) {
38629
- }
38640
+ },
38641
+ callbacks: onStart
38642
+ });
38630
38643
  const initialMessages = initialPrompt.messages;
38631
38644
  const initialResponseMessages = [];
38632
38645
  const { approvedToolApprovals, deniedToolApprovals } = collectToolApprovals({ messages: initialMessages });
@@ -38807,8 +38820,8 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
38807
38820
  providerOptions,
38808
38821
  prepareStepResult == null ? void 0 : prepareStepResult.providerOptions
38809
38822
  );
38810
- try {
38811
- await (onStepStart == null ? void 0 : onStepStart({
38823
+ await notify({
38824
+ event: {
38812
38825
  stepNumber: recordedSteps.length,
38813
38826
  model: stepModelInfo,
38814
38827
  system: stepSystem,
@@ -38826,9 +38839,9 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
38826
38839
  include,
38827
38840
  ...callbackTelemetryProps,
38828
38841
  experimental_context
38829
- }));
38830
- } catch (_ignored) {
38831
- }
38842
+ },
38843
+ callbacks: onStepStart
38844
+ });
38832
38845
  const {
38833
38846
  result: { stream: stream2, response, request },
38834
38847
  doStreamSpan,
@@ -42743,7 +42756,7 @@ Learn more: \x1B[34m${moreInfoURL}\x1B[0m
42743
42756
  for (const toolCallDelta of delta.tool_calls) {
42744
42757
  const index = toolCallDelta.index;
42745
42758
  if (toolCalls[index] == null) {
42746
- if (toolCallDelta.type !== "function") {
42759
+ if (toolCallDelta.type != null && toolCallDelta.type !== "function") {
42747
42760
  throw new InvalidResponseDataError$1({
42748
42761
  data: toolCallDelta,
42749
42762
  message: `Expected 'function' type.`
@@ -43437,6 +43450,7 @@ ${user}:`]
43437
43450
  "chatgpt-image-latest": 10
43438
43451
  };
43439
43452
  var defaultResponseFormatPrefixes = [
43453
+ "chatgpt-image-",
43440
43454
  "gpt-image-1-mini",
43441
43455
  "gpt-image-1.5",
43442
43456
  "gpt-image-1"
@@ -44206,7 +44220,7 @@ ${user}:`]
44206
44220
  hasShellTool = false,
44207
44221
  hasApplyPatchTool = false
44208
44222
  }) {
44209
- var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
44223
+ var _a10, _b9, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
44210
44224
  const input = [];
44211
44225
  const warnings = [];
44212
44226
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -44287,7 +44301,9 @@ ${user}:`]
44287
44301
  for (const part of content) {
44288
44302
  switch (part.type) {
44289
44303
  case "text": {
44290
- const id2 = (_b9 = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName]) == null ? void 0 : _b9.itemId;
44304
+ const providerOpts = (_a10 = part.providerOptions) == null ? void 0 : _a10[providerOptionsName];
44305
+ const id2 = providerOpts == null ? void 0 : providerOpts.itemId;
44306
+ const phase = providerOpts == null ? void 0 : providerOpts.phase;
44291
44307
  if (hasConversation && id2 != null) {
44292
44308
  break;
44293
44309
  }
@@ -44298,12 +44314,13 @@ ${user}:`]
44298
44314
  input.push({
44299
44315
  role: "assistant",
44300
44316
  content: [{ type: "output_text", text: part.text }],
44301
- id: id2
44317
+ id: id2,
44318
+ ...phase != null && { phase }
44302
44319
  });
44303
44320
  break;
44304
44321
  }
44305
44322
  case "tool-call": {
44306
- 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;
44323
+ 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;
44307
44324
  if (hasConversation && id2 != null) {
44308
44325
  break;
44309
44326
  }
@@ -44414,7 +44431,7 @@ ${user}:`]
44414
44431
  break;
44415
44432
  }
44416
44433
  if (store) {
44417
- const itemId = (_j = (_i = (_h = part.providerOptions) == null ? void 0 : _h[providerOptionsName]) == null ? void 0 : _i.itemId) != null ? _j : part.toolCallId;
44434
+ const itemId = (_i = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.itemId) != null ? _i : part.toolCallId;
44418
44435
  input.push({ type: "item_reference", id: itemId });
44419
44436
  } else {
44420
44437
  warnings.push({
@@ -44474,10 +44491,26 @@ ${user}:`]
44474
44491
  }
44475
44492
  }
44476
44493
  } else {
44477
- warnings.push({
44478
- type: "other",
44479
- message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
44480
- });
44494
+ const encryptedContent = providerOptions == null ? void 0 : providerOptions.reasoningEncryptedContent;
44495
+ if (encryptedContent != null) {
44496
+ const summaryParts = [];
44497
+ if (part.text.length > 0) {
44498
+ summaryParts.push({
44499
+ type: "summary_text",
44500
+ text: part.text
44501
+ });
44502
+ }
44503
+ input.push({
44504
+ type: "reasoning",
44505
+ encrypted_content: encryptedContent,
44506
+ summary: summaryParts
44507
+ });
44508
+ } else {
44509
+ warnings.push({
44510
+ type: "other",
44511
+ message: `Non-OpenAI reasoning parts are not supported. Skipping reasoning part: ${JSON.stringify(part)}.`
44512
+ });
44513
+ }
44481
44514
  }
44482
44515
  break;
44483
44516
  }
@@ -44508,7 +44541,7 @@ ${user}:`]
44508
44541
  }
44509
44542
  const output = part.output;
44510
44543
  if (output.type === "execution-denied") {
44511
- const approvalId = (_l = (_k = output.providerOptions) == null ? void 0 : _k.openai) == null ? void 0 : _l.approvalId;
44544
+ const approvalId = (_k = (_j = output.providerOptions) == null ? void 0 : _j.openai) == null ? void 0 : _k.approvalId;
44512
44545
  if (approvalId) {
44513
44546
  continue;
44514
44547
  }
@@ -44567,7 +44600,7 @@ ${user}:`]
44567
44600
  contentValue = output.value;
44568
44601
  break;
44569
44602
  case "execution-denied":
44570
- contentValue = (_m = output.reason) != null ? _m : "Tool execution denied.";
44603
+ contentValue = (_l = output.reason) != null ? _l : "Tool execution denied.";
44571
44604
  break;
44572
44605
  case "json":
44573
44606
  case "error-json":
@@ -44694,7 +44727,8 @@ ${user}:`]
44694
44727
  item: discriminatedUnion("type", [
44695
44728
  object$2({
44696
44729
  type: literal("message"),
44697
- id: string()
44730
+ id: string(),
44731
+ phase: _enum(["commentary", "final_answer"]).nullish()
44698
44732
  }),
44699
44733
  object$2({
44700
44734
  type: literal("reasoning"),
@@ -44811,7 +44845,8 @@ ${user}:`]
44811
44845
  item: discriminatedUnion("type", [
44812
44846
  object$2({
44813
44847
  type: literal("message"),
44814
- id: string()
44848
+ id: string(),
44849
+ phase: _enum(["commentary", "final_answer"]).nullish()
44815
44850
  }),
44816
44851
  object$2({
44817
44852
  type: literal("reasoning"),
@@ -45123,6 +45158,7 @@ ${user}:`]
45123
45158
  type: literal("message"),
45124
45159
  role: literal("assistant"),
45125
45160
  id: string(),
45161
+ phase: _enum(["commentary", "final_answer"]).nullish(),
45126
45162
  content: array$1(
45127
45163
  object$2({
45128
45164
  type: literal("output_text"),
@@ -46174,6 +46210,7 @@ ${user}:`]
46174
46210
  }
46175
46211
  const providerMetadata2 = {
46176
46212
  itemId: part.id,
46213
+ ...part.phase != null && { phase: part.phase },
46177
46214
  ...contentPart.annotations.length > 0 && {
46178
46215
  annotations: contentPart.annotations
46179
46216
  }
@@ -46488,6 +46525,7 @@ ${user}:`]
46488
46525
  let responseId = null;
46489
46526
  const ongoingToolCalls = {};
46490
46527
  const ongoingAnnotations = [];
46528
+ let activeMessagePhase;
46491
46529
  let hasFunctionCall = false;
46492
46530
  const activeReasoning = {};
46493
46531
  let serviceTier;
@@ -46498,7 +46536,7 @@ ${user}:`]
46498
46536
  controller.enqueue({ type: "stream-start", warnings });
46499
46537
  },
46500
46538
  transform(chunk, controller) {
46501
- 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;
46539
+ 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;
46502
46540
  if (options.includeRawChunks) {
46503
46541
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
46504
46542
  }
@@ -46639,12 +46677,16 @@ ${user}:`]
46639
46677
  } else if (value.item.type === "shell_call_output") ;
46640
46678
  else if (value.item.type === "message") {
46641
46679
  ongoingAnnotations.splice(0, ongoingAnnotations.length);
46680
+ activeMessagePhase = (_a10 = value.item.phase) != null ? _a10 : void 0;
46642
46681
  controller.enqueue({
46643
46682
  type: "text-start",
46644
46683
  id: value.item.id,
46645
46684
  providerMetadata: {
46646
46685
  [providerOptionsName]: {
46647
- itemId: value.item.id
46686
+ itemId: value.item.id,
46687
+ ...value.item.phase != null && {
46688
+ phase: value.item.phase
46689
+ }
46648
46690
  }
46649
46691
  }
46650
46692
  });
@@ -46659,19 +46701,22 @@ ${user}:`]
46659
46701
  providerMetadata: {
46660
46702
  [providerOptionsName]: {
46661
46703
  itemId: value.item.id,
46662
- reasoningEncryptedContent: (_a10 = value.item.encrypted_content) != null ? _a10 : null
46704
+ reasoningEncryptedContent: (_b9 = value.item.encrypted_content) != null ? _b9 : null
46663
46705
  }
46664
46706
  }
46665
46707
  });
46666
46708
  }
46667
46709
  } else if (isResponseOutputItemDoneChunk(value)) {
46668
46710
  if (value.item.type === "message") {
46711
+ const phase = (_c = value.item.phase) != null ? _c : activeMessagePhase;
46712
+ activeMessagePhase = void 0;
46669
46713
  controller.enqueue({
46670
46714
  type: "text-end",
46671
46715
  id: value.item.id,
46672
46716
  providerMetadata: {
46673
46717
  [providerOptionsName]: {
46674
46718
  itemId: value.item.id,
46719
+ ...phase != null && { phase },
46675
46720
  ...ongoingAnnotations.length > 0 && {
46676
46721
  annotations: ongoingAnnotations
46677
46722
  }
@@ -46736,13 +46781,13 @@ ${user}:`]
46736
46781
  toolName: toolNameMapping.toCustomToolName("file_search"),
46737
46782
  result: {
46738
46783
  queries: value.item.queries,
46739
- results: (_c = (_b9 = value.item.results) == null ? void 0 : _b9.map((result) => ({
46784
+ results: (_e = (_d = value.item.results) == null ? void 0 : _d.map((result) => ({
46740
46785
  attributes: result.attributes,
46741
46786
  fileId: result.file_id,
46742
46787
  filename: result.filename,
46743
46788
  score: result.score,
46744
46789
  text: result.text
46745
- }))) != null ? _c : null
46790
+ }))) != null ? _e : null
46746
46791
  }
46747
46792
  });
46748
46793
  } else if (value.item.type === "code_interpreter_call") {
@@ -46766,10 +46811,10 @@ ${user}:`]
46766
46811
  });
46767
46812
  } else if (value.item.type === "mcp_call") {
46768
46813
  ongoingToolCalls[value.output_index] = void 0;
46769
- const approvalRequestId = (_d = value.item.approval_request_id) != null ? _d : void 0;
46770
- const aliasedToolCallId = approvalRequestId != null ? (_f = (_e = approvalRequestIdToDummyToolCallIdFromStream.get(
46814
+ const approvalRequestId = (_f = value.item.approval_request_id) != null ? _f : void 0;
46815
+ const aliasedToolCallId = approvalRequestId != null ? (_h = (_g = approvalRequestIdToDummyToolCallIdFromStream.get(
46771
46816
  approvalRequestId
46772
- )) != null ? _e : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _f : value.item.id : value.item.id;
46817
+ )) != null ? _g : approvalRequestIdToDummyToolCallIdFromPrompt[approvalRequestId]) != null ? _h : value.item.id : value.item.id;
46773
46818
  const toolName = `mcp.${value.item.name}`;
46774
46819
  controller.enqueue({
46775
46820
  type: "tool-call",
@@ -46839,8 +46884,8 @@ ${user}:`]
46839
46884
  ongoingToolCalls[value.output_index] = void 0;
46840
46885
  } else if (value.item.type === "mcp_approval_request") {
46841
46886
  ongoingToolCalls[value.output_index] = void 0;
46842
- const dummyToolCallId = (_i = (_h = (_g = self2.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId$1();
46843
- const approvalRequestId = (_j = value.item.approval_request_id) != null ? _j : value.item.id;
46887
+ const dummyToolCallId = (_k = (_j = (_i = self2.config).generateId) == null ? void 0 : _j.call(_i)) != null ? _k : generateId$1();
46888
+ const approvalRequestId = (_l = value.item.approval_request_id) != null ? _l : value.item.id;
46844
46889
  approvalRequestIdToDummyToolCallIdFromStream.set(
46845
46890
  approvalRequestId,
46846
46891
  dummyToolCallId
@@ -46929,7 +46974,7 @@ ${user}:`]
46929
46974
  providerMetadata: {
46930
46975
  [providerOptionsName]: {
46931
46976
  itemId: value.item.id,
46932
- reasoningEncryptedContent: (_k = value.item.encrypted_content) != null ? _k : null
46977
+ reasoningEncryptedContent: (_m = value.item.encrypted_content) != null ? _m : null
46933
46978
  }
46934
46979
  }
46935
46980
  });
@@ -47033,7 +47078,7 @@ ${user}:`]
47033
47078
  id: value.item_id,
47034
47079
  delta: value.delta
47035
47080
  });
47036
- if (((_m = (_l = options.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.logprobs) && value.logprobs) {
47081
+ if (((_o = (_n = options.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.logprobs) && value.logprobs) {
47037
47082
  logprobs.push(value.logprobs);
47038
47083
  }
47039
47084
  } else if (value.type === "response.reasoning_summary_part.added") {
@@ -47062,7 +47107,7 @@ ${user}:`]
47062
47107
  providerMetadata: {
47063
47108
  [providerOptionsName]: {
47064
47109
  itemId: value.item_id,
47065
- reasoningEncryptedContent: (_o = (_n = activeReasoning[value.item_id]) == null ? void 0 : _n.encryptedContent) != null ? _o : null
47110
+ reasoningEncryptedContent: (_q = (_p = activeReasoning[value.item_id]) == null ? void 0 : _p.encryptedContent) != null ? _q : null
47066
47111
  }
47067
47112
  }
47068
47113
  });
@@ -47096,10 +47141,10 @@ ${user}:`]
47096
47141
  } else if (isResponseFinishedChunk(value)) {
47097
47142
  finishReason = {
47098
47143
  unified: mapOpenAIResponseFinishReason({
47099
- finishReason: (_p = value.response.incomplete_details) == null ? void 0 : _p.reason,
47144
+ finishReason: (_r = value.response.incomplete_details) == null ? void 0 : _r.reason,
47100
47145
  hasFunctionCall
47101
47146
  }),
47102
- raw: (_r = (_q = value.response.incomplete_details) == null ? void 0 : _q.reason) != null ? _r : void 0
47147
+ raw: (_t = (_s = value.response.incomplete_details) == null ? void 0 : _s.reason) != null ? _t : void 0
47103
47148
  };
47104
47149
  usage = value.response.usage;
47105
47150
  if (typeof value.response.service_tier === "string") {
@@ -47111,7 +47156,7 @@ ${user}:`]
47111
47156
  controller.enqueue({
47112
47157
  type: "source",
47113
47158
  sourceType: "url",
47114
- id: (_u = (_t = (_s = self2.config).generateId) == null ? void 0 : _t.call(_s)) != null ? _u : generateId$1(),
47159
+ id: (_w = (_v = (_u = self2.config).generateId) == null ? void 0 : _v.call(_u)) != null ? _w : generateId$1(),
47115
47160
  url: value.annotation.url,
47116
47161
  title: value.annotation.title
47117
47162
  });
@@ -47119,7 +47164,7 @@ ${user}:`]
47119
47164
  controller.enqueue({
47120
47165
  type: "source",
47121
47166
  sourceType: "document",
47122
- id: (_x = (_w = (_v = self2.config).generateId) == null ? void 0 : _w.call(_v)) != null ? _x : generateId$1(),
47167
+ id: (_z = (_y = (_x = self2.config).generateId) == null ? void 0 : _y.call(_x)) != null ? _z : generateId$1(),
47123
47168
  mediaType: "text/plain",
47124
47169
  title: value.annotation.filename,
47125
47170
  filename: value.annotation.filename,
@@ -47135,7 +47180,7 @@ ${user}:`]
47135
47180
  controller.enqueue({
47136
47181
  type: "source",
47137
47182
  sourceType: "document",
47138
- id: (_A = (_z = (_y = self2.config).generateId) == null ? void 0 : _z.call(_y)) != null ? _A : generateId$1(),
47183
+ id: (_C = (_B = (_A = self2.config).generateId) == null ? void 0 : _B.call(_A)) != null ? _C : generateId$1(),
47139
47184
  mediaType: "text/plain",
47140
47185
  title: value.annotation.filename,
47141
47186
  filename: value.annotation.filename,
@@ -47151,7 +47196,7 @@ ${user}:`]
47151
47196
  controller.enqueue({
47152
47197
  type: "source",
47153
47198
  sourceType: "document",
47154
- id: (_D = (_C = (_B = self2.config).generateId) == null ? void 0 : _C.call(_B)) != null ? _D : generateId$1(),
47199
+ id: (_F = (_E = (_D = self2.config).generateId) == null ? void 0 : _E.call(_D)) != null ? _F : generateId$1(),
47155
47200
  mediaType: "application/octet-stream",
47156
47201
  title: value.annotation.file_id,
47157
47202
  filename: value.annotation.file_id,
@@ -47586,7 +47631,7 @@ ${user}:`]
47586
47631
  };
47587
47632
  }
47588
47633
  };
47589
- var VERSION$2 = "3.0.33";
47634
+ var VERSION$2 = "3.0.36";
47590
47635
  function createOpenAI(options = {}) {
47591
47636
  var _a10, _b9;
47592
47637
  const baseURL = (_a10 = withoutTrailingSlash$1(
@@ -50095,10 +50140,10 @@ ${lines.join("\n")}
50095
50140
  }
50096
50141
  function createSkillTools(modules) {
50097
50142
  const getSkillContent = tool({
50098
- description: "根据技能名称或文档路径获取该技能的完整 Markdown 文档内容。传入 skillName(如 calculator)或 path(如 ./calculator/SKILL.md",
50143
+ description: "根据技能名称或文档路径获取该技能的完整文档内容。传入 skillName(如 calculator)或 path(如 ./calculator/SKILL.md)。支持 .md、.json、.xml 等各类文本格式文件。",
50099
50144
  inputSchema: objectType({
50100
50145
  skillName: stringType().optional().describe("技能名称,与目录名一致,如 calculator"),
50101
- path: stringType().optional().describe("文档相对路径,如 ./calculator/SKILL.md 或 ./product-guide/reference/xxx.md")
50146
+ path: stringType().optional().describe("文档相对路径,如 ./calculator/SKILL.md 或 ./product-guide/reference/xxx.json")
50102
50147
  }),
50103
50148
  execute: (args) => {
50104
50149
  const { skillName, path: pathArg } = args;