@polka-codes/cli-shared 0.7.18 → 0.7.20

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 (2) hide show
  1. package/dist/index.js +1039 -480
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -18999,7 +18999,7 @@ var require_cli_width = __commonJS((exports, module2) => {
18999
18999
  }
19000
19000
  });
19001
19001
 
19002
- // ../../node_modules/@inquirer/core/node_modules/strip-ansi/node_modules/ansi-regex/index.js
19002
+ // ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/index.js
19003
19003
  var require_ansi_regex = __commonJS((exports, module2) => {
19004
19004
  module2.exports = ({ onlyFirst = false } = {}) => {
19005
19005
  const pattern = [
@@ -19010,13 +19010,13 @@ var require_ansi_regex = __commonJS((exports, module2) => {
19010
19010
  };
19011
19011
  });
19012
19012
 
19013
- // ../../node_modules/@inquirer/core/node_modules/strip-ansi/index.js
19013
+ // ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/strip-ansi/index.js
19014
19014
  var require_strip_ansi = __commonJS((exports, module2) => {
19015
19015
  var ansiRegex = require_ansi_regex();
19016
19016
  module2.exports = (string) => typeof string === "string" ? string.replace(ansiRegex(), "") : string;
19017
19017
  });
19018
19018
 
19019
- // ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js
19019
+ // ../../node_modules/is-fullwidth-code-point/index.js
19020
19020
  var require_is_fullwidth_code_point = __commonJS((exports, module2) => {
19021
19021
  var isFullwidthCodePoint = (codePoint) => {
19022
19022
  if (Number.isNaN(codePoint)) {
@@ -20020,7 +20020,7 @@ var require_color_convert = __commonJS((exports, module2) => {
20020
20020
  module2.exports = convert;
20021
20021
  });
20022
20022
 
20023
- // ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/ansi-styles/index.js
20023
+ // ../../node_modules/ansi-styles/index.js
20024
20024
  var require_ansi_styles = __commonJS((exports, module2) => {
20025
20025
  var wrapAnsi16 = (fn, offset) => (...args2) => {
20026
20026
  const code = fn(...args2);
@@ -24496,7 +24496,7 @@ function stringify(object, opts = {}) {
24496
24496
  return joined.length > 0 ? prefix + joined : "";
24497
24497
  }
24498
24498
  // ../../node_modules/openai/version.mjs
24499
- var VERSION2 = "4.80.0";
24499
+ var VERSION2 = "4.89.1";
24500
24500
 
24501
24501
  // ../../node_modules/openai/_shims/registry.mjs
24502
24502
  var auto2 = false;
@@ -24721,39 +24721,57 @@ class ContentFilterFinishReasonError extends OpenAIError {
24721
24721
  }
24722
24722
 
24723
24723
  // ../../node_modules/openai/internal/decoders/line.mjs
24724
+ var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
24725
+ if (kind3 === "m")
24726
+ throw new TypeError("Private method is not writable");
24727
+ if (kind3 === "a" && !f2)
24728
+ throw new TypeError("Private accessor was defined without a setter");
24729
+ if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
24730
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
24731
+ return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
24732
+ };
24733
+ var __classPrivateFieldGet10 = function(receiver, state, kind3, f2) {
24734
+ if (kind3 === "a" && !f2)
24735
+ throw new TypeError("Private accessor was defined without a getter");
24736
+ if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
24737
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
24738
+ return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
24739
+ };
24740
+ var _LineDecoder_carriageReturnIndex2;
24741
+
24724
24742
  class LineDecoder2 {
24725
24743
  constructor() {
24726
- this.buffer = [];
24727
- this.trailingCR = false;
24744
+ _LineDecoder_carriageReturnIndex2.set(this, undefined);
24745
+ this.buffer = new Uint8Array;
24746
+ __classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
24728
24747
  }
24729
24748
  decode(chunk) {
24730
- let text = this.decodeText(chunk);
24731
- if (this.trailingCR) {
24732
- text = "\r" + text;
24733
- this.trailingCR = false;
24734
- }
24735
- if (text.endsWith("\r")) {
24736
- this.trailingCR = true;
24737
- text = text.slice(0, -1);
24738
- }
24739
- if (!text) {
24740
- return [];
24741
- }
24742
- const trailingNewline = LineDecoder2.NEWLINE_CHARS.has(text[text.length - 1] || "");
24743
- let lines = text.split(LineDecoder2.NEWLINE_REGEXP);
24744
- if (trailingNewline) {
24745
- lines.pop();
24746
- }
24747
- if (lines.length === 1 && !trailingNewline) {
24748
- this.buffer.push(lines[0]);
24749
+ if (chunk == null) {
24749
24750
  return [];
24750
24751
  }
24751
- if (this.buffer.length > 0) {
24752
- lines = [this.buffer.join("") + lines[0], ...lines.slice(1)];
24753
- this.buffer = [];
24754
- }
24755
- if (!trailingNewline) {
24756
- this.buffer = [lines.pop() || ""];
24752
+ const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk) : typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
24753
+ let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
24754
+ newData.set(this.buffer);
24755
+ newData.set(binaryChunk, this.buffer.length);
24756
+ this.buffer = newData;
24757
+ const lines = [];
24758
+ let patternIndex;
24759
+ while ((patternIndex = findNewlineIndex2(this.buffer, __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f"))) != null) {
24760
+ if (patternIndex.carriage && __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") == null) {
24761
+ __classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, patternIndex.index, "f");
24762
+ continue;
24763
+ }
24764
+ if (__classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") != null && (patternIndex.index !== __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") + 1 || patternIndex.carriage)) {
24765
+ lines.push(this.decodeText(this.buffer.slice(0, __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") - 1)));
24766
+ this.buffer = this.buffer.slice(__classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f"));
24767
+ __classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
24768
+ continue;
24769
+ }
24770
+ const endIndex = __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
24771
+ const line = this.decodeText(this.buffer.slice(0, endIndex));
24772
+ lines.push(line);
24773
+ this.buffer = this.buffer.slice(patternIndex.index);
24774
+ __classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
24757
24775
  }
24758
24776
  return lines;
24759
24777
  }
@@ -24781,18 +24799,46 @@ class LineDecoder2 {
24781
24799
  throw new OpenAIError(`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`);
24782
24800
  }
24783
24801
  flush() {
24784
- if (!this.buffer.length && !this.trailingCR) {
24802
+ if (!this.buffer.length) {
24785
24803
  return [];
24786
24804
  }
24787
- const lines = [this.buffer.join("")];
24788
- this.buffer = [];
24789
- this.trailingCR = false;
24790
- return lines;
24805
+ return this.decode(`
24806
+ `);
24791
24807
  }
24792
24808
  }
24809
+ _LineDecoder_carriageReturnIndex2 = new WeakMap;
24793
24810
  LineDecoder2.NEWLINE_CHARS = new Set([`
24794
24811
  `, "\r"]);
24795
24812
  LineDecoder2.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
24813
+ function findNewlineIndex2(buffer, startIndex) {
24814
+ const newline = 10;
24815
+ const carriage = 13;
24816
+ for (let i3 = startIndex ?? 0;i3 < buffer.length; i3++) {
24817
+ if (buffer[i3] === newline) {
24818
+ return { preceding: i3, index: i3 + 1, carriage: false };
24819
+ }
24820
+ if (buffer[i3] === carriage) {
24821
+ return { preceding: i3, index: i3 + 1, carriage: true };
24822
+ }
24823
+ }
24824
+ return null;
24825
+ }
24826
+ function findDoubleNewlineIndex2(buffer) {
24827
+ const newline = 10;
24828
+ const carriage = 13;
24829
+ for (let i3 = 0;i3 < buffer.length - 1; i3++) {
24830
+ if (buffer[i3] === newline && buffer[i3 + 1] === newline) {
24831
+ return i3 + 2;
24832
+ }
24833
+ if (buffer[i3] === carriage && buffer[i3 + 1] === carriage) {
24834
+ return i3 + 2;
24835
+ }
24836
+ if (buffer[i3] === carriage && buffer[i3 + 1] === newline && i3 + 3 < buffer.length && buffer[i3 + 2] === carriage && buffer[i3 + 3] === newline) {
24837
+ return i3 + 4;
24838
+ }
24839
+ }
24840
+ return -1;
24841
+ }
24796
24842
 
24797
24843
  // ../../node_modules/openai/internal/stream-utils.mjs
24798
24844
  function ReadableStreamToAsyncIterable2(stream) {
@@ -24845,7 +24891,7 @@ class Stream2 {
24845
24891
  done = true;
24846
24892
  continue;
24847
24893
  }
24848
- if (sse.event === null) {
24894
+ if (sse.event === null || sse.event.startsWith("response.")) {
24849
24895
  let data;
24850
24896
  try {
24851
24897
  data = JSON.parse(sse.data);
@@ -25016,22 +25062,6 @@ async function* iterSSEChunks2(iterator) {
25016
25062
  yield data;
25017
25063
  }
25018
25064
  }
25019
- function findDoubleNewlineIndex2(buffer) {
25020
- const newline = 10;
25021
- const carriage = 13;
25022
- for (let i3 = 0;i3 < buffer.length - 2; i3++) {
25023
- if (buffer[i3] === newline && buffer[i3 + 1] === newline) {
25024
- return i3 + 2;
25025
- }
25026
- if (buffer[i3] === carriage && buffer[i3 + 1] === carriage) {
25027
- return i3 + 2;
25028
- }
25029
- if (buffer[i3] === carriage && buffer[i3 + 1] === newline && i3 + 3 < buffer.length && buffer[i3 + 2] === carriage && buffer[i3 + 3] === newline) {
25030
- return i3 + 4;
25031
- }
25032
- }
25033
- return -1;
25034
- }
25035
25065
 
25036
25066
  class SSEDecoder2 {
25037
25067
  constructor() {
@@ -25170,7 +25200,7 @@ var addFormValue = async (form, key, value) => {
25170
25200
  };
25171
25201
 
25172
25202
  // ../../node_modules/openai/core.mjs
25173
- var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
25203
+ var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
25174
25204
  if (kind3 === "m")
25175
25205
  throw new TypeError("Private method is not writable");
25176
25206
  if (kind3 === "a" && !f2)
@@ -25179,7 +25209,7 @@ var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
25179
25209
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
25180
25210
  return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
25181
25211
  };
25182
- var __classPrivateFieldGet10 = function(receiver, state, kind3, f2) {
25212
+ var __classPrivateFieldGet11 = function(receiver, state, kind3, f2) {
25183
25213
  if (kind3 === "a" && !f2)
25184
25214
  throw new TypeError("Private accessor was defined without a getter");
25185
25215
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
@@ -25203,7 +25233,8 @@ async function defaultParseResponse2(props) {
25203
25233
  return response;
25204
25234
  }
25205
25235
  const contentType = response.headers.get("content-type");
25206
- const isJSON = contentType?.includes("application/json") || contentType?.includes("application/vnd.api+json");
25236
+ const mediaType = contentType?.split(";")[0]?.trim();
25237
+ const isJSON = mediaType?.includes("application/json") || mediaType?.endsWith("+json");
25207
25238
  if (isJSON) {
25208
25239
  const json = await response.json();
25209
25240
  debug2("response", response.status, response.url, response.headers, json);
@@ -25328,15 +25359,16 @@ class APIClient2 {
25328
25359
  return null;
25329
25360
  }
25330
25361
  buildRequest(options, { retryCount = 0 } = {}) {
25362
+ options = { ...options };
25331
25363
  const { method, path, query, headers = {} } = options;
25332
25364
  const body2 = ArrayBuffer.isView(options.body) || options.__binaryRequest && typeof options.body === "string" ? options.body : isMultipartBody2(options.body) ? options.body.body : options.body ? JSON.stringify(options.body, null, 2) : null;
25333
25365
  const contentLength = this.calculateContentLength(body2);
25334
25366
  const url = this.buildURL(path, query);
25335
25367
  if ("timeout" in options)
25336
25368
  validatePositiveInteger2("timeout", options.timeout);
25337
- const timeout = options.timeout ?? this.timeout;
25369
+ options.timeout = options.timeout ?? this.timeout;
25338
25370
  const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent2(url);
25339
- const minAgentTimeout = timeout + 1000;
25371
+ const minAgentTimeout = options.timeout + 1000;
25340
25372
  if (typeof httpAgent?.options?.timeout === "number" && minAgentTimeout > (httpAgent.options.timeout ?? 0)) {
25341
25373
  httpAgent.options.timeout = minAgentTimeout;
25342
25374
  }
@@ -25353,7 +25385,7 @@ class APIClient2 {
25353
25385
  ...httpAgent && { agent: httpAgent },
25354
25386
  signal: options.signal ?? null
25355
25387
  };
25356
- return { req, url, timeout };
25388
+ return { req, url, timeout: options.timeout };
25357
25389
  }
25358
25390
  buildHeaders({ options, headers, contentLength, retryCount }) {
25359
25391
  const reqHeaders = {};
@@ -25369,6 +25401,9 @@ class APIClient2 {
25369
25401
  if (getHeader2(defaultHeaders, "x-stainless-retry-count") === undefined && getHeader2(headers, "x-stainless-retry-count") === undefined) {
25370
25402
  reqHeaders["x-stainless-retry-count"] = String(retryCount);
25371
25403
  }
25404
+ if (getHeader2(defaultHeaders, "x-stainless-timeout") === undefined && getHeader2(headers, "x-stainless-timeout") === undefined && options.timeout) {
25405
+ reqHeaders["x-stainless-timeout"] = String(options.timeout);
25406
+ }
25372
25407
  this.validateHeaders(reqHeaders, headers);
25373
25408
  return reqHeaders;
25374
25409
  }
@@ -25526,7 +25561,7 @@ class APIClient2 {
25526
25561
  class AbstractPage2 {
25527
25562
  constructor(client, response, body2, options) {
25528
25563
  _AbstractPage_client2.set(this, undefined);
25529
- __classPrivateFieldSet9(this, _AbstractPage_client2, client, "f");
25564
+ __classPrivateFieldSet10(this, _AbstractPage_client2, client, "f");
25530
25565
  this.options = options;
25531
25566
  this.response = response;
25532
25567
  this.body = body2;
@@ -25553,7 +25588,7 @@ class AbstractPage2 {
25553
25588
  nextOptions.query = undefined;
25554
25589
  nextOptions.path = nextInfo.url.toString();
25555
25590
  }
25556
- return await __classPrivateFieldGet10(this, _AbstractPage_client2, "f").requestAPIList(this.constructor, nextOptions);
25591
+ return await __classPrivateFieldGet11(this, _AbstractPage_client2, "f").requestAPIList(this.constructor, nextOptions);
25557
25592
  }
25558
25593
  async* iterPages() {
25559
25594
  let page = this;
@@ -25603,6 +25638,7 @@ var requestOptionsKeys2 = {
25603
25638
  httpAgent: true,
25604
25639
  signal: true,
25605
25640
  idempotencyKey: true,
25641
+ __metadata: true,
25606
25642
  __binaryRequest: true,
25607
25643
  __binaryResponse: true,
25608
25644
  __streamClass: true
@@ -25877,10 +25913,17 @@ class CursorPage extends AbstractPage2 {
25877
25913
  constructor(client, response, body2, options) {
25878
25914
  super(client, response, body2, options);
25879
25915
  this.data = body2.data || [];
25916
+ this.has_more = body2.has_more || false;
25880
25917
  }
25881
25918
  getPaginatedItems() {
25882
25919
  return this.data ?? [];
25883
25920
  }
25921
+ hasNextPage() {
25922
+ if (this.has_more === false) {
25923
+ return false;
25924
+ }
25925
+ return super.hasNextPage();
25926
+ }
25884
25927
  nextPageParams() {
25885
25928
  const info2 = this.nextPageInfo();
25886
25929
  if (!info2)
@@ -25912,13 +25955,50 @@ class APIResource2 {
25912
25955
  }
25913
25956
  }
25914
25957
 
25915
- // ../../node_modules/openai/resources/chat/completions.mjs
25958
+ // ../../node_modules/openai/resources/chat/completions/messages.mjs
25959
+ class Messages3 extends APIResource2 {
25960
+ list(completionId, query = {}, options) {
25961
+ if (isRequestOptions2(query)) {
25962
+ return this.list(completionId, {}, query);
25963
+ }
25964
+ return this._client.getAPIList(`/chat/completions/${completionId}/messages`, ChatCompletionStoreMessagesPage, { query, ...options });
25965
+ }
25966
+ }
25967
+
25968
+ // ../../node_modules/openai/resources/chat/completions/completions.mjs
25916
25969
  class Completions2 extends APIResource2 {
25970
+ constructor() {
25971
+ super(...arguments);
25972
+ this.messages = new Messages3(this._client);
25973
+ }
25917
25974
  create(body2, options) {
25918
25975
  return this._client.post("/chat/completions", { body: body2, ...options, stream: body2.stream ?? false });
25919
25976
  }
25977
+ retrieve(completionId, options) {
25978
+ return this._client.get(`/chat/completions/${completionId}`, options);
25979
+ }
25980
+ update(completionId, body2, options) {
25981
+ return this._client.post(`/chat/completions/${completionId}`, { body: body2, ...options });
25982
+ }
25983
+ list(query = {}, options) {
25984
+ if (isRequestOptions2(query)) {
25985
+ return this.list({}, query);
25986
+ }
25987
+ return this._client.getAPIList("/chat/completions", ChatCompletionsPage, { query, ...options });
25988
+ }
25989
+ del(completionId, options) {
25990
+ return this._client.delete(`/chat/completions/${completionId}`, options);
25991
+ }
25992
+ }
25993
+
25994
+ class ChatCompletionsPage extends CursorPage {
25920
25995
  }
25921
25996
 
25997
+ class ChatCompletionStoreMessagesPage extends CursorPage {
25998
+ }
25999
+ Completions2.ChatCompletionsPage = ChatCompletionsPage;
26000
+ Completions2.Messages = Messages3;
26001
+
25922
26002
  // ../../node_modules/openai/resources/chat/chat.mjs
25923
26003
  class Chat extends APIResource2 {
25924
26004
  constructor() {
@@ -25927,6 +26007,7 @@ class Chat extends APIResource2 {
25927
26007
  }
25928
26008
  }
25929
26009
  Chat.Completions = Completions2;
26010
+ Chat.ChatCompletionsPage = ChatCompletionsPage;
25930
26011
  // ../../node_modules/openai/resources/audio/speech.mjs
25931
26012
  class Speech extends APIResource2 {
25932
26013
  create(body2, options) {
@@ -25942,14 +26023,14 @@ class Speech extends APIResource2 {
25942
26023
  // ../../node_modules/openai/resources/audio/transcriptions.mjs
25943
26024
  class Transcriptions extends APIResource2 {
25944
26025
  create(body2, options) {
25945
- return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body: body2, ...options }));
26026
+ return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body: body2, ...options, __metadata: { model: body2.model } }));
25946
26027
  }
25947
26028
  }
25948
26029
 
25949
26030
  // ../../node_modules/openai/resources/audio/translations.mjs
25950
26031
  class Translations extends APIResource2 {
25951
26032
  create(body2, options) {
25952
- return this._client.post("/audio/translations", multipartFormRequestOptions({ body: body2, ...options }));
26033
+ return this._client.post("/audio/translations", multipartFormRequestOptions({ body: body2, ...options, __metadata: { model: body2.model } }));
25953
26034
  }
25954
26035
  }
25955
26036
 
@@ -26048,7 +26129,7 @@ var isToolMessage = (message) => {
26048
26129
  };
26049
26130
 
26050
26131
  // ../../node_modules/openai/lib/EventStream.mjs
26051
- var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
26132
+ var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
26052
26133
  if (kind3 === "m")
26053
26134
  throw new TypeError("Private method is not writable");
26054
26135
  if (kind3 === "a" && !f2)
@@ -26057,7 +26138,7 @@ var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
26057
26138
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
26058
26139
  return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
26059
26140
  };
26060
- var __classPrivateFieldGet11 = function(receiver, state, kind3, f2) {
26141
+ var __classPrivateFieldGet12 = function(receiver, state, kind3, f2) {
26061
26142
  if (kind3 === "a" && !f2)
26062
26143
  throw new TypeError("Private accessor was defined without a getter");
26063
26144
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
@@ -26093,50 +26174,50 @@ class EventStream {
26093
26174
  _EventStream_errored.set(this, false);
26094
26175
  _EventStream_aborted.set(this, false);
26095
26176
  _EventStream_catchingPromiseCreated.set(this, false);
26096
- __classPrivateFieldSet10(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
26097
- __classPrivateFieldSet10(this, _EventStream_resolveConnectedPromise, resolve, "f");
26098
- __classPrivateFieldSet10(this, _EventStream_rejectConnectedPromise, reject, "f");
26177
+ __classPrivateFieldSet11(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
26178
+ __classPrivateFieldSet11(this, _EventStream_resolveConnectedPromise, resolve, "f");
26179
+ __classPrivateFieldSet11(this, _EventStream_rejectConnectedPromise, reject, "f");
26099
26180
  }), "f");
26100
- __classPrivateFieldSet10(this, _EventStream_endPromise, new Promise((resolve, reject) => {
26101
- __classPrivateFieldSet10(this, _EventStream_resolveEndPromise, resolve, "f");
26102
- __classPrivateFieldSet10(this, _EventStream_rejectEndPromise, reject, "f");
26181
+ __classPrivateFieldSet11(this, _EventStream_endPromise, new Promise((resolve, reject) => {
26182
+ __classPrivateFieldSet11(this, _EventStream_resolveEndPromise, resolve, "f");
26183
+ __classPrivateFieldSet11(this, _EventStream_rejectEndPromise, reject, "f");
26103
26184
  }), "f");
26104
- __classPrivateFieldGet11(this, _EventStream_connectedPromise, "f").catch(() => {});
26105
- __classPrivateFieldGet11(this, _EventStream_endPromise, "f").catch(() => {});
26185
+ __classPrivateFieldGet12(this, _EventStream_connectedPromise, "f").catch(() => {});
26186
+ __classPrivateFieldGet12(this, _EventStream_endPromise, "f").catch(() => {});
26106
26187
  }
26107
26188
  _run(executor) {
26108
26189
  setTimeout(() => {
26109
26190
  executor().then(() => {
26110
26191
  this._emitFinal();
26111
26192
  this._emit("end");
26112
- }, __classPrivateFieldGet11(this, _EventStream_instances, "m", _EventStream_handleError).bind(this));
26193
+ }, __classPrivateFieldGet12(this, _EventStream_instances, "m", _EventStream_handleError).bind(this));
26113
26194
  }, 0);
26114
26195
  }
26115
26196
  _connected() {
26116
26197
  if (this.ended)
26117
26198
  return;
26118
- __classPrivateFieldGet11(this, _EventStream_resolveConnectedPromise, "f").call(this);
26199
+ __classPrivateFieldGet12(this, _EventStream_resolveConnectedPromise, "f").call(this);
26119
26200
  this._emit("connect");
26120
26201
  }
26121
26202
  get ended() {
26122
- return __classPrivateFieldGet11(this, _EventStream_ended, "f");
26203
+ return __classPrivateFieldGet12(this, _EventStream_ended, "f");
26123
26204
  }
26124
26205
  get errored() {
26125
- return __classPrivateFieldGet11(this, _EventStream_errored, "f");
26206
+ return __classPrivateFieldGet12(this, _EventStream_errored, "f");
26126
26207
  }
26127
26208
  get aborted() {
26128
- return __classPrivateFieldGet11(this, _EventStream_aborted, "f");
26209
+ return __classPrivateFieldGet12(this, _EventStream_aborted, "f");
26129
26210
  }
26130
26211
  abort() {
26131
26212
  this.controller.abort();
26132
26213
  }
26133
26214
  on(event, listener) {
26134
- const listeners = __classPrivateFieldGet11(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet11(this, _EventStream_listeners, "f")[event] = []);
26215
+ const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = []);
26135
26216
  listeners.push({ listener });
26136
26217
  return this;
26137
26218
  }
26138
26219
  off(event, listener) {
26139
- const listeners = __classPrivateFieldGet11(this, _EventStream_listeners, "f")[event];
26220
+ const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event];
26140
26221
  if (!listeners)
26141
26222
  return this;
26142
26223
  const index = listeners.findIndex((l2) => l2.listener === listener);
@@ -26145,64 +26226,64 @@ class EventStream {
26145
26226
  return this;
26146
26227
  }
26147
26228
  once(event, listener) {
26148
- const listeners = __classPrivateFieldGet11(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet11(this, _EventStream_listeners, "f")[event] = []);
26229
+ const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = []);
26149
26230
  listeners.push({ listener, once: true });
26150
26231
  return this;
26151
26232
  }
26152
26233
  emitted(event) {
26153
26234
  return new Promise((resolve, reject) => {
26154
- __classPrivateFieldSet10(this, _EventStream_catchingPromiseCreated, true, "f");
26235
+ __classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true, "f");
26155
26236
  if (event !== "error")
26156
26237
  this.once("error", reject);
26157
26238
  this.once(event, resolve);
26158
26239
  });
26159
26240
  }
26160
26241
  async done() {
26161
- __classPrivateFieldSet10(this, _EventStream_catchingPromiseCreated, true, "f");
26162
- await __classPrivateFieldGet11(this, _EventStream_endPromise, "f");
26242
+ __classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true, "f");
26243
+ await __classPrivateFieldGet12(this, _EventStream_endPromise, "f");
26163
26244
  }
26164
26245
  _emit(event, ...args2) {
26165
- if (__classPrivateFieldGet11(this, _EventStream_ended, "f")) {
26246
+ if (__classPrivateFieldGet12(this, _EventStream_ended, "f")) {
26166
26247
  return;
26167
26248
  }
26168
26249
  if (event === "end") {
26169
- __classPrivateFieldSet10(this, _EventStream_ended, true, "f");
26170
- __classPrivateFieldGet11(this, _EventStream_resolveEndPromise, "f").call(this);
26250
+ __classPrivateFieldSet11(this, _EventStream_ended, true, "f");
26251
+ __classPrivateFieldGet12(this, _EventStream_resolveEndPromise, "f").call(this);
26171
26252
  }
26172
- const listeners = __classPrivateFieldGet11(this, _EventStream_listeners, "f")[event];
26253
+ const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event];
26173
26254
  if (listeners) {
26174
- __classPrivateFieldGet11(this, _EventStream_listeners, "f")[event] = listeners.filter((l2) => !l2.once);
26255
+ __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = listeners.filter((l2) => !l2.once);
26175
26256
  listeners.forEach(({ listener }) => listener(...args2));
26176
26257
  }
26177
26258
  if (event === "abort") {
26178
26259
  const error = args2[0];
26179
- if (!__classPrivateFieldGet11(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
26260
+ if (!__classPrivateFieldGet12(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
26180
26261
  Promise.reject(error);
26181
26262
  }
26182
- __classPrivateFieldGet11(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
26183
- __classPrivateFieldGet11(this, _EventStream_rejectEndPromise, "f").call(this, error);
26263
+ __classPrivateFieldGet12(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
26264
+ __classPrivateFieldGet12(this, _EventStream_rejectEndPromise, "f").call(this, error);
26184
26265
  this._emit("end");
26185
26266
  return;
26186
26267
  }
26187
26268
  if (event === "error") {
26188
26269
  const error = args2[0];
26189
- if (!__classPrivateFieldGet11(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
26270
+ if (!__classPrivateFieldGet12(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
26190
26271
  Promise.reject(error);
26191
26272
  }
26192
- __classPrivateFieldGet11(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
26193
- __classPrivateFieldGet11(this, _EventStream_rejectEndPromise, "f").call(this, error);
26273
+ __classPrivateFieldGet12(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
26274
+ __classPrivateFieldGet12(this, _EventStream_rejectEndPromise, "f").call(this, error);
26194
26275
  this._emit("end");
26195
26276
  }
26196
26277
  }
26197
26278
  _emitFinal() {}
26198
26279
  }
26199
26280
  _EventStream_connectedPromise = new WeakMap, _EventStream_resolveConnectedPromise = new WeakMap, _EventStream_rejectConnectedPromise = new WeakMap, _EventStream_endPromise = new WeakMap, _EventStream_resolveEndPromise = new WeakMap, _EventStream_rejectEndPromise = new WeakMap, _EventStream_listeners = new WeakMap, _EventStream_ended = new WeakMap, _EventStream_errored = new WeakMap, _EventStream_aborted = new WeakMap, _EventStream_catchingPromiseCreated = new WeakMap, _EventStream_instances = new WeakSet, _EventStream_handleError = function _EventStream_handleError2(error) {
26200
- __classPrivateFieldSet10(this, _EventStream_errored, true, "f");
26281
+ __classPrivateFieldSet11(this, _EventStream_errored, true, "f");
26201
26282
  if (error instanceof Error && error.name === "AbortError") {
26202
26283
  error = new APIUserAbortError2;
26203
26284
  }
26204
26285
  if (error instanceof APIUserAbortError2) {
26205
- __classPrivateFieldSet10(this, _EventStream_aborted, true, "f");
26286
+ __classPrivateFieldSet11(this, _EventStream_aborted, true, "f");
26206
26287
  return this._emit("abort", error);
26207
26288
  }
26208
26289
  if (error instanceof OpenAIError) {
@@ -26229,7 +26310,13 @@ function maybeParseChatCompletion(completion, params) {
26229
26310
  ...completion,
26230
26311
  choices: completion.choices.map((choice) => ({
26231
26312
  ...choice,
26232
- message: { ...choice.message, parsed: null, tool_calls: choice.message.tool_calls ?? [] }
26313
+ message: {
26314
+ ...choice.message,
26315
+ parsed: null,
26316
+ ...choice.message.tool_calls ? {
26317
+ tool_calls: choice.message.tool_calls
26318
+ } : undefined
26319
+ }
26233
26320
  }))
26234
26321
  };
26235
26322
  }
@@ -26247,7 +26334,9 @@ function parseChatCompletion(completion, params) {
26247
26334
  ...choice,
26248
26335
  message: {
26249
26336
  ...choice.message,
26250
- tool_calls: choice.message.tool_calls?.map((toolCall) => parseToolCall(params, toolCall)) ?? [],
26337
+ ...choice.message.tool_calls ? {
26338
+ tool_calls: choice.message.tool_calls?.map((toolCall) => parseToolCall(params, toolCall)) ?? undefined
26339
+ } : undefined,
26251
26340
  parsed: choice.message.content && !choice.message.refusal ? parseResponseFormat(params, choice.message.content) : null
26252
26341
  }
26253
26342
  };
@@ -26302,7 +26391,7 @@ function validateInputTools(tools) {
26302
26391
  }
26303
26392
 
26304
26393
  // ../../node_modules/openai/lib/AbstractChatCompletionRunner.mjs
26305
- var __classPrivateFieldGet12 = function(receiver, state, kind3, f2) {
26394
+ var __classPrivateFieldGet13 = function(receiver, state, kind3, f2) {
26306
26395
  if (kind3 === "a" && !f2)
26307
26396
  throw new TypeError("Private accessor was defined without a getter");
26308
26397
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
@@ -26362,23 +26451,23 @@ class AbstractChatCompletionRunner extends EventStream {
26362
26451
  }
26363
26452
  async finalContent() {
26364
26453
  await this.done();
26365
- return __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
26454
+ return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
26366
26455
  }
26367
26456
  async finalMessage() {
26368
26457
  await this.done();
26369
- return __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
26458
+ return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
26370
26459
  }
26371
26460
  async finalFunctionCall() {
26372
26461
  await this.done();
26373
- return __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
26462
+ return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
26374
26463
  }
26375
26464
  async finalFunctionCallResult() {
26376
26465
  await this.done();
26377
- return __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
26466
+ return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
26378
26467
  }
26379
26468
  async totalUsage() {
26380
26469
  await this.done();
26381
- return __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this);
26470
+ return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this);
26382
26471
  }
26383
26472
  allChatCompletions() {
26384
26473
  return [...this._chatCompletions];
@@ -26387,20 +26476,20 @@ class AbstractChatCompletionRunner extends EventStream {
26387
26476
  const completion = this._chatCompletions[this._chatCompletions.length - 1];
26388
26477
  if (completion)
26389
26478
  this._emit("finalChatCompletion", completion);
26390
- const finalMessage = __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
26479
+ const finalMessage = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
26391
26480
  if (finalMessage)
26392
26481
  this._emit("finalMessage", finalMessage);
26393
- const finalContent = __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
26482
+ const finalContent = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
26394
26483
  if (finalContent)
26395
26484
  this._emit("finalContent", finalContent);
26396
- const finalFunctionCall = __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
26485
+ const finalFunctionCall = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
26397
26486
  if (finalFunctionCall)
26398
26487
  this._emit("finalFunctionCall", finalFunctionCall);
26399
- const finalFunctionCallResult = __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
26488
+ const finalFunctionCallResult = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
26400
26489
  if (finalFunctionCallResult != null)
26401
26490
  this._emit("finalFunctionCallResult", finalFunctionCallResult);
26402
26491
  if (this._chatCompletions.some((c2) => c2.usage)) {
26403
- this._emit("totalUsage", __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this));
26492
+ this._emit("totalUsage", __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this));
26404
26493
  }
26405
26494
  }
26406
26495
  async _createChatCompletion(client, params, options) {
@@ -26410,7 +26499,7 @@ class AbstractChatCompletionRunner extends EventStream {
26410
26499
  this.controller.abort();
26411
26500
  signal.addEventListener("abort", () => this.controller.abort());
26412
26501
  }
26413
- __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_validateParams).call(this, params);
26502
+ __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_validateParams).call(this, params);
26414
26503
  const chatCompletion = await client.chat.completions.create({ ...params, stream: false }, { ...options, signal: this.controller.signal });
26415
26504
  this._connected();
26416
26505
  return this._addChatCompletion(parseChatCompletion(chatCompletion, params));
@@ -26474,7 +26563,7 @@ class AbstractChatCompletionRunner extends EventStream {
26474
26563
  continue;
26475
26564
  }
26476
26565
  const rawContent = await fn.function(parsed, this);
26477
- const content = __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
26566
+ const content = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
26478
26567
  this._addMessage({ role, name: name2, content });
26479
26568
  if (singleFunctionToCall)
26480
26569
  return;
@@ -26560,7 +26649,7 @@ class AbstractChatCompletionRunner extends EventStream {
26560
26649
  continue;
26561
26650
  }
26562
26651
  const rawContent = await fn.function(parsed, this);
26563
- const content = __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
26652
+ const content = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
26564
26653
  this._addMessage({ role, tool_call_id, content });
26565
26654
  if (singleFunctionToCall) {
26566
26655
  return;
@@ -26571,7 +26660,7 @@ class AbstractChatCompletionRunner extends EventStream {
26571
26660
  }
26572
26661
  }
26573
26662
  _AbstractChatCompletionRunner_instances = new WeakSet, _AbstractChatCompletionRunner_getFinalContent = function _AbstractChatCompletionRunner_getFinalContent2() {
26574
- return __classPrivateFieldGet12(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this).content ?? null;
26663
+ return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this).content ?? null;
26575
26664
  }, _AbstractChatCompletionRunner_getFinalMessage = function _AbstractChatCompletionRunner_getFinalMessage2() {
26576
26665
  let i3 = this.messages.length;
26577
26666
  while (i3-- > 0) {
@@ -26877,7 +26966,7 @@ var _parseJSON = (jsonString, allow) => {
26877
26966
  var partialParse2 = (input) => parseJSON(input, Allow.ALL ^ Allow.NUM);
26878
26967
 
26879
26968
  // ../../node_modules/openai/lib/ChatCompletionStream.mjs
26880
- var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
26969
+ var __classPrivateFieldSet12 = function(receiver, state, value, kind3, f2) {
26881
26970
  if (kind3 === "m")
26882
26971
  throw new TypeError("Private method is not writable");
26883
26972
  if (kind3 === "a" && !f2)
@@ -26886,7 +26975,7 @@ var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
26886
26975
  throw new TypeError("Cannot write private member to an object whose class did not declare it");
26887
26976
  return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
26888
26977
  };
26889
- var __classPrivateFieldGet13 = function(receiver, state, kind3, f2) {
26978
+ var __classPrivateFieldGet14 = function(receiver, state, kind3, f2) {
26890
26979
  if (kind3 === "a" && !f2)
26891
26980
  throw new TypeError("Private accessor was defined without a getter");
26892
26981
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
@@ -26913,11 +27002,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
26913
27002
  _ChatCompletionStream_params.set(this, undefined);
26914
27003
  _ChatCompletionStream_choiceEventStates.set(this, undefined);
26915
27004
  _ChatCompletionStream_currentChatCompletionSnapshot.set(this, undefined);
26916
- __classPrivateFieldSet11(this, _ChatCompletionStream_params, params, "f");
26917
- __classPrivateFieldSet11(this, _ChatCompletionStream_choiceEventStates, [], "f");
27005
+ __classPrivateFieldSet12(this, _ChatCompletionStream_params, params, "f");
27006
+ __classPrivateFieldSet12(this, _ChatCompletionStream_choiceEventStates, [], "f");
26918
27007
  }
26919
27008
  get currentChatCompletionSnapshot() {
26920
- return __classPrivateFieldGet13(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
27009
+ return __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
26921
27010
  }
26922
27011
  static fromReadableStream(stream) {
26923
27012
  const runner = new ChatCompletionStream(null);
@@ -26937,16 +27026,16 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
26937
27026
  this.controller.abort();
26938
27027
  signal.addEventListener("abort", () => this.controller.abort());
26939
27028
  }
26940
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
27029
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
26941
27030
  const stream = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
26942
27031
  this._connected();
26943
27032
  for await (const chunk of stream) {
26944
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
27033
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
26945
27034
  }
26946
27035
  if (stream.controller.signal?.aborted) {
26947
27036
  throw new APIUserAbortError2;
26948
27037
  }
26949
- return this._addChatCompletion(__classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
27038
+ return this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
26950
27039
  }
26951
27040
  async _fromReadableStream(readableStream, options) {
26952
27041
  const signal = options?.signal;
@@ -26955,28 +27044,28 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
26955
27044
  this.controller.abort();
26956
27045
  signal.addEventListener("abort", () => this.controller.abort());
26957
27046
  }
26958
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
27047
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
26959
27048
  this._connected();
26960
27049
  const stream = Stream2.fromReadableStream(readableStream, this.controller);
26961
27050
  let chatId;
26962
27051
  for await (const chunk of stream) {
26963
27052
  if (chatId && chatId !== chunk.id) {
26964
- this._addChatCompletion(__classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
27053
+ this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
26965
27054
  }
26966
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
27055
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
26967
27056
  chatId = chunk.id;
26968
27057
  }
26969
27058
  if (stream.controller.signal?.aborted) {
26970
27059
  throw new APIUserAbortError2;
26971
27060
  }
26972
- return this._addChatCompletion(__classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
27061
+ return this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
26973
27062
  }
26974
27063
  [(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest() {
26975
27064
  if (this.ended)
26976
27065
  return;
26977
- __classPrivateFieldSet11(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
27066
+ __classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
26978
27067
  }, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState(choice) {
26979
- let state = __classPrivateFieldGet13(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
27068
+ let state = __classPrivateFieldGet14(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
26980
27069
  if (state) {
26981
27070
  return state;
26982
27071
  }
@@ -26988,12 +27077,12 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
26988
27077
  done_tool_calls: new Set,
26989
27078
  current_tool_call_index: null
26990
27079
  };
26991
- __classPrivateFieldGet13(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
27080
+ __classPrivateFieldGet14(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
26992
27081
  return state;
26993
27082
  }, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk(chunk) {
26994
27083
  if (this.ended)
26995
27084
  return;
26996
- const completion = __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
27085
+ const completion = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
26997
27086
  this._emit("chunk", chunk, completion);
26998
27087
  for (const choice of chunk.choices) {
26999
27088
  const choiceSnapshot = completion.choices[choice.index];
@@ -27023,18 +27112,18 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27023
27112
  snapshot: choiceSnapshot.logprobs?.refusal ?? []
27024
27113
  });
27025
27114
  }
27026
- const state = __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
27115
+ const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
27027
27116
  if (choiceSnapshot.finish_reason) {
27028
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
27117
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
27029
27118
  if (state.current_tool_call_index != null) {
27030
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
27119
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
27031
27120
  }
27032
27121
  }
27033
27122
  for (const toolCall of choice.delta.tool_calls ?? []) {
27034
27123
  if (state.current_tool_call_index !== toolCall.index) {
27035
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
27124
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
27036
27125
  if (state.current_tool_call_index != null) {
27037
- __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
27126
+ __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
27038
27127
  }
27039
27128
  }
27040
27129
  state.current_tool_call_index = toolCall.index;
@@ -27058,7 +27147,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27058
27147
  }
27059
27148
  }
27060
27149
  }, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent(choiceSnapshot, toolCallIndex) {
27061
- const state = __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
27150
+ const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
27062
27151
  if (state.done_tool_calls.has(toolCallIndex)) {
27063
27152
  return;
27064
27153
  }
@@ -27070,7 +27159,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27070
27159
  throw new Error("tool call snapshot missing `type`");
27071
27160
  }
27072
27161
  if (toolCallSnapshot.type === "function") {
27073
- const inputTool = __classPrivateFieldGet13(this, _ChatCompletionStream_params, "f")?.tools?.find((tool) => tool.type === "function" && tool.function.name === toolCallSnapshot.function.name);
27162
+ const inputTool = __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f")?.tools?.find((tool) => tool.type === "function" && tool.function.name === toolCallSnapshot.function.name);
27074
27163
  this._emit("tool_calls.function.arguments.done", {
27075
27164
  name: toolCallSnapshot.function.name,
27076
27165
  index: toolCallIndex,
@@ -27081,10 +27170,10 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27081
27170
  assertNever(toolCallSnapshot.type);
27082
27171
  }
27083
27172
  }, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents(choiceSnapshot) {
27084
- const state = __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
27173
+ const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
27085
27174
  if (choiceSnapshot.message.content && !state.content_done) {
27086
27175
  state.content_done = true;
27087
- const responseFormat = __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);
27176
+ const responseFormat = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);
27088
27177
  this._emit("content.done", {
27089
27178
  content: choiceSnapshot.message.content,
27090
27179
  parsed: responseFormat ? responseFormat.$parseRaw(choiceSnapshot.message.content) : null
@@ -27106,25 +27195,25 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27106
27195
  if (this.ended) {
27107
27196
  throw new OpenAIError(`stream has ended, this shouldn't happen`);
27108
27197
  }
27109
- const snapshot = __classPrivateFieldGet13(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
27198
+ const snapshot = __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
27110
27199
  if (!snapshot) {
27111
27200
  throw new OpenAIError(`request ended without sending any chunks`);
27112
27201
  }
27113
- __classPrivateFieldSet11(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
27114
- __classPrivateFieldSet11(this, _ChatCompletionStream_choiceEventStates, [], "f");
27115
- return finalizeChatCompletion(snapshot, __classPrivateFieldGet13(this, _ChatCompletionStream_params, "f"));
27202
+ __classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
27203
+ __classPrivateFieldSet12(this, _ChatCompletionStream_choiceEventStates, [], "f");
27204
+ return finalizeChatCompletion(snapshot, __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"));
27116
27205
  }, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat() {
27117
- const responseFormat = __classPrivateFieldGet13(this, _ChatCompletionStream_params, "f")?.response_format;
27206
+ const responseFormat = __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f")?.response_format;
27118
27207
  if (isAutoParsableResponseFormat(responseFormat)) {
27119
27208
  return responseFormat;
27120
27209
  }
27121
27210
  return null;
27122
27211
  }, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion(chunk) {
27123
27212
  var _a2, _b, _c, _d;
27124
- let snapshot = __classPrivateFieldGet13(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
27213
+ let snapshot = __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
27125
27214
  const { choices, ...rest } = chunk;
27126
27215
  if (!snapshot) {
27127
- snapshot = __classPrivateFieldSet11(this, _ChatCompletionStream_currentChatCompletionSnapshot, {
27216
+ snapshot = __classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, {
27128
27217
  ...rest,
27129
27218
  choices: []
27130
27219
  }, "f");
@@ -27155,7 +27244,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27155
27244
  }
27156
27245
  if (finish_reason) {
27157
27246
  choice.finish_reason = finish_reason;
27158
- if (__classPrivateFieldGet13(this, _ChatCompletionStream_params, "f") && hasAutoParseableInput(__classPrivateFieldGet13(this, _ChatCompletionStream_params, "f"))) {
27247
+ if (__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f") && hasAutoParseableInput(__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"))) {
27159
27248
  if (finish_reason === "length") {
27160
27249
  throw new LengthFinishReasonError;
27161
27250
  }
@@ -27189,7 +27278,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27189
27278
  }
27190
27279
  if (content) {
27191
27280
  choice.message.content = (choice.message.content || "") + content;
27192
- if (!choice.message.refusal && __classPrivateFieldGet13(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {
27281
+ if (!choice.message.refusal && __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {
27193
27282
  choice.message.parsed = partialParse2(choice.message.content);
27194
27283
  }
27195
27284
  }
@@ -27209,7 +27298,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
27209
27298
  tool_call.function.name = fn.name;
27210
27299
  if (fn?.arguments) {
27211
27300
  tool_call.function.arguments += fn.arguments;
27212
- if (shouldParseToolCall(__classPrivateFieldGet13(this, _ChatCompletionStream_params, "f"), tool_call)) {
27301
+ if (shouldParseToolCall(__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"), tool_call)) {
27213
27302
  tool_call.function.parsed_arguments = partialParse2(tool_call.function.arguments);
27214
27303
  }
27215
27304
  }
@@ -27443,24 +27532,37 @@ class Sessions extends APIResource2 {
27443
27532
  }
27444
27533
  }
27445
27534
 
27535
+ // ../../node_modules/openai/resources/beta/realtime/transcription-sessions.mjs
27536
+ class TranscriptionSessions extends APIResource2 {
27537
+ create(body2, options) {
27538
+ return this._client.post("/realtime/transcription_sessions", {
27539
+ body: body2,
27540
+ ...options,
27541
+ headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
27542
+ });
27543
+ }
27544
+ }
27545
+
27446
27546
  // ../../node_modules/openai/resources/beta/realtime/realtime.mjs
27447
27547
  class Realtime extends APIResource2 {
27448
27548
  constructor() {
27449
27549
  super(...arguments);
27450
27550
  this.sessions = new Sessions(this._client);
27551
+ this.transcriptionSessions = new TranscriptionSessions(this._client);
27451
27552
  }
27452
27553
  }
27453
27554
  Realtime.Sessions = Sessions;
27555
+ Realtime.TranscriptionSessions = TranscriptionSessions;
27454
27556
 
27455
27557
  // ../../node_modules/openai/lib/AssistantStream.mjs
27456
- var __classPrivateFieldGet14 = function(receiver, state, kind3, f2) {
27558
+ var __classPrivateFieldGet15 = function(receiver, state, kind3, f2) {
27457
27559
  if (kind3 === "a" && !f2)
27458
27560
  throw new TypeError("Private accessor was defined without a getter");
27459
27561
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
27460
27562
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
27461
27563
  return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
27462
27564
  };
27463
- var __classPrivateFieldSet12 = function(receiver, state, value, kind3, f2) {
27565
+ var __classPrivateFieldSet13 = function(receiver, state, value, kind3, f2) {
27464
27566
  if (kind3 === "m")
27465
27567
  throw new TypeError("Private method is not writable");
27466
27568
  if (kind3 === "a" && !f2)
@@ -27574,12 +27676,12 @@ class AssistantStream extends EventStream {
27574
27676
  this._connected();
27575
27677
  const stream = Stream2.fromReadableStream(readableStream, this.controller);
27576
27678
  for await (const event of stream) {
27577
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27679
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27578
27680
  }
27579
27681
  if (stream.controller.signal?.aborted) {
27580
27682
  throw new APIUserAbortError2;
27581
27683
  }
27582
- return this._addRun(__classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27684
+ return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27583
27685
  }
27584
27686
  toReadableStream() {
27585
27687
  const stream = new Stream2(this[Symbol.asyncIterator].bind(this), this.controller);
@@ -27607,12 +27709,12 @@ class AssistantStream extends EventStream {
27607
27709
  });
27608
27710
  this._connected();
27609
27711
  for await (const event of stream) {
27610
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27712
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27611
27713
  }
27612
27714
  if (stream.controller.signal?.aborted) {
27613
27715
  throw new APIUserAbortError2;
27614
27716
  }
27615
- return this._addRun(__classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27717
+ return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27616
27718
  }
27617
27719
  static createThreadAssistantStream(params, thread, options) {
27618
27720
  const runner = new AssistantStream;
@@ -27631,30 +27733,30 @@ class AssistantStream extends EventStream {
27631
27733
  return runner;
27632
27734
  }
27633
27735
  currentEvent() {
27634
- return __classPrivateFieldGet14(this, _AssistantStream_currentEvent, "f");
27736
+ return __classPrivateFieldGet15(this, _AssistantStream_currentEvent, "f");
27635
27737
  }
27636
27738
  currentRun() {
27637
- return __classPrivateFieldGet14(this, _AssistantStream_currentRunSnapshot, "f");
27739
+ return __classPrivateFieldGet15(this, _AssistantStream_currentRunSnapshot, "f");
27638
27740
  }
27639
27741
  currentMessageSnapshot() {
27640
- return __classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f");
27742
+ return __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f");
27641
27743
  }
27642
27744
  currentRunStepSnapshot() {
27643
- return __classPrivateFieldGet14(this, _AssistantStream_currentRunStepSnapshot, "f");
27745
+ return __classPrivateFieldGet15(this, _AssistantStream_currentRunStepSnapshot, "f");
27644
27746
  }
27645
27747
  async finalRunSteps() {
27646
27748
  await this.done();
27647
- return Object.values(__classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f"));
27749
+ return Object.values(__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f"));
27648
27750
  }
27649
27751
  async finalMessages() {
27650
27752
  await this.done();
27651
- return Object.values(__classPrivateFieldGet14(this, _AssistantStream_messageSnapshots, "f"));
27753
+ return Object.values(__classPrivateFieldGet15(this, _AssistantStream_messageSnapshots, "f"));
27652
27754
  }
27653
27755
  async finalRun() {
27654
27756
  await this.done();
27655
- if (!__classPrivateFieldGet14(this, _AssistantStream_finalRun, "f"))
27757
+ if (!__classPrivateFieldGet15(this, _AssistantStream_finalRun, "f"))
27656
27758
  throw Error("Final run was not received.");
27657
- return __classPrivateFieldGet14(this, _AssistantStream_finalRun, "f");
27759
+ return __classPrivateFieldGet15(this, _AssistantStream_finalRun, "f");
27658
27760
  }
27659
27761
  async _createThreadAssistantStream(thread, params, options) {
27660
27762
  const signal = options?.signal;
@@ -27667,12 +27769,12 @@ class AssistantStream extends EventStream {
27667
27769
  const stream = await thread.createAndRun(body2, { ...options, signal: this.controller.signal });
27668
27770
  this._connected();
27669
27771
  for await (const event of stream) {
27670
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27772
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27671
27773
  }
27672
27774
  if (stream.controller.signal?.aborted) {
27673
27775
  throw new APIUserAbortError2;
27674
27776
  }
27675
- return this._addRun(__classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27777
+ return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27676
27778
  }
27677
27779
  async _createAssistantStream(run2, threadId, params, options) {
27678
27780
  const signal = options?.signal;
@@ -27685,12 +27787,12 @@ class AssistantStream extends EventStream {
27685
27787
  const stream = await run2.create(threadId, body2, { ...options, signal: this.controller.signal });
27686
27788
  this._connected();
27687
27789
  for await (const event of stream) {
27688
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27790
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
27689
27791
  }
27690
27792
  if (stream.controller.signal?.aborted) {
27691
27793
  throw new APIUserAbortError2;
27692
27794
  }
27693
- return this._addRun(__classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27795
+ return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
27694
27796
  }
27695
27797
  static accumulateDelta(acc, delta) {
27696
27798
  for (const [key, deltaValue] of Object.entries(delta)) {
@@ -27761,8 +27863,8 @@ class AssistantStream extends EventStream {
27761
27863
  _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27762
27864
  if (this.ended)
27763
27865
  return;
27764
- __classPrivateFieldSet12(this, _AssistantStream_currentEvent, event, "f");
27765
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_handleEvent).call(this, event);
27866
+ __classPrivateFieldSet13(this, _AssistantStream_currentEvent, event, "f");
27867
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleEvent).call(this, event);
27766
27868
  switch (event.event) {
27767
27869
  case "thread.created":
27768
27870
  break;
@@ -27771,11 +27873,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27771
27873
  case "thread.run.in_progress":
27772
27874
  case "thread.run.requires_action":
27773
27875
  case "thread.run.completed":
27876
+ case "thread.run.incomplete":
27774
27877
  case "thread.run.failed":
27775
27878
  case "thread.run.cancelling":
27776
27879
  case "thread.run.cancelled":
27777
27880
  case "thread.run.expired":
27778
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_handleRun).call(this, event);
27881
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleRun).call(this, event);
27779
27882
  break;
27780
27883
  case "thread.run.step.created":
27781
27884
  case "thread.run.step.in_progress":
@@ -27784,29 +27887,31 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27784
27887
  case "thread.run.step.failed":
27785
27888
  case "thread.run.step.cancelled":
27786
27889
  case "thread.run.step.expired":
27787
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_handleRunStep).call(this, event);
27890
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleRunStep).call(this, event);
27788
27891
  break;
27789
27892
  case "thread.message.created":
27790
27893
  case "thread.message.in_progress":
27791
27894
  case "thread.message.delta":
27792
27895
  case "thread.message.completed":
27793
27896
  case "thread.message.incomplete":
27794
- __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_handleMessage).call(this, event);
27897
+ __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleMessage).call(this, event);
27795
27898
  break;
27796
27899
  case "error":
27797
27900
  throw new Error("Encountered an error event in event processing - errors should be processed earlier");
27901
+ default:
27902
+ assertNever2(event);
27798
27903
  }
27799
27904
  }, _AssistantStream_endRequest = function _AssistantStream_endRequest2() {
27800
27905
  if (this.ended) {
27801
27906
  throw new OpenAIError(`stream has ended, this shouldn't happen`);
27802
27907
  }
27803
- if (!__classPrivateFieldGet14(this, _AssistantStream_finalRun, "f"))
27908
+ if (!__classPrivateFieldGet15(this, _AssistantStream_finalRun, "f"))
27804
27909
  throw Error("Final run has not been received");
27805
- return __classPrivateFieldGet14(this, _AssistantStream_finalRun, "f");
27910
+ return __classPrivateFieldGet15(this, _AssistantStream_finalRun, "f");
27806
27911
  }, _AssistantStream_handleMessage = function _AssistantStream_handleMessage2(event) {
27807
- const [accumulatedMessage, newContent] = __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_accumulateMessage).call(this, event, __classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f"));
27808
- __classPrivateFieldSet12(this, _AssistantStream_messageSnapshot, accumulatedMessage, "f");
27809
- __classPrivateFieldGet14(this, _AssistantStream_messageSnapshots, "f")[accumulatedMessage.id] = accumulatedMessage;
27912
+ const [accumulatedMessage, newContent] = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateMessage).call(this, event, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
27913
+ __classPrivateFieldSet13(this, _AssistantStream_messageSnapshot, accumulatedMessage, "f");
27914
+ __classPrivateFieldGet15(this, _AssistantStream_messageSnapshots, "f")[accumulatedMessage.id] = accumulatedMessage;
27810
27915
  for (const content of newContent) {
27811
27916
  const snapshotContent = accumulatedMessage.content[content.index];
27812
27917
  if (snapshotContent?.type == "text") {
@@ -27832,46 +27937,46 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27832
27937
  throw Error("The snapshot associated with this text delta is not text or missing");
27833
27938
  }
27834
27939
  }
27835
- if (content.index != __classPrivateFieldGet14(this, _AssistantStream_currentContentIndex, "f")) {
27836
- if (__classPrivateFieldGet14(this, _AssistantStream_currentContent, "f")) {
27837
- switch (__classPrivateFieldGet14(this, _AssistantStream_currentContent, "f").type) {
27940
+ if (content.index != __classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f")) {
27941
+ if (__classPrivateFieldGet15(this, _AssistantStream_currentContent, "f")) {
27942
+ switch (__classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").type) {
27838
27943
  case "text":
27839
- this._emit("textDone", __classPrivateFieldGet14(this, _AssistantStream_currentContent, "f").text, __classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f"));
27944
+ this._emit("textDone", __classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").text, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
27840
27945
  break;
27841
27946
  case "image_file":
27842
- this._emit("imageFileDone", __classPrivateFieldGet14(this, _AssistantStream_currentContent, "f").image_file, __classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f"));
27947
+ this._emit("imageFileDone", __classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").image_file, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
27843
27948
  break;
27844
27949
  }
27845
27950
  }
27846
- __classPrivateFieldSet12(this, _AssistantStream_currentContentIndex, content.index, "f");
27951
+ __classPrivateFieldSet13(this, _AssistantStream_currentContentIndex, content.index, "f");
27847
27952
  }
27848
- __classPrivateFieldSet12(this, _AssistantStream_currentContent, accumulatedMessage.content[content.index], "f");
27953
+ __classPrivateFieldSet13(this, _AssistantStream_currentContent, accumulatedMessage.content[content.index], "f");
27849
27954
  }
27850
27955
  }
27851
27956
  break;
27852
27957
  case "thread.message.completed":
27853
27958
  case "thread.message.incomplete":
27854
- if (__classPrivateFieldGet14(this, _AssistantStream_currentContentIndex, "f") !== undefined) {
27855
- const currentContent = event.data.content[__classPrivateFieldGet14(this, _AssistantStream_currentContentIndex, "f")];
27959
+ if (__classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f") !== undefined) {
27960
+ const currentContent = event.data.content[__classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f")];
27856
27961
  if (currentContent) {
27857
27962
  switch (currentContent.type) {
27858
27963
  case "image_file":
27859
- this._emit("imageFileDone", currentContent.image_file, __classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f"));
27964
+ this._emit("imageFileDone", currentContent.image_file, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
27860
27965
  break;
27861
27966
  case "text":
27862
- this._emit("textDone", currentContent.text, __classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f"));
27967
+ this._emit("textDone", currentContent.text, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
27863
27968
  break;
27864
27969
  }
27865
27970
  }
27866
27971
  }
27867
- if (__classPrivateFieldGet14(this, _AssistantStream_messageSnapshot, "f")) {
27972
+ if (__classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f")) {
27868
27973
  this._emit("messageDone", event.data);
27869
27974
  }
27870
- __classPrivateFieldSet12(this, _AssistantStream_messageSnapshot, undefined, "f");
27975
+ __classPrivateFieldSet13(this, _AssistantStream_messageSnapshot, undefined, "f");
27871
27976
  }
27872
27977
  }, _AssistantStream_handleRunStep = function _AssistantStream_handleRunStep2(event) {
27873
- const accumulatedRunStep = __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_accumulateRunStep).call(this, event);
27874
- __classPrivateFieldSet12(this, _AssistantStream_currentRunStepSnapshot, accumulatedRunStep, "f");
27978
+ const accumulatedRunStep = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateRunStep).call(this, event);
27979
+ __classPrivateFieldSet13(this, _AssistantStream_currentRunStepSnapshot, accumulatedRunStep, "f");
27875
27980
  switch (event.event) {
27876
27981
  case "thread.run.step.created":
27877
27982
  this._emit("runStepCreated", event.data);
@@ -27880,16 +27985,16 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27880
27985
  const delta = event.data.delta;
27881
27986
  if (delta.step_details && delta.step_details.type == "tool_calls" && delta.step_details.tool_calls && accumulatedRunStep.step_details.type == "tool_calls") {
27882
27987
  for (const toolCall of delta.step_details.tool_calls) {
27883
- if (toolCall.index == __classPrivateFieldGet14(this, _AssistantStream_currentToolCallIndex, "f")) {
27988
+ if (toolCall.index == __classPrivateFieldGet15(this, _AssistantStream_currentToolCallIndex, "f")) {
27884
27989
  this._emit("toolCallDelta", toolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index]);
27885
27990
  } else {
27886
- if (__classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f")) {
27887
- this._emit("toolCallDone", __classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f"));
27991
+ if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
27992
+ this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
27888
27993
  }
27889
- __classPrivateFieldSet12(this, _AssistantStream_currentToolCallIndex, toolCall.index, "f");
27890
- __classPrivateFieldSet12(this, _AssistantStream_currentToolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index], "f");
27891
- if (__classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f"))
27892
- this._emit("toolCallCreated", __classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f"));
27994
+ __classPrivateFieldSet13(this, _AssistantStream_currentToolCallIndex, toolCall.index, "f");
27995
+ __classPrivateFieldSet13(this, _AssistantStream_currentToolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index], "f");
27996
+ if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"))
27997
+ this._emit("toolCallCreated", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
27893
27998
  }
27894
27999
  }
27895
28000
  }
@@ -27899,12 +28004,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27899
28004
  case "thread.run.step.failed":
27900
28005
  case "thread.run.step.cancelled":
27901
28006
  case "thread.run.step.expired":
27902
- __classPrivateFieldSet12(this, _AssistantStream_currentRunStepSnapshot, undefined, "f");
28007
+ __classPrivateFieldSet13(this, _AssistantStream_currentRunStepSnapshot, undefined, "f");
27903
28008
  const details = event.data.step_details;
27904
28009
  if (details.type == "tool_calls") {
27905
- if (__classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f")) {
27906
- this._emit("toolCallDone", __classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f"));
27907
- __classPrivateFieldSet12(this, _AssistantStream_currentToolCall, undefined, "f");
28010
+ if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
28011
+ this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
28012
+ __classPrivateFieldSet13(this, _AssistantStream_currentToolCall, undefined, "f");
27908
28013
  }
27909
28014
  }
27910
28015
  this._emit("runStepDone", event.data, accumulatedRunStep);
@@ -27913,34 +28018,34 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27913
28018
  break;
27914
28019
  }
27915
28020
  }, _AssistantStream_handleEvent = function _AssistantStream_handleEvent2(event) {
27916
- __classPrivateFieldGet14(this, _AssistantStream_events, "f").push(event);
28021
+ __classPrivateFieldGet15(this, _AssistantStream_events, "f").push(event);
27917
28022
  this._emit("event", event);
27918
28023
  }, _AssistantStream_accumulateRunStep = function _AssistantStream_accumulateRunStep2(event) {
27919
28024
  switch (event.event) {
27920
28025
  case "thread.run.step.created":
27921
- __classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
28026
+ __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
27922
28027
  return event.data;
27923
28028
  case "thread.run.step.delta":
27924
- let snapshot = __classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
28029
+ let snapshot = __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
27925
28030
  if (!snapshot) {
27926
28031
  throw Error("Received a RunStepDelta before creation of a snapshot");
27927
28032
  }
27928
28033
  let data = event.data;
27929
28034
  if (data.delta) {
27930
28035
  const accumulated = AssistantStream.accumulateDelta(snapshot, data.delta);
27931
- __classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = accumulated;
28036
+ __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = accumulated;
27932
28037
  }
27933
- return __classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
28038
+ return __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
27934
28039
  case "thread.run.step.completed":
27935
28040
  case "thread.run.step.failed":
27936
28041
  case "thread.run.step.cancelled":
27937
28042
  case "thread.run.step.expired":
27938
28043
  case "thread.run.step.in_progress":
27939
- __classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
28044
+ __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
27940
28045
  break;
27941
28046
  }
27942
- if (__classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id])
27943
- return __classPrivateFieldGet14(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
28047
+ if (__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id])
28048
+ return __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
27944
28049
  throw new Error("No snapshot available");
27945
28050
  }, _AssistantStream_accumulateMessage = function _AssistantStream_accumulateMessage2(event, snapshot) {
27946
28051
  let newContent = [];
@@ -27956,7 +28061,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27956
28061
  for (const contentElement of data.delta.content) {
27957
28062
  if (contentElement.index in snapshot.content) {
27958
28063
  let currentContent = snapshot.content[contentElement.index];
27959
- snapshot.content[contentElement.index] = __classPrivateFieldGet14(this, _AssistantStream_instances, "m", _AssistantStream_accumulateContent).call(this, contentElement, currentContent);
28064
+ snapshot.content[contentElement.index] = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateContent).call(this, contentElement, currentContent);
27960
28065
  } else {
27961
28066
  snapshot.content[contentElement.index] = contentElement;
27962
28067
  newContent.push(contentElement);
@@ -27977,7 +28082,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27977
28082
  }, _AssistantStream_accumulateContent = function _AssistantStream_accumulateContent2(contentElement, currentContent) {
27978
28083
  return AssistantStream.accumulateDelta(currentContent, contentElement);
27979
28084
  }, _AssistantStream_handleRun = function _AssistantStream_handleRun2(event) {
27980
- __classPrivateFieldSet12(this, _AssistantStream_currentRunSnapshot, event.data, "f");
28085
+ __classPrivateFieldSet13(this, _AssistantStream_currentRunSnapshot, event.data, "f");
27981
28086
  switch (event.event) {
27982
28087
  case "thread.run.created":
27983
28088
  break;
@@ -27990,19 +28095,20 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
27990
28095
  case "thread.run.failed":
27991
28096
  case "thread.run.completed":
27992
28097
  case "thread.run.expired":
27993
- __classPrivateFieldSet12(this, _AssistantStream_finalRun, event.data, "f");
27994
- if (__classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f")) {
27995
- this._emit("toolCallDone", __classPrivateFieldGet14(this, _AssistantStream_currentToolCall, "f"));
27996
- __classPrivateFieldSet12(this, _AssistantStream_currentToolCall, undefined, "f");
28098
+ __classPrivateFieldSet13(this, _AssistantStream_finalRun, event.data, "f");
28099
+ if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
28100
+ this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
28101
+ __classPrivateFieldSet13(this, _AssistantStream_currentToolCall, undefined, "f");
27997
28102
  }
27998
28103
  break;
27999
28104
  case "thread.run.cancelling":
28000
28105
  break;
28001
28106
  }
28002
28107
  };
28108
+ function assertNever2(_x) {}
28003
28109
 
28004
28110
  // ../../node_modules/openai/resources/beta/threads/messages.mjs
28005
- class Messages3 extends APIResource2 {
28111
+ class Messages4 extends APIResource2 {
28006
28112
  create(threadId, body2, options) {
28007
28113
  return this._client.post(`/threads/${threadId}/messages`, {
28008
28114
  body: body2,
@@ -28043,7 +28149,7 @@ class Messages3 extends APIResource2 {
28043
28149
 
28044
28150
  class MessagesPage extends CursorPage {
28045
28151
  }
28046
- Messages3.MessagesPage = MessagesPage;
28152
+ Messages4.MessagesPage = MessagesPage;
28047
28153
 
28048
28154
  // ../../node_modules/openai/resources/beta/threads/runs/steps.mjs
28049
28155
  class Steps extends APIResource2 {
@@ -28194,7 +28300,7 @@ class Threads extends APIResource2 {
28194
28300
  constructor() {
28195
28301
  super(...arguments);
28196
28302
  this.runs = new Runs(this._client);
28197
- this.messages = new Messages3(this._client);
28303
+ this.messages = new Messages4(this._client);
28198
28304
  }
28199
28305
  create(body2 = {}, options) {
28200
28306
  if (isRequestOptions2(body2)) {
@@ -28233,19 +28339,626 @@ class Threads extends APIResource2 {
28233
28339
  stream: body2.stream ?? false
28234
28340
  });
28235
28341
  }
28236
- async createAndRunPoll(body2, options) {
28237
- const run2 = await this.createAndRun(body2, options);
28238
- return await this.runs.poll(run2.thread_id, run2.id, options);
28342
+ async createAndRunPoll(body2, options) {
28343
+ const run2 = await this.createAndRun(body2, options);
28344
+ return await this.runs.poll(run2.thread_id, run2.id, options);
28345
+ }
28346
+ createAndRunStream(body2, options) {
28347
+ return AssistantStream.createThreadAssistantStream(body2, this._client.beta.threads, options);
28348
+ }
28349
+ }
28350
+ Threads.Runs = Runs;
28351
+ Threads.RunsPage = RunsPage;
28352
+ Threads.Messages = Messages4;
28353
+ Threads.MessagesPage = MessagesPage;
28354
+
28355
+ // ../../node_modules/openai/resources/beta/beta.mjs
28356
+ class Beta2 extends APIResource2 {
28357
+ constructor() {
28358
+ super(...arguments);
28359
+ this.realtime = new Realtime(this._client);
28360
+ this.chat = new Chat2(this._client);
28361
+ this.assistants = new Assistants(this._client);
28362
+ this.threads = new Threads(this._client);
28363
+ }
28364
+ }
28365
+ Beta2.Realtime = Realtime;
28366
+ Beta2.Assistants = Assistants;
28367
+ Beta2.AssistantsPage = AssistantsPage;
28368
+ Beta2.Threads = Threads;
28369
+ // ../../node_modules/openai/resources/completions.mjs
28370
+ class Completions4 extends APIResource2 {
28371
+ create(body2, options) {
28372
+ return this._client.post("/completions", { body: body2, ...options, stream: body2.stream ?? false });
28373
+ }
28374
+ }
28375
+ // ../../node_modules/openai/resources/embeddings.mjs
28376
+ class Embeddings extends APIResource2 {
28377
+ create(body2, options) {
28378
+ return this._client.post("/embeddings", { body: body2, ...options });
28379
+ }
28380
+ }
28381
+ // ../../node_modules/openai/resources/files.mjs
28382
+ class Files extends APIResource2 {
28383
+ create(body2, options) {
28384
+ return this._client.post("/files", multipartFormRequestOptions({ body: body2, ...options }));
28385
+ }
28386
+ retrieve(fileId, options) {
28387
+ return this._client.get(`/files/${fileId}`, options);
28388
+ }
28389
+ list(query = {}, options) {
28390
+ if (isRequestOptions2(query)) {
28391
+ return this.list({}, query);
28392
+ }
28393
+ return this._client.getAPIList("/files", FileObjectsPage, { query, ...options });
28394
+ }
28395
+ del(fileId, options) {
28396
+ return this._client.delete(`/files/${fileId}`, options);
28397
+ }
28398
+ content(fileId, options) {
28399
+ return this._client.get(`/files/${fileId}/content`, {
28400
+ ...options,
28401
+ headers: { Accept: "application/binary", ...options?.headers },
28402
+ __binaryResponse: true
28403
+ });
28404
+ }
28405
+ retrieveContent(fileId, options) {
28406
+ return this._client.get(`/files/${fileId}/content`, options);
28407
+ }
28408
+ async waitForProcessing(id, { pollInterval = 5000, maxWait = 30 * 60 * 1000 } = {}) {
28409
+ const TERMINAL_STATES = new Set(["processed", "error", "deleted"]);
28410
+ const start2 = Date.now();
28411
+ let file = await this.retrieve(id);
28412
+ while (!file.status || !TERMINAL_STATES.has(file.status)) {
28413
+ await sleep2(pollInterval);
28414
+ file = await this.retrieve(id);
28415
+ if (Date.now() - start2 > maxWait) {
28416
+ throw new APIConnectionTimeoutError2({
28417
+ message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`
28418
+ });
28419
+ }
28420
+ }
28421
+ return file;
28422
+ }
28423
+ }
28424
+
28425
+ class FileObjectsPage extends CursorPage {
28426
+ }
28427
+ Files.FileObjectsPage = FileObjectsPage;
28428
+ // ../../node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
28429
+ class Checkpoints extends APIResource2 {
28430
+ list(fineTuningJobId, query = {}, options) {
28431
+ if (isRequestOptions2(query)) {
28432
+ return this.list(fineTuningJobId, {}, query);
28433
+ }
28434
+ return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/checkpoints`, FineTuningJobCheckpointsPage, { query, ...options });
28435
+ }
28436
+ }
28437
+
28438
+ class FineTuningJobCheckpointsPage extends CursorPage {
28439
+ }
28440
+ Checkpoints.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
28441
+
28442
+ // ../../node_modules/openai/resources/fine-tuning/jobs/jobs.mjs
28443
+ class Jobs extends APIResource2 {
28444
+ constructor() {
28445
+ super(...arguments);
28446
+ this.checkpoints = new Checkpoints(this._client);
28447
+ }
28448
+ create(body2, options) {
28449
+ return this._client.post("/fine_tuning/jobs", { body: body2, ...options });
28450
+ }
28451
+ retrieve(fineTuningJobId, options) {
28452
+ return this._client.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
28453
+ }
28454
+ list(query = {}, options) {
28455
+ if (isRequestOptions2(query)) {
28456
+ return this.list({}, query);
28457
+ }
28458
+ return this._client.getAPIList("/fine_tuning/jobs", FineTuningJobsPage, { query, ...options });
28459
+ }
28460
+ cancel(fineTuningJobId, options) {
28461
+ return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
28462
+ }
28463
+ listEvents(fineTuningJobId, query = {}, options) {
28464
+ if (isRequestOptions2(query)) {
28465
+ return this.listEvents(fineTuningJobId, {}, query);
28466
+ }
28467
+ return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/events`, FineTuningJobEventsPage, {
28468
+ query,
28469
+ ...options
28470
+ });
28471
+ }
28472
+ }
28473
+
28474
+ class FineTuningJobsPage extends CursorPage {
28475
+ }
28476
+
28477
+ class FineTuningJobEventsPage extends CursorPage {
28478
+ }
28479
+ Jobs.FineTuningJobsPage = FineTuningJobsPage;
28480
+ Jobs.FineTuningJobEventsPage = FineTuningJobEventsPage;
28481
+ Jobs.Checkpoints = Checkpoints;
28482
+ Jobs.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
28483
+
28484
+ // ../../node_modules/openai/resources/fine-tuning/fine-tuning.mjs
28485
+ class FineTuning extends APIResource2 {
28486
+ constructor() {
28487
+ super(...arguments);
28488
+ this.jobs = new Jobs(this._client);
28489
+ }
28490
+ }
28491
+ FineTuning.Jobs = Jobs;
28492
+ FineTuning.FineTuningJobsPage = FineTuningJobsPage;
28493
+ FineTuning.FineTuningJobEventsPage = FineTuningJobEventsPage;
28494
+ // ../../node_modules/openai/resources/images.mjs
28495
+ class Images extends APIResource2 {
28496
+ createVariation(body2, options) {
28497
+ return this._client.post("/images/variations", multipartFormRequestOptions({ body: body2, ...options }));
28498
+ }
28499
+ edit(body2, options) {
28500
+ return this._client.post("/images/edits", multipartFormRequestOptions({ body: body2, ...options }));
28501
+ }
28502
+ generate(body2, options) {
28503
+ return this._client.post("/images/generations", { body: body2, ...options });
28504
+ }
28505
+ }
28506
+ // ../../node_modules/openai/resources/models.mjs
28507
+ class Models3 extends APIResource2 {
28508
+ retrieve(model, options) {
28509
+ return this._client.get(`/models/${model}`, options);
28510
+ }
28511
+ list(options) {
28512
+ return this._client.getAPIList("/models", ModelsPage, options);
28513
+ }
28514
+ del(model, options) {
28515
+ return this._client.delete(`/models/${model}`, options);
28516
+ }
28517
+ }
28518
+
28519
+ class ModelsPage extends Page2 {
28520
+ }
28521
+ Models3.ModelsPage = ModelsPage;
28522
+ // ../../node_modules/openai/resources/moderations.mjs
28523
+ class Moderations extends APIResource2 {
28524
+ create(body2, options) {
28525
+ return this._client.post("/moderations", { body: body2, ...options });
28526
+ }
28527
+ }
28528
+ // ../../node_modules/openai/lib/ResponsesParser.mjs
28529
+ function maybeParseResponse(response, params) {
28530
+ if (!params || !hasAutoParseableInput2(params)) {
28531
+ return {
28532
+ ...response,
28533
+ output_parsed: null,
28534
+ output: response.output.map((item) => {
28535
+ if (item.type === "function_call") {
28536
+ return {
28537
+ ...item,
28538
+ parsed_arguments: null
28539
+ };
28540
+ }
28541
+ if (item.type === "message") {
28542
+ return {
28543
+ ...item,
28544
+ content: item.content.map((content) => ({
28545
+ ...content,
28546
+ parsed: null
28547
+ }))
28548
+ };
28549
+ } else {
28550
+ return item;
28551
+ }
28552
+ })
28553
+ };
28554
+ }
28555
+ return parseResponse(response, params);
28556
+ }
28557
+ function parseResponse(response, params) {
28558
+ const output = response.output.map((item) => {
28559
+ if (item.type === "function_call") {
28560
+ return {
28561
+ ...item,
28562
+ parsed_arguments: parseToolCall2(params, item)
28563
+ };
28564
+ }
28565
+ if (item.type === "message") {
28566
+ const content = item.content.map((content2) => {
28567
+ if (content2.type === "output_text") {
28568
+ return {
28569
+ ...content2,
28570
+ parsed: parseTextFormat(params, content2.text)
28571
+ };
28572
+ }
28573
+ return content2;
28574
+ });
28575
+ return {
28576
+ ...item,
28577
+ content
28578
+ };
28579
+ }
28580
+ return item;
28581
+ });
28582
+ const parsed = Object.assign({}, response, { output });
28583
+ if (!Object.getOwnPropertyDescriptor(response, "output_text")) {
28584
+ addOutputText(parsed);
28585
+ }
28586
+ Object.defineProperty(parsed, "output_parsed", {
28587
+ enumerable: true,
28588
+ get() {
28589
+ for (const output2 of parsed.output) {
28590
+ if (output2.type !== "message") {
28591
+ continue;
28592
+ }
28593
+ for (const content of output2.content) {
28594
+ if (content.type === "output_text" && content.parsed !== null) {
28595
+ return content.parsed;
28596
+ }
28597
+ }
28598
+ }
28599
+ return null;
28600
+ }
28601
+ });
28602
+ return parsed;
28603
+ }
28604
+ function parseTextFormat(params, content) {
28605
+ if (params.text?.format?.type !== "json_schema") {
28606
+ return null;
28607
+ }
28608
+ if ("$parseRaw" in params.text?.format) {
28609
+ const text_format = params.text?.format;
28610
+ return text_format.$parseRaw(content);
28611
+ }
28612
+ return JSON.parse(content);
28613
+ }
28614
+ function hasAutoParseableInput2(params) {
28615
+ if (isAutoParsableResponseFormat(params.text?.format)) {
28616
+ return true;
28617
+ }
28618
+ return false;
28619
+ }
28620
+ function isAutoParsableTool2(tool) {
28621
+ return tool?.["$brand"] === "auto-parseable-tool";
28622
+ }
28623
+ function getInputToolByName(input_tools, name2) {
28624
+ return input_tools.find((tool) => tool.type === "function" && tool.name === name2);
28625
+ }
28626
+ function parseToolCall2(params, toolCall) {
28627
+ const inputTool = getInputToolByName(params.tools ?? [], toolCall.name);
28628
+ return {
28629
+ ...toolCall,
28630
+ ...toolCall,
28631
+ parsed_arguments: isAutoParsableTool2(inputTool) ? inputTool.$parseRaw(toolCall.arguments) : inputTool?.strict ? JSON.parse(toolCall.arguments) : null
28632
+ };
28633
+ }
28634
+ function addOutputText(rsp) {
28635
+ const texts = [];
28636
+ for (const output of rsp.output) {
28637
+ if (output.type !== "message") {
28638
+ continue;
28639
+ }
28640
+ for (const content of output.content) {
28641
+ if (content.type === "output_text") {
28642
+ texts.push(content.text);
28643
+ }
28644
+ }
28645
+ }
28646
+ rsp.output_text = texts.join("");
28647
+ }
28648
+
28649
+ // ../../node_modules/openai/resources/responses/input-items.mjs
28650
+ class InputItems extends APIResource2 {
28651
+ list(responseId, query = {}, options) {
28652
+ if (isRequestOptions2(query)) {
28653
+ return this.list(responseId, {}, query);
28654
+ }
28655
+ return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemsPage, {
28656
+ query,
28657
+ ...options
28658
+ });
28659
+ }
28660
+ }
28661
+
28662
+ // ../../node_modules/openai/lib/responses/ResponseStream.mjs
28663
+ var __classPrivateFieldSet14 = function(receiver, state, value, kind3, f2) {
28664
+ if (kind3 === "m")
28665
+ throw new TypeError("Private method is not writable");
28666
+ if (kind3 === "a" && !f2)
28667
+ throw new TypeError("Private accessor was defined without a setter");
28668
+ if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
28669
+ throw new TypeError("Cannot write private member to an object whose class did not declare it");
28670
+ return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
28671
+ };
28672
+ var __classPrivateFieldGet16 = function(receiver, state, kind3, f2) {
28673
+ if (kind3 === "a" && !f2)
28674
+ throw new TypeError("Private accessor was defined without a getter");
28675
+ if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
28676
+ throw new TypeError("Cannot read private member from an object whose class did not declare it");
28677
+ return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
28678
+ };
28679
+ var _ResponseStream_instances;
28680
+ var _ResponseStream_params;
28681
+ var _ResponseStream_currentResponseSnapshot;
28682
+ var _ResponseStream_finalResponse;
28683
+ var _ResponseStream_beginRequest;
28684
+ var _ResponseStream_addEvent;
28685
+ var _ResponseStream_endRequest;
28686
+ var _ResponseStream_accumulateResponse;
28687
+
28688
+ class ResponseStream extends EventStream {
28689
+ constructor(params) {
28690
+ super();
28691
+ _ResponseStream_instances.add(this);
28692
+ _ResponseStream_params.set(this, undefined);
28693
+ _ResponseStream_currentResponseSnapshot.set(this, undefined);
28694
+ _ResponseStream_finalResponse.set(this, undefined);
28695
+ __classPrivateFieldSet14(this, _ResponseStream_params, params, "f");
28696
+ }
28697
+ static createResponse(client, params, options) {
28698
+ const runner = new ResponseStream(params);
28699
+ runner._run(() => runner._createResponse(client, params, {
28700
+ ...options,
28701
+ headers: { ...options?.headers, "X-Stainless-Helper-Method": "stream" }
28702
+ }));
28703
+ return runner;
28704
+ }
28705
+ async _createResponse(client, params, options) {
28706
+ const signal = options?.signal;
28707
+ if (signal) {
28708
+ if (signal.aborted)
28709
+ this.controller.abort();
28710
+ signal.addEventListener("abort", () => this.controller.abort());
28711
+ }
28712
+ __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_beginRequest).call(this);
28713
+ const stream = await client.responses.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
28714
+ this._connected();
28715
+ for await (const event of stream) {
28716
+ __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_addEvent).call(this, event);
28717
+ }
28718
+ if (stream.controller.signal?.aborted) {
28719
+ throw new APIUserAbortError2;
28720
+ }
28721
+ return __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
28722
+ }
28723
+ [(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function _ResponseStream_beginRequest() {
28724
+ if (this.ended)
28725
+ return;
28726
+ __classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
28727
+ }, _ResponseStream_addEvent = function _ResponseStream_addEvent(event) {
28728
+ if (this.ended)
28729
+ return;
28730
+ const response = __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_accumulateResponse).call(this, event);
28731
+ this._emit("event", event);
28732
+ switch (event.type) {
28733
+ case "response.output_text.delta": {
28734
+ const output = response.output[event.output_index];
28735
+ if (!output) {
28736
+ throw new OpenAIError(`missing output at index ${event.output_index}`);
28737
+ }
28738
+ if (output.type === "message") {
28739
+ const content = output.content[event.content_index];
28740
+ if (!content) {
28741
+ throw new OpenAIError(`missing content at index ${event.content_index}`);
28742
+ }
28743
+ if (content.type !== "output_text") {
28744
+ throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
28745
+ }
28746
+ this._emit("response.output_text.delta", {
28747
+ ...event,
28748
+ snapshot: content.text
28749
+ });
28750
+ }
28751
+ break;
28752
+ }
28753
+ case "response.function_call_arguments.delta": {
28754
+ const output = response.output[event.output_index];
28755
+ if (!output) {
28756
+ throw new OpenAIError(`missing output at index ${event.output_index}`);
28757
+ }
28758
+ if (output.type === "function_call") {
28759
+ this._emit("response.function_call_arguments.delta", {
28760
+ ...event,
28761
+ snapshot: output.arguments
28762
+ });
28763
+ }
28764
+ break;
28765
+ }
28766
+ default:
28767
+ this._emit(event.type, event);
28768
+ break;
28769
+ }
28770
+ }, _ResponseStream_endRequest = function _ResponseStream_endRequest() {
28771
+ if (this.ended) {
28772
+ throw new OpenAIError(`stream has ended, this shouldn't happen`);
28773
+ }
28774
+ const snapshot = __classPrivateFieldGet16(this, _ResponseStream_currentResponseSnapshot, "f");
28775
+ if (!snapshot) {
28776
+ throw new OpenAIError(`request ended without sending any events`);
28777
+ }
28778
+ __classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
28779
+ const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet16(this, _ResponseStream_params, "f"));
28780
+ __classPrivateFieldSet14(this, _ResponseStream_finalResponse, parsedResponse, "f");
28781
+ return parsedResponse;
28782
+ }, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse(event) {
28783
+ let snapshot = __classPrivateFieldGet16(this, _ResponseStream_currentResponseSnapshot, "f");
28784
+ if (!snapshot) {
28785
+ if (event.type !== "response.created") {
28786
+ throw new OpenAIError(`When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`);
28787
+ }
28788
+ snapshot = __classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
28789
+ return snapshot;
28790
+ }
28791
+ switch (event.type) {
28792
+ case "response.output_item.added": {
28793
+ snapshot.output.push(event.item);
28794
+ break;
28795
+ }
28796
+ case "response.content_part.added": {
28797
+ const output = snapshot.output[event.output_index];
28798
+ if (!output) {
28799
+ throw new OpenAIError(`missing output at index ${event.output_index}`);
28800
+ }
28801
+ if (output.type === "message") {
28802
+ output.content.push(event.part);
28803
+ }
28804
+ break;
28805
+ }
28806
+ case "response.output_text.delta": {
28807
+ const output = snapshot.output[event.output_index];
28808
+ if (!output) {
28809
+ throw new OpenAIError(`missing output at index ${event.output_index}`);
28810
+ }
28811
+ if (output.type === "message") {
28812
+ const content = output.content[event.content_index];
28813
+ if (!content) {
28814
+ throw new OpenAIError(`missing content at index ${event.content_index}`);
28815
+ }
28816
+ if (content.type !== "output_text") {
28817
+ throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
28818
+ }
28819
+ content.text += event.delta;
28820
+ }
28821
+ break;
28822
+ }
28823
+ case "response.function_call_arguments.delta": {
28824
+ const output = snapshot.output[event.output_index];
28825
+ if (!output) {
28826
+ throw new OpenAIError(`missing output at index ${event.output_index}`);
28827
+ }
28828
+ if (output.type === "function_call") {
28829
+ output.arguments += event.delta;
28830
+ }
28831
+ break;
28832
+ }
28833
+ case "response.completed": {
28834
+ __classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
28835
+ break;
28836
+ }
28837
+ }
28838
+ return snapshot;
28839
+ }, Symbol.asyncIterator)]() {
28840
+ const pushQueue = [];
28841
+ const readQueue = [];
28842
+ let done = false;
28843
+ this.on("event", (event) => {
28844
+ const reader = readQueue.shift();
28845
+ if (reader) {
28846
+ reader.resolve(event);
28847
+ } else {
28848
+ pushQueue.push(event);
28849
+ }
28850
+ });
28851
+ this.on("end", () => {
28852
+ done = true;
28853
+ for (const reader of readQueue) {
28854
+ reader.resolve(undefined);
28855
+ }
28856
+ readQueue.length = 0;
28857
+ });
28858
+ this.on("abort", (err2) => {
28859
+ done = true;
28860
+ for (const reader of readQueue) {
28861
+ reader.reject(err2);
28862
+ }
28863
+ readQueue.length = 0;
28864
+ });
28865
+ this.on("error", (err2) => {
28866
+ done = true;
28867
+ for (const reader of readQueue) {
28868
+ reader.reject(err2);
28869
+ }
28870
+ readQueue.length = 0;
28871
+ });
28872
+ return {
28873
+ next: async () => {
28874
+ if (!pushQueue.length) {
28875
+ if (done) {
28876
+ return { value: undefined, done: true };
28877
+ }
28878
+ return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: undefined, done: true });
28879
+ }
28880
+ const event = pushQueue.shift();
28881
+ return { value: event, done: false };
28882
+ },
28883
+ return: async () => {
28884
+ this.abort();
28885
+ return { value: undefined, done: true };
28886
+ }
28887
+ };
28888
+ }
28889
+ async finalResponse() {
28890
+ await this.done();
28891
+ const response = __classPrivateFieldGet16(this, _ResponseStream_finalResponse, "f");
28892
+ if (!response)
28893
+ throw new OpenAIError("stream ended without producing a ChatCompletion");
28894
+ return response;
28895
+ }
28896
+ }
28897
+ function finalizeResponse(snapshot, params) {
28898
+ return maybeParseResponse(snapshot, params);
28899
+ }
28900
+
28901
+ // ../../node_modules/openai/resources/responses/responses.mjs
28902
+ class Responses extends APIResource2 {
28903
+ constructor() {
28904
+ super(...arguments);
28905
+ this.inputItems = new InputItems(this._client);
28906
+ }
28907
+ create(body2, options) {
28908
+ return this._client.post("/responses", { body: body2, ...options, stream: body2.stream ?? false })._thenUnwrap((rsp) => {
28909
+ if ("object" in rsp && rsp.object === "response") {
28910
+ addOutputText(rsp);
28911
+ }
28912
+ return rsp;
28913
+ });
28914
+ }
28915
+ retrieve(responseId, query = {}, options) {
28916
+ if (isRequestOptions2(query)) {
28917
+ return this.retrieve(responseId, {}, query);
28918
+ }
28919
+ return this._client.get(`/responses/${responseId}`, { query, ...options });
28920
+ }
28921
+ del(responseId, options) {
28922
+ return this._client.delete(`/responses/${responseId}`, {
28923
+ ...options,
28924
+ headers: { Accept: "*/*", ...options?.headers }
28925
+ });
28926
+ }
28927
+ parse(body2, options) {
28928
+ return this._client.responses.create(body2, options)._thenUnwrap((response) => parseResponse(response, body2));
28929
+ }
28930
+ stream(body2, options) {
28931
+ return ResponseStream.createResponse(this._client, body2, options);
28239
28932
  }
28240
- createAndRunStream(body2, options) {
28241
- return AssistantStream.createThreadAssistantStream(body2, this._client.beta.threads, options);
28933
+ }
28934
+
28935
+ class ResponseItemsPage extends CursorPage {
28936
+ }
28937
+ Responses.InputItems = InputItems;
28938
+ // ../../node_modules/openai/resources/uploads/parts.mjs
28939
+ class Parts extends APIResource2 {
28940
+ create(uploadId, body2, options) {
28941
+ return this._client.post(`/uploads/${uploadId}/parts`, multipartFormRequestOptions({ body: body2, ...options }));
28242
28942
  }
28243
28943
  }
28244
- Threads.Runs = Runs;
28245
- Threads.RunsPage = RunsPage;
28246
- Threads.Messages = Messages3;
28247
- Threads.MessagesPage = MessagesPage;
28248
28944
 
28945
+ // ../../node_modules/openai/resources/uploads/uploads.mjs
28946
+ class Uploads extends APIResource2 {
28947
+ constructor() {
28948
+ super(...arguments);
28949
+ this.parts = new Parts(this._client);
28950
+ }
28951
+ create(body2, options) {
28952
+ return this._client.post("/uploads", { body: body2, ...options });
28953
+ }
28954
+ cancel(uploadId, options) {
28955
+ return this._client.post(`/uploads/${uploadId}/cancel`, options);
28956
+ }
28957
+ complete(uploadId, body2, options) {
28958
+ return this._client.post(`/uploads/${uploadId}/complete`, { body: body2, ...options });
28959
+ }
28960
+ }
28961
+ Uploads.Parts = Parts;
28249
28962
  // ../../node_modules/openai/lib/Util.mjs
28250
28963
  var allSettledWithThrow = async (promises) => {
28251
28964
  const results = await Promise.allSettled(promises);
@@ -28265,8 +28978,8 @@ var allSettledWithThrow = async (promises) => {
28265
28978
  return values;
28266
28979
  };
28267
28980
 
28268
- // ../../node_modules/openai/resources/beta/vector-stores/files.mjs
28269
- class Files extends APIResource2 {
28981
+ // ../../node_modules/openai/resources/vector-stores/files.mjs
28982
+ class Files2 extends APIResource2 {
28270
28983
  create(vectorStoreId, body2, options) {
28271
28984
  return this._client.post(`/vector_stores/${vectorStoreId}/files`, {
28272
28985
  body: body2,
@@ -28280,6 +28993,13 @@ class Files extends APIResource2 {
28280
28993
  headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
28281
28994
  });
28282
28995
  }
28996
+ update(vectorStoreId, fileId, body2, options) {
28997
+ return this._client.post(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
28998
+ body: body2,
28999
+ ...options,
29000
+ headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
29001
+ });
29002
+ }
28283
29003
  list(vectorStoreId, query = {}, options) {
28284
29004
  if (isRequestOptions2(query)) {
28285
29005
  return this.list(vectorStoreId, {}, query);
@@ -28341,13 +29061,20 @@ class Files extends APIResource2 {
28341
29061
  const fileInfo = await this.upload(vectorStoreId, file, options);
28342
29062
  return await this.poll(vectorStoreId, fileInfo.id, options);
28343
29063
  }
29064
+ content(vectorStoreId, fileId, options) {
29065
+ return this._client.getAPIList(`/vector_stores/${vectorStoreId}/files/${fileId}/content`, FileContentResponsesPage, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers } });
29066
+ }
28344
29067
  }
28345
29068
 
28346
29069
  class VectorStoreFilesPage extends CursorPage {
28347
29070
  }
28348
- Files.VectorStoreFilesPage = VectorStoreFilesPage;
28349
29071
 
28350
- // ../../node_modules/openai/resources/beta/vector-stores/file-batches.mjs
29072
+ class FileContentResponsesPage extends Page2 {
29073
+ }
29074
+ Files2.VectorStoreFilesPage = VectorStoreFilesPage;
29075
+ Files2.FileContentResponsesPage = FileContentResponsesPage;
29076
+
29077
+ // ../../node_modules/openai/resources/vector-stores/file-batches.mjs
28351
29078
  class FileBatches extends APIResource2 {
28352
29079
  create(vectorStoreId, body2, options) {
28353
29080
  return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, {
@@ -28434,11 +29161,11 @@ class FileBatches extends APIResource2 {
28434
29161
  }
28435
29162
  }
28436
29163
 
28437
- // ../../node_modules/openai/resources/beta/vector-stores/vector-stores.mjs
29164
+ // ../../node_modules/openai/resources/vector-stores/vector-stores.mjs
28438
29165
  class VectorStores extends APIResource2 {
28439
29166
  constructor() {
28440
29167
  super(...arguments);
28441
- this.files = new Files(this._client);
29168
+ this.files = new Files2(this._client);
28442
29169
  this.fileBatches = new FileBatches(this._client);
28443
29170
  }
28444
29171
  create(body2, options) {
@@ -28477,215 +29204,27 @@ class VectorStores extends APIResource2 {
28477
29204
  headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
28478
29205
  });
28479
29206
  }
28480
- }
28481
-
28482
- class VectorStoresPage extends CursorPage {
28483
- }
28484
- VectorStores.VectorStoresPage = VectorStoresPage;
28485
- VectorStores.Files = Files;
28486
- VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
28487
- VectorStores.FileBatches = FileBatches;
28488
-
28489
- // ../../node_modules/openai/resources/beta/beta.mjs
28490
- class Beta2 extends APIResource2 {
28491
- constructor() {
28492
- super(...arguments);
28493
- this.realtime = new Realtime(this._client);
28494
- this.vectorStores = new VectorStores(this._client);
28495
- this.chat = new Chat2(this._client);
28496
- this.assistants = new Assistants(this._client);
28497
- this.threads = new Threads(this._client);
28498
- }
28499
- }
28500
- Beta2.Realtime = Realtime;
28501
- Beta2.VectorStores = VectorStores;
28502
- Beta2.VectorStoresPage = VectorStoresPage;
28503
- Beta2.Assistants = Assistants;
28504
- Beta2.AssistantsPage = AssistantsPage;
28505
- Beta2.Threads = Threads;
28506
- // ../../node_modules/openai/resources/completions.mjs
28507
- class Completions4 extends APIResource2 {
28508
- create(body2, options) {
28509
- return this._client.post("/completions", { body: body2, ...options, stream: body2.stream ?? false });
28510
- }
28511
- }
28512
- // ../../node_modules/openai/resources/embeddings.mjs
28513
- class Embeddings extends APIResource2 {
28514
- create(body2, options) {
28515
- return this._client.post("/embeddings", { body: body2, ...options });
28516
- }
28517
- }
28518
- // ../../node_modules/openai/resources/files.mjs
28519
- class Files2 extends APIResource2 {
28520
- create(body2, options) {
28521
- return this._client.post("/files", multipartFormRequestOptions({ body: body2, ...options }));
28522
- }
28523
- retrieve(fileId, options) {
28524
- return this._client.get(`/files/${fileId}`, options);
28525
- }
28526
- list(query = {}, options) {
28527
- if (isRequestOptions2(query)) {
28528
- return this.list({}, query);
28529
- }
28530
- return this._client.getAPIList("/files", FileObjectsPage, { query, ...options });
28531
- }
28532
- del(fileId, options) {
28533
- return this._client.delete(`/files/${fileId}`, options);
28534
- }
28535
- content(fileId, options) {
28536
- return this._client.get(`/files/${fileId}/content`, {
29207
+ search(vectorStoreId, body2, options) {
29208
+ return this._client.getAPIList(`/vector_stores/${vectorStoreId}/search`, VectorStoreSearchResponsesPage, {
29209
+ body: body2,
29210
+ method: "post",
28537
29211
  ...options,
28538
- headers: { Accept: "application/binary", ...options?.headers },
28539
- __binaryResponse: true
28540
- });
28541
- }
28542
- retrieveContent(fileId, options) {
28543
- return this._client.get(`/files/${fileId}/content`, options);
28544
- }
28545
- async waitForProcessing(id, { pollInterval = 5000, maxWait = 30 * 60 * 1000 } = {}) {
28546
- const TERMINAL_STATES = new Set(["processed", "error", "deleted"]);
28547
- const start2 = Date.now();
28548
- let file = await this.retrieve(id);
28549
- while (!file.status || !TERMINAL_STATES.has(file.status)) {
28550
- await sleep2(pollInterval);
28551
- file = await this.retrieve(id);
28552
- if (Date.now() - start2 > maxWait) {
28553
- throw new APIConnectionTimeoutError2({
28554
- message: `Giving up on waiting for file ${id} to finish processing after ${maxWait} milliseconds.`
28555
- });
28556
- }
28557
- }
28558
- return file;
28559
- }
28560
- }
28561
-
28562
- class FileObjectsPage extends CursorPage {
28563
- }
28564
- Files2.FileObjectsPage = FileObjectsPage;
28565
- // ../../node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
28566
- class Checkpoints extends APIResource2 {
28567
- list(fineTuningJobId, query = {}, options) {
28568
- if (isRequestOptions2(query)) {
28569
- return this.list(fineTuningJobId, {}, query);
28570
- }
28571
- return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/checkpoints`, FineTuningJobCheckpointsPage, { query, ...options });
28572
- }
28573
- }
28574
-
28575
- class FineTuningJobCheckpointsPage extends CursorPage {
28576
- }
28577
- Checkpoints.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
28578
-
28579
- // ../../node_modules/openai/resources/fine-tuning/jobs/jobs.mjs
28580
- class Jobs extends APIResource2 {
28581
- constructor() {
28582
- super(...arguments);
28583
- this.checkpoints = new Checkpoints(this._client);
28584
- }
28585
- create(body2, options) {
28586
- return this._client.post("/fine_tuning/jobs", { body: body2, ...options });
28587
- }
28588
- retrieve(fineTuningJobId, options) {
28589
- return this._client.get(`/fine_tuning/jobs/${fineTuningJobId}`, options);
28590
- }
28591
- list(query = {}, options) {
28592
- if (isRequestOptions2(query)) {
28593
- return this.list({}, query);
28594
- }
28595
- return this._client.getAPIList("/fine_tuning/jobs", FineTuningJobsPage, { query, ...options });
28596
- }
28597
- cancel(fineTuningJobId, options) {
28598
- return this._client.post(`/fine_tuning/jobs/${fineTuningJobId}/cancel`, options);
28599
- }
28600
- listEvents(fineTuningJobId, query = {}, options) {
28601
- if (isRequestOptions2(query)) {
28602
- return this.listEvents(fineTuningJobId, {}, query);
28603
- }
28604
- return this._client.getAPIList(`/fine_tuning/jobs/${fineTuningJobId}/events`, FineTuningJobEventsPage, {
28605
- query,
28606
- ...options
29212
+ headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
28607
29213
  });
28608
29214
  }
28609
29215
  }
28610
29216
 
28611
- class FineTuningJobsPage extends CursorPage {
28612
- }
28613
-
28614
- class FineTuningJobEventsPage extends CursorPage {
28615
- }
28616
- Jobs.FineTuningJobsPage = FineTuningJobsPage;
28617
- Jobs.FineTuningJobEventsPage = FineTuningJobEventsPage;
28618
- Jobs.Checkpoints = Checkpoints;
28619
- Jobs.FineTuningJobCheckpointsPage = FineTuningJobCheckpointsPage;
28620
-
28621
- // ../../node_modules/openai/resources/fine-tuning/fine-tuning.mjs
28622
- class FineTuning extends APIResource2 {
28623
- constructor() {
28624
- super(...arguments);
28625
- this.jobs = new Jobs(this._client);
28626
- }
28627
- }
28628
- FineTuning.Jobs = Jobs;
28629
- FineTuning.FineTuningJobsPage = FineTuningJobsPage;
28630
- FineTuning.FineTuningJobEventsPage = FineTuningJobEventsPage;
28631
- // ../../node_modules/openai/resources/images.mjs
28632
- class Images extends APIResource2 {
28633
- createVariation(body2, options) {
28634
- return this._client.post("/images/variations", multipartFormRequestOptions({ body: body2, ...options }));
28635
- }
28636
- edit(body2, options) {
28637
- return this._client.post("/images/edits", multipartFormRequestOptions({ body: body2, ...options }));
28638
- }
28639
- generate(body2, options) {
28640
- return this._client.post("/images/generations", { body: body2, ...options });
28641
- }
28642
- }
28643
- // ../../node_modules/openai/resources/models.mjs
28644
- class Models3 extends APIResource2 {
28645
- retrieve(model, options) {
28646
- return this._client.get(`/models/${model}`, options);
28647
- }
28648
- list(options) {
28649
- return this._client.getAPIList("/models", ModelsPage, options);
28650
- }
28651
- del(model, options) {
28652
- return this._client.delete(`/models/${model}`, options);
28653
- }
28654
- }
28655
-
28656
- class ModelsPage extends Page2 {
28657
- }
28658
- Models3.ModelsPage = ModelsPage;
28659
- // ../../node_modules/openai/resources/moderations.mjs
28660
- class Moderations extends APIResource2 {
28661
- create(body2, options) {
28662
- return this._client.post("/moderations", { body: body2, ...options });
28663
- }
28664
- }
28665
- // ../../node_modules/openai/resources/uploads/parts.mjs
28666
- class Parts extends APIResource2 {
28667
- create(uploadId, body2, options) {
28668
- return this._client.post(`/uploads/${uploadId}/parts`, multipartFormRequestOptions({ body: body2, ...options }));
28669
- }
29217
+ class VectorStoresPage extends CursorPage {
28670
29218
  }
28671
29219
 
28672
- // ../../node_modules/openai/resources/uploads/uploads.mjs
28673
- class Uploads extends APIResource2 {
28674
- constructor() {
28675
- super(...arguments);
28676
- this.parts = new Parts(this._client);
28677
- }
28678
- create(body2, options) {
28679
- return this._client.post("/uploads", { body: body2, ...options });
28680
- }
28681
- cancel(uploadId, options) {
28682
- return this._client.post(`/uploads/${uploadId}/cancel`, options);
28683
- }
28684
- complete(uploadId, body2, options) {
28685
- return this._client.post(`/uploads/${uploadId}/complete`, { body: body2, ...options });
28686
- }
29220
+ class VectorStoreSearchResponsesPage extends Page2 {
28687
29221
  }
28688
- Uploads.Parts = Parts;
29222
+ VectorStores.VectorStoresPage = VectorStoresPage;
29223
+ VectorStores.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
29224
+ VectorStores.Files = Files2;
29225
+ VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
29226
+ VectorStores.FileContentResponsesPage = FileContentResponsesPage;
29227
+ VectorStores.FileBatches = FileBatches;
28689
29228
  // ../../node_modules/openai/index.mjs
28690
29229
  var _a2;
28691
29230
 
@@ -28723,15 +29262,17 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
28723
29262
  this.completions = new Completions4(this);
28724
29263
  this.chat = new Chat(this);
28725
29264
  this.embeddings = new Embeddings(this);
28726
- this.files = new Files2(this);
29265
+ this.files = new Files(this);
28727
29266
  this.images = new Images(this);
28728
29267
  this.audio = new Audio(this);
28729
29268
  this.moderations = new Moderations(this);
28730
29269
  this.models = new Models3(this);
28731
29270
  this.fineTuning = new FineTuning(this);
29271
+ this.vectorStores = new VectorStores(this);
28732
29272
  this.beta = new Beta2(this);
28733
29273
  this.batches = new Batches3(this);
28734
29274
  this.uploads = new Uploads(this);
29275
+ this.responses = new Responses(this);
28735
29276
  this._options = options;
28736
29277
  this.apiKey = apiKey;
28737
29278
  this.organization = organization;
@@ -28775,8 +29316,9 @@ OpenAI.toFile = toFile2;
28775
29316
  OpenAI.fileFromPath = fileFromPath4;
28776
29317
  OpenAI.Completions = Completions4;
28777
29318
  OpenAI.Chat = Chat;
29319
+ OpenAI.ChatCompletionsPage = ChatCompletionsPage;
28778
29320
  OpenAI.Embeddings = Embeddings;
28779
- OpenAI.Files = Files2;
29321
+ OpenAI.Files = Files;
28780
29322
  OpenAI.FileObjectsPage = FileObjectsPage;
28781
29323
  OpenAI.Images = Images;
28782
29324
  OpenAI.Audio = Audio;
@@ -28784,10 +29326,14 @@ OpenAI.Moderations = Moderations;
28784
29326
  OpenAI.Models = Models3;
28785
29327
  OpenAI.ModelsPage = ModelsPage;
28786
29328
  OpenAI.FineTuning = FineTuning;
29329
+ OpenAI.VectorStores = VectorStores;
29330
+ OpenAI.VectorStoresPage = VectorStoresPage;
29331
+ OpenAI.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
28787
29332
  OpenAI.Beta = Beta2;
28788
29333
  OpenAI.Batches = Batches3;
28789
29334
  OpenAI.BatchesPage = BatchesPage;
28790
29335
  OpenAI.Uploads = Uploads;
29336
+ OpenAI.Responses = Responses;
28791
29337
  var _deployments_endpoints = new Set([
28792
29338
  "/completions",
28793
29339
  "/chat/completions",
@@ -30659,6 +31205,7 @@ ${agents}`;
30659
31205
  }
30660
31206
  async#handleResponse(response) {
30661
31207
  const toolReponses = [];
31208
+ let hasPause = false;
30662
31209
  outer:
30663
31210
  for (const content of response) {
30664
31211
  switch (content.type) {
@@ -30670,7 +31217,7 @@ ${agents}`;
30670
31217
  switch (toolResp.type) {
30671
31218
  case "Reply" /* Reply */:
30672
31219
  await this.#callback({ kind: "ToolReply" /* ToolReply */, agent: this, tool: content.name });
30673
- toolReponses.push({ tool: content.name, response: toolResp.message });
31220
+ toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
30674
31221
  break;
30675
31222
  case "Exit" /* Exit */:
30676
31223
  if (toolReponses.length > 0) {
@@ -30679,11 +31226,11 @@ ${agents}`;
30679
31226
  return { type: "exit", reason: toolResp };
30680
31227
  case "Invalid" /* Invalid */:
30681
31228
  await this.#callback({ kind: "ToolInvalid" /* ToolInvalid */, agent: this, tool: content.name });
30682
- toolReponses.push({ tool: content.name, response: toolResp.message });
31229
+ toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
30683
31230
  break outer;
30684
31231
  case "Error" /* Error */:
30685
31232
  await this.#callback({ kind: "ToolError" /* ToolError */, agent: this, tool: content.name });
30686
- toolReponses.push({ tool: content.name, response: toolResp.message });
31233
+ toolReponses.push({ type: "response", tool: content.name, response: toolResp.message });
30687
31234
  break outer;
30688
31235
  case "Interrupted" /* Interrupted */:
30689
31236
  await this.#callback({ kind: "ToolInterrupted" /* ToolInterrupted */, agent: this, tool: content.name });
@@ -30728,15 +31275,23 @@ ${agents}`;
30728
31275
  });
30729
31276
  return { type: "exit", reason: delegateResp };
30730
31277
  }
31278
+ case "Pause" /* Pause */: {
31279
+ await this.#callback({ kind: "ToolPause" /* ToolPause */, agent: this, tool: content.name, object: toolResp.object });
31280
+ toolReponses.push({ type: "pause", tool: content.name, object: toolResp.object });
31281
+ hasPause = true;
31282
+ }
30731
31283
  }
30732
31284
  break;
30733
31285
  }
30734
31286
  }
30735
31287
  }
31288
+ if (hasPause) {
31289
+ return { type: "exit", reason: { type: "Pause", responses: toolReponses } };
31290
+ }
30736
31291
  if (toolReponses.length === 0) {
30737
31292
  return { type: "reply", message: responsePrompts.requireUseTool };
30738
31293
  }
30739
- const finalResp = toolReponses.map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
31294
+ const finalResp = toolReponses.filter((resp) => resp.type === "response").map(({ tool, response: response2 }) => responsePrompts.toolResults(tool, response2)).join(`
30740
31295
 
30741
31296
  `);
30742
31297
  return { type: "reply", message: finalResp };
@@ -31375,10 +31930,10 @@ var util;
31375
31930
  util2.assertEqual = (val) => val;
31376
31931
  function assertIs(_arg) {}
31377
31932
  util2.assertIs = assertIs;
31378
- function assertNever2(_x) {
31933
+ function assertNever3(_x) {
31379
31934
  throw new Error;
31380
31935
  }
31381
- util2.assertNever = assertNever2;
31936
+ util2.assertNever = assertNever3;
31382
31937
  util2.arrayToEnum = (items) => {
31383
31938
  const obj = {};
31384
31939
  for (const item of items) {
@@ -31825,14 +32380,14 @@ var isAborted = (x2) => x2.status === "aborted";
31825
32380
  var isDirty = (x2) => x2.status === "dirty";
31826
32381
  var isValid = (x2) => x2.status === "valid";
31827
32382
  var isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
31828
- function __classPrivateFieldGet15(receiver, state, kind3, f2) {
32383
+ function __classPrivateFieldGet17(receiver, state, kind3, f2) {
31829
32384
  if (kind3 === "a" && !f2)
31830
32385
  throw new TypeError("Private accessor was defined without a getter");
31831
32386
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
31832
32387
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
31833
32388
  return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
31834
32389
  }
31835
- function __classPrivateFieldSet13(receiver, state, value, kind3, f2) {
32390
+ function __classPrivateFieldSet15(receiver, state, value, kind3, f2) {
31836
32391
  if (kind3 === "m")
31837
32392
  throw new TypeError("Private method is not writable");
31838
32393
  if (kind3 === "a" && !f2)
@@ -34632,10 +35187,10 @@ class ZodEnum extends ZodType {
34632
35187
  });
34633
35188
  return INVALID;
34634
35189
  }
34635
- if (!__classPrivateFieldGet15(this, _ZodEnum_cache, "f")) {
34636
- __classPrivateFieldSet13(this, _ZodEnum_cache, new Set(this._def.values), "f");
35190
+ if (!__classPrivateFieldGet17(this, _ZodEnum_cache, "f")) {
35191
+ __classPrivateFieldSet15(this, _ZodEnum_cache, new Set(this._def.values), "f");
34637
35192
  }
34638
- if (!__classPrivateFieldGet15(this, _ZodEnum_cache, "f").has(input.data)) {
35193
+ if (!__classPrivateFieldGet17(this, _ZodEnum_cache, "f").has(input.data)) {
34639
35194
  const ctx = this._getOrReturnCtx(input);
34640
35195
  const expectedValues = this._def.values;
34641
35196
  addIssueToContext(ctx, {
@@ -34704,10 +35259,10 @@ class ZodNativeEnum extends ZodType {
34704
35259
  });
34705
35260
  return INVALID;
34706
35261
  }
34707
- if (!__classPrivateFieldGet15(this, _ZodNativeEnum_cache, "f")) {
34708
- __classPrivateFieldSet13(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
35262
+ if (!__classPrivateFieldGet17(this, _ZodNativeEnum_cache, "f")) {
35263
+ __classPrivateFieldSet15(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
34709
35264
  }
34710
- if (!__classPrivateFieldGet15(this, _ZodNativeEnum_cache, "f").has(input.data)) {
35265
+ if (!__classPrivateFieldGet17(this, _ZodNativeEnum_cache, "f").has(input.data)) {
34711
35266
  const expectedValues = util.objectValues(nativeEnumValues);
34712
35267
  addIssueToContext(ctx, {
34713
35268
  received: ctx.data,
@@ -35470,10 +36025,10 @@ var util2;
35470
36025
  util3.assertEqual = (val) => val;
35471
36026
  function assertIs(_arg) {}
35472
36027
  util3.assertIs = assertIs;
35473
- function assertNever2(_x) {
36028
+ function assertNever3(_x) {
35474
36029
  throw new Error;
35475
36030
  }
35476
- util3.assertNever = assertNever2;
36031
+ util3.assertNever = assertNever3;
35477
36032
  util3.arrayToEnum = (items) => {
35478
36033
  const obj = {};
35479
36034
  for (const item of items) {
@@ -35911,14 +36466,14 @@ var isAborted2 = (x2) => x2.status === "aborted";
35911
36466
  var isDirty2 = (x2) => x2.status === "dirty";
35912
36467
  var isValid2 = (x2) => x2.status === "valid";
35913
36468
  var isAsync2 = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
35914
- function __classPrivateFieldGet16(receiver, state, kind3, f2) {
36469
+ function __classPrivateFieldGet18(receiver, state, kind3, f2) {
35915
36470
  if (kind3 === "a" && !f2)
35916
36471
  throw new TypeError("Private accessor was defined without a getter");
35917
36472
  if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
35918
36473
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
35919
36474
  return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
35920
36475
  }
35921
- function __classPrivateFieldSet14(receiver, state, value, kind3, f2) {
36476
+ function __classPrivateFieldSet16(receiver, state, value, kind3, f2) {
35922
36477
  if (kind3 === "m")
35923
36478
  throw new TypeError("Private method is not writable");
35924
36479
  if (kind3 === "a" && !f2)
@@ -38718,10 +39273,10 @@ class ZodEnum2 extends ZodType2 {
38718
39273
  });
38719
39274
  return INVALID2;
38720
39275
  }
38721
- if (!__classPrivateFieldGet16(this, _ZodEnum_cache2, "f")) {
38722
- __classPrivateFieldSet14(this, _ZodEnum_cache2, new Set(this._def.values), "f");
39276
+ if (!__classPrivateFieldGet18(this, _ZodEnum_cache2, "f")) {
39277
+ __classPrivateFieldSet16(this, _ZodEnum_cache2, new Set(this._def.values), "f");
38723
39278
  }
38724
- if (!__classPrivateFieldGet16(this, _ZodEnum_cache2, "f").has(input.data)) {
39279
+ if (!__classPrivateFieldGet18(this, _ZodEnum_cache2, "f").has(input.data)) {
38725
39280
  const ctx = this._getOrReturnCtx(input);
38726
39281
  const expectedValues = this._def.values;
38727
39282
  addIssueToContext2(ctx, {
@@ -38790,10 +39345,10 @@ class ZodNativeEnum2 extends ZodType2 {
38790
39345
  });
38791
39346
  return INVALID2;
38792
39347
  }
38793
- if (!__classPrivateFieldGet16(this, _ZodNativeEnum_cache2, "f")) {
38794
- __classPrivateFieldSet14(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
39348
+ if (!__classPrivateFieldGet18(this, _ZodNativeEnum_cache2, "f")) {
39349
+ __classPrivateFieldSet16(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
38795
39350
  }
38796
- if (!__classPrivateFieldGet16(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
39351
+ if (!__classPrivateFieldGet18(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
38797
39352
  const expectedValues = util2.objectValues(nativeEnumValues);
38798
39353
  addIssueToContext2(ctx, {
38799
39354
  received: ctx.data,
@@ -39403,7 +39958,7 @@ import { dirname } from "node:path";
39403
39958
  var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
39404
39959
  var isDownKey = (key) => key.name === "down" || key.name === "j" || key.ctrl && key.name === "n";
39405
39960
  var isBackspaceKey = (key) => key.name === "backspace";
39406
- var isNumberKey = (key) => "123456789".includes(key.name);
39961
+ var isNumberKey = (key) => "1234567890".includes(key.name);
39407
39962
  var isEnterKey = (key) => key.name === "enter" || key.name === "return";
39408
39963
  // ../../node_modules/@inquirer/core/dist/esm/lib/errors.js
39409
39964
  class AbortPromptError extends Error {
@@ -40287,8 +40842,8 @@ var {
40287
40842
  } = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
40288
40843
 
40289
40844
  // ../../node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
40290
- var import_strip_ansi = __toESM(require_strip_ansi(), 1);
40291
40845
  var import_ansi_escapes = __toESM(require_ansi_escapes(), 1);
40846
+ import { stripVTControlCharacters } from "node:util";
40292
40847
  var height = (content) => content.split(`
40293
40848
  `).length;
40294
40849
  var lastLine = (content) => content.split(`
@@ -40298,12 +40853,11 @@ function cursorDown(n2) {
40298
40853
  }
40299
40854
 
40300
40855
  class ScreenManager {
40301
- rl;
40302
40856
  height = 0;
40303
40857
  extraLinesUnderPrompt = 0;
40304
40858
  cursorPos;
40859
+ rl;
40305
40860
  constructor(rl) {
40306
- this.rl = rl;
40307
40861
  this.rl = rl;
40308
40862
  this.cursorPos = rl.getCursorPos();
40309
40863
  }
@@ -40314,7 +40868,7 @@ class ScreenManager {
40314
40868
  }
40315
40869
  render(content, bottomContent = "") {
40316
40870
  const promptLine = lastLine(content);
40317
- const rawPromptLine = import_strip_ansi.default(promptLine);
40871
+ const rawPromptLine = stripVTControlCharacters(promptLine);
40318
40872
  let prompt5 = rawPromptLine;
40319
40873
  if (this.rl.line.length > 0) {
40320
40874
  prompt5 = prompt5.slice(0, -this.rl.line.length);
@@ -40373,22 +40927,22 @@ class PromisePolyfill extends Promise {
40373
40927
  // ../../node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
40374
40928
  function getCallSites() {
40375
40929
  const _prepareStackTrace = Error.prepareStackTrace;
40930
+ let result = [];
40376
40931
  try {
40377
- let result = [];
40378
40932
  Error.prepareStackTrace = (_2, callSites) => {
40379
40933
  const callSitesWithoutCurrent = callSites.slice(1);
40380
40934
  result = callSitesWithoutCurrent;
40381
40935
  return callSitesWithoutCurrent;
40382
40936
  };
40383
40937
  new Error().stack;
40938
+ } catch {
40384
40939
  return result;
40385
- } finally {
40386
- Error.prepareStackTrace = _prepareStackTrace;
40387
40940
  }
40941
+ Error.prepareStackTrace = _prepareStackTrace;
40942
+ return result;
40388
40943
  }
40389
40944
  function createPrompt(view) {
40390
40945
  const callSites = getCallSites();
40391
- const callerFilename = callSites[1]?.getFileName?.();
40392
40946
  const prompt5 = (config2, context = {}) => {
40393
40947
  const { input = process.stdin, signal } = context;
40394
40948
  const cleanups = new Set;
@@ -40427,6 +40981,7 @@ function createPrompt(view) {
40427
40981
  setImmediate(() => resolve(value));
40428
40982
  });
40429
40983
  if (nextView === undefined) {
40984
+ const callerFilename = callSites[1]?.getFileName?.();
40430
40985
  throw new Error(`Prompt functions must return a string.
40431
40986
  at ${callerFilename}`);
40432
40987
  }
@@ -40540,7 +41095,8 @@ var selectTheme = {
40540
41095
  disabled: (text) => import_yoctocolors_cjs3.default.dim(`- ${text}`),
40541
41096
  description: (text) => import_yoctocolors_cjs3.default.cyan(text)
40542
41097
  },
40543
- helpMode: "auto"
41098
+ helpMode: "auto",
41099
+ indexMode: "hidden"
40544
41100
  };
40545
41101
  function isSelectable(item) {
40546
41102
  return !Separator.isSeparator(item) && !item.disabled;
@@ -40605,13 +41161,15 @@ var esm_default3 = createPrompt((config2, done) => {
40605
41161
  } while (!isSelectable(items[next]));
40606
41162
  setActive(next);
40607
41163
  }
40608
- } else if (isNumberKey(key2)) {
40609
- rl.clearLine(0);
40610
- const position = Number(key2.name) - 1;
41164
+ } else if (isNumberKey(key2) && !Number.isNaN(Number(rl.line))) {
41165
+ const position = Number(rl.line) - 1;
40611
41166
  const item = items[position];
40612
41167
  if (item != null && isSelectable(item)) {
40613
41168
  setActive(position);
40614
41169
  }
41170
+ searchTimeoutRef.current = setTimeout(() => {
41171
+ rl.clearLine(0);
41172
+ }, 700);
40615
41173
  } else if (isBackspaceKey(key2)) {
40616
41174
  rl.clearLine(0);
40617
41175
  } else {
@@ -40647,17 +41205,18 @@ ${theme.style.help("(Use arrow keys to reveal more choices)")}`;
40647
41205
  const page = usePagination({
40648
41206
  items,
40649
41207
  active,
40650
- renderItem({ item, isActive }) {
41208
+ renderItem({ item, isActive, index }) {
40651
41209
  if (Separator.isSeparator(item)) {
40652
41210
  return ` ${item.separator}`;
40653
41211
  }
41212
+ const indexLabel = theme.indexMode === "number" ? `${index + 1}. ` : "";
40654
41213
  if (item.disabled) {
40655
41214
  const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
40656
- return theme.style.disabled(`${item.name} ${disabledLabel}`);
41215
+ return theme.style.disabled(`${indexLabel}${item.name} ${disabledLabel}`);
40657
41216
  }
40658
41217
  const color = isActive ? theme.style.highlight : (x2) => x2;
40659
41218
  const cursor = isActive ? theme.icon.cursor : ` `;
40660
- return color(`${cursor} ${item.name}`);
41219
+ return color(`${cursor} ${indexLabel}${item.name}`);
40661
41220
  },
40662
41221
  pageSize,
40663
41222
  loop