@xyd-js/ask-ai-widget 0.0.0-build-56377ca-20251013180714 → 0.0.0-build-1f6458c-20251015205119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -157564,8 +157564,8 @@ var je2 = "a16o3qrr";
157564
157564
  var Se2 = "a1ln4qwr";
157565
157565
  function Ce2(e488) {
157566
157566
  var t481, r325 = e488.properties;
157567
- return import_react5.default.createElement("ul", { className: me2 }, (t481 = Fe2(r325)) === null || t481 === undefined ? undefined : t481.map(function(e489, t482) {
157568
- var r326, a443 = e489.name, o237 = e489.type, i314 = Te2(e489), l52 = ((r326 = e489.ofProperty) === null || r326 === undefined ? undefined : r326.description) || e489.description || "", c105 = Ie2(e489.meta);
157567
+ return import_react5.default.createElement("ul", { className: me2 }, (t481 = Te2(r325)) === null || t481 === undefined ? undefined : t481.map(function(e489, t482) {
157568
+ var r326, a443 = e489.name, o237 = e489.type, i314 = Fe2(e489), l52 = ((r326 = e489.ofProperty) === null || r326 === undefined ? undefined : r326.description) || e489.description || "", c105 = Ie2(e489.meta);
157569
157569
  return import_react5.default.createElement("atlas-apiref-prop", { className: ve2, key: t482 }, a443 || o237 ? import_react5.default.createElement("dl", { className: fe2 }, import_react5.default.createElement(Oe2, { property: e489, meta: e489.meta || [] }), import_react5.default.createElement(_e2, { property: e489 }), import_react5.default.createElement(Re2, { metas: e489.meta || [] })) : null, l52 || c105 ? import_react5.default.createElement("atlas-apiref-propdescription", { className: pe2 }, import_react5.default.createElement(import_react5.default.Fragment, null, import_react5.default.createElement("div", null, l52), import_react5.default.createElement("div", null, Ie2(e489.meta)))) : null, (i314 == null ? undefined : i314.length) > 0 ? import_react5.default.createElement(Ae2, { parent: e489, properties: i314 }) : null);
157570
157570
  }));
157571
157571
  }
@@ -157625,7 +157625,7 @@ function Re2(e488) {
157625
157625
  }));
157626
157626
  }
