drizzle-cube 0.4.22 → 0.4.24

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.
Files changed (37) hide show
  1. package/dist/adapters/express/index.cjs +1 -1
  2. package/dist/adapters/express/index.js +2 -2
  3. package/dist/adapters/fastify/index.cjs +1 -1
  4. package/dist/adapters/fastify/index.js +2 -2
  5. package/dist/adapters/{handler-9Rdn7zM2.js → handler-BV2_dul8.js} +2 -2
  6. package/dist/adapters/{handler-B-tEntiU.cjs → handler-LMRPeTNJ.cjs} +2 -2
  7. package/dist/adapters/hono/index.cjs +6 -6
  8. package/dist/adapters/hono/index.d.ts +13 -6
  9. package/dist/adapters/hono/index.js +65 -65
  10. package/dist/{server/index-CFEJ62GJ.js → adapters/index-C3PskWTr.js} +209 -193
  11. package/dist/{server/index-BIMhF5KZ.cjs → adapters/index-ht4NPca9.cjs} +11 -11
  12. package/dist/adapters/{mcp-transport-m1X1GtwG.js → mcp-transport-B6ZudTSk.js} +7 -0
  13. package/dist/adapters/{mcp-transport-8u9G5oNa.cjs → mcp-transport-DCiSGtp1.cjs} +1 -1
  14. package/dist/adapters/nextjs/index.cjs +2 -2
  15. package/dist/adapters/nextjs/index.js +2 -2
  16. package/dist/adapters/{openai-mLo2MCat.cjs → openai-BvA6eLs8.cjs} +1 -1
  17. package/dist/adapters/{openai-CUSRuKTk.js → openai-mcE24du8.js} +1 -1
  18. package/dist/client/chunks/{analysis-builder-DVrv9Q4n.js → analysis-builder-KeTsXp1G.js} +141 -141
  19. package/dist/client/chunks/{analysis-builder-DVrv9Q4n.js.map → analysis-builder-KeTsXp1G.js.map} +1 -1
  20. package/dist/client/chunks/{analysis-builder-shared-CrENEvEk.js → analysis-builder-shared-KSvGUzx6.js} +2 -2
  21. package/dist/client/chunks/{analysis-builder-shared-CrENEvEk.js.map → analysis-builder-shared-KSvGUzx6.js.map} +1 -1
  22. package/dist/client/chunks/{components-GzooQM5J.js → components-Dz6XHgnZ.js} +49 -49
  23. package/dist/client/chunks/{components-GzooQM5J.js.map → components-Dz6XHgnZ.js.map} +1 -1
  24. package/dist/client/components/AgenticNotebook/NotebookCanvas.d.ts +4 -1
  25. package/dist/client/components/AgenticNotebook/NotebookPortletBlock.d.ts +2 -0
  26. package/dist/client/components.js +3 -3
  27. package/dist/client/index.js +678 -672
  28. package/dist/client/index.js.map +1 -1
  29. package/dist/client-bundle-stats.html +1 -1
  30. package/dist/{adapters/index-CFEJ62GJ.js → server/index-C3PskWTr.js} +209 -193
  31. package/dist/{adapters/index-BIMhF5KZ.cjs → server/index-ht4NPca9.cjs} +11 -11
  32. package/dist/server/index.cjs +2 -2
  33. package/dist/server/index.d.ts +5 -0
  34. package/dist/server/index.js +8 -1
  35. package/dist/server/{openai-mLo2MCat.cjs → openai-BvA6eLs8.cjs} +1 -1
  36. package/dist/server/{openai-CUSRuKTk.js → openai-mcE24du8.js} +1 -1
  37. package/package.json +1 -1
