@polka-codes/cli 0.7.18 → 0.7.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1070 -520
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -21407,7 +21407,7 @@ var require_cli_width = __commonJS((exports, module2) => {
|
|
|
21407
21407
|
}
|
|
21408
21408
|
});
|
|
21409
21409
|
|
|
21410
|
-
// ../../node_modules/@inquirer/core/node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
21410
|
+
// ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/strip-ansi/node_modules/ansi-regex/index.js
|
|
21411
21411
|
var require_ansi_regex = __commonJS((exports, module2) => {
|
|
21412
21412
|
module2.exports = ({ onlyFirst = false } = {}) => {
|
|
21413
21413
|
const pattern = [
|
|
@@ -21418,13 +21418,13 @@ var require_ansi_regex = __commonJS((exports, module2) => {
|
|
|
21418
21418
|
};
|
|
21419
21419
|
});
|
|
21420
21420
|
|
|
21421
|
-
// ../../node_modules/@inquirer/core/node_modules/strip-ansi/index.js
|
|
21421
|
+
// ../../node_modules/@inquirer/core/node_modules/wrap-ansi/node_modules/strip-ansi/index.js
|
|
21422
21422
|
var require_strip_ansi = __commonJS((exports, module2) => {
|
|
21423
21423
|
var ansiRegex = require_ansi_regex();
|
|
21424
21424
|
module2.exports = (string) => typeof string === "string" ? string.replace(ansiRegex(), "") : string;
|
|
21425
21425
|
});
|
|
21426
21426
|
|
|
21427
|
-
// ../../node_modules
|
|
21427
|
+
// ../../node_modules/is-fullwidth-code-point/index.js
|
|
21428
21428
|
var require_is_fullwidth_code_point = __commonJS((exports, module2) => {
|
|
21429
21429
|
var isFullwidthCodePoint = (codePoint) => {
|
|
21430
21430
|
if (Number.isNaN(codePoint)) {
|
|
@@ -22428,7 +22428,7 @@ var require_color_convert = __commonJS((exports, module2) => {
|
|
|
22428
22428
|
module2.exports = convert;
|
|
22429
22429
|
});
|
|
22430
22430
|
|
|
22431
|
-
// ../../node_modules
|
|
22431
|
+
// ../../node_modules/ansi-styles/index.js
|
|
22432
22432
|
var require_ansi_styles = __commonJS((exports, module2) => {
|
|
22433
22433
|
var wrapAnsi16 = (fn, offset) => (...args2) => {
|
|
22434
22434
|
const code = fn(...args2);
|
|
@@ -24604,7 +24604,7 @@ var {
|
|
|
24604
24604
|
Help
|
|
24605
24605
|
} = import__.default;
|
|
24606
24606
|
// package.json
|
|
24607
|
-
var version = "0.7.
|
|
24607
|
+
var version = "0.7.19";
|
|
24608
24608
|
|
|
24609
24609
|
// ../core/src/AiService/AiServiceBase.ts
|
|
24610
24610
|
class AiServiceBase {
|
|
@@ -28567,7 +28567,7 @@ function stringify(object, opts = {}) {
|
|
|
28567
28567
|
return joined.length > 0 ? prefix + joined : "";
|
|
28568
28568
|
}
|
|
28569
28569
|
// ../../node_modules/openai/version.mjs
|
|
28570
|
-
var VERSION2 = "4.
|
|
28570
|
+
var VERSION2 = "4.89.1";
|
|
28571
28571
|
|
|
28572
28572
|
// ../../node_modules/openai/_shims/registry.mjs
|
|
28573
28573
|
var auto2 = false;
|
|
@@ -28792,39 +28792,57 @@ class ContentFilterFinishReasonError extends OpenAIError {
|
|
|
28792
28792
|
}
|
|
28793
28793
|
|
|
28794
28794
|
// ../../node_modules/openai/internal/decoders/line.mjs
|
|
28795
|
+
var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
|
|
28796
|
+
if (kind3 === "m")
|
|
28797
|
+
throw new TypeError("Private method is not writable");
|
|
28798
|
+
if (kind3 === "a" && !f2)
|
|
28799
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
28800
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
28801
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
28802
|
+
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
28803
|
+
};
|
|
28804
|
+
var __classPrivateFieldGet10 = function(receiver, state, kind3, f2) {
|
|
28805
|
+
if (kind3 === "a" && !f2)
|
|
28806
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
28807
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
28808
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
28809
|
+
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
28810
|
+
};
|
|
28811
|
+
var _LineDecoder_carriageReturnIndex2;
|
|
28812
|
+
|
|
28795
28813
|
class LineDecoder2 {
|
|
28796
28814
|
constructor() {
|
|
28797
|
-
this
|
|
28798
|
-
this.
|
|
28815
|
+
_LineDecoder_carriageReturnIndex2.set(this, undefined);
|
|
28816
|
+
this.buffer = new Uint8Array;
|
|
28817
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
|
|
28799
28818
|
}
|
|
28800
28819
|
decode(chunk) {
|
|
28801
|
-
|
|
28802
|
-
if (this.trailingCR) {
|
|
28803
|
-
text = "\r" + text;
|
|
28804
|
-
this.trailingCR = false;
|
|
28805
|
-
}
|
|
28806
|
-
if (text.endsWith("\r")) {
|
|
28807
|
-
this.trailingCR = true;
|
|
28808
|
-
text = text.slice(0, -1);
|
|
28809
|
-
}
|
|
28810
|
-
if (!text) {
|
|
28811
|
-
return [];
|
|
28812
|
-
}
|
|
28813
|
-
const trailingNewline = LineDecoder2.NEWLINE_CHARS.has(text[text.length - 1] || "");
|
|
28814
|
-
let lines = text.split(LineDecoder2.NEWLINE_REGEXP);
|
|
28815
|
-
if (trailingNewline) {
|
|
28816
|
-
lines.pop();
|
|
28817
|
-
}
|
|
28818
|
-
if (lines.length === 1 && !trailingNewline) {
|
|
28819
|
-
this.buffer.push(lines[0]);
|
|
28820
|
+
if (chunk == null) {
|
|
28820
28821
|
return [];
|
|
28821
28822
|
}
|
|
28822
|
-
|
|
28823
|
-
|
|
28824
|
-
|
|
28825
|
-
|
|
28826
|
-
|
|
28827
|
-
|
|
28823
|
+
const binaryChunk = chunk instanceof ArrayBuffer ? new Uint8Array(chunk) : typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
|
|
28824
|
+
let newData = new Uint8Array(this.buffer.length + binaryChunk.length);
|
|
28825
|
+
newData.set(this.buffer);
|
|
28826
|
+
newData.set(binaryChunk, this.buffer.length);
|
|
28827
|
+
this.buffer = newData;
|
|
28828
|
+
const lines = [];
|
|
28829
|
+
let patternIndex;
|
|
28830
|
+
while ((patternIndex = findNewlineIndex2(this.buffer, __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f"))) != null) {
|
|
28831
|
+
if (patternIndex.carriage && __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") == null) {
|
|
28832
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, patternIndex.index, "f");
|
|
28833
|
+
continue;
|
|
28834
|
+
}
|
|
28835
|
+
if (__classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") != null && (patternIndex.index !== __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") + 1 || patternIndex.carriage)) {
|
|
28836
|
+
lines.push(this.decodeText(this.buffer.slice(0, __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") - 1)));
|
|
28837
|
+
this.buffer = this.buffer.slice(__classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f"));
|
|
28838
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
|
|
28839
|
+
continue;
|
|
28840
|
+
}
|
|
28841
|
+
const endIndex = __classPrivateFieldGet10(this, _LineDecoder_carriageReturnIndex2, "f") !== null ? patternIndex.preceding - 1 : patternIndex.preceding;
|
|
28842
|
+
const line = this.decodeText(this.buffer.slice(0, endIndex));
|
|
28843
|
+
lines.push(line);
|
|
28844
|
+
this.buffer = this.buffer.slice(patternIndex.index);
|
|
28845
|
+
__classPrivateFieldSet9(this, _LineDecoder_carriageReturnIndex2, null, "f");
|
|
28828
28846
|
}
|
|
28829
28847
|
return lines;
|
|
28830
28848
|
}
|
|
@@ -28852,18 +28870,46 @@ class LineDecoder2 {
|
|
|
28852
28870
|
throw new OpenAIError(`Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.`);
|
|
28853
28871
|
}
|
|
28854
28872
|
flush() {
|
|
28855
|
-
if (!this.buffer.length
|
|
28873
|
+
if (!this.buffer.length) {
|
|
28856
28874
|
return [];
|
|
28857
28875
|
}
|
|
28858
|
-
|
|
28859
|
-
|
|
28860
|
-
this.trailingCR = false;
|
|
28861
|
-
return lines;
|
|
28876
|
+
return this.decode(`
|
|
28877
|
+
`);
|
|
28862
28878
|
}
|
|
28863
28879
|
}
|
|
28880
|
+
_LineDecoder_carriageReturnIndex2 = new WeakMap;
|
|
28864
28881
|
LineDecoder2.NEWLINE_CHARS = new Set([`
|
|
28865
28882
|
`, "\r"]);
|
|
28866
28883
|
LineDecoder2.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
28884
|
+
function findNewlineIndex2(buffer, startIndex) {
|
|
28885
|
+
const newline = 10;
|
|
28886
|
+
const carriage = 13;
|
|
28887
|
+
for (let i3 = startIndex ?? 0;i3 < buffer.length; i3++) {
|
|
28888
|
+
if (buffer[i3] === newline) {
|
|
28889
|
+
return { preceding: i3, index: i3 + 1, carriage: false };
|
|
28890
|
+
}
|
|
28891
|
+
if (buffer[i3] === carriage) {
|
|
28892
|
+
return { preceding: i3, index: i3 + 1, carriage: true };
|
|
28893
|
+
}
|
|
28894
|
+
}
|
|
28895
|
+
return null;
|
|
28896
|
+
}
|
|
28897
|
+
function findDoubleNewlineIndex2(buffer) {
|
|
28898
|
+
const newline = 10;
|
|
28899
|
+
const carriage = 13;
|
|
28900
|
+
for (let i3 = 0;i3 < buffer.length - 1; i3++) {
|
|
28901
|
+
if (buffer[i3] === newline && buffer[i3 + 1] === newline) {
|
|
28902
|
+
return i3 + 2;
|
|
28903
|
+
}
|
|
28904
|
+
if (buffer[i3] === carriage && buffer[i3 + 1] === carriage) {
|
|
28905
|
+
return i3 + 2;
|
|
28906
|
+
}
|
|
28907
|
+
if (buffer[i3] === carriage && buffer[i3 + 1] === newline && i3 + 3 < buffer.length && buffer[i3 + 2] === carriage && buffer[i3 + 3] === newline) {
|
|
28908
|
+
return i3 + 4;
|
|
28909
|
+
}
|
|
28910
|
+
}
|
|
28911
|
+
return -1;
|
|
28912
|
+
}
|
|
28867
28913
|
|
|
28868
28914
|
// ../../node_modules/openai/internal/stream-utils.mjs
|
|
28869
28915
|
function ReadableStreamToAsyncIterable2(stream) {
|
|
@@ -28916,7 +28962,7 @@ class Stream2 {
|
|
|
28916
28962
|
done = true;
|
|
28917
28963
|
continue;
|
|
28918
28964
|
}
|
|
28919
|
-
if (sse.event === null) {
|
|
28965
|
+
if (sse.event === null || sse.event.startsWith("response.")) {
|
|
28920
28966
|
let data;
|
|
28921
28967
|
try {
|
|
28922
28968
|
data = JSON.parse(sse.data);
|
|
@@ -29087,22 +29133,6 @@ async function* iterSSEChunks2(iterator) {
|
|
|
29087
29133
|
yield data;
|
|
29088
29134
|
}
|
|
29089
29135
|
}
|
|
29090
|
-
function findDoubleNewlineIndex2(buffer) {
|
|
29091
|
-
const newline = 10;
|
|
29092
|
-
const carriage = 13;
|
|
29093
|
-
for (let i3 = 0;i3 < buffer.length - 2; i3++) {
|
|
29094
|
-
if (buffer[i3] === newline && buffer[i3 + 1] === newline) {
|
|
29095
|
-
return i3 + 2;
|
|
29096
|
-
}
|
|
29097
|
-
if (buffer[i3] === carriage && buffer[i3 + 1] === carriage) {
|
|
29098
|
-
return i3 + 2;
|
|
29099
|
-
}
|
|
29100
|
-
if (buffer[i3] === carriage && buffer[i3 + 1] === newline && i3 + 3 < buffer.length && buffer[i3 + 2] === carriage && buffer[i3 + 3] === newline) {
|
|
29101
|
-
return i3 + 4;
|
|
29102
|
-
}
|
|
29103
|
-
}
|
|
29104
|
-
return -1;
|
|
29105
|
-
}
|
|
29106
29136
|
|
|
29107
29137
|
class SSEDecoder2 {
|
|
29108
29138
|
constructor() {
|
|
@@ -29241,7 +29271,7 @@ var addFormValue = async (form, key, value) => {
|
|
|
29241
29271
|
};
|
|
29242
29272
|
|
|
29243
29273
|
// ../../node_modules/openai/core.mjs
|
|
29244
|
-
var
|
|
29274
|
+
var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
|
|
29245
29275
|
if (kind3 === "m")
|
|
29246
29276
|
throw new TypeError("Private method is not writable");
|
|
29247
29277
|
if (kind3 === "a" && !f2)
|
|
@@ -29250,7 +29280,7 @@ var __classPrivateFieldSet9 = function(receiver, state, value, kind3, f2) {
|
|
|
29250
29280
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
29251
29281
|
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
29252
29282
|
};
|
|
29253
|
-
var
|
|
29283
|
+
var __classPrivateFieldGet11 = function(receiver, state, kind3, f2) {
|
|
29254
29284
|
if (kind3 === "a" && !f2)
|
|
29255
29285
|
throw new TypeError("Private accessor was defined without a getter");
|
|
29256
29286
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -29274,7 +29304,8 @@ async function defaultParseResponse2(props) {
|
|
|
29274
29304
|
return response;
|
|
29275
29305
|
}
|
|
29276
29306
|
const contentType = response.headers.get("content-type");
|
|
29277
|
-
const
|
|
29307
|
+
const mediaType = contentType?.split(";")[0]?.trim();
|
|
29308
|
+
const isJSON = mediaType?.includes("application/json") || mediaType?.endsWith("+json");
|
|
29278
29309
|
if (isJSON) {
|
|
29279
29310
|
const json = await response.json();
|
|
29280
29311
|
debug2("response", response.status, response.url, response.headers, json);
|
|
@@ -29399,15 +29430,16 @@ class APIClient2 {
|
|
|
29399
29430
|
return null;
|
|
29400
29431
|
}
|
|
29401
29432
|
buildRequest(options, { retryCount = 0 } = {}) {
|
|
29433
|
+
options = { ...options };
|
|
29402
29434
|
const { method, path, query, headers = {} } = options;
|
|
29403
29435
|
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;
|
|
29404
29436
|
const contentLength = this.calculateContentLength(body2);
|
|
29405
29437
|
const url = this.buildURL(path, query);
|
|
29406
29438
|
if ("timeout" in options)
|
|
29407
29439
|
validatePositiveInteger2("timeout", options.timeout);
|
|
29408
|
-
|
|
29440
|
+
options.timeout = options.timeout ?? this.timeout;
|
|
29409
29441
|
const httpAgent = options.httpAgent ?? this.httpAgent ?? getDefaultAgent2(url);
|
|
29410
|
-
const minAgentTimeout = timeout + 1000;
|
|
29442
|
+
const minAgentTimeout = options.timeout + 1000;
|
|
29411
29443
|
if (typeof httpAgent?.options?.timeout === "number" && minAgentTimeout > (httpAgent.options.timeout ?? 0)) {
|
|
29412
29444
|
httpAgent.options.timeout = minAgentTimeout;
|
|
29413
29445
|
}
|
|
@@ -29424,7 +29456,7 @@ class APIClient2 {
|
|
|
29424
29456
|
...httpAgent && { agent: httpAgent },
|
|
29425
29457
|
signal: options.signal ?? null
|
|
29426
29458
|
};
|
|
29427
|
-
return { req, url, timeout };
|
|
29459
|
+
return { req, url, timeout: options.timeout };
|
|
29428
29460
|
}
|
|
29429
29461
|
buildHeaders({ options, headers, contentLength, retryCount }) {
|
|
29430
29462
|
const reqHeaders = {};
|
|
@@ -29440,6 +29472,9 @@ class APIClient2 {
|
|
|
29440
29472
|
if (getHeader2(defaultHeaders, "x-stainless-retry-count") === undefined && getHeader2(headers, "x-stainless-retry-count") === undefined) {
|
|
29441
29473
|
reqHeaders["x-stainless-retry-count"] = String(retryCount);
|
|
29442
29474
|
}
|
|
29475
|
+
if (getHeader2(defaultHeaders, "x-stainless-timeout") === undefined && getHeader2(headers, "x-stainless-timeout") === undefined && options.timeout) {
|
|
29476
|
+
reqHeaders["x-stainless-timeout"] = String(options.timeout);
|
|
29477
|
+
}
|
|
29443
29478
|
this.validateHeaders(reqHeaders, headers);
|
|
29444
29479
|
return reqHeaders;
|
|
29445
29480
|
}
|
|
@@ -29597,7 +29632,7 @@ class APIClient2 {
|
|
|
29597
29632
|
class AbstractPage2 {
|
|
29598
29633
|
constructor(client, response, body2, options) {
|
|
29599
29634
|
_AbstractPage_client2.set(this, undefined);
|
|
29600
|
-
|
|
29635
|
+
__classPrivateFieldSet10(this, _AbstractPage_client2, client, "f");
|
|
29601
29636
|
this.options = options;
|
|
29602
29637
|
this.response = response;
|
|
29603
29638
|
this.body = body2;
|
|
@@ -29624,7 +29659,7 @@ class AbstractPage2 {
|
|
|
29624
29659
|
nextOptions.query = undefined;
|
|
29625
29660
|
nextOptions.path = nextInfo.url.toString();
|
|
29626
29661
|
}
|
|
29627
|
-
return await
|
|
29662
|
+
return await __classPrivateFieldGet11(this, _AbstractPage_client2, "f").requestAPIList(this.constructor, nextOptions);
|
|
29628
29663
|
}
|
|
29629
29664
|
async* iterPages() {
|
|
29630
29665
|
let page = this;
|
|
@@ -29674,6 +29709,7 @@ var requestOptionsKeys2 = {
|
|
|
29674
29709
|
httpAgent: true,
|
|
29675
29710
|
signal: true,
|
|
29676
29711
|
idempotencyKey: true,
|
|
29712
|
+
__metadata: true,
|
|
29677
29713
|
__binaryRequest: true,
|
|
29678
29714
|
__binaryResponse: true,
|
|
29679
29715
|
__streamClass: true
|
|
@@ -29948,10 +29984,17 @@ class CursorPage extends AbstractPage2 {
|
|
|
29948
29984
|
constructor(client, response, body2, options) {
|
|
29949
29985
|
super(client, response, body2, options);
|
|
29950
29986
|
this.data = body2.data || [];
|
|
29987
|
+
this.has_more = body2.has_more || false;
|
|
29951
29988
|
}
|
|
29952
29989
|
getPaginatedItems() {
|
|
29953
29990
|
return this.data ?? [];
|
|
29954
29991
|
}
|
|
29992
|
+
hasNextPage() {
|
|
29993
|
+
if (this.has_more === false) {
|
|
29994
|
+
return false;
|
|
29995
|
+
}
|
|
29996
|
+
return super.hasNextPage();
|
|
29997
|
+
}
|
|
29955
29998
|
nextPageParams() {
|
|
29956
29999
|
const info2 = this.nextPageInfo();
|
|
29957
30000
|
if (!info2)
|
|
@@ -29983,13 +30026,50 @@ class APIResource2 {
|
|
|
29983
30026
|
}
|
|
29984
30027
|
}
|
|
29985
30028
|
|
|
29986
|
-
// ../../node_modules/openai/resources/chat/completions.mjs
|
|
30029
|
+
// ../../node_modules/openai/resources/chat/completions/messages.mjs
|
|
30030
|
+
class Messages3 extends APIResource2 {
|
|
30031
|
+
list(completionId, query = {}, options) {
|
|
30032
|
+
if (isRequestOptions2(query)) {
|
|
30033
|
+
return this.list(completionId, {}, query);
|
|
30034
|
+
}
|
|
30035
|
+
return this._client.getAPIList(`/chat/completions/${completionId}/messages`, ChatCompletionStoreMessagesPage, { query, ...options });
|
|
30036
|
+
}
|
|
30037
|
+
}
|
|
30038
|
+
|
|
30039
|
+
// ../../node_modules/openai/resources/chat/completions/completions.mjs
|
|
29987
30040
|
class Completions2 extends APIResource2 {
|
|
30041
|
+
constructor() {
|
|
30042
|
+
super(...arguments);
|
|
30043
|
+
this.messages = new Messages3(this._client);
|
|
30044
|
+
}
|
|
29988
30045
|
create(body2, options) {
|
|
29989
30046
|
return this._client.post("/chat/completions", { body: body2, ...options, stream: body2.stream ?? false });
|
|
29990
30047
|
}
|
|
30048
|
+
retrieve(completionId, options) {
|
|
30049
|
+
return this._client.get(`/chat/completions/${completionId}`, options);
|
|
30050
|
+
}
|
|
30051
|
+
update(completionId, body2, options) {
|
|
30052
|
+
return this._client.post(`/chat/completions/${completionId}`, { body: body2, ...options });
|
|
30053
|
+
}
|
|
30054
|
+
list(query = {}, options) {
|
|
30055
|
+
if (isRequestOptions2(query)) {
|
|
30056
|
+
return this.list({}, query);
|
|
30057
|
+
}
|
|
30058
|
+
return this._client.getAPIList("/chat/completions", ChatCompletionsPage, { query, ...options });
|
|
30059
|
+
}
|
|
30060
|
+
del(completionId, options) {
|
|
30061
|
+
return this._client.delete(`/chat/completions/${completionId}`, options);
|
|
30062
|
+
}
|
|
30063
|
+
}
|
|
30064
|
+
|
|
30065
|
+
class ChatCompletionsPage extends CursorPage {
|
|
29991
30066
|
}
|
|
29992
30067
|
|
|
30068
|
+
class ChatCompletionStoreMessagesPage extends CursorPage {
|
|
30069
|
+
}
|
|
30070
|
+
Completions2.ChatCompletionsPage = ChatCompletionsPage;
|
|
30071
|
+
Completions2.Messages = Messages3;
|
|
30072
|
+
|
|
29993
30073
|
// ../../node_modules/openai/resources/chat/chat.mjs
|
|
29994
30074
|
class Chat extends APIResource2 {
|
|
29995
30075
|
constructor() {
|
|
@@ -29998,6 +30078,7 @@ class Chat extends APIResource2 {
|
|
|
29998
30078
|
}
|
|
29999
30079
|
}
|
|
30000
30080
|
Chat.Completions = Completions2;
|
|
30081
|
+
Chat.ChatCompletionsPage = ChatCompletionsPage;
|
|
30001
30082
|
// ../../node_modules/openai/resources/audio/speech.mjs
|
|
30002
30083
|
class Speech extends APIResource2 {
|
|
30003
30084
|
create(body2, options) {
|
|
@@ -30013,14 +30094,14 @@ class Speech extends APIResource2 {
|
|
|
30013
30094
|
// ../../node_modules/openai/resources/audio/transcriptions.mjs
|
|
30014
30095
|
class Transcriptions extends APIResource2 {
|
|
30015
30096
|
create(body2, options) {
|
|
30016
|
-
return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body: body2, ...options }));
|
|
30097
|
+
return this._client.post("/audio/transcriptions", multipartFormRequestOptions({ body: body2, ...options, __metadata: { model: body2.model } }));
|
|
30017
30098
|
}
|
|
30018
30099
|
}
|
|
30019
30100
|
|
|
30020
30101
|
// ../../node_modules/openai/resources/audio/translations.mjs
|
|
30021
30102
|
class Translations extends APIResource2 {
|
|
30022
30103
|
create(body2, options) {
|
|
30023
|
-
return this._client.post("/audio/translations", multipartFormRequestOptions({ body: body2, ...options }));
|
|
30104
|
+
return this._client.post("/audio/translations", multipartFormRequestOptions({ body: body2, ...options, __metadata: { model: body2.model } }));
|
|
30024
30105
|
}
|
|
30025
30106
|
}
|
|
30026
30107
|
|
|
@@ -30119,7 +30200,7 @@ var isToolMessage = (message) => {
|
|
|
30119
30200
|
};
|
|
30120
30201
|
|
|
30121
30202
|
// ../../node_modules/openai/lib/EventStream.mjs
|
|
30122
|
-
var
|
|
30203
|
+
var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
|
|
30123
30204
|
if (kind3 === "m")
|
|
30124
30205
|
throw new TypeError("Private method is not writable");
|
|
30125
30206
|
if (kind3 === "a" && !f2)
|
|
@@ -30128,7 +30209,7 @@ var __classPrivateFieldSet10 = function(receiver, state, value, kind3, f2) {
|
|
|
30128
30209
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
30129
30210
|
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
30130
30211
|
};
|
|
30131
|
-
var
|
|
30212
|
+
var __classPrivateFieldGet12 = function(receiver, state, kind3, f2) {
|
|
30132
30213
|
if (kind3 === "a" && !f2)
|
|
30133
30214
|
throw new TypeError("Private accessor was defined without a getter");
|
|
30134
30215
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -30164,50 +30245,50 @@ class EventStream {
|
|
|
30164
30245
|
_EventStream_errored.set(this, false);
|
|
30165
30246
|
_EventStream_aborted.set(this, false);
|
|
30166
30247
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
30167
|
-
|
|
30168
|
-
|
|
30169
|
-
|
|
30248
|
+
__classPrivateFieldSet11(this, _EventStream_connectedPromise, new Promise((resolve, reject) => {
|
|
30249
|
+
__classPrivateFieldSet11(this, _EventStream_resolveConnectedPromise, resolve, "f");
|
|
30250
|
+
__classPrivateFieldSet11(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
30170
30251
|
}), "f");
|
|
30171
|
-
|
|
30172
|
-
|
|
30173
|
-
|
|
30252
|
+
__classPrivateFieldSet11(this, _EventStream_endPromise, new Promise((resolve, reject) => {
|
|
30253
|
+
__classPrivateFieldSet11(this, _EventStream_resolveEndPromise, resolve, "f");
|
|
30254
|
+
__classPrivateFieldSet11(this, _EventStream_rejectEndPromise, reject, "f");
|
|
30174
30255
|
}), "f");
|
|
30175
|
-
|
|
30176
|
-
|
|
30256
|
+
__classPrivateFieldGet12(this, _EventStream_connectedPromise, "f").catch(() => {});
|
|
30257
|
+
__classPrivateFieldGet12(this, _EventStream_endPromise, "f").catch(() => {});
|
|
30177
30258
|
}
|
|
30178
30259
|
_run(executor) {
|
|
30179
30260
|
setTimeout(() => {
|
|
30180
30261
|
executor().then(() => {
|
|
30181
30262
|
this._emitFinal();
|
|
30182
30263
|
this._emit("end");
|
|
30183
|
-
},
|
|
30264
|
+
}, __classPrivateFieldGet12(this, _EventStream_instances, "m", _EventStream_handleError).bind(this));
|
|
30184
30265
|
}, 0);
|
|
30185
30266
|
}
|
|
30186
30267
|
_connected() {
|
|
30187
30268
|
if (this.ended)
|
|
30188
30269
|
return;
|
|
30189
|
-
|
|
30270
|
+
__classPrivateFieldGet12(this, _EventStream_resolveConnectedPromise, "f").call(this);
|
|
30190
30271
|
this._emit("connect");
|
|
30191
30272
|
}
|
|
30192
30273
|
get ended() {
|
|
30193
|
-
return
|
|
30274
|
+
return __classPrivateFieldGet12(this, _EventStream_ended, "f");
|
|
30194
30275
|
}
|
|
30195
30276
|
get errored() {
|
|
30196
|
-
return
|
|
30277
|
+
return __classPrivateFieldGet12(this, _EventStream_errored, "f");
|
|
30197
30278
|
}
|
|
30198
30279
|
get aborted() {
|
|
30199
|
-
return
|
|
30280
|
+
return __classPrivateFieldGet12(this, _EventStream_aborted, "f");
|
|
30200
30281
|
}
|
|
30201
30282
|
abort() {
|
|
30202
30283
|
this.controller.abort();
|
|
30203
30284
|
}
|
|
30204
30285
|
on(event, listener) {
|
|
30205
|
-
const listeners =
|
|
30286
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = []);
|
|
30206
30287
|
listeners.push({ listener });
|
|
30207
30288
|
return this;
|
|
30208
30289
|
}
|
|
30209
30290
|
off(event, listener) {
|
|
30210
|
-
const listeners =
|
|
30291
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event];
|
|
30211
30292
|
if (!listeners)
|
|
30212
30293
|
return this;
|
|
30213
30294
|
const index = listeners.findIndex((l2) => l2.listener === listener);
|
|
@@ -30216,64 +30297,64 @@ class EventStream {
|
|
|
30216
30297
|
return this;
|
|
30217
30298
|
}
|
|
30218
30299
|
once(event, listener) {
|
|
30219
|
-
const listeners =
|
|
30300
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] || (__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = []);
|
|
30220
30301
|
listeners.push({ listener, once: true });
|
|
30221
30302
|
return this;
|
|
30222
30303
|
}
|
|
30223
30304
|
emitted(event) {
|
|
30224
30305
|
return new Promise((resolve, reject) => {
|
|
30225
|
-
|
|
30306
|
+
__classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
30226
30307
|
if (event !== "error")
|
|
30227
30308
|
this.once("error", reject);
|
|
30228
30309
|
this.once(event, resolve);
|
|
30229
30310
|
});
|
|
30230
30311
|
}
|
|
30231
30312
|
async done() {
|
|
30232
|
-
|
|
30233
|
-
await
|
|
30313
|
+
__classPrivateFieldSet11(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
30314
|
+
await __classPrivateFieldGet12(this, _EventStream_endPromise, "f");
|
|
30234
30315
|
}
|
|
30235
30316
|
_emit(event, ...args2) {
|
|
30236
|
-
if (
|
|
30317
|
+
if (__classPrivateFieldGet12(this, _EventStream_ended, "f")) {
|
|
30237
30318
|
return;
|
|
30238
30319
|
}
|
|
30239
30320
|
if (event === "end") {
|
|
30240
|
-
|
|
30241
|
-
|
|
30321
|
+
__classPrivateFieldSet11(this, _EventStream_ended, true, "f");
|
|
30322
|
+
__classPrivateFieldGet12(this, _EventStream_resolveEndPromise, "f").call(this);
|
|
30242
30323
|
}
|
|
30243
|
-
const listeners =
|
|
30324
|
+
const listeners = __classPrivateFieldGet12(this, _EventStream_listeners, "f")[event];
|
|
30244
30325
|
if (listeners) {
|
|
30245
|
-
|
|
30326
|
+
__classPrivateFieldGet12(this, _EventStream_listeners, "f")[event] = listeners.filter((l2) => !l2.once);
|
|
30246
30327
|
listeners.forEach(({ listener }) => listener(...args2));
|
|
30247
30328
|
}
|
|
30248
30329
|
if (event === "abort") {
|
|
30249
30330
|
const error = args2[0];
|
|
30250
|
-
if (!
|
|
30331
|
+
if (!__classPrivateFieldGet12(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
30251
30332
|
Promise.reject(error);
|
|
30252
30333
|
}
|
|
30253
|
-
|
|
30254
|
-
|
|
30334
|
+
__classPrivateFieldGet12(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
|
|
30335
|
+
__classPrivateFieldGet12(this, _EventStream_rejectEndPromise, "f").call(this, error);
|
|
30255
30336
|
this._emit("end");
|
|
30256
30337
|
return;
|
|
30257
30338
|
}
|
|
30258
30339
|
if (event === "error") {
|
|
30259
30340
|
const error = args2[0];
|
|
30260
|
-
if (!
|
|
30341
|
+
if (!__classPrivateFieldGet12(this, _EventStream_catchingPromiseCreated, "f") && !listeners?.length) {
|
|
30261
30342
|
Promise.reject(error);
|
|
30262
30343
|
}
|
|
30263
|
-
|
|
30264
|
-
|
|
30344
|
+
__classPrivateFieldGet12(this, _EventStream_rejectConnectedPromise, "f").call(this, error);
|
|
30345
|
+
__classPrivateFieldGet12(this, _EventStream_rejectEndPromise, "f").call(this, error);
|
|
30265
30346
|
this._emit("end");
|
|
30266
30347
|
}
|
|
30267
30348
|
}
|
|
30268
30349
|
_emitFinal() {}
|
|
30269
30350
|
}
|
|
30270
30351
|
_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) {
|
|
30271
|
-
|
|
30352
|
+
__classPrivateFieldSet11(this, _EventStream_errored, true, "f");
|
|
30272
30353
|
if (error instanceof Error && error.name === "AbortError") {
|
|
30273
30354
|
error = new APIUserAbortError2;
|
|
30274
30355
|
}
|
|
30275
30356
|
if (error instanceof APIUserAbortError2) {
|
|
30276
|
-
|
|
30357
|
+
__classPrivateFieldSet11(this, _EventStream_aborted, true, "f");
|
|
30277
30358
|
return this._emit("abort", error);
|
|
30278
30359
|
}
|
|
30279
30360
|
if (error instanceof OpenAIError) {
|
|
@@ -30300,7 +30381,13 @@ function maybeParseChatCompletion(completion, params) {
|
|
|
30300
30381
|
...completion,
|
|
30301
30382
|
choices: completion.choices.map((choice) => ({
|
|
30302
30383
|
...choice,
|
|
30303
|
-
message: {
|
|
30384
|
+
message: {
|
|
30385
|
+
...choice.message,
|
|
30386
|
+
parsed: null,
|
|
30387
|
+
...choice.message.tool_calls ? {
|
|
30388
|
+
tool_calls: choice.message.tool_calls
|
|
30389
|
+
} : undefined
|
|
30390
|
+
}
|
|
30304
30391
|
}))
|
|
30305
30392
|
};
|
|
30306
30393
|
}
|
|
@@ -30318,7 +30405,9 @@ function parseChatCompletion(completion, params) {
|
|
|
30318
30405
|
...choice,
|
|
30319
30406
|
message: {
|
|
30320
30407
|
...choice.message,
|
|
30321
|
-
|
|
30408
|
+
...choice.message.tool_calls ? {
|
|
30409
|
+
tool_calls: choice.message.tool_calls?.map((toolCall) => parseToolCall(params, toolCall)) ?? undefined
|
|
30410
|
+
} : undefined,
|
|
30322
30411
|
parsed: choice.message.content && !choice.message.refusal ? parseResponseFormat(params, choice.message.content) : null
|
|
30323
30412
|
}
|
|
30324
30413
|
};
|
|
@@ -30373,7 +30462,7 @@ function validateInputTools(tools) {
|
|
|
30373
30462
|
}
|
|
30374
30463
|
|
|
30375
30464
|
// ../../node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
30376
|
-
var
|
|
30465
|
+
var __classPrivateFieldGet13 = function(receiver, state, kind3, f2) {
|
|
30377
30466
|
if (kind3 === "a" && !f2)
|
|
30378
30467
|
throw new TypeError("Private accessor was defined without a getter");
|
|
30379
30468
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -30433,23 +30522,23 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
30433
30522
|
}
|
|
30434
30523
|
async finalContent() {
|
|
30435
30524
|
await this.done();
|
|
30436
|
-
return
|
|
30525
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
30437
30526
|
}
|
|
30438
30527
|
async finalMessage() {
|
|
30439
30528
|
await this.done();
|
|
30440
|
-
return
|
|
30529
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
|
|
30441
30530
|
}
|
|
30442
30531
|
async finalFunctionCall() {
|
|
30443
30532
|
await this.done();
|
|
30444
|
-
return
|
|
30533
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
|
|
30445
30534
|
}
|
|
30446
30535
|
async finalFunctionCallResult() {
|
|
30447
30536
|
await this.done();
|
|
30448
|
-
return
|
|
30537
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
|
|
30449
30538
|
}
|
|
30450
30539
|
async totalUsage() {
|
|
30451
30540
|
await this.done();
|
|
30452
|
-
return
|
|
30541
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this);
|
|
30453
30542
|
}
|
|
30454
30543
|
allChatCompletions() {
|
|
30455
30544
|
return [...this._chatCompletions];
|
|
@@ -30458,20 +30547,20 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
30458
30547
|
const completion = this._chatCompletions[this._chatCompletions.length - 1];
|
|
30459
30548
|
if (completion)
|
|
30460
30549
|
this._emit("finalChatCompletion", completion);
|
|
30461
|
-
const finalMessage =
|
|
30550
|
+
const finalMessage = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this);
|
|
30462
30551
|
if (finalMessage)
|
|
30463
30552
|
this._emit("finalMessage", finalMessage);
|
|
30464
|
-
const finalContent =
|
|
30553
|
+
const finalContent = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
30465
30554
|
if (finalContent)
|
|
30466
30555
|
this._emit("finalContent", finalContent);
|
|
30467
|
-
const finalFunctionCall =
|
|
30556
|
+
const finalFunctionCall = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCall).call(this);
|
|
30468
30557
|
if (finalFunctionCall)
|
|
30469
30558
|
this._emit("finalFunctionCall", finalFunctionCall);
|
|
30470
|
-
const finalFunctionCallResult =
|
|
30559
|
+
const finalFunctionCallResult = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalFunctionCallResult).call(this);
|
|
30471
30560
|
if (finalFunctionCallResult != null)
|
|
30472
30561
|
this._emit("finalFunctionCallResult", finalFunctionCallResult);
|
|
30473
30562
|
if (this._chatCompletions.some((c2) => c2.usage)) {
|
|
30474
|
-
this._emit("totalUsage",
|
|
30563
|
+
this._emit("totalUsage", __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_calculateTotalUsage).call(this));
|
|
30475
30564
|
}
|
|
30476
30565
|
}
|
|
30477
30566
|
async _createChatCompletion(client, params, options) {
|
|
@@ -30481,7 +30570,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
30481
30570
|
this.controller.abort();
|
|
30482
30571
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
30483
30572
|
}
|
|
30484
|
-
|
|
30573
|
+
__classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_validateParams).call(this, params);
|
|
30485
30574
|
const chatCompletion = await client.chat.completions.create({ ...params, stream: false }, { ...options, signal: this.controller.signal });
|
|
30486
30575
|
this._connected();
|
|
30487
30576
|
return this._addChatCompletion(parseChatCompletion(chatCompletion, params));
|
|
@@ -30545,7 +30634,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
30545
30634
|
continue;
|
|
30546
30635
|
}
|
|
30547
30636
|
const rawContent = await fn.function(parsed, this);
|
|
30548
|
-
const content =
|
|
30637
|
+
const content = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
30549
30638
|
this._addMessage({ role, name: name2, content });
|
|
30550
30639
|
if (singleFunctionToCall)
|
|
30551
30640
|
return;
|
|
@@ -30631,7 +30720,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
30631
30720
|
continue;
|
|
30632
30721
|
}
|
|
30633
30722
|
const rawContent = await fn.function(parsed, this);
|
|
30634
|
-
const content =
|
|
30723
|
+
const content = __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
30635
30724
|
this._addMessage({ role, tool_call_id, content });
|
|
30636
30725
|
if (singleFunctionToCall) {
|
|
30637
30726
|
return;
|
|
@@ -30642,7 +30731,7 @@ class AbstractChatCompletionRunner extends EventStream {
|
|
|
30642
30731
|
}
|
|
30643
30732
|
}
|
|
30644
30733
|
_AbstractChatCompletionRunner_instances = new WeakSet, _AbstractChatCompletionRunner_getFinalContent = function _AbstractChatCompletionRunner_getFinalContent2() {
|
|
30645
|
-
return
|
|
30734
|
+
return __classPrivateFieldGet13(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalMessage).call(this).content ?? null;
|
|
30646
30735
|
}, _AbstractChatCompletionRunner_getFinalMessage = function _AbstractChatCompletionRunner_getFinalMessage2() {
|
|
30647
30736
|
let i3 = this.messages.length;
|
|
30648
30737
|
while (i3-- > 0) {
|
|
@@ -30948,7 +31037,7 @@ var _parseJSON = (jsonString, allow) => {
|
|
|
30948
31037
|
var partialParse2 = (input) => parseJSON(input, Allow.ALL ^ Allow.NUM);
|
|
30949
31038
|
|
|
30950
31039
|
// ../../node_modules/openai/lib/ChatCompletionStream.mjs
|
|
30951
|
-
var
|
|
31040
|
+
var __classPrivateFieldSet12 = function(receiver, state, value, kind3, f2) {
|
|
30952
31041
|
if (kind3 === "m")
|
|
30953
31042
|
throw new TypeError("Private method is not writable");
|
|
30954
31043
|
if (kind3 === "a" && !f2)
|
|
@@ -30957,7 +31046,7 @@ var __classPrivateFieldSet11 = function(receiver, state, value, kind3, f2) {
|
|
|
30957
31046
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
30958
31047
|
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
30959
31048
|
};
|
|
30960
|
-
var
|
|
31049
|
+
var __classPrivateFieldGet14 = function(receiver, state, kind3, f2) {
|
|
30961
31050
|
if (kind3 === "a" && !f2)
|
|
30962
31051
|
throw new TypeError("Private accessor was defined without a getter");
|
|
30963
31052
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
@@ -30984,11 +31073,11 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
30984
31073
|
_ChatCompletionStream_params.set(this, undefined);
|
|
30985
31074
|
_ChatCompletionStream_choiceEventStates.set(this, undefined);
|
|
30986
31075
|
_ChatCompletionStream_currentChatCompletionSnapshot.set(this, undefined);
|
|
30987
|
-
|
|
30988
|
-
|
|
31076
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_params, params, "f");
|
|
31077
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
30989
31078
|
}
|
|
30990
31079
|
get currentChatCompletionSnapshot() {
|
|
30991
|
-
return
|
|
31080
|
+
return __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
30992
31081
|
}
|
|
30993
31082
|
static fromReadableStream(stream) {
|
|
30994
31083
|
const runner = new ChatCompletionStream(null);
|
|
@@ -31008,16 +31097,16 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31008
31097
|
this.controller.abort();
|
|
31009
31098
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
31010
31099
|
}
|
|
31011
|
-
|
|
31100
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
31012
31101
|
const stream = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
31013
31102
|
this._connected();
|
|
31014
31103
|
for await (const chunk of stream) {
|
|
31015
|
-
|
|
31104
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
31016
31105
|
}
|
|
31017
31106
|
if (stream.controller.signal?.aborted) {
|
|
31018
31107
|
throw new APIUserAbortError2;
|
|
31019
31108
|
}
|
|
31020
|
-
return this._addChatCompletion(
|
|
31109
|
+
return this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
31021
31110
|
}
|
|
31022
31111
|
async _fromReadableStream(readableStream, options) {
|
|
31023
31112
|
const signal = options?.signal;
|
|
@@ -31026,28 +31115,28 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31026
31115
|
this.controller.abort();
|
|
31027
31116
|
signal.addEventListener("abort", () => this.controller.abort());
|
|
31028
31117
|
}
|
|
31029
|
-
|
|
31118
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
31030
31119
|
this._connected();
|
|
31031
31120
|
const stream = Stream2.fromReadableStream(readableStream, this.controller);
|
|
31032
31121
|
let chatId;
|
|
31033
31122
|
for await (const chunk of stream) {
|
|
31034
31123
|
if (chatId && chatId !== chunk.id) {
|
|
31035
|
-
this._addChatCompletion(
|
|
31124
|
+
this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
31036
31125
|
}
|
|
31037
|
-
|
|
31126
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
31038
31127
|
chatId = chunk.id;
|
|
31039
31128
|
}
|
|
31040
31129
|
if (stream.controller.signal?.aborted) {
|
|
31041
31130
|
throw new APIUserAbortError2;
|
|
31042
31131
|
}
|
|
31043
|
-
return this._addChatCompletion(
|
|
31132
|
+
return this._addChatCompletion(__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
31044
31133
|
}
|
|
31045
31134
|
[(_ChatCompletionStream_params = new WeakMap, _ChatCompletionStream_choiceEventStates = new WeakMap, _ChatCompletionStream_currentChatCompletionSnapshot = new WeakMap, _ChatCompletionStream_instances = new WeakSet, _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest() {
|
|
31046
31135
|
if (this.ended)
|
|
31047
31136
|
return;
|
|
31048
|
-
|
|
31137
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
31049
31138
|
}, _ChatCompletionStream_getChoiceEventState = function _ChatCompletionStream_getChoiceEventState(choice) {
|
|
31050
|
-
let state =
|
|
31139
|
+
let state = __classPrivateFieldGet14(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index];
|
|
31051
31140
|
if (state) {
|
|
31052
31141
|
return state;
|
|
31053
31142
|
}
|
|
@@ -31059,12 +31148,12 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31059
31148
|
done_tool_calls: new Set,
|
|
31060
31149
|
current_tool_call_index: null
|
|
31061
31150
|
};
|
|
31062
|
-
|
|
31151
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_choiceEventStates, "f")[choice.index] = state;
|
|
31063
31152
|
return state;
|
|
31064
31153
|
}, _ChatCompletionStream_addChunk = function _ChatCompletionStream_addChunk(chunk) {
|
|
31065
31154
|
if (this.ended)
|
|
31066
31155
|
return;
|
|
31067
|
-
const completion =
|
|
31156
|
+
const completion = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_accumulateChatCompletion).call(this, chunk);
|
|
31068
31157
|
this._emit("chunk", chunk, completion);
|
|
31069
31158
|
for (const choice of chunk.choices) {
|
|
31070
31159
|
const choiceSnapshot = completion.choices[choice.index];
|
|
@@ -31094,18 +31183,18 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31094
31183
|
snapshot: choiceSnapshot.logprobs?.refusal ?? []
|
|
31095
31184
|
});
|
|
31096
31185
|
}
|
|
31097
|
-
const state =
|
|
31186
|
+
const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
31098
31187
|
if (choiceSnapshot.finish_reason) {
|
|
31099
|
-
|
|
31188
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
31100
31189
|
if (state.current_tool_call_index != null) {
|
|
31101
|
-
|
|
31190
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
31102
31191
|
}
|
|
31103
31192
|
}
|
|
31104
31193
|
for (const toolCall of choice.delta.tool_calls ?? []) {
|
|
31105
31194
|
if (state.current_tool_call_index !== toolCall.index) {
|
|
31106
|
-
|
|
31195
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
31107
31196
|
if (state.current_tool_call_index != null) {
|
|
31108
|
-
|
|
31197
|
+
__classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
31109
31198
|
}
|
|
31110
31199
|
}
|
|
31111
31200
|
state.current_tool_call_index = toolCall.index;
|
|
@@ -31129,7 +31218,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31129
31218
|
}
|
|
31130
31219
|
}
|
|
31131
31220
|
}, _ChatCompletionStream_emitToolCallDoneEvent = function _ChatCompletionStream_emitToolCallDoneEvent(choiceSnapshot, toolCallIndex) {
|
|
31132
|
-
const state =
|
|
31221
|
+
const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
31133
31222
|
if (state.done_tool_calls.has(toolCallIndex)) {
|
|
31134
31223
|
return;
|
|
31135
31224
|
}
|
|
@@ -31141,7 +31230,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31141
31230
|
throw new Error("tool call snapshot missing `type`");
|
|
31142
31231
|
}
|
|
31143
31232
|
if (toolCallSnapshot.type === "function") {
|
|
31144
|
-
const inputTool =
|
|
31233
|
+
const inputTool = __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f")?.tools?.find((tool) => tool.type === "function" && tool.function.name === toolCallSnapshot.function.name);
|
|
31145
31234
|
this._emit("tool_calls.function.arguments.done", {
|
|
31146
31235
|
name: toolCallSnapshot.function.name,
|
|
31147
31236
|
index: toolCallIndex,
|
|
@@ -31152,10 +31241,10 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31152
31241
|
assertNever(toolCallSnapshot.type);
|
|
31153
31242
|
}
|
|
31154
31243
|
}, _ChatCompletionStream_emitContentDoneEvents = function _ChatCompletionStream_emitContentDoneEvents(choiceSnapshot) {
|
|
31155
|
-
const state =
|
|
31244
|
+
const state = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getChoiceEventState).call(this, choiceSnapshot);
|
|
31156
31245
|
if (choiceSnapshot.message.content && !state.content_done) {
|
|
31157
31246
|
state.content_done = true;
|
|
31158
|
-
const responseFormat =
|
|
31247
|
+
const responseFormat = __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this);
|
|
31159
31248
|
this._emit("content.done", {
|
|
31160
31249
|
content: choiceSnapshot.message.content,
|
|
31161
31250
|
parsed: responseFormat ? responseFormat.$parseRaw(choiceSnapshot.message.content) : null
|
|
@@ -31177,25 +31266,25 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31177
31266
|
if (this.ended) {
|
|
31178
31267
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
31179
31268
|
}
|
|
31180
|
-
const snapshot =
|
|
31269
|
+
const snapshot = __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
31181
31270
|
if (!snapshot) {
|
|
31182
31271
|
throw new OpenAIError(`request ended without sending any chunks`);
|
|
31183
31272
|
}
|
|
31184
|
-
|
|
31185
|
-
|
|
31186
|
-
return finalizeChatCompletion(snapshot,
|
|
31273
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, undefined, "f");
|
|
31274
|
+
__classPrivateFieldSet12(this, _ChatCompletionStream_choiceEventStates, [], "f");
|
|
31275
|
+
return finalizeChatCompletion(snapshot, __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"));
|
|
31187
31276
|
}, _ChatCompletionStream_getAutoParseableResponseFormat = function _ChatCompletionStream_getAutoParseableResponseFormat() {
|
|
31188
|
-
const responseFormat =
|
|
31277
|
+
const responseFormat = __classPrivateFieldGet14(this, _ChatCompletionStream_params, "f")?.response_format;
|
|
31189
31278
|
if (isAutoParsableResponseFormat(responseFormat)) {
|
|
31190
31279
|
return responseFormat;
|
|
31191
31280
|
}
|
|
31192
31281
|
return null;
|
|
31193
31282
|
}, _ChatCompletionStream_accumulateChatCompletion = function _ChatCompletionStream_accumulateChatCompletion(chunk) {
|
|
31194
31283
|
var _a2, _b, _c, _d;
|
|
31195
|
-
let snapshot =
|
|
31284
|
+
let snapshot = __classPrivateFieldGet14(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f");
|
|
31196
31285
|
const { choices, ...rest } = chunk;
|
|
31197
31286
|
if (!snapshot) {
|
|
31198
|
-
snapshot =
|
|
31287
|
+
snapshot = __classPrivateFieldSet12(this, _ChatCompletionStream_currentChatCompletionSnapshot, {
|
|
31199
31288
|
...rest,
|
|
31200
31289
|
choices: []
|
|
31201
31290
|
}, "f");
|
|
@@ -31226,7 +31315,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31226
31315
|
}
|
|
31227
31316
|
if (finish_reason) {
|
|
31228
31317
|
choice.finish_reason = finish_reason;
|
|
31229
|
-
if (
|
|
31318
|
+
if (__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f") && hasAutoParseableInput(__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"))) {
|
|
31230
31319
|
if (finish_reason === "length") {
|
|
31231
31320
|
throw new LengthFinishReasonError;
|
|
31232
31321
|
}
|
|
@@ -31260,7 +31349,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31260
31349
|
}
|
|
31261
31350
|
if (content) {
|
|
31262
31351
|
choice.message.content = (choice.message.content || "") + content;
|
|
31263
|
-
if (!choice.message.refusal &&
|
|
31352
|
+
if (!choice.message.refusal && __classPrivateFieldGet14(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {
|
|
31264
31353
|
choice.message.parsed = partialParse2(choice.message.content);
|
|
31265
31354
|
}
|
|
31266
31355
|
}
|
|
@@ -31280,7 +31369,7 @@ class ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
|
31280
31369
|
tool_call.function.name = fn.name;
|
|
31281
31370
|
if (fn?.arguments) {
|
|
31282
31371
|
tool_call.function.arguments += fn.arguments;
|
|
31283
|
-
if (shouldParseToolCall(
|
|
31372
|
+
if (shouldParseToolCall(__classPrivateFieldGet14(this, _ChatCompletionStream_params, "f"), tool_call)) {
|
|
31284
31373
|
tool_call.function.parsed_arguments = partialParse2(tool_call.function.arguments);
|
|
31285
31374
|
}
|
|
31286
31375
|
}
|
|
@@ -31514,24 +31603,37 @@ class Sessions extends APIResource2 {
|
|
|
31514
31603
|
}
|
|
31515
31604
|
}
|
|
31516
31605
|
|
|
31606
|
+
// ../../node_modules/openai/resources/beta/realtime/transcription-sessions.mjs
|
|
31607
|
+
class TranscriptionSessions extends APIResource2 {
|
|
31608
|
+
create(body2, options) {
|
|
31609
|
+
return this._client.post("/realtime/transcription_sessions", {
|
|
31610
|
+
body: body2,
|
|
31611
|
+
...options,
|
|
31612
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
31613
|
+
});
|
|
31614
|
+
}
|
|
31615
|
+
}
|
|
31616
|
+
|
|
31517
31617
|
// ../../node_modules/openai/resources/beta/realtime/realtime.mjs
|
|
31518
31618
|
class Realtime extends APIResource2 {
|
|
31519
31619
|
constructor() {
|
|
31520
31620
|
super(...arguments);
|
|
31521
31621
|
this.sessions = new Sessions(this._client);
|
|
31622
|
+
this.transcriptionSessions = new TranscriptionSessions(this._client);
|
|
31522
31623
|
}
|
|
31523
31624
|
}
|
|
31524
31625
|
Realtime.Sessions = Sessions;
|
|
31626
|
+
Realtime.TranscriptionSessions = TranscriptionSessions;
|
|
31525
31627
|
|
|
31526
31628
|
// ../../node_modules/openai/lib/AssistantStream.mjs
|
|
31527
|
-
var
|
|
31629
|
+
var __classPrivateFieldGet15 = function(receiver, state, kind3, f2) {
|
|
31528
31630
|
if (kind3 === "a" && !f2)
|
|
31529
31631
|
throw new TypeError("Private accessor was defined without a getter");
|
|
31530
31632
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
31531
31633
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
31532
31634
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
31533
31635
|
};
|
|
31534
|
-
var
|
|
31636
|
+
var __classPrivateFieldSet13 = function(receiver, state, value, kind3, f2) {
|
|
31535
31637
|
if (kind3 === "m")
|
|
31536
31638
|
throw new TypeError("Private method is not writable");
|
|
31537
31639
|
if (kind3 === "a" && !f2)
|
|
@@ -31645,12 +31747,12 @@ class AssistantStream extends EventStream {
|
|
|
31645
31747
|
this._connected();
|
|
31646
31748
|
const stream = Stream2.fromReadableStream(readableStream, this.controller);
|
|
31647
31749
|
for await (const event of stream) {
|
|
31648
|
-
|
|
31750
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
31649
31751
|
}
|
|
31650
31752
|
if (stream.controller.signal?.aborted) {
|
|
31651
31753
|
throw new APIUserAbortError2;
|
|
31652
31754
|
}
|
|
31653
|
-
return this._addRun(
|
|
31755
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
31654
31756
|
}
|
|
31655
31757
|
toReadableStream() {
|
|
31656
31758
|
const stream = new Stream2(this[Symbol.asyncIterator].bind(this), this.controller);
|
|
@@ -31678,12 +31780,12 @@ class AssistantStream extends EventStream {
|
|
|
31678
31780
|
});
|
|
31679
31781
|
this._connected();
|
|
31680
31782
|
for await (const event of stream) {
|
|
31681
|
-
|
|
31783
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
31682
31784
|
}
|
|
31683
31785
|
if (stream.controller.signal?.aborted) {
|
|
31684
31786
|
throw new APIUserAbortError2;
|
|
31685
31787
|
}
|
|
31686
|
-
return this._addRun(
|
|
31788
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
31687
31789
|
}
|
|
31688
31790
|
static createThreadAssistantStream(params, thread, options) {
|
|
31689
31791
|
const runner = new AssistantStream;
|
|
@@ -31702,30 +31804,30 @@ class AssistantStream extends EventStream {
|
|
|
31702
31804
|
return runner;
|
|
31703
31805
|
}
|
|
31704
31806
|
currentEvent() {
|
|
31705
|
-
return
|
|
31807
|
+
return __classPrivateFieldGet15(this, _AssistantStream_currentEvent, "f");
|
|
31706
31808
|
}
|
|
31707
31809
|
currentRun() {
|
|
31708
|
-
return
|
|
31810
|
+
return __classPrivateFieldGet15(this, _AssistantStream_currentRunSnapshot, "f");
|
|
31709
31811
|
}
|
|
31710
31812
|
currentMessageSnapshot() {
|
|
31711
|
-
return
|
|
31813
|
+
return __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f");
|
|
31712
31814
|
}
|
|
31713
31815
|
currentRunStepSnapshot() {
|
|
31714
|
-
return
|
|
31816
|
+
return __classPrivateFieldGet15(this, _AssistantStream_currentRunStepSnapshot, "f");
|
|
31715
31817
|
}
|
|
31716
31818
|
async finalRunSteps() {
|
|
31717
31819
|
await this.done();
|
|
31718
|
-
return Object.values(
|
|
31820
|
+
return Object.values(__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f"));
|
|
31719
31821
|
}
|
|
31720
31822
|
async finalMessages() {
|
|
31721
31823
|
await this.done();
|
|
31722
|
-
return Object.values(
|
|
31824
|
+
return Object.values(__classPrivateFieldGet15(this, _AssistantStream_messageSnapshots, "f"));
|
|
31723
31825
|
}
|
|
31724
31826
|
async finalRun() {
|
|
31725
31827
|
await this.done();
|
|
31726
|
-
if (!
|
|
31828
|
+
if (!__classPrivateFieldGet15(this, _AssistantStream_finalRun, "f"))
|
|
31727
31829
|
throw Error("Final run was not received.");
|
|
31728
|
-
return
|
|
31830
|
+
return __classPrivateFieldGet15(this, _AssistantStream_finalRun, "f");
|
|
31729
31831
|
}
|
|
31730
31832
|
async _createThreadAssistantStream(thread, params, options) {
|
|
31731
31833
|
const signal = options?.signal;
|
|
@@ -31738,12 +31840,12 @@ class AssistantStream extends EventStream {
|
|
|
31738
31840
|
const stream = await thread.createAndRun(body2, { ...options, signal: this.controller.signal });
|
|
31739
31841
|
this._connected();
|
|
31740
31842
|
for await (const event of stream) {
|
|
31741
|
-
|
|
31843
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
31742
31844
|
}
|
|
31743
31845
|
if (stream.controller.signal?.aborted) {
|
|
31744
31846
|
throw new APIUserAbortError2;
|
|
31745
31847
|
}
|
|
31746
|
-
return this._addRun(
|
|
31848
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
31747
31849
|
}
|
|
31748
31850
|
async _createAssistantStream(run2, threadId, params, options) {
|
|
31749
31851
|
const signal = options?.signal;
|
|
@@ -31756,12 +31858,12 @@ class AssistantStream extends EventStream {
|
|
|
31756
31858
|
const stream = await run2.create(threadId, body2, { ...options, signal: this.controller.signal });
|
|
31757
31859
|
this._connected();
|
|
31758
31860
|
for await (const event of stream) {
|
|
31759
|
-
|
|
31861
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_addEvent).call(this, event);
|
|
31760
31862
|
}
|
|
31761
31863
|
if (stream.controller.signal?.aborted) {
|
|
31762
31864
|
throw new APIUserAbortError2;
|
|
31763
31865
|
}
|
|
31764
|
-
return this._addRun(
|
|
31866
|
+
return this._addRun(__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
31765
31867
|
}
|
|
31766
31868
|
static accumulateDelta(acc, delta) {
|
|
31767
31869
|
for (const [key, deltaValue] of Object.entries(delta)) {
|
|
@@ -31832,8 +31934,8 @@ class AssistantStream extends EventStream {
|
|
|
31832
31934
|
_AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
31833
31935
|
if (this.ended)
|
|
31834
31936
|
return;
|
|
31835
|
-
|
|
31836
|
-
|
|
31937
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentEvent, event, "f");
|
|
31938
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleEvent).call(this, event);
|
|
31837
31939
|
switch (event.event) {
|
|
31838
31940
|
case "thread.created":
|
|
31839
31941
|
break;
|
|
@@ -31842,11 +31944,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
31842
31944
|
case "thread.run.in_progress":
|
|
31843
31945
|
case "thread.run.requires_action":
|
|
31844
31946
|
case "thread.run.completed":
|
|
31947
|
+
case "thread.run.incomplete":
|
|
31845
31948
|
case "thread.run.failed":
|
|
31846
31949
|
case "thread.run.cancelling":
|
|
31847
31950
|
case "thread.run.cancelled":
|
|
31848
31951
|
case "thread.run.expired":
|
|
31849
|
-
|
|
31952
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleRun).call(this, event);
|
|
31850
31953
|
break;
|
|
31851
31954
|
case "thread.run.step.created":
|
|
31852
31955
|
case "thread.run.step.in_progress":
|
|
@@ -31855,29 +31958,31 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
31855
31958
|
case "thread.run.step.failed":
|
|
31856
31959
|
case "thread.run.step.cancelled":
|
|
31857
31960
|
case "thread.run.step.expired":
|
|
31858
|
-
|
|
31961
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleRunStep).call(this, event);
|
|
31859
31962
|
break;
|
|
31860
31963
|
case "thread.message.created":
|
|
31861
31964
|
case "thread.message.in_progress":
|
|
31862
31965
|
case "thread.message.delta":
|
|
31863
31966
|
case "thread.message.completed":
|
|
31864
31967
|
case "thread.message.incomplete":
|
|
31865
|
-
|
|
31968
|
+
__classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_handleMessage).call(this, event);
|
|
31866
31969
|
break;
|
|
31867
31970
|
case "error":
|
|
31868
31971
|
throw new Error("Encountered an error event in event processing - errors should be processed earlier");
|
|
31972
|
+
default:
|
|
31973
|
+
assertNever2(event);
|
|
31869
31974
|
}
|
|
31870
31975
|
}, _AssistantStream_endRequest = function _AssistantStream_endRequest2() {
|
|
31871
31976
|
if (this.ended) {
|
|
31872
31977
|
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
31873
31978
|
}
|
|
31874
|
-
if (!
|
|
31979
|
+
if (!__classPrivateFieldGet15(this, _AssistantStream_finalRun, "f"))
|
|
31875
31980
|
throw Error("Final run has not been received");
|
|
31876
|
-
return
|
|
31981
|
+
return __classPrivateFieldGet15(this, _AssistantStream_finalRun, "f");
|
|
31877
31982
|
}, _AssistantStream_handleMessage = function _AssistantStream_handleMessage2(event) {
|
|
31878
|
-
const [accumulatedMessage, newContent] =
|
|
31879
|
-
|
|
31880
|
-
|
|
31983
|
+
const [accumulatedMessage, newContent] = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateMessage).call(this, event, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
31984
|
+
__classPrivateFieldSet13(this, _AssistantStream_messageSnapshot, accumulatedMessage, "f");
|
|
31985
|
+
__classPrivateFieldGet15(this, _AssistantStream_messageSnapshots, "f")[accumulatedMessage.id] = accumulatedMessage;
|
|
31881
31986
|
for (const content of newContent) {
|
|
31882
31987
|
const snapshotContent = accumulatedMessage.content[content.index];
|
|
31883
31988
|
if (snapshotContent?.type == "text") {
|
|
@@ -31903,46 +32008,46 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
31903
32008
|
throw Error("The snapshot associated with this text delta is not text or missing");
|
|
31904
32009
|
}
|
|
31905
32010
|
}
|
|
31906
|
-
if (content.index !=
|
|
31907
|
-
if (
|
|
31908
|
-
switch (
|
|
32011
|
+
if (content.index != __classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f")) {
|
|
32012
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentContent, "f")) {
|
|
32013
|
+
switch (__classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").type) {
|
|
31909
32014
|
case "text":
|
|
31910
|
-
this._emit("textDone",
|
|
32015
|
+
this._emit("textDone", __classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").text, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
31911
32016
|
break;
|
|
31912
32017
|
case "image_file":
|
|
31913
|
-
this._emit("imageFileDone",
|
|
32018
|
+
this._emit("imageFileDone", __classPrivateFieldGet15(this, _AssistantStream_currentContent, "f").image_file, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
31914
32019
|
break;
|
|
31915
32020
|
}
|
|
31916
32021
|
}
|
|
31917
|
-
|
|
32022
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentContentIndex, content.index, "f");
|
|
31918
32023
|
}
|
|
31919
|
-
|
|
32024
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentContent, accumulatedMessage.content[content.index], "f");
|
|
31920
32025
|
}
|
|
31921
32026
|
}
|
|
31922
32027
|
break;
|
|
31923
32028
|
case "thread.message.completed":
|
|
31924
32029
|
case "thread.message.incomplete":
|
|
31925
|
-
if (
|
|
31926
|
-
const currentContent = event.data.content[
|
|
32030
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f") !== undefined) {
|
|
32031
|
+
const currentContent = event.data.content[__classPrivateFieldGet15(this, _AssistantStream_currentContentIndex, "f")];
|
|
31927
32032
|
if (currentContent) {
|
|
31928
32033
|
switch (currentContent.type) {
|
|
31929
32034
|
case "image_file":
|
|
31930
|
-
this._emit("imageFileDone", currentContent.image_file,
|
|
32035
|
+
this._emit("imageFileDone", currentContent.image_file, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
31931
32036
|
break;
|
|
31932
32037
|
case "text":
|
|
31933
|
-
this._emit("textDone", currentContent.text,
|
|
32038
|
+
this._emit("textDone", currentContent.text, __classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f"));
|
|
31934
32039
|
break;
|
|
31935
32040
|
}
|
|
31936
32041
|
}
|
|
31937
32042
|
}
|
|
31938
|
-
if (
|
|
32043
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_messageSnapshot, "f")) {
|
|
31939
32044
|
this._emit("messageDone", event.data);
|
|
31940
32045
|
}
|
|
31941
|
-
|
|
32046
|
+
__classPrivateFieldSet13(this, _AssistantStream_messageSnapshot, undefined, "f");
|
|
31942
32047
|
}
|
|
31943
32048
|
}, _AssistantStream_handleRunStep = function _AssistantStream_handleRunStep2(event) {
|
|
31944
|
-
const accumulatedRunStep =
|
|
31945
|
-
|
|
32049
|
+
const accumulatedRunStep = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateRunStep).call(this, event);
|
|
32050
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentRunStepSnapshot, accumulatedRunStep, "f");
|
|
31946
32051
|
switch (event.event) {
|
|
31947
32052
|
case "thread.run.step.created":
|
|
31948
32053
|
this._emit("runStepCreated", event.data);
|
|
@@ -31951,16 +32056,16 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
31951
32056
|
const delta = event.data.delta;
|
|
31952
32057
|
if (delta.step_details && delta.step_details.type == "tool_calls" && delta.step_details.tool_calls && accumulatedRunStep.step_details.type == "tool_calls") {
|
|
31953
32058
|
for (const toolCall of delta.step_details.tool_calls) {
|
|
31954
|
-
if (toolCall.index ==
|
|
32059
|
+
if (toolCall.index == __classPrivateFieldGet15(this, _AssistantStream_currentToolCallIndex, "f")) {
|
|
31955
32060
|
this._emit("toolCallDelta", toolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index]);
|
|
31956
32061
|
} else {
|
|
31957
|
-
if (
|
|
31958
|
-
this._emit("toolCallDone",
|
|
32062
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
|
|
32063
|
+
this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
31959
32064
|
}
|
|
31960
|
-
|
|
31961
|
-
|
|
31962
|
-
if (
|
|
31963
|
-
this._emit("toolCallCreated",
|
|
32065
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCallIndex, toolCall.index, "f");
|
|
32066
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCall, accumulatedRunStep.step_details.tool_calls[toolCall.index], "f");
|
|
32067
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"))
|
|
32068
|
+
this._emit("toolCallCreated", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
31964
32069
|
}
|
|
31965
32070
|
}
|
|
31966
32071
|
}
|
|
@@ -31970,12 +32075,12 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
31970
32075
|
case "thread.run.step.failed":
|
|
31971
32076
|
case "thread.run.step.cancelled":
|
|
31972
32077
|
case "thread.run.step.expired":
|
|
31973
|
-
|
|
32078
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentRunStepSnapshot, undefined, "f");
|
|
31974
32079
|
const details = event.data.step_details;
|
|
31975
32080
|
if (details.type == "tool_calls") {
|
|
31976
|
-
if (
|
|
31977
|
-
this._emit("toolCallDone",
|
|
31978
|
-
|
|
32081
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
|
|
32082
|
+
this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
32083
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCall, undefined, "f");
|
|
31979
32084
|
}
|
|
31980
32085
|
}
|
|
31981
32086
|
this._emit("runStepDone", event.data, accumulatedRunStep);
|
|
@@ -31984,34 +32089,34 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
31984
32089
|
break;
|
|
31985
32090
|
}
|
|
31986
32091
|
}, _AssistantStream_handleEvent = function _AssistantStream_handleEvent2(event) {
|
|
31987
|
-
|
|
32092
|
+
__classPrivateFieldGet15(this, _AssistantStream_events, "f").push(event);
|
|
31988
32093
|
this._emit("event", event);
|
|
31989
32094
|
}, _AssistantStream_accumulateRunStep = function _AssistantStream_accumulateRunStep2(event) {
|
|
31990
32095
|
switch (event.event) {
|
|
31991
32096
|
case "thread.run.step.created":
|
|
31992
|
-
|
|
32097
|
+
__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
|
|
31993
32098
|
return event.data;
|
|
31994
32099
|
case "thread.run.step.delta":
|
|
31995
|
-
let snapshot =
|
|
32100
|
+
let snapshot = __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
31996
32101
|
if (!snapshot) {
|
|
31997
32102
|
throw Error("Received a RunStepDelta before creation of a snapshot");
|
|
31998
32103
|
}
|
|
31999
32104
|
let data = event.data;
|
|
32000
32105
|
if (data.delta) {
|
|
32001
32106
|
const accumulated = AssistantStream.accumulateDelta(snapshot, data.delta);
|
|
32002
|
-
|
|
32107
|
+
__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = accumulated;
|
|
32003
32108
|
}
|
|
32004
|
-
return
|
|
32109
|
+
return __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
32005
32110
|
case "thread.run.step.completed":
|
|
32006
32111
|
case "thread.run.step.failed":
|
|
32007
32112
|
case "thread.run.step.cancelled":
|
|
32008
32113
|
case "thread.run.step.expired":
|
|
32009
32114
|
case "thread.run.step.in_progress":
|
|
32010
|
-
|
|
32115
|
+
__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id] = event.data;
|
|
32011
32116
|
break;
|
|
32012
32117
|
}
|
|
32013
|
-
if (
|
|
32014
|
-
return
|
|
32118
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id])
|
|
32119
|
+
return __classPrivateFieldGet15(this, _AssistantStream_runStepSnapshots, "f")[event.data.id];
|
|
32015
32120
|
throw new Error("No snapshot available");
|
|
32016
32121
|
}, _AssistantStream_accumulateMessage = function _AssistantStream_accumulateMessage2(event, snapshot) {
|
|
32017
32122
|
let newContent = [];
|
|
@@ -32027,7 +32132,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
32027
32132
|
for (const contentElement of data.delta.content) {
|
|
32028
32133
|
if (contentElement.index in snapshot.content) {
|
|
32029
32134
|
let currentContent = snapshot.content[contentElement.index];
|
|
32030
|
-
snapshot.content[contentElement.index] =
|
|
32135
|
+
snapshot.content[contentElement.index] = __classPrivateFieldGet15(this, _AssistantStream_instances, "m", _AssistantStream_accumulateContent).call(this, contentElement, currentContent);
|
|
32031
32136
|
} else {
|
|
32032
32137
|
snapshot.content[contentElement.index] = contentElement;
|
|
32033
32138
|
newContent.push(contentElement);
|
|
@@ -32048,7 +32153,7 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
32048
32153
|
}, _AssistantStream_accumulateContent = function _AssistantStream_accumulateContent2(contentElement, currentContent) {
|
|
32049
32154
|
return AssistantStream.accumulateDelta(currentContent, contentElement);
|
|
32050
32155
|
}, _AssistantStream_handleRun = function _AssistantStream_handleRun2(event) {
|
|
32051
|
-
|
|
32156
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentRunSnapshot, event.data, "f");
|
|
32052
32157
|
switch (event.event) {
|
|
32053
32158
|
case "thread.run.created":
|
|
32054
32159
|
break;
|
|
@@ -32061,19 +32166,20 @@ _AssistantStream_addEvent = function _AssistantStream_addEvent2(event) {
|
|
|
32061
32166
|
case "thread.run.failed":
|
|
32062
32167
|
case "thread.run.completed":
|
|
32063
32168
|
case "thread.run.expired":
|
|
32064
|
-
|
|
32065
|
-
if (
|
|
32066
|
-
this._emit("toolCallDone",
|
|
32067
|
-
|
|
32169
|
+
__classPrivateFieldSet13(this, _AssistantStream_finalRun, event.data, "f");
|
|
32170
|
+
if (__classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f")) {
|
|
32171
|
+
this._emit("toolCallDone", __classPrivateFieldGet15(this, _AssistantStream_currentToolCall, "f"));
|
|
32172
|
+
__classPrivateFieldSet13(this, _AssistantStream_currentToolCall, undefined, "f");
|
|
32068
32173
|
}
|
|
32069
32174
|
break;
|
|
32070
32175
|
case "thread.run.cancelling":
|
|
32071
32176
|
break;
|
|
32072
32177
|
}
|
|
32073
32178
|
};
|
|
32179
|
+
function assertNever2(_x) {}
|
|
32074
32180
|
|
|
32075
32181
|
// ../../node_modules/openai/resources/beta/threads/messages.mjs
|
|
32076
|
-
class
|
|
32182
|
+
class Messages4 extends APIResource2 {
|
|
32077
32183
|
create(threadId, body2, options) {
|
|
32078
32184
|
return this._client.post(`/threads/${threadId}/messages`, {
|
|
32079
32185
|
body: body2,
|
|
@@ -32114,7 +32220,7 @@ class Messages3 extends APIResource2 {
|
|
|
32114
32220
|
|
|
32115
32221
|
class MessagesPage extends CursorPage {
|
|
32116
32222
|
}
|
|
32117
|
-
|
|
32223
|
+
Messages4.MessagesPage = MessagesPage;
|
|
32118
32224
|
|
|
32119
32225
|
// ../../node_modules/openai/resources/beta/threads/runs/steps.mjs
|
|
32120
32226
|
class Steps extends APIResource2 {
|
|
@@ -32265,7 +32371,7 @@ class Threads extends APIResource2 {
|
|
|
32265
32371
|
constructor() {
|
|
32266
32372
|
super(...arguments);
|
|
32267
32373
|
this.runs = new Runs(this._client);
|
|
32268
|
-
this.messages = new
|
|
32374
|
+
this.messages = new Messages4(this._client);
|
|
32269
32375
|
}
|
|
32270
32376
|
create(body2 = {}, options) {
|
|
32271
32377
|
if (isRequestOptions2(body2)) {
|
|
@@ -32314,263 +32420,20 @@ class Threads extends APIResource2 {
|
|
|
32314
32420
|
}
|
|
32315
32421
|
Threads.Runs = Runs;
|
|
32316
32422
|
Threads.RunsPage = RunsPage;
|
|
32317
|
-
Threads.Messages =
|
|
32423
|
+
Threads.Messages = Messages4;
|
|
32318
32424
|
Threads.MessagesPage = MessagesPage;
|
|
32319
32425
|
|
|
32320
|
-
// ../../node_modules/openai/lib/Util.mjs
|
|
32321
|
-
var allSettledWithThrow = async (promises) => {
|
|
32322
|
-
const results = await Promise.allSettled(promises);
|
|
32323
|
-
const rejected = results.filter((result) => result.status === "rejected");
|
|
32324
|
-
if (rejected.length) {
|
|
32325
|
-
for (const result of rejected) {
|
|
32326
|
-
console.error(result.reason);
|
|
32327
|
-
}
|
|
32328
|
-
throw new Error(`${rejected.length} promise(s) failed - see the above errors`);
|
|
32329
|
-
}
|
|
32330
|
-
const values = [];
|
|
32331
|
-
for (const result of results) {
|
|
32332
|
-
if (result.status === "fulfilled") {
|
|
32333
|
-
values.push(result.value);
|
|
32334
|
-
}
|
|
32335
|
-
}
|
|
32336
|
-
return values;
|
|
32337
|
-
};
|
|
32338
|
-
|
|
32339
|
-
// ../../node_modules/openai/resources/beta/vector-stores/files.mjs
|
|
32340
|
-
class Files extends APIResource2 {
|
|
32341
|
-
create(vectorStoreId, body2, options) {
|
|
32342
|
-
return this._client.post(`/vector_stores/${vectorStoreId}/files`, {
|
|
32343
|
-
body: body2,
|
|
32344
|
-
...options,
|
|
32345
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32346
|
-
});
|
|
32347
|
-
}
|
|
32348
|
-
retrieve(vectorStoreId, fileId, options) {
|
|
32349
|
-
return this._client.get(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
|
32350
|
-
...options,
|
|
32351
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32352
|
-
});
|
|
32353
|
-
}
|
|
32354
|
-
list(vectorStoreId, query = {}, options) {
|
|
32355
|
-
if (isRequestOptions2(query)) {
|
|
32356
|
-
return this.list(vectorStoreId, {}, query);
|
|
32357
|
-
}
|
|
32358
|
-
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/files`, VectorStoreFilesPage, {
|
|
32359
|
-
query,
|
|
32360
|
-
...options,
|
|
32361
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32362
|
-
});
|
|
32363
|
-
}
|
|
32364
|
-
del(vectorStoreId, fileId, options) {
|
|
32365
|
-
return this._client.delete(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
|
32366
|
-
...options,
|
|
32367
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32368
|
-
});
|
|
32369
|
-
}
|
|
32370
|
-
async createAndPoll(vectorStoreId, body2, options) {
|
|
32371
|
-
const file = await this.create(vectorStoreId, body2, options);
|
|
32372
|
-
return await this.poll(vectorStoreId, file.id, options);
|
|
32373
|
-
}
|
|
32374
|
-
async poll(vectorStoreId, fileId, options) {
|
|
32375
|
-
const headers = { ...options?.headers, "X-Stainless-Poll-Helper": "true" };
|
|
32376
|
-
if (options?.pollIntervalMs) {
|
|
32377
|
-
headers["X-Stainless-Custom-Poll-Interval"] = options.pollIntervalMs.toString();
|
|
32378
|
-
}
|
|
32379
|
-
while (true) {
|
|
32380
|
-
const fileResponse = await this.retrieve(vectorStoreId, fileId, {
|
|
32381
|
-
...options,
|
|
32382
|
-
headers
|
|
32383
|
-
}).withResponse();
|
|
32384
|
-
const file = fileResponse.data;
|
|
32385
|
-
switch (file.status) {
|
|
32386
|
-
case "in_progress":
|
|
32387
|
-
let sleepInterval = 5000;
|
|
32388
|
-
if (options?.pollIntervalMs) {
|
|
32389
|
-
sleepInterval = options.pollIntervalMs;
|
|
32390
|
-
} else {
|
|
32391
|
-
const headerInterval = fileResponse.response.headers.get("openai-poll-after-ms");
|
|
32392
|
-
if (headerInterval) {
|
|
32393
|
-
const headerIntervalMs = parseInt(headerInterval);
|
|
32394
|
-
if (!isNaN(headerIntervalMs)) {
|
|
32395
|
-
sleepInterval = headerIntervalMs;
|
|
32396
|
-
}
|
|
32397
|
-
}
|
|
32398
|
-
}
|
|
32399
|
-
await sleep2(sleepInterval);
|
|
32400
|
-
break;
|
|
32401
|
-
case "failed":
|
|
32402
|
-
case "completed":
|
|
32403
|
-
return file;
|
|
32404
|
-
}
|
|
32405
|
-
}
|
|
32406
|
-
}
|
|
32407
|
-
async upload(vectorStoreId, file, options) {
|
|
32408
|
-
const fileInfo = await this._client.files.create({ file, purpose: "assistants" }, options);
|
|
32409
|
-
return this.create(vectorStoreId, { file_id: fileInfo.id }, options);
|
|
32410
|
-
}
|
|
32411
|
-
async uploadAndPoll(vectorStoreId, file, options) {
|
|
32412
|
-
const fileInfo = await this.upload(vectorStoreId, file, options);
|
|
32413
|
-
return await this.poll(vectorStoreId, fileInfo.id, options);
|
|
32414
|
-
}
|
|
32415
|
-
}
|
|
32416
|
-
|
|
32417
|
-
class VectorStoreFilesPage extends CursorPage {
|
|
32418
|
-
}
|
|
32419
|
-
Files.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
32420
|
-
|
|
32421
|
-
// ../../node_modules/openai/resources/beta/vector-stores/file-batches.mjs
|
|
32422
|
-
class FileBatches extends APIResource2 {
|
|
32423
|
-
create(vectorStoreId, body2, options) {
|
|
32424
|
-
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, {
|
|
32425
|
-
body: body2,
|
|
32426
|
-
...options,
|
|
32427
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32428
|
-
});
|
|
32429
|
-
}
|
|
32430
|
-
retrieve(vectorStoreId, batchId, options) {
|
|
32431
|
-
return this._client.get(`/vector_stores/${vectorStoreId}/file_batches/${batchId}`, {
|
|
32432
|
-
...options,
|
|
32433
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32434
|
-
});
|
|
32435
|
-
}
|
|
32436
|
-
cancel(vectorStoreId, batchId, options) {
|
|
32437
|
-
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/cancel`, {
|
|
32438
|
-
...options,
|
|
32439
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32440
|
-
});
|
|
32441
|
-
}
|
|
32442
|
-
async createAndPoll(vectorStoreId, body2, options) {
|
|
32443
|
-
const batch = await this.create(vectorStoreId, body2);
|
|
32444
|
-
return await this.poll(vectorStoreId, batch.id, options);
|
|
32445
|
-
}
|
|
32446
|
-
listFiles(vectorStoreId, batchId, query = {}, options) {
|
|
32447
|
-
if (isRequestOptions2(query)) {
|
|
32448
|
-
return this.listFiles(vectorStoreId, batchId, {}, query);
|
|
32449
|
-
}
|
|
32450
|
-
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/files`, VectorStoreFilesPage, { query, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers } });
|
|
32451
|
-
}
|
|
32452
|
-
async poll(vectorStoreId, batchId, options) {
|
|
32453
|
-
const headers = { ...options?.headers, "X-Stainless-Poll-Helper": "true" };
|
|
32454
|
-
if (options?.pollIntervalMs) {
|
|
32455
|
-
headers["X-Stainless-Custom-Poll-Interval"] = options.pollIntervalMs.toString();
|
|
32456
|
-
}
|
|
32457
|
-
while (true) {
|
|
32458
|
-
const { data: batch, response } = await this.retrieve(vectorStoreId, batchId, {
|
|
32459
|
-
...options,
|
|
32460
|
-
headers
|
|
32461
|
-
}).withResponse();
|
|
32462
|
-
switch (batch.status) {
|
|
32463
|
-
case "in_progress":
|
|
32464
|
-
let sleepInterval = 5000;
|
|
32465
|
-
if (options?.pollIntervalMs) {
|
|
32466
|
-
sleepInterval = options.pollIntervalMs;
|
|
32467
|
-
} else {
|
|
32468
|
-
const headerInterval = response.headers.get("openai-poll-after-ms");
|
|
32469
|
-
if (headerInterval) {
|
|
32470
|
-
const headerIntervalMs = parseInt(headerInterval);
|
|
32471
|
-
if (!isNaN(headerIntervalMs)) {
|
|
32472
|
-
sleepInterval = headerIntervalMs;
|
|
32473
|
-
}
|
|
32474
|
-
}
|
|
32475
|
-
}
|
|
32476
|
-
await sleep2(sleepInterval);
|
|
32477
|
-
break;
|
|
32478
|
-
case "failed":
|
|
32479
|
-
case "cancelled":
|
|
32480
|
-
case "completed":
|
|
32481
|
-
return batch;
|
|
32482
|
-
}
|
|
32483
|
-
}
|
|
32484
|
-
}
|
|
32485
|
-
async uploadAndPoll(vectorStoreId, { files, fileIds = [] }, options) {
|
|
32486
|
-
if (files == null || files.length == 0) {
|
|
32487
|
-
throw new Error(`No \`files\` provided to process. If you've already uploaded files you should use \`.createAndPoll()\` instead`);
|
|
32488
|
-
}
|
|
32489
|
-
const configuredConcurrency = options?.maxConcurrency ?? 5;
|
|
32490
|
-
const concurrencyLimit = Math.min(configuredConcurrency, files.length);
|
|
32491
|
-
const client = this._client;
|
|
32492
|
-
const fileIterator = files.values();
|
|
32493
|
-
const allFileIds = [...fileIds];
|
|
32494
|
-
async function processFiles(iterator) {
|
|
32495
|
-
for (let item of iterator) {
|
|
32496
|
-
const fileObj = await client.files.create({ file: item, purpose: "assistants" }, options);
|
|
32497
|
-
allFileIds.push(fileObj.id);
|
|
32498
|
-
}
|
|
32499
|
-
}
|
|
32500
|
-
const workers = Array(concurrencyLimit).fill(fileIterator).map(processFiles);
|
|
32501
|
-
await allSettledWithThrow(workers);
|
|
32502
|
-
return await this.createAndPoll(vectorStoreId, {
|
|
32503
|
-
file_ids: allFileIds
|
|
32504
|
-
});
|
|
32505
|
-
}
|
|
32506
|
-
}
|
|
32507
|
-
|
|
32508
|
-
// ../../node_modules/openai/resources/beta/vector-stores/vector-stores.mjs
|
|
32509
|
-
class VectorStores extends APIResource2 {
|
|
32510
|
-
constructor() {
|
|
32511
|
-
super(...arguments);
|
|
32512
|
-
this.files = new Files(this._client);
|
|
32513
|
-
this.fileBatches = new FileBatches(this._client);
|
|
32514
|
-
}
|
|
32515
|
-
create(body2, options) {
|
|
32516
|
-
return this._client.post("/vector_stores", {
|
|
32517
|
-
body: body2,
|
|
32518
|
-
...options,
|
|
32519
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32520
|
-
});
|
|
32521
|
-
}
|
|
32522
|
-
retrieve(vectorStoreId, options) {
|
|
32523
|
-
return this._client.get(`/vector_stores/${vectorStoreId}`, {
|
|
32524
|
-
...options,
|
|
32525
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32526
|
-
});
|
|
32527
|
-
}
|
|
32528
|
-
update(vectorStoreId, body2, options) {
|
|
32529
|
-
return this._client.post(`/vector_stores/${vectorStoreId}`, {
|
|
32530
|
-
body: body2,
|
|
32531
|
-
...options,
|
|
32532
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32533
|
-
});
|
|
32534
|
-
}
|
|
32535
|
-
list(query = {}, options) {
|
|
32536
|
-
if (isRequestOptions2(query)) {
|
|
32537
|
-
return this.list({}, query);
|
|
32538
|
-
}
|
|
32539
|
-
return this._client.getAPIList("/vector_stores", VectorStoresPage, {
|
|
32540
|
-
query,
|
|
32541
|
-
...options,
|
|
32542
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32543
|
-
});
|
|
32544
|
-
}
|
|
32545
|
-
del(vectorStoreId, options) {
|
|
32546
|
-
return this._client.delete(`/vector_stores/${vectorStoreId}`, {
|
|
32547
|
-
...options,
|
|
32548
|
-
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
32549
|
-
});
|
|
32550
|
-
}
|
|
32551
|
-
}
|
|
32552
|
-
|
|
32553
|
-
class VectorStoresPage extends CursorPage {
|
|
32554
|
-
}
|
|
32555
|
-
VectorStores.VectorStoresPage = VectorStoresPage;
|
|
32556
|
-
VectorStores.Files = Files;
|
|
32557
|
-
VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
32558
|
-
VectorStores.FileBatches = FileBatches;
|
|
32559
|
-
|
|
32560
32426
|
// ../../node_modules/openai/resources/beta/beta.mjs
|
|
32561
32427
|
class Beta2 extends APIResource2 {
|
|
32562
32428
|
constructor() {
|
|
32563
32429
|
super(...arguments);
|
|
32564
32430
|
this.realtime = new Realtime(this._client);
|
|
32565
|
-
this.vectorStores = new VectorStores(this._client);
|
|
32566
32431
|
this.chat = new Chat2(this._client);
|
|
32567
32432
|
this.assistants = new Assistants(this._client);
|
|
32568
32433
|
this.threads = new Threads(this._client);
|
|
32569
32434
|
}
|
|
32570
32435
|
}
|
|
32571
32436
|
Beta2.Realtime = Realtime;
|
|
32572
|
-
Beta2.VectorStores = VectorStores;
|
|
32573
|
-
Beta2.VectorStoresPage = VectorStoresPage;
|
|
32574
32437
|
Beta2.Assistants = Assistants;
|
|
32575
32438
|
Beta2.AssistantsPage = AssistantsPage;
|
|
32576
32439
|
Beta2.Threads = Threads;
|
|
@@ -32587,7 +32450,7 @@ class Embeddings extends APIResource2 {
|
|
|
32587
32450
|
}
|
|
32588
32451
|
}
|
|
32589
32452
|
// ../../node_modules/openai/resources/files.mjs
|
|
32590
|
-
class
|
|
32453
|
+
class Files extends APIResource2 {
|
|
32591
32454
|
create(body2, options) {
|
|
32592
32455
|
return this._client.post("/files", multipartFormRequestOptions({ body: body2, ...options }));
|
|
32593
32456
|
}
|
|
@@ -32632,7 +32495,7 @@ class Files2 extends APIResource2 {
|
|
|
32632
32495
|
|
|
32633
32496
|
class FileObjectsPage extends CursorPage {
|
|
32634
32497
|
}
|
|
32635
|
-
|
|
32498
|
+
Files.FileObjectsPage = FileObjectsPage;
|
|
32636
32499
|
// ../../node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
|
|
32637
32500
|
class Checkpoints extends APIResource2 {
|
|
32638
32501
|
list(fineTuningJobId, query = {}, options) {
|
|
@@ -32733,6 +32596,416 @@ class Moderations extends APIResource2 {
|
|
|
32733
32596
|
return this._client.post("/moderations", { body: body2, ...options });
|
|
32734
32597
|
}
|
|
32735
32598
|
}
|
|
32599
|
+
// ../../node_modules/openai/lib/ResponsesParser.mjs
|
|
32600
|
+
function maybeParseResponse(response, params) {
|
|
32601
|
+
if (!params || !hasAutoParseableInput2(params)) {
|
|
32602
|
+
return {
|
|
32603
|
+
...response,
|
|
32604
|
+
output_parsed: null,
|
|
32605
|
+
output: response.output.map((item) => {
|
|
32606
|
+
if (item.type === "function_call") {
|
|
32607
|
+
return {
|
|
32608
|
+
...item,
|
|
32609
|
+
parsed_arguments: null
|
|
32610
|
+
};
|
|
32611
|
+
}
|
|
32612
|
+
if (item.type === "message") {
|
|
32613
|
+
return {
|
|
32614
|
+
...item,
|
|
32615
|
+
content: item.content.map((content) => ({
|
|
32616
|
+
...content,
|
|
32617
|
+
parsed: null
|
|
32618
|
+
}))
|
|
32619
|
+
};
|
|
32620
|
+
} else {
|
|
32621
|
+
return item;
|
|
32622
|
+
}
|
|
32623
|
+
})
|
|
32624
|
+
};
|
|
32625
|
+
}
|
|
32626
|
+
return parseResponse(response, params);
|
|
32627
|
+
}
|
|
32628
|
+
function parseResponse(response, params) {
|
|
32629
|
+
const output = response.output.map((item) => {
|
|
32630
|
+
if (item.type === "function_call") {
|
|
32631
|
+
return {
|
|
32632
|
+
...item,
|
|
32633
|
+
parsed_arguments: parseToolCall2(params, item)
|
|
32634
|
+
};
|
|
32635
|
+
}
|
|
32636
|
+
if (item.type === "message") {
|
|
32637
|
+
const content = item.content.map((content2) => {
|
|
32638
|
+
if (content2.type === "output_text") {
|
|
32639
|
+
return {
|
|
32640
|
+
...content2,
|
|
32641
|
+
parsed: parseTextFormat(params, content2.text)
|
|
32642
|
+
};
|
|
32643
|
+
}
|
|
32644
|
+
return content2;
|
|
32645
|
+
});
|
|
32646
|
+
return {
|
|
32647
|
+
...item,
|
|
32648
|
+
content
|
|
32649
|
+
};
|
|
32650
|
+
}
|
|
32651
|
+
return item;
|
|
32652
|
+
});
|
|
32653
|
+
const parsed = Object.assign({}, response, { output });
|
|
32654
|
+
if (!Object.getOwnPropertyDescriptor(response, "output_text")) {
|
|
32655
|
+
addOutputText(parsed);
|
|
32656
|
+
}
|
|
32657
|
+
Object.defineProperty(parsed, "output_parsed", {
|
|
32658
|
+
enumerable: true,
|
|
32659
|
+
get() {
|
|
32660
|
+
for (const output2 of parsed.output) {
|
|
32661
|
+
if (output2.type !== "message") {
|
|
32662
|
+
continue;
|
|
32663
|
+
}
|
|
32664
|
+
for (const content of output2.content) {
|
|
32665
|
+
if (content.type === "output_text" && content.parsed !== null) {
|
|
32666
|
+
return content.parsed;
|
|
32667
|
+
}
|
|
32668
|
+
}
|
|
32669
|
+
}
|
|
32670
|
+
return null;
|
|
32671
|
+
}
|
|
32672
|
+
});
|
|
32673
|
+
return parsed;
|
|
32674
|
+
}
|
|
32675
|
+
function parseTextFormat(params, content) {
|
|
32676
|
+
if (params.text?.format?.type !== "json_schema") {
|
|
32677
|
+
return null;
|
|
32678
|
+
}
|
|
32679
|
+
if ("$parseRaw" in params.text?.format) {
|
|
32680
|
+
const text_format = params.text?.format;
|
|
32681
|
+
return text_format.$parseRaw(content);
|
|
32682
|
+
}
|
|
32683
|
+
return JSON.parse(content);
|
|
32684
|
+
}
|
|
32685
|
+
function hasAutoParseableInput2(params) {
|
|
32686
|
+
if (isAutoParsableResponseFormat(params.text?.format)) {
|
|
32687
|
+
return true;
|
|
32688
|
+
}
|
|
32689
|
+
return false;
|
|
32690
|
+
}
|
|
32691
|
+
function isAutoParsableTool2(tool) {
|
|
32692
|
+
return tool?.["$brand"] === "auto-parseable-tool";
|
|
32693
|
+
}
|
|
32694
|
+
function getInputToolByName(input_tools, name2) {
|
|
32695
|
+
return input_tools.find((tool) => tool.type === "function" && tool.name === name2);
|
|
32696
|
+
}
|
|
32697
|
+
function parseToolCall2(params, toolCall) {
|
|
32698
|
+
const inputTool = getInputToolByName(params.tools ?? [], toolCall.name);
|
|
32699
|
+
return {
|
|
32700
|
+
...toolCall,
|
|
32701
|
+
...toolCall,
|
|
32702
|
+
parsed_arguments: isAutoParsableTool2(inputTool) ? inputTool.$parseRaw(toolCall.arguments) : inputTool?.strict ? JSON.parse(toolCall.arguments) : null
|
|
32703
|
+
};
|
|
32704
|
+
}
|
|
32705
|
+
function addOutputText(rsp) {
|
|
32706
|
+
const texts = [];
|
|
32707
|
+
for (const output of rsp.output) {
|
|
32708
|
+
if (output.type !== "message") {
|
|
32709
|
+
continue;
|
|
32710
|
+
}
|
|
32711
|
+
for (const content of output.content) {
|
|
32712
|
+
if (content.type === "output_text") {
|
|
32713
|
+
texts.push(content.text);
|
|
32714
|
+
}
|
|
32715
|
+
}
|
|
32716
|
+
}
|
|
32717
|
+
rsp.output_text = texts.join("");
|
|
32718
|
+
}
|
|
32719
|
+
|
|
32720
|
+
// ../../node_modules/openai/resources/responses/input-items.mjs
|
|
32721
|
+
class InputItems extends APIResource2 {
|
|
32722
|
+
list(responseId, query = {}, options) {
|
|
32723
|
+
if (isRequestOptions2(query)) {
|
|
32724
|
+
return this.list(responseId, {}, query);
|
|
32725
|
+
}
|
|
32726
|
+
return this._client.getAPIList(`/responses/${responseId}/input_items`, ResponseItemsPage, {
|
|
32727
|
+
query,
|
|
32728
|
+
...options
|
|
32729
|
+
});
|
|
32730
|
+
}
|
|
32731
|
+
}
|
|
32732
|
+
|
|
32733
|
+
// ../../node_modules/openai/lib/responses/ResponseStream.mjs
|
|
32734
|
+
var __classPrivateFieldSet14 = function(receiver, state, value, kind3, f2) {
|
|
32735
|
+
if (kind3 === "m")
|
|
32736
|
+
throw new TypeError("Private method is not writable");
|
|
32737
|
+
if (kind3 === "a" && !f2)
|
|
32738
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
32739
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
32740
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
32741
|
+
return kind3 === "a" ? f2.call(receiver, value) : f2 ? f2.value = value : state.set(receiver, value), value;
|
|
32742
|
+
};
|
|
32743
|
+
var __classPrivateFieldGet16 = function(receiver, state, kind3, f2) {
|
|
32744
|
+
if (kind3 === "a" && !f2)
|
|
32745
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
32746
|
+
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
32747
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
32748
|
+
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
32749
|
+
};
|
|
32750
|
+
var _ResponseStream_instances;
|
|
32751
|
+
var _ResponseStream_params;
|
|
32752
|
+
var _ResponseStream_currentResponseSnapshot;
|
|
32753
|
+
var _ResponseStream_finalResponse;
|
|
32754
|
+
var _ResponseStream_beginRequest;
|
|
32755
|
+
var _ResponseStream_addEvent;
|
|
32756
|
+
var _ResponseStream_endRequest;
|
|
32757
|
+
var _ResponseStream_accumulateResponse;
|
|
32758
|
+
|
|
32759
|
+
class ResponseStream extends EventStream {
|
|
32760
|
+
constructor(params) {
|
|
32761
|
+
super();
|
|
32762
|
+
_ResponseStream_instances.add(this);
|
|
32763
|
+
_ResponseStream_params.set(this, undefined);
|
|
32764
|
+
_ResponseStream_currentResponseSnapshot.set(this, undefined);
|
|
32765
|
+
_ResponseStream_finalResponse.set(this, undefined);
|
|
32766
|
+
__classPrivateFieldSet14(this, _ResponseStream_params, params, "f");
|
|
32767
|
+
}
|
|
32768
|
+
static createResponse(client, params, options) {
|
|
32769
|
+
const runner = new ResponseStream(params);
|
|
32770
|
+
runner._run(() => runner._createResponse(client, params, {
|
|
32771
|
+
...options,
|
|
32772
|
+
headers: { ...options?.headers, "X-Stainless-Helper-Method": "stream" }
|
|
32773
|
+
}));
|
|
32774
|
+
return runner;
|
|
32775
|
+
}
|
|
32776
|
+
async _createResponse(client, params, options) {
|
|
32777
|
+
const signal = options?.signal;
|
|
32778
|
+
if (signal) {
|
|
32779
|
+
if (signal.aborted)
|
|
32780
|
+
this.controller.abort();
|
|
32781
|
+
signal.addEventListener("abort", () => this.controller.abort());
|
|
32782
|
+
}
|
|
32783
|
+
__classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_beginRequest).call(this);
|
|
32784
|
+
const stream = await client.responses.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
32785
|
+
this._connected();
|
|
32786
|
+
for await (const event of stream) {
|
|
32787
|
+
__classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_addEvent).call(this, event);
|
|
32788
|
+
}
|
|
32789
|
+
if (stream.controller.signal?.aborted) {
|
|
32790
|
+
throw new APIUserAbortError2;
|
|
32791
|
+
}
|
|
32792
|
+
return __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
32793
|
+
}
|
|
32794
|
+
[(_ResponseStream_params = new WeakMap, _ResponseStream_currentResponseSnapshot = new WeakMap, _ResponseStream_finalResponse = new WeakMap, _ResponseStream_instances = new WeakSet, _ResponseStream_beginRequest = function _ResponseStream_beginRequest() {
|
|
32795
|
+
if (this.ended)
|
|
32796
|
+
return;
|
|
32797
|
+
__classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
32798
|
+
}, _ResponseStream_addEvent = function _ResponseStream_addEvent(event) {
|
|
32799
|
+
if (this.ended)
|
|
32800
|
+
return;
|
|
32801
|
+
const response = __classPrivateFieldGet16(this, _ResponseStream_instances, "m", _ResponseStream_accumulateResponse).call(this, event);
|
|
32802
|
+
this._emit("event", event);
|
|
32803
|
+
switch (event.type) {
|
|
32804
|
+
case "response.output_text.delta": {
|
|
32805
|
+
const output = response.output[event.output_index];
|
|
32806
|
+
if (!output) {
|
|
32807
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
32808
|
+
}
|
|
32809
|
+
if (output.type === "message") {
|
|
32810
|
+
const content = output.content[event.content_index];
|
|
32811
|
+
if (!content) {
|
|
32812
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
32813
|
+
}
|
|
32814
|
+
if (content.type !== "output_text") {
|
|
32815
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
32816
|
+
}
|
|
32817
|
+
this._emit("response.output_text.delta", {
|
|
32818
|
+
...event,
|
|
32819
|
+
snapshot: content.text
|
|
32820
|
+
});
|
|
32821
|
+
}
|
|
32822
|
+
break;
|
|
32823
|
+
}
|
|
32824
|
+
case "response.function_call_arguments.delta": {
|
|
32825
|
+
const output = response.output[event.output_index];
|
|
32826
|
+
if (!output) {
|
|
32827
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
32828
|
+
}
|
|
32829
|
+
if (output.type === "function_call") {
|
|
32830
|
+
this._emit("response.function_call_arguments.delta", {
|
|
32831
|
+
...event,
|
|
32832
|
+
snapshot: output.arguments
|
|
32833
|
+
});
|
|
32834
|
+
}
|
|
32835
|
+
break;
|
|
32836
|
+
}
|
|
32837
|
+
default:
|
|
32838
|
+
this._emit(event.type, event);
|
|
32839
|
+
break;
|
|
32840
|
+
}
|
|
32841
|
+
}, _ResponseStream_endRequest = function _ResponseStream_endRequest() {
|
|
32842
|
+
if (this.ended) {
|
|
32843
|
+
throw new OpenAIError(`stream has ended, this shouldn't happen`);
|
|
32844
|
+
}
|
|
32845
|
+
const snapshot = __classPrivateFieldGet16(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
32846
|
+
if (!snapshot) {
|
|
32847
|
+
throw new OpenAIError(`request ended without sending any events`);
|
|
32848
|
+
}
|
|
32849
|
+
__classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, undefined, "f");
|
|
32850
|
+
const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet16(this, _ResponseStream_params, "f"));
|
|
32851
|
+
__classPrivateFieldSet14(this, _ResponseStream_finalResponse, parsedResponse, "f");
|
|
32852
|
+
return parsedResponse;
|
|
32853
|
+
}, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse(event) {
|
|
32854
|
+
let snapshot = __classPrivateFieldGet16(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
32855
|
+
if (!snapshot) {
|
|
32856
|
+
if (event.type !== "response.created") {
|
|
32857
|
+
throw new OpenAIError(`When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`);
|
|
32858
|
+
}
|
|
32859
|
+
snapshot = __classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
|
|
32860
|
+
return snapshot;
|
|
32861
|
+
}
|
|
32862
|
+
switch (event.type) {
|
|
32863
|
+
case "response.output_item.added": {
|
|
32864
|
+
snapshot.output.push(event.item);
|
|
32865
|
+
break;
|
|
32866
|
+
}
|
|
32867
|
+
case "response.content_part.added": {
|
|
32868
|
+
const output = snapshot.output[event.output_index];
|
|
32869
|
+
if (!output) {
|
|
32870
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
32871
|
+
}
|
|
32872
|
+
if (output.type === "message") {
|
|
32873
|
+
output.content.push(event.part);
|
|
32874
|
+
}
|
|
32875
|
+
break;
|
|
32876
|
+
}
|
|
32877
|
+
case "response.output_text.delta": {
|
|
32878
|
+
const output = snapshot.output[event.output_index];
|
|
32879
|
+
if (!output) {
|
|
32880
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
32881
|
+
}
|
|
32882
|
+
if (output.type === "message") {
|
|
32883
|
+
const content = output.content[event.content_index];
|
|
32884
|
+
if (!content) {
|
|
32885
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
32886
|
+
}
|
|
32887
|
+
if (content.type !== "output_text") {
|
|
32888
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
32889
|
+
}
|
|
32890
|
+
content.text += event.delta;
|
|
32891
|
+
}
|
|
32892
|
+
break;
|
|
32893
|
+
}
|
|
32894
|
+
case "response.function_call_arguments.delta": {
|
|
32895
|
+
const output = snapshot.output[event.output_index];
|
|
32896
|
+
if (!output) {
|
|
32897
|
+
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
32898
|
+
}
|
|
32899
|
+
if (output.type === "function_call") {
|
|
32900
|
+
output.arguments += event.delta;
|
|
32901
|
+
}
|
|
32902
|
+
break;
|
|
32903
|
+
}
|
|
32904
|
+
case "response.completed": {
|
|
32905
|
+
__classPrivateFieldSet14(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
|
|
32906
|
+
break;
|
|
32907
|
+
}
|
|
32908
|
+
}
|
|
32909
|
+
return snapshot;
|
|
32910
|
+
}, Symbol.asyncIterator)]() {
|
|
32911
|
+
const pushQueue = [];
|
|
32912
|
+
const readQueue = [];
|
|
32913
|
+
let done = false;
|
|
32914
|
+
this.on("event", (event) => {
|
|
32915
|
+
const reader = readQueue.shift();
|
|
32916
|
+
if (reader) {
|
|
32917
|
+
reader.resolve(event);
|
|
32918
|
+
} else {
|
|
32919
|
+
pushQueue.push(event);
|
|
32920
|
+
}
|
|
32921
|
+
});
|
|
32922
|
+
this.on("end", () => {
|
|
32923
|
+
done = true;
|
|
32924
|
+
for (const reader of readQueue) {
|
|
32925
|
+
reader.resolve(undefined);
|
|
32926
|
+
}
|
|
32927
|
+
readQueue.length = 0;
|
|
32928
|
+
});
|
|
32929
|
+
this.on("abort", (err2) => {
|
|
32930
|
+
done = true;
|
|
32931
|
+
for (const reader of readQueue) {
|
|
32932
|
+
reader.reject(err2);
|
|
32933
|
+
}
|
|
32934
|
+
readQueue.length = 0;
|
|
32935
|
+
});
|
|
32936
|
+
this.on("error", (err2) => {
|
|
32937
|
+
done = true;
|
|
32938
|
+
for (const reader of readQueue) {
|
|
32939
|
+
reader.reject(err2);
|
|
32940
|
+
}
|
|
32941
|
+
readQueue.length = 0;
|
|
32942
|
+
});
|
|
32943
|
+
return {
|
|
32944
|
+
next: async () => {
|
|
32945
|
+
if (!pushQueue.length) {
|
|
32946
|
+
if (done) {
|
|
32947
|
+
return { value: undefined, done: true };
|
|
32948
|
+
}
|
|
32949
|
+
return new Promise((resolve, reject) => readQueue.push({ resolve, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: undefined, done: true });
|
|
32950
|
+
}
|
|
32951
|
+
const event = pushQueue.shift();
|
|
32952
|
+
return { value: event, done: false };
|
|
32953
|
+
},
|
|
32954
|
+
return: async () => {
|
|
32955
|
+
this.abort();
|
|
32956
|
+
return { value: undefined, done: true };
|
|
32957
|
+
}
|
|
32958
|
+
};
|
|
32959
|
+
}
|
|
32960
|
+
async finalResponse() {
|
|
32961
|
+
await this.done();
|
|
32962
|
+
const response = __classPrivateFieldGet16(this, _ResponseStream_finalResponse, "f");
|
|
32963
|
+
if (!response)
|
|
32964
|
+
throw new OpenAIError("stream ended without producing a ChatCompletion");
|
|
32965
|
+
return response;
|
|
32966
|
+
}
|
|
32967
|
+
}
|
|
32968
|
+
function finalizeResponse(snapshot, params) {
|
|
32969
|
+
return maybeParseResponse(snapshot, params);
|
|
32970
|
+
}
|
|
32971
|
+
|
|
32972
|
+
// ../../node_modules/openai/resources/responses/responses.mjs
|
|
32973
|
+
class Responses extends APIResource2 {
|
|
32974
|
+
constructor() {
|
|
32975
|
+
super(...arguments);
|
|
32976
|
+
this.inputItems = new InputItems(this._client);
|
|
32977
|
+
}
|
|
32978
|
+
create(body2, options) {
|
|
32979
|
+
return this._client.post("/responses", { body: body2, ...options, stream: body2.stream ?? false })._thenUnwrap((rsp) => {
|
|
32980
|
+
if ("object" in rsp && rsp.object === "response") {
|
|
32981
|
+
addOutputText(rsp);
|
|
32982
|
+
}
|
|
32983
|
+
return rsp;
|
|
32984
|
+
});
|
|
32985
|
+
}
|
|
32986
|
+
retrieve(responseId, query = {}, options) {
|
|
32987
|
+
if (isRequestOptions2(query)) {
|
|
32988
|
+
return this.retrieve(responseId, {}, query);
|
|
32989
|
+
}
|
|
32990
|
+
return this._client.get(`/responses/${responseId}`, { query, ...options });
|
|
32991
|
+
}
|
|
32992
|
+
del(responseId, options) {
|
|
32993
|
+
return this._client.delete(`/responses/${responseId}`, {
|
|
32994
|
+
...options,
|
|
32995
|
+
headers: { Accept: "*/*", ...options?.headers }
|
|
32996
|
+
});
|
|
32997
|
+
}
|
|
32998
|
+
parse(body2, options) {
|
|
32999
|
+
return this._client.responses.create(body2, options)._thenUnwrap((response) => parseResponse(response, body2));
|
|
33000
|
+
}
|
|
33001
|
+
stream(body2, options) {
|
|
33002
|
+
return ResponseStream.createResponse(this._client, body2, options);
|
|
33003
|
+
}
|
|
33004
|
+
}
|
|
33005
|
+
|
|
33006
|
+
class ResponseItemsPage extends CursorPage {
|
|
33007
|
+
}
|
|
33008
|
+
Responses.InputItems = InputItems;
|
|
32736
33009
|
// ../../node_modules/openai/resources/uploads/parts.mjs
|
|
32737
33010
|
class Parts extends APIResource2 {
|
|
32738
33011
|
create(uploadId, body2, options) {
|
|
@@ -32757,6 +33030,272 @@ class Uploads extends APIResource2 {
|
|
|
32757
33030
|
}
|
|
32758
33031
|
}
|
|
32759
33032
|
Uploads.Parts = Parts;
|
|
33033
|
+
// ../../node_modules/openai/lib/Util.mjs
|
|
33034
|
+
var allSettledWithThrow = async (promises) => {
|
|
33035
|
+
const results = await Promise.allSettled(promises);
|
|
33036
|
+
const rejected = results.filter((result) => result.status === "rejected");
|
|
33037
|
+
if (rejected.length) {
|
|
33038
|
+
for (const result of rejected) {
|
|
33039
|
+
console.error(result.reason);
|
|
33040
|
+
}
|
|
33041
|
+
throw new Error(`${rejected.length} promise(s) failed - see the above errors`);
|
|
33042
|
+
}
|
|
33043
|
+
const values = [];
|
|
33044
|
+
for (const result of results) {
|
|
33045
|
+
if (result.status === "fulfilled") {
|
|
33046
|
+
values.push(result.value);
|
|
33047
|
+
}
|
|
33048
|
+
}
|
|
33049
|
+
return values;
|
|
33050
|
+
};
|
|
33051
|
+
|
|
33052
|
+
// ../../node_modules/openai/resources/vector-stores/files.mjs
|
|
33053
|
+
class Files2 extends APIResource2 {
|
|
33054
|
+
create(vectorStoreId, body2, options) {
|
|
33055
|
+
return this._client.post(`/vector_stores/${vectorStoreId}/files`, {
|
|
33056
|
+
body: body2,
|
|
33057
|
+
...options,
|
|
33058
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33059
|
+
});
|
|
33060
|
+
}
|
|
33061
|
+
retrieve(vectorStoreId, fileId, options) {
|
|
33062
|
+
return this._client.get(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
|
33063
|
+
...options,
|
|
33064
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33065
|
+
});
|
|
33066
|
+
}
|
|
33067
|
+
update(vectorStoreId, fileId, body2, options) {
|
|
33068
|
+
return this._client.post(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
|
33069
|
+
body: body2,
|
|
33070
|
+
...options,
|
|
33071
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33072
|
+
});
|
|
33073
|
+
}
|
|
33074
|
+
list(vectorStoreId, query = {}, options) {
|
|
33075
|
+
if (isRequestOptions2(query)) {
|
|
33076
|
+
return this.list(vectorStoreId, {}, query);
|
|
33077
|
+
}
|
|
33078
|
+
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/files`, VectorStoreFilesPage, {
|
|
33079
|
+
query,
|
|
33080
|
+
...options,
|
|
33081
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33082
|
+
});
|
|
33083
|
+
}
|
|
33084
|
+
del(vectorStoreId, fileId, options) {
|
|
33085
|
+
return this._client.delete(`/vector_stores/${vectorStoreId}/files/${fileId}`, {
|
|
33086
|
+
...options,
|
|
33087
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33088
|
+
});
|
|
33089
|
+
}
|
|
33090
|
+
async createAndPoll(vectorStoreId, body2, options) {
|
|
33091
|
+
const file = await this.create(vectorStoreId, body2, options);
|
|
33092
|
+
return await this.poll(vectorStoreId, file.id, options);
|
|
33093
|
+
}
|
|
33094
|
+
async poll(vectorStoreId, fileId, options) {
|
|
33095
|
+
const headers = { ...options?.headers, "X-Stainless-Poll-Helper": "true" };
|
|
33096
|
+
if (options?.pollIntervalMs) {
|
|
33097
|
+
headers["X-Stainless-Custom-Poll-Interval"] = options.pollIntervalMs.toString();
|
|
33098
|
+
}
|
|
33099
|
+
while (true) {
|
|
33100
|
+
const fileResponse = await this.retrieve(vectorStoreId, fileId, {
|
|
33101
|
+
...options,
|
|
33102
|
+
headers
|
|
33103
|
+
}).withResponse();
|
|
33104
|
+
const file = fileResponse.data;
|
|
33105
|
+
switch (file.status) {
|
|
33106
|
+
case "in_progress":
|
|
33107
|
+
let sleepInterval = 5000;
|
|
33108
|
+
if (options?.pollIntervalMs) {
|
|
33109
|
+
sleepInterval = options.pollIntervalMs;
|
|
33110
|
+
} else {
|
|
33111
|
+
const headerInterval = fileResponse.response.headers.get("openai-poll-after-ms");
|
|
33112
|
+
if (headerInterval) {
|
|
33113
|
+
const headerIntervalMs = parseInt(headerInterval);
|
|
33114
|
+
if (!isNaN(headerIntervalMs)) {
|
|
33115
|
+
sleepInterval = headerIntervalMs;
|
|
33116
|
+
}
|
|
33117
|
+
}
|
|
33118
|
+
}
|
|
33119
|
+
await sleep2(sleepInterval);
|
|
33120
|
+
break;
|
|
33121
|
+
case "failed":
|
|
33122
|
+
case "completed":
|
|
33123
|
+
return file;
|
|
33124
|
+
}
|
|
33125
|
+
}
|
|
33126
|
+
}
|
|
33127
|
+
async upload(vectorStoreId, file, options) {
|
|
33128
|
+
const fileInfo = await this._client.files.create({ file, purpose: "assistants" }, options);
|
|
33129
|
+
return this.create(vectorStoreId, { file_id: fileInfo.id }, options);
|
|
33130
|
+
}
|
|
33131
|
+
async uploadAndPoll(vectorStoreId, file, options) {
|
|
33132
|
+
const fileInfo = await this.upload(vectorStoreId, file, options);
|
|
33133
|
+
return await this.poll(vectorStoreId, fileInfo.id, options);
|
|
33134
|
+
}
|
|
33135
|
+
content(vectorStoreId, fileId, options) {
|
|
33136
|
+
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/files/${fileId}/content`, FileContentResponsesPage, { ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers } });
|
|
33137
|
+
}
|
|
33138
|
+
}
|
|
33139
|
+
|
|
33140
|
+
class VectorStoreFilesPage extends CursorPage {
|
|
33141
|
+
}
|
|
33142
|
+
|
|
33143
|
+
class FileContentResponsesPage extends Page2 {
|
|
33144
|
+
}
|
|
33145
|
+
Files2.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
33146
|
+
Files2.FileContentResponsesPage = FileContentResponsesPage;
|
|
33147
|
+
|
|
33148
|
+
// ../../node_modules/openai/resources/vector-stores/file-batches.mjs
|
|
33149
|
+
class FileBatches extends APIResource2 {
|
|
33150
|
+
create(vectorStoreId, body2, options) {
|
|
33151
|
+
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches`, {
|
|
33152
|
+
body: body2,
|
|
33153
|
+
...options,
|
|
33154
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33155
|
+
});
|
|
33156
|
+
}
|
|
33157
|
+
retrieve(vectorStoreId, batchId, options) {
|
|
33158
|
+
return this._client.get(`/vector_stores/${vectorStoreId}/file_batches/${batchId}`, {
|
|
33159
|
+
...options,
|
|
33160
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33161
|
+
});
|
|
33162
|
+
}
|
|
33163
|
+
cancel(vectorStoreId, batchId, options) {
|
|
33164
|
+
return this._client.post(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/cancel`, {
|
|
33165
|
+
...options,
|
|
33166
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33167
|
+
});
|
|
33168
|
+
}
|
|
33169
|
+
async createAndPoll(vectorStoreId, body2, options) {
|
|
33170
|
+
const batch = await this.create(vectorStoreId, body2);
|
|
33171
|
+
return await this.poll(vectorStoreId, batch.id, options);
|
|
33172
|
+
}
|
|
33173
|
+
listFiles(vectorStoreId, batchId, query = {}, options) {
|
|
33174
|
+
if (isRequestOptions2(query)) {
|
|
33175
|
+
return this.listFiles(vectorStoreId, batchId, {}, query);
|
|
33176
|
+
}
|
|
33177
|
+
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/file_batches/${batchId}/files`, VectorStoreFilesPage, { query, ...options, headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers } });
|
|
33178
|
+
}
|
|
33179
|
+
async poll(vectorStoreId, batchId, options) {
|
|
33180
|
+
const headers = { ...options?.headers, "X-Stainless-Poll-Helper": "true" };
|
|
33181
|
+
if (options?.pollIntervalMs) {
|
|
33182
|
+
headers["X-Stainless-Custom-Poll-Interval"] = options.pollIntervalMs.toString();
|
|
33183
|
+
}
|
|
33184
|
+
while (true) {
|
|
33185
|
+
const { data: batch, response } = await this.retrieve(vectorStoreId, batchId, {
|
|
33186
|
+
...options,
|
|
33187
|
+
headers
|
|
33188
|
+
}).withResponse();
|
|
33189
|
+
switch (batch.status) {
|
|
33190
|
+
case "in_progress":
|
|
33191
|
+
let sleepInterval = 5000;
|
|
33192
|
+
if (options?.pollIntervalMs) {
|
|
33193
|
+
sleepInterval = options.pollIntervalMs;
|
|
33194
|
+
} else {
|
|
33195
|
+
const headerInterval = response.headers.get("openai-poll-after-ms");
|
|
33196
|
+
if (headerInterval) {
|
|
33197
|
+
const headerIntervalMs = parseInt(headerInterval);
|
|
33198
|
+
if (!isNaN(headerIntervalMs)) {
|
|
33199
|
+
sleepInterval = headerIntervalMs;
|
|
33200
|
+
}
|
|
33201
|
+
}
|
|
33202
|
+
}
|
|
33203
|
+
await sleep2(sleepInterval);
|
|
33204
|
+
break;
|
|
33205
|
+
case "failed":
|
|
33206
|
+
case "cancelled":
|
|
33207
|
+
case "completed":
|
|
33208
|
+
return batch;
|
|
33209
|
+
}
|
|
33210
|
+
}
|
|
33211
|
+
}
|
|
33212
|
+
async uploadAndPoll(vectorStoreId, { files, fileIds = [] }, options) {
|
|
33213
|
+
if (files == null || files.length == 0) {
|
|
33214
|
+
throw new Error(`No \`files\` provided to process. If you've already uploaded files you should use \`.createAndPoll()\` instead`);
|
|
33215
|
+
}
|
|
33216
|
+
const configuredConcurrency = options?.maxConcurrency ?? 5;
|
|
33217
|
+
const concurrencyLimit = Math.min(configuredConcurrency, files.length);
|
|
33218
|
+
const client = this._client;
|
|
33219
|
+
const fileIterator = files.values();
|
|
33220
|
+
const allFileIds = [...fileIds];
|
|
33221
|
+
async function processFiles(iterator) {
|
|
33222
|
+
for (let item of iterator) {
|
|
33223
|
+
const fileObj = await client.files.create({ file: item, purpose: "assistants" }, options);
|
|
33224
|
+
allFileIds.push(fileObj.id);
|
|
33225
|
+
}
|
|
33226
|
+
}
|
|
33227
|
+
const workers = Array(concurrencyLimit).fill(fileIterator).map(processFiles);
|
|
33228
|
+
await allSettledWithThrow(workers);
|
|
33229
|
+
return await this.createAndPoll(vectorStoreId, {
|
|
33230
|
+
file_ids: allFileIds
|
|
33231
|
+
});
|
|
33232
|
+
}
|
|
33233
|
+
}
|
|
33234
|
+
|
|
33235
|
+
// ../../node_modules/openai/resources/vector-stores/vector-stores.mjs
|
|
33236
|
+
class VectorStores extends APIResource2 {
|
|
33237
|
+
constructor() {
|
|
33238
|
+
super(...arguments);
|
|
33239
|
+
this.files = new Files2(this._client);
|
|
33240
|
+
this.fileBatches = new FileBatches(this._client);
|
|
33241
|
+
}
|
|
33242
|
+
create(body2, options) {
|
|
33243
|
+
return this._client.post("/vector_stores", {
|
|
33244
|
+
body: body2,
|
|
33245
|
+
...options,
|
|
33246
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33247
|
+
});
|
|
33248
|
+
}
|
|
33249
|
+
retrieve(vectorStoreId, options) {
|
|
33250
|
+
return this._client.get(`/vector_stores/${vectorStoreId}`, {
|
|
33251
|
+
...options,
|
|
33252
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33253
|
+
});
|
|
33254
|
+
}
|
|
33255
|
+
update(vectorStoreId, body2, options) {
|
|
33256
|
+
return this._client.post(`/vector_stores/${vectorStoreId}`, {
|
|
33257
|
+
body: body2,
|
|
33258
|
+
...options,
|
|
33259
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33260
|
+
});
|
|
33261
|
+
}
|
|
33262
|
+
list(query = {}, options) {
|
|
33263
|
+
if (isRequestOptions2(query)) {
|
|
33264
|
+
return this.list({}, query);
|
|
33265
|
+
}
|
|
33266
|
+
return this._client.getAPIList("/vector_stores", VectorStoresPage, {
|
|
33267
|
+
query,
|
|
33268
|
+
...options,
|
|
33269
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33270
|
+
});
|
|
33271
|
+
}
|
|
33272
|
+
del(vectorStoreId, options) {
|
|
33273
|
+
return this._client.delete(`/vector_stores/${vectorStoreId}`, {
|
|
33274
|
+
...options,
|
|
33275
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33276
|
+
});
|
|
33277
|
+
}
|
|
33278
|
+
search(vectorStoreId, body2, options) {
|
|
33279
|
+
return this._client.getAPIList(`/vector_stores/${vectorStoreId}/search`, VectorStoreSearchResponsesPage, {
|
|
33280
|
+
body: body2,
|
|
33281
|
+
method: "post",
|
|
33282
|
+
...options,
|
|
33283
|
+
headers: { "OpenAI-Beta": "assistants=v2", ...options?.headers }
|
|
33284
|
+
});
|
|
33285
|
+
}
|
|
33286
|
+
}
|
|
33287
|
+
|
|
33288
|
+
class VectorStoresPage extends CursorPage {
|
|
33289
|
+
}
|
|
33290
|
+
|
|
33291
|
+
class VectorStoreSearchResponsesPage extends Page2 {
|
|
33292
|
+
}
|
|
33293
|
+
VectorStores.VectorStoresPage = VectorStoresPage;
|
|
33294
|
+
VectorStores.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
|
|
33295
|
+
VectorStores.Files = Files2;
|
|
33296
|
+
VectorStores.VectorStoreFilesPage = VectorStoreFilesPage;
|
|
33297
|
+
VectorStores.FileContentResponsesPage = FileContentResponsesPage;
|
|
33298
|
+
VectorStores.FileBatches = FileBatches;
|
|
32760
33299
|
// ../../node_modules/openai/index.mjs
|
|
32761
33300
|
var _a2;
|
|
32762
33301
|
|
|
@@ -32794,15 +33333,17 @@ https://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety
|
|
|
32794
33333
|
this.completions = new Completions4(this);
|
|
32795
33334
|
this.chat = new Chat(this);
|
|
32796
33335
|
this.embeddings = new Embeddings(this);
|
|
32797
|
-
this.files = new
|
|
33336
|
+
this.files = new Files(this);
|
|
32798
33337
|
this.images = new Images(this);
|
|
32799
33338
|
this.audio = new Audio(this);
|
|
32800
33339
|
this.moderations = new Moderations(this);
|
|
32801
33340
|
this.models = new Models3(this);
|
|
32802
33341
|
this.fineTuning = new FineTuning(this);
|
|
33342
|
+
this.vectorStores = new VectorStores(this);
|
|
32803
33343
|
this.beta = new Beta2(this);
|
|
32804
33344
|
this.batches = new Batches3(this);
|
|
32805
33345
|
this.uploads = new Uploads(this);
|
|
33346
|
+
this.responses = new Responses(this);
|
|
32806
33347
|
this._options = options;
|
|
32807
33348
|
this.apiKey = apiKey;
|
|
32808
33349
|
this.organization = organization;
|
|
@@ -32846,8 +33387,9 @@ OpenAI.toFile = toFile2;
|
|
|
32846
33387
|
OpenAI.fileFromPath = fileFromPath4;
|
|
32847
33388
|
OpenAI.Completions = Completions4;
|
|
32848
33389
|
OpenAI.Chat = Chat;
|
|
33390
|
+
OpenAI.ChatCompletionsPage = ChatCompletionsPage;
|
|
32849
33391
|
OpenAI.Embeddings = Embeddings;
|
|
32850
|
-
OpenAI.Files =
|
|
33392
|
+
OpenAI.Files = Files;
|
|
32851
33393
|
OpenAI.FileObjectsPage = FileObjectsPage;
|
|
32852
33394
|
OpenAI.Images = Images;
|
|
32853
33395
|
OpenAI.Audio = Audio;
|
|
@@ -32855,10 +33397,14 @@ OpenAI.Moderations = Moderations;
|
|
|
32855
33397
|
OpenAI.Models = Models3;
|
|
32856
33398
|
OpenAI.ModelsPage = ModelsPage;
|
|
32857
33399
|
OpenAI.FineTuning = FineTuning;
|
|
33400
|
+
OpenAI.VectorStores = VectorStores;
|
|
33401
|
+
OpenAI.VectorStoresPage = VectorStoresPage;
|
|
33402
|
+
OpenAI.VectorStoreSearchResponsesPage = VectorStoreSearchResponsesPage;
|
|
32858
33403
|
OpenAI.Beta = Beta2;
|
|
32859
33404
|
OpenAI.Batches = Batches3;
|
|
32860
33405
|
OpenAI.BatchesPage = BatchesPage;
|
|
32861
33406
|
OpenAI.Uploads = Uploads;
|
|
33407
|
+
OpenAI.Responses = Responses;
|
|
32862
33408
|
var _deployments_endpoints = new Set([
|
|
32863
33409
|
"/completions",
|
|
32864
33410
|
"/chat/completions",
|
|
@@ -35833,10 +36379,10 @@ var util;
|
|
|
35833
36379
|
util2.assertEqual = (val) => val;
|
|
35834
36380
|
function assertIs(_arg) {}
|
|
35835
36381
|
util2.assertIs = assertIs;
|
|
35836
|
-
function
|
|
36382
|
+
function assertNever3(_x) {
|
|
35837
36383
|
throw new Error;
|
|
35838
36384
|
}
|
|
35839
|
-
util2.assertNever =
|
|
36385
|
+
util2.assertNever = assertNever3;
|
|
35840
36386
|
util2.arrayToEnum = (items) => {
|
|
35841
36387
|
const obj = {};
|
|
35842
36388
|
for (const item of items) {
|
|
@@ -36283,14 +36829,14 @@ var isAborted = (x2) => x2.status === "aborted";
|
|
|
36283
36829
|
var isDirty = (x2) => x2.status === "dirty";
|
|
36284
36830
|
var isValid = (x2) => x2.status === "valid";
|
|
36285
36831
|
var isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
|
|
36286
|
-
function
|
|
36832
|
+
function __classPrivateFieldGet17(receiver, state, kind3, f2) {
|
|
36287
36833
|
if (kind3 === "a" && !f2)
|
|
36288
36834
|
throw new TypeError("Private accessor was defined without a getter");
|
|
36289
36835
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
36290
36836
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
36291
36837
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
36292
36838
|
}
|
|
36293
|
-
function
|
|
36839
|
+
function __classPrivateFieldSet15(receiver, state, value, kind3, f2) {
|
|
36294
36840
|
if (kind3 === "m")
|
|
36295
36841
|
throw new TypeError("Private method is not writable");
|
|
36296
36842
|
if (kind3 === "a" && !f2)
|
|
@@ -39090,10 +39636,10 @@ class ZodEnum extends ZodType {
|
|
|
39090
39636
|
});
|
|
39091
39637
|
return INVALID;
|
|
39092
39638
|
}
|
|
39093
|
-
if (!
|
|
39094
|
-
|
|
39639
|
+
if (!__classPrivateFieldGet17(this, _ZodEnum_cache, "f")) {
|
|
39640
|
+
__classPrivateFieldSet15(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
39095
39641
|
}
|
|
39096
|
-
if (!
|
|
39642
|
+
if (!__classPrivateFieldGet17(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
39097
39643
|
const ctx = this._getOrReturnCtx(input);
|
|
39098
39644
|
const expectedValues = this._def.values;
|
|
39099
39645
|
addIssueToContext(ctx, {
|
|
@@ -39162,10 +39708,10 @@ class ZodNativeEnum extends ZodType {
|
|
|
39162
39708
|
});
|
|
39163
39709
|
return INVALID;
|
|
39164
39710
|
}
|
|
39165
|
-
if (!
|
|
39166
|
-
|
|
39711
|
+
if (!__classPrivateFieldGet17(this, _ZodNativeEnum_cache, "f")) {
|
|
39712
|
+
__classPrivateFieldSet15(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
39167
39713
|
}
|
|
39168
|
-
if (!
|
|
39714
|
+
if (!__classPrivateFieldGet17(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
39169
39715
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
39170
39716
|
addIssueToContext(ctx, {
|
|
39171
39717
|
received: ctx.data,
|
|
@@ -40064,10 +40610,10 @@ var util2;
|
|
|
40064
40610
|
util3.assertEqual = (val) => val;
|
|
40065
40611
|
function assertIs(_arg) {}
|
|
40066
40612
|
util3.assertIs = assertIs;
|
|
40067
|
-
function
|
|
40613
|
+
function assertNever3(_x) {
|
|
40068
40614
|
throw new Error;
|
|
40069
40615
|
}
|
|
40070
|
-
util3.assertNever =
|
|
40616
|
+
util3.assertNever = assertNever3;
|
|
40071
40617
|
util3.arrayToEnum = (items) => {
|
|
40072
40618
|
const obj = {};
|
|
40073
40619
|
for (const item of items) {
|
|
@@ -40505,14 +41051,14 @@ var isAborted2 = (x2) => x2.status === "aborted";
|
|
|
40505
41051
|
var isDirty2 = (x2) => x2.status === "dirty";
|
|
40506
41052
|
var isValid2 = (x2) => x2.status === "valid";
|
|
40507
41053
|
var isAsync2 = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
|
|
40508
|
-
function
|
|
41054
|
+
function __classPrivateFieldGet18(receiver, state, kind3, f2) {
|
|
40509
41055
|
if (kind3 === "a" && !f2)
|
|
40510
41056
|
throw new TypeError("Private accessor was defined without a getter");
|
|
40511
41057
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
40512
41058
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
40513
41059
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
40514
41060
|
}
|
|
40515
|
-
function
|
|
41061
|
+
function __classPrivateFieldSet16(receiver, state, value, kind3, f2) {
|
|
40516
41062
|
if (kind3 === "m")
|
|
40517
41063
|
throw new TypeError("Private method is not writable");
|
|
40518
41064
|
if (kind3 === "a" && !f2)
|
|
@@ -43312,10 +43858,10 @@ class ZodEnum2 extends ZodType2 {
|
|
|
43312
43858
|
});
|
|
43313
43859
|
return INVALID2;
|
|
43314
43860
|
}
|
|
43315
|
-
if (!
|
|
43316
|
-
|
|
43861
|
+
if (!__classPrivateFieldGet18(this, _ZodEnum_cache2, "f")) {
|
|
43862
|
+
__classPrivateFieldSet16(this, _ZodEnum_cache2, new Set(this._def.values), "f");
|
|
43317
43863
|
}
|
|
43318
|
-
if (!
|
|
43864
|
+
if (!__classPrivateFieldGet18(this, _ZodEnum_cache2, "f").has(input.data)) {
|
|
43319
43865
|
const ctx = this._getOrReturnCtx(input);
|
|
43320
43866
|
const expectedValues = this._def.values;
|
|
43321
43867
|
addIssueToContext2(ctx, {
|
|
@@ -43384,10 +43930,10 @@ class ZodNativeEnum2 extends ZodType2 {
|
|
|
43384
43930
|
});
|
|
43385
43931
|
return INVALID2;
|
|
43386
43932
|
}
|
|
43387
|
-
if (!
|
|
43388
|
-
|
|
43933
|
+
if (!__classPrivateFieldGet18(this, _ZodNativeEnum_cache2, "f")) {
|
|
43934
|
+
__classPrivateFieldSet16(this, _ZodNativeEnum_cache2, new Set(util2.getValidEnumValues(this._def.values)), "f");
|
|
43389
43935
|
}
|
|
43390
|
-
if (!
|
|
43936
|
+
if (!__classPrivateFieldGet18(this, _ZodNativeEnum_cache2, "f").has(input.data)) {
|
|
43391
43937
|
const expectedValues = util2.objectValues(nativeEnumValues);
|
|
43392
43938
|
addIssueToContext2(ctx, {
|
|
43393
43939
|
received: ctx.data,
|
|
@@ -43990,7 +44536,7 @@ import { dirname } from "node:path";
|
|
|
43990
44536
|
var isUpKey = (key) => key.name === "up" || key.name === "k" || key.ctrl && key.name === "p";
|
|
43991
44537
|
var isDownKey = (key) => key.name === "down" || key.name === "j" || key.ctrl && key.name === "n";
|
|
43992
44538
|
var isBackspaceKey = (key) => key.name === "backspace";
|
|
43993
|
-
var isNumberKey = (key) => "
|
|
44539
|
+
var isNumberKey = (key) => "1234567890".includes(key.name);
|
|
43994
44540
|
var isEnterKey = (key) => key.name === "enter" || key.name === "return";
|
|
43995
44541
|
// ../../node_modules/@inquirer/core/dist/esm/lib/errors.js
|
|
43996
44542
|
class AbortPromptError extends Error {
|
|
@@ -44874,8 +45420,8 @@ var {
|
|
|
44874
45420
|
} = signalExitWrap(processOk(process3) ? new SignalExit(process3) : new SignalExitFallback);
|
|
44875
45421
|
|
|
44876
45422
|
// ../../node_modules/@inquirer/core/dist/esm/lib/screen-manager.js
|
|
44877
|
-
var import_strip_ansi = __toESM(require_strip_ansi(), 1);
|
|
44878
45423
|
var import_ansi_escapes = __toESM(require_ansi_escapes(), 1);
|
|
45424
|
+
import { stripVTControlCharacters } from "node:util";
|
|
44879
45425
|
var height = (content) => content.split(`
|
|
44880
45426
|
`).length;
|
|
44881
45427
|
var lastLine = (content) => content.split(`
|
|
@@ -44885,12 +45431,11 @@ function cursorDown(n2) {
|
|
|
44885
45431
|
}
|
|
44886
45432
|
|
|
44887
45433
|
class ScreenManager {
|
|
44888
|
-
rl;
|
|
44889
45434
|
height = 0;
|
|
44890
45435
|
extraLinesUnderPrompt = 0;
|
|
44891
45436
|
cursorPos;
|
|
45437
|
+
rl;
|
|
44892
45438
|
constructor(rl) {
|
|
44893
|
-
this.rl = rl;
|
|
44894
45439
|
this.rl = rl;
|
|
44895
45440
|
this.cursorPos = rl.getCursorPos();
|
|
44896
45441
|
}
|
|
@@ -44901,7 +45446,7 @@ class ScreenManager {
|
|
|
44901
45446
|
}
|
|
44902
45447
|
render(content, bottomContent = "") {
|
|
44903
45448
|
const promptLine = lastLine(content);
|
|
44904
|
-
const rawPromptLine =
|
|
45449
|
+
const rawPromptLine = stripVTControlCharacters(promptLine);
|
|
44905
45450
|
let prompt5 = rawPromptLine;
|
|
44906
45451
|
if (this.rl.line.length > 0) {
|
|
44907
45452
|
prompt5 = prompt5.slice(0, -this.rl.line.length);
|
|
@@ -44960,22 +45505,22 @@ class PromisePolyfill extends Promise {
|
|
|
44960
45505
|
// ../../node_modules/@inquirer/core/dist/esm/lib/create-prompt.js
|
|
44961
45506
|
function getCallSites() {
|
|
44962
45507
|
const _prepareStackTrace = Error.prepareStackTrace;
|
|
45508
|
+
let result = [];
|
|
44963
45509
|
try {
|
|
44964
|
-
let result = [];
|
|
44965
45510
|
Error.prepareStackTrace = (_2, callSites) => {
|
|
44966
45511
|
const callSitesWithoutCurrent = callSites.slice(1);
|
|
44967
45512
|
result = callSitesWithoutCurrent;
|
|
44968
45513
|
return callSitesWithoutCurrent;
|
|
44969
45514
|
};
|
|
44970
45515
|
new Error().stack;
|
|
45516
|
+
} catch {
|
|
44971
45517
|
return result;
|
|
44972
|
-
} finally {
|
|
44973
|
-
Error.prepareStackTrace = _prepareStackTrace;
|
|
44974
45518
|
}
|
|
45519
|
+
Error.prepareStackTrace = _prepareStackTrace;
|
|
45520
|
+
return result;
|
|
44975
45521
|
}
|
|
44976
45522
|
function createPrompt(view) {
|
|
44977
45523
|
const callSites = getCallSites();
|
|
44978
|
-
const callerFilename = callSites[1]?.getFileName?.();
|
|
44979
45524
|
const prompt5 = (config2, context = {}) => {
|
|
44980
45525
|
const { input = process.stdin, signal } = context;
|
|
44981
45526
|
const cleanups = new Set;
|
|
@@ -45014,6 +45559,7 @@ function createPrompt(view) {
|
|
|
45014
45559
|
setImmediate(() => resolve(value));
|
|
45015
45560
|
});
|
|
45016
45561
|
if (nextView === undefined) {
|
|
45562
|
+
const callerFilename = callSites[1]?.getFileName?.();
|
|
45017
45563
|
throw new Error(`Prompt functions must return a string.
|
|
45018
45564
|
at ${callerFilename}`);
|
|
45019
45565
|
}
|
|
@@ -45219,7 +45765,8 @@ var selectTheme = {
|
|
|
45219
45765
|
disabled: (text) => import_yoctocolors_cjs3.default.dim(`- ${text}`),
|
|
45220
45766
|
description: (text) => import_yoctocolors_cjs3.default.cyan(text)
|
|
45221
45767
|
},
|
|
45222
|
-
helpMode: "auto"
|
|
45768
|
+
helpMode: "auto",
|
|
45769
|
+
indexMode: "hidden"
|
|
45223
45770
|
};
|
|
45224
45771
|
function isSelectable(item) {
|
|
45225
45772
|
return !Separator.isSeparator(item) && !item.disabled;
|
|
@@ -45284,13 +45831,15 @@ var esm_default5 = createPrompt((config2, done) => {
|
|
|
45284
45831
|
} while (!isSelectable(items[next]));
|
|
45285
45832
|
setActive(next);
|
|
45286
45833
|
}
|
|
45287
|
-
} else if (isNumberKey(key2)) {
|
|
45288
|
-
rl.
|
|
45289
|
-
const position = Number(key2.name) - 1;
|
|
45834
|
+
} else if (isNumberKey(key2) && !Number.isNaN(Number(rl.line))) {
|
|
45835
|
+
const position = Number(rl.line) - 1;
|
|
45290
45836
|
const item = items[position];
|
|
45291
45837
|
if (item != null && isSelectable(item)) {
|
|
45292
45838
|
setActive(position);
|
|
45293
45839
|
}
|
|
45840
|
+
searchTimeoutRef.current = setTimeout(() => {
|
|
45841
|
+
rl.clearLine(0);
|
|
45842
|
+
}, 700);
|
|
45294
45843
|
} else if (isBackspaceKey(key2)) {
|
|
45295
45844
|
rl.clearLine(0);
|
|
45296
45845
|
} else {
|
|
@@ -45326,17 +45875,18 @@ ${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
|
|
45326
45875
|
const page = usePagination({
|
|
45327
45876
|
items,
|
|
45328
45877
|
active,
|
|
45329
|
-
renderItem({ item, isActive }) {
|
|
45878
|
+
renderItem({ item, isActive, index }) {
|
|
45330
45879
|
if (Separator.isSeparator(item)) {
|
|
45331
45880
|
return ` ${item.separator}`;
|
|
45332
45881
|
}
|
|
45882
|
+
const indexLabel = theme.indexMode === "number" ? `${index + 1}. ` : "";
|
|
45333
45883
|
if (item.disabled) {
|
|
45334
45884
|
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
45335
|
-
return theme.style.disabled(`${item.name} ${disabledLabel}`);
|
|
45885
|
+
return theme.style.disabled(`${indexLabel}${item.name} ${disabledLabel}`);
|
|
45336
45886
|
}
|
|
45337
45887
|
const color = isActive ? theme.style.highlight : (x2) => x2;
|
|
45338
45888
|
const cursor = isActive ? theme.icon.cursor : ` `;
|
|
45339
|
-
return color(`${cursor} ${item.name}`);
|
|
45889
|
+
return color(`${cursor} ${indexLabel}${item.name}`);
|
|
45340
45890
|
},
|
|
45341
45891
|
pageSize,
|
|
45342
45892
|
loop
|
|
@@ -50536,7 +51086,7 @@ function ansiRegex({ onlyFirst = false } = {}) {
|
|
|
50536
51086
|
|
|
50537
51087
|
// ../../node_modules/strip-ansi/index.js
|
|
50538
51088
|
var regex = ansiRegex();
|
|
50539
|
-
function
|
|
51089
|
+
function stripAnsi(string) {
|
|
50540
51090
|
if (typeof string !== "string") {
|
|
50541
51091
|
throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
|
|
50542
51092
|
}
|
|
@@ -50581,7 +51131,7 @@ function stringWidth(string, options = {}) {
|
|
|
50581
51131
|
countAnsiEscapeCodes = false
|
|
50582
51132
|
} = options;
|
|
50583
51133
|
if (!countAnsiEscapeCodes) {
|
|
50584
|
-
string =
|
|
51134
|
+
string = stripAnsi(string);
|
|
50585
51135
|
}
|
|
50586
51136
|
if (string.length === 0) {
|
|
50587
51137
|
return 0;
|
|
@@ -50828,7 +51378,7 @@ class Ora {
|
|
|
50828
51378
|
const fullSuffixText = this.#getFullSuffixText(this.#suffixText, "-");
|
|
50829
51379
|
const fullText = " ".repeat(this.#indent) + fullPrefixText + "--" + this.#text + "--" + fullSuffixText;
|
|
50830
51380
|
this.#lineCount = 0;
|
|
50831
|
-
for (const line of
|
|
51381
|
+
for (const line of stripAnsi(fullText).split(`
|
|
50832
51382
|
`)) {
|
|
50833
51383
|
this.#lineCount += Math.max(1, Math.ceil(stringWidth(line, { countAnsiEscapeCodes: true }) / columns));
|
|
50834
51384
|
}
|
|
@@ -51117,10 +51667,10 @@ var util3;
|
|
|
51117
51667
|
util4.assertEqual = (val) => val;
|
|
51118
51668
|
function assertIs(_arg) {}
|
|
51119
51669
|
util4.assertIs = assertIs;
|
|
51120
|
-
function
|
|
51670
|
+
function assertNever3(_x) {
|
|
51121
51671
|
throw new Error;
|
|
51122
51672
|
}
|
|
51123
|
-
util4.assertNever =
|
|
51673
|
+
util4.assertNever = assertNever3;
|
|
51124
51674
|
util4.arrayToEnum = (items) => {
|
|
51125
51675
|
const obj = {};
|
|
51126
51676
|
for (const item of items) {
|
|
@@ -51558,14 +52108,14 @@ var isAborted3 = (x2) => x2.status === "aborted";
|
|
|
51558
52108
|
var isDirty3 = (x2) => x2.status === "dirty";
|
|
51559
52109
|
var isValid3 = (x2) => x2.status === "valid";
|
|
51560
52110
|
var isAsync3 = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
|
|
51561
|
-
function
|
|
52111
|
+
function __classPrivateFieldGet19(receiver, state, kind3, f2) {
|
|
51562
52112
|
if (kind3 === "a" && !f2)
|
|
51563
52113
|
throw new TypeError("Private accessor was defined without a getter");
|
|
51564
52114
|
if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver))
|
|
51565
52115
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
51566
52116
|
return kind3 === "m" ? f2 : kind3 === "a" ? f2.call(receiver) : f2 ? f2.value : state.get(receiver);
|
|
51567
52117
|
}
|
|
51568
|
-
function
|
|
52118
|
+
function __classPrivateFieldSet17(receiver, state, value, kind3, f2) {
|
|
51569
52119
|
if (kind3 === "m")
|
|
51570
52120
|
throw new TypeError("Private method is not writable");
|
|
51571
52121
|
if (kind3 === "a" && !f2)
|
|
@@ -54365,10 +54915,10 @@ class ZodEnum3 extends ZodType3 {
|
|
|
54365
54915
|
});
|
|
54366
54916
|
return INVALID3;
|
|
54367
54917
|
}
|
|
54368
|
-
if (!
|
|
54369
|
-
|
|
54918
|
+
if (!__classPrivateFieldGet19(this, _ZodEnum_cache3, "f")) {
|
|
54919
|
+
__classPrivateFieldSet17(this, _ZodEnum_cache3, new Set(this._def.values), "f");
|
|
54370
54920
|
}
|
|
54371
|
-
if (!
|
|
54921
|
+
if (!__classPrivateFieldGet19(this, _ZodEnum_cache3, "f").has(input.data)) {
|
|
54372
54922
|
const ctx = this._getOrReturnCtx(input);
|
|
54373
54923
|
const expectedValues = this._def.values;
|
|
54374
54924
|
addIssueToContext3(ctx, {
|
|
@@ -54437,10 +54987,10 @@ class ZodNativeEnum3 extends ZodType3 {
|
|
|
54437
54987
|
});
|
|
54438
54988
|
return INVALID3;
|
|
54439
54989
|
}
|
|
54440
|
-
if (!
|
|
54441
|
-
|
|
54990
|
+
if (!__classPrivateFieldGet19(this, _ZodNativeEnum_cache3, "f")) {
|
|
54991
|
+
__classPrivateFieldSet17(this, _ZodNativeEnum_cache3, new Set(util3.getValidEnumValues(this._def.values)), "f");
|
|
54442
54992
|
}
|
|
54443
|
-
if (!
|
|
54993
|
+
if (!__classPrivateFieldGet19(this, _ZodNativeEnum_cache3, "f").has(input.data)) {
|
|
54444
54994
|
const expectedValues = util3.objectValues(nativeEnumValues);
|
|
54445
54995
|
addIssueToContext3(ctx, {
|
|
54446
54996
|
received: ctx.data,
|