157627
157627
  function Ae2(e488) {
157628
- var r325, a443 = e488.parent, o237 = e488.properties, i314 = import_react5.useState(false), l52 = g3(i314, 2), c105 = l52[0], u28 = l52[1], s187 = Fe2(o237 || []), d29 = Le2(a443), m82 = function() {
157628
+ var r325, a443 = e488.parent, o237 = e488.properties, i314 = import_react5.useState(false), l52 = g3(i314, 2), c105 = l52[0], u28 = l52[1], s187 = Te2(o237 || []), d29 = Le2(a443), m82 = function() {
157629
157629
  var e489;
157630
157630
  return ((a443 == null ? undefined : a443.type) !== DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY || ((e489 = a443 == null ? undefined : a443.ofProperty) === null || e489 === undefined ? undefined : e489.type) !== DEFINED_DEFINITION_PROPERTY_TYPE.ENUM) && (a443 == null ? undefined : a443.type) !== DEFINED_DEFINITION_PROPERTY_TYPE.ENUM && s187.every(function(e490) {
157631
157631
  var n470, t481;
@@ -157640,7 +157640,7 @@ function Ae2(e488) {
157640
157640
  return import_react5.default.createElement(import_react5.default.Fragment, null, (s187 == null ? undefined : s187.length) ? import_react5.default.createElement(Be2, { choiceType: d29, isArgument: v4, onClick: function() {
157641
157641
  return u28(!c105);
157642
157642
  }, isExpanded: c105 }) : null, import_react5.default.createElement("div", { className: "".concat(Ee2, " ").concat(c105 && be2) }, import_react5.default.createElement("div", { className: ke2 }, import_react5.default.createElement("ul", { role: "list", className: xe2 }, s187 == null ? undefined : s187.map(function(e489, t481) {
157643
- var r326, a444 = e489.name, o238 = e489.type, i315 = Te2(e489), l53 = ((r326 = e489.ofProperty) === null || r326 === undefined ? undefined : r326.description) || e489.description || "", c106 = Ie2(e489.meta);
157643
+ var r326, a444 = e489.name, o238 = e489.type, i315 = Fe2(e489), l53 = ((r326 = e489.ofProperty) === null || r326 === undefined ? undefined : r326.description) || e489.description || "", c106 = Ie2(e489.meta);
157644
157644
  return import_react5.default.createElement("atlas-apiref-prop", { className: we2, key: t481 }, a444 || o238 ? import_react5.default.createElement("dl", { className: fe2 }, import_react5.default.createElement(Oe2, { property: e489, meta: e489.meta || [], parentChoiceType: d29 || !!v4 }), import_react5.default.createElement(_e2, { property: e489 }), import_react5.default.createElement(Re2, { metas: e489.meta || [] })) : null, l53 || c106 ? import_react5.default.createElement("atlas-apiref-propdescription", { className: pe2 }, import_react5.default.createElement(import_react5.default.Fragment, null, import_react5.default.createElement("div", null, l53), import_react5.default.createElement("div", null, Ie2(e489.meta)))) : null, (i315 == null ? undefined : i315.length) ? import_react5.default.createElement(Ae2, { parent: e489, properties: i315 }) : null);
157645
157645
  })))));
157646
157646
  }
@@ -157652,11 +157652,11 @@ function Le2(e488) {
157652
157652
  var n470;
157653
157653
  return e488.type === DEFINED_DEFINITION_PROPERTY_TYPE.ARRAY && ((n470 = e488.ofProperty) === null || n470 === undefined ? undefined : n470.type) === DEFINED_DEFINITION_PROPERTY_TYPE.ENUM || (e488.ofProperty ? Le2(e488.ofProperty) : [DEFINED_DEFINITION_PROPERTY_TYPE.UNION, DEFINED_DEFINITION_PROPERTY_TYPE.XOR, DEFINED_DEFINITION_PROPERTY_TYPE.ENUM].includes(e488.type));
157654
157654
  }
157655
- function Te2(e488) {
157655
+ function Fe2(e488) {
157656
157656
  var n470;
157657
- return ((n470 = e488.properties) === null || n470 === undefined ? undefined : n470.length) ? e488.properties : e488.ofProperty ? Te2(e488.ofProperty) : [];
157657
+ return ((n470 = e488.properties) === null || n470 === undefined ? undefined : n470.length) ? e488.properties : e488.ofProperty ? Fe2(e488.ofProperty) : [];
157658
157658
  }
157659
- function Fe2(e488) {
157659
+ function Te2(e488) {
157660
157660
  return e488.filter(function(e489) {
157661
157661
  var n470;
157662
157662
  return !((n470 = e489 == null ? undefined : e489.meta) === null || n470 === undefined ? undefined : n470.some(function(e490) {
@@ -158239,10 +158239,10 @@ function Bn(e488) {
158239
158239
  function Ln(e488) {
158240
158240
  var { linesOrGroups: n470, handlers: t481, inlineAnnotations: r325, annotationStack: a443 } = e488, o237 = a443 === undefined ? [] : a443;
158241
158241
  return n470.map(function(e489) {
158242
- return Bn(e489) ? un.jsx(Fn, { group: e489, handlers: t481, inlineAnnotations: r325, annotationStack: o237 }, e489.range[0]) : un.jsx(Tn, { line: e489, handlers: t481, inlineAnnotations: r325, annotationStack: o237 }, e489.lineNumber);
158242
+ return Bn(e489) ? un.jsx(Tn, { group: e489, handlers: t481, inlineAnnotations: r325, annotationStack: o237 }, e489.range[0]) : un.jsx(Fn, { line: e489, handlers: t481, inlineAnnotations: r325, annotationStack: o237 }, e489.lineNumber);
158243
158243
  });
158244
158244
  }
158245
- function Tn(e488) {
158245
+ function Fn(e488) {
158246
158246
  var { line: n470, handlers: t481, inlineAnnotations: r325, annotationStack: a443 } = e488, o237 = a443 === undefined ? [] : a443, i314 = n470.lineNumber, l52 = n470.totalLines, c105 = n470.indentation, u28 = r325.filter(function(e489) {
158247
158247
  return e489.lineNumber === i314;
158248
158248
  }), s187 = function(e489, n471) {
@@ -158264,7 +158264,7 @@ function Tn(e488) {
158264
158264
  }(t481, o237), m82 = On({ content: s187, handlers: t481, annotationStack: o237 }), v4 = { lineNumber: i314, indentation: c105, totalLines: l52, _stack: d29 };
158265
158265
  return un.jsx(xn, { merge: v4, children: m82 }, i314);
158266
158266
  }
158267
- function Fn(e488) {
158267
+ function Tn(e488) {
158268
158268
  var n470, t481 = e488.group, r325 = e488.handlers, a443 = e488.inlineAnnotations, o237 = e488.annotationStack, i314 = t481.annotation, l52 = t481.lines, c105 = i314.name, u28 = (n470 = r325.find(function(e489) {
158269
158269
  return e489.name === c105;
158270
158270
  })) === null || n470 === undefined ? undefined : n470.Block, s187 = Ln({ linesOrGroups: l52, handlers: r325, inlineAnnotations: a443, annotationStack: [].concat(j2(o237), [i314]) });
@@ -181406,6 +181406,7 @@ function oasToSnippet(oas, operation, values2, auth, lang, opts = {}) {
181406
181406
  };
181407
181407
  }
181408
181408
  }
181409
+ var SKIP_SYMBOL = Symbol("skip");
181409
181410
  function pad(number2) {
181410
181411
  if (number2 < 10) {
181411
181412
  return "0" + number2;
@@ -181531,7 +181532,10 @@ function allOfSample(into, children, options, spec, context) {
181531
181532
  let res = traverse(into, options, spec);
181532
181533
  const subSamples = [];
181533
181534
  for (let subSchema of children) {
181534
- const { type: type2, readOnly, writeOnly, value } = traverse({ type: res.type, ...subSchema }, options, spec, context);
181535
+ const { type: type2, readOnly, writeOnly, value } = traverse({ type: res.type, ...subSchema }, options, spec, {
181536
+ ...context,
181537
+ isAllOfChild: true
181538
+ });
181535
181539
  if (res.type && type2 && type2 !== res.type) {
181536
181540
  console.warn("allOf: schemas with different types can't be merged");
181537
181541
  res.type = type2;
@@ -181544,6 +181548,11 @@ function allOfSample(into, children, options, spec, context) {
181544
181548
  }
181545
181549
  if (res.type === "object") {
181546
181550
  res.value = mergeDeep(res.value || {}, ...subSamples.filter((sample) => typeof sample === "object"));
181551
+ for (const key in res.value) {
181552
+ if (res.value[key] === SKIP_SYMBOL) {
181553
+ delete res.value[key];
181554
+ }
181555
+ }
181547
181556
  return res;
181548
181557
  } else {
181549
181558
  if (res.type === "array") {
@@ -181995,9 +182004,15 @@ function sampleObject(schema2, options = {}, spec, context) {
181995
182004
  }
181996
182005
  const sample = traverse(schema2.properties[propertyName], options, spec, { propertyName, depth: depth + 1 });
181997
182006
  if (options.skipReadOnly && sample.readOnly) {
182007
+ if (context?.isAllOfChild) {
182008
+ res[propertyName] = SKIP_SYMBOL;
182009
+ }
181998
182010
  return;
181999
182011
  }
182000
182012
  if (options.skipWriteOnly && sample.writeOnly) {
182013
+ if (context?.isAllOfChild) {
182014
+ res[propertyName] = SKIP_SYMBOL;
182015
+ }
182001
182016
  return;
182002
182017
  }
182003
182018
  if (options?.format === "xml") {
@@ -182073,6 +182088,7 @@ function regexSample$1(pattern) {
182073
182088
  pattern = pattern.toString();
182074
182089
  pattern = pattern.match(/\/(.+?)\//)?.[1] ?? "";
182075
182090
  }
182091
+ pattern = pattern.replace(/^(\^)?(.*?)(\$)?$/, "$2");
182076
182092
  let min;
182077
182093
  let max;
182078
182094
  let repetitions;
@@ -210672,7 +210688,7 @@ async function* executeTool({
210672
210688
  }
210673
210689
  }
210674
210690
 
210675
- // ../../node_modules/.pnpm/@ai-sdk+gateway@1.0.39_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
210691
+ // ../../node_modules/.pnpm/@ai-sdk+gateway@1.0.40_zod@3.25.76/node_modules/@ai-sdk/gateway/dist/index.mjs
210676
210692
  var import_oidc = __toESM(require_dist2(), 1);
210677
210693
  var import_oidc2 = __toESM(require_dist2(), 1);
210678
210694
  var marker15 = "vercel.ai.gateway.error";
@@ -211238,7 +211254,7 @@ async function getVercelRequestId() {
211238
211254
  var _a82;
211239
211255
  return (_a82 = import_oidc.getContext().headers) == null ? undefined : _a82["x-vercel-id"];
211240
211256
  }
211241
- var VERSION2 = "1.0.39";
211257
+ var VERSION2 = "1.0.40";
211242
211258
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
211243
211259
  function createGatewayProvider(options = {}) {
211244
211260
  var _a82, _b8;
@@ -211368,7 +211384,7 @@ async function getGatewayAuthToken(options) {
211368
211384
  }
211369
211385
  }
211370
211386
 
211371
- // ../../node_modules/.pnpm/ai@5.0.68_zod@3.25.76/node_modules/ai/dist/index.mjs
211387
+ // ../../node_modules/.pnpm/ai@5.0.72_zod@3.25.76/node_modules/ai/dist/index.mjs
211372
211388
  var import_api2 = __toESM(require_src6(), 1);
211373
211389
  var import_api3 = __toESM(require_src6(), 1);
211374
211390
  var __defProp3 = Object.defineProperty;
@@ -211794,7 +211810,7 @@ function detectMediaType({
211794
211810
  }
211795
211811
  return;
211796
211812
  }
211797
- var VERSION3 = "5.0.68";
211813
+ var VERSION3 = "5.0.72";
211798
211814
  var download = async ({ url: url2 }) => {
211799
211815
  var _a172;
211800
211816
  const urlText = url2.toString();
@@ -213036,7 +213052,12 @@ function writeToServerResponse({
213036
213052
  const { done, value } = await reader.read();
213037
213053
  if (done)
213038
213054
  break;
213039
- response.write(value);
213055
+ const canContinue = response.write(value);
213056
+ if (!canContinue) {
213057
+ await new Promise((resolve2) => {
213058
+ response.once("drain", resolve2);
213059
+ });
213060
+ }
213040
213061
  }
213041
213062
  } catch (error40) {
213042
213063
  throw error40;
@@ -216953,8 +216974,8 @@ async function pkceChallenge(length) {
216953
216974
  };
216954
216975
  }
216955
216976
 
216956
- // ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.27_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
216957
- var VERSION4 = "2.0.27";
216977
+ // ../../node_modules/.pnpm/@ai-sdk+anthropic@2.0.30_zod@3.25.76/node_modules/@ai-sdk/anthropic/dist/index.mjs
216978
+ var VERSION4 = "2.0.30";
216958
216979
  var anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external3.object({
216959
216980
  type: exports_external3.literal("error"),
216960
216981
  error: exports_external3.object({
@@ -217078,6 +217099,56 @@ var anthropicMessagesResponseSchema = lazySchema(() => zodSchema(exports_externa
217078
217099
  error_code: exports_external3.string()
217079
217100
  })
217080
217101
  ])
217102
+ }),
217103
+ exports_external3.object({
217104
+ type: exports_external3.literal("bash_code_execution_tool_result"),
217105
+ tool_use_id: exports_external3.string(),
217106
+ content: exports_external3.discriminatedUnion("type", [
217107
+ exports_external3.object({
217108
+ type: exports_external3.literal("bash_code_execution_result"),
217109
+ content: exports_external3.array(exports_external3.object({
217110
+ type: exports_external3.literal("bash_code_execution_output"),
217111
+ file_id: exports_external3.string()
217112
+ })),
217113
+ stdout: exports_external3.string(),
217114
+ stderr: exports_external3.string(),
217115
+ return_code: exports_external3.number()
217116
+ }),
217117
+ exports_external3.object({
217118
+ type: exports_external3.literal("bash_code_execution_tool_result_error"),
217119
+ error_code: exports_external3.string()
217120
+ })
217121
+ ])
217122
+ }),
217123
+ exports_external3.object({
217124
+ type: exports_external3.literal("text_editor_code_execution_tool_result"),
217125
+ tool_use_id: exports_external3.string(),
217126
+ content: exports_external3.discriminatedUnion("type", [
217127
+ exports_external3.object({
217128
+ type: exports_external3.literal("text_editor_code_execution_tool_result_error"),
217129
+ error_code: exports_external3.string()
217130
+ }),
217131
+ exports_external3.object({
217132
+ type: exports_external3.literal("text_editor_code_execution_view_result"),
217133
+ content: exports_external3.string(),
217134
+ file_type: exports_external3.string(),
217135
+ num_lines: exports_external3.number().nullable(),
217136
+ start_line: exports_external3.number().nullable(),
217137
+ total_lines: exports_external3.number().nullable()
217138
+ }),
217139
+ exports_external3.object({
217140
+ type: exports_external3.literal("text_editor_code_execution_create_result"),
217141
+ is_file_update: exports_external3.boolean()
217142
+ }),
217143
+ exports_external3.object({
217144
+ type: exports_external3.literal("text_editor_code_execution_str_replace_result"),
217145
+ lines: exports_external3.array(exports_external3.string()).nullable(),
217146
+ new_lines: exports_external3.number().nullable(),
217147
+ new_start: exports_external3.number().nullable(),
217148
+ old_lines: exports_external3.number().nullable(),
217149
+ old_start: exports_external3.number().nullable()
217150
+ })
217151
+ ])
217081
217152
  })
217082
217153
  ])),
217083
217154
  stop_reason: exports_external3.string().nullish(),
@@ -217186,6 +217257,56 @@ var anthropicMessagesChunkSchema = lazySchema(() => zodSchema(exports_external3.
217186
217257
  error_code: exports_external3.string()
217187
217258
  })
217188
217259
  ])
217260
+ }),
217261
+ exports_external3.object({
217262
+ type: exports_external3.literal("bash_code_execution_tool_result"),
217263
+ tool_use_id: exports_external3.string(),
217264
+ content: exports_external3.discriminatedUnion("type", [
217265
+ exports_external3.object({
217266
+ type: exports_external3.literal("bash_code_execution_result"),
217267
+ content: exports_external3.array(exports_external3.object({
217268
+ type: exports_external3.literal("bash_code_execution_output"),
217269
+ file_id: exports_external3.string()
217270
+ })),
217271
+ stdout: exports_external3.string(),
217272
+ stderr: exports_external3.string(),
217273
+ return_code: exports_external3.number()
217274
+ }),
217275
+ exports_external3.object({
217276
+ type: exports_external3.literal("bash_code_execution_tool_result_error"),
217277
+ error_code: exports_external3.string()
217278
+ })
217279
+ ])
217280
+ }),
217281
+ exports_external3.object({
217282
+ type: exports_external3.literal("text_editor_code_execution_tool_result"),
217283
+ tool_use_id: exports_external3.string(),
217284
+ content: exports_external3.discriminatedUnion("type", [
217285
+ exports_external3.object({
217286
+ type: exports_external3.literal("text_editor_code_execution_tool_result_error"),
217287
+ error_code: exports_external3.string()
217288
+ }),
217289
+ exports_external3.object({
217290
+ type: exports_external3.literal("text_editor_code_execution_view_result"),
217291
+ content: exports_external3.string(),
217292
+ file_type: exports_external3.string(),
217293
+ num_lines: exports_external3.number().nullable(),
217294
+ start_line: exports_external3.number().nullable(),
217295
+ total_lines: exports_external3.number().nullable()
217296
+ }),
217297
+ exports_external3.object({
217298
+ type: exports_external3.literal("text_editor_code_execution_create_result"),
217299
+ is_file_update: exports_external3.boolean()
217300
+ }),
217301
+ exports_external3.object({
217302
+ type: exports_external3.literal("text_editor_code_execution_str_replace_result"),
217303
+ lines: exports_external3.array(exports_external3.string()).nullable(),
217304
+ new_lines: exports_external3.number().nullable(),
217305
+ new_start: exports_external3.number().nullable(),
217306
+ old_lines: exports_external3.number().nullable(),
217307
+ old_start: exports_external3.number().nullable()
217308
+ })
217309
+ ])
217189
217310
  })
217190
217311
  ])
217191
217312
  }),
@@ -217423,6 +217544,14 @@ async function prepareTools({
217423
217544
  });
217424
217545
  break;
217425
217546
  }
217547
+ case "anthropic.code_execution_20250825": {
217548
+ betas.add("code-execution-2025-08-25");
217549
+ anthropicTools2.push({
217550
+ type: "code_execution_20250825",
217551
+ name: "code_execution"
217552
+ });
217553
+ break;
217554
+ }
217426
217555
  case "anthropic.computer_20250124": {
217427
217556
  betas.add("computer-use-2025-01-24");
217428
217557
  anthropicTools2.push({
@@ -217497,6 +217626,14 @@ async function prepareTools({
217497
217626
  });
217498
217627
  break;
217499
217628
  }
217629
+ case "anthropic.memory_20250818": {
217630
+ betas.add("context-management-2025-06-27");
217631
+ anthropicTools2.push({
217632
+ name: "memory",
217633
+ type: "memory_20250818"
217634
+ });
217635
+ break;
217636
+ }
217500
217637
  case "anthropic.web_fetch_20250910": {
217501
217638
  betas.add("web-fetch-2025-09-10");
217502
217639
  const args = await validateTypes({
@@ -217611,6 +217748,81 @@ var factory4 = createProviderDefinedToolFactoryWithOutputSchema({
217611
217748
  var codeExecution_20250522 = (args = {}) => {
217612
217749
  return factory4(args);
217613
217750
  };
217751
+ var codeExecution_20250825OutputSchema = lazySchema(() => zodSchema(exports_external3.discriminatedUnion("type", [
217752
+ exports_external3.object({
217753
+ type: exports_external3.literal("bash_code_execution_result"),
217754
+ content: exports_external3.array(exports_external3.object({
217755
+ type: exports_external3.literal("bash_code_execution_output"),
217756
+ file_id: exports_external3.string()
217757
+ })),
217758
+ stdout: exports_external3.string(),
217759
+ stderr: exports_external3.string(),
217760
+ return_code: exports_external3.number()
217761
+ }),
217762
+ exports_external3.object({
217763
+ type: exports_external3.literal("bash_code_execution_tool_result_error"),
217764
+ error_code: exports_external3.string()
217765
+ }),
217766
+ exports_external3.object({
217767
+ type: exports_external3.literal("text_editor_code_execution_tool_result_error"),
217768
+ error_code: exports_external3.string()
217769
+ }),
217770
+ exports_external3.object({
217771
+ type: exports_external3.literal("text_editor_code_execution_view_result"),
217772
+ content: exports_external3.string(),
217773
+ file_type: exports_external3.string(),
217774
+ num_lines: exports_external3.number().nullable(),
217775
+ start_line: exports_external3.number().nullable(),
217776
+ total_lines: exports_external3.number().nullable()
217777
+ }),
217778
+ exports_external3.object({
217779
+ type: exports_external3.literal("text_editor_code_execution_create_result"),
217780
+ is_file_update: exports_external3.boolean()
217781
+ }),
217782
+ exports_external3.object({
217783
+ type: exports_external3.literal("text_editor_code_execution_str_replace_result"),
217784
+ lines: exports_external3.array(exports_external3.string()).nullable(),
217785
+ new_lines: exports_external3.number().nullable(),
217786
+ new_start: exports_external3.number().nullable(),
217787
+ old_lines: exports_external3.number().nullable(),
217788
+ old_start: exports_external3.number().nullable()
217789
+ })
217790
+ ])));
217791
+ var codeExecution_20250825InputSchema = lazySchema(() => zodSchema(exports_external3.discriminatedUnion("type", [
217792
+ exports_external3.object({
217793
+ type: exports_external3.literal("bash_code_execution"),
217794
+ command: exports_external3.string()
217795
+ }),
217796
+ exports_external3.discriminatedUnion("command", [
217797
+ exports_external3.object({
217798
+ type: exports_external3.literal("text_editor_code_execution"),
217799
+ command: exports_external3.literal("view"),
217800
+ path: exports_external3.string()
217801
+ }),
217802
+ exports_external3.object({
217803
+ type: exports_external3.literal("text_editor_code_execution"),
217804
+ command: exports_external3.literal("create"),
217805
+ path: exports_external3.string(),
217806
+ file_text: exports_external3.string().nullish()
217807
+ }),
217808
+ exports_external3.object({
217809
+ type: exports_external3.literal("text_editor_code_execution"),
217810
+ command: exports_external3.literal("str_replace"),
217811
+ path: exports_external3.string(),
217812
+ old_str: exports_external3.string(),
217813
+ new_str: exports_external3.string()
217814
+ })
217815
+ ])
217816
+ ])));
217817
+ var factory5 = createProviderDefinedToolFactoryWithOutputSchema({
217818
+ id: "anthropic.code_execution_20250825",
217819
+ name: "code_execution",
217820
+ inputSchema: codeExecution_20250825InputSchema,
217821
+ outputSchema: codeExecution_20250825OutputSchema
217822
+ });
217823
+ var codeExecution_20250825 = (args = {}) => {
217824
+ return factory5(args);
217825
+ };
217614
217826
  function convertToString(data) {
217615
217827
  if (typeof data === "string") {
217616
217828
  return Buffer.from(data, "base64").toString("utf-8");
@@ -217899,7 +218111,15 @@ async function convertToAnthropicMessagesPrompt({
217899
218111
  }
217900
218112
  case "tool-call": {
217901
218113
  if (part.providerExecuted) {
217902
- if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
218114
+ if (part.toolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")) {
218115
+ anthropicContent.push({
218116
+ type: "server_tool_use",
218117
+ id: part.toolCallId,
218118
+ name: part.input.type,
218119
+ input: part.input,
218120
+ cache_control: cacheControl
218121
+ });
218122
+ } else if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
217903
218123
  anthropicContent.push({
217904
218124
  type: "server_tool_use",
217905
218125
  id: part.toolCallId,
@@ -217934,21 +218154,46 @@ async function convertToAnthropicMessagesPrompt({
217934
218154
  });
217935
218155
  break;
217936
218156
  }
217937
- const codeExecutionOutput = await validateTypes({
217938
- value: output.value,
217939
- schema: codeExecution_20250522OutputSchema
217940
- });
217941
- anthropicContent.push({
217942
- type: "code_execution_tool_result",
217943
- tool_use_id: part.toolCallId,
217944
- content: {
217945
- type: codeExecutionOutput.type,
217946
- stdout: codeExecutionOutput.stdout,
217947
- stderr: codeExecutionOutput.stderr,
217948
- return_code: codeExecutionOutput.return_code
217949
- },
217950
- cache_control: cacheControl
217951
- });
218157
+ if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
218158
+ warnings.push({
218159
+ type: "other",
218160
+ message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
218161
+ });
218162
+ break;
218163
+ }
218164
+ if (output.value.type === "code_execution_result") {
218165
+ const codeExecutionOutput = await validateTypes({
218166
+ value: output.value,
218167
+ schema: codeExecution_20250522OutputSchema
218168
+ });
218169
+ anthropicContent.push({
218170
+ type: "code_execution_tool_result",
218171
+ tool_use_id: part.toolCallId,
218172
+ content: {
218173
+ type: codeExecutionOutput.type,
218174
+ stdout: codeExecutionOutput.stdout,
218175
+ stderr: codeExecutionOutput.stderr,
218176
+ return_code: codeExecutionOutput.return_code
218177
+ },
218178
+ cache_control: cacheControl
218179
+ });
218180
+ } else {
218181
+ const codeExecutionOutput = await validateTypes({
218182
+ value: output.value,
218183
+ schema: codeExecution_20250825OutputSchema
218184
+ });
218185
+ anthropicContent.push(codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
218186
+ type: "bash_code_execution_tool_result",
218187
+ tool_use_id: part.toolCallId,
218188
+ cache_control: cacheControl,
218189
+ content: codeExecutionOutput
218190
+ } : {
218191
+ type: "text_editor_code_execution_tool_result",
218192
+ tool_use_id: part.toolCallId,
218193
+ cache_control: cacheControl,
218194
+ content: codeExecutionOutput
218195
+ });
218196
+ }
217952
218197
  break;
217953
218198
  }
217954
218199
  if (part.toolName === "web_fetch") {
@@ -218394,7 +218639,15 @@ var AnthropicMessagesLanguageModel = class {
218394
218639
  break;
218395
218640
  }
218396
218641
  case "server_tool_use": {
218397
- if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
218642
+ if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
218643
+ content3.push({
218644
+ type: "tool-call",
218645
+ toolCallId: part.id,
218646
+ toolName: "code_execution",
218647
+ input: JSON.stringify({ type: part.name, ...part.input }),
218648
+ providerExecuted: true
218649
+ });
218650
+ } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
218398
218651
  content3.push({
218399
218652
  type: "tool-call",
218400
218653
  toolCallId: part.id,
@@ -218519,6 +218772,17 @@ var AnthropicMessagesLanguageModel = class {
218519
218772
  }
218520
218773
  break;
218521
218774
  }
218775
+ case "bash_code_execution_tool_result":
218776
+ case "text_editor_code_execution_tool_result": {
218777
+ content3.push({
218778
+ type: "tool-result",
218779
+ toolCallId: part.tool_use_id,
218780
+ toolName: "code_execution",
218781
+ result: part.content,
218782
+ providerExecuted: true
218783
+ });
218784
+ break;
218785
+ }
218522
218786
  }
218523
218787
  }
218524
218788
  return {
@@ -218632,7 +218896,8 @@ var AnthropicMessagesLanguageModel = class {
218632
218896
  type: "tool-call",
218633
218897
  toolCallId: value.content_block.id,
218634
218898
  toolName: value.content_block.name,
218635
- input: ""
218899
+ input: "",
218900
+ firstDelta: true
218636
218901
  };
218637
218902
  controller.enqueue(usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
218638
218903
  type: "tool-input-start",
@@ -218642,18 +218907,26 @@ var AnthropicMessagesLanguageModel = class {
218642
218907
  return;
218643
218908
  }
218644
218909
  case "server_tool_use": {
218645
- if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
218910
+ if ([
218911
+ "web_fetch",
218912
+ "web_search",
218913
+ "code_execution",
218914
+ "text_editor_code_execution",
218915
+ "bash_code_execution"
218916
+ ].includes(value.content_block.name)) {
218646
218917
  contentBlocks[value.index] = {
218647
218918
  type: "tool-call",
218648
218919
  toolCallId: value.content_block.id,
218649
218920
  toolName: value.content_block.name,
218650
218921
  input: "",
218651
- providerExecuted: true
218922
+ providerExecuted: true,
218923
+ firstDelta: true
218652
218924
  };
218925
+ const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
218653
218926
  controller.enqueue({
218654
218927
  type: "tool-input-start",
218655
218928
  id: value.content_block.id,
218656
- toolName: value.content_block.name,
218929
+ toolName: mappedToolName,
218657
218930
  providerExecuted: true
218658
218931
  });
218659
218932
  }
@@ -218775,6 +219048,18 @@ var AnthropicMessagesLanguageModel = class {
218775
219048
  }
218776
219049
  return;
218777
219050
  }
219051
+ case "bash_code_execution_tool_result":
219052
+ case "text_editor_code_execution_tool_result": {
219053
+ const part = value.content_block;
219054
+ controller.enqueue({
219055
+ type: "tool-result",
219056
+ toolCallId: part.tool_use_id,
219057
+ toolName: "code_execution",
219058
+ result: part.content,
219059
+ providerExecuted: true
219060
+ });
219061
+ return;
219062
+ }
218778
219063
  default: {
218779
219064
  const _exhaustiveCheck = contentBlockType;
218780
219065
  throw new Error(`Unsupported content block type: ${_exhaustiveCheck}`);
@@ -218805,7 +219090,14 @@ var AnthropicMessagesLanguageModel = class {
218805
219090
  type: "tool-input-end",
218806
219091
  id: contentBlock.toolCallId
218807
219092
  });
218808
- controller.enqueue(contentBlock);
219093
+ const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
219094
+ controller.enqueue({
219095
+ type: "tool-call",
219096
+ toolCallId: contentBlock.toolCallId,
219097
+ toolName,
219098
+ input: contentBlock.input,
219099
+ providerExecuted: contentBlock.providerExecuted
219100
+ });
218809
219101
  }
218810
219102
  break;
218811
219103
  }
@@ -218853,7 +219145,10 @@ var AnthropicMessagesLanguageModel = class {
218853
219145
  }
218854
219146
  case "input_json_delta": {
218855
219147
  const contentBlock = contentBlocks[value.index];
218856
- const delta = value.delta.partial_json;
219148
+ let delta = value.delta.partial_json;
219149
+ if (delta.length === 0) {
219150
+ return;
219151
+ }
218857
219152
  if (usesJsonResponseTool) {
218858
219153
  if ((contentBlock == null ? undefined : contentBlock.type) !== "text") {
218859
219154
  return;
@@ -218867,12 +219162,16 @@ var AnthropicMessagesLanguageModel = class {
218867
219162
  if ((contentBlock == null ? undefined : contentBlock.type) !== "tool-call") {
218868
219163
  return;
218869
219164
  }
219165
+ if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
219166
+ delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
219167
+ }
218870
219168
  controller.enqueue({
218871
219169
  type: "tool-input-delta",
218872
219170
  id: contentBlock.toolCallId,
218873
219171
  delta
218874
219172
  });
218875
219173
  contentBlock.input += delta;
219174
+ contentBlock.firstDelta = false;
218876
219175
  }
218877
219176
  return;
218878
219177
  }
@@ -219019,6 +219318,44 @@ var computer_20250124 = createProviderDefinedToolFactory({
219019
219318
  name: "computer",
219020
219319
  inputSchema: computer_20250124InputSchema
219021
219320
  });
219321
+ var memory_20250818InputSchema = lazySchema(() => zodSchema(exports_external3.discriminatedUnion("command", [
219322
+ exports_external3.object({
219323
+ command: exports_external3.literal("view"),
219324
+ path: exports_external3.string(),
219325
+ view_range: exports_external3.tuple([exports_external3.number(), exports_external3.number()]).optional()
219326
+ }),
219327
+ exports_external3.object({
219328
+ command: exports_external3.literal("create"),
219329
+ path: exports_external3.string(),
219330
+ file_text: exports_external3.string()
219331
+ }),
219332
+ exports_external3.object({
219333
+ command: exports_external3.literal("str_replace"),
219334
+ path: exports_external3.string(),
219335
+ old_str: exports_external3.string(),
219336
+ new_str: exports_external3.string()
219337
+ }),
219338
+ exports_external3.object({
219339
+ command: exports_external3.literal("insert"),
219340
+ path: exports_external3.string(),
219341
+ insert_line: exports_external3.number(),
219342
+ insert_text: exports_external3.string()
219343
+ }),
219344
+ exports_external3.object({
219345
+ command: exports_external3.literal("delete"),
219346
+ path: exports_external3.string()
219347
+ }),
219348
+ exports_external3.object({
219349
+ command: exports_external3.literal("rename"),
219350
+ old_path: exports_external3.string(),
219351
+ new_path: exports_external3.string()
219352
+ })
219353
+ ])));
219354
+ var memory_20250818 = createProviderDefinedToolFactory({
219355
+ id: "anthropic.memory_20250818",
219356
+ name: "memory",
219357
+ inputSchema: memory_20250818InputSchema
219358
+ });
219022
219359
  var textEditor_20241022InputSchema = lazySchema(() => zodSchema(exports_external3.object({
219023
219360
  command: exports_external3.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
219024
219361
  path: exports_external3.string(),
@@ -219065,8 +219402,10 @@ var anthropicTools = {
219065
219402
  bash_20241022,
219066
219403
  bash_20250124,
219067
219404
  codeExecution_20250522,
219405
+ codeExecution_20250825,
219068
219406
  computer_20241022,
219069
219407
  computer_20250124,
219408
+ memory_20250818,
219070
219409
  textEditor_20241022,
219071
219410
  textEditor_20250124,
219072
219411
  textEditor_20250429,
@@ -219119,7 +219458,7 @@ function createAnthropic(options = {}) {
219119
219458
  }
219120
219459
  var anthropic = createAnthropic();
219121
219460
 
219122
- // ../../node_modules/.pnpm/@ai-sdk+openai@2.0.50_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
219461
+ // ../../node_modules/.pnpm/@ai-sdk+openai@2.0.52_zod@3.25.76/node_modules/@ai-sdk/openai/dist/index.mjs
219123
219462
  var openaiErrorDataSchema = exports_external3.object({
219124
219463
  error: exports_external3.object({
219125
219464
  message: exports_external3.string(),
@@ -220660,9 +220999,7 @@ var localShell = createProviderDefinedToolFactoryWithOutputSchema({
220660
220999
  outputSchema: localShellOutputSchema
220661
221000
  });
220662
221001
  var webSearchArgsSchema = lazySchema(() => zodSchema(exports_external3.object({
220663
- filters: exports_external3.object({
220664
- allowedDomains: exports_external3.array(exports_external3.string()).optional()
220665
- }).optional(),
221002
+ filters: exports_external3.object({ allowedDomains: exports_external3.array(exports_external3.string()).optional() }).optional(),
220666
221003
  searchContextSize: exports_external3.enum(["low", "medium", "high"]).optional(),
220667
221004
  userLocation: exports_external3.object({
220668
221005
  type: exports_external3.literal("approximate"),
@@ -220672,14 +221009,15 @@ var webSearchArgsSchema = lazySchema(() => zodSchema(exports_external3.object({
220672
221009
  timezone: exports_external3.string().optional()
220673
221010
  }).optional()
220674
221011
  })));
220675
- var webSearchInputSchema = lazySchema(() => zodSchema(exports_external3.object({
221012
+ var webSearchInputSchema = lazySchema(() => zodSchema(exports_external3.object({})));
221013
+ var webSearchOutputSchema = lazySchema(() => zodSchema(exports_external3.object({
220676
221014
  action: exports_external3.discriminatedUnion("type", [
220677
221015
  exports_external3.object({
220678
221016
  type: exports_external3.literal("search"),
220679
- query: exports_external3.string().nullish()
221017
+ query: exports_external3.string().optional()
220680
221018
  }),
220681
221019
  exports_external3.object({
220682
- type: exports_external3.literal("open_page"),
221020
+ type: exports_external3.literal("openPage"),
220683
221021
  url: exports_external3.string()
220684
221022
  }),
220685
221023
  exports_external3.object({
@@ -220687,16 +221025,15 @@ var webSearchInputSchema = lazySchema(() => zodSchema(exports_external3.object({
220687
221025
  url: exports_external3.string(),
220688
221026
  pattern: exports_external3.string()
220689
221027
  })
220690
- ]).nullish()
221028
+ ])
220691
221029
  })));
220692
- var webSearchToolFactory = createProviderDefinedToolFactory({
221030
+ var webSearchToolFactory = createProviderDefinedToolFactoryWithOutputSchema({
220693
221031
  id: "openai.web_search",
220694
221032
  name: "web_search",
220695
- inputSchema: webSearchInputSchema
221033
+ inputSchema: webSearchInputSchema,
221034
+ outputSchema: webSearchOutputSchema
220696
221035
  });
220697
- var webSearch = (args = {}) => {
220698
- return webSearchToolFactory(args);
220699
- };
221036
+ var webSearch = (args = {}) => webSearchToolFactory(args);
220700
221037
  var webSearchPreviewArgsSchema = lazySchema(() => zodSchema(exports_external3.object({
220701
221038
  searchContextSize: exports_external3.enum(["low", "medium", "high"]).optional(),
220702
221039
  userLocation: exports_external3.object({
@@ -220707,14 +221044,15 @@ var webSearchPreviewArgsSchema = lazySchema(() => zodSchema(exports_external3.ob
220707
221044
  timezone: exports_external3.string().optional()
220708
221045
  }).optional()
220709
221046
  })));
220710
- var webSearchPreviewInputSchema = lazySchema(() => zodSchema(exports_external3.object({
221047
+ var webSearchPreviewInputSchema = lazySchema(() => zodSchema(exports_external3.object({})));
221048
+ var webSearchPreviewOutputSchema = lazySchema(() => zodSchema(exports_external3.object({
220711
221049
  action: exports_external3.discriminatedUnion("type", [
220712
221050
  exports_external3.object({
220713
221051
  type: exports_external3.literal("search"),
220714
- query: exports_external3.string().nullish()
221052
+ query: exports_external3.string().optional()
220715
221053
  }),
220716
221054
  exports_external3.object({
220717
- type: exports_external3.literal("open_page"),
221055
+ type: exports_external3.literal("openPage"),
220718
221056
  url: exports_external3.string()
220719
221057
  }),
220720
221058
  exports_external3.object({
@@ -220722,12 +221060,13 @@ var webSearchPreviewInputSchema = lazySchema(() => zodSchema(exports_external3.o
220722
221060
  url: exports_external3.string(),
220723
221061
  pattern: exports_external3.string()
220724
221062
  })
220725
- ]).nullish()
221063
+ ])
220726
221064
  })));
220727
- var webSearchPreview = createProviderDefinedToolFactory({
221065
+ var webSearchPreview = createProviderDefinedToolFactoryWithOutputSchema({
220728
221066
  id: "openai.web_search_preview",
220729
221067
  name: "web_search_preview",
220730
- inputSchema: webSearchPreviewInputSchema
221068
+ inputSchema: webSearchPreviewInputSchema,
221069
+ outputSchema: webSearchPreviewOutputSchema
220731
221070
  });
220732
221071
  var openaiTools = {
220733
221072
  codeInterpreter,
@@ -220931,6 +221270,9 @@ async function convertToOpenAIResponsesInput({
220931
221270
  input.push(reasoningMessages[reasoningId]);
220932
221271
  } else {
220933
221272
  reasoningMessage.summary.push(...summaryParts);
221273
+ if ((providerOptions == null ? undefined : providerOptions.reasoningEncryptedContent) != null) {
221274
+ reasoningMessage.encrypted_content = providerOptions.reasoningEncryptedContent;
221275
+ }
220934
221276
  }
220935
221277
  }
220936
221278
  } else {
@@ -221085,11 +221427,7 @@ var openaiResponsesChunkSchema = lazyValidator(() => zodSchema(exports_external3
221085
221427
  exports_external3.object({
221086
221428
  type: exports_external3.literal("web_search_call"),
221087
221429
  id: exports_external3.string(),
221088
- status: exports_external3.string(),
221089
- action: exports_external3.object({
221090
- type: exports_external3.literal("search"),
221091
- query: exports_external3.string().optional()
221092
- }).nullish()
221430
+ status: exports_external3.string()
221093
221431
  }),
221094
221432
  exports_external3.object({
221095
221433
  type: exports_external3.literal("computer_call"),
@@ -221171,7 +221509,7 @@ var openaiResponsesChunkSchema = lazyValidator(() => zodSchema(exports_external3
221171
221509
  url: exports_external3.string(),
221172
221510
  pattern: exports_external3.string()
221173
221511
  })
221174
- ]).nullish()
221512
+ ])
221175
221513
  }),
221176
221514
  exports_external3.object({
221177
221515
  type: exports_external3.literal("file_search_call"),
@@ -221259,6 +221597,11 @@ var openaiResponsesChunkSchema = lazyValidator(() => zodSchema(exports_external3
221259
221597
  summary_index: exports_external3.number(),
221260
221598
  delta: exports_external3.string()
221261
221599
  }),
221600
+ exports_external3.object({
221601
+ type: exports_external3.literal("response.reasoning_summary_part.done"),
221602
+ item_id: exports_external3.string(),
221603
+ summary_index: exports_external3.number()
221604
+ }),
221262
221605
  exports_external3.object({
221263
221606
  type: exports_external3.literal("error"),
221264
221607
  code: exports_external3.string(),
@@ -221336,7 +221679,7 @@ var openaiResponsesResponseSchema = lazyValidator(() => zodSchema(exports_extern
221336
221679
  url: exports_external3.string(),
221337
221680
  pattern: exports_external3.string()
221338
221681
  })
221339
- ]).nullish()
221682
+ ])
221340
221683
  }),
221341
221684
  exports_external3.object({
221342
221685
  type: exports_external3.literal("file_search_call"),
@@ -221830,7 +222173,8 @@ var OpenAIResponsesLanguageModel = class {
221830
222173
  tools: openaiTools2,
221831
222174
  tool_choice: openaiToolChoice
221832
222175
  },
221833
- warnings: [...warnings, ...toolWarnings]
222176
+ warnings: [...warnings, ...toolWarnings],
222177
+ store
221834
222178
  };
221835
222179
  }
221836
222180
  async doGenerate(options) {
@@ -221983,14 +222327,14 @@ var OpenAIResponsesLanguageModel = class {
221983
222327
  type: "tool-call",
221984
222328
  toolCallId: part.id,
221985
222329
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
221986
- input: JSON.stringify({ action: part.action }),
222330
+ input: JSON.stringify({}),
221987
222331
  providerExecuted: true
221988
222332
  });
221989
222333
  content3.push({
221990
222334
  type: "tool-result",
221991
222335
  toolCallId: part.id,
221992
222336
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
221993
- result: { status: part.status },
222337
+ result: mapWebSearchOutput(part.action),
221994
222338
  providerExecuted: true
221995
222339
  });
221996
222340
  break;
@@ -222103,7 +222447,8 @@ var OpenAIResponsesLanguageModel = class {
222103
222447
  const {
222104
222448
  args: body,
222105
222449
  warnings,
222106
- webSearchToolName
222450
+ webSearchToolName,
222451
+ store
222107
222452
  } = await this.getArgs(options);
222108
222453
  const { responseHeaders, value: response } = await postJsonToApi({
222109
222454
  url: this.config.url({
@@ -222139,7 +222484,7 @@ var OpenAIResponsesLanguageModel = class {
222139
222484
  controller.enqueue({ type: "stream-start", warnings });
222140
222485
  },
222141
222486
  transform(chunk, controller) {
222142
- var _a18, _b8, _c, _d, _e3, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s, _t3, _u, _v, _w;
222487
+ var _a18, _b8, _c, _d, _e3, _f, _g, _h, _i, _j, _k, _l, _m, _n2, _o, _p, _q, _r, _s, _t3, _u, _v;
222143
222488
  if (options.includeRawChunks) {
222144
222489
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
222145
222490
  }
@@ -222171,6 +222516,17 @@ var OpenAIResponsesLanguageModel = class {
222171
222516
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
222172
222517
  providerExecuted: true
222173
222518
  });
222519
+ controller.enqueue({
222520
+ type: "tool-input-end",
222521
+ id: value.item.id
222522
+ });
222523
+ controller.enqueue({
222524
+ type: "tool-call",
222525
+ toolCallId: value.item.id,
222526
+ toolName: "web_search",
222527
+ input: JSON.stringify({}),
222528
+ providerExecuted: true
222529
+ });
222174
222530
  } else if (value.item.type === "computer_call") {
222175
222531
  ongoingToolCalls[value.output_index] = {
222176
222532
  toolName: "computer_use",
@@ -222227,10 +222583,10 @@ var OpenAIResponsesLanguageModel = class {
222227
222583
  }
222228
222584
  }
222229
222585
  });
222230
- } else if (isResponseOutputItemAddedReasoningChunk(value)) {
222586
+ } else if (isResponseOutputItemAddedChunk(value) && value.item.type === "reasoning") {
222231
222587
  activeReasoning[value.item.id] = {
222232
222588
  encryptedContent: value.item.encrypted_content,
222233
- summaryParts: [0]
222589
+ summaryParts: { 0: "active" }
222234
222590
  };
222235
222591
  controller.enqueue({
222236
222592
  type: "reasoning-start",
@@ -222264,22 +222620,11 @@ var OpenAIResponsesLanguageModel = class {
222264
222620
  });
222265
222621
  } else if (value.item.type === "web_search_call") {
222266
222622
  ongoingToolCalls[value.output_index] = undefined;
222267
- controller.enqueue({
222268
- type: "tool-input-end",
222269
- id: value.item.id
222270
- });
222271
- controller.enqueue({
222272
- type: "tool-call",
222273
- toolCallId: value.item.id,
222274
- toolName: "web_search",
222275
- input: JSON.stringify({ action: value.item.action }),
222276
- providerExecuted: true
222277
- });
222278
222623
  controller.enqueue({
222279
222624
  type: "tool-result",
222280
222625
  toolCallId: value.item.id,
222281
222626
  toolName: "web_search",
222282
- result: { status: value.item.status },
222627
+ result: mapWebSearchOutput(value.item.action),
222283
222628
  providerExecuted: true
222284
222629
  });
222285
222630
  } else if (value.item.type === "computer_call") {
@@ -222369,9 +222714,10 @@ var OpenAIResponsesLanguageModel = class {
222369
222714
  type: "text-end",
222370
222715
  id: value.item.id
222371
222716
  });
222372
- } else if (isResponseOutputItemDoneReasoningChunk(value)) {
222717
+ } else if (value.item.type === "reasoning") {
222373
222718
  const activeReasoningPart = activeReasoning[value.item.id];
222374
- for (const summaryIndex of activeReasoningPart.summaryParts) {
222719
+ const summaryPartIndices = Object.entries(activeReasoningPart.summaryParts).filter(([_8, status]) => status === "active" || status === "can-conclude").map(([summaryIndex]) => summaryIndex);
222720
+ for (const summaryIndex of summaryPartIndices) {
222375
222721
  controller.enqueue({
222376
222722
  type: "reasoning-end",
222377
222723
  id: `${value.item.id}:${summaryIndex}`,
@@ -222443,21 +222789,32 @@ var OpenAIResponsesLanguageModel = class {
222443
222789
  if (((_f = (_e3 = options.providerOptions) == null ? undefined : _e3.openai) == null ? undefined : _f.logprobs) && value.logprobs) {
222444
222790
  logprobs.push(value.logprobs);
222445
222791
  }
222446
- } else if (isResponseReasoningSummaryPartAddedChunk(value)) {
222792
+ } else if (value.type === "response.reasoning_summary_part.added") {
222447
222793
  if (value.summary_index > 0) {
222448
- (_g = activeReasoning[value.item_id]) == null || _g.summaryParts.push(value.summary_index);
222794
+ const activeReasoningPart = activeReasoning[value.item_id];
222795
+ activeReasoningPart.summaryParts[value.summary_index] = "active";
222796
+ for (const summaryIndex of Object.keys(activeReasoningPart.summaryParts)) {
222797
+ if (activeReasoningPart.summaryParts[summaryIndex] === "can-conclude") {
222798
+ controller.enqueue({
222799
+ type: "reasoning-end",
222800
+ id: `${value.item_id}:${summaryIndex}`,
222801
+ providerMetadata: { openai: { itemId: value.item_id } }
222802
+ });
222803
+ activeReasoningPart.summaryParts[summaryIndex] = "concluded";
222804
+ }
222805
+ }
222449
222806
  controller.enqueue({
222450
222807
  type: "reasoning-start",
222451
222808
  id: `${value.item_id}:${value.summary_index}`,
222452
222809
  providerMetadata: {
222453
222810
  openai: {
222454
222811
  itemId: value.item_id,
222455
- reasoningEncryptedContent: (_i = (_h = activeReasoning[value.item_id]) == null ? undefined : _h.encryptedContent) != null ? _i : null
222812
+ reasoningEncryptedContent: (_h = (_g = activeReasoning[value.item_id]) == null ? undefined : _g.encryptedContent) != null ? _h : null
222456
222813
  }
222457
222814
  }
222458
222815
  });
222459
222816
  }
222460
- } else if (isResponseReasoningSummaryTextDeltaChunk(value)) {
222817
+ } else if (value.type === "response.reasoning_summary_text.delta") {
222461
222818
  controller.enqueue({
222462
222819
  type: "reasoning-delta",
222463
222820
  id: `${value.item_id}:${value.summary_index}`,
@@ -222468,16 +222825,29 @@ var OpenAIResponsesLanguageModel = class {
222468
222825
  }
222469
222826
  }
222470
222827
  });
222828
+ } else if (value.type === "response.reasoning_summary_part.done") {
222829
+ if (store) {
222830
+ controller.enqueue({
222831
+ type: "reasoning-end",
222832
+ id: `${value.item_id}:${value.summary_index}`,
222833
+ providerMetadata: {
222834
+ openai: { itemId: value.item_id }
222835
+ }
222836
+ });
222837
+ activeReasoning[value.item_id].summaryParts[value.summary_index] = "concluded";
222838
+ } else {
222839
+ activeReasoning[value.item_id].summaryParts[value.summary_index] = "can-conclude";
222840
+ }
222471
222841
  } else if (isResponseFinishedChunk(value)) {
222472
222842
  finishReason = mapOpenAIResponseFinishReason({
222473
- finishReason: (_j = value.response.incomplete_details) == null ? undefined : _j.reason,
222843
+ finishReason: (_i = value.response.incomplete_details) == null ? undefined : _i.reason,
222474
222844
  hasFunctionCall
222475
222845
  });
222476
222846
  usage.inputTokens = value.response.usage.input_tokens;
222477
222847
  usage.outputTokens = value.response.usage.output_tokens;
222478
222848
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
222479
- usage.reasoningTokens = (_l = (_k = value.response.usage.output_tokens_details) == null ? undefined : _k.reasoning_tokens) != null ? _l : undefined;
222480
- usage.cachedInputTokens = (_n2 = (_m = value.response.usage.input_tokens_details) == null ? undefined : _m.cached_tokens) != null ? _n2 : undefined;
222849
+ usage.reasoningTokens = (_k = (_j = value.response.usage.output_tokens_details) == null ? undefined : _j.reasoning_tokens) != null ? _k : undefined;
222850
+ usage.cachedInputTokens = (_m = (_l = value.response.usage.input_tokens_details) == null ? undefined : _l.cached_tokens) != null ? _m : undefined;
222481
222851
  if (typeof value.response.service_tier === "string") {
222482
222852
  serviceTier = value.response.service_tier;
222483
222853
  }
@@ -222486,7 +222856,7 @@ var OpenAIResponsesLanguageModel = class {
222486
222856
  controller.enqueue({
222487
222857
  type: "source",
222488
222858
  sourceType: "url",
222489
- id: (_q = (_p = (_o = self2.config).generateId) == null ? undefined : _p.call(_o)) != null ? _q : generateId(),
222859
+ id: (_p = (_o = (_n2 = self2.config).generateId) == null ? undefined : _o.call(_n2)) != null ? _p : generateId(),
222490
222860
  url: value.annotation.url,
222491
222861
  title: value.annotation.title
222492
222862
  });
@@ -222494,10 +222864,10 @@ var OpenAIResponsesLanguageModel = class {
222494
222864
  controller.enqueue({
222495
222865
  type: "source",
222496
222866
  sourceType: "document",
222497
- id: (_t3 = (_s = (_r = self2.config).generateId) == null ? undefined : _s.call(_r)) != null ? _t3 : generateId(),
222867
+ id: (_s = (_r = (_q = self2.config).generateId) == null ? undefined : _r.call(_q)) != null ? _s : generateId(),
222498
222868
  mediaType: "text/plain",
222499
- title: (_v = (_u = value.annotation.quote) != null ? _u : value.annotation.filename) != null ? _v : "Document",
222500
- filename: (_w = value.annotation.filename) != null ? _w : value.annotation.file_id
222869
+ title: (_u = (_t3 = value.annotation.quote) != null ? _t3 : value.annotation.filename) != null ? _u : "Document",
222870
+ filename: (_v = value.annotation.filename) != null ? _v : value.annotation.file_id
222501
222871
  });
222502
222872
  }
222503
222873
  } else if (isErrorChunk(value)) {
@@ -222535,9 +222905,6 @@ function isTextDeltaChunk(chunk) {
222535
222905
  function isResponseOutputItemDoneChunk(chunk) {
222536
222906
  return chunk.type === "response.output_item.done";
222537
222907
  }
222538
- function isResponseOutputItemDoneReasoningChunk(chunk) {
222539
- return isResponseOutputItemDoneChunk(chunk) && chunk.item.type === "reasoning";
222540
- }
222541
222908
  function isResponseFinishedChunk(chunk) {
222542
222909
  return chunk.type === "response.completed" || chunk.type === "response.incomplete";
222543
222910
  }
@@ -222556,18 +222923,9 @@ function isResponseCodeInterpreterCallCodeDoneChunk(chunk) {
222556
222923
  function isResponseOutputItemAddedChunk(chunk) {
222557
222924
  return chunk.type === "response.output_item.added";
222558
222925
  }
222559
- function isResponseOutputItemAddedReasoningChunk(chunk) {
222560
- return isResponseOutputItemAddedChunk(chunk) && chunk.item.type === "reasoning";
222561
- }
222562
222926
  function isResponseAnnotationAddedChunk(chunk) {
222563
222927
  return chunk.type === "response.output_text.annotation.added";
222564
222928
  }
222565
- function isResponseReasoningSummaryPartAddedChunk(chunk) {
222566
- return chunk.type === "response.reasoning_summary_part.added";
222567
- }
222568
- function isResponseReasoningSummaryTextDeltaChunk(chunk) {
222569
- return chunk.type === "response.reasoning_summary_text.delta";
222570
- }
222571
222929
  function isErrorChunk(chunk) {
222572
222930
  return chunk.type === "error";
222573
222931
  }
@@ -222605,6 +222963,19 @@ function getResponsesModelConfig(modelId) {
222605
222963
  isReasoningModel: false
222606
222964
  };
222607
222965
  }
222966
+ function mapWebSearchOutput(action) {
222967
+ var _a18;
222968
+ switch (action.type) {
222969
+ case "search":
222970
+ return { action: { type: "search", query: (_a18 = action.query) != null ? _a18 : undefined } };
222971
+ case "open_page":
222972
+ return { action: { type: "openPage", url: action.url } };
222973
+ case "find":
222974
+ return {
222975
+ action: { type: "find", url: action.url, pattern: action.pattern }
222976
+ };
222977
+ }
222978
+ }
222608
222979
  var openaiSpeechProviderOptionsSchema = lazyValidator(() => zodSchema(exports_external3.object({
222609
222980
  instructions: exports_external3.string().nullish(),
222610
222981
  speed: exports_external3.number().min(0.25).max(4).default(1).nullish()
@@ -222894,7 +223265,7 @@ var OpenAITranscriptionModel = class {
222894
223265
  };
222895
223266
  }
222896
223267
  };
222897
- var VERSION5 = "2.0.50";
223268
+ var VERSION5 = "2.0.52";
222898
223269
  function createOpenAI(options = {}) {
222899
223270
  var _a18, _b8;
222900
223271
  const baseURL = (_a18 = withoutTrailingSlash(loadOptionalSetting({
@@ -226660,15 +227031,15 @@ class wa {
226660
227031
  return console.error("Error:", { status: e489, message: t480 }), new Response(JSON.stringify({ error: t480 }), { status: e489, headers: { ...this.corsHeaders, "Content-Type": "application/json" } });
226661
227032
  }
226662
227033
  }
226663
- async function ba(e489) {
227034
+ function ba(e489) {
226664
227035
  if (e489 instanceof Request) {
226665
- return (await wa.New({ ...wa.defaultConfig() }))(e489);
227036
+ return wa.New({ ...wa.defaultConfig() })(e489);
226666
227037
  }
226667
227038
  return wa.New(e489);
226668
227039
  }
226669
227040
 
226670
227041
  // src/index.ts
226671
- async function startServer(mcpServer) {
227042
+ async function startServer(settings, mcpServer) {
226672
227043
  const widgetPath = findWidgetPath();
226673
227044
  console.log("✅ Widget found:", widgetPath);
226674
227045
  const port = await findAvailablePort(parseInt(process.env.PORT || "3500"));
@@ -226676,11 +227047,12 @@ async function startServer(mcpServer) {
226676
227047
  const app = import_express.default();
226677
227048
  app.use(import_express.default.json());
226678
227049
  app.use((req, res, next) => {
226679
- res.header("Access-Control-Allow-Origin", "*");
226680
- res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
226681
- res.header("Access-Control-Allow-Headers", "Content-Type");
227050
+ res.header(settings.headers);
226682
227051
  next();
226683
227052
  });
227053
+ app.options("*", (req, res) => {
227054
+ res.status(200).end();
227055
+ });
226684
227056
  app.get("/widget.js", (req, res) => {
226685
227057
  try {
226686
227058
  const widgetCode = readFileSync(widgetPath, "utf-8");
@@ -226693,7 +227065,7 @@ async function startServer(mcpServer) {
226693
227065
  res.status(404).send("Widget not found. Please run 'bun run build:widget' first.");
226694
227066
  }
226695
227067
  });
226696
- app.all("/ask", async (req, res) => {
227068
+ app.post("/ask", async (req, res) => {
226697
227069
  try {
226698
227070
  const body = req.method === "POST" ? JSON.stringify(req.body) : undefined;
226699
227071
  const request = new Request(`http://localhost:${port}${req.url}`, {
@@ -226701,7 +227073,18 @@ async function startServer(mcpServer) {
226701
227073
  headers: new Headers(req.headers),
226702
227074
  body
226703
227075
  });
226704
- const response = await ba(request);
227076
+ let mcpUrl = settings.mcp?.url || "";
227077
+ if (Array.isArray(mcpUrl)) {
227078
+ console.warn("MCP as array is not supported, using the first one");
227079
+ mcpUrl = mcpUrl[0];
227080
+ }
227081
+ const askAiHandlerFn = ba({
227082
+ mcpUrl,
227083
+ aiProvider: settings.ai.provider || "",
227084
+ aiModel: settings.ai.model || "",
227085
+ aiToken: settings.ai.token || ""
227086
+ });
227087
+ const response = await askAiHandlerFn(request);
226705
227088
  for (const [key, value] of response.headers.entries()) {
226706
227089
  res.set(key, value);
226707
227090
  }
@@ -226787,9 +227170,139 @@ async function findAvailablePort(startPort = 3500, maxAttempts = 10) {
226787
227170
  throw new Error(`No available ports found between ${startPort} and ${startPort + maxAttempts - 1}`);
226788
227171
  }
226789
227172
 
226790
- // server.ts
226791
- var source = process.env.MCP_SOURCE;
226792
- if (!source) {
226793
- throw new Error("MCP_SOURCE is not set");
227173
+ // src/utils.ts
227174
+ import path4 from "node:path";
227175
+ import fs4 from "node:fs/promises";
227176
+
227177
+ // ../cli-sdk/dist/index.js
227178
+ function replaceEnvVars(obj, removeUndefined = false) {
227179
+ if (obj === null || obj === undefined) {
227180
+ return obj;
227181
+ }
227182
+ if (typeof obj === "string") {
227183
+ if (obj.includes("$")) {
227184
+ return obj.replace(/\$([A-Z_][A-Z0-9_]*)/g, (match, varName) => {
227185
+ const envValue = process.env[varName];
227186
+ if (envValue === undefined) {
227187
+ if (removeUndefined) {
227188
+ return "";
227189
+ }
227190
+ console.warn(`
227191
+ ⚠️ Environment variable "${varName}" is not set, keeping placeholder: ${match}`);
227192
+ return match;
227193
+ }
227194
+ return envValue;
227195
+ });
227196
+ }
227197
+ return obj;
227198
+ }
227199
+ if (Array.isArray(obj)) {
227200
+ return obj.map((item) => replaceEnvVars(item, removeUndefined));
227201
+ }
227202
+ if (typeof obj === "object") {
227203
+ const result = {};
227204
+ for (const [key, value] of Object.entries(obj)) {
227205
+ result[key] = replaceEnvVars(value, removeUndefined);
227206
+ }
227207
+ return result;
227208
+ }
227209
+ return obj;
227210
+ }
227211
+
227212
+ // src/utils.ts
227213
+ function getSettingsPath() {
227214
+ return path4.join(process.cwd(), "askai.json");
227215
+ }
227216
+ async function loadSetting() {
227217
+ const settingsPath = getSettingsPath();
227218
+ try {
227219
+ await fs4.access(settingsPath);
227220
+ } catch (error40) {
227221
+ const settings2 = newSettings();
227222
+ ensureSettings(settings2);
227223
+ return settings2;
227224
+ }
227225
+ const settingsJSON = await fs4.readFile(settingsPath, "utf-8");
227226
+ let settings = JSON.parse(settingsJSON);
227227
+ settings = replaceEnvVars(settings, true);
227228
+ ensureSettings(settings);
227229
+ return settings;
227230
+ }
227231
+ function newSettings() {
227232
+ return {
227233
+ ai: {
227234
+ provider: "",
227235
+ model: "",
227236
+ token: ""
227237
+ },
227238
+ mcp: {
227239
+ url: ""
227240
+ },
227241
+ headers: {}
227242
+ };
227243
+ }
227244
+ function ensureSettings(settings) {
227245
+ if (!settings.ai) {
227246
+ settings.ai = {
227247
+ provider: "",
227248
+ model: "",
227249
+ token: ""
227250
+ };
227251
+ }
227252
+ if (!settings.mcp) {
227253
+ settings.mcp = {
227254
+ url: ""
227255
+ };
227256
+ }
227257
+ if (!settings.sources) {
227258
+ settings.sources = {
227259
+ openapi: "",
227260
+ llms: ""
227261
+ };
227262
+ }
227263
+ if (process.env.OPENAPI_SOURCE) {
227264
+ settings.sources.openapi = process.env.OPENAPI_SOURCE;
227265
+ console.log("(env settings): using OPENAPI_SOURCE");
227266
+ }
227267
+ if (process.env.LLMS_SOURCE) {
227268
+ settings.sources.llms = process.env.LLMS_SOURCE;
227269
+ console.log("(env settings): using LLMS_SOURCE");
227270
+ }
227271
+ if (process.env.MCP_URL) {
227272
+ settings.mcp.url = process.env.MCP_URL;
227273
+ console.log("(env settings): using MCP_URL");
227274
+ }
227275
+ if (process.env.AI_PROVIDER) {
227276
+ settings.ai.provider = process.env.AI_PROVIDER;
227277
+ console.log("(env settings): using AI_PROVIDER");
227278
+ }
227279
+ if (process.env.AI_MODEL) {
227280
+ settings.ai.model = process.env.AI_MODEL;
227281
+ console.log("(env settings): using AI_MODEL");
227282
+ }
227283
+ if (process.env.AI_TOKEN) {
227284
+ settings.ai.token = process.env.AI_TOKEN;
227285
+ console.log("(env settings): using AI_TOKEN");
227286
+ }
227287
+ if (!settings.headers || !Object.keys(settings.headers).length) {
227288
+ settings.headers = {
227289
+ "Access-Control-Allow-Origin": "*",
227290
+ "Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
227291
+ "Access-Control-Allow-Methods": "GET, POST, OPTIONS, PUT, DELETE",
227292
+ "Access-Control-Max-Age": "86400"
227293
+ };
227294
+ }
226794
227295
  }
226795
- startServer(new MCPServer(source)).catch(console.error);
227296
+
227297
+ // server.ts
227298
+ loadSetting().then((settings) => {
227299
+ if (!settings.mcp?.url) {
227300
+ throw new Error("MCP_SOURCE is not set");
227301
+ }
227302
+ const openApiSource = settings.mcp?.sources?.openapi || "";
227303
+ if (!openApiSource) {
227304
+ console.warn("Open API source is not set");
227305
+ }
227306
+ const mcpServer = new MCPServer(openApiSource);
227307
+ return startServer(settings, mcpServer);
227308
+ }).catch(console.error);