@@ -120,7 +120,7 @@ function xr(n) {
120
120
  function Ar(n, e) {
121
121
  return Object.prototype.hasOwnProperty.call(n, e);
122
122
  }
123
- function We(n) {
123
+ function qe(n) {
124
124
  return n != null && typeof n == "object" && !Array.isArray(n);
125
125
  }
126
126
  const Rr = (n, e) => {
@@ -135,7 +135,7 @@ const Rr = (n, e) => {
135
135
  } catch {
136
136
  return;
137
137
  }
138
- }, Oe = (n) => new Promise((e) => setTimeout(e, n)), ce = "6.25.0", Cr = () => (
138
+ }, Pe = (n) => new Promise((e) => setTimeout(e, n)), ce = "6.27.0", Cr = () => (
139
139
  // @ts-ignore
140
140
  typeof window < "u" && // @ts-ignore
141
141
  typeof window.document < "u" && // @ts-ignore
@@ -547,6 +547,9 @@ function Dr(n, e = {}) {
547
547
  return s.charsetSentinel && (s.charset === "iso-8859-1" ? d += "utf8=%26%2310003%3B&" : d += "utf8=%E2%9C%93&"), m.length > 0 ? d + m : "";
548
548
  }
549
549
  function Ur(n) {
550
+ return Dr(n, { arrayFormat: "brackets" });
551
+ }
552
+ function Wr(n) {
550
553
  let e = 0;
551
554
  for (const r of n)
552
555
  e += r.length;
@@ -575,10 +578,10 @@ class ot {
575
578
  if (e == null)
576
579
  return [];
577
580
  const t = e instanceof ArrayBuffer ? new Uint8Array(e) : typeof e == "string" ? Ut(e) : e;
578
- S(this, j, Ur([o(this, j, "f"), t]));
581
+ S(this, j, Wr([o(this, j, "f"), t]));
579
582
  const s = [];
580
583
  let r;
581
- for (; (r = Wr(o(this, j, "f"), o(this, H, "f"))) != null; ) {
584
+ for (; (r = qr(o(this, j, "f"), o(this, H, "f"))) != null; ) {
582
585
  if (r.carriage && o(this, H, "f") == null) {
583
586
  S(this, H, r.index);
584
587
  continue;
@@ -601,7 +604,7 @@ j = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap();
601
604
  ot.NEWLINE_CHARS = /* @__PURE__ */ new Set([`
602
605
  `, "\r"]);
603
606
  ot.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
604
- function Wr(n, e) {
607
+ function qr(n, e) {
605
608
  for (let r = e ?? 0; r < n.length; r++) {
606
609
  if (n[r] === 10)
607
610
  return { preceding: r, index: r + 1, carriage: !1 };
@@ -610,7 +613,7 @@ function Wr(n, e) {
610
613
  }
611
614
  return null;
612
615
  }
613
- function qr(n) {
616
+ function jr(n) {
614
617
  for (let s = 0; s < n.length - 1; s++) {
615
618
  if (n[s] === 10 && n[s + 1] === 10 || n[s] === 13 && n[s + 1] === 13)
616
619
  return s + 2;
@@ -619,7 +622,7 @@ function qr(n) {
619
622
  }
620
623
  return -1;
621
624
  }
622
- const Ge = {
625
+ const Ye = {
623
626
  off: 0,
624
627
  error: 200,
625
628
  warn: 300,
@@ -627,17 +630,17 @@ const Ge = {
627
630
  debug: 500
628
631
  }, Ss = (n, e, t) => {
629
632
  if (n) {
630
- if (Ar(Ge, n))
633
+ if (Ar(Ye, n))
631
634
  return n;
632
- L(t).warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(Ge))}`);
635
+ L(t).warn(`${e} was set to ${JSON.stringify(n)}, expected one of ${JSON.stringify(Object.keys(Ye))}`);
633
636
  }
634
637
  };
635
638
  function ye() {
636
639
  }
637
- function Ne(n, e, t) {
638
- return !e || Ge[n] > Ge[t] ? ye : e[n].bind(e);
640
+ function Me(n, e, t) {
641
+ return !e || Ye[n] > Ye[t] ? ye : e[n].bind(e);
639
642
  }
640
- const jr = {
643
+ const Hr = {
641
644
  error: ye,
642
645
  warn: ye,
643
646
  info: ye,
@@ -647,15 +650,15 @@ let xs = /* @__PURE__ */ new WeakMap();
647
650
  function L(n) {
648
651
  const e = n.logger, t = n.logLevel ?? "off";
649
652
  if (!e)
650
- return jr;
653
+ return Hr;
651
654
  const s = xs.get(e);
652
655
  if (s && s[0] === t)
653
656
  return s[1];
654
657
  const r = {
655
- error: Ne("error", e, t),
656
- warn: Ne("warn", e, t),
657
- info: Ne("info", e, t),
658
- debug: Ne("debug", e, t)
658
+ error: Me("error", e, t),
659
+ warn: Me("warn", e, t),
660
+ info: Me("info", e, t),
661
+ debug: Me("debug", e, t)
659
662
  };
660
663
  return xs.set(e, [t, r]), r;
661
664
  }
@@ -677,7 +680,7 @@ class G {
677
680
  i = !0;
678
681
  let h = !1;
679
682
  try {
680
- for await (const f of Hr(e, t))
683
+ for await (const f of Jr(e, t))
681
684
  if (!h) {
682
685
  if (f.data.startsWith("[DONE]")) {
683
686
  h = !0;
@@ -801,11 +804,11 @@ class G {
801
804
  });
802
805
  }
803
806
  }
804
- async function* Hr(n, e) {
807
+ async function* Jr(n, e) {
805
808
  if (!n.body)
806
809
  throw e.abort(), typeof globalThis.navigator < "u" && globalThis.navigator.product === "ReactNative" ? new g("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new g("Attempted to iterate over a response with no body");
807
- const t = new Xr(), s = new ot(), r = Ys(n.body);
808
- for await (const i of Jr(r))
810
+ const t = new Kr(), s = new ot(), r = Ys(n.body);
811
+ for await (const i of Xr(r))
809
812
  for (const a of s.decode(i)) {
810
813
  const l = t.decode(a);
811
814
  l && (yield l);
@@ -815,7 +818,7 @@ async function* Hr(n, e) {
815
818
  a && (yield a);
816
819
  }
817
820
  }
818
- async function* Jr(n) {
821
+ async function* Xr(n) {
819
822
  let e = new Uint8Array();
820
823
  for await (const t of n) {
821
824
  if (t == null)
@@ -824,12 +827,12 @@ async function* Jr(n) {
824
827
  let r = new Uint8Array(e.length + s.length);
825
828
  r.set(e), r.set(s, e.length), e = r;
826
829
  let i;
827
- for (; (i = qr(e)) !== -1; )
830
+ for (; (i = jr(e)) !== -1; )
828
831
  yield e.slice(0, i), e = e.slice(i);
829
832
  }
830
833
  e.length > 0 && (yield e);
831
834
  }
832
- class Xr {
835
+ class Kr {
833
836
  constructor() {
834
837
  this.event = null, this.data = [], this.chunks = [];
835
838
  }
@@ -847,11 +850,11 @@ class Xr {
847
850
  }
848
851
  if (this.chunks.push(e), e.startsWith(":"))
849
852
  return null;
850
- let [t, s, r] = Kr(e, ":");
853
+ let [t, s, r] = Vr(e, ":");
851
854
  return r.startsWith(" ") && (r = r.substring(1)), t === "event" ? this.event = r : t === "data" && this.data.push(r), null;
852
855
  }
853
856
  }
854
- function Kr(n, e) {
857
+ function Vr(n, e) {
855
858
  const t = n.indexOf(e);
856
859
  return t !== -1 ? [n.substring(0, t), e, n.substring(t + e.length)] : [n, "", ""];
857
860
  }
@@ -940,10 +943,10 @@ class lt extends Promise {
940
943
  }
941
944
  }
942
945
  we = /* @__PURE__ */ new WeakMap();
943
- var Me;
946
+ var Fe;
944
947
  class Wt {
945
948
  constructor(e, t, s, r) {
946
- Me.set(this, void 0), S(this, Me, e), this.options = r, this.response = t, this.body = s;
949
+ Fe.set(this, void 0), S(this, Fe, e), this.options = r, this.response = t, this.body = s;
947
950
  }
948
951
  hasNextPage() {
949
952
  return this.getPaginatedItems().length ? this.nextPageRequestOptions() != null : !1;
@@ -952,20 +955,20 @@ class Wt {
952
955
  const e = this.nextPageRequestOptions();
953
956
  if (!e)
954
957
  throw new g("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");
955
- return await o(this, Me, "f").requestAPIList(this.constructor, e);
958
+ return await o(this, Fe, "f").requestAPIList(this.constructor, e);
956
959
  }
957
960
  async *iterPages() {
958
961
  let e = this;
959
962
  for (yield e; e.hasNextPage(); )
960
963
  e = await e.getNextPage(), yield e;
961
964
  }
962
- async *[(Me = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
965
+ async *[(Fe = /* @__PURE__ */ new WeakMap(), Symbol.asyncIterator)]() {
963
966
  for await (const e of this.iterPages())
964
967
  for (const t of e.getPaginatedItems())
965
968
  yield t;
966
969
  }
967
970
  }
968
- class Vr extends lt {
971
+ class zr extends lt {
969
972
  constructor(e, t, s) {
970
973
  super(e, t, async (r, i) => new s(r, i.response, await rn(r, i), i.options));
971
974
  }
@@ -1014,7 +1017,7 @@ class C extends Wt {
1014
1017
  } : null;
1015
1018
  }
1016
1019
  }
1017
- class Ye extends Wt {
1020
+ class ke extends Wt {
1018
1021
  constructor(e, t, s, r) {
1019
1022
  super(e, t, s, r), this.data = s.data || [], this.has_more = s.has_more || !1, this.last_id = s.last_id || "";
1020
1023
  }
@@ -1044,11 +1047,11 @@ const on = () => {
1044
1047
  function Ce(n, e, t) {
1045
1048
  return on(), new File(n, e ?? "unknown_file", t);
1046
1049
  }
1047
- function qe(n) {
1050
+ function je(n) {
1048
1051
  return (typeof n == "object" && n !== null && ("name" in n && n.name && String(n.name) || "url" in n && n.url && String(n.url) || "filename" in n && n.filename && String(n.filename) || "path" in n && n.path && String(n.path)) || "").split(/[\\/]/).pop() || void 0;
1049
1052
  }
1050
- const qt = (n) => n != null && typeof n == "object" && typeof n[Symbol.asyncIterator] == "function", ke = async (n, e) => It(n.body) ? { ...n, body: await ln(n.body, e) } : n, fe = async (n, e) => ({ ...n, body: await ln(n.body, e) }), As = /* @__PURE__ */ new WeakMap();
1051
- function zr(n) {
1053
+ const qt = (n) => n != null && typeof n == "object" && typeof n[Symbol.asyncIterator] == "function", Ee = async (n, e) => It(n.body) ? { ...n, body: await ln(n.body, e) } : n, fe = async (n, e) => ({ ...n, body: await ln(n.body, e) }), As = /* @__PURE__ */ new WeakMap();
1054
+ function Qr(n) {
1052
1055
  const e = typeof n == "function" ? n : n.fetch, t = As.get(e);
1053
1056
  if (t)
1054
1057
  return t;
@@ -1063,12 +1066,12 @@ function zr(n) {
1063
1066
  return As.set(e, s), s;
1064
1067
  }
1065
1068
  const ln = async (n, e) => {
1066
- if (!await zr(e))
1069
+ if (!await Qr(e))
1067
1070
  throw new TypeError("The provided fetch function does not support file uploads with the current global FormData class.");
1068
1071
  const t = new FormData();
1069
1072
  return await Promise.all(Object.entries(n || {}).map(([s, r]) => kt(t, s, r))), t;
1070
- }, cn = (n) => n instanceof Blob && "name" in n, Qr = (n) => typeof n == "object" && n !== null && (n instanceof Response || qt(n) || cn(n)), It = (n) => {
1071
- if (Qr(n))
1073
+ }, cn = (n) => n instanceof Blob && "name" in n, Gr = (n) => typeof n == "object" && n !== null && (n instanceof Response || qt(n) || cn(n)), It = (n) => {
1074
+ if (Gr(n))
1072
1075
  return !0;
1073
1076
  if (Array.isArray(n))
1074
1077
  return n.some(It);
@@ -1085,11 +1088,11 @@ const ln = async (n, e) => {
1085
1088
  if (typeof t == "string" || typeof t == "number" || typeof t == "boolean")
1086
1089
  n.append(e, String(t));
1087
1090
  else if (t instanceof Response)
1088
- n.append(e, Ce([await t.blob()], qe(t)));
1091
+ n.append(e, Ce([await t.blob()], je(t)));
1089
1092
  else if (qt(t))
1090
- n.append(e, Ce([await new Response(Gs(t)).blob()], qe(t)));
1093
+ n.append(e, Ce([await new Response(Gs(t)).blob()], je(t)));
1091
1094
  else if (cn(t))
1092
- n.append(e, t, qe(t));
1095
+ n.append(e, t, je(t));
1093
1096
  else if (Array.isArray(t))
1094
1097
  await Promise.all(t.map((s) => kt(n, e + "[]", s)));
1095
1098
  else if (typeof t == "object")
@@ -1097,16 +1100,16 @@ const ln = async (n, e) => {
1097
1100
  else
1098
1101
  throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${t} instead`);
1099
1102
  }
1100
- }, un = (n) => n != null && typeof n == "object" && typeof n.size == "number" && typeof n.type == "string" && typeof n.text == "function" && typeof n.slice == "function" && typeof n.arrayBuffer == "function", Gr = (n) => n != null && typeof n == "object" && typeof n.name == "string" && typeof n.lastModified == "number" && un(n), Yr = (n) => n != null && typeof n == "object" && typeof n.url == "string" && typeof n.blob == "function";
1101
- async function Zr(n, e, t) {
1102
- if (on(), n = await n, Gr(n))
1103
+ }, un = (n) => n != null && typeof n == "object" && typeof n.size == "number" && typeof n.type == "string" && typeof n.text == "function" && typeof n.slice == "function" && typeof n.arrayBuffer == "function", Yr = (n) => n != null && typeof n == "object" && typeof n.name == "string" && typeof n.lastModified == "number" && un(n), Zr = (n) => n != null && typeof n == "object" && typeof n.url == "string" && typeof n.blob == "function";
1104
+ async function ei(n, e, t) {
1105
+ if (on(), n = await n, Yr(n))
1103
1106
  return n instanceof File ? n : Ce([await n.arrayBuffer()], n.name);
1104
- if (Yr(n)) {
1107
+ if (Zr(n)) {
1105
1108
  const r = await n.blob();
1106
1109
  return e || (e = new URL(n.url).pathname.split(/[\\/]/).pop()), Ce(await Et(r), e, t);
1107
1110
  }
1108
1111
  const s = await Et(n);
1109
- if (e || (e = qe(n)), !t?.type) {
1112
+ if (e || (e = je(n)), !t?.type) {
1110
1113
  const r = s.find((i) => typeof i == "object" && "type" in i && i.type);
1111
1114
  typeof r == "string" && (t = { ...t, type: r });
1112
1115
  }
@@ -1124,11 +1127,11 @@ async function Et(n) {
1124
1127
  e.push(...await Et(t));
1125
1128
  else {
1126
1129
  const t = n?.constructor?.name;
1127
- throw new Error(`Unexpected data type: ${typeof n}${t ? `; constructor: ${t}` : ""}${ei(n)}`);
1130
+ throw new Error(`Unexpected data type: ${typeof n}${t ? `; constructor: ${t}` : ""}${ti(n)}`);
1128
1131
  }
1129
1132
  return e;
1130
1133
  }
1131
- function ei(n) {
1134
+ function ti(n) {
1132
1135
  return typeof n != "object" || n === null ? "" : `; props: [${Object.getOwnPropertyNames(n).map((t) => `"${t}"`).join(", ")}]`;
1133
1136
  }
1134
1137
  class _ {
@@ -1139,7 +1142,7 @@ class _ {
1139
1142
  function hn(n) {
1140
1143
  return n.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
1141
1144
  }
1142
- const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), ti = (n = hn) => function(t, ...s) {
1145
+ const Rs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), si = (n = hn) => function(t, ...s) {
1143
1146
  if (t.length === 1)
1144
1147
  return t[0];
1145
1148
  let r = !1;
@@ -1174,7 +1177,7 @@ ${a}
1174
1177
  ${d}`);
1175
1178
  }
1176
1179
  return a;
1177
- }, c = /* @__PURE__ */ ti(hn);
1180
+ }, c = /* @__PURE__ */ si(hn);
1178
1181
  let dn = class extends _ {
1179
1182
  /**
1180
1183
  * Get the messages in a stored chat completion. Only Chat Completions that have
@@ -1200,10 +1203,10 @@ function Ze(n) {
1200
1203
  function jt(n) {
1201
1204
  return n?.$brand === "auto-parseable-response-format";
1202
1205
  }
1203
- function Pe(n) {
1206
+ function Te(n) {
1204
1207
  return n?.$brand === "auto-parseable-tool";
1205
1208
  }
1206
- function si(n, e) {
1209
+ function ni(n, e) {
1207
1210
  return !e || !fn(e) ? {
1208
1211
  ...n,
1209
1212
  choices: n.choices.map((t) => (pn(t.message.tool_calls), {
@@ -1229,42 +1232,42 @@ function Ht(n, e) {
1229
1232
  message: {
1230
1233
  ...s.message,
1231
1234
  ...s.message.tool_calls ? {
1232
- tool_calls: s.message.tool_calls?.map((r) => ri(e, r)) ?? void 0
1235
+ tool_calls: s.message.tool_calls?.map((r) => ii(e, r)) ?? void 0
1233
1236
  } : void 0,
1234
- parsed: s.message.content && !s.message.refusal ? ni(e, s.message.content) : null
1237
+ parsed: s.message.content && !s.message.refusal ? ri(e, s.message.content) : null
1235
1238
  }
1236
1239
  };
1237
1240
  });
1238
1241
  return { ...n, choices: t };
1239
1242
  }
1240
- function ni(n, e) {
1243
+ function ri(n, e) {
1241
1244
  return n.response_format?.type !== "json_schema" ? null : n.response_format?.type === "json_schema" ? "$parseRaw" in n.response_format ? n.response_format.$parseRaw(e) : JSON.parse(e) : null;
1242
1245
  }
1243
- function ri(n, e) {
1246
+ function ii(n, e) {
1244
1247
  const t = n.tools?.find((s) => Ze(s) && s.function?.name === e.function.name);
1245
1248
  return {
1246
1249
  ...e,
1247
1250
  function: {
1248
1251
  ...e.function,
1249
- parsed_arguments: Pe(t) ? t.$parseRaw(e.function.arguments) : t?.function.strict ? JSON.parse(e.function.arguments) : null
1252
+ parsed_arguments: Te(t) ? t.$parseRaw(e.function.arguments) : t?.function.strict ? JSON.parse(e.function.arguments) : null
1250
1253
  }
1251
1254
  };
1252
1255
  }
1253
- function ii(n, e) {
1256
+ function ai(n, e) {
1254
1257
  if (!n || !("tools" in n) || !n.tools)
1255
1258
  return !1;
1256
1259
  const t = n.tools?.find((s) => Ze(s) && s.function?.name === e.function.name);
1257
- return Ze(t) && (Pe(t) || t?.function.strict || !1);
1260
+ return Ze(t) && (Te(t) || t?.function.strict || !1);
1258
1261
  }
1259
1262
  function fn(n) {
1260
- return jt(n.response_format) ? !0 : n.tools?.some((e) => Pe(e) || e.type === "function" && e.function.strict === !0) ?? !1;
1263
+ return jt(n.response_format) ? !0 : n.tools?.some((e) => Te(e) || e.type === "function" && e.function.strict === !0) ?? !1;
1261
1264
  }
1262
1265
  function pn(n) {
1263
1266
  for (const e of n || [])
1264
1267
  if (e.type !== "function")
1265
1268
  throw new g(`Currently only \`function\` tool calls are supported; Received \`${e.type}\``);
1266
1269
  }
1267
- function ai(n) {
1270
+ function oi(n) {
1268
1271
  for (const e of n ?? []) {
1269
1272
  if (e.type !== "function")
1270
1273
  throw new g(`Currently only \`function\` tool types support auto-parsing; Received \`${e.type}\``);
@@ -1273,18 +1276,18 @@ function ai(n) {
1273
1276
  }
1274
1277
  }
1275
1278
  const et = (n) => n?.role === "assistant", mn = (n) => n?.role === "tool";
1276
- var Ot, je, He, be, Se, Je, xe, Z, Ae, tt, st, ue, _n;
1279
+ var Ot, He, Je, be, Se, Xe, xe, Z, Ae, tt, st, ue, _n;
1277
1280
  class Jt {
1278
1281
  constructor() {
1279
- Ot.add(this), this.controller = new AbortController(), je.set(this, void 0), He.set(this, () => {
1282
+ Ot.add(this), this.controller = new AbortController(), He.set(this, void 0), Je.set(this, () => {
1280
1283
  }), be.set(this, () => {
1281
- }), Se.set(this, void 0), Je.set(this, () => {
1284
+ }), Se.set(this, void 0), Xe.set(this, () => {
1282
1285
  }), xe.set(this, () => {
1283
- }), Z.set(this, {}), Ae.set(this, !1), tt.set(this, !1), st.set(this, !1), ue.set(this, !1), S(this, je, new Promise((e, t) => {
1284
- S(this, He, e, "f"), S(this, be, t, "f");
1286
+ }), Z.set(this, {}), Ae.set(this, !1), tt.set(this, !1), st.set(this, !1), ue.set(this, !1), S(this, He, new Promise((e, t) => {
1287
+ S(this, Je, e, "f"), S(this, be, t, "f");
1285
1288
  })), S(this, Se, new Promise((e, t) => {
1286
- S(this, Je, e, "f"), S(this, xe, t, "f");
1287
- })), o(this, je, "f").catch(() => {
1289
+ S(this, Xe, e, "f"), S(this, xe, t, "f");
1290
+ })), o(this, He, "f").catch(() => {
1288
1291
  }), o(this, Se, "f").catch(() => {
1289
1292
  });
1290
1293
  }
@@ -1296,7 +1299,7 @@ class Jt {
1296
1299
  }, 0);
1297
1300
  }
1298
1301
  _connected() {
1299
- this.ended || (o(this, He, "f").call(this), this._emit("connect"));
1302
+ this.ended || (o(this, Je, "f").call(this), this._emit("connect"));
1300
1303
  }
1301
1304
  get ended() {
1302
1305
  return o(this, Ae, "f");
@@ -1364,7 +1367,7 @@ class Jt {
1364
1367
  _emit(e, ...t) {
1365
1368
  if (o(this, Ae, "f"))
1366
1369
  return;
1367
- e === "end" && (S(this, Ae, !0), o(this, Je, "f").call(this));
1370
+ e === "end" && (S(this, Ae, !0), o(this, Xe, "f").call(this));
1368
1371
  const s = o(this, Z, "f")[e];
1369
1372
  if (s && (o(this, Z, "f")[e] = s.filter((r) => !r.once), s.forEach(({ listener: r }) => r(...t))), e === "abort") {
1370
1373
  const r = t[0];
@@ -1379,7 +1382,7 @@ class Jt {
1379
1382
  _emitFinal() {
1380
1383
  }
1381
1384
  }
1382
- je = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), Ae = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakSet(), _n = function(e) {
1385
+ He = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap(), be = /* @__PURE__ */ new WeakMap(), Se = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), xe = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new WeakMap(), Ae = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ue = /* @__PURE__ */ new WeakMap(), Ot = /* @__PURE__ */ new WeakSet(), _n = function(e) {
1383
1386
  if (S(this, tt, !0), e instanceof Error && e.name === "AbortError" && (e = new K()), e instanceof K)
1384
1387
  return S(this, st, !0), this._emit("abort", e);
1385
1388
  if (e instanceof g)
@@ -1390,11 +1393,11 @@ je = /* @__PURE__ */ new WeakMap(), He = /* @__PURE__ */ new WeakMap(), be = /*
1390
1393
  }
1391
1394
  return this._emit("error", new g(String(e)));
1392
1395
  };
1393
- function oi(n) {
1396
+ function li(n) {
1394
1397
  return typeof n.parse == "function";
1395
1398
  }
1396
1399
  var W, Pt, nt, Tt, Nt, Mt, gn, yn;
1397
- const li = 10;
1400
+ const ci = 10;
1398
1401
  class wn extends Jt {
1399
1402
  constructor() {
1400
1403
  super(...arguments), W.add(this), this._chatCompletions = [], this.messages = [];
@@ -1478,8 +1481,8 @@ class wn extends Jt {
1478
1481
  return await this._createChatCompletion(e, t, s);
1479
1482
  }
1480
1483
  async _runTools(e, t, s) {
1481
- const r = "tool", { tool_choice: i = "auto", stream: a, ...l } = t, h = typeof i != "string" && i.type === "function" && i?.function?.name, { maxChatCompletions: f = li } = s || {}, m = t.tools.map((u) => {
1482
- if (Pe(u)) {
1484
+ const r = "tool", { tool_choice: i = "auto", stream: a, ...l } = t, h = typeof i != "string" && i.type === "function" && i?.function?.name, { maxChatCompletions: f = ci } = s || {}, m = t.tools.map((u) => {
1485
+ if (Te(u)) {
1483
1486
  if (!u.$callback)
1484
1487
  throw new g("Tool given to `.runTools()` that does not have an associated function");
1485
1488
  return {
@@ -1537,7 +1540,7 @@ class wn extends Jt {
1537
1540
  }
1538
1541
  let X;
1539
1542
  try {
1540
- X = oi($) ? await $.parse(T) : T;
1543
+ X = li($) ? await $.parse(T) : T;
1541
1544
  } catch (F) {
1542
1545
  const N = F instanceof Error ? F.message : String(F);
1543
1546
  this._addMessage({ role: r, tool_call_id: R, content: N });
@@ -1603,7 +1606,7 @@ class Xt extends wn {
1603
1606
  super._addMessage(e, t), et(e) && e.content && this._emit("content", e.content);
1604
1607
  }
1605
1608
  }
1606
- const bn = 1, Sn = 2, xn = 4, An = 8, Rn = 16, $n = 32, Cn = 64, vn = 128, In = 256, kn = vn | In, En = Rn | $n | kn | Cn, On = bn | Sn | En, Pn = xn | An, ci = On | Pn, M = {
1609
+ const bn = 1, Sn = 2, xn = 4, An = 8, Rn = 16, $n = 32, Cn = 64, vn = 128, In = 256, kn = vn | In, En = Rn | $n | kn | Cn, On = bn | Sn | En, Pn = xn | An, ui = On | Pn, M = {
1607
1610
  STR: bn,
1608
1611
  NUM: Sn,
1609
1612
  ARR: xn,
@@ -1617,26 +1620,26 @@ const bn = 1, Sn = 2, xn = 4, An = 8, Rn = 16, $n = 32, Cn = 64, vn = 128, In =
1617
1620
  SPECIAL: En,
1618
1621
  ATOM: On,
1619
1622
  COLLECTION: Pn,
1620
- ALL: ci
1623
+ ALL: ui
1621
1624
  };
1622
- class ui extends Error {
1623
- }
1624
1625
  class hi extends Error {
1625
1626
  }
1626
- function di(n, e = M.ALL) {
1627
+ class di extends Error {
1628
+ }
1629
+ function fi(n, e = M.ALL) {
1627
1630
  if (typeof n != "string")
1628
1631
  throw new TypeError(`expecting str, got ${typeof n}`);
1629
1632
  if (!n.trim())
1630
1633
  throw new Error(`${n} is empty`);
1631
- return fi(n.trim(), e);
1634
+ return pi(n.trim(), e);
1632
1635
  }
1633
- const fi = (n, e) => {
1636
+ const pi = (n, e) => {
1634
1637
  const t = n.length;
1635
1638
  let s = 0;
1636
1639
  const r = (y) => {
1637
- throw new ui(`${y} at position ${s}`);
1638
- }, i = (y) => {
1639
1640
  throw new hi(`${y} at position ${s}`);
1641
+ }, i = (y) => {
1642
+ throw new di(`${y} at position ${s}`);
1640
1643
  }, a = () => (d(), s >= t && r("Unexpected end of input"), n[s] === '"' ? l() : n[s] === "{" ? h() : n[s] === "[" ? f() : n.substring(s, s + 4) === "null" || M.NULL & e && t - s < 4 && "null".startsWith(n.substring(s)) ? (s += 4, null) : n.substring(s, s + 4) === "true" || M.BOOL & e && t - s < 4 && "true".startsWith(n.substring(s)) ? (s += 4, !0) : n.substring(s, s + 5) === "false" || M.BOOL & e && t - s < 5 && "false".startsWith(n.substring(s)) ? (s += 5, !1) : n.substring(s, s + 8) === "Infinity" || M.INFINITY & e && t - s < 8 && "Infinity".startsWith(n.substring(s)) ? (s += 8, 1 / 0) : n.substring(s, s + 9) === "-Infinity" || M.MINUS_INFINITY & e && 1 < t - s && t - s < 9 && "-Infinity".startsWith(n.substring(s)) ? (s += 9, -1 / 0) : n.substring(s, s + 3) === "NaN" || M.NAN & e && t - s < 3 && "NaN".startsWith(n.substring(s)) ? (s += 3, NaN) : m()), l = () => {
1641
1644
  const y = s;
1642
1645
  let u = !1;
@@ -1726,9 +1729,9 @@ const fi = (n, e) => {
1726
1729
  s++;
1727
1730
  };
1728
1731
  return a();
1729
- }, $s = (n) => di(n, M.ALL ^ M.NUM);
1730
- var O, Y, oe, te, bt, Fe, St, xt, At, Le, Rt, Cs;
1731
- class Ee extends wn {
1732
+ }, $s = (n) => fi(n, M.ALL ^ M.NUM);
1733
+ var O, Y, oe, te, bt, Le, St, xt, At, Be, Rt, Cs;
1734
+ class Oe extends wn {
1732
1735
  constructor(e) {
1733
1736
  super(), O.add(this), Y.set(this, void 0), oe.set(this, void 0), te.set(this, void 0), S(this, Y, e), S(this, oe, []);
1734
1737
  }
@@ -1743,11 +1746,11 @@ class Ee extends wn {
1743
1746
  * in this context.
1744
1747
  */
1745
1748
  static fromReadableStream(e) {
1746
- const t = new Ee(null);
1749
+ const t = new Oe(null);
1747
1750
  return t._run(() => t._fromReadableStream(e)), t;
1748
1751
  }
1749
1752
  static createChatCompletion(e, t, s) {
1750
- const r = new Ee(t);
1753
+ const r = new Oe(t);
1751
1754
  return r._run(() => r._runChatCompletion(e, { ...t, stream: !0 }, { ...s, headers: { ...s?.headers, "X-Stainless-Helper-Method": "stream" } })), r;
1752
1755
  }
1753
1756
  async _createChatCompletion(e, t, s) {
@@ -1760,7 +1763,7 @@ class Ee extends wn {
1760
1763
  o(this, O, "m", St).call(this, a);
1761
1764
  if (i.controller.signal?.aborted)
1762
1765
  throw new K();
1763
- return this._addChatCompletion(o(this, O, "m", Le).call(this));
1766
+ return this._addChatCompletion(o(this, O, "m", Be).call(this));
1764
1767
  }
1765
1768
  async _fromReadableStream(e, t) {
1766
1769
  const s = t?.signal;
@@ -1768,14 +1771,14 @@ class Ee extends wn {
1768
1771
  const r = G.fromReadableStream(e, this.controller);
1769
1772
  let i;
1770
1773
  for await (const a of r)
1771
- i && i !== a.id && this._addChatCompletion(o(this, O, "m", Le).call(this)), o(this, O, "m", St).call(this, a), i = a.id;
1774
+ i && i !== a.id && this._addChatCompletion(o(this, O, "m", Be).call(this)), o(this, O, "m", St).call(this, a), i = a.id;
1772
1775
  if (r.controller.signal?.aborted)
1773
1776
  throw new K();
1774
- return this._addChatCompletion(o(this, O, "m", Le).call(this));
1777
+ return this._addChatCompletion(o(this, O, "m", Be).call(this));
1775
1778
  }
1776
1779
  [(Y = /* @__PURE__ */ new WeakMap(), oe = /* @__PURE__ */ new WeakMap(), te = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakSet(), bt = function() {
1777
1780
  this.ended || S(this, te, void 0);
1778
- }, Fe = function(t) {
1781
+ }, Le = function(t) {
1779
1782
  let s = o(this, oe, "f")[t.index];
1780
1783
  return s || (s = {
1781
1784
  content_done: !1,
@@ -1806,7 +1809,7 @@ class Ee extends wn {
1806
1809
  refusal: r.logprobs?.refusal,
1807
1810
  snapshot: i.logprobs?.refusal ?? []
1808
1811
  });
1809
- const a = o(this, O, "m", Fe).call(this, i);
1812
+ const a = o(this, O, "m", Le).call(this, i);
1810
1813
  i.finish_reason && (o(this, O, "m", At).call(this, i), a.current_tool_call_index != null && o(this, O, "m", xt).call(this, i, a.current_tool_call_index));
1811
1814
  for (const l of r.delta.tool_calls ?? [])
1812
1815
  a.current_tool_call_index !== l.index && (o(this, O, "m", At).call(this, i), a.current_tool_call_index != null && o(this, O, "m", xt).call(this, i, a.current_tool_call_index)), a.current_tool_call_index = l.index;
@@ -1822,7 +1825,7 @@ class Ee extends wn {
1822
1825
  }
1823
1826
  }
1824
1827
  }, xt = function(t, s) {
1825
- if (o(this, O, "m", Fe).call(this, t).done_tool_calls.has(s))
1828
+ if (o(this, O, "m", Le).call(this, t).done_tool_calls.has(s))
1826
1829
  return;
1827
1830
  const i = t.message.tool_calls?.[s];
1828
1831
  if (!i)
@@ -1835,12 +1838,12 @@ class Ee extends wn {
1835
1838
  name: i.function.name,
1836
1839
  index: s,
1837
1840
  arguments: i.function.arguments,
1838
- parsed_arguments: Pe(a) ? a.$parseRaw(i.function.arguments) : a?.function.strict ? JSON.parse(i.function.arguments) : null
1841
+ parsed_arguments: Te(a) ? a.$parseRaw(i.function.arguments) : a?.function.strict ? JSON.parse(i.function.arguments) : null
1839
1842
  });
1840
1843
  } else
1841
1844
  i.type;
1842
1845
  }, At = function(t) {
1843
- const s = o(this, O, "m", Fe).call(this, t);
1846
+ const s = o(this, O, "m", Le).call(this, t);
1844
1847
  if (t.message.content && !s.content_done) {
1845
1848
  s.content_done = !0;
1846
1849
  const r = o(this, O, "m", Rt).call(this);
@@ -1850,13 +1853,13 @@ class Ee extends wn {
1850
1853
  });
1851
1854
  }
1852
1855
  t.message.refusal && !s.refusal_done && (s.refusal_done = !0, this._emit("refusal.done", { refusal: t.message.refusal })), t.logprobs?.content && !s.logprobs_content_done && (s.logprobs_content_done = !0, this._emit("logprobs.content.done", { content: t.logprobs.content })), t.logprobs?.refusal && !s.logprobs_refusal_done && (s.logprobs_refusal_done = !0, this._emit("logprobs.refusal.done", { refusal: t.logprobs.refusal }));
1853
- }, Le = function() {
1856
+ }, Be = function() {
1854
1857
  if (this.ended)
1855
1858
  throw new g("stream has ended, this shouldn't happen");
1856
1859
  const t = o(this, te, "f");
1857
1860
  if (!t)
1858
1861
  throw new g("request ended without sending any chunks");
1859
- return S(this, te, void 0), S(this, oe, []), pi(t, o(this, Y, "f"));
1862
+ return S(this, te, void 0), S(this, oe, []), mi(t, o(this, Y, "f"));
1860
1863
  }, Rt = function() {
1861
1864
  const t = o(this, Y, "f")?.response_format;
1862
1865
  return jt(t) ? t : null;
@@ -1890,7 +1893,7 @@ class Ee extends wn {
1890
1893
  b.message.tool_calls || (b.message.tool_calls = []);
1891
1894
  for (const { index: U, id: v, type: F, function: N, ...k } of $) {
1892
1895
  const E = (a = b.message.tool_calls)[U] ?? (a[U] = {});
1893
- Object.assign(E, k), v && (E.id = v), F && (E.type = F), N && (E.function ?? (E.function = { name: N.name ?? "", arguments: "" })), N?.name && (E.function.name = N.name), N?.arguments && (E.function.arguments += N.arguments, ii(o(this, Y, "f"), E) && (E.function.parsed_arguments = $s(E.function.arguments)));
1896
+ Object.assign(E, k), v && (E.id = v), F && (E.type = F), N && (E.function ?? (E.function = { name: N.name ?? "", arguments: "" })), N?.name && (E.function.name = N.name), N?.arguments && (E.function.arguments += N.arguments, ai(o(this, Y, "f"), E) && (E.function.parsed_arguments = $s(E.function.arguments)));
1894
1897
  }
1895
1898
  }
1896
1899
  }
@@ -1925,7 +1928,7 @@ class Ee extends wn {
1925
1928
  return new G(this[Symbol.asyncIterator].bind(this), this.controller).toReadableStream();
1926
1929
  }
1927
1930
  }
1928
- function pi(n, e) {
1931
+ function mi(n, e) {
1929
1932
  const { id: t, choices: s, created: r, model: i, system_fingerprint: a, ...l } = n, h = {
1930
1933
  ...l,
1931
1934
  id: t,
@@ -1968,16 +1971,16 @@ function pi(n, e) {
1968
1971
  const { function: X, type: U, id: v, ...F } = T, { arguments: N, name: k, ...E } = X || {};
1969
1972
  if (v == null)
1970
1973
  throw new g(`missing choices[${d}].tool_calls[${$}].id
1971
- ${Be(n)}`);
1974
+ ${De(n)}`);
1972
1975
  if (U == null)
1973
1976
  throw new g(`missing choices[${d}].tool_calls[${$}].type
1974
- ${Be(n)}`);
1977
+ ${De(n)}`);
1975
1978
  if (k == null)
1976
1979
  throw new g(`missing choices[${d}].tool_calls[${$}].function.name
1977
- ${Be(n)}`);
1980
+ ${De(n)}`);
1978
1981
  if (N == null)
1979
1982
  throw new g(`missing choices[${d}].tool_calls[${$}].function.arguments
1980
- ${Be(n)}`);
1983
+ ${De(n)}`);
1981
1984
  return { ...F, id: v, type: U, function: { ...E, name: k, arguments: N } };
1982
1985
  })
1983
1986
  }
@@ -1994,12 +1997,12 @@ ${Be(n)}`);
1994
1997
  object: "chat.completion",
1995
1998
  ...a ? { system_fingerprint: a } : {}
1996
1999
  };
1997
- return si(h, e);
2000
+ return ni(h, e);
1998
2001
  }
1999
- function Be(n) {
2002
+ function De(n) {
2000
2003
  return JSON.stringify(n);
2001
2004
  }
2002
- class rt extends Ee {
2005
+ class rt extends Oe {
2003
2006
  static fromReadableStream(e) {
2004
2007
  const t = new rt(null);
2005
2008
  return t._run(() => t._fromReadableStream(e)), t;
@@ -2080,7 +2083,7 @@ let Kt = class extends _ {
2080
2083
  return this._client.delete(c`/chat/completions/${e}`, t);
2081
2084
  }
2082
2085
  parse(e, t) {
2083
- return ai(e.tools), this._client.chat.completions.create(e, {
2086
+ return oi(e.tools), this._client.chat.completions.create(e, {
2084
2087
  ...t,
2085
2088
  headers: {
2086
2089
  ...t?.headers,
@@ -2095,7 +2098,7 @@ let Kt = class extends _ {
2095
2098
  * Creates a chat completion stream
2096
2099
  */
2097
2100
  stream(e, t) {
2098
- return Ee.createChatCompletion(this._client, e, t);
2101
+ return Oe.createChatCompletion(this._client, e, t);
2099
2102
  }
2100
2103
  };
2101
2104
  Kt.Messages = dn;
@@ -2106,7 +2109,7 @@ class Vt extends _ {
2106
2109
  }
2107
2110
  Vt.Completions = Kt;
2108
2111
  const Tn = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
2109
- function* mi(n) {
2112
+ function* _i(n) {
2110
2113
  if (!n)
2111
2114
  return;
2112
2115
  if (Tn in n) {
@@ -2132,7 +2135,7 @@ const p = (n) => {
2132
2135
  const e = new Headers(), t = /* @__PURE__ */ new Set();
2133
2136
  for (const s of n) {
2134
2137
  const r = /* @__PURE__ */ new Set();
2135
- for (const [i, a] of mi(s)) {
2138
+ for (const [i, a] of _i(s)) {
2136
2139
  const l = i.toLowerCase();
2137
2140
  r.has(l) || (e.delete(i), r.add(l)), a === null ? (e.delete(i), t.add(l)) : (e.append(i, a), t.delete(l));
2138
2141
  }
@@ -2181,14 +2184,14 @@ class Fn extends _ {
2181
2184
  return this._client.post("/audio/translations", fe({ body: e, ...t, __metadata: { model: e.model } }, this._client));
2182
2185
  }
2183
2186
  }
2184
- class Te extends _ {
2187
+ class Ne extends _ {
2185
2188
  constructor() {
2186
2189
  super(...arguments), this.transcriptions = new Mn(this._client), this.translations = new Fn(this._client), this.speech = new Nn(this._client);
2187
2190
  }
2188
2191
  }
2189
- Te.Transcriptions = Mn;
2190
- Te.Translations = Fn;
2191
- Te.Speech = Nn;
2192
+ Ne.Transcriptions = Mn;
2193
+ Ne.Translations = Fn;
2194
+ Ne.Speech = Nn;
2192
2195
  class Ln extends _ {
2193
2196
  /**
2194
2197
  * Creates and executes a batch from an uploaded file of requests
@@ -2398,7 +2401,7 @@ let qn = class extends _ {
2398
2401
  * ```
2399
2402
  */
2400
2403
  list(e = {}, t) {
2401
- return this._client.getAPIList("/chatkit/threads", Ye, {
2404
+ return this._client.getAPIList("/chatkit/threads", ke, {
2402
2405
  query: e,
2403
2406
  ...t,
2404
2407
  headers: p([{ "OpenAI-Beta": "chatkit_beta=v1" }, t?.headers])
@@ -2434,7 +2437,7 @@ let qn = class extends _ {
2434
2437
  * ```
2435
2438
  */
2436
2439
  listItems(e, t = {}, s) {
2437
- return this._client.getAPIList(c`/chatkit/threads/${e}/items`, Ye, { query: t, ...s, headers: p([{ "OpenAI-Beta": "chatkit_beta=v1" }, s?.headers]) });
2440
+ return this._client.getAPIList(c`/chatkit/threads/${e}/items`, ke, { query: t, ...s, headers: p([{ "OpenAI-Beta": "chatkit_beta=v1" }, s?.headers]) });
2438
2441
  }
2439
2442
  };
2440
2443
  class ht extends _ {
@@ -2535,7 +2538,7 @@ class Hn extends _ {
2535
2538
  });
2536
2539
  }
2537
2540
  }
2538
- const _i = (n) => {
2541
+ const gi = (n) => {
2539
2542
  if (typeof Buffer < "u") {
2540
2543
  const e = Buffer.from(n, "base64");
2541
2544
  return Array.from(new Float32Array(e.buffer, e.byteOffset, e.length / Float32Array.BYTES_PER_ELEMENT));
@@ -2551,12 +2554,12 @@ const _i = (n) => {
2551
2554
  if (typeof globalThis.Deno < "u")
2552
2555
  return globalThis.Deno.env?.get?.(n)?.trim();
2553
2556
  };
2554
- var B, ie, Ft, Q, Xe, V, ae, de, re, it, J, Ke, Ve, ve, Re, $e, vs, Is, ks, Es, Os, Ps, Ts;
2557
+ var B, ie, Ft, Q, Ke, V, ae, de, re, it, J, Ve, ze, ve, Re, $e, vs, Is, ks, Es, Os, Ps, Ts;
2555
2558
  class Ie extends Jt {
2556
2559
  constructor() {
2557
- super(...arguments), B.add(this), Ft.set(this, []), Q.set(this, {}), Xe.set(this, {}), V.set(this, void 0), ae.set(this, void 0), de.set(this, void 0), re.set(this, void 0), it.set(this, void 0), J.set(this, void 0), Ke.set(this, void 0), Ve.set(this, void 0), ve.set(this, void 0);
2560
+ super(...arguments), B.add(this), Ft.set(this, []), Q.set(this, {}), Ke.set(this, {}), V.set(this, void 0), ae.set(this, void 0), de.set(this, void 0), re.set(this, void 0), it.set(this, void 0), J.set(this, void 0), Ve.set(this, void 0), ze.set(this, void 0), ve.set(this, void 0);
2558
2561
  }
2559
- [(Ft = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), Xe = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap(), ve = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakSet(), Symbol.asyncIterator)]() {
2562
+ [(Ft = /* @__PURE__ */ new WeakMap(), Q = /* @__PURE__ */ new WeakMap(), Ke = /* @__PURE__ */ new WeakMap(), V = /* @__PURE__ */ new WeakMap(), ae = /* @__PURE__ */ new WeakMap(), de = /* @__PURE__ */ new WeakMap(), re = /* @__PURE__ */ new WeakMap(), it = /* @__PURE__ */ new WeakMap(), J = /* @__PURE__ */ new WeakMap(), Ve = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), ve = /* @__PURE__ */ new WeakMap(), B = /* @__PURE__ */ new WeakSet(), Symbol.asyncIterator)]() {
2560
2563
  const e = [], t = [];
2561
2564
  let s = !1;
2562
2565
  return this.on("event", (r) => {
@@ -2635,10 +2638,10 @@ class Ie extends Jt {
2635
2638
  })), i;
2636
2639
  }
2637
2640
  currentEvent() {
2638
- return o(this, Ke, "f");
2641
+ return o(this, Ve, "f");
2639
2642
  }
2640
2643
  currentRun() {
2641
- return o(this, Ve, "f");
2644
+ return o(this, ze, "f");
2642
2645
  }
2643
2646
  currentMessageSnapshot() {
2644
2647
  return o(this, V, "f");
@@ -2650,7 +2653,7 @@ class Ie extends Jt {
2650
2653
  return await this.done(), Object.values(o(this, Q, "f"));
2651
2654
  }
2652
2655
  async finalMessages() {
2653
- return await this.done(), Object.values(o(this, Xe, "f"));
2656
+ return await this.done(), Object.values(o(this, Ke, "f"));
2654
2657
  }
2655
2658
  async finalRun() {
2656
2659
  if (await this.done(), !o(this, ae, "f"))
@@ -2698,7 +2701,7 @@ class Ie extends Jt {
2698
2701
  i += r;
2699
2702
  else if (typeof i == "number" && typeof r == "number")
2700
2703
  i += r;
2701
- else if (We(i) && We(r))
2704
+ else if (qe(i) && qe(r))
2702
2705
  i = this.accumulateDelta(i, r);
2703
2706
  else if (Array.isArray(i) && Array.isArray(r)) {
2704
2707
  if (i.every((a) => typeof a == "string" || typeof a == "number")) {
@@ -2706,7 +2709,7 @@ class Ie extends Jt {
2706
2709
  continue;
2707
2710
  }
2708
2711
  for (const a of r) {
2709
- if (!We(a))
2712
+ if (!qe(a))
2710
2713
  throw new Error(`Expected array delta entry to be an object but got: ${a}`);
2711
2714
  const l = a.index;
2712
2715
  if (l == null)
@@ -2738,7 +2741,7 @@ class Ie extends Jt {
2738
2741
  }
2739
2742
  ie = Ie, Re = function(e) {
2740
2743
  if (!this.ended)
2741
- switch (S(this, Ke, e), o(this, B, "m", ks).call(this, e), e.event) {
2744
+ switch (S(this, Ve, e), o(this, B, "m", ks).call(this, e), e.event) {
2742
2745
  case "thread.created":
2743
2746
  break;
2744
2747
  case "thread.run.created":
@@ -2780,7 +2783,7 @@ ie = Ie, Re = function(e) {
2780
2783
  return o(this, ae, "f");
2781
2784
  }, vs = function(e) {
2782
2785
  const [t, s] = o(this, B, "m", Os).call(this, e, o(this, V, "f"));
2783
- S(this, V, t), o(this, Xe, "f")[t.id] = t;
2786
+ S(this, V, t), o(this, Ke, "f")[t.id] = t;
2784
2787
  for (const r of s) {
2785
2788
  const i = t.content[r.index];
2786
2789
  i?.type == "text" && this._emit("textCreated", i.text);
@@ -2907,7 +2910,7 @@ ie = Ie, Re = function(e) {
2907
2910
  }, Ps = function(e, t) {
2908
2911
  return ie.accumulateDelta(t, e);
2909
2912
  }, Ts = function(e) {
2910
- switch (S(this, Ve, e.data), e.event) {
2913
+ switch (S(this, ze, e.data), e.event) {
2911
2914
  case "thread.run.created":
2912
2915
  break;
2913
2916
  case "thread.run.queued":
@@ -3038,7 +3041,7 @@ let zt = class extends _ {
3038
3041
  isNaN(f) || (l = f);
3039
3042
  }
3040
3043
  }
3041
- await Oe(l);
3044
+ await Pe(l);
3042
3045
  break;
3043
3046
  //We return the run in any terminal state.
3044
3047
  case "requires_action":
@@ -3200,7 +3203,7 @@ let Xn = class extends _ {
3200
3203
  * a JSON request with a file ID.
3201
3204
  */
3202
3205
  create(e, t, s) {
3203
- return this._client.post(c`/containers/${e}/files`, ke({ body: t, ...s }, this._client));
3206
+ return this._client.post(c`/containers/${e}/files`, Ee({ body: t, ...s }, this._client));
3204
3207
  }
3205
3208
  /**
3206
3209
  * Retrieve Container File
@@ -3286,7 +3289,7 @@ class Kn extends _ {
3286
3289
  * List all items for a conversation with the given ID.
3287
3290
  */
3288
3291
  list(e, t = {}, s) {
3289
- return this._client.getAPIList(c`/conversations/${e}/items`, Ye, { query: t, ...s });
3292
+ return this._client.getAPIList(c`/conversations/${e}/items`, ke, { query: t, ...s });
3290
3293
  }
3291
3294
  /**
3292
3295
  * Delete an item from a conversation with the given IDs.
@@ -3352,7 +3355,7 @@ class Vn extends _ {
3352
3355
  });
3353
3356
  return s ? i : (L(this._client).debug("embeddings/decoding base64 embeddings from base64"), i._thenUnwrap((a) => (a && a.data && a.data.forEach((l) => {
3354
3357
  const h = l.embedding;
3355
- l.embedding = _i(h);
3358
+ l.embedding = gi(h);
3356
3359
  }), a)));
3357
3360
  }
3358
3361
  }
@@ -3518,7 +3521,7 @@ let Qn = class extends _ {
3518
3521
  const r = /* @__PURE__ */ new Set(["processed", "error", "deleted"]), i = Date.now();
3519
3522
  let a = await this.retrieve(e);
3520
3523
  for (; !a.status || !r.has(a.status); )
3521
- if (await Oe(t), a = await this.retrieve(e), Date.now() - i > s)
3524
+ if (await Pe(t), a = await this.retrieve(e), Date.now() - i > s)
3522
3525
  throw new Dt({
3523
3526
  message: `Giving up on waiting for file ${e} to finish processing after ${s} milliseconds.`
3524
3527
  });
@@ -3602,13 +3605,7 @@ class Zn extends _ {
3602
3605
  * Organization owners can use this endpoint to view all permissions for a
3603
3606
  * fine-tuned model checkpoint.
3604
3607
  *
3605
- * @example
3606
- * ```ts
3607
- * const permission =
3608
- * await client.fineTuning.checkpoints.permissions.retrieve(
3609
- * 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
3610
- * );
3611
- * ```
3608
+ * @deprecated Retrieve is deprecated. Please swap to the paginated list method instead.
3612
3609
  */
3613
3610
  retrieve(e, t = {}, s) {
3614
3611
  return this._client.get(c`/fine_tuning/checkpoints/${e}/permissions`, {
@@ -3616,6 +3613,25 @@ class Zn extends _ {
3616
3613
  ...s
3617
3614
  });
3618
3615
  }
3616
+ /**
3617
+ * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
3618
+ *
3619
+ * Organization owners can use this endpoint to view all permissions for a
3620
+ * fine-tuned model checkpoint.
3621
+ *
3622
+ * @example
3623
+ * ```ts
3624
+ * // Automatically fetches more pages as needed.
3625
+ * for await (const permissionListResponse of client.fineTuning.checkpoints.permissions.list(
3626
+ * 'ft-AF1WoRqd3aJAHsqc9NY7iL8F',
3627
+ * )) {
3628
+ * // ...
3629
+ * }
3630
+ * ```
3631
+ */
3632
+ list(e, t = {}, s) {
3633
+ return this._client.getAPIList(c`/fine_tuning/checkpoints/${e}/permissions`, ke, { query: t, ...s });
3634
+ }
3619
3635
  /**
3620
3636
  * **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
3621
3637
  *
@@ -3944,8 +3960,8 @@ class ft extends _ {
3944
3960
  }
3945
3961
  ft.ClientSecrets = ar;
3946
3962
  ft.Calls = ir;
3947
- function gi(n, e) {
3948
- return !e || !wi(e) ? {
3963
+ function yi(n, e) {
3964
+ return !e || !bi(e) ? {
3949
3965
  ...n,
3950
3966
  output_parsed: null,
3951
3967
  output: n.output.map((t) => t.type === "function_call" ? {
@@ -3965,12 +3981,12 @@ function or(n, e) {
3965
3981
  if (r.type === "function_call")
3966
3982
  return {
3967
3983
  ...r,
3968
- parsed_arguments: xi(e, r)
3984
+ parsed_arguments: Ai(e, r)
3969
3985
  };
3970
3986
  if (r.type === "message") {
3971
3987
  const i = r.content.map((a) => a.type === "output_text" ? {
3972
3988
  ...a,
3973
- parsed: yi(e, a.text)
3989
+ parsed: wi(e, a.text)
3974
3990
  } : a);
3975
3991
  return {
3976
3992
  ...r,
@@ -3992,24 +4008,24 @@ function or(n, e) {
3992
4008
  }
3993
4009
  }), s;
3994
4010
  }
3995
- function yi(n, e) {
4011
+ function wi(n, e) {
3996
4012
  return n.text?.format?.type !== "json_schema" ? null : "$parseRaw" in n.text?.format ? (n.text?.format).$parseRaw(e) : JSON.parse(e);
3997
4013
  }
3998
- function wi(n) {
4014
+ function bi(n) {
3999
4015
  return !!jt(n.text?.format);
4000
4016
  }
4001
- function bi(n) {
4017
+ function Si(n) {
4002
4018
  return n?.$brand === "auto-parseable-tool";
4003
4019
  }
4004
- function Si(n, e) {
4020
+ function xi(n, e) {
4005
4021
  return n.find((t) => t.type === "function" && t.name === e);
4006
4022
  }
4007
- function xi(n, e) {
4008
- const t = Si(n.tools ?? [], e.name);
4023
+ function Ai(n, e) {
4024
+ const t = xi(n.tools ?? [], e.name);
4009
4025
  return {
4010
4026
  ...e,
4011
4027
  ...e,
4012
- parsed_arguments: bi(t) ? t.$parseRaw(e.arguments) : t?.strict ? JSON.parse(e.arguments) : null
4028
+ parsed_arguments: Si(t) ? t.$parseRaw(e.arguments) : t?.strict ? JSON.parse(e.arguments) : null
4013
4029
  };
4014
4030
  }
4015
4031
  function Lt(n) {
@@ -4020,10 +4036,10 @@ function Lt(n) {
4020
4036
  s.type === "output_text" && e.push(s.text);
4021
4037
  n.output_text = e.join("");
4022
4038
  }
4023
- var le, De, se, Ue, Ns, Ms, Fs, Ls;
4039
+ var le, Ue, se, We, Ns, Ms, Fs, Ls;
4024
4040
  class is extends Jt {
4025
4041
  constructor(e) {
4026
- super(), le.add(this), De.set(this, void 0), se.set(this, void 0), Ue.set(this, void 0), S(this, De, e);
4042
+ super(), le.add(this), Ue.set(this, void 0), se.set(this, void 0), We.set(this, void 0), S(this, Ue, e);
4027
4043
  }
4028
4044
  static createResponse(e, t, s) {
4029
4045
  const r = new is(t);
@@ -4043,7 +4059,7 @@ class is extends Jt {
4043
4059
  throw new K();
4044
4060
  return o(this, le, "m", Fs).call(this);
4045
4061
  }
4046
- [(De = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakSet(), Ns = function() {
4062
+ [(Ue = /* @__PURE__ */ new WeakMap(), se = /* @__PURE__ */ new WeakMap(), We = /* @__PURE__ */ new WeakMap(), le = /* @__PURE__ */ new WeakSet(), Ns = function() {
4047
4063
  this.ended || S(this, se, void 0);
4048
4064
  }, Ms = function(t, s) {
4049
4065
  if (this.ended)
@@ -4090,8 +4106,8 @@ class is extends Jt {
4090
4106
  if (!t)
4091
4107
  throw new g("request ended without sending any events");
4092
4108
  S(this, se, void 0);
4093
- const s = Ai(t, o(this, De, "f"));
4094
- return S(this, Ue, s), s;
4109
+ const s = Ri(t, o(this, Ue, "f"));
4110
+ return S(this, We, s), s;
4095
4111
  }, Ls = function(t) {
4096
4112
  let s = o(this, se, "f");
4097
4113
  if (!s) {
@@ -4185,14 +4201,14 @@ class is extends Jt {
4185
4201
  */
4186
4202
  async finalResponse() {
4187
4203
  await this.done();
4188
- const e = o(this, Ue, "f");
4204
+ const e = o(this, We, "f");
4189
4205
  if (!e)
4190
4206
  throw new g("stream ended without producing a ChatCompletion");
4191
4207
  return e;
4192
4208
  }
4193
4209
  }
4194
- function Ai(n, e) {
4195
- return gi(n, e);
4210
+ function Ri(n, e) {
4211
+ return yi(n, e);
4196
4212
  }
4197
4213
  class lr extends _ {
4198
4214
  /**
@@ -4293,7 +4309,7 @@ class pt extends _ {
4293
4309
  * @example
4294
4310
  * ```ts
4295
4311
  * const compactedResponse = await client.responses.compact({
4296
- * model: 'gpt-5.2',
4312
+ * model: 'gpt-5.4',
4297
4313
  * });
4298
4314
  * ```
4299
4315
  */
@@ -4336,7 +4352,7 @@ class as extends _ {
4336
4352
  * Create a new immutable skill version.
4337
4353
  */
4338
4354
  create(e, t = {}, s) {
4339
- return this._client.post(c`/skills/${e}/versions`, ke({ body: t, ...s }, this._client));
4355
+ return this._client.post(c`/skills/${e}/versions`, Ee({ body: t, ...s }, this._client));
4340
4356
  }
4341
4357
  /**
4342
4358
  * Get a specific skill version.
@@ -4371,7 +4387,7 @@ class mt extends _ {
4371
4387
  * Create a new skill.
4372
4388
  */
4373
4389
  create(e = {}, t) {
4374
- return this._client.post("/skills", ke({ body: e, ...t }, this._client));
4390
+ return this._client.post("/skills", Ee({ body: e, ...t }, this._client));
4375
4391
  }
4376
4392
  /**
4377
4393
  * Get a skill by its ID.
@@ -4478,7 +4494,7 @@ class os extends _ {
4478
4494
  }
4479
4495
  }
4480
4496
  os.Parts = dr;
4481
- const Ri = async (n) => {
4497
+ const $i = async (n) => {
4482
4498
  const e = await Promise.allSettled(n), t = e.filter((r) => r.status === "rejected");
4483
4499
  if (t.length) {
4484
4500
  for (const r of t)
@@ -4567,7 +4583,7 @@ class fr extends _ {
4567
4583
  isNaN(f) || (l = f);
4568
4584
  }
4569
4585
  }
4570
- await Oe(l);
4586
+ await Pe(l);
4571
4587
  break;
4572
4588
  case "failed":
4573
4589
  case "cancelled":
@@ -4592,7 +4608,7 @@ class fr extends _ {
4592
4608
  }
4593
4609
  }
4594
4610
  const d = Array(a).fill(h).map(m);
4595
- return await Ri(d), await this.createAndPoll(e, {
4611
+ return await $i(d), await this.createAndPoll(e, {
4596
4612
  file_ids: f
4597
4613
  });
4598
4614
  }
@@ -4691,7 +4707,7 @@ class pr extends _ {
4691
4707
  isNaN(f) || (l = f);
4692
4708
  }
4693
4709
  }
4694
- await Oe(l);
4710
+ await Pe(l);
4695
4711
  break;
4696
4712
  case "failed":
4697
4713
  case "completed":
@@ -4796,7 +4812,7 @@ class mr extends _ {
4796
4812
  * Create a new video generation job from a prompt and optional reference assets.
4797
4813
  */
4798
4814
  create(e, t) {
4799
- return this._client.post("/videos", ke({ body: e, ...t }, this._client));
4815
+ return this._client.post("/videos", Ee({ body: e, ...t }, this._client));
4800
4816
  }
4801
4817
  /**
4802
4818
  * Fetch the latest metadata for a generated video.
@@ -4808,7 +4824,7 @@ class mr extends _ {
4808
4824
  * List recently generated videos for the current project.
4809
4825
  */
4810
4826
  list(e = {}, t) {
4811
- return this._client.getAPIList("/videos", Ye, { query: e, ...t });
4827
+ return this._client.getAPIList("/videos", ke, { query: e, ...t });
4812
4828
  }
4813
4829
  /**
4814
4830
  * Permanently delete a completed or failed video and its stored assets.
@@ -4833,10 +4849,10 @@ class mr extends _ {
4833
4849
  * Create a remix of a completed video using a refreshed prompt.
4834
4850
  */
4835
4851
  remix(e, t, s) {
4836
- return this._client.post(c`/videos/${e}/remix`, ke({ body: t, ...s }, this._client));
4852
+ return this._client.post(c`/videos/${e}/remix`, Ee({ body: t, ...s }, this._client));
4837
4853
  }
4838
4854
  }
4839
- var he, _r, ze;
4855
+ var he, _r, Qe;
4840
4856
  class gr extends _ {
4841
4857
  constructor() {
4842
4858
  super(...arguments), he.add(this);
@@ -4861,7 +4877,7 @@ class gr extends _ {
4861
4877
  if (typeof crypto > "u" || typeof crypto.subtle.importKey != "function" || typeof crypto.subtle.verify != "function")
4862
4878
  throw new Error("Webhook signature verification is only supported when the `crypto` global is defined");
4863
4879
  o(this, he, "m", _r).call(this, s);
4864
- const i = p([t]).values, a = o(this, he, "m", ze).call(this, i, "webhook-signature"), l = o(this, he, "m", ze).call(this, i, "webhook-timestamp"), h = o(this, he, "m", ze).call(this, i, "webhook-id"), f = parseInt(l, 10);
4880
+ const i = p([t]).values, a = o(this, he, "m", Qe).call(this, i, "webhook-signature"), l = o(this, he, "m", Qe).call(this, i, "webhook-timestamp"), h = o(this, he, "m", Qe).call(this, i, "webhook-id"), f = parseInt(l, 10);
4865
4881
  if (isNaN(f))
4866
4882
  throw new ge("Invalid webhook timestamp format");
4867
4883
  const m = Math.floor(Date.now() / 1e3);
@@ -4884,7 +4900,7 @@ class gr extends _ {
4884
4900
  he = /* @__PURE__ */ new WeakSet(), _r = function(e) {
4885
4901
  if (typeof e != "string" || e.length === 0)
4886
4902
  throw new Error("The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, on the client class, OpenAI({ webhookSecret: '123' }), or passed to this function");
4887
- }, ze = function(e, t) {
4903
+ }, Qe = function(e, t) {
4888
4904
  if (!e)
4889
4905
  throw new Error("Headers are required");
4890
4906
  const s = e.get(t);
@@ -4892,7 +4908,7 @@ he = /* @__PURE__ */ new WeakSet(), _r = function(e) {
4892
4908
  throw new Error(`Missing required header: ${t}`);
4893
4909
  return s;
4894
4910
  };
4895
- var Bt, ls, Qe, yr;
4911
+ var Bt, ls, Ge, yr;
4896
4912
  class x {
4897
4913
  /**
4898
4914
  * API Client for interfacing with the OpenAI API.
@@ -4911,7 +4927,7 @@ class x {
4911
4927
  * @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
4912
4928
  */
4913
4929
  constructor({ baseURL: e = ee("OPENAI_BASE_URL"), apiKey: t = ee("OPENAI_API_KEY"), organization: s = ee("OPENAI_ORG_ID") ?? null, project: r = ee("OPENAI_PROJECT_ID") ?? null, webhookSecret: i = ee("OPENAI_WEBHOOK_SECRET") ?? null, ...a } = {}) {
4914
- if (Bt.add(this), Qe.set(this, void 0), this.completions = new Jn(this), this.chat = new Vt(this), this.embeddings = new Vn(this), this.files = new Qn(this), this.images = new sr(this), this.audio = new Te(this), this.moderations = new rr(this), this.models = new nr(this), this.fineTuning = new me(this), this.graders = new rs(this), this.vectorStores = new _t(this), this.webhooks = new gr(this), this.beta = new pe(this), this.batches = new Ln(this), this.uploads = new os(this), this.responses = new pt(this), this.realtime = new ft(this), this.conversations = new Yt(this), this.evals = new es(this), this.containers = new Gt(this), this.skills = new mt(this), this.videos = new mr(this), t === void 0)
4930
+ if (Bt.add(this), Ge.set(this, void 0), this.completions = new Jn(this), this.chat = new Vt(this), this.embeddings = new Vn(this), this.files = new Qn(this), this.images = new sr(this), this.audio = new Ne(this), this.moderations = new rr(this), this.models = new nr(this), this.fineTuning = new me(this), this.graders = new rs(this), this.vectorStores = new _t(this), this.webhooks = new gr(this), this.beta = new pe(this), this.batches = new Ln(this), this.uploads = new os(this), this.responses = new pt(this), this.realtime = new ft(this), this.conversations = new Yt(this), this.evals = new es(this), this.containers = new Gt(this), this.skills = new mt(this), this.videos = new mr(this), t === void 0)
4915
4931
  throw new g("Missing credentials. Please pass an `apiKey`, or set the `OPENAI_API_KEY` environment variable.");
4916
4932
  const l = {
4917
4933
  apiKey: t,
@@ -4934,7 +4950,7 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
4934
4950
  `);
4935
4951
  this.baseURL = l.baseURL, this.timeout = l.timeout ?? ls.DEFAULT_TIMEOUT, this.logger = l.logger ?? console;
4936
4952
  const h = "warn";
4937
- this.logLevel = h, this.logLevel = Ss(l.logLevel, "ClientOptions.logLevel", this) ?? Ss(ee("OPENAI_LOG"), "process.env['OPENAI_LOG']", this) ?? h, this.fetchOptions = l.fetchOptions, this.maxRetries = l.maxRetries ?? 2, this.fetch = l.fetch ?? Or(), S(this, Qe, Tr), this._options = l, this.apiKey = typeof t == "string" ? t : "Missing Key", this.organization = s, this.project = r, this.webhookSecret = i;
4953
+ this.logLevel = h, this.logLevel = Ss(l.logLevel, "ClientOptions.logLevel", this) ?? Ss(ee("OPENAI_LOG"), "process.env['OPENAI_LOG']", this) ?? h, this.fetchOptions = l.fetchOptions, this.maxRetries = l.maxRetries ?? 2, this.fetch = l.fetch ?? Or(), S(this, Ge, Tr), this._options = l, this.apiKey = typeof t == "string" ? t : "Missing Key", this.organization = s, this.project = r, this.webhookSecret = i;
4938
4954
  }
4939
4955
  /**
4940
4956
  * Create a new client instance re-using the same options given to the current client with optional overriding.
@@ -4965,7 +4981,7 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
4965
4981
  return p([{ Authorization: `Bearer ${this.apiKey}` }]);
4966
4982
  }
4967
4983
  stringifyQuery(e) {
4968
- return Dr(e, { arrayFormat: "brackets" });
4984
+ return Ur(e);
4969
4985
  }
4970
4986
  getUserAgent() {
4971
4987
  return `${this.constructor.name}/JS ${ce}`;
@@ -5107,7 +5123,7 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5107
5123
  }
5108
5124
  requestAPIList(e, t) {
5109
5125
  const s = this.makeRequest(t, null, void 0);
5110
- return new Vr(this, s, e);
5126
+ return new zr(this, s, e);
5111
5127
  }
5112
5128
  async fetchWithTimeout(e, t, s, r) {
5113
5129
  const { signal: i, method: a, ...l } = t || {}, h = this._makeAbort(r);
@@ -5141,11 +5157,11 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5141
5157
  const h = parseFloat(l);
5142
5158
  Number.isNaN(h) ? i = Date.parse(l) - Date.now() : i = h * 1e3;
5143
5159
  }
5144
- if (!(i && 0 <= i && i < 60 * 1e3)) {
5160
+ if (i === void 0) {
5145
5161
  const h = e.maxRetries ?? this.maxRetries;
5146
5162
  i = this.calculateDefaultRetryTimeoutMillis(t, h);
5147
5163
  }
5148
- return await Oe(i), this.makeRequest(e, t - 1, s);
5164
+ return await Pe(i), this.makeRequest(e, t - 1, s);
5149
5165
  }
5150
5166
  calculateDefaultRetryTimeoutMillis(e, t) {
5151
5167
  const i = t - e, a = Math.min(0.5 * Math.pow(2, i), 8), l = 1 - Math.random() * 0.25;
@@ -5203,11 +5219,11 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
5203
5219
  globalThis.ReadableStream && e instanceof globalThis.ReadableStream ? { bodyHeaders: void 0, body: e } : typeof e == "object" && (Symbol.asyncIterator in e || Symbol.iterator in e && "next" in e && typeof e.next == "function") ? { bodyHeaders: void 0, body: Gs(e) } : typeof e == "object" && s.values.get("content-type") === "application/x-www-form-urlencoded" ? {
5204
5220
  bodyHeaders: { "content-type": "application/x-www-form-urlencoded" },
5205
5221
  body: this.stringifyQuery(e)
5206
- } : o(this, Qe, "f").call(this, { body: e, headers: s })
5222
+ } : o(this, Ge, "f").call(this, { body: e, headers: s })
5207
5223
  );
5208
5224
  }
5209
5225
  }
5210
- ls = x, Qe = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ new WeakSet(), yr = function() {
5226
+ ls = x, Ge = /* @__PURE__ */ new WeakMap(), Bt = /* @__PURE__ */ new WeakSet(), yr = function() {
5211
5227
  return this.baseURL !== "https://api.openai.com/v1";
5212
5228
  };
5213
5229
  x.OpenAI = ls;
@@ -5226,13 +5242,13 @@ x.InternalServerError = Xs;
5226
5242
  x.PermissionDeniedError = Ws;
5227
5243
  x.UnprocessableEntityError = Hs;
5228
5244
  x.InvalidWebhookSignatureError = ge;
5229
- x.toFile = Zr;
5245
+ x.toFile = ei;
5230
5246
  x.Completions = Jn;
5231
5247
  x.Chat = Vt;
5232
5248
  x.Embeddings = Vn;
5233
5249
  x.Files = Qn;
5234
5250
  x.Images = sr;
5235
- x.Audio = Te;
5251
+ x.Audio = Ne;
5236
5252
  x.Moderations = rr;
5237
5253
  x.Models = nr;
5238
5254
  x.FineTuning = me;
@@ -5249,7 +5265,7 @@ x.Evals = es;
5249
5265
  x.Containers = Gt;
5250
5266
  x.Skills = mt;
5251
5267
  x.Videos = mr;
5252
- class Bi extends x {
5268
+ class Di extends x {
5253
5269
  /**
5254
5270
  * API Client for interfacing with the Azure OpenAI API.
5255
5271
  *
@@ -5290,8 +5306,8 @@ class Bi extends x {
5290
5306
  }), this.apiVersion = "", this.apiVersion = s, this.deploymentName = i;
5291
5307
  }
5292
5308
  async buildRequest(e, t = {}) {
5293
- if ($i.has(e.path) && e.method === "post" && e.body !== void 0) {
5294
- if (!We(e.body))
5309
+ if (Ci.has(e.path) && e.method === "post" && e.body !== void 0) {
5310
+ if (!qe(e.body))
5295
5311
  throw new Error("Expected request body to be an object");
5296
5312
  const s = this.deploymentName || e.body.model || e.__metadata?.model;
5297
5313
  s !== void 0 && !this.baseURL.includes("/deployments") && (e.path = `/deployments/${s}${e.path}`);
@@ -5302,7 +5318,7 @@ class Bi extends x {
5302
5318
  return typeof this._options.apiKey == "string" ? p([{ "api-key": this.apiKey }]) : super.authHeaders(e);
5303
5319
  }
5304
5320
  }
5305
- const $i = /* @__PURE__ */ new Set([
5321
+ const Ci = /* @__PURE__ */ new Set([
5306
5322
  "/completions",
5307
5323
  "/chat/completions",
5308
5324
  "/embeddings",
@@ -5320,7 +5336,7 @@ export {
5320
5336
  lt as APIPromise,
5321
5337
  K as APIUserAbortError,
5322
5338
  Us as AuthenticationError,
5323
- Bi as AzureOpenAI,
5339
+ Di as AzureOpenAI,
5324
5340
  Ds as BadRequestError,
5325
5341
  js as ConflictError,
5326
5342
  Xs as InternalServerError,
@@ -5328,10 +5344,10 @@ export {
5328
5344
  qs as NotFoundError,
5329
5345
  x as OpenAI,
5330
5346
  g as OpenAIError,
5331
- Vr as PagePromise,
5347
+ zr as PagePromise,
5332
5348
  Ws as PermissionDeniedError,
5333
5349
  Js as RateLimitError,
5334
5350
  Hs as UnprocessableEntityError,
5335
5351
  x as default,
5336
- Zr as toFile
5352
+ ei as toFile
5337
5353
  };