@m8t-stack/cli 0.2.42 → 0.2.43
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/cli.js +1568 -543
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -858,6 +858,9 @@ var init_brain_yaml_mirror = __esm({
|
|
|
858
858
|
|
|
859
859
|
// src/lib/foundry-agents.ts
|
|
860
860
|
import { AIProjectClient } from "@azure/ai-projects";
|
|
861
|
+
function fitsAgentMetadataValue(value) {
|
|
862
|
+
return Buffer.byteLength(value, "utf8") <= METADATA_VALUE_MAX;
|
|
863
|
+
}
|
|
861
864
|
async function createCoderVersion(args) {
|
|
862
865
|
const project = new AIProjectClient(args.endpoint, args.credential);
|
|
863
866
|
const definition = {
|
|
@@ -948,7 +951,15 @@ async function createPromptVersion(args) {
|
|
|
948
951
|
persona: args.metadata.persona
|
|
949
952
|
};
|
|
950
953
|
if (args.metadata.personaVersion !== null) metadata.personaVersion = args.metadata.personaVersion;
|
|
951
|
-
if (args.metadata.fillableFieldValues !== void 0)
|
|
954
|
+
if (args.metadata.fillableFieldValues !== void 0) {
|
|
955
|
+
if (fitsAgentMetadataValue(args.metadata.fillableFieldValues)) {
|
|
956
|
+
metadata.fillableFieldValues = args.metadata.fillableFieldValues;
|
|
957
|
+
} else {
|
|
958
|
+
args.onNotice?.(
|
|
959
|
+
`field values (${String(Buffer.byteLength(args.metadata.fillableFieldValues, "utf8"))} bytes) exceed Foundry's ${String(METADATA_VALUE_MAX)}-byte metadata limit \u2014 omitting them from '${args.name}' metadata; the agent's instructions are unaffected.`
|
|
960
|
+
);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
952
963
|
const version = await project.agents.createVersion(args.name, definition, { metadata });
|
|
953
964
|
await ensureAgentEndpointEntraIsolation({
|
|
954
965
|
credential: args.credential,
|
|
@@ -975,7 +986,7 @@ async function deleteAgent(args) {
|
|
|
975
986
|
// already gone — idempotent
|
|
976
987
|
});
|
|
977
988
|
}
|
|
978
|
-
var METADATA_SOURCE, FOUNDRY_SCOPE2, API;
|
|
989
|
+
var METADATA_SOURCE, FOUNDRY_SCOPE2, API, METADATA_VALUE_MAX;
|
|
979
990
|
var init_foundry_agents = __esm({
|
|
980
991
|
"src/lib/foundry-agents.ts"() {
|
|
981
992
|
"use strict";
|
|
@@ -985,6 +996,7 @@ var init_foundry_agents = __esm({
|
|
|
985
996
|
METADATA_SOURCE = "m8t";
|
|
986
997
|
FOUNDRY_SCOPE2 = "https://ai.azure.com/.default";
|
|
987
998
|
API = "v1";
|
|
999
|
+
METADATA_VALUE_MAX = 512;
|
|
988
1000
|
}
|
|
989
1001
|
});
|
|
990
1002
|
|
|
@@ -1298,7 +1310,7 @@ var init_enable_hosted_brain = __esm({
|
|
|
1298
1310
|
import { Builtins, Cli } from "clipanion";
|
|
1299
1311
|
|
|
1300
1312
|
// src/lib/package-version.ts
|
|
1301
|
-
var CLI_VERSION = "0.2.
|
|
1313
|
+
var CLI_VERSION = "0.2.43";
|
|
1302
1314
|
|
|
1303
1315
|
// src/lib/render-error.ts
|
|
1304
1316
|
init_errors();
|
|
@@ -1606,7 +1618,7 @@ var colors = {
|
|
|
1606
1618
|
warn: (s) => pc.yellow(s)
|
|
1607
1619
|
};
|
|
1608
1620
|
|
|
1609
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1621
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/tslib.mjs
|
|
1610
1622
|
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
1611
1623
|
if (kind === "m")
|
|
1612
1624
|
throw new TypeError("Private method is not writable");
|
|
@@ -1624,7 +1636,7 @@ function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
|
1624
1636
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1625
1637
|
}
|
|
1626
1638
|
|
|
1627
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1639
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/uuid.mjs
|
|
1628
1640
|
var uuid4 = function() {
|
|
1629
1641
|
const { crypto: crypto2 } = globalThis;
|
|
1630
1642
|
if (crypto2?.randomUUID) {
|
|
@@ -1636,7 +1648,7 @@ var uuid4 = function() {
|
|
|
1636
1648
|
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (c) => (+c ^ randomByte() & 15 >> +c / 4).toString(16));
|
|
1637
1649
|
};
|
|
1638
1650
|
|
|
1639
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1651
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/errors.mjs
|
|
1640
1652
|
function isAbortError(err) {
|
|
1641
1653
|
return typeof err === "object" && err !== null && // Spec-compliant fetch implementations
|
|
1642
1654
|
("name" in err && err.name === "AbortError" || // Expo fetch
|
|
@@ -1667,7 +1679,7 @@ var castToError = (err) => {
|
|
|
1667
1679
|
return new Error(err);
|
|
1668
1680
|
};
|
|
1669
1681
|
|
|
1670
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1682
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/core/error.mjs
|
|
1671
1683
|
var OpenAIError = class extends Error {
|
|
1672
1684
|
};
|
|
1673
1685
|
var APIError = class _APIError extends OpenAIError {
|
|
@@ -1801,7 +1813,7 @@ var SubjectTokenProviderError = class extends OpenAIError {
|
|
|
1801
1813
|
}
|
|
1802
1814
|
};
|
|
1803
1815
|
|
|
1804
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1816
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/values.mjs
|
|
1805
1817
|
var startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
1806
1818
|
var isAbsoluteURL = (url) => {
|
|
1807
1819
|
return startsWithSchemeRegexp.test(url);
|
|
@@ -1844,13 +1856,13 @@ var safeJSON = (text) => {
|
|
|
1844
1856
|
}
|
|
1845
1857
|
};
|
|
1846
1858
|
|
|
1847
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1859
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/sleep.mjs
|
|
1848
1860
|
var sleep = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
1849
1861
|
|
|
1850
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1851
|
-
var VERSION = "6.
|
|
1862
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/version.mjs
|
|
1863
|
+
var VERSION = "6.48.0";
|
|
1852
1864
|
|
|
1853
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1865
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/detect-platform.mjs
|
|
1854
1866
|
var isRunningInBrowser = () => {
|
|
1855
1867
|
return (
|
|
1856
1868
|
// @ts-ignore
|
|
@@ -1984,7 +1996,7 @@ var getPlatformHeaders = () => {
|
|
|
1984
1996
|
return _platformHeaders ?? (_platformHeaders = getPlatformProperties());
|
|
1985
1997
|
};
|
|
1986
1998
|
|
|
1987
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
1999
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/shims.mjs
|
|
1988
2000
|
function getDefaultFetch() {
|
|
1989
2001
|
if (typeof fetch !== "undefined") {
|
|
1990
2002
|
return fetch;
|
|
@@ -2056,7 +2068,7 @@ async function CancelReadableStream(stream) {
|
|
|
2056
2068
|
await cancelPromise;
|
|
2057
2069
|
}
|
|
2058
2070
|
|
|
2059
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2071
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/request-options.mjs
|
|
2060
2072
|
var FallbackEncoder = ({ headers, body }) => {
|
|
2061
2073
|
return {
|
|
2062
2074
|
bodyHeaders: {
|
|
@@ -2066,7 +2078,7 @@ var FallbackEncoder = ({ headers, body }) => {
|
|
|
2066
2078
|
};
|
|
2067
2079
|
};
|
|
2068
2080
|
|
|
2069
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2081
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/qs/formats.mjs
|
|
2070
2082
|
var default_format = "RFC3986";
|
|
2071
2083
|
var default_formatter = (v) => String(v);
|
|
2072
2084
|
var formatters = {
|
|
@@ -2075,7 +2087,7 @@ var formatters = {
|
|
|
2075
2087
|
};
|
|
2076
2088
|
var RFC1738 = "RFC1738";
|
|
2077
2089
|
|
|
2078
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2090
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/qs/utils.mjs
|
|
2079
2091
|
var has = (obj, key2) => (has = Object.hasOwn ?? Function.prototype.call.bind(Object.prototype.hasOwnProperty), has(obj, key2));
|
|
2080
2092
|
var hex_table = /* @__PURE__ */ (() => {
|
|
2081
2093
|
const array = [];
|
|
@@ -2154,7 +2166,7 @@ function maybe_map(val, fn) {
|
|
|
2154
2166
|
return fn(val);
|
|
2155
2167
|
}
|
|
2156
2168
|
|
|
2157
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2169
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/qs/stringify.mjs
|
|
2158
2170
|
var array_prefix_generators = {
|
|
2159
2171
|
brackets(prefix) {
|
|
2160
2172
|
return String(prefix) + "[]";
|
|
@@ -2432,12 +2444,12 @@ function stringify(object, opts = {}) {
|
|
|
2432
2444
|
return joined.length > 0 ? prefix + joined : "";
|
|
2433
2445
|
}
|
|
2434
2446
|
|
|
2435
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2447
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/query.mjs
|
|
2436
2448
|
function stringifyQuery(query) {
|
|
2437
2449
|
return stringify(query, { arrayFormat: "brackets" });
|
|
2438
2450
|
}
|
|
2439
2451
|
|
|
2440
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2452
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/bytes.mjs
|
|
2441
2453
|
function concatBytes(buffers) {
|
|
2442
2454
|
let length = 0;
|
|
2443
2455
|
for (const buffer of buffers) {
|
|
@@ -2462,7 +2474,7 @@ function decodeUTF8(bytes) {
|
|
|
2462
2474
|
return (decodeUTF8_ ?? (decoder = new globalThis.TextDecoder(), decodeUTF8_ = decoder.decode.bind(decoder)))(bytes);
|
|
2463
2475
|
}
|
|
2464
2476
|
|
|
2465
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2477
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/decoders/line.mjs
|
|
2466
2478
|
var _LineDecoder_buffer;
|
|
2467
2479
|
var _LineDecoder_carriageReturnIndex;
|
|
2468
2480
|
var LineDecoder = class {
|
|
@@ -2539,7 +2551,7 @@ function findDoubleNewlineIndex(buffer) {
|
|
|
2539
2551
|
return -1;
|
|
2540
2552
|
}
|
|
2541
2553
|
|
|
2542
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2554
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/log.mjs
|
|
2543
2555
|
var levelNumbers = {
|
|
2544
2556
|
off: 0,
|
|
2545
2557
|
error: 200,
|
|
@@ -2600,7 +2612,7 @@ var formatRequestDetails = (details) => {
|
|
|
2600
2612
|
if (details.headers) {
|
|
2601
2613
|
details.headers = Object.fromEntries((details.headers instanceof Headers ? [...details.headers] : Object.entries(details.headers)).map(([name, value]) => [
|
|
2602
2614
|
name,
|
|
2603
|
-
name.toLowerCase() === "authorization" || name.toLowerCase() === "api-key" || name.toLowerCase() === "x-api-key" || name.toLowerCase() === "cookie" || name.toLowerCase() === "set-cookie" ? "***" : value
|
|
2615
|
+
name.toLowerCase() === "authorization" || name.toLowerCase() === "api-key" || name.toLowerCase() === "x-api-key" || name.toLowerCase() === "x-amz-security-token" || name.toLowerCase() === "cookie" || name.toLowerCase() === "set-cookie" ? "***" : value
|
|
2604
2616
|
]));
|
|
2605
2617
|
}
|
|
2606
2618
|
if ("retryOfRequestLogID" in details) {
|
|
@@ -2612,7 +2624,7 @@ var formatRequestDetails = (details) => {
|
|
|
2612
2624
|
return details;
|
|
2613
2625
|
};
|
|
2614
2626
|
|
|
2615
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2627
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/core/streaming.mjs
|
|
2616
2628
|
var _Stream_client;
|
|
2617
2629
|
var Stream = class _Stream {
|
|
2618
2630
|
constructor(iterator, controller, client) {
|
|
@@ -2686,14 +2698,46 @@ var Stream = class _Stream {
|
|
|
2686
2698
|
let consumed = false;
|
|
2687
2699
|
async function* iterLines() {
|
|
2688
2700
|
const lineDecoder = new LineDecoder();
|
|
2689
|
-
const
|
|
2690
|
-
|
|
2691
|
-
|
|
2701
|
+
const reader = readableStream.getReader();
|
|
2702
|
+
let closed = false;
|
|
2703
|
+
let cancelPromise;
|
|
2704
|
+
const cancel = () => {
|
|
2705
|
+
cancelPromise ?? (cancelPromise = reader.cancel());
|
|
2706
|
+
cancelPromise.catch(() => {
|
|
2707
|
+
});
|
|
2708
|
+
};
|
|
2709
|
+
controller.signal.addEventListener("abort", cancel, { once: true });
|
|
2710
|
+
try {
|
|
2711
|
+
if (controller.signal.aborted) {
|
|
2712
|
+
cancel();
|
|
2713
|
+
return;
|
|
2714
|
+
}
|
|
2715
|
+
while (true) {
|
|
2716
|
+
const { value: chunk, done } = await reader.read();
|
|
2717
|
+
if (done) {
|
|
2718
|
+
closed = true;
|
|
2719
|
+
break;
|
|
2720
|
+
}
|
|
2721
|
+
if (controller.signal.aborted)
|
|
2722
|
+
return;
|
|
2723
|
+
for (const line2 of lineDecoder.decode(chunk)) {
|
|
2724
|
+
if (controller.signal.aborted)
|
|
2725
|
+
return;
|
|
2726
|
+
yield line2;
|
|
2727
|
+
}
|
|
2728
|
+
}
|
|
2729
|
+
if (controller.signal.aborted)
|
|
2730
|
+
return;
|
|
2731
|
+
for (const line2 of lineDecoder.flush()) {
|
|
2732
|
+
if (controller.signal.aborted)
|
|
2733
|
+
return;
|
|
2692
2734
|
yield line2;
|
|
2693
2735
|
}
|
|
2694
|
-
}
|
|
2695
|
-
|
|
2696
|
-
|
|
2736
|
+
} finally {
|
|
2737
|
+
controller.signal.removeEventListener("abort", cancel);
|
|
2738
|
+
if (!closed)
|
|
2739
|
+
cancel();
|
|
2740
|
+
reader.releaseLock();
|
|
2697
2741
|
}
|
|
2698
2742
|
}
|
|
2699
2743
|
async function* iterator() {
|
|
@@ -2711,7 +2755,7 @@ var Stream = class _Stream {
|
|
|
2711
2755
|
}
|
|
2712
2756
|
done = true;
|
|
2713
2757
|
} catch (e) {
|
|
2714
|
-
if (isAbortError(e))
|
|
2758
|
+
if (controller.signal.aborted || isAbortError(e))
|
|
2715
2759
|
return;
|
|
2716
2760
|
throw e;
|
|
2717
2761
|
} finally {
|
|
@@ -2870,7 +2914,7 @@ function partition(str4, delimiter) {
|
|
|
2870
2914
|
return [str4, "", ""];
|
|
2871
2915
|
}
|
|
2872
2916
|
|
|
2873
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2917
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/parse.mjs
|
|
2874
2918
|
async function defaultParseResponse(client, props) {
|
|
2875
2919
|
const { response, requestLogID, retryOfRequestLogID, startTime } = props;
|
|
2876
2920
|
const body = await (async () => {
|
|
@@ -2920,7 +2964,7 @@ function addRequestID(value, response) {
|
|
|
2920
2964
|
});
|
|
2921
2965
|
}
|
|
2922
2966
|
|
|
2923
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
2967
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/core/api-promise.mjs
|
|
2924
2968
|
var _APIPromise_client;
|
|
2925
2969
|
var APIPromise = class _APIPromise extends Promise {
|
|
2926
2970
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
@@ -2983,7 +3027,7 @@ var APIPromise = class _APIPromise extends Promise {
|
|
|
2983
3027
|
};
|
|
2984
3028
|
_APIPromise_client = /* @__PURE__ */ new WeakMap();
|
|
2985
3029
|
|
|
2986
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3030
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/core/pagination.mjs
|
|
2987
3031
|
var _AbstractPage_client;
|
|
2988
3032
|
var AbstractPage = class {
|
|
2989
3033
|
constructor(client, response, body, options) {
|
|
@@ -3144,7 +3188,7 @@ var NextCursorPage = class extends AbstractPage {
|
|
|
3144
3188
|
}
|
|
3145
3189
|
};
|
|
3146
3190
|
|
|
3147
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3191
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/auth/workload-identity-auth.mjs
|
|
3148
3192
|
var SUBJECT_TOKEN_TYPES = {
|
|
3149
3193
|
jwt: "urn:ietf:params:oauth:token-type:jwt",
|
|
3150
3194
|
id: "urn:ietf:params:oauth:token-type:id_token"
|
|
@@ -3210,13 +3254,17 @@ var WorkloadIdentityAuth = class {
|
|
|
3210
3254
|
throw APIError.generate(response.status, body2, `Token exchange failed with status ${response.status}`, response.headers);
|
|
3211
3255
|
}
|
|
3212
3256
|
const tokenResponse = await response.json();
|
|
3213
|
-
|
|
3257
|
+
if (typeof tokenResponse !== "object" || tokenResponse === null || !("access_token" in tokenResponse) || typeof tokenResponse.access_token !== "string" || tokenResponse.access_token.trim().length === 0) {
|
|
3258
|
+
throw new OpenAIError("Token exchange response missing 'access_token' field");
|
|
3259
|
+
}
|
|
3260
|
+
const accessToken = tokenResponse.access_token;
|
|
3261
|
+
const expiresIn = tokenResponse.expires_in ?? 3600;
|
|
3214
3262
|
const expiresAt = Date.now() + expiresIn * 1e3;
|
|
3215
3263
|
this.cachedToken = {
|
|
3216
|
-
token:
|
|
3264
|
+
token: accessToken,
|
|
3217
3265
|
expiresAt
|
|
3218
3266
|
};
|
|
3219
|
-
return
|
|
3267
|
+
return accessToken;
|
|
3220
3268
|
}
|
|
3221
3269
|
isTokenExpired(cachedToken) {
|
|
3222
3270
|
return Date.now() >= cachedToken.expiresAt;
|
|
@@ -3232,7 +3280,86 @@ var WorkloadIdentityAuth = class {
|
|
|
3232
3280
|
}
|
|
3233
3281
|
};
|
|
3234
3282
|
|
|
3235
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3283
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/headers.mjs
|
|
3284
|
+
var brand_privateNullableHeaders = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
|
|
3285
|
+
var httpTokenHeaderName = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
3286
|
+
function* iterateHeaders(headers) {
|
|
3287
|
+
if (!headers)
|
|
3288
|
+
return;
|
|
3289
|
+
if (brand_privateNullableHeaders in headers) {
|
|
3290
|
+
const { values, nulls } = headers;
|
|
3291
|
+
yield* values.entries();
|
|
3292
|
+
for (const name of nulls) {
|
|
3293
|
+
yield [name, null];
|
|
3294
|
+
}
|
|
3295
|
+
return;
|
|
3296
|
+
}
|
|
3297
|
+
let shouldClear = false;
|
|
3298
|
+
let iter;
|
|
3299
|
+
if (headers instanceof Headers) {
|
|
3300
|
+
iter = headers.entries();
|
|
3301
|
+
} else if (isReadonlyArray(headers)) {
|
|
3302
|
+
iter = headers;
|
|
3303
|
+
} else {
|
|
3304
|
+
shouldClear = true;
|
|
3305
|
+
iter = Object.entries(headers ?? {});
|
|
3306
|
+
}
|
|
3307
|
+
for (let row of iter) {
|
|
3308
|
+
const name = row[0];
|
|
3309
|
+
if (typeof name !== "string")
|
|
3310
|
+
throw new TypeError("expected header name to be a string");
|
|
3311
|
+
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
|
|
3312
|
+
let didClear = false;
|
|
3313
|
+
for (const value of values) {
|
|
3314
|
+
if (value === void 0)
|
|
3315
|
+
continue;
|
|
3316
|
+
if (shouldClear && !didClear) {
|
|
3317
|
+
didClear = true;
|
|
3318
|
+
yield [name, null];
|
|
3319
|
+
}
|
|
3320
|
+
yield [name, value];
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
var buildHeaders = (newHeaders) => {
|
|
3325
|
+
const targetHeaders = new Headers();
|
|
3326
|
+
const nullHeaders = /* @__PURE__ */ new Set();
|
|
3327
|
+
for (const headers of newHeaders) {
|
|
3328
|
+
const seenHeaders = /* @__PURE__ */ new Set();
|
|
3329
|
+
for (const [name, value] of iterateHeaders(headers)) {
|
|
3330
|
+
if (!httpTokenHeaderName.test(name)) {
|
|
3331
|
+
throw new TypeError(`Header name must be a valid HTTP token ["${name}"]`);
|
|
3332
|
+
}
|
|
3333
|
+
const lowerName = name.toLowerCase();
|
|
3334
|
+
if (!seenHeaders.has(lowerName)) {
|
|
3335
|
+
targetHeaders.delete(lowerName);
|
|
3336
|
+
seenHeaders.add(lowerName);
|
|
3337
|
+
}
|
|
3338
|
+
if (value === null) {
|
|
3339
|
+
targetHeaders.delete(lowerName);
|
|
3340
|
+
nullHeaders.add(lowerName);
|
|
3341
|
+
} else {
|
|
3342
|
+
targetHeaders.append(lowerName, value);
|
|
3343
|
+
nullHeaders.delete(lowerName);
|
|
3344
|
+
}
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
3348
|
+
};
|
|
3349
|
+
|
|
3350
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/uploads.mjs
|
|
3351
|
+
var brand_privateStreamingFile = /* @__PURE__ */ Symbol("brand.privateStreamingFile");
|
|
3352
|
+
function toStreamingFile(data, name, options) {
|
|
3353
|
+
if (!name) {
|
|
3354
|
+
throw new TypeError("toStreamingFile requires a non-empty file name");
|
|
3355
|
+
}
|
|
3356
|
+
return {
|
|
3357
|
+
[brand_privateStreamingFile]: true,
|
|
3358
|
+
data,
|
|
3359
|
+
name,
|
|
3360
|
+
...options?.type ? { type: options.type } : {}
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3236
3363
|
var checkFileSupport = () => {
|
|
3237
3364
|
if (typeof File === "undefined") {
|
|
3238
3365
|
const { process: process2 } = globalThis;
|
|
@@ -3251,9 +3378,15 @@ var isAsyncIterable = (value) => value != null && typeof value === "object" && t
|
|
|
3251
3378
|
var maybeMultipartFormRequestOptions = async (opts, fetch2) => {
|
|
3252
3379
|
if (!hasUploadableValue(opts.body))
|
|
3253
3380
|
return opts;
|
|
3381
|
+
if (hasStreamingUploadableValue(opts.body)) {
|
|
3382
|
+
return createStreamingFormRequestOptions(opts);
|
|
3383
|
+
}
|
|
3254
3384
|
return { ...opts, body: await createForm(opts.body, fetch2) };
|
|
3255
3385
|
};
|
|
3256
3386
|
var multipartFormRequestOptions = async (opts, fetch2) => {
|
|
3387
|
+
if (hasStreamingUploadableValue(opts.body)) {
|
|
3388
|
+
return createStreamingFormRequestOptions(opts);
|
|
3389
|
+
}
|
|
3257
3390
|
return { ...opts, body: await createForm(opts.body, fetch2) };
|
|
3258
3391
|
};
|
|
3259
3392
|
var supportsFormDataMap = /* @__PURE__ */ new WeakMap();
|
|
@@ -3286,7 +3419,22 @@ var createForm = async (body, fetch2) => {
|
|
|
3286
3419
|
return form;
|
|
3287
3420
|
};
|
|
3288
3421
|
var isNamedBlob = (value) => value instanceof Blob && "name" in value;
|
|
3289
|
-
var
|
|
3422
|
+
var isReadableStream = (value) => typeof value === "object" && value !== null && "getReader" in value && typeof value.getReader === "function";
|
|
3423
|
+
var isStreamingFile = (value) => typeof value === "object" && value !== null && brand_privateStreamingFile in value;
|
|
3424
|
+
var isUploadable = (value) => typeof value === "object" && value !== null && (value instanceof Response || isAsyncIterable(value) || isReadableStream(value) || isStreamingFile(value) || isNamedBlob(value));
|
|
3425
|
+
var hasStreamingUploadableValue = (value) => {
|
|
3426
|
+
if (isStreamingFile(value) || isAsyncIterable(value) || isReadableStream(value))
|
|
3427
|
+
return true;
|
|
3428
|
+
if (Array.isArray(value))
|
|
3429
|
+
return value.some(hasStreamingUploadableValue);
|
|
3430
|
+
if (value && typeof value === "object" && !isNamedBlob(value) && !(value instanceof Response)) {
|
|
3431
|
+
for (const k in value) {
|
|
3432
|
+
if (hasStreamingUploadableValue(value[k]))
|
|
3433
|
+
return true;
|
|
3434
|
+
}
|
|
3435
|
+
}
|
|
3436
|
+
return false;
|
|
3437
|
+
};
|
|
3290
3438
|
var hasUploadableValue = (value) => {
|
|
3291
3439
|
if (isUploadable(value))
|
|
3292
3440
|
return true;
|
|
@@ -3300,6 +3448,115 @@ var hasUploadableValue = (value) => {
|
|
|
3300
3448
|
}
|
|
3301
3449
|
return false;
|
|
3302
3450
|
};
|
|
3451
|
+
var createStreamingFormRequestOptions = (opts) => {
|
|
3452
|
+
const boundary = `openai-${Math.random().toString(36).slice(2)}`;
|
|
3453
|
+
const body = ReadableStreamFrom(iterateMultipartBody(opts.body, boundary));
|
|
3454
|
+
return {
|
|
3455
|
+
...opts,
|
|
3456
|
+
body,
|
|
3457
|
+
headers: buildHeaders([{ "content-type": `multipart/form-data; boundary=${boundary}` }, opts.headers])
|
|
3458
|
+
};
|
|
3459
|
+
};
|
|
3460
|
+
async function* iterateMultipartBody(body, boundary) {
|
|
3461
|
+
for await (const { key: key2, value } of iterateFormEntries(body)) {
|
|
3462
|
+
yield encodeUTF8(`--${boundary}\r
|
|
3463
|
+
`);
|
|
3464
|
+
if (isUploadable(value)) {
|
|
3465
|
+
const filename = getStreamingFileName(value);
|
|
3466
|
+
const type = getStreamingFileType(value);
|
|
3467
|
+
yield encodeUTF8(`Content-Disposition: form-data; name="${escapeHeaderValue(key2)}"; filename="${escapeHeaderValue(filename)}"\r
|
|
3468
|
+
Content-Type: ${type}\r
|
|
3469
|
+
\r
|
|
3470
|
+
`);
|
|
3471
|
+
yield* iterateBytes(getStreamingFileData(value));
|
|
3472
|
+
} else {
|
|
3473
|
+
yield encodeUTF8(`Content-Disposition: form-data; name="${escapeHeaderValue(key2)}"\r
|
|
3474
|
+
\r
|
|
3475
|
+
${String(value)}`);
|
|
3476
|
+
}
|
|
3477
|
+
yield encodeUTF8("\r\n");
|
|
3478
|
+
}
|
|
3479
|
+
yield encodeUTF8(`--${boundary}--\r
|
|
3480
|
+
`);
|
|
3481
|
+
}
|
|
3482
|
+
async function* iterateFormEntries(body) {
|
|
3483
|
+
if (!body || typeof body !== "object")
|
|
3484
|
+
return;
|
|
3485
|
+
for (const [key2, value] of Object.entries(body)) {
|
|
3486
|
+
yield* iterateFormValue(key2, value);
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
async function* iterateFormValue(key2, value) {
|
|
3490
|
+
if (value === void 0)
|
|
3491
|
+
return;
|
|
3492
|
+
if (value == null) {
|
|
3493
|
+
throw new TypeError(`Received null for "${key2}"; to pass null in FormData, you must use the string 'null'`);
|
|
3494
|
+
}
|
|
3495
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || isUploadable(value)) {
|
|
3496
|
+
yield { key: key2, value };
|
|
3497
|
+
} else if (Array.isArray(value)) {
|
|
3498
|
+
for (const entry of value) {
|
|
3499
|
+
yield* iterateFormValue(key2 + "[]", entry);
|
|
3500
|
+
}
|
|
3501
|
+
} else if (typeof value === "object") {
|
|
3502
|
+
for (const [name, prop] of Object.entries(value)) {
|
|
3503
|
+
yield* iterateFormValue(`${key2}[${name}]`, prop);
|
|
3504
|
+
}
|
|
3505
|
+
} else {
|
|
3506
|
+
throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${value} instead`);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
function getStreamingFileName(value) {
|
|
3510
|
+
return isStreamingFile(value) ? value.name : getName(value) ?? "unknown_file";
|
|
3511
|
+
}
|
|
3512
|
+
function getStreamingFileType(value) {
|
|
3513
|
+
if (isStreamingFile(value))
|
|
3514
|
+
return value.type || "application/octet-stream";
|
|
3515
|
+
if (isNamedBlob(value) && value.type)
|
|
3516
|
+
return value.type;
|
|
3517
|
+
if (value instanceof Response)
|
|
3518
|
+
return value.headers.get("content-type") || "application/octet-stream";
|
|
3519
|
+
return "application/octet-stream";
|
|
3520
|
+
}
|
|
3521
|
+
function getStreamingFileData(value) {
|
|
3522
|
+
if (isStreamingFile(value))
|
|
3523
|
+
return value.data;
|
|
3524
|
+
return value;
|
|
3525
|
+
}
|
|
3526
|
+
async function* iterateBytes(value) {
|
|
3527
|
+
if (typeof value === "string") {
|
|
3528
|
+
yield encodeUTF8(value);
|
|
3529
|
+
} else if (ArrayBuffer.isView(value)) {
|
|
3530
|
+
yield new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
|
3531
|
+
} else if (value instanceof ArrayBuffer) {
|
|
3532
|
+
yield new Uint8Array(value);
|
|
3533
|
+
} else if (value instanceof Response) {
|
|
3534
|
+
if (value.body) {
|
|
3535
|
+
yield* iterateBytes(value.body);
|
|
3536
|
+
} else {
|
|
3537
|
+
yield* iterateBytes(await value.blob());
|
|
3538
|
+
}
|
|
3539
|
+
} else if (value instanceof Blob) {
|
|
3540
|
+
if (typeof value.stream === "function") {
|
|
3541
|
+
yield* iterateBytes(value.stream());
|
|
3542
|
+
} else {
|
|
3543
|
+
yield new Uint8Array(await value.arrayBuffer());
|
|
3544
|
+
}
|
|
3545
|
+
} else if (isReadableStream(value)) {
|
|
3546
|
+
for await (const chunk of ReadableStreamToAsyncIterable(value)) {
|
|
3547
|
+
yield* iterateBytes(chunk);
|
|
3548
|
+
}
|
|
3549
|
+
} else if (isAsyncIterable(value)) {
|
|
3550
|
+
for await (const chunk of value) {
|
|
3551
|
+
yield* iterateBytes(chunk);
|
|
3552
|
+
}
|
|
3553
|
+
} else {
|
|
3554
|
+
throw new TypeError(`Invalid streaming file chunk: ${String(value)}`);
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
function escapeHeaderValue(value) {
|
|
3558
|
+
return value.replace(/["\\\r\n]/g, (character) => encodeURIComponent(character));
|
|
3559
|
+
}
|
|
3303
3560
|
var addFormValue = async (form, key2, value) => {
|
|
3304
3561
|
if (value === void 0)
|
|
3305
3562
|
return;
|
|
@@ -3323,7 +3580,7 @@ var addFormValue = async (form, key2, value) => {
|
|
|
3323
3580
|
}
|
|
3324
3581
|
};
|
|
3325
3582
|
|
|
3326
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3583
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/to-file.mjs
|
|
3327
3584
|
var isBlobLike = (value) => value != null && typeof value === "object" && typeof value.size === "number" && typeof value.type === "string" && typeof value.text === "function" && typeof value.slice === "function" && typeof value.arrayBuffer === "function";
|
|
3328
3585
|
var isFileLike = (value) => value != null && typeof value === "object" && typeof value.name === "string" && typeof value.lastModified === "number" && isBlobLike(value);
|
|
3329
3586
|
var isResponseLike = (value) => value != null && typeof value === "object" && typeof value.url === "string" && typeof value.blob === "function";
|
|
@@ -3375,14 +3632,14 @@ function propsForError(value) {
|
|
|
3375
3632
|
return `; props: [${props.map((p) => `"${p}"`).join(", ")}]`;
|
|
3376
3633
|
}
|
|
3377
3634
|
|
|
3378
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3635
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/core/resource.mjs
|
|
3379
3636
|
var APIResource = class {
|
|
3380
3637
|
constructor(client) {
|
|
3381
3638
|
this._client = client;
|
|
3382
3639
|
}
|
|
3383
3640
|
};
|
|
3384
3641
|
|
|
3385
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3642
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/path.mjs
|
|
3386
3643
|
function encodeURIPath(str4) {
|
|
3387
3644
|
return str4.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
3388
3645
|
}
|
|
@@ -3437,7 +3694,7 @@ ${underline}`);
|
|
|
3437
3694
|
};
|
|
3438
3695
|
var path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
3439
3696
|
|
|
3440
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3697
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/chat/completions/messages.mjs
|
|
3441
3698
|
var Messages = class extends APIResource {
|
|
3442
3699
|
/**
|
|
3443
3700
|
* Get the messages in a stored chat completion. Only Chat Completions that have
|
|
@@ -3458,7 +3715,7 @@ var Messages = class extends APIResource {
|
|
|
3458
3715
|
}
|
|
3459
3716
|
};
|
|
3460
3717
|
|
|
3461
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3718
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/parser.mjs
|
|
3462
3719
|
function isChatCompletionFunctionTool(tool) {
|
|
3463
3720
|
return tool !== void 0 && "function" in tool && tool.function !== void 0;
|
|
3464
3721
|
}
|
|
@@ -3565,7 +3822,7 @@ function validateInputTools(tools) {
|
|
|
3565
3822
|
}
|
|
3566
3823
|
}
|
|
3567
3824
|
|
|
3568
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3825
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/chatCompletionUtils.mjs
|
|
3569
3826
|
var isAssistantMessage = (message) => {
|
|
3570
3827
|
return message?.role === "assistant";
|
|
3571
3828
|
};
|
|
@@ -3573,7 +3830,7 @@ var isToolMessage = (message) => {
|
|
|
3573
3830
|
return message?.role === "tool";
|
|
3574
3831
|
};
|
|
3575
3832
|
|
|
3576
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
3833
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/EventStream.mjs
|
|
3577
3834
|
var _EventStream_instances;
|
|
3578
3835
|
var _EventStream_connectedPromise;
|
|
3579
3836
|
var _EventStream_resolveConnectedPromise;
|
|
@@ -3582,10 +3839,12 @@ var _EventStream_endPromise;
|
|
|
3582
3839
|
var _EventStream_resolveEndPromise;
|
|
3583
3840
|
var _EventStream_rejectEndPromise;
|
|
3584
3841
|
var _EventStream_listeners;
|
|
3842
|
+
var _EventStream_abortListeners;
|
|
3585
3843
|
var _EventStream_ended;
|
|
3586
3844
|
var _EventStream_errored;
|
|
3587
3845
|
var _EventStream_aborted;
|
|
3588
3846
|
var _EventStream_catchingPromiseCreated;
|
|
3847
|
+
var _EventStream_removeAbortListeners;
|
|
3589
3848
|
var _EventStream_handleError;
|
|
3590
3849
|
var EventStream = class {
|
|
3591
3850
|
constructor() {
|
|
@@ -3602,6 +3861,7 @@ var EventStream = class {
|
|
|
3602
3861
|
_EventStream_rejectEndPromise.set(this, () => {
|
|
3603
3862
|
});
|
|
3604
3863
|
_EventStream_listeners.set(this, {});
|
|
3864
|
+
_EventStream_abortListeners.set(this, []);
|
|
3605
3865
|
_EventStream_ended.set(this, false);
|
|
3606
3866
|
_EventStream_errored.set(this, false);
|
|
3607
3867
|
_EventStream_aborted.set(this, false);
|
|
@@ -3621,8 +3881,13 @@ var EventStream = class {
|
|
|
3621
3881
|
}
|
|
3622
3882
|
_run(executor) {
|
|
3623
3883
|
setTimeout(() => {
|
|
3624
|
-
|
|
3625
|
-
|
|
3884
|
+
Promise.resolve().then(executor).then(() => {
|
|
3885
|
+
try {
|
|
3886
|
+
this._emitFinal();
|
|
3887
|
+
} catch (error) {
|
|
3888
|
+
__classPrivateFieldGet(this, _EventStream_instances, "m", _EventStream_handleError).call(this, error);
|
|
3889
|
+
return;
|
|
3890
|
+
}
|
|
3626
3891
|
this._emit("end");
|
|
3627
3892
|
}, __classPrivateFieldGet(this, _EventStream_instances, "m", _EventStream_handleError).bind(this));
|
|
3628
3893
|
}, 0);
|
|
@@ -3645,6 +3910,17 @@ var EventStream = class {
|
|
|
3645
3910
|
abort() {
|
|
3646
3911
|
this.controller.abort();
|
|
3647
3912
|
}
|
|
3913
|
+
_listenForAbort(signal) {
|
|
3914
|
+
if (!signal || this.ended)
|
|
3915
|
+
return;
|
|
3916
|
+
if (signal.aborted) {
|
|
3917
|
+
this.controller.abort();
|
|
3918
|
+
return;
|
|
3919
|
+
}
|
|
3920
|
+
const listener = () => this.controller.abort();
|
|
3921
|
+
signal.addEventListener("abort", listener, { once: true });
|
|
3922
|
+
__classPrivateFieldGet(this, _EventStream_abortListeners, "f").push({ signal, listener });
|
|
3923
|
+
}
|
|
3648
3924
|
/**
|
|
3649
3925
|
* Adds the listener function to the end of the listeners array for the event.
|
|
3650
3926
|
* No checks are made to see if the listener has already been added. Multiple calls passing
|
|
@@ -3702,6 +3978,102 @@ var EventStream = class {
|
|
|
3702
3978
|
this.once(event, resolve3);
|
|
3703
3979
|
});
|
|
3704
3980
|
}
|
|
3981
|
+
/**
|
|
3982
|
+
* Returns an async iterator that yields every time the event is triggered.
|
|
3983
|
+
* The iterator ends when the stream ends and rejects if the stream errors
|
|
3984
|
+
* or is aborted. If you request the 'error' or 'abort' event, the iterator
|
|
3985
|
+
* yields that event instead of rejecting.
|
|
3986
|
+
*
|
|
3987
|
+
* Example:
|
|
3988
|
+
*
|
|
3989
|
+
* for await (const [message] of stream.events('message')) {
|
|
3990
|
+
* await processMessage(message);
|
|
3991
|
+
* }
|
|
3992
|
+
*/
|
|
3993
|
+
events(event) {
|
|
3994
|
+
const pushQueue = [];
|
|
3995
|
+
const readQueue = [];
|
|
3996
|
+
let ended = this.ended;
|
|
3997
|
+
let failure;
|
|
3998
|
+
let failureDelivered = false;
|
|
3999
|
+
const doneResult = () => ({ value: void 0, done: true });
|
|
4000
|
+
const finishReaders = () => {
|
|
4001
|
+
while (readQueue.length) {
|
|
4002
|
+
readQueue.shift().resolve(doneResult());
|
|
4003
|
+
}
|
|
4004
|
+
};
|
|
4005
|
+
const rejectReader = () => {
|
|
4006
|
+
if (!failure || failureDelivered || !readQueue.length)
|
|
4007
|
+
return;
|
|
4008
|
+
failureDelivered = true;
|
|
4009
|
+
readQueue.shift().reject(failure);
|
|
4010
|
+
};
|
|
4011
|
+
const cleanup = () => {
|
|
4012
|
+
this.off(event, onEvent);
|
|
4013
|
+
this.off("end", onEnd);
|
|
4014
|
+
if (event !== "error")
|
|
4015
|
+
this.off("error", onFailure);
|
|
4016
|
+
if (event !== "abort")
|
|
4017
|
+
this.off("abort", onFailure);
|
|
4018
|
+
};
|
|
4019
|
+
const onEvent = (...args) => {
|
|
4020
|
+
if (ended)
|
|
4021
|
+
return;
|
|
4022
|
+
const reader = readQueue.shift();
|
|
4023
|
+
if (reader) {
|
|
4024
|
+
reader.resolve({ value: args, done: false });
|
|
4025
|
+
} else {
|
|
4026
|
+
pushQueue.push(args);
|
|
4027
|
+
}
|
|
4028
|
+
};
|
|
4029
|
+
const onFailure = (error) => {
|
|
4030
|
+
failure = error;
|
|
4031
|
+
if (!pushQueue.length)
|
|
4032
|
+
rejectReader();
|
|
4033
|
+
};
|
|
4034
|
+
const onEnd = () => {
|
|
4035
|
+
ended = true;
|
|
4036
|
+
cleanup();
|
|
4037
|
+
if (!pushQueue.length) {
|
|
4038
|
+
rejectReader();
|
|
4039
|
+
finishReaders();
|
|
4040
|
+
}
|
|
4041
|
+
};
|
|
4042
|
+
if (!ended) {
|
|
4043
|
+
this.on(event, onEvent);
|
|
4044
|
+
this.on("end", onEnd);
|
|
4045
|
+
if (event !== "error")
|
|
4046
|
+
this.on("error", onFailure);
|
|
4047
|
+
if (event !== "abort")
|
|
4048
|
+
this.on("abort", onFailure);
|
|
4049
|
+
}
|
|
4050
|
+
return {
|
|
4051
|
+
next: () => {
|
|
4052
|
+
const value = pushQueue.shift();
|
|
4053
|
+
if (value)
|
|
4054
|
+
return Promise.resolve({ value, done: false });
|
|
4055
|
+
if (failure && !failureDelivered) {
|
|
4056
|
+
failureDelivered = true;
|
|
4057
|
+
return Promise.reject(failure);
|
|
4058
|
+
}
|
|
4059
|
+
if (ended)
|
|
4060
|
+
return Promise.resolve(doneResult());
|
|
4061
|
+
return new Promise((resolve3, reject) => {
|
|
4062
|
+
readQueue.push({ resolve: resolve3, reject });
|
|
4063
|
+
});
|
|
4064
|
+
},
|
|
4065
|
+
return: () => {
|
|
4066
|
+
ended = true;
|
|
4067
|
+
pushQueue.length = 0;
|
|
4068
|
+
cleanup();
|
|
4069
|
+
finishReaders();
|
|
4070
|
+
return Promise.resolve(doneResult());
|
|
4071
|
+
},
|
|
4072
|
+
[Symbol.asyncIterator]() {
|
|
4073
|
+
return this;
|
|
4074
|
+
}
|
|
4075
|
+
};
|
|
4076
|
+
}
|
|
3705
4077
|
async done() {
|
|
3706
4078
|
__classPrivateFieldSet(this, _EventStream_catchingPromiseCreated, true, "f");
|
|
3707
4079
|
await __classPrivateFieldGet(this, _EventStream_endPromise, "f");
|
|
@@ -3711,6 +4083,7 @@ var EventStream = class {
|
|
|
3711
4083
|
return;
|
|
3712
4084
|
}
|
|
3713
4085
|
if (event === "end") {
|
|
4086
|
+
__classPrivateFieldGet(this, _EventStream_instances, "m", _EventStream_removeAbortListeners).call(this);
|
|
3714
4087
|
__classPrivateFieldSet(this, _EventStream_ended, true, "f");
|
|
3715
4088
|
__classPrivateFieldGet(this, _EventStream_resolveEndPromise, "f").call(this);
|
|
3716
4089
|
}
|
|
@@ -3742,7 +4115,11 @@ var EventStream = class {
|
|
|
3742
4115
|
_emitFinal() {
|
|
3743
4116
|
}
|
|
3744
4117
|
};
|
|
3745
|
-
_EventStream_connectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_resolveConnectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_rejectConnectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_endPromise = /* @__PURE__ */ new WeakMap(), _EventStream_resolveEndPromise = /* @__PURE__ */ new WeakMap(), _EventStream_rejectEndPromise = /* @__PURE__ */ new WeakMap(), _EventStream_listeners = /* @__PURE__ */ new WeakMap(), _EventStream_ended = /* @__PURE__ */ new WeakMap(), _EventStream_errored = /* @__PURE__ */ new WeakMap(), _EventStream_aborted = /* @__PURE__ */ new WeakMap(), _EventStream_catchingPromiseCreated = /* @__PURE__ */ new WeakMap(), _EventStream_instances = /* @__PURE__ */ new WeakSet(),
|
|
4118
|
+
_EventStream_connectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_resolveConnectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_rejectConnectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_endPromise = /* @__PURE__ */ new WeakMap(), _EventStream_resolveEndPromise = /* @__PURE__ */ new WeakMap(), _EventStream_rejectEndPromise = /* @__PURE__ */ new WeakMap(), _EventStream_listeners = /* @__PURE__ */ new WeakMap(), _EventStream_abortListeners = /* @__PURE__ */ new WeakMap(), _EventStream_ended = /* @__PURE__ */ new WeakMap(), _EventStream_errored = /* @__PURE__ */ new WeakMap(), _EventStream_aborted = /* @__PURE__ */ new WeakMap(), _EventStream_catchingPromiseCreated = /* @__PURE__ */ new WeakMap(), _EventStream_instances = /* @__PURE__ */ new WeakSet(), _EventStream_removeAbortListeners = function _EventStream_removeAbortListeners2() {
|
|
4119
|
+
for (const { signal, listener } of __classPrivateFieldGet(this, _EventStream_abortListeners, "f").splice(0)) {
|
|
4120
|
+
signal.removeEventListener("abort", listener);
|
|
4121
|
+
}
|
|
4122
|
+
}, _EventStream_handleError = function _EventStream_handleError2(error) {
|
|
3746
4123
|
__classPrivateFieldSet(this, _EventStream_errored, true, "f");
|
|
3747
4124
|
if (error instanceof Error && error.name === "AbortError") {
|
|
3748
4125
|
error = new APIUserAbortError();
|
|
@@ -3762,12 +4139,12 @@ _EventStream_connectedPromise = /* @__PURE__ */ new WeakMap(), _EventStream_reso
|
|
|
3762
4139
|
return this._emit("error", new OpenAIError(String(error)));
|
|
3763
4140
|
};
|
|
3764
4141
|
|
|
3765
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
4142
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/RunnableFunction.mjs
|
|
3766
4143
|
function isRunnableFunctionWithParse(fn) {
|
|
3767
4144
|
return typeof fn.parse === "function";
|
|
3768
4145
|
}
|
|
3769
4146
|
|
|
3770
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
4147
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/AbstractChatCompletionRunner.mjs
|
|
3771
4148
|
var _AbstractChatCompletionRunner_instances;
|
|
3772
4149
|
var _AbstractChatCompletionRunner_getFinalContent;
|
|
3773
4150
|
var _AbstractChatCompletionRunner_getFinalMessage;
|
|
@@ -3777,6 +4154,15 @@ var _AbstractChatCompletionRunner_calculateTotalUsage;
|
|
|
3777
4154
|
var _AbstractChatCompletionRunner_validateParams;
|
|
3778
4155
|
var _AbstractChatCompletionRunner_stringifyFunctionCallResult;
|
|
3779
4156
|
var DEFAULT_MAX_CHAT_COMPLETIONS = 10;
|
|
4157
|
+
function normalizeToolCallIds(chatCompletion) {
|
|
4158
|
+
for (const choice of chatCompletion.choices) {
|
|
4159
|
+
for (const toolCall of choice.message.tool_calls ?? []) {
|
|
4160
|
+
if (!toolCall.id) {
|
|
4161
|
+
toolCall.id = `call_${uuid4()}`;
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
}
|
|
3780
4166
|
var AbstractChatCompletionRunner = class extends EventStream {
|
|
3781
4167
|
constructor() {
|
|
3782
4168
|
super(...arguments);
|
|
@@ -3785,6 +4171,7 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
3785
4171
|
this.messages = [];
|
|
3786
4172
|
}
|
|
3787
4173
|
_addChatCompletion(chatCompletion) {
|
|
4174
|
+
normalizeToolCallIds(chatCompletion);
|
|
3788
4175
|
this._chatCompletions.push(chatCompletion);
|
|
3789
4176
|
this._emit("chatCompletion", chatCompletion);
|
|
3790
4177
|
const message = chatCompletion.choices[0]?.message;
|
|
@@ -3829,7 +4216,7 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
3829
4216
|
return __classPrivateFieldGet(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_getFinalContent).call(this);
|
|
3830
4217
|
}
|
|
3831
4218
|
/**
|
|
3832
|
-
* @returns a promise that resolves with the
|
|
4219
|
+
* @returns a promise that resolves with the final assistant ChatCompletionMessage response,
|
|
3833
4220
|
* or rejects if an error occurred or the stream ended prematurely without producing a ChatCompletionMessage.
|
|
3834
4221
|
*/
|
|
3835
4222
|
async finalMessage() {
|
|
@@ -3876,12 +4263,7 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
3876
4263
|
}
|
|
3877
4264
|
}
|
|
3878
4265
|
async _createChatCompletion(client, params, options) {
|
|
3879
|
-
|
|
3880
|
-
if (signal) {
|
|
3881
|
-
if (signal.aborted)
|
|
3882
|
-
this.controller.abort();
|
|
3883
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
3884
|
-
}
|
|
4266
|
+
this._listenForAbort(options?.signal);
|
|
3885
4267
|
__classPrivateFieldGet(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_validateParams).call(this, params);
|
|
3886
4268
|
const chatCompletion = await client.chat.completions.create({ ...params, stream: false }, { ...options, signal: this.controller.signal });
|
|
3887
4269
|
this._connected();
|
|
@@ -3893,11 +4275,12 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
3893
4275
|
}
|
|
3894
4276
|
return await this._createChatCompletion(client, params, options);
|
|
3895
4277
|
}
|
|
3896
|
-
async _runTools(client, params, options) {
|
|
4278
|
+
async _runTools(client, params, runner, options) {
|
|
3897
4279
|
const role = "tool";
|
|
3898
|
-
const { tool_choice = "auto", stream, ...restParams } = params;
|
|
4280
|
+
const { tool_choice = "auto", stream, toolContext: inputToolContext, ...restParams } = params;
|
|
4281
|
+
const toolContext = inputToolContext;
|
|
3899
4282
|
const singleFunctionToCall = typeof tool_choice !== "string" && tool_choice.type === "function" && tool_choice?.function?.name;
|
|
3900
|
-
const { maxChatCompletions = DEFAULT_MAX_CHAT_COMPLETIONS } = options || {};
|
|
4283
|
+
const { maxChatCompletions = DEFAULT_MAX_CHAT_COMPLETIONS, afterCompletion } = options || {};
|
|
3901
4284
|
const inputTools = params.tools.map((tool) => {
|
|
3902
4285
|
if (isAutoParsableTool(tool)) {
|
|
3903
4286
|
if (!tool.$callback) {
|
|
@@ -3935,6 +4318,36 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
3935
4318
|
for (const message of params.messages) {
|
|
3936
4319
|
this._addMessage(message, false);
|
|
3937
4320
|
}
|
|
4321
|
+
const runToolCall = async (toolCall) => {
|
|
4322
|
+
if (toolCall.type !== "function")
|
|
4323
|
+
return { message: void 0, functionCalled: false };
|
|
4324
|
+
const tool_call_id = toolCall.id;
|
|
4325
|
+
const { name, arguments: args } = toolCall.function;
|
|
4326
|
+
const fn = functionsByName[name];
|
|
4327
|
+
if (!fn) {
|
|
4328
|
+
const content2 = `Invalid tool_call: ${JSON.stringify(name)}. Available options are: ${Object.keys(functionsByName).map((name2) => JSON.stringify(name2)).join(", ")}. Please try again`;
|
|
4329
|
+
return { message: { role, tool_call_id, content: content2 }, functionCalled: false };
|
|
4330
|
+
}
|
|
4331
|
+
if (singleFunctionToCall && singleFunctionToCall !== name) {
|
|
4332
|
+
const content2 = `Invalid tool_call: ${JSON.stringify(name)}. ${JSON.stringify(singleFunctionToCall)} requested. Please try again`;
|
|
4333
|
+
return { message: { role, tool_call_id, content: content2 }, functionCalled: false };
|
|
4334
|
+
}
|
|
4335
|
+
let rawContent;
|
|
4336
|
+
if (isRunnableFunctionWithParse(fn)) {
|
|
4337
|
+
let parsed;
|
|
4338
|
+
try {
|
|
4339
|
+
parsed = await fn.parse(args);
|
|
4340
|
+
} catch (error) {
|
|
4341
|
+
const content2 = error instanceof Error ? error.message : String(error);
|
|
4342
|
+
return { message: { role, tool_call_id, content: content2 }, functionCalled: false };
|
|
4343
|
+
}
|
|
4344
|
+
rawContent = await fn.function(parsed, runner, toolContext);
|
|
4345
|
+
} else {
|
|
4346
|
+
rawContent = await fn.function(args, runner, toolContext);
|
|
4347
|
+
}
|
|
4348
|
+
const content = __classPrivateFieldGet(this, _AbstractChatCompletionRunner_instances, "m", _AbstractChatCompletionRunner_stringifyFunctionCallResult).call(this, rawContent);
|
|
4349
|
+
return { message: { role, tool_call_id, content }, functionCalled: true };
|
|
4350
|
+
};
|
|
3938
4351
|
for (let i = 0; i < maxChatCompletions; ++i) {
|
|
3939
4352
|
const chatCompletion = await this._createChatCompletion(client, {
|
|
3940
4353
|
...restParams,
|
|
@@ -3947,38 +4360,32 @@ var AbstractChatCompletionRunner = class extends EventStream {
|
|
|
3947
4360
|
throw new OpenAIError(`missing message in ChatCompletion response`);
|
|
3948
4361
|
}
|
|
3949
4362
|
if (!message.tool_calls?.length) {
|
|
4363
|
+
await afterCompletion?.(chatCompletion, runner);
|
|
3950
4364
|
return;
|
|
3951
4365
|
}
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
continue;
|
|
3962
|
-
} else if (singleFunctionToCall && singleFunctionToCall !== name) {
|
|
3963
|
-
const content2 = `Invalid tool_call: ${JSON.stringify(name)}. ${JSON.stringify(singleFunctionToCall)} requested. Please try again`;
|
|
3964
|
-
this._addMessage({ role, tool_call_id, content: content2 });
|
|
3965
|
-
continue;
|
|
4366
|
+
if (singleFunctionToCall || params.parallel_tool_calls === false) {
|
|
4367
|
+
for (const toolCall of message.tool_calls) {
|
|
4368
|
+
const result = await runToolCall(toolCall);
|
|
4369
|
+
if (result.message)
|
|
4370
|
+
this._addMessage(result.message);
|
|
4371
|
+
if (singleFunctionToCall && result.functionCalled) {
|
|
4372
|
+
await afterCompletion?.(chatCompletion, runner);
|
|
4373
|
+
return;
|
|
4374
|
+
}
|
|
3966
4375
|
}
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
this._addMessage({ role, tool_call_id, content: content2 });
|
|
3973
|
-
continue;
|
|
4376
|
+
} else {
|
|
4377
|
+
const results = await Promise.allSettled(message.tool_calls.map(runToolCall));
|
|
4378
|
+
for (const result of results) {
|
|
4379
|
+
if (result.status === "rejected")
|
|
4380
|
+
throw result.reason;
|
|
3974
4381
|
}
|
|
3975
|
-
const
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
return;
|
|
4382
|
+
for (const result of results) {
|
|
4383
|
+
if (result.status === "fulfilled" && result.value.message) {
|
|
4384
|
+
this._addMessage(result.value.message);
|
|
4385
|
+
}
|
|
3980
4386
|
}
|
|
3981
4387
|
}
|
|
4388
|
+
await afterCompletion?.(chatCompletion, runner);
|
|
3982
4389
|
}
|
|
3983
4390
|
return;
|
|
3984
4391
|
}
|
|
@@ -4042,7 +4449,7 @@ _AbstractChatCompletionRunner_instances = /* @__PURE__ */ new WeakSet(), _Abstra
|
|
|
4042
4449
|
return typeof rawContent === "string" ? rawContent : rawContent === void 0 ? "undefined" : JSON.stringify(rawContent);
|
|
4043
4450
|
};
|
|
4044
4451
|
|
|
4045
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
4452
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/ChatCompletionRunner.mjs
|
|
4046
4453
|
var ChatCompletionRunner = class _ChatCompletionRunner extends AbstractChatCompletionRunner {
|
|
4047
4454
|
static runTools(client, params, options) {
|
|
4048
4455
|
const runner = new _ChatCompletionRunner();
|
|
@@ -4050,7 +4457,7 @@ var ChatCompletionRunner = class _ChatCompletionRunner extends AbstractChatCompl
|
|
|
4050
4457
|
...options,
|
|
4051
4458
|
headers: { ...options?.headers, "X-Stainless-Helper-Method": "runTools" }
|
|
4052
4459
|
};
|
|
4053
|
-
runner._run(() => runner._runTools(client, params, opts));
|
|
4460
|
+
runner._run(() => runner._runTools(client, params, runner, opts));
|
|
4054
4461
|
return runner;
|
|
4055
4462
|
}
|
|
4056
4463
|
_addMessage(message, emit = true) {
|
|
@@ -4061,7 +4468,7 @@ var ChatCompletionRunner = class _ChatCompletionRunner extends AbstractChatCompl
|
|
|
4061
4468
|
}
|
|
4062
4469
|
};
|
|
4063
4470
|
|
|
4064
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
4471
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/_vendor/partial-json-parser/parser.mjs
|
|
4065
4472
|
var STR = 1;
|
|
4066
4473
|
var NUM = 2;
|
|
4067
4474
|
var ARR = 4;
|
|
@@ -4273,7 +4680,7 @@ var _parseJSON = (jsonString, allow) => {
|
|
|
4273
4680
|
};
|
|
4274
4681
|
var partialParse = (input) => parseJSON(input, Allow.ALL ^ Allow.NUM);
|
|
4275
4682
|
|
|
4276
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
4683
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/ChatCompletionStream.mjs
|
|
4277
4684
|
var _ChatCompletionStream_instances;
|
|
4278
4685
|
var _ChatCompletionStream_params;
|
|
4279
4686
|
var _ChatCompletionStream_choiceEventStates;
|
|
@@ -4286,6 +4693,30 @@ var _ChatCompletionStream_emitContentDoneEvents;
|
|
|
4286
4693
|
var _ChatCompletionStream_endRequest;
|
|
4287
4694
|
var _ChatCompletionStream_getAutoParseableResponseFormat;
|
|
4288
4695
|
var _ChatCompletionStream_accumulateChatCompletion;
|
|
4696
|
+
var CHAT_COMPLETION_READABLE_STREAM_MESSAGE_PREFIX = "chat.completion.chunk.message:";
|
|
4697
|
+
function makeChatCompletionReadableStreamMessageChunk(chunk, message, toolCallIds) {
|
|
4698
|
+
const payload = {
|
|
4699
|
+
type: "message",
|
|
4700
|
+
message,
|
|
4701
|
+
...toolCallIds ? { tool_call_ids: toolCallIds } : {}
|
|
4702
|
+
};
|
|
4703
|
+
return {
|
|
4704
|
+
id: chunk.id,
|
|
4705
|
+
choices: [],
|
|
4706
|
+
created: chunk.created,
|
|
4707
|
+
model: chunk.model,
|
|
4708
|
+
object: `${CHAT_COMPLETION_READABLE_STREAM_MESSAGE_PREFIX}${JSON.stringify(payload)}`
|
|
4709
|
+
};
|
|
4710
|
+
}
|
|
4711
|
+
function isChatCompletionReadableStreamMessage(item) {
|
|
4712
|
+
return "type" in item && item.type === "message" && "message" in item || "object" in item && typeof item.object === "string" && item.object.startsWith(CHAT_COMPLETION_READABLE_STREAM_MESSAGE_PREFIX);
|
|
4713
|
+
}
|
|
4714
|
+
function getChatCompletionReadableStreamMessage(item) {
|
|
4715
|
+
if ("type" in item) {
|
|
4716
|
+
return item;
|
|
4717
|
+
}
|
|
4718
|
+
return JSON.parse(item.object.slice(CHAT_COMPLETION_READABLE_STREAM_MESSAGE_PREFIX.length));
|
|
4719
|
+
}
|
|
4289
4720
|
var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompletionRunner {
|
|
4290
4721
|
constructor(params) {
|
|
4291
4722
|
super();
|
|
@@ -4318,12 +4749,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4318
4749
|
}
|
|
4319
4750
|
async _createChatCompletion(client, params, options) {
|
|
4320
4751
|
super._createChatCompletion;
|
|
4321
|
-
|
|
4322
|
-
if (signal) {
|
|
4323
|
-
if (signal.aborted)
|
|
4324
|
-
this.controller.abort();
|
|
4325
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
4326
|
-
}
|
|
4752
|
+
this._listenForAbort(options?.signal);
|
|
4327
4753
|
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
4328
4754
|
const stream = await client.chat.completions.create({ ...params, stream: true }, { ...options, signal: this.controller.signal });
|
|
4329
4755
|
this._connected();
|
|
@@ -4336,27 +4762,47 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4336
4762
|
return this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
4337
4763
|
}
|
|
4338
4764
|
async _fromReadableStream(readableStream, options) {
|
|
4339
|
-
|
|
4340
|
-
if (signal) {
|
|
4341
|
-
if (signal.aborted)
|
|
4342
|
-
this.controller.abort();
|
|
4343
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
4344
|
-
}
|
|
4765
|
+
this._listenForAbort(options?.signal);
|
|
4345
4766
|
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_beginRequest).call(this);
|
|
4346
4767
|
this._connected();
|
|
4347
4768
|
const stream = Stream.fromReadableStream(readableStream, this.controller);
|
|
4348
4769
|
let chatId;
|
|
4349
|
-
for await (const
|
|
4350
|
-
if (
|
|
4770
|
+
for await (const item of stream) {
|
|
4771
|
+
if (isChatCompletionReadableStreamMessage(item)) {
|
|
4772
|
+
const message = getChatCompletionReadableStreamMessage(item);
|
|
4773
|
+
if (__classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f")) {
|
|
4774
|
+
const toolCalls = __classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f").choices[0]?.message.tool_calls;
|
|
4775
|
+
for (const [index, id] of message.tool_call_ids?.entries() ?? []) {
|
|
4776
|
+
const toolCall = toolCalls?.[index];
|
|
4777
|
+
if (toolCall && id) {
|
|
4778
|
+
toolCall.id = id;
|
|
4779
|
+
}
|
|
4780
|
+
}
|
|
4781
|
+
this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
4782
|
+
chatId = void 0;
|
|
4783
|
+
}
|
|
4784
|
+
this._addMessage(message.message);
|
|
4785
|
+
continue;
|
|
4786
|
+
}
|
|
4787
|
+
const chunk = item;
|
|
4788
|
+
if (chatId && chunk.id && chatId !== chunk.id) {
|
|
4351
4789
|
this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
4352
4790
|
}
|
|
4353
4791
|
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_addChunk).call(this, chunk);
|
|
4354
|
-
|
|
4792
|
+
if (chunk.id)
|
|
4793
|
+
chatId = chunk.id;
|
|
4355
4794
|
}
|
|
4356
4795
|
if (stream.controller.signal?.aborted) {
|
|
4357
4796
|
throw new APIUserAbortError();
|
|
4358
4797
|
}
|
|
4359
|
-
|
|
4798
|
+
if (__classPrivateFieldGet(this, _ChatCompletionStream_currentChatCompletionSnapshot, "f")) {
|
|
4799
|
+
return this._addChatCompletion(__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_endRequest).call(this));
|
|
4800
|
+
}
|
|
4801
|
+
const lastChatCompletion = this._chatCompletions[this._chatCompletions.length - 1];
|
|
4802
|
+
if (lastChatCompletion) {
|
|
4803
|
+
return lastChatCompletion;
|
|
4804
|
+
}
|
|
4805
|
+
throw new OpenAIError(`request ended without sending any chunks`);
|
|
4360
4806
|
}
|
|
4361
4807
|
[(_ChatCompletionStream_params = /* @__PURE__ */ new WeakMap(), _ChatCompletionStream_choiceEventStates = /* @__PURE__ */ new WeakMap(), _ChatCompletionStream_currentChatCompletionSnapshot = /* @__PURE__ */ new WeakMap(), _ChatCompletionStream_instances = /* @__PURE__ */ new WeakSet(), _ChatCompletionStream_beginRequest = function _ChatCompletionStream_beginRequest2() {
|
|
4362
4808
|
if (this.ended)
|
|
@@ -4384,17 +4830,18 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4384
4830
|
this._emit("chunk", chunk, completion);
|
|
4385
4831
|
for (const choice of chunk.choices) {
|
|
4386
4832
|
const choiceSnapshot = completion.choices[choice.index];
|
|
4387
|
-
|
|
4388
|
-
|
|
4833
|
+
const { delta } = choice;
|
|
4834
|
+
if (delta?.content != null && choiceSnapshot.message?.role === "assistant" && choiceSnapshot.message?.content) {
|
|
4835
|
+
this._emit("content", delta.content, choiceSnapshot.message.content);
|
|
4389
4836
|
this._emit("content.delta", {
|
|
4390
|
-
delta:
|
|
4837
|
+
delta: delta.content,
|
|
4391
4838
|
snapshot: choiceSnapshot.message.content,
|
|
4392
4839
|
parsed: choiceSnapshot.message.parsed
|
|
4393
4840
|
});
|
|
4394
4841
|
}
|
|
4395
|
-
if (
|
|
4842
|
+
if (delta?.refusal != null && choiceSnapshot.message?.role === "assistant" && choiceSnapshot.message?.refusal) {
|
|
4396
4843
|
this._emit("refusal.delta", {
|
|
4397
|
-
delta:
|
|
4844
|
+
delta: delta.refusal,
|
|
4398
4845
|
snapshot: choiceSnapshot.message.refusal
|
|
4399
4846
|
});
|
|
4400
4847
|
}
|
|
@@ -4417,7 +4864,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4417
4864
|
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitToolCallDoneEvent).call(this, choiceSnapshot, state.current_tool_call_index);
|
|
4418
4865
|
}
|
|
4419
4866
|
}
|
|
4420
|
-
for (const toolCall of
|
|
4867
|
+
for (const toolCall of delta?.tool_calls ?? []) {
|
|
4421
4868
|
if (state.current_tool_call_index !== toolCall.index) {
|
|
4422
4869
|
__classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_emitContentDoneEvents).call(this, choiceSnapshot);
|
|
4423
4870
|
if (state.current_tool_call_index != null) {
|
|
@@ -4426,7 +4873,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4426
4873
|
}
|
|
4427
4874
|
state.current_tool_call_index = toolCall.index;
|
|
4428
4875
|
}
|
|
4429
|
-
for (const toolCallDelta of
|
|
4876
|
+
for (const toolCallDelta of delta?.tool_calls ?? []) {
|
|
4430
4877
|
const toolCallSnapshot = choiceSnapshot.message.tool_calls?.[toolCallDelta.index];
|
|
4431
4878
|
if (!toolCallSnapshot?.type) {
|
|
4432
4879
|
continue;
|
|
@@ -4515,7 +4962,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4515
4962
|
...rest,
|
|
4516
4963
|
choices: []
|
|
4517
4964
|
}, "f");
|
|
4518
|
-
} else {
|
|
4965
|
+
} else if (chunk.id) {
|
|
4519
4966
|
Object.assign(snapshot, rest);
|
|
4520
4967
|
}
|
|
4521
4968
|
for (const { delta, finish_reason, index, logprobs = null, ...other } of chunk.choices) {
|
|
@@ -4577,7 +5024,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
4577
5024
|
if (content) {
|
|
4578
5025
|
choice.message.content = (choice.message.content || "") + content;
|
|
4579
5026
|
if (!choice.message.refusal && __classPrivateFieldGet(this, _ChatCompletionStream_instances, "m", _ChatCompletionStream_getAutoParseableResponseFormat).call(this)) {
|
|
4580
|
-
choice.message.parsed = partialParse(choice.message.content);
|
|
5027
|
+
choice.message.parsed = choice.message.content.trim() ? partialParse(choice.message.content) : null;
|
|
4581
5028
|
}
|
|
4582
5029
|
}
|
|
4583
5030
|
if (tool_calls) {
|
|
@@ -4708,10 +5155,6 @@ function finalizeChatCompletion(snapshot, params) {
|
|
|
4708
5155
|
tool_calls: tool_calls.map((tool_call, i) => {
|
|
4709
5156
|
const { function: fn, type, id: id2, ...toolRest } = tool_call;
|
|
4710
5157
|
const { arguments: args, name, ...fnRest } = fn || {};
|
|
4711
|
-
if (id2 == null) {
|
|
4712
|
-
throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].id
|
|
4713
|
-
${str(snapshot)}`);
|
|
4714
|
-
}
|
|
4715
5158
|
if (type == null) {
|
|
4716
5159
|
throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].type
|
|
4717
5160
|
${str(snapshot)}`);
|
|
@@ -4724,7 +5167,12 @@ ${str(snapshot)}`);
|
|
|
4724
5167
|
throw new OpenAIError(`missing choices[${index}].tool_calls[${i}].function.arguments
|
|
4725
5168
|
${str(snapshot)}`);
|
|
4726
5169
|
}
|
|
4727
|
-
return {
|
|
5170
|
+
return {
|
|
5171
|
+
...toolRest,
|
|
5172
|
+
id: id2 || `call_${uuid4()}`,
|
|
5173
|
+
type,
|
|
5174
|
+
function: { ...fnRest, name, arguments: args }
|
|
5175
|
+
};
|
|
4728
5176
|
})
|
|
4729
5177
|
}
|
|
4730
5178
|
};
|
|
@@ -4753,30 +5201,103 @@ function assertIsEmpty(obj) {
|
|
|
4753
5201
|
function assertNever(_x) {
|
|
4754
5202
|
}
|
|
4755
5203
|
|
|
4756
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5204
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/ChatCompletionStreamingRunner.mjs
|
|
4757
5205
|
var ChatCompletionStreamingRunner = class _ChatCompletionStreamingRunner extends ChatCompletionStream {
|
|
4758
5206
|
static fromReadableStream(stream) {
|
|
4759
5207
|
const runner = new _ChatCompletionStreamingRunner(null);
|
|
4760
5208
|
runner._run(() => runner._fromReadableStream(stream));
|
|
4761
5209
|
return runner;
|
|
4762
5210
|
}
|
|
4763
|
-
|
|
4764
|
-
const
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
5211
|
+
toReadableStream() {
|
|
5212
|
+
const pushQueue = [];
|
|
5213
|
+
const readQueue = [];
|
|
5214
|
+
let done = false;
|
|
5215
|
+
let lastChunk;
|
|
5216
|
+
let toolCallIds;
|
|
5217
|
+
const pushEvent = (event) => {
|
|
5218
|
+
const reader = readQueue.shift();
|
|
5219
|
+
if (reader) {
|
|
5220
|
+
reader.resolve(event);
|
|
5221
|
+
} else {
|
|
5222
|
+
pushQueue.push(event);
|
|
5223
|
+
}
|
|
4771
5224
|
};
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
};
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
5225
|
+
this.on("chunk", (chunk) => {
|
|
5226
|
+
lastChunk = chunk;
|
|
5227
|
+
pushEvent(chunk);
|
|
5228
|
+
});
|
|
5229
|
+
this.on("message", (message) => {
|
|
5230
|
+
if (isAssistantMessage(message)) {
|
|
5231
|
+
toolCallIds = message.tool_calls?.map((toolCall) => toolCall.id);
|
|
5232
|
+
return;
|
|
5233
|
+
}
|
|
5234
|
+
if (isToolMessage(message)) {
|
|
5235
|
+
if (!lastChunk) {
|
|
5236
|
+
throw new OpenAIError("cannot serialize a tool message before receiving any chunks");
|
|
5237
|
+
}
|
|
5238
|
+
pushEvent(makeChatCompletionReadableStreamMessageChunk(lastChunk, message, toolCallIds));
|
|
5239
|
+
}
|
|
5240
|
+
});
|
|
5241
|
+
this.on("end", () => {
|
|
5242
|
+
done = true;
|
|
5243
|
+
for (const reader of readQueue) {
|
|
5244
|
+
reader.resolve(void 0);
|
|
5245
|
+
}
|
|
5246
|
+
readQueue.length = 0;
|
|
5247
|
+
});
|
|
5248
|
+
this.on("abort", (err) => {
|
|
5249
|
+
done = true;
|
|
5250
|
+
for (const reader of readQueue) {
|
|
5251
|
+
reader.reject(err);
|
|
5252
|
+
}
|
|
5253
|
+
readQueue.length = 0;
|
|
5254
|
+
});
|
|
5255
|
+
this.on("error", (err) => {
|
|
5256
|
+
done = true;
|
|
5257
|
+
for (const reader of readQueue) {
|
|
5258
|
+
reader.reject(err);
|
|
5259
|
+
}
|
|
5260
|
+
readQueue.length = 0;
|
|
5261
|
+
});
|
|
5262
|
+
const iterator = () => ({
|
|
5263
|
+
next: async () => {
|
|
5264
|
+
if (!pushQueue.length) {
|
|
5265
|
+
if (done) {
|
|
5266
|
+
return { value: void 0, done: true };
|
|
5267
|
+
}
|
|
5268
|
+
return new Promise((resolve3, reject) => readQueue.push({ resolve: resolve3, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
5269
|
+
}
|
|
5270
|
+
const event = pushQueue.shift();
|
|
5271
|
+
if (!event) {
|
|
5272
|
+
return { value: void 0, done: true };
|
|
5273
|
+
}
|
|
5274
|
+
return { value: event, done: false };
|
|
5275
|
+
},
|
|
5276
|
+
return: async () => {
|
|
5277
|
+
this.abort();
|
|
5278
|
+
return { value: void 0, done: true };
|
|
5279
|
+
}
|
|
5280
|
+
});
|
|
5281
|
+
const stream = new Stream(iterator, this.controller);
|
|
5282
|
+
return stream.toReadableStream();
|
|
5283
|
+
}
|
|
5284
|
+
static runTools(client, params, options) {
|
|
5285
|
+
const runner = new _ChatCompletionStreamingRunner(
|
|
5286
|
+
// @ts-expect-error TODO these types are incompatible
|
|
5287
|
+
params
|
|
5288
|
+
);
|
|
5289
|
+
const opts = {
|
|
5290
|
+
...options,
|
|
5291
|
+
headers: { ...options?.headers, "X-Stainless-Helper-Method": "runTools" }
|
|
5292
|
+
};
|
|
5293
|
+
runner._run(() => runner._runTools(client, params, runner, opts));
|
|
5294
|
+
return runner;
|
|
5295
|
+
}
|
|
5296
|
+
};
|
|
5297
|
+
|
|
5298
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/chat/completions/completions.mjs
|
|
5299
|
+
var Completions = class extends APIResource {
|
|
5300
|
+
constructor() {
|
|
4780
5301
|
super(...arguments);
|
|
4781
5302
|
this.messages = new Messages(this._client);
|
|
4782
5303
|
}
|
|
@@ -4884,7 +5405,7 @@ var Completions = class extends APIResource {
|
|
|
4884
5405
|
};
|
|
4885
5406
|
Completions.Messages = Messages;
|
|
4886
5407
|
|
|
4887
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5408
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/chat/chat.mjs
|
|
4888
5409
|
var Chat = class extends APIResource {
|
|
4889
5410
|
constructor() {
|
|
4890
5411
|
super(...arguments);
|
|
@@ -4893,7 +5414,7 @@ var Chat = class extends APIResource {
|
|
|
4893
5414
|
};
|
|
4894
5415
|
Chat.Completions = Completions;
|
|
4895
5416
|
|
|
4896
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5417
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/admin-api-keys.mjs
|
|
4897
5418
|
var AdminAPIKeys = class extends APIResource {
|
|
4898
5419
|
/**
|
|
4899
5420
|
* Create an organization admin API key
|
|
@@ -4967,7 +5488,7 @@ var AdminAPIKeys = class extends APIResource {
|
|
|
4967
5488
|
}
|
|
4968
5489
|
};
|
|
4969
5490
|
|
|
4970
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5491
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/audit-logs.mjs
|
|
4971
5492
|
var AuditLogs = class extends APIResource {
|
|
4972
5493
|
/**
|
|
4973
5494
|
* List user actions and configuration changes within this organization.
|
|
@@ -4989,7 +5510,7 @@ var AuditLogs = class extends APIResource {
|
|
|
4989
5510
|
}
|
|
4990
5511
|
};
|
|
4991
5512
|
|
|
4992
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5513
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/certificates.mjs
|
|
4993
5514
|
var Certificates = class extends APIResource {
|
|
4994
5515
|
/**
|
|
4995
5516
|
* Upload a certificate to the organization. This does **not** automatically
|
|
@@ -5126,7 +5647,7 @@ var Certificates = class extends APIResource {
|
|
|
5126
5647
|
}
|
|
5127
5648
|
};
|
|
5128
5649
|
|
|
5129
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5650
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/data-retention.mjs
|
|
5130
5651
|
var DataRetention = class extends APIResource {
|
|
5131
5652
|
/**
|
|
5132
5653
|
* Retrieves organization data retention controls.
|
|
@@ -5163,7 +5684,7 @@ var DataRetention = class extends APIResource {
|
|
|
5163
5684
|
}
|
|
5164
5685
|
};
|
|
5165
5686
|
|
|
5166
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5687
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/invites.mjs
|
|
5167
5688
|
var Invites = class extends APIResource {
|
|
5168
5689
|
/**
|
|
5169
5690
|
* Create an invite for a user to the organization. The invite must be accepted by
|
|
@@ -5239,7 +5760,7 @@ var Invites = class extends APIResource {
|
|
|
5239
5760
|
}
|
|
5240
5761
|
};
|
|
5241
5762
|
|
|
5242
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5763
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/roles.mjs
|
|
5243
5764
|
var Roles = class extends APIResource {
|
|
5244
5765
|
/**
|
|
5245
5766
|
* Creates a custom role for the organization.
|
|
@@ -5328,7 +5849,7 @@ var Roles = class extends APIResource {
|
|
|
5328
5849
|
}
|
|
5329
5850
|
};
|
|
5330
5851
|
|
|
5331
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5852
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/spend-alerts.mjs
|
|
5332
5853
|
var SpendAlerts = class extends APIResource {
|
|
5333
5854
|
/**
|
|
5334
5855
|
* Creates an organization spend alert.
|
|
@@ -5431,7 +5952,7 @@ var SpendAlerts = class extends APIResource {
|
|
|
5431
5952
|
}
|
|
5432
5953
|
};
|
|
5433
5954
|
|
|
5434
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
5955
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/usage.mjs
|
|
5435
5956
|
var Usage = class extends APIResource {
|
|
5436
5957
|
/**
|
|
5437
5958
|
* Get audio speeches usage details for the organization.
|
|
@@ -5633,7 +6154,7 @@ var Usage = class extends APIResource {
|
|
|
5633
6154
|
}
|
|
5634
6155
|
};
|
|
5635
6156
|
|
|
5636
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6157
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/groups/roles.mjs
|
|
5637
6158
|
var Roles2 = class extends APIResource {
|
|
5638
6159
|
/**
|
|
5639
6160
|
* Assigns an organization role to a group within the organization.
|
|
@@ -5710,7 +6231,7 @@ var Roles2 = class extends APIResource {
|
|
|
5710
6231
|
}
|
|
5711
6232
|
};
|
|
5712
6233
|
|
|
5713
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6234
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/groups/users.mjs
|
|
5714
6235
|
var Users = class extends APIResource {
|
|
5715
6236
|
/**
|
|
5716
6237
|
* Adds a user to a group.
|
|
@@ -5787,7 +6308,7 @@ var Users = class extends APIResource {
|
|
|
5787
6308
|
}
|
|
5788
6309
|
};
|
|
5789
6310
|
|
|
5790
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6311
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/groups/groups.mjs
|
|
5791
6312
|
var Groups = class extends APIResource {
|
|
5792
6313
|
constructor() {
|
|
5793
6314
|
super(...arguments);
|
|
@@ -5884,7 +6405,7 @@ var Groups = class extends APIResource {
|
|
|
5884
6405
|
Groups.Users = Users;
|
|
5885
6406
|
Groups.Roles = Roles2;
|
|
5886
6407
|
|
|
5887
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6408
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/api-keys.mjs
|
|
5888
6409
|
var APIKeys = class extends APIResource {
|
|
5889
6410
|
/**
|
|
5890
6411
|
* Retrieves an API key in the project.
|
|
@@ -5945,7 +6466,7 @@ var APIKeys = class extends APIResource {
|
|
|
5945
6466
|
}
|
|
5946
6467
|
};
|
|
5947
6468
|
|
|
5948
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6469
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/certificates.mjs
|
|
5949
6470
|
var Certificates2 = class extends APIResource {
|
|
5950
6471
|
/**
|
|
5951
6472
|
* List certificates for this project.
|
|
@@ -6002,7 +6523,7 @@ var Certificates2 = class extends APIResource {
|
|
|
6002
6523
|
}
|
|
6003
6524
|
};
|
|
6004
6525
|
|
|
6005
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6526
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/data-retention.mjs
|
|
6006
6527
|
var DataRetention2 = class extends APIResource {
|
|
6007
6528
|
/**
|
|
6008
6529
|
* Retrieves project data retention controls.
|
|
@@ -6042,7 +6563,7 @@ var DataRetention2 = class extends APIResource {
|
|
|
6042
6563
|
}
|
|
6043
6564
|
};
|
|
6044
6565
|
|
|
6045
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6566
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/hosted-tool-permissions.mjs
|
|
6046
6567
|
var HostedToolPermissions = class extends APIResource {
|
|
6047
6568
|
/**
|
|
6048
6569
|
* Returns hosted tool permissions for a project.
|
|
@@ -6081,7 +6602,7 @@ var HostedToolPermissions = class extends APIResource {
|
|
|
6081
6602
|
}
|
|
6082
6603
|
};
|
|
6083
6604
|
|
|
6084
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6605
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/model-permissions.mjs
|
|
6085
6606
|
var ModelPermissions = class extends APIResource {
|
|
6086
6607
|
/**
|
|
6087
6608
|
* Returns model permissions for a project.
|
|
@@ -6138,7 +6659,7 @@ var ModelPermissions = class extends APIResource {
|
|
|
6138
6659
|
}
|
|
6139
6660
|
};
|
|
6140
6661
|
|
|
6141
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6662
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/rate-limits.mjs
|
|
6142
6663
|
var RateLimits = class extends APIResource {
|
|
6143
6664
|
/**
|
|
6144
6665
|
* Returns the rate limits per model for a project.
|
|
@@ -6178,7 +6699,7 @@ var RateLimits = class extends APIResource {
|
|
|
6178
6699
|
}
|
|
6179
6700
|
};
|
|
6180
6701
|
|
|
6181
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6702
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/roles.mjs
|
|
6182
6703
|
var Roles3 = class extends APIResource {
|
|
6183
6704
|
/**
|
|
6184
6705
|
* Creates a custom role for a project.
|
|
@@ -6279,101 +6800,7 @@ var Roles3 = class extends APIResource {
|
|
|
6279
6800
|
}
|
|
6280
6801
|
};
|
|
6281
6802
|
|
|
6282
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6283
|
-
var ServiceAccounts = class extends APIResource {
|
|
6284
|
-
/**
|
|
6285
|
-
* Creates a new service account in the project. This also returns an unredacted
|
|
6286
|
-
* API key for the service account.
|
|
6287
|
-
*
|
|
6288
|
-
* @example
|
|
6289
|
-
* ```ts
|
|
6290
|
-
* const serviceAccount =
|
|
6291
|
-
* await client.admin.organization.projects.serviceAccounts.create(
|
|
6292
|
-
* 'project_id',
|
|
6293
|
-
* { name: 'name' },
|
|
6294
|
-
* );
|
|
6295
|
-
* ```
|
|
6296
|
-
*/
|
|
6297
|
-
create(projectID, body, options) {
|
|
6298
|
-
return this._client.post(path`/organization/projects/${projectID}/service_accounts`, {
|
|
6299
|
-
body,
|
|
6300
|
-
...options,
|
|
6301
|
-
__security: { adminAPIKeyAuth: true }
|
|
6302
|
-
});
|
|
6303
|
-
}
|
|
6304
|
-
/**
|
|
6305
|
-
* Retrieves a service account in the project.
|
|
6306
|
-
*
|
|
6307
|
-
* @example
|
|
6308
|
-
* ```ts
|
|
6309
|
-
* const projectServiceAccount =
|
|
6310
|
-
* await client.admin.organization.projects.serviceAccounts.retrieve(
|
|
6311
|
-
* 'service_account_id',
|
|
6312
|
-
* { project_id: 'project_id' },
|
|
6313
|
-
* );
|
|
6314
|
-
* ```
|
|
6315
|
-
*/
|
|
6316
|
-
retrieve(serviceAccountID, params, options) {
|
|
6317
|
-
const { project_id } = params;
|
|
6318
|
-
return this._client.get(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
|
|
6319
|
-
...options,
|
|
6320
|
-
__security: { adminAPIKeyAuth: true }
|
|
6321
|
-
});
|
|
6322
|
-
}
|
|
6323
|
-
/**
|
|
6324
|
-
* Updates a service account in the project.
|
|
6325
|
-
*
|
|
6326
|
-
* @example
|
|
6327
|
-
* ```ts
|
|
6328
|
-
* const projectServiceAccount =
|
|
6329
|
-
* await client.admin.organization.projects.serviceAccounts.update(
|
|
6330
|
-
* 'service_account_id',
|
|
6331
|
-
* { project_id: 'project_id' },
|
|
6332
|
-
* );
|
|
6333
|
-
* ```
|
|
6334
|
-
*/
|
|
6335
|
-
update(serviceAccountID, params, options) {
|
|
6336
|
-
const { project_id, ...body } = params;
|
|
6337
|
-
return this._client.post(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { body, ...options, __security: { adminAPIKeyAuth: true } });
|
|
6338
|
-
}
|
|
6339
|
-
/**
|
|
6340
|
-
* Returns a list of service accounts in the project.
|
|
6341
|
-
*
|
|
6342
|
-
* @example
|
|
6343
|
-
* ```ts
|
|
6344
|
-
* // Automatically fetches more pages as needed.
|
|
6345
|
-
* for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
|
|
6346
|
-
* 'project_id',
|
|
6347
|
-
* )) {
|
|
6348
|
-
* // ...
|
|
6349
|
-
* }
|
|
6350
|
-
* ```
|
|
6351
|
-
*/
|
|
6352
|
-
list(projectID, query = {}, options) {
|
|
6353
|
-
return this._client.getAPIList(path`/organization/projects/${projectID}/service_accounts`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
|
|
6354
|
-
}
|
|
6355
|
-
/**
|
|
6356
|
-
* Deletes a service account from the project.
|
|
6357
|
-
*
|
|
6358
|
-
* Returns confirmation of service account deletion, or an error if the project is
|
|
6359
|
-
* archived (archived projects have no service accounts).
|
|
6360
|
-
*
|
|
6361
|
-
* @example
|
|
6362
|
-
* ```ts
|
|
6363
|
-
* const serviceAccount =
|
|
6364
|
-
* await client.admin.organization.projects.serviceAccounts.delete(
|
|
6365
|
-
* 'service_account_id',
|
|
6366
|
-
* { project_id: 'project_id' },
|
|
6367
|
-
* );
|
|
6368
|
-
* ```
|
|
6369
|
-
*/
|
|
6370
|
-
delete(serviceAccountID, params, options) {
|
|
6371
|
-
const { project_id } = params;
|
|
6372
|
-
return this._client.delete(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { ...options, __security: { adminAPIKeyAuth: true } });
|
|
6373
|
-
}
|
|
6374
|
-
};
|
|
6375
|
-
|
|
6376
|
-
// ../../node_modules/.pnpm/openai@6.44.0_ws@8.21.0_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs
|
|
6803
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/spend-alerts.mjs
|
|
6377
6804
|
var SpendAlerts2 = class extends APIResource {
|
|
6378
6805
|
/**
|
|
6379
6806
|
* Creates a project spend alert.
|
|
@@ -6487,7 +6914,7 @@ var SpendAlerts2 = class extends APIResource {
|
|
|
6487
6914
|
}
|
|
6488
6915
|
};
|
|
6489
6916
|
|
|
6490
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6917
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/groups/roles.mjs
|
|
6491
6918
|
var Roles4 = class extends APIResource {
|
|
6492
6919
|
/**
|
|
6493
6920
|
* Assigns a project role to a group within a project.
|
|
@@ -6567,7 +6994,7 @@ var Roles4 = class extends APIResource {
|
|
|
6567
6994
|
}
|
|
6568
6995
|
};
|
|
6569
6996
|
|
|
6570
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
6997
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/groups/groups.mjs
|
|
6571
6998
|
var Groups2 = class extends APIResource {
|
|
6572
6999
|
constructor() {
|
|
6573
7000
|
super(...arguments);
|
|
@@ -6650,7 +7077,126 @@ var Groups2 = class extends APIResource {
|
|
|
6650
7077
|
};
|
|
6651
7078
|
Groups2.Roles = Roles4;
|
|
6652
7079
|
|
|
6653
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7080
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/service-accounts/api-keys.mjs
|
|
7081
|
+
var APIKeys2 = class extends APIResource {
|
|
7082
|
+
/**
|
|
7083
|
+
* Creates an API key for a service account in the project.
|
|
7084
|
+
*
|
|
7085
|
+
* @example
|
|
7086
|
+
* ```ts
|
|
7087
|
+
* const apiKey =
|
|
7088
|
+
* await client.admin.organization.projects.serviceAccounts.apiKeys.create(
|
|
7089
|
+
* 'service_account_id',
|
|
7090
|
+
* { project_id: 'project_id' },
|
|
7091
|
+
* );
|
|
7092
|
+
* ```
|
|
7093
|
+
*/
|
|
7094
|
+
create(serviceAccountID, params, options) {
|
|
7095
|
+
const { project_id, ...body } = params;
|
|
7096
|
+
return this._client.post(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}/api_keys`, { body, ...options, __security: { adminAPIKeyAuth: true } });
|
|
7097
|
+
}
|
|
7098
|
+
};
|
|
7099
|
+
|
|
7100
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/service-accounts/service-accounts.mjs
|
|
7101
|
+
var ServiceAccounts = class extends APIResource {
|
|
7102
|
+
constructor() {
|
|
7103
|
+
super(...arguments);
|
|
7104
|
+
this.apiKeys = new APIKeys2(this._client);
|
|
7105
|
+
}
|
|
7106
|
+
/**
|
|
7107
|
+
* Creates a new service account in the project. By default, this also returns an
|
|
7108
|
+
* unredacted API key for the service account.
|
|
7109
|
+
*
|
|
7110
|
+
* @example
|
|
7111
|
+
* ```ts
|
|
7112
|
+
* const serviceAccount =
|
|
7113
|
+
* await client.admin.organization.projects.serviceAccounts.create(
|
|
7114
|
+
* 'project_id',
|
|
7115
|
+
* { name: 'name' },
|
|
7116
|
+
* );
|
|
7117
|
+
* ```
|
|
7118
|
+
*/
|
|
7119
|
+
create(projectID, body, options) {
|
|
7120
|
+
return this._client.post(path`/organization/projects/${projectID}/service_accounts`, {
|
|
7121
|
+
body,
|
|
7122
|
+
...options,
|
|
7123
|
+
__security: { adminAPIKeyAuth: true }
|
|
7124
|
+
});
|
|
7125
|
+
}
|
|
7126
|
+
/**
|
|
7127
|
+
* Retrieves a service account in the project.
|
|
7128
|
+
*
|
|
7129
|
+
* @example
|
|
7130
|
+
* ```ts
|
|
7131
|
+
* const projectServiceAccount =
|
|
7132
|
+
* await client.admin.organization.projects.serviceAccounts.retrieve(
|
|
7133
|
+
* 'service_account_id',
|
|
7134
|
+
* { project_id: 'project_id' },
|
|
7135
|
+
* );
|
|
7136
|
+
* ```
|
|
7137
|
+
*/
|
|
7138
|
+
retrieve(serviceAccountID, params, options) {
|
|
7139
|
+
const { project_id } = params;
|
|
7140
|
+
return this._client.get(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, {
|
|
7141
|
+
...options,
|
|
7142
|
+
__security: { adminAPIKeyAuth: true }
|
|
7143
|
+
});
|
|
7144
|
+
}
|
|
7145
|
+
/**
|
|
7146
|
+
* Updates a service account in the project.
|
|
7147
|
+
*
|
|
7148
|
+
* @example
|
|
7149
|
+
* ```ts
|
|
7150
|
+
* const projectServiceAccount =
|
|
7151
|
+
* await client.admin.organization.projects.serviceAccounts.update(
|
|
7152
|
+
* 'service_account_id',
|
|
7153
|
+
* { project_id: 'project_id' },
|
|
7154
|
+
* );
|
|
7155
|
+
* ```
|
|
7156
|
+
*/
|
|
7157
|
+
update(serviceAccountID, params, options) {
|
|
7158
|
+
const { project_id, ...body } = params;
|
|
7159
|
+
return this._client.post(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { body, ...options, __security: { adminAPIKeyAuth: true } });
|
|
7160
|
+
}
|
|
7161
|
+
/**
|
|
7162
|
+
* Returns a list of service accounts in the project.
|
|
7163
|
+
*
|
|
7164
|
+
* @example
|
|
7165
|
+
* ```ts
|
|
7166
|
+
* // Automatically fetches more pages as needed.
|
|
7167
|
+
* for await (const projectServiceAccount of client.admin.organization.projects.serviceAccounts.list(
|
|
7168
|
+
* 'project_id',
|
|
7169
|
+
* )) {
|
|
7170
|
+
* // ...
|
|
7171
|
+
* }
|
|
7172
|
+
* ```
|
|
7173
|
+
*/
|
|
7174
|
+
list(projectID, query = {}, options) {
|
|
7175
|
+
return this._client.getAPIList(path`/organization/projects/${projectID}/service_accounts`, ConversationCursorPage, { query, ...options, __security: { adminAPIKeyAuth: true } });
|
|
7176
|
+
}
|
|
7177
|
+
/**
|
|
7178
|
+
* Deletes a service account from the project.
|
|
7179
|
+
*
|
|
7180
|
+
* Returns confirmation of service account deletion, or an error if the project is
|
|
7181
|
+
* archived (archived projects have no service accounts).
|
|
7182
|
+
*
|
|
7183
|
+
* @example
|
|
7184
|
+
* ```ts
|
|
7185
|
+
* const serviceAccount =
|
|
7186
|
+
* await client.admin.organization.projects.serviceAccounts.delete(
|
|
7187
|
+
* 'service_account_id',
|
|
7188
|
+
* { project_id: 'project_id' },
|
|
7189
|
+
* );
|
|
7190
|
+
* ```
|
|
7191
|
+
*/
|
|
7192
|
+
delete(serviceAccountID, params, options) {
|
|
7193
|
+
const { project_id } = params;
|
|
7194
|
+
return this._client.delete(path`/organization/projects/${project_id}/service_accounts/${serviceAccountID}`, { ...options, __security: { adminAPIKeyAuth: true } });
|
|
7195
|
+
}
|
|
7196
|
+
};
|
|
7197
|
+
ServiceAccounts.APIKeys = APIKeys2;
|
|
7198
|
+
|
|
7199
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/users/roles.mjs
|
|
6654
7200
|
var Roles5 = class extends APIResource {
|
|
6655
7201
|
/**
|
|
6656
7202
|
* Assigns a project role to a user within a project.
|
|
@@ -6730,7 +7276,7 @@ var Roles5 = class extends APIResource {
|
|
|
6730
7276
|
}
|
|
6731
7277
|
};
|
|
6732
7278
|
|
|
6733
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7279
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/users/users.mjs
|
|
6734
7280
|
var Users2 = class extends APIResource {
|
|
6735
7281
|
constructor() {
|
|
6736
7282
|
super(...arguments);
|
|
@@ -6836,7 +7382,7 @@ var Users2 = class extends APIResource {
|
|
|
6836
7382
|
};
|
|
6837
7383
|
Users2.Roles = Roles5;
|
|
6838
7384
|
|
|
6839
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7385
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/projects/projects.mjs
|
|
6840
7386
|
var Projects = class extends APIResource {
|
|
6841
7387
|
constructor() {
|
|
6842
7388
|
super(...arguments);
|
|
@@ -6955,7 +7501,7 @@ Projects.DataRetention = DataRetention2;
|
|
|
6955
7501
|
Projects.SpendAlerts = SpendAlerts2;
|
|
6956
7502
|
Projects.Certificates = Certificates2;
|
|
6957
7503
|
|
|
6958
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7504
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/users/roles.mjs
|
|
6959
7505
|
var Roles6 = class extends APIResource {
|
|
6960
7506
|
/**
|
|
6961
7507
|
* Assigns an organization role to a user within the organization.
|
|
@@ -7032,7 +7578,7 @@ var Roles6 = class extends APIResource {
|
|
|
7032
7578
|
}
|
|
7033
7579
|
};
|
|
7034
7580
|
|
|
7035
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7581
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/users/users.mjs
|
|
7036
7582
|
var Users3 = class extends APIResource {
|
|
7037
7583
|
constructor() {
|
|
7038
7584
|
super(...arguments);
|
|
@@ -7106,7 +7652,7 @@ var Users3 = class extends APIResource {
|
|
|
7106
7652
|
};
|
|
7107
7653
|
Users3.Roles = Roles6;
|
|
7108
7654
|
|
|
7109
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7655
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/organization/organization.mjs
|
|
7110
7656
|
var Organization = class extends APIResource {
|
|
7111
7657
|
constructor() {
|
|
7112
7658
|
super(...arguments);
|
|
@@ -7135,7 +7681,7 @@ Organization.SpendAlerts = SpendAlerts;
|
|
|
7135
7681
|
Organization.Certificates = Certificates;
|
|
7136
7682
|
Organization.Projects = Projects;
|
|
7137
7683
|
|
|
7138
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7684
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/admin/admin.mjs
|
|
7139
7685
|
var Admin = class extends APIResource {
|
|
7140
7686
|
constructor() {
|
|
7141
7687
|
super(...arguments);
|
|
@@ -7144,70 +7690,7 @@ var Admin = class extends APIResource {
|
|
|
7144
7690
|
};
|
|
7145
7691
|
Admin.Organization = Organization;
|
|
7146
7692
|
|
|
7147
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7148
|
-
var brand_privateNullableHeaders = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
|
|
7149
|
-
function* iterateHeaders(headers) {
|
|
7150
|
-
if (!headers)
|
|
7151
|
-
return;
|
|
7152
|
-
if (brand_privateNullableHeaders in headers) {
|
|
7153
|
-
const { values, nulls } = headers;
|
|
7154
|
-
yield* values.entries();
|
|
7155
|
-
for (const name of nulls) {
|
|
7156
|
-
yield [name, null];
|
|
7157
|
-
}
|
|
7158
|
-
return;
|
|
7159
|
-
}
|
|
7160
|
-
let shouldClear = false;
|
|
7161
|
-
let iter;
|
|
7162
|
-
if (headers instanceof Headers) {
|
|
7163
|
-
iter = headers.entries();
|
|
7164
|
-
} else if (isReadonlyArray(headers)) {
|
|
7165
|
-
iter = headers;
|
|
7166
|
-
} else {
|
|
7167
|
-
shouldClear = true;
|
|
7168
|
-
iter = Object.entries(headers ?? {});
|
|
7169
|
-
}
|
|
7170
|
-
for (let row of iter) {
|
|
7171
|
-
const name = row[0];
|
|
7172
|
-
if (typeof name !== "string")
|
|
7173
|
-
throw new TypeError("expected header name to be a string");
|
|
7174
|
-
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
|
|
7175
|
-
let didClear = false;
|
|
7176
|
-
for (const value of values) {
|
|
7177
|
-
if (value === void 0)
|
|
7178
|
-
continue;
|
|
7179
|
-
if (shouldClear && !didClear) {
|
|
7180
|
-
didClear = true;
|
|
7181
|
-
yield [name, null];
|
|
7182
|
-
}
|
|
7183
|
-
yield [name, value];
|
|
7184
|
-
}
|
|
7185
|
-
}
|
|
7186
|
-
}
|
|
7187
|
-
var buildHeaders = (newHeaders) => {
|
|
7188
|
-
const targetHeaders = new Headers();
|
|
7189
|
-
const nullHeaders = /* @__PURE__ */ new Set();
|
|
7190
|
-
for (const headers of newHeaders) {
|
|
7191
|
-
const seenHeaders = /* @__PURE__ */ new Set();
|
|
7192
|
-
for (const [name, value] of iterateHeaders(headers)) {
|
|
7193
|
-
const lowerName = name.toLowerCase();
|
|
7194
|
-
if (!seenHeaders.has(lowerName)) {
|
|
7195
|
-
targetHeaders.delete(name);
|
|
7196
|
-
seenHeaders.add(lowerName);
|
|
7197
|
-
}
|
|
7198
|
-
if (value === null) {
|
|
7199
|
-
targetHeaders.delete(name);
|
|
7200
|
-
nullHeaders.add(lowerName);
|
|
7201
|
-
} else {
|
|
7202
|
-
targetHeaders.append(name, value);
|
|
7203
|
-
nullHeaders.delete(lowerName);
|
|
7204
|
-
}
|
|
7205
|
-
}
|
|
7206
|
-
}
|
|
7207
|
-
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
7208
|
-
};
|
|
7209
|
-
|
|
7210
|
-
// ../../node_modules/.pnpm/openai@6.44.0_ws@8.21.0_zod@4.4.3/node_modules/openai/resources/audio/speech.mjs
|
|
7693
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/audio/speech.mjs
|
|
7211
7694
|
var Speech = class extends APIResource {
|
|
7212
7695
|
/**
|
|
7213
7696
|
* Generates audio from the input text.
|
|
@@ -7237,7 +7720,7 @@ var Speech = class extends APIResource {
|
|
|
7237
7720
|
}
|
|
7238
7721
|
};
|
|
7239
7722
|
|
|
7240
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7723
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/audio/transcriptions.mjs
|
|
7241
7724
|
var Transcriptions = class extends APIResource {
|
|
7242
7725
|
create(body, options) {
|
|
7243
7726
|
return this._client.post("/audio/transcriptions", multipartFormRequestOptions({
|
|
@@ -7250,14 +7733,14 @@ var Transcriptions = class extends APIResource {
|
|
|
7250
7733
|
}
|
|
7251
7734
|
};
|
|
7252
7735
|
|
|
7253
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7736
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/audio/translations.mjs
|
|
7254
7737
|
var Translations = class extends APIResource {
|
|
7255
7738
|
create(body, options) {
|
|
7256
7739
|
return this._client.post("/audio/translations", multipartFormRequestOptions({ body, ...options, __metadata: { model: body.model }, __security: { bearerAuth: true } }, this._client));
|
|
7257
7740
|
}
|
|
7258
7741
|
};
|
|
7259
7742
|
|
|
7260
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7743
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/audio/audio.mjs
|
|
7261
7744
|
var Audio = class extends APIResource {
|
|
7262
7745
|
constructor() {
|
|
7263
7746
|
super(...arguments);
|
|
@@ -7270,7 +7753,7 @@ Audio.Transcriptions = Transcriptions;
|
|
|
7270
7753
|
Audio.Translations = Translations;
|
|
7271
7754
|
Audio.Speech = Speech;
|
|
7272
7755
|
|
|
7273
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7756
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/batches.mjs
|
|
7274
7757
|
var Batches = class extends APIResource {
|
|
7275
7758
|
/**
|
|
7276
7759
|
* Creates and executes a batch from an uploaded file of requests
|
|
@@ -7307,7 +7790,7 @@ var Batches = class extends APIResource {
|
|
|
7307
7790
|
}
|
|
7308
7791
|
};
|
|
7309
7792
|
|
|
7310
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7793
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/assistants.mjs
|
|
7311
7794
|
var Assistants = class extends APIResource {
|
|
7312
7795
|
/**
|
|
7313
7796
|
* Create an assistant with a model and instructions.
|
|
@@ -7374,7 +7857,7 @@ var Assistants = class extends APIResource {
|
|
|
7374
7857
|
}
|
|
7375
7858
|
};
|
|
7376
7859
|
|
|
7377
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7860
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/realtime/sessions.mjs
|
|
7378
7861
|
var Sessions = class extends APIResource {
|
|
7379
7862
|
/**
|
|
7380
7863
|
* Create an ephemeral API token for use in client-side applications with the
|
|
@@ -7401,7 +7884,7 @@ var Sessions = class extends APIResource {
|
|
|
7401
7884
|
}
|
|
7402
7885
|
};
|
|
7403
7886
|
|
|
7404
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7887
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/realtime/transcription-sessions.mjs
|
|
7405
7888
|
var TranscriptionSessions = class extends APIResource {
|
|
7406
7889
|
/**
|
|
7407
7890
|
* Create an ephemeral API token for use in client-side applications with the
|
|
@@ -7428,7 +7911,7 @@ var TranscriptionSessions = class extends APIResource {
|
|
|
7428
7911
|
}
|
|
7429
7912
|
};
|
|
7430
7913
|
|
|
7431
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7914
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/realtime/realtime.mjs
|
|
7432
7915
|
var Realtime = class extends APIResource {
|
|
7433
7916
|
constructor() {
|
|
7434
7917
|
super(...arguments);
|
|
@@ -7439,7 +7922,7 @@ var Realtime = class extends APIResource {
|
|
|
7439
7922
|
Realtime.Sessions = Sessions;
|
|
7440
7923
|
Realtime.TranscriptionSessions = TranscriptionSessions;
|
|
7441
7924
|
|
|
7442
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7925
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/chatkit/sessions.mjs
|
|
7443
7926
|
var Sessions2 = class extends APIResource {
|
|
7444
7927
|
/**
|
|
7445
7928
|
* Create a ChatKit session.
|
|
@@ -7481,7 +7964,7 @@ var Sessions2 = class extends APIResource {
|
|
|
7481
7964
|
}
|
|
7482
7965
|
};
|
|
7483
7966
|
|
|
7484
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
7967
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/chatkit/threads.mjs
|
|
7485
7968
|
var Threads = class extends APIResource {
|
|
7486
7969
|
/**
|
|
7487
7970
|
* Retrieve a ChatKit thread by its identifier.
|
|
@@ -7558,7 +8041,7 @@ var Threads = class extends APIResource {
|
|
|
7558
8041
|
}
|
|
7559
8042
|
};
|
|
7560
8043
|
|
|
7561
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8044
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/chatkit/chatkit.mjs
|
|
7562
8045
|
var ChatKit = class extends APIResource {
|
|
7563
8046
|
constructor() {
|
|
7564
8047
|
super(...arguments);
|
|
@@ -7566,10 +8049,176 @@ var ChatKit = class extends APIResource {
|
|
|
7566
8049
|
this.threads = new Threads(this._client);
|
|
7567
8050
|
}
|
|
7568
8051
|
};
|
|
7569
|
-
ChatKit.Sessions = Sessions2;
|
|
7570
|
-
ChatKit.Threads = Threads;
|
|
8052
|
+
ChatKit.Sessions = Sessions2;
|
|
8053
|
+
ChatKit.Threads = Threads;
|
|
8054
|
+
|
|
8055
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/responses/input-items.mjs
|
|
8056
|
+
var InputItems = class extends APIResource {
|
|
8057
|
+
/**
|
|
8058
|
+
* Returns a list of input items for a given response.
|
|
8059
|
+
*
|
|
8060
|
+
* @example
|
|
8061
|
+
* ```ts
|
|
8062
|
+
* // Automatically fetches more pages as needed.
|
|
8063
|
+
* for await (const betaResponseItem of client.beta.responses.inputItems.list(
|
|
8064
|
+
* 'response_id',
|
|
8065
|
+
* )) {
|
|
8066
|
+
* // ...
|
|
8067
|
+
* }
|
|
8068
|
+
* ```
|
|
8069
|
+
*/
|
|
8070
|
+
list(responseID, params = {}, options) {
|
|
8071
|
+
const { betas, ...query } = params ?? {};
|
|
8072
|
+
return this._client.getAPIList(path`/responses/${responseID}/input_items?beta=true`, CursorPage, {
|
|
8073
|
+
query,
|
|
8074
|
+
...options,
|
|
8075
|
+
headers: buildHeaders([
|
|
8076
|
+
{ ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8077
|
+
options?.headers
|
|
8078
|
+
]),
|
|
8079
|
+
__security: { bearerAuth: true }
|
|
8080
|
+
});
|
|
8081
|
+
}
|
|
8082
|
+
};
|
|
8083
|
+
|
|
8084
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/responses/input-tokens.mjs
|
|
8085
|
+
var InputTokens = class extends APIResource {
|
|
8086
|
+
/**
|
|
8087
|
+
* Returns input token counts of the request.
|
|
8088
|
+
*
|
|
8089
|
+
* Returns an object with `object` set to `response.input_tokens` and an
|
|
8090
|
+
* `input_tokens` count.
|
|
8091
|
+
*
|
|
8092
|
+
* @example
|
|
8093
|
+
* ```ts
|
|
8094
|
+
* const response =
|
|
8095
|
+
* await client.beta.responses.inputTokens.count();
|
|
8096
|
+
* ```
|
|
8097
|
+
*/
|
|
8098
|
+
count(params = {}, options) {
|
|
8099
|
+
const { betas, ...body } = params ?? {};
|
|
8100
|
+
return this._client.post("/responses/input_tokens?beta=true", {
|
|
8101
|
+
body,
|
|
8102
|
+
...options,
|
|
8103
|
+
headers: buildHeaders([
|
|
8104
|
+
{ ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8105
|
+
options?.headers
|
|
8106
|
+
]),
|
|
8107
|
+
__security: { bearerAuth: true }
|
|
8108
|
+
});
|
|
8109
|
+
}
|
|
8110
|
+
};
|
|
8111
|
+
|
|
8112
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/responses/responses.mjs
|
|
8113
|
+
var Responses = class extends APIResource {
|
|
8114
|
+
constructor() {
|
|
8115
|
+
super(...arguments);
|
|
8116
|
+
this.inputItems = new InputItems(this._client);
|
|
8117
|
+
this.inputTokens = new InputTokens(this._client);
|
|
8118
|
+
}
|
|
8119
|
+
create(params, options) {
|
|
8120
|
+
const { betas, ...body } = params;
|
|
8121
|
+
return this._client.post("/responses?beta=true", {
|
|
8122
|
+
body,
|
|
8123
|
+
...options,
|
|
8124
|
+
headers: buildHeaders([
|
|
8125
|
+
{ ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8126
|
+
options?.headers
|
|
8127
|
+
]),
|
|
8128
|
+
stream: params.stream ?? false,
|
|
8129
|
+
__security: { bearerAuth: true }
|
|
8130
|
+
});
|
|
8131
|
+
}
|
|
8132
|
+
retrieve(responseID, params = {}, options) {
|
|
8133
|
+
const { betas, ...query } = params ?? {};
|
|
8134
|
+
return this._client.get(path`/responses/${responseID}?beta=true`, {
|
|
8135
|
+
query,
|
|
8136
|
+
...options,
|
|
8137
|
+
headers: buildHeaders([
|
|
8138
|
+
{ ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8139
|
+
options?.headers
|
|
8140
|
+
]),
|
|
8141
|
+
stream: params?.stream ?? false,
|
|
8142
|
+
__security: { bearerAuth: true }
|
|
8143
|
+
});
|
|
8144
|
+
}
|
|
8145
|
+
/**
|
|
8146
|
+
* Deletes a model response with the given ID.
|
|
8147
|
+
*
|
|
8148
|
+
* @example
|
|
8149
|
+
* ```ts
|
|
8150
|
+
* await client.beta.responses.delete(
|
|
8151
|
+
* 'resp_677efb5139a88190b512bc3fef8e535d',
|
|
8152
|
+
* );
|
|
8153
|
+
* ```
|
|
8154
|
+
*/
|
|
8155
|
+
delete(responseID, params = {}, options) {
|
|
8156
|
+
const { betas } = params ?? {};
|
|
8157
|
+
return this._client.delete(path`/responses/${responseID}?beta=true`, {
|
|
8158
|
+
...options,
|
|
8159
|
+
headers: buildHeaders([
|
|
8160
|
+
{ Accept: "*/*", ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8161
|
+
options?.headers
|
|
8162
|
+
]),
|
|
8163
|
+
__security: { bearerAuth: true }
|
|
8164
|
+
});
|
|
8165
|
+
}
|
|
8166
|
+
/**
|
|
8167
|
+
* Cancels a model response with the given ID. Only responses created with the
|
|
8168
|
+
* `background` parameter set to `true` can be cancelled.
|
|
8169
|
+
* [Learn more](https://platform.openai.com/docs/guides/background).
|
|
8170
|
+
*
|
|
8171
|
+
* @example
|
|
8172
|
+
* ```ts
|
|
8173
|
+
* const betaResponse = await client.beta.responses.cancel(
|
|
8174
|
+
* 'resp_677efb5139a88190b512bc3fef8e535d',
|
|
8175
|
+
* );
|
|
8176
|
+
* ```
|
|
8177
|
+
*/
|
|
8178
|
+
cancel(responseID, params = {}, options) {
|
|
8179
|
+
const { betas } = params ?? {};
|
|
8180
|
+
return this._client.post(path`/responses/${responseID}/cancel?beta=true`, {
|
|
8181
|
+
...options,
|
|
8182
|
+
headers: buildHeaders([
|
|
8183
|
+
{ ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8184
|
+
options?.headers
|
|
8185
|
+
]),
|
|
8186
|
+
__security: { bearerAuth: true }
|
|
8187
|
+
});
|
|
8188
|
+
}
|
|
8189
|
+
/**
|
|
8190
|
+
* Compact a conversation. Returns a compacted response object.
|
|
8191
|
+
*
|
|
8192
|
+
* Learn when and how to compact long-running conversations in the
|
|
8193
|
+
* [conversation state guide](https://platform.openai.com/docs/guides/conversation-state#managing-the-context-window).
|
|
8194
|
+
* For ZDR-compatible compaction details, see
|
|
8195
|
+
* [Compaction (advanced)](https://platform.openai.com/docs/guides/conversation-state#compaction-advanced).
|
|
8196
|
+
*
|
|
8197
|
+
* @example
|
|
8198
|
+
* ```ts
|
|
8199
|
+
* const betaCompactedResponse =
|
|
8200
|
+
* await client.beta.responses.compact({
|
|
8201
|
+
* model: 'gpt-5.6-sol',
|
|
8202
|
+
* });
|
|
8203
|
+
* ```
|
|
8204
|
+
*/
|
|
8205
|
+
compact(params, options) {
|
|
8206
|
+
const { betas, ...body } = params;
|
|
8207
|
+
return this._client.post("/responses/compact?beta=true", {
|
|
8208
|
+
body,
|
|
8209
|
+
...options,
|
|
8210
|
+
headers: buildHeaders([
|
|
8211
|
+
{ ...betas?.toString() != null ? { "openai-beta": betas?.toString() } : void 0 },
|
|
8212
|
+
options?.headers
|
|
8213
|
+
]),
|
|
8214
|
+
__security: { bearerAuth: true }
|
|
8215
|
+
});
|
|
8216
|
+
}
|
|
8217
|
+
};
|
|
8218
|
+
Responses.InputItems = InputItems;
|
|
8219
|
+
Responses.InputTokens = InputTokens;
|
|
7571
8220
|
|
|
7572
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8221
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/threads/messages.mjs
|
|
7573
8222
|
var Messages2 = class extends APIResource {
|
|
7574
8223
|
/**
|
|
7575
8224
|
* Create a message.
|
|
@@ -7639,7 +8288,7 @@ var Messages2 = class extends APIResource {
|
|
|
7639
8288
|
}
|
|
7640
8289
|
};
|
|
7641
8290
|
|
|
7642
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8291
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/threads/runs/steps.mjs
|
|
7643
8292
|
var Steps = class extends APIResource {
|
|
7644
8293
|
/**
|
|
7645
8294
|
* Retrieves a run step.
|
|
@@ -7671,7 +8320,7 @@ var Steps = class extends APIResource {
|
|
|
7671
8320
|
}
|
|
7672
8321
|
};
|
|
7673
8322
|
|
|
7674
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8323
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/base64.mjs
|
|
7675
8324
|
var toFloat32Array = (base64Str) => {
|
|
7676
8325
|
if (typeof Buffer !== "undefined") {
|
|
7677
8326
|
const buf = Buffer.from(base64Str, "base64");
|
|
@@ -7687,7 +8336,7 @@ var toFloat32Array = (base64Str) => {
|
|
|
7687
8336
|
}
|
|
7688
8337
|
};
|
|
7689
8338
|
|
|
7690
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8339
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/utils/env.mjs
|
|
7691
8340
|
var readEnv = (env) => {
|
|
7692
8341
|
if (typeof globalThis.process !== "undefined") {
|
|
7693
8342
|
return globalThis.process.env?.[env]?.trim() || void 0;
|
|
@@ -7698,7 +8347,7 @@ var readEnv = (env) => {
|
|
|
7698
8347
|
return void 0;
|
|
7699
8348
|
};
|
|
7700
8349
|
|
|
7701
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8350
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/AssistantStream.mjs
|
|
7702
8351
|
var _AssistantStream_instances;
|
|
7703
8352
|
var _a;
|
|
7704
8353
|
var _AssistantStream_events;
|
|
@@ -7744,11 +8393,12 @@ var AssistantStream = class extends EventStream {
|
|
|
7744
8393
|
const readQueue = [];
|
|
7745
8394
|
let done = false;
|
|
7746
8395
|
this.on("event", (event) => {
|
|
8396
|
+
const eventCopy = structuredClone(event);
|
|
7747
8397
|
const reader = readQueue.shift();
|
|
7748
8398
|
if (reader) {
|
|
7749
|
-
reader.resolve(
|
|
8399
|
+
reader.resolve(eventCopy);
|
|
7750
8400
|
} else {
|
|
7751
|
-
pushQueue.push(
|
|
8401
|
+
pushQueue.push(eventCopy);
|
|
7752
8402
|
}
|
|
7753
8403
|
});
|
|
7754
8404
|
this.on("end", () => {
|
|
@@ -7795,12 +8445,7 @@ var AssistantStream = class extends EventStream {
|
|
|
7795
8445
|
return runner;
|
|
7796
8446
|
}
|
|
7797
8447
|
async _fromReadableStream(readableStream, options) {
|
|
7798
|
-
|
|
7799
|
-
if (signal) {
|
|
7800
|
-
if (signal.aborted)
|
|
7801
|
-
this.controller.abort();
|
|
7802
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
7803
|
-
}
|
|
8448
|
+
this._listenForAbort(options?.signal);
|
|
7804
8449
|
this._connected();
|
|
7805
8450
|
const stream = Stream.fromReadableStream(readableStream, this.controller);
|
|
7806
8451
|
for await (const event of stream) {
|
|
@@ -7824,12 +8469,7 @@ var AssistantStream = class extends EventStream {
|
|
|
7824
8469
|
return runner;
|
|
7825
8470
|
}
|
|
7826
8471
|
async _createToolAssistantStream(run2, runId, params, options) {
|
|
7827
|
-
|
|
7828
|
-
if (signal) {
|
|
7829
|
-
if (signal.aborted)
|
|
7830
|
-
this.controller.abort();
|
|
7831
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
7832
|
-
}
|
|
8472
|
+
this._listenForAbort(options?.signal);
|
|
7833
8473
|
const body = { ...params, stream: true };
|
|
7834
8474
|
const stream = await run2.submitToolOutputs(runId, body, {
|
|
7835
8475
|
...options,
|
|
@@ -7887,12 +8527,7 @@ var AssistantStream = class extends EventStream {
|
|
|
7887
8527
|
return __classPrivateFieldGet(this, _AssistantStream_finalRun, "f");
|
|
7888
8528
|
}
|
|
7889
8529
|
async _createThreadAssistantStream(thread, params, options) {
|
|
7890
|
-
|
|
7891
|
-
if (signal) {
|
|
7892
|
-
if (signal.aborted)
|
|
7893
|
-
this.controller.abort();
|
|
7894
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
7895
|
-
}
|
|
8530
|
+
this._listenForAbort(options?.signal);
|
|
7896
8531
|
const body = { ...params, stream: true };
|
|
7897
8532
|
const stream = await thread.createAndRun(body, { ...options, signal: this.controller.signal });
|
|
7898
8533
|
this._connected();
|
|
@@ -7905,12 +8540,7 @@ var AssistantStream = class extends EventStream {
|
|
|
7905
8540
|
return this._addRun(__classPrivateFieldGet(this, _AssistantStream_instances, "m", _AssistantStream_endRequest).call(this));
|
|
7906
8541
|
}
|
|
7907
8542
|
async _createAssistantStream(run2, threadId, params, options) {
|
|
7908
|
-
|
|
7909
|
-
if (signal) {
|
|
7910
|
-
if (signal.aborted)
|
|
7911
|
-
this.controller.abort();
|
|
7912
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
7913
|
-
}
|
|
8543
|
+
this._listenForAbort(options?.signal);
|
|
7914
8544
|
const body = { ...params, stream: true };
|
|
7915
8545
|
const stream = await run2.create(threadId, body, { ...options, signal: this.controller.signal });
|
|
7916
8546
|
this._connected();
|
|
@@ -7962,7 +8592,7 @@ var AssistantStream = class extends EventStream {
|
|
|
7962
8592
|
}
|
|
7963
8593
|
const accEntry = accValue[index];
|
|
7964
8594
|
if (accEntry == null) {
|
|
7965
|
-
accValue
|
|
8595
|
+
accValue[index] = deltaEntry;
|
|
7966
8596
|
} else {
|
|
7967
8597
|
accValue[index] = this.accumulateDelta(accEntry, deltaEntry);
|
|
7968
8598
|
}
|
|
@@ -8237,7 +8867,7 @@ _a = AssistantStream, _AssistantStream_addEvent = function _AssistantStream_addE
|
|
|
8237
8867
|
function assertNever2(_x) {
|
|
8238
8868
|
}
|
|
8239
8869
|
|
|
8240
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
8870
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/threads/runs/runs.mjs
|
|
8241
8871
|
var Runs = class extends APIResource {
|
|
8242
8872
|
constructor() {
|
|
8243
8873
|
super(...arguments);
|
|
@@ -8410,7 +9040,7 @@ var Runs = class extends APIResource {
|
|
|
8410
9040
|
};
|
|
8411
9041
|
Runs.Steps = Steps;
|
|
8412
9042
|
|
|
8413
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9043
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/threads/threads.mjs
|
|
8414
9044
|
var Threads2 = class extends APIResource {
|
|
8415
9045
|
constructor() {
|
|
8416
9046
|
super(...arguments);
|
|
@@ -8496,22 +9126,24 @@ var Threads2 = class extends APIResource {
|
|
|
8496
9126
|
Threads2.Runs = Runs;
|
|
8497
9127
|
Threads2.Messages = Messages2;
|
|
8498
9128
|
|
|
8499
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9129
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/beta/beta.mjs
|
|
8500
9130
|
var Beta = class extends APIResource {
|
|
8501
9131
|
constructor() {
|
|
8502
9132
|
super(...arguments);
|
|
8503
9133
|
this.realtime = new Realtime(this._client);
|
|
9134
|
+
this.responses = new Responses(this._client);
|
|
8504
9135
|
this.chatkit = new ChatKit(this._client);
|
|
8505
9136
|
this.assistants = new Assistants(this._client);
|
|
8506
9137
|
this.threads = new Threads2(this._client);
|
|
8507
9138
|
}
|
|
8508
9139
|
};
|
|
8509
9140
|
Beta.Realtime = Realtime;
|
|
9141
|
+
Beta.Responses = Responses;
|
|
8510
9142
|
Beta.ChatKit = ChatKit;
|
|
8511
9143
|
Beta.Assistants = Assistants;
|
|
8512
9144
|
Beta.Threads = Threads2;
|
|
8513
9145
|
|
|
8514
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9146
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/completions.mjs
|
|
8515
9147
|
var Completions2 = class extends APIResource {
|
|
8516
9148
|
create(body, options) {
|
|
8517
9149
|
return this._client.post("/completions", {
|
|
@@ -8523,7 +9155,7 @@ var Completions2 = class extends APIResource {
|
|
|
8523
9155
|
}
|
|
8524
9156
|
};
|
|
8525
9157
|
|
|
8526
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9158
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/containers/files/content.mjs
|
|
8527
9159
|
var Content = class extends APIResource {
|
|
8528
9160
|
/**
|
|
8529
9161
|
* Retrieve Container File Content
|
|
@@ -8539,7 +9171,7 @@ var Content = class extends APIResource {
|
|
|
8539
9171
|
}
|
|
8540
9172
|
};
|
|
8541
9173
|
|
|
8542
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9174
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/containers/files/files.mjs
|
|
8543
9175
|
var Files = class extends APIResource {
|
|
8544
9176
|
constructor() {
|
|
8545
9177
|
super(...arguments);
|
|
@@ -8588,7 +9220,7 @@ var Files = class extends APIResource {
|
|
|
8588
9220
|
};
|
|
8589
9221
|
Files.Content = Content;
|
|
8590
9222
|
|
|
8591
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9223
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/containers/containers.mjs
|
|
8592
9224
|
var Containers = class extends APIResource {
|
|
8593
9225
|
constructor() {
|
|
8594
9226
|
super(...arguments);
|
|
@@ -8632,7 +9264,7 @@ var Containers = class extends APIResource {
|
|
|
8632
9264
|
};
|
|
8633
9265
|
Containers.Files = Files;
|
|
8634
9266
|
|
|
8635
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9267
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/conversations/items.mjs
|
|
8636
9268
|
var Items = class extends APIResource {
|
|
8637
9269
|
/**
|
|
8638
9270
|
* Create items in a conversation with the given ID.
|
|
@@ -8675,7 +9307,7 @@ var Items = class extends APIResource {
|
|
|
8675
9307
|
}
|
|
8676
9308
|
};
|
|
8677
9309
|
|
|
8678
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9310
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/conversations/conversations.mjs
|
|
8679
9311
|
var Conversations = class extends APIResource {
|
|
8680
9312
|
constructor() {
|
|
8681
9313
|
super(...arguments);
|
|
@@ -8718,7 +9350,7 @@ var Conversations = class extends APIResource {
|
|
|
8718
9350
|
};
|
|
8719
9351
|
Conversations.Items = Items;
|
|
8720
9352
|
|
|
8721
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9353
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/embeddings.mjs
|
|
8722
9354
|
var Embeddings = class extends APIResource {
|
|
8723
9355
|
/**
|
|
8724
9356
|
* Creates an embedding vector representing the input text.
|
|
@@ -8762,7 +9394,7 @@ var Embeddings = class extends APIResource {
|
|
|
8762
9394
|
}
|
|
8763
9395
|
};
|
|
8764
9396
|
|
|
8765
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9397
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/evals/runs/output-items.mjs
|
|
8766
9398
|
var OutputItems = class extends APIResource {
|
|
8767
9399
|
/**
|
|
8768
9400
|
* Get an evaluation run output item by ID.
|
|
@@ -8783,7 +9415,7 @@ var OutputItems = class extends APIResource {
|
|
|
8783
9415
|
}
|
|
8784
9416
|
};
|
|
8785
9417
|
|
|
8786
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9418
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/evals/runs/runs.mjs
|
|
8787
9419
|
var Runs2 = class extends APIResource {
|
|
8788
9420
|
constructor() {
|
|
8789
9421
|
super(...arguments);
|
|
@@ -8844,7 +9476,7 @@ var Runs2 = class extends APIResource {
|
|
|
8844
9476
|
};
|
|
8845
9477
|
Runs2.OutputItems = OutputItems;
|
|
8846
9478
|
|
|
8847
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9479
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/evals/evals.mjs
|
|
8848
9480
|
var Evals = class extends APIResource {
|
|
8849
9481
|
constructor() {
|
|
8850
9482
|
super(...arguments);
|
|
@@ -8892,7 +9524,7 @@ var Evals = class extends APIResource {
|
|
|
8892
9524
|
};
|
|
8893
9525
|
Evals.Runs = Runs2;
|
|
8894
9526
|
|
|
8895
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9527
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/files.mjs
|
|
8896
9528
|
var Files2 = class extends APIResource {
|
|
8897
9529
|
/**
|
|
8898
9530
|
* Upload a file that can be used across various endpoints. Individual files can be
|
|
@@ -8979,11 +9611,11 @@ var Files2 = class extends APIResource {
|
|
|
8979
9611
|
}
|
|
8980
9612
|
};
|
|
8981
9613
|
|
|
8982
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9614
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/methods.mjs
|
|
8983
9615
|
var Methods = class extends APIResource {
|
|
8984
9616
|
};
|
|
8985
9617
|
|
|
8986
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9618
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/alpha/graders.mjs
|
|
8987
9619
|
var Graders = class extends APIResource {
|
|
8988
9620
|
/**
|
|
8989
9621
|
* Run a grader.
|
|
@@ -9035,7 +9667,7 @@ var Graders = class extends APIResource {
|
|
|
9035
9667
|
}
|
|
9036
9668
|
};
|
|
9037
9669
|
|
|
9038
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9670
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/alpha/alpha.mjs
|
|
9039
9671
|
var Alpha = class extends APIResource {
|
|
9040
9672
|
constructor() {
|
|
9041
9673
|
super(...arguments);
|
|
@@ -9044,7 +9676,7 @@ var Alpha = class extends APIResource {
|
|
|
9044
9676
|
};
|
|
9045
9677
|
Alpha.Graders = Graders;
|
|
9046
9678
|
|
|
9047
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9679
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/checkpoints/permissions.mjs
|
|
9048
9680
|
var Permissions = class extends APIResource {
|
|
9049
9681
|
/**
|
|
9050
9682
|
* **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
|
|
@@ -9124,7 +9756,7 @@ var Permissions = class extends APIResource {
|
|
|
9124
9756
|
}
|
|
9125
9757
|
};
|
|
9126
9758
|
|
|
9127
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9759
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/checkpoints/checkpoints.mjs
|
|
9128
9760
|
var Checkpoints = class extends APIResource {
|
|
9129
9761
|
constructor() {
|
|
9130
9762
|
super(...arguments);
|
|
@@ -9133,7 +9765,7 @@ var Checkpoints = class extends APIResource {
|
|
|
9133
9765
|
};
|
|
9134
9766
|
Checkpoints.Permissions = Permissions;
|
|
9135
9767
|
|
|
9136
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9768
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/jobs/checkpoints.mjs
|
|
9137
9769
|
var Checkpoints2 = class extends APIResource {
|
|
9138
9770
|
/**
|
|
9139
9771
|
* List checkpoints for a fine-tuning job.
|
|
@@ -9153,7 +9785,7 @@ var Checkpoints2 = class extends APIResource {
|
|
|
9153
9785
|
}
|
|
9154
9786
|
};
|
|
9155
9787
|
|
|
9156
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9788
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/jobs/jobs.mjs
|
|
9157
9789
|
var Jobs = class extends APIResource {
|
|
9158
9790
|
constructor() {
|
|
9159
9791
|
super(...arguments);
|
|
@@ -9282,7 +9914,7 @@ var Jobs = class extends APIResource {
|
|
|
9282
9914
|
};
|
|
9283
9915
|
Jobs.Checkpoints = Checkpoints2;
|
|
9284
9916
|
|
|
9285
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9917
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/fine-tuning/fine-tuning.mjs
|
|
9286
9918
|
var FineTuning = class extends APIResource {
|
|
9287
9919
|
constructor() {
|
|
9288
9920
|
super(...arguments);
|
|
@@ -9297,11 +9929,11 @@ FineTuning.Jobs = Jobs;
|
|
|
9297
9929
|
FineTuning.Checkpoints = Checkpoints;
|
|
9298
9930
|
FineTuning.Alpha = Alpha;
|
|
9299
9931
|
|
|
9300
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9932
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/graders/grader-models.mjs
|
|
9301
9933
|
var GraderModels = class extends APIResource {
|
|
9302
9934
|
};
|
|
9303
9935
|
|
|
9304
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9936
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/graders/graders.mjs
|
|
9305
9937
|
var Graders2 = class extends APIResource {
|
|
9306
9938
|
constructor() {
|
|
9307
9939
|
super(...arguments);
|
|
@@ -9310,7 +9942,7 @@ var Graders2 = class extends APIResource {
|
|
|
9310
9942
|
};
|
|
9311
9943
|
Graders2.GraderModels = GraderModels;
|
|
9312
9944
|
|
|
9313
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9945
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/images.mjs
|
|
9314
9946
|
var Images = class extends APIResource {
|
|
9315
9947
|
/**
|
|
9316
9948
|
* Creates a variation of a given image. This endpoint only supports `dall-e-2`.
|
|
@@ -9338,7 +9970,7 @@ var Images = class extends APIResource {
|
|
|
9338
9970
|
}
|
|
9339
9971
|
};
|
|
9340
9972
|
|
|
9341
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9973
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/models.mjs
|
|
9342
9974
|
var Models = class extends APIResource {
|
|
9343
9975
|
/**
|
|
9344
9976
|
* Retrieves a model instance, providing basic information about the model such as
|
|
@@ -9363,7 +9995,7 @@ var Models = class extends APIResource {
|
|
|
9363
9995
|
}
|
|
9364
9996
|
};
|
|
9365
9997
|
|
|
9366
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9998
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/moderations.mjs
|
|
9367
9999
|
var Moderations = class extends APIResource {
|
|
9368
10000
|
/**
|
|
9369
10001
|
* Classifies if text and/or image inputs are potentially harmful. Learn more in
|
|
@@ -9374,7 +10006,7 @@ var Moderations = class extends APIResource {
|
|
|
9374
10006
|
}
|
|
9375
10007
|
};
|
|
9376
10008
|
|
|
9377
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10009
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/realtime/calls.mjs
|
|
9378
10010
|
var Calls = class extends APIResource {
|
|
9379
10011
|
/**
|
|
9380
10012
|
* Accept an incoming SIP call and configure the realtime session that will handle
|
|
@@ -9446,7 +10078,7 @@ var Calls = class extends APIResource {
|
|
|
9446
10078
|
}
|
|
9447
10079
|
};
|
|
9448
10080
|
|
|
9449
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10081
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/realtime/client-secrets.mjs
|
|
9450
10082
|
var ClientSecrets = class extends APIResource {
|
|
9451
10083
|
/**
|
|
9452
10084
|
* Create a Realtime client secret with an associated session configuration.
|
|
@@ -9480,7 +10112,7 @@ var ClientSecrets = class extends APIResource {
|
|
|
9480
10112
|
}
|
|
9481
10113
|
};
|
|
9482
10114
|
|
|
9483
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10115
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/realtime/realtime.mjs
|
|
9484
10116
|
var Realtime2 = class extends APIResource {
|
|
9485
10117
|
constructor() {
|
|
9486
10118
|
super(...arguments);
|
|
@@ -9491,10 +10123,10 @@ var Realtime2 = class extends APIResource {
|
|
|
9491
10123
|
Realtime2.ClientSecrets = ClientSecrets;
|
|
9492
10124
|
Realtime2.Calls = Calls;
|
|
9493
10125
|
|
|
9494
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10126
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/ResponsesParser.mjs
|
|
9495
10127
|
function maybeParseResponse(response, params) {
|
|
9496
10128
|
if (!params || !hasAutoParseableInput2(params)) {
|
|
9497
|
-
|
|
10129
|
+
const parsed = {
|
|
9498
10130
|
...response,
|
|
9499
10131
|
output_parsed: null,
|
|
9500
10132
|
output: response.output.map((item) => {
|
|
@@ -9517,15 +10149,20 @@ function maybeParseResponse(response, params) {
|
|
|
9517
10149
|
}
|
|
9518
10150
|
})
|
|
9519
10151
|
};
|
|
10152
|
+
if (needsOutputText(response, parsed)) {
|
|
10153
|
+
addOutputText(parsed);
|
|
10154
|
+
}
|
|
10155
|
+
return parsed;
|
|
9520
10156
|
}
|
|
9521
10157
|
return parseResponse(response, params);
|
|
9522
10158
|
}
|
|
9523
10159
|
function parseResponse(response, params) {
|
|
10160
|
+
const shouldParse = !response.status || response.status === "completed";
|
|
9524
10161
|
const output = response.output.map((item) => {
|
|
9525
10162
|
if (item.type === "function_call") {
|
|
9526
10163
|
return {
|
|
9527
10164
|
...item,
|
|
9528
|
-
parsed_arguments: parseToolCall2(params, item)
|
|
10165
|
+
parsed_arguments: shouldParse ? parseToolCall2(params, item) : null
|
|
9529
10166
|
};
|
|
9530
10167
|
}
|
|
9531
10168
|
if (item.type === "message") {
|
|
@@ -9533,7 +10170,7 @@ function parseResponse(response, params) {
|
|
|
9533
10170
|
if (content2.type === "output_text") {
|
|
9534
10171
|
return {
|
|
9535
10172
|
...content2,
|
|
9536
|
-
parsed: parseTextFormat(params, content2.text)
|
|
10173
|
+
parsed: shouldParse ? parseTextFormat(params, content2.text) : null
|
|
9537
10174
|
};
|
|
9538
10175
|
}
|
|
9539
10176
|
return content2;
|
|
@@ -9546,7 +10183,7 @@ function parseResponse(response, params) {
|
|
|
9546
10183
|
return item;
|
|
9547
10184
|
});
|
|
9548
10185
|
const parsed = Object.assign({}, response, { output });
|
|
9549
|
-
if (
|
|
10186
|
+
if (needsOutputText(response, parsed)) {
|
|
9550
10187
|
addOutputText(parsed);
|
|
9551
10188
|
}
|
|
9552
10189
|
Object.defineProperty(parsed, "output_parsed", {
|
|
@@ -9597,6 +10234,9 @@ function parseToolCall2(params, toolCall) {
|
|
|
9597
10234
|
parsed_arguments: isAutoParsableTool2(inputTool) ? inputTool.$parseRaw(toolCall.arguments) : inputTool?.strict ? JSON.parse(toolCall.arguments) : null
|
|
9598
10235
|
};
|
|
9599
10236
|
}
|
|
10237
|
+
function needsOutputText(response, target) {
|
|
10238
|
+
return !Object.getOwnPropertyDescriptor(response, "output_text") || target.output_text == null;
|
|
10239
|
+
}
|
|
9600
10240
|
function addOutputText(rsp) {
|
|
9601
10241
|
const texts = [];
|
|
9602
10242
|
for (const output of rsp.output) {
|
|
@@ -9612,7 +10252,396 @@ function addOutputText(rsp) {
|
|
|
9612
10252
|
rsp.output_text = texts.join("");
|
|
9613
10253
|
}
|
|
9614
10254
|
|
|
9615
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10255
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/responses/ResponseAccumulator.mjs
|
|
10256
|
+
function accumulateResponse(event, snapshot) {
|
|
10257
|
+
if (!snapshot) {
|
|
10258
|
+
if (event.type !== "response.created") {
|
|
10259
|
+
throw new OpenAIError(`When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`);
|
|
10260
|
+
}
|
|
10261
|
+
return cloneResponse(event.response);
|
|
10262
|
+
}
|
|
10263
|
+
switch (event.type) {
|
|
10264
|
+
case "response.output_item.added": {
|
|
10265
|
+
snapshot.output.push(structuredClone(event.item));
|
|
10266
|
+
if (event.item.type === "message") {
|
|
10267
|
+
addOutputText(snapshot);
|
|
10268
|
+
}
|
|
10269
|
+
break;
|
|
10270
|
+
}
|
|
10271
|
+
case "response.output_item.done": {
|
|
10272
|
+
getOutput(snapshot, event.output_index);
|
|
10273
|
+
snapshot.output[event.output_index] = structuredClone(event.item);
|
|
10274
|
+
if (event.item.type === "message") {
|
|
10275
|
+
addOutputText(snapshot);
|
|
10276
|
+
}
|
|
10277
|
+
break;
|
|
10278
|
+
}
|
|
10279
|
+
case "response.content_part.added": {
|
|
10280
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10281
|
+
const type = output.type;
|
|
10282
|
+
const part = event.part;
|
|
10283
|
+
if (type === "message" && part.type !== "reasoning_text") {
|
|
10284
|
+
output.content.push(structuredClone(part));
|
|
10285
|
+
if (part.type === "output_text") {
|
|
10286
|
+
addOutputText(snapshot);
|
|
10287
|
+
}
|
|
10288
|
+
} else if (type === "reasoning" && part.type === "reasoning_text") {
|
|
10289
|
+
if (!output.content) {
|
|
10290
|
+
output.content = [];
|
|
10291
|
+
}
|
|
10292
|
+
output.content.push(structuredClone(part));
|
|
10293
|
+
}
|
|
10294
|
+
break;
|
|
10295
|
+
}
|
|
10296
|
+
case "response.content_part.done": {
|
|
10297
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10298
|
+
const part = event.part;
|
|
10299
|
+
if (output.type === "message" && part.type !== "reasoning_text") {
|
|
10300
|
+
getContent(output.content, event.content_index);
|
|
10301
|
+
output.content[event.content_index] = structuredClone(part);
|
|
10302
|
+
if (part.type === "output_text") {
|
|
10303
|
+
addOutputText(snapshot);
|
|
10304
|
+
}
|
|
10305
|
+
} else if (output.type === "reasoning" && part.type === "reasoning_text") {
|
|
10306
|
+
const content = output.content;
|
|
10307
|
+
if (!content) {
|
|
10308
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
10309
|
+
}
|
|
10310
|
+
getContent(content, event.content_index);
|
|
10311
|
+
content[event.content_index] = structuredClone(part);
|
|
10312
|
+
}
|
|
10313
|
+
break;
|
|
10314
|
+
}
|
|
10315
|
+
case "response.output_text.delta": {
|
|
10316
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10317
|
+
if (output.type === "message") {
|
|
10318
|
+
const content = getContent(output.content, event.content_index);
|
|
10319
|
+
if (content.type !== "output_text") {
|
|
10320
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
10321
|
+
}
|
|
10322
|
+
content.text += event.delta;
|
|
10323
|
+
snapshot.output_text += event.delta;
|
|
10324
|
+
}
|
|
10325
|
+
break;
|
|
10326
|
+
}
|
|
10327
|
+
case "response.output_text.done": {
|
|
10328
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10329
|
+
if (output.type === "message") {
|
|
10330
|
+
const content = getContent(output.content, event.content_index);
|
|
10331
|
+
if (content.type !== "output_text") {
|
|
10332
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
10333
|
+
}
|
|
10334
|
+
content.text = event.text;
|
|
10335
|
+
addOutputText(snapshot);
|
|
10336
|
+
}
|
|
10337
|
+
break;
|
|
10338
|
+
}
|
|
10339
|
+
case "response.output_text.annotation.added": {
|
|
10340
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10341
|
+
if (output.type === "message") {
|
|
10342
|
+
const content = getContent(output.content, event.content_index);
|
|
10343
|
+
if (content.type !== "output_text") {
|
|
10344
|
+
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
10345
|
+
}
|
|
10346
|
+
content.annotations[event.annotation_index] = structuredClone(event.annotation);
|
|
10347
|
+
}
|
|
10348
|
+
break;
|
|
10349
|
+
}
|
|
10350
|
+
case "response.refusal.delta": {
|
|
10351
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10352
|
+
if (output.type === "message") {
|
|
10353
|
+
const content = getContent(output.content, event.content_index);
|
|
10354
|
+
if (content.type !== "refusal") {
|
|
10355
|
+
throw new OpenAIError(`expected content to be 'refusal', got ${content.type}`);
|
|
10356
|
+
}
|
|
10357
|
+
content.refusal += event.delta;
|
|
10358
|
+
}
|
|
10359
|
+
break;
|
|
10360
|
+
}
|
|
10361
|
+
case "response.refusal.done": {
|
|
10362
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10363
|
+
if (output.type === "message") {
|
|
10364
|
+
const content = getContent(output.content, event.content_index);
|
|
10365
|
+
if (content.type !== "refusal") {
|
|
10366
|
+
throw new OpenAIError(`expected content to be 'refusal', got ${content.type}`);
|
|
10367
|
+
}
|
|
10368
|
+
content.refusal = event.refusal;
|
|
10369
|
+
}
|
|
10370
|
+
break;
|
|
10371
|
+
}
|
|
10372
|
+
case "response.function_call_arguments.delta": {
|
|
10373
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10374
|
+
if (output.type === "function_call") {
|
|
10375
|
+
output.arguments += event.delta;
|
|
10376
|
+
}
|
|
10377
|
+
break;
|
|
10378
|
+
}
|
|
10379
|
+
case "response.function_call_arguments.done": {
|
|
10380
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10381
|
+
if (output.type === "function_call") {
|
|
10382
|
+
output.arguments = event.arguments;
|
|
10383
|
+
}
|
|
10384
|
+
break;
|
|
10385
|
+
}
|
|
10386
|
+
case "response.reasoning_text.delta": {
|
|
10387
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10388
|
+
if (output.type === "reasoning") {
|
|
10389
|
+
if (!output.content) {
|
|
10390
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
10391
|
+
}
|
|
10392
|
+
const content = getContent(output.content, event.content_index);
|
|
10393
|
+
if (content.type !== "reasoning_text") {
|
|
10394
|
+
throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
|
|
10395
|
+
}
|
|
10396
|
+
content.text += event.delta;
|
|
10397
|
+
}
|
|
10398
|
+
break;
|
|
10399
|
+
}
|
|
10400
|
+
case "response.reasoning_text.done": {
|
|
10401
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10402
|
+
if (output.type === "reasoning") {
|
|
10403
|
+
if (!output.content) {
|
|
10404
|
+
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
10405
|
+
}
|
|
10406
|
+
const content = getContent(output.content, event.content_index);
|
|
10407
|
+
if (content.type !== "reasoning_text") {
|
|
10408
|
+
throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
|
|
10409
|
+
}
|
|
10410
|
+
content.text = event.text;
|
|
10411
|
+
}
|
|
10412
|
+
break;
|
|
10413
|
+
}
|
|
10414
|
+
case "response.reasoning_summary_part.added": {
|
|
10415
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10416
|
+
if (output.type === "reasoning") {
|
|
10417
|
+
output.summary.push(structuredClone(event.part));
|
|
10418
|
+
}
|
|
10419
|
+
break;
|
|
10420
|
+
}
|
|
10421
|
+
case "response.reasoning_summary_part.done": {
|
|
10422
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10423
|
+
if (output.type === "reasoning") {
|
|
10424
|
+
getContent(output.summary, event.summary_index);
|
|
10425
|
+
output.summary[event.summary_index] = structuredClone(event.part);
|
|
10426
|
+
}
|
|
10427
|
+
break;
|
|
10428
|
+
}
|
|
10429
|
+
case "response.reasoning_summary_text.delta": {
|
|
10430
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10431
|
+
if (output.type === "reasoning") {
|
|
10432
|
+
const part = getContent(output.summary, event.summary_index);
|
|
10433
|
+
part.text += event.delta;
|
|
10434
|
+
}
|
|
10435
|
+
break;
|
|
10436
|
+
}
|
|
10437
|
+
case "response.reasoning_summary_text.done": {
|
|
10438
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10439
|
+
if (output.type === "reasoning") {
|
|
10440
|
+
const part = getContent(output.summary, event.summary_index);
|
|
10441
|
+
part.text = event.text;
|
|
10442
|
+
}
|
|
10443
|
+
break;
|
|
10444
|
+
}
|
|
10445
|
+
case "response.custom_tool_call_input.delta": {
|
|
10446
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10447
|
+
if (output.type === "custom_tool_call") {
|
|
10448
|
+
output.input += event.delta;
|
|
10449
|
+
}
|
|
10450
|
+
break;
|
|
10451
|
+
}
|
|
10452
|
+
case "response.custom_tool_call_input.done": {
|
|
10453
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10454
|
+
if (output.type === "custom_tool_call") {
|
|
10455
|
+
output.input = event.input;
|
|
10456
|
+
}
|
|
10457
|
+
break;
|
|
10458
|
+
}
|
|
10459
|
+
case "response.mcp_call_arguments.delta": {
|
|
10460
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10461
|
+
if (output.type === "mcp_call") {
|
|
10462
|
+
output.arguments += event.delta;
|
|
10463
|
+
}
|
|
10464
|
+
break;
|
|
10465
|
+
}
|
|
10466
|
+
case "response.mcp_call_arguments.done": {
|
|
10467
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10468
|
+
if (output.type === "mcp_call") {
|
|
10469
|
+
output.arguments = event.arguments;
|
|
10470
|
+
}
|
|
10471
|
+
break;
|
|
10472
|
+
}
|
|
10473
|
+
case "response.code_interpreter_call_code.delta": {
|
|
10474
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10475
|
+
if (output.type === "code_interpreter_call") {
|
|
10476
|
+
output.code = (output.code ?? "") + event.delta;
|
|
10477
|
+
}
|
|
10478
|
+
break;
|
|
10479
|
+
}
|
|
10480
|
+
case "response.code_interpreter_call_code.done": {
|
|
10481
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10482
|
+
if (output.type === "code_interpreter_call") {
|
|
10483
|
+
output.code = event.code;
|
|
10484
|
+
}
|
|
10485
|
+
break;
|
|
10486
|
+
}
|
|
10487
|
+
case "response.code_interpreter_call.in_progress": {
|
|
10488
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10489
|
+
if (output.type === "code_interpreter_call") {
|
|
10490
|
+
output.status = "in_progress";
|
|
10491
|
+
}
|
|
10492
|
+
break;
|
|
10493
|
+
}
|
|
10494
|
+
case "response.code_interpreter_call.interpreting": {
|
|
10495
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10496
|
+
if (output.type === "code_interpreter_call") {
|
|
10497
|
+
output.status = "interpreting";
|
|
10498
|
+
}
|
|
10499
|
+
break;
|
|
10500
|
+
}
|
|
10501
|
+
case "response.code_interpreter_call.completed": {
|
|
10502
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10503
|
+
if (output.type === "code_interpreter_call") {
|
|
10504
|
+
output.status = "completed";
|
|
10505
|
+
}
|
|
10506
|
+
break;
|
|
10507
|
+
}
|
|
10508
|
+
case "response.file_search_call.in_progress": {
|
|
10509
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10510
|
+
if (output.type === "file_search_call") {
|
|
10511
|
+
output.status = "in_progress";
|
|
10512
|
+
}
|
|
10513
|
+
break;
|
|
10514
|
+
}
|
|
10515
|
+
case "response.file_search_call.searching": {
|
|
10516
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10517
|
+
if (output.type === "file_search_call") {
|
|
10518
|
+
output.status = "searching";
|
|
10519
|
+
}
|
|
10520
|
+
break;
|
|
10521
|
+
}
|
|
10522
|
+
case "response.file_search_call.completed": {
|
|
10523
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10524
|
+
if (output.type === "file_search_call") {
|
|
10525
|
+
output.status = "completed";
|
|
10526
|
+
}
|
|
10527
|
+
break;
|
|
10528
|
+
}
|
|
10529
|
+
case "response.web_search_call.in_progress": {
|
|
10530
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10531
|
+
if (output.type === "web_search_call") {
|
|
10532
|
+
output.status = "in_progress";
|
|
10533
|
+
}
|
|
10534
|
+
break;
|
|
10535
|
+
}
|
|
10536
|
+
case "response.web_search_call.searching": {
|
|
10537
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10538
|
+
if (output.type === "web_search_call") {
|
|
10539
|
+
output.status = "searching";
|
|
10540
|
+
}
|
|
10541
|
+
break;
|
|
10542
|
+
}
|
|
10543
|
+
case "response.web_search_call.completed": {
|
|
10544
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10545
|
+
if (output.type === "web_search_call") {
|
|
10546
|
+
output.status = "completed";
|
|
10547
|
+
}
|
|
10548
|
+
break;
|
|
10549
|
+
}
|
|
10550
|
+
case "response.image_generation_call.in_progress": {
|
|
10551
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10552
|
+
if (output.type === "image_generation_call") {
|
|
10553
|
+
output.status = "in_progress";
|
|
10554
|
+
}
|
|
10555
|
+
break;
|
|
10556
|
+
}
|
|
10557
|
+
case "response.image_generation_call.generating": {
|
|
10558
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10559
|
+
if (output.type === "image_generation_call") {
|
|
10560
|
+
output.status = "generating";
|
|
10561
|
+
}
|
|
10562
|
+
break;
|
|
10563
|
+
}
|
|
10564
|
+
case "response.image_generation_call.completed": {
|
|
10565
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10566
|
+
if (output.type === "image_generation_call") {
|
|
10567
|
+
output.status = "completed";
|
|
10568
|
+
}
|
|
10569
|
+
break;
|
|
10570
|
+
}
|
|
10571
|
+
case "response.mcp_call.in_progress": {
|
|
10572
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10573
|
+
if (output.type === "mcp_call") {
|
|
10574
|
+
output.status = "in_progress";
|
|
10575
|
+
}
|
|
10576
|
+
break;
|
|
10577
|
+
}
|
|
10578
|
+
case "response.mcp_call.completed": {
|
|
10579
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10580
|
+
if (output.type === "mcp_call") {
|
|
10581
|
+
output.status = "completed";
|
|
10582
|
+
}
|
|
10583
|
+
break;
|
|
10584
|
+
}
|
|
10585
|
+
case "response.mcp_call.failed": {
|
|
10586
|
+
const output = getOutput(snapshot, event.output_index);
|
|
10587
|
+
if (output.type === "mcp_call") {
|
|
10588
|
+
output.status = "failed";
|
|
10589
|
+
}
|
|
10590
|
+
break;
|
|
10591
|
+
}
|
|
10592
|
+
case "response.created":
|
|
10593
|
+
case "response.queued":
|
|
10594
|
+
case "response.in_progress":
|
|
10595
|
+
case "response.completed":
|
|
10596
|
+
case "response.failed":
|
|
10597
|
+
case "response.incomplete": {
|
|
10598
|
+
snapshot = cloneResponse(event.response);
|
|
10599
|
+
break;
|
|
10600
|
+
}
|
|
10601
|
+
case "response.audio.delta":
|
|
10602
|
+
case "response.audio.done":
|
|
10603
|
+
case "response.audio.transcript.delta":
|
|
10604
|
+
case "response.audio.transcript.done":
|
|
10605
|
+
case "response.image_generation_call.partial_image":
|
|
10606
|
+
case "response.mcp_list_tools.in_progress":
|
|
10607
|
+
case "response.mcp_list_tools.completed":
|
|
10608
|
+
case "response.mcp_list_tools.failed":
|
|
10609
|
+
case "keepalive":
|
|
10610
|
+
case "error": {
|
|
10611
|
+
break;
|
|
10612
|
+
}
|
|
10613
|
+
default: {
|
|
10614
|
+
assertNever3(event);
|
|
10615
|
+
}
|
|
10616
|
+
}
|
|
10617
|
+
return snapshot;
|
|
10618
|
+
}
|
|
10619
|
+
function cloneResponse(response) {
|
|
10620
|
+
const snapshot = structuredClone(response);
|
|
10621
|
+
if (!Object.getOwnPropertyDescriptor(snapshot, "output_text") || snapshot.output_text == null) {
|
|
10622
|
+
addOutputText(snapshot);
|
|
10623
|
+
}
|
|
10624
|
+
return snapshot;
|
|
10625
|
+
}
|
|
10626
|
+
function getOutput(snapshot, outputIndex) {
|
|
10627
|
+
const output = snapshot.output[outputIndex];
|
|
10628
|
+
if (!output) {
|
|
10629
|
+
throw new OpenAIError(`missing output at index ${outputIndex}`);
|
|
10630
|
+
}
|
|
10631
|
+
return output;
|
|
10632
|
+
}
|
|
10633
|
+
function getContent(content, contentIndex) {
|
|
10634
|
+
const part = content[contentIndex];
|
|
10635
|
+
if (!part) {
|
|
10636
|
+
throw new OpenAIError(`missing content at index ${contentIndex}`);
|
|
10637
|
+
}
|
|
10638
|
+
return part;
|
|
10639
|
+
}
|
|
10640
|
+
function assertNever3(value) {
|
|
10641
|
+
throw new OpenAIError(`Unhandled response stream event: ${JSON.stringify(value)}`);
|
|
10642
|
+
}
|
|
10643
|
+
|
|
10644
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/responses/ResponseStream.mjs
|
|
9616
10645
|
var _ResponseStream_instances;
|
|
9617
10646
|
var _ResponseStream_params;
|
|
9618
10647
|
var _ResponseStream_currentResponseSnapshot;
|
|
@@ -9620,7 +10649,6 @@ var _ResponseStream_finalResponse;
|
|
|
9620
10649
|
var _ResponseStream_beginRequest;
|
|
9621
10650
|
var _ResponseStream_addEvent;
|
|
9622
10651
|
var _ResponseStream_endRequest;
|
|
9623
|
-
var _ResponseStream_accumulateResponse;
|
|
9624
10652
|
var ResponseStream = class _ResponseStream extends EventStream {
|
|
9625
10653
|
constructor(params) {
|
|
9626
10654
|
super();
|
|
@@ -9638,13 +10666,13 @@ var ResponseStream = class _ResponseStream extends EventStream {
|
|
|
9638
10666
|
}));
|
|
9639
10667
|
return runner;
|
|
9640
10668
|
}
|
|
10669
|
+
static fromReadableStream(stream) {
|
|
10670
|
+
const runner = new _ResponseStream(null);
|
|
10671
|
+
runner._run(() => runner._fromReadableStream(stream));
|
|
10672
|
+
return runner;
|
|
10673
|
+
}
|
|
9641
10674
|
async _createOrRetrieveResponse(client, params, options) {
|
|
9642
|
-
|
|
9643
|
-
if (signal) {
|
|
9644
|
-
if (signal.aborted)
|
|
9645
|
-
this.controller.abort();
|
|
9646
|
-
signal.addEventListener("abort", () => this.controller.abort());
|
|
9647
|
-
}
|
|
10675
|
+
this._listenForAbort(options?.signal);
|
|
9648
10676
|
__classPrivateFieldGet(this, _ResponseStream_instances, "m", _ResponseStream_beginRequest).call(this);
|
|
9649
10677
|
let stream;
|
|
9650
10678
|
let starting_after = null;
|
|
@@ -9663,6 +10691,19 @@ var ResponseStream = class _ResponseStream extends EventStream {
|
|
|
9663
10691
|
}
|
|
9664
10692
|
return __classPrivateFieldGet(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
9665
10693
|
}
|
|
10694
|
+
async _fromReadableStream(readableStream, options) {
|
|
10695
|
+
this._listenForAbort(options?.signal);
|
|
10696
|
+
__classPrivateFieldGet(this, _ResponseStream_instances, "m", _ResponseStream_beginRequest).call(this);
|
|
10697
|
+
this._connected();
|
|
10698
|
+
const stream = Stream.fromReadableStream(readableStream, this.controller);
|
|
10699
|
+
for await (const event of stream) {
|
|
10700
|
+
__classPrivateFieldGet(this, _ResponseStream_instances, "m", _ResponseStream_addEvent).call(this, event, null);
|
|
10701
|
+
}
|
|
10702
|
+
if (stream.controller.signal?.aborted) {
|
|
10703
|
+
throw new APIUserAbortError();
|
|
10704
|
+
}
|
|
10705
|
+
return __classPrivateFieldGet(this, _ResponseStream_instances, "m", _ResponseStream_endRequest).call(this);
|
|
10706
|
+
}
|
|
9666
10707
|
[(_ResponseStream_params = /* @__PURE__ */ new WeakMap(), _ResponseStream_currentResponseSnapshot = /* @__PURE__ */ new WeakMap(), _ResponseStream_finalResponse = /* @__PURE__ */ new WeakMap(), _ResponseStream_instances = /* @__PURE__ */ new WeakSet(), _ResponseStream_beginRequest = function _ResponseStream_beginRequest2() {
|
|
9667
10708
|
if (this.ended)
|
|
9668
10709
|
return;
|
|
@@ -9675,7 +10716,8 @@ var ResponseStream = class _ResponseStream extends EventStream {
|
|
|
9675
10716
|
this._emit(name, event2);
|
|
9676
10717
|
}
|
|
9677
10718
|
};
|
|
9678
|
-
const response = __classPrivateFieldGet(this,
|
|
10719
|
+
const response = accumulateResponse(event, __classPrivateFieldGet(this, _ResponseStream_currentResponseSnapshot, "f"));
|
|
10720
|
+
__classPrivateFieldSet(this, _ResponseStream_currentResponseSnapshot, response, "f");
|
|
9679
10721
|
maybeEmit("event", event);
|
|
9680
10722
|
switch (event.type) {
|
|
9681
10723
|
case "response.output_text.delta": {
|
|
@@ -9727,87 +10769,6 @@ var ResponseStream = class _ResponseStream extends EventStream {
|
|
|
9727
10769
|
const parsedResponse = finalizeResponse(snapshot, __classPrivateFieldGet(this, _ResponseStream_params, "f"));
|
|
9728
10770
|
__classPrivateFieldSet(this, _ResponseStream_finalResponse, parsedResponse, "f");
|
|
9729
10771
|
return parsedResponse;
|
|
9730
|
-
}, _ResponseStream_accumulateResponse = function _ResponseStream_accumulateResponse2(event) {
|
|
9731
|
-
let snapshot = __classPrivateFieldGet(this, _ResponseStream_currentResponseSnapshot, "f");
|
|
9732
|
-
if (!snapshot) {
|
|
9733
|
-
if (event.type !== "response.created") {
|
|
9734
|
-
throw new OpenAIError(`When snapshot hasn't been set yet, expected 'response.created' event, got ${event.type}`);
|
|
9735
|
-
}
|
|
9736
|
-
snapshot = __classPrivateFieldSet(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
|
|
9737
|
-
return snapshot;
|
|
9738
|
-
}
|
|
9739
|
-
switch (event.type) {
|
|
9740
|
-
case "response.output_item.added": {
|
|
9741
|
-
snapshot.output.push(event.item);
|
|
9742
|
-
break;
|
|
9743
|
-
}
|
|
9744
|
-
case "response.content_part.added": {
|
|
9745
|
-
const output = snapshot.output[event.output_index];
|
|
9746
|
-
if (!output) {
|
|
9747
|
-
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
9748
|
-
}
|
|
9749
|
-
const type = output.type;
|
|
9750
|
-
const part = event.part;
|
|
9751
|
-
if (type === "message" && part.type !== "reasoning_text") {
|
|
9752
|
-
output.content.push(part);
|
|
9753
|
-
} else if (type === "reasoning" && part.type === "reasoning_text") {
|
|
9754
|
-
if (!output.content) {
|
|
9755
|
-
output.content = [];
|
|
9756
|
-
}
|
|
9757
|
-
output.content.push(part);
|
|
9758
|
-
}
|
|
9759
|
-
break;
|
|
9760
|
-
}
|
|
9761
|
-
case "response.output_text.delta": {
|
|
9762
|
-
const output = snapshot.output[event.output_index];
|
|
9763
|
-
if (!output) {
|
|
9764
|
-
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
9765
|
-
}
|
|
9766
|
-
if (output.type === "message") {
|
|
9767
|
-
const content = output.content[event.content_index];
|
|
9768
|
-
if (!content) {
|
|
9769
|
-
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
9770
|
-
}
|
|
9771
|
-
if (content.type !== "output_text") {
|
|
9772
|
-
throw new OpenAIError(`expected content to be 'output_text', got ${content.type}`);
|
|
9773
|
-
}
|
|
9774
|
-
content.text += event.delta;
|
|
9775
|
-
}
|
|
9776
|
-
break;
|
|
9777
|
-
}
|
|
9778
|
-
case "response.function_call_arguments.delta": {
|
|
9779
|
-
const output = snapshot.output[event.output_index];
|
|
9780
|
-
if (!output) {
|
|
9781
|
-
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
9782
|
-
}
|
|
9783
|
-
if (output.type === "function_call") {
|
|
9784
|
-
output.arguments += event.delta;
|
|
9785
|
-
}
|
|
9786
|
-
break;
|
|
9787
|
-
}
|
|
9788
|
-
case "response.reasoning_text.delta": {
|
|
9789
|
-
const output = snapshot.output[event.output_index];
|
|
9790
|
-
if (!output) {
|
|
9791
|
-
throw new OpenAIError(`missing output at index ${event.output_index}`);
|
|
9792
|
-
}
|
|
9793
|
-
if (output.type === "reasoning") {
|
|
9794
|
-
const content = output.content?.[event.content_index];
|
|
9795
|
-
if (!content) {
|
|
9796
|
-
throw new OpenAIError(`missing content at index ${event.content_index}`);
|
|
9797
|
-
}
|
|
9798
|
-
if (content.type !== "reasoning_text") {
|
|
9799
|
-
throw new OpenAIError(`expected content to be 'reasoning_text', got ${content.type}`);
|
|
9800
|
-
}
|
|
9801
|
-
content.text += event.delta;
|
|
9802
|
-
}
|
|
9803
|
-
break;
|
|
9804
|
-
}
|
|
9805
|
-
case "response.completed": {
|
|
9806
|
-
__classPrivateFieldSet(this, _ResponseStream_currentResponseSnapshot, event.response, "f");
|
|
9807
|
-
break;
|
|
9808
|
-
}
|
|
9809
|
-
}
|
|
9810
|
-
return snapshot;
|
|
9811
10772
|
}, Symbol.asyncIterator)]() {
|
|
9812
10773
|
const pushQueue = [];
|
|
9813
10774
|
const readQueue = [];
|
|
@@ -9874,8 +10835,8 @@ function finalizeResponse(snapshot, params) {
|
|
|
9874
10835
|
return maybeParseResponse(snapshot, params);
|
|
9875
10836
|
}
|
|
9876
10837
|
|
|
9877
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9878
|
-
var
|
|
10838
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/responses/input-items.mjs
|
|
10839
|
+
var InputItems2 = class extends APIResource {
|
|
9879
10840
|
/**
|
|
9880
10841
|
* Returns a list of input items for a given response.
|
|
9881
10842
|
*
|
|
@@ -9894,8 +10855,8 @@ var InputItems = class extends APIResource {
|
|
|
9894
10855
|
}
|
|
9895
10856
|
};
|
|
9896
10857
|
|
|
9897
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9898
|
-
var
|
|
10858
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/responses/input-tokens.mjs
|
|
10859
|
+
var InputTokens2 = class extends APIResource {
|
|
9899
10860
|
/**
|
|
9900
10861
|
* Returns input token counts of the request.
|
|
9901
10862
|
*
|
|
@@ -9916,12 +10877,12 @@ var InputTokens = class extends APIResource {
|
|
|
9916
10877
|
}
|
|
9917
10878
|
};
|
|
9918
10879
|
|
|
9919
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
9920
|
-
var
|
|
10880
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/responses/responses.mjs
|
|
10881
|
+
var Responses2 = class extends APIResource {
|
|
9921
10882
|
constructor() {
|
|
9922
10883
|
super(...arguments);
|
|
9923
|
-
this.inputItems = new
|
|
9924
|
-
this.inputTokens = new
|
|
10884
|
+
this.inputItems = new InputItems2(this._client);
|
|
10885
|
+
this.inputTokens = new InputTokens2(this._client);
|
|
9925
10886
|
}
|
|
9926
10887
|
create(body, options) {
|
|
9927
10888
|
return this._client.post("/responses", {
|
|
@@ -10004,7 +10965,7 @@ var Responses = class extends APIResource {
|
|
|
10004
10965
|
* @example
|
|
10005
10966
|
* ```ts
|
|
10006
10967
|
* const compactedResponse = await client.responses.compact({
|
|
10007
|
-
* model: 'gpt-5.
|
|
10968
|
+
* model: 'gpt-5.6-sol',
|
|
10008
10969
|
* });
|
|
10009
10970
|
* ```
|
|
10010
10971
|
*/
|
|
@@ -10012,10 +10973,10 @@ var Responses = class extends APIResource {
|
|
|
10012
10973
|
return this._client.post("/responses/compact", { body, ...options, __security: { bearerAuth: true } });
|
|
10013
10974
|
}
|
|
10014
10975
|
};
|
|
10015
|
-
|
|
10016
|
-
|
|
10976
|
+
Responses2.InputItems = InputItems2;
|
|
10977
|
+
Responses2.InputTokens = InputTokens2;
|
|
10017
10978
|
|
|
10018
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10979
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/skills/content.mjs
|
|
10019
10980
|
var Content2 = class extends APIResource {
|
|
10020
10981
|
/**
|
|
10021
10982
|
* Download a skill zip bundle by its ID.
|
|
@@ -10030,7 +10991,7 @@ var Content2 = class extends APIResource {
|
|
|
10030
10991
|
}
|
|
10031
10992
|
};
|
|
10032
10993
|
|
|
10033
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
10994
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/skills/versions/content.mjs
|
|
10034
10995
|
var Content3 = class extends APIResource {
|
|
10035
10996
|
/**
|
|
10036
10997
|
* Download a skill version zip bundle.
|
|
@@ -10046,7 +11007,7 @@ var Content3 = class extends APIResource {
|
|
|
10046
11007
|
}
|
|
10047
11008
|
};
|
|
10048
11009
|
|
|
10049
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11010
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/skills/versions/versions.mjs
|
|
10050
11011
|
var Versions = class extends APIResource {
|
|
10051
11012
|
constructor() {
|
|
10052
11013
|
super(...arguments);
|
|
@@ -10091,7 +11052,7 @@ var Versions = class extends APIResource {
|
|
|
10091
11052
|
};
|
|
10092
11053
|
Versions.Content = Content3;
|
|
10093
11054
|
|
|
10094
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11055
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/skills/skills.mjs
|
|
10095
11056
|
var Skills = class extends APIResource {
|
|
10096
11057
|
constructor() {
|
|
10097
11058
|
super(...arguments);
|
|
@@ -10140,7 +11101,7 @@ var Skills = class extends APIResource {
|
|
|
10140
11101
|
Skills.Content = Content2;
|
|
10141
11102
|
Skills.Versions = Versions;
|
|
10142
11103
|
|
|
10143
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11104
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/uploads/parts.mjs
|
|
10144
11105
|
var Parts = class extends APIResource {
|
|
10145
11106
|
/**
|
|
10146
11107
|
* Adds a
|
|
@@ -10160,7 +11121,7 @@ var Parts = class extends APIResource {
|
|
|
10160
11121
|
}
|
|
10161
11122
|
};
|
|
10162
11123
|
|
|
10163
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11124
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/uploads/uploads.mjs
|
|
10164
11125
|
var Uploads = class extends APIResource {
|
|
10165
11126
|
constructor() {
|
|
10166
11127
|
super(...arguments);
|
|
@@ -10230,7 +11191,7 @@ var Uploads = class extends APIResource {
|
|
|
10230
11191
|
};
|
|
10231
11192
|
Uploads.Parts = Parts;
|
|
10232
11193
|
|
|
10233
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11194
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/lib/Util.mjs
|
|
10234
11195
|
var allSettledWithThrow = async (promises) => {
|
|
10235
11196
|
const results = await Promise.allSettled(promises);
|
|
10236
11197
|
const rejected = results.filter((result) => result.status === "rejected");
|
|
@@ -10249,7 +11210,7 @@ var allSettledWithThrow = async (promises) => {
|
|
|
10249
11210
|
return values;
|
|
10250
11211
|
};
|
|
10251
11212
|
|
|
10252
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11213
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/vector-stores/file-batches.mjs
|
|
10253
11214
|
var FileBatches = class extends APIResource {
|
|
10254
11215
|
/**
|
|
10255
11216
|
* Create a vector store file batch.
|
|
@@ -10374,7 +11335,7 @@ var FileBatches = class extends APIResource {
|
|
|
10374
11335
|
}
|
|
10375
11336
|
};
|
|
10376
11337
|
|
|
10377
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11338
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/vector-stores/files.mjs
|
|
10378
11339
|
var Files3 = class extends APIResource {
|
|
10379
11340
|
/**
|
|
10380
11341
|
* Create a vector store file by attaching a
|
|
@@ -10515,7 +11476,7 @@ var Files3 = class extends APIResource {
|
|
|
10515
11476
|
}
|
|
10516
11477
|
};
|
|
10517
11478
|
|
|
10518
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11479
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/vector-stores/vector-stores.mjs
|
|
10519
11480
|
var VectorStores = class extends APIResource {
|
|
10520
11481
|
constructor() {
|
|
10521
11482
|
super(...arguments);
|
|
@@ -10592,7 +11553,7 @@ var VectorStores = class extends APIResource {
|
|
|
10592
11553
|
VectorStores.Files = Files3;
|
|
10593
11554
|
VectorStores.FileBatches = FileBatches;
|
|
10594
11555
|
|
|
10595
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11556
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/videos.mjs
|
|
10596
11557
|
var Videos = class extends APIResource {
|
|
10597
11558
|
/**
|
|
10598
11559
|
* Create a new video generation job from a prompt and optional reference assets.
|
|
@@ -10672,7 +11633,7 @@ var Videos = class extends APIResource {
|
|
|
10672
11633
|
}
|
|
10673
11634
|
};
|
|
10674
11635
|
|
|
10675
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11636
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/resources/webhooks/webhooks.mjs
|
|
10676
11637
|
var _Webhooks_instances;
|
|
10677
11638
|
var _Webhooks_validateSecret;
|
|
10678
11639
|
var _Webhooks_getRequiredHeader;
|
|
@@ -10751,7 +11712,23 @@ _Webhooks_instances = /* @__PURE__ */ new WeakSet(), _Webhooks_validateSecret =
|
|
|
10751
11712
|
return value;
|
|
10752
11713
|
};
|
|
10753
11714
|
|
|
10754
|
-
// ../../node_modules/.pnpm/openai@6.
|
|
11715
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/internal/provider.mjs
|
|
11716
|
+
var providerDefinitionsKey = /* @__PURE__ */ Symbol.for("openai.node.providerDefinitions.v1");
|
|
11717
|
+
var providerGlobal = globalThis;
|
|
11718
|
+
var existingProviderDefinitions = providerGlobal[providerDefinitionsKey];
|
|
11719
|
+
var providerDefinitions = existingProviderDefinitions ?? /* @__PURE__ */ new WeakMap();
|
|
11720
|
+
if (!existingProviderDefinitions) {
|
|
11721
|
+
Object.defineProperty(providerGlobal, providerDefinitionsKey, { value: providerDefinitions });
|
|
11722
|
+
}
|
|
11723
|
+
function configureProvider(provider) {
|
|
11724
|
+
const definition = providerDefinitions.get(provider);
|
|
11725
|
+
if (!definition) {
|
|
11726
|
+
throw new Error("Invalid provider. Providers must be created with createProvider().");
|
|
11727
|
+
}
|
|
11728
|
+
return definition.configure();
|
|
11729
|
+
}
|
|
11730
|
+
|
|
11731
|
+
// ../../node_modules/.pnpm/openai@6.48.0_ws@8.21.1_zod@4.4.3/node_modules/openai/client.mjs
|
|
10755
11732
|
var _OpenAI_instances;
|
|
10756
11733
|
var _a2;
|
|
10757
11734
|
var _OpenAI_encoder;
|
|
@@ -10767,6 +11744,7 @@ var OpenAI = class {
|
|
|
10767
11744
|
* @param {string | null | undefined} [opts.project=process.env['OPENAI_PROJECT_ID'] ?? null]
|
|
10768
11745
|
* @param {string | null | undefined} [opts.webhookSecret=process.env['OPENAI_WEBHOOK_SECRET'] ?? null]
|
|
10769
11746
|
* @param {string} [opts.baseURL=process.env['OPENAI_BASE_URL'] ?? https://api.openai.com/v1] - Override the default base URL for the API.
|
|
11747
|
+
* @param {Provider} [opts.provider] - Configure a third-party API provider. Mutually exclusive with top-level authentication and base URL options.
|
|
10770
11748
|
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
10771
11749
|
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
10772
11750
|
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
@@ -10775,7 +11753,7 @@ var OpenAI = class {
|
|
|
10775
11753
|
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
10776
11754
|
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
10777
11755
|
*/
|
|
10778
|
-
constructor(
|
|
11756
|
+
constructor(clientOptions = {}) {
|
|
10779
11757
|
_OpenAI_instances.add(this);
|
|
10780
11758
|
_OpenAI_encoder.set(this, void 0);
|
|
10781
11759
|
this.completions = new Completions2(this);
|
|
@@ -10794,13 +11772,22 @@ var OpenAI = class {
|
|
|
10794
11772
|
this.batches = new Batches(this);
|
|
10795
11773
|
this.uploads = new Uploads(this);
|
|
10796
11774
|
this.admin = new Admin(this);
|
|
10797
|
-
this.responses = new
|
|
11775
|
+
this.responses = new Responses2(this);
|
|
10798
11776
|
this.realtime = new Realtime2(this);
|
|
10799
11777
|
this.conversations = new Conversations(this);
|
|
10800
11778
|
this.evals = new Evals(this);
|
|
10801
11779
|
this.containers = new Containers(this);
|
|
10802
11780
|
this.skills = new Skills(this);
|
|
10803
11781
|
this.videos = new Videos(this);
|
|
11782
|
+
const provider = clientOptions.provider;
|
|
11783
|
+
if (provider) {
|
|
11784
|
+
const conflictingOptions = ["apiKey", "adminAPIKey", "workloadIdentity", "baseURL"].filter((key2) => clientOptions[key2] != null);
|
|
11785
|
+
if (conflictingOptions.length) {
|
|
11786
|
+
throw new OpenAIError(`The \`provider\` option cannot be used with ${conflictingOptions.map((key2) => `\`${key2}\``).join(", ")}. Configure authentication and the base URL through the provider instead.`);
|
|
11787
|
+
}
|
|
11788
|
+
}
|
|
11789
|
+
const { baseURL = provider ? null : readEnv("OPENAI_BASE_URL"), apiKey = provider ? null : readEnv("OPENAI_API_KEY") ?? null, adminAPIKey = provider ? null : readEnv("OPENAI_ADMIN_KEY") ?? null, organization = provider ? null : readEnv("OPENAI_ORG_ID") ?? null, project = provider ? null : readEnv("OPENAI_PROJECT_ID") ?? null, webhookSecret = readEnv("OPENAI_WEBHOOK_SECRET") ?? null, workloadIdentity, ...opts } = clientOptions;
|
|
11790
|
+
const providerRuntime = provider ? configureProvider(provider) : void 0;
|
|
10804
11791
|
const options = {
|
|
10805
11792
|
apiKey,
|
|
10806
11793
|
adminAPIKey,
|
|
@@ -10808,13 +11795,14 @@ var OpenAI = class {
|
|
|
10808
11795
|
project,
|
|
10809
11796
|
webhookSecret,
|
|
10810
11797
|
workloadIdentity,
|
|
11798
|
+
provider,
|
|
10811
11799
|
...opts,
|
|
10812
|
-
baseURL: baseURL || `https://api.openai.com/v1`
|
|
11800
|
+
baseURL: providerRuntime?.baseURL ?? (baseURL || `https://api.openai.com/v1`)
|
|
10813
11801
|
};
|
|
10814
11802
|
if (apiKey && workloadIdentity) {
|
|
10815
11803
|
throw new OpenAIError("The `apiKey` and `workloadIdentity` options are mutually exclusive");
|
|
10816
11804
|
}
|
|
10817
|
-
if (!apiKey && !adminAPIKey && !workloadIdentity) {
|
|
11805
|
+
if (!providerRuntime && !apiKey && !adminAPIKey && !workloadIdentity) {
|
|
10818
11806
|
throw new OpenAIError("Missing credentials. Please pass an `apiKey`, `workloadIdentity`, `adminAPIKey`, or set the `OPENAI_API_KEY` or `OPENAI_ADMIN_KEY` environment variable.");
|
|
10819
11807
|
}
|
|
10820
11808
|
if (!options.dangerouslyAllowBrowser && isRunningInBrowser()) {
|
|
@@ -10830,7 +11818,7 @@ var OpenAI = class {
|
|
|
10830
11818
|
this.maxRetries = options.maxRetries ?? 2;
|
|
10831
11819
|
this.fetch = options.fetch ?? getDefaultFetch();
|
|
10832
11820
|
__classPrivateFieldSet(this, _OpenAI_encoder, FallbackEncoder, "f");
|
|
10833
|
-
const customHeadersEnv = readEnv("OPENAI_CUSTOM_HEADERS");
|
|
11821
|
+
const customHeadersEnv = provider ? void 0 : readEnv("OPENAI_CUSTOM_HEADERS");
|
|
10834
11822
|
if (customHeadersEnv) {
|
|
10835
11823
|
const parsed = {};
|
|
10836
11824
|
for (const line2 of customHeadersEnv.split("\n")) {
|
|
@@ -10842,6 +11830,7 @@ var OpenAI = class {
|
|
|
10842
11830
|
options.defaultHeaders = buildHeaders([parsed, options.defaultHeaders]);
|
|
10843
11831
|
}
|
|
10844
11832
|
this._options = options;
|
|
11833
|
+
this._provider = providerRuntime;
|
|
10845
11834
|
if (workloadIdentity) {
|
|
10846
11835
|
this._workloadIdentityAuth = new WorkloadIdentityAuth(workloadIdentity, this.fetch);
|
|
10847
11836
|
}
|
|
@@ -10855,7 +11844,9 @@ var OpenAI = class {
|
|
|
10855
11844
|
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
10856
11845
|
*/
|
|
10857
11846
|
withOptions(options) {
|
|
10858
|
-
const
|
|
11847
|
+
const inheritedProvider = this._options.provider;
|
|
11848
|
+
const provider = options.provider ?? inheritedProvider;
|
|
11849
|
+
const inheritedOptions = {
|
|
10859
11850
|
...this._options,
|
|
10860
11851
|
baseURL: this.baseURL,
|
|
10861
11852
|
maxRetries: this.maxRetries,
|
|
@@ -10869,8 +11860,23 @@ var OpenAI = class {
|
|
|
10869
11860
|
workloadIdentity: this._options.workloadIdentity,
|
|
10870
11861
|
organization: this.organization,
|
|
10871
11862
|
project: this.project,
|
|
10872
|
-
webhookSecret: this.webhookSecret
|
|
10873
|
-
|
|
11863
|
+
webhookSecret: this.webhookSecret
|
|
11864
|
+
};
|
|
11865
|
+
if (provider) {
|
|
11866
|
+
delete inheritedOptions.apiKey;
|
|
11867
|
+
delete inheritedOptions.adminAPIKey;
|
|
11868
|
+
delete inheritedOptions.workloadIdentity;
|
|
11869
|
+
delete inheritedOptions.baseURL;
|
|
11870
|
+
if (provider !== inheritedProvider) {
|
|
11871
|
+
delete inheritedOptions.organization;
|
|
11872
|
+
delete inheritedOptions.project;
|
|
11873
|
+
delete inheritedOptions.defaultHeaders;
|
|
11874
|
+
}
|
|
11875
|
+
}
|
|
11876
|
+
const client = new this.constructor({
|
|
11877
|
+
...inheritedOptions,
|
|
11878
|
+
...options,
|
|
11879
|
+
provider
|
|
10874
11880
|
});
|
|
10875
11881
|
return client;
|
|
10876
11882
|
}
|
|
@@ -10929,6 +11935,8 @@ var OpenAI = class {
|
|
|
10929
11935
|
return APIError.generate(status, error, message, headers);
|
|
10930
11936
|
}
|
|
10931
11937
|
async _callApiKey() {
|
|
11938
|
+
if (this._provider)
|
|
11939
|
+
return false;
|
|
10932
11940
|
const apiKey = this._options.apiKey;
|
|
10933
11941
|
if (typeof apiKey !== "function")
|
|
10934
11942
|
return false;
|
|
@@ -10967,6 +11975,8 @@ var OpenAI = class {
|
|
|
10967
11975
|
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
10968
11976
|
*/
|
|
10969
11977
|
async prepareOptions(options) {
|
|
11978
|
+
if (this._provider)
|
|
11979
|
+
return;
|
|
10970
11980
|
const security = options.__security ?? { bearerAuth: true };
|
|
10971
11981
|
if (security.bearerAuth) {
|
|
10972
11982
|
await this._callApiKey();
|
|
@@ -11013,7 +12023,9 @@ var OpenAI = class {
|
|
|
11013
12023
|
const { req: req2, url, timeout } = await this.buildRequest(options, {
|
|
11014
12024
|
retryCount: maxRetries - retriesRemaining
|
|
11015
12025
|
});
|
|
12026
|
+
const hasStreamingBody = options.__metadata?.["hasStreamingBody"] === true;
|
|
11016
12027
|
await this.prepareRequest(req2, { url, options });
|
|
12028
|
+
await this._provider?.prepareRequest?.(req2, { url, options });
|
|
11017
12029
|
const requestLogID = "log_" + (Math.random() * (1 << 24) | 0).toString(16).padStart(6, "0");
|
|
11018
12030
|
const retryLogStr = retryOfRequestLogID === void 0 ? "" : `, retryOf: ${retryOfRequestLogID}`;
|
|
11019
12031
|
const startTime = Date.now();
|
|
@@ -11037,7 +12049,7 @@ var OpenAI = class {
|
|
|
11037
12049
|
throw new APIUserAbortError();
|
|
11038
12050
|
}
|
|
11039
12051
|
const isTimeout = isAbortError(response) || /timed? ?out/i.test(String(response) + ("cause" in response ? String(response.cause) : ""));
|
|
11040
|
-
if (retriesRemaining) {
|
|
12052
|
+
if (retriesRemaining && !hasStreamingBody) {
|
|
11041
12053
|
loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${retryMessage}`);
|
|
11042
12054
|
loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${retryMessage})`, formatRequestDetails({
|
|
11043
12055
|
retryOfRequestLogID,
|
|
@@ -11047,8 +12059,9 @@ var OpenAI = class {
|
|
|
11047
12059
|
}));
|
|
11048
12060
|
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID);
|
|
11049
12061
|
}
|
|
11050
|
-
|
|
11051
|
-
loggerFor(this).
|
|
12062
|
+
const terminalMessage = hasStreamingBody ? "error; streaming body cannot be retried" : "error; no more retries left";
|
|
12063
|
+
loggerFor(this).info(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} - ${terminalMessage}`);
|
|
12064
|
+
loggerFor(this).debug(`[${requestLogID}] connection ${isTimeout ? "timed out" : "failed"} (${terminalMessage})`, formatRequestDetails({
|
|
11052
12065
|
retryOfRequestLogID,
|
|
11053
12066
|
url,
|
|
11054
12067
|
durationMs: headersTime - startTime,
|
|
@@ -11080,7 +12093,7 @@ var OpenAI = class {
|
|
|
11080
12093
|
}, retriesRemaining, retryOfRequestLogID ?? requestLogID);
|
|
11081
12094
|
}
|
|
11082
12095
|
const shouldRetry = await this.shouldRetry(response);
|
|
11083
|
-
if (retriesRemaining && shouldRetry) {
|
|
12096
|
+
if (retriesRemaining && shouldRetry && !hasStreamingBody) {
|
|
11084
12097
|
const retryMessage2 = `retrying, ${retriesRemaining} attempts remaining`;
|
|
11085
12098
|
await CancelReadableStream(response.body);
|
|
11086
12099
|
loggerFor(this).info(`${responseInfo} - ${retryMessage2}`);
|
|
@@ -11093,7 +12106,7 @@ var OpenAI = class {
|
|
|
11093
12106
|
}));
|
|
11094
12107
|
return this.retryRequest(options, retriesRemaining, retryOfRequestLogID ?? requestLogID, response.headers);
|
|
11095
12108
|
}
|
|
11096
|
-
const retryMessage = shouldRetry ? `error; no more retries left` : `error; not retryable`;
|
|
12109
|
+
const retryMessage = shouldRetry ? hasStreamingBody ? `error; streaming body cannot be retried` : `error; no more retries left` : `error; not retryable`;
|
|
11097
12110
|
loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
|
|
11098
12111
|
const errText2 = await response.text().catch((err2) => castToError(err2).message);
|
|
11099
12112
|
const errJSON = safeJSON(errText2);
|
|
@@ -11256,24 +12269,30 @@ var OpenAI = class {
|
|
|
11256
12269
|
"OpenAI-Organization": this.organization,
|
|
11257
12270
|
"OpenAI-Project": this.project
|
|
11258
12271
|
},
|
|
11259
|
-
await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
|
|
12272
|
+
this._provider ? void 0 : await this.authHeaders(options, options.__security ?? { bearerAuth: true }),
|
|
11260
12273
|
this._options.defaultHeaders,
|
|
11261
12274
|
bodyHeaders,
|
|
11262
12275
|
options.headers
|
|
11263
12276
|
]);
|
|
11264
|
-
this.
|
|
12277
|
+
if (!this._provider) {
|
|
12278
|
+
this.validateHeaders(headers, options.__security ?? { bearerAuth: true });
|
|
12279
|
+
}
|
|
11265
12280
|
return headers.values;
|
|
11266
12281
|
}
|
|
11267
12282
|
_makeAbort(controller) {
|
|
11268
12283
|
return () => controller.abort();
|
|
11269
12284
|
}
|
|
11270
|
-
buildBody({ options
|
|
12285
|
+
buildBody({ options }) {
|
|
12286
|
+
const { body, headers: rawHeaders } = options;
|
|
11271
12287
|
if (!body) {
|
|
12288
|
+
if (body === void 0 && "body" in options) {
|
|
12289
|
+
return { ...__classPrivateFieldGet(this, _OpenAI_encoder, "f").call(this, { body, headers: buildHeaders([rawHeaders]) }), isStreamingBody: false };
|
|
12290
|
+
}
|
|
11272
12291
|
return { bodyHeaders: void 0, body: void 0, isStreamingBody: false };
|
|
11273
12292
|
}
|
|
11274
12293
|
const headers = buildHeaders([rawHeaders]);
|
|
11275
|
-
const
|
|
11276
|
-
const isRetryableBody = !
|
|
12294
|
+
const isReadableStream2 = typeof globalThis.ReadableStream !== "undefined" && body instanceof globalThis.ReadableStream;
|
|
12295
|
+
const isRetryableBody = !isReadableStream2 && (typeof body === "string" || body instanceof ArrayBuffer || ArrayBuffer.isView(body) || typeof globalThis.Blob !== "undefined" && body instanceof globalThis.Blob || body instanceof URLSearchParams || body instanceof FormData);
|
|
11277
12296
|
if (
|
|
11278
12297
|
// Pass raw type verbatim
|
|
11279
12298
|
ArrayBuffer.isView(body) || body instanceof ArrayBuffer || body instanceof DataView || typeof body === "string" && // Preserve legacy string encoding behavior for now
|
|
@@ -11281,7 +12300,7 @@ var OpenAI = class {
|
|
|
11281
12300
|
globalThis.Blob && body instanceof globalThis.Blob || // `FormData` -> `multipart/form-data`
|
|
11282
12301
|
body instanceof FormData || // `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
11283
12302
|
body instanceof URLSearchParams || // Send chunked stream (each chunk has own `length`)
|
|
11284
|
-
|
|
12303
|
+
isReadableStream2
|
|
11285
12304
|
) {
|
|
11286
12305
|
return { bodyHeaders: void 0, body, isStreamingBody: !isRetryableBody };
|
|
11287
12306
|
} else if (typeof body === "object" && (Symbol.asyncIterator in body || Symbol.iterator in body && "next" in body && typeof body.next === "function")) {
|
|
@@ -11302,7 +12321,7 @@ var OpenAI = class {
|
|
|
11302
12321
|
}
|
|
11303
12322
|
};
|
|
11304
12323
|
_a2 = OpenAI, _OpenAI_encoder = /* @__PURE__ */ new WeakMap(), _OpenAI_instances = /* @__PURE__ */ new WeakSet(), _OpenAI_baseURLOverridden = function _OpenAI_baseURLOverridden2() {
|
|
11305
|
-
return this.baseURL !== "https://api.openai.com/v1";
|
|
12324
|
+
return this._provider !== void 0 || this.baseURL !== "https://api.openai.com/v1";
|
|
11306
12325
|
};
|
|
11307
12326
|
OpenAI.OpenAI = _a2;
|
|
11308
12327
|
OpenAI.DEFAULT_TIMEOUT = 6e5;
|
|
@@ -11321,6 +12340,7 @@ OpenAI.PermissionDeniedError = PermissionDeniedError;
|
|
|
11321
12340
|
OpenAI.UnprocessableEntityError = UnprocessableEntityError;
|
|
11322
12341
|
OpenAI.InvalidWebhookSignatureError = InvalidWebhookSignatureError;
|
|
11323
12342
|
OpenAI.toFile = toFile;
|
|
12343
|
+
OpenAI.toStreamingFile = toStreamingFile;
|
|
11324
12344
|
OpenAI.Completions = Completions2;
|
|
11325
12345
|
OpenAI.Chat = Chat;
|
|
11326
12346
|
OpenAI.Embeddings = Embeddings;
|
|
@@ -11337,7 +12357,7 @@ OpenAI.Beta = Beta;
|
|
|
11337
12357
|
OpenAI.Batches = Batches;
|
|
11338
12358
|
OpenAI.Uploads = Uploads;
|
|
11339
12359
|
OpenAI.Admin = Admin;
|
|
11340
|
-
OpenAI.Responses =
|
|
12360
|
+
OpenAI.Responses = Responses2;
|
|
11341
12361
|
OpenAI.Realtime = Realtime2;
|
|
11342
12362
|
OpenAI.Conversations = Conversations;
|
|
11343
12363
|
OpenAI.Evals = Evals;
|
|
@@ -15596,7 +16616,8 @@ async function deployPromptAdvisor(args) {
|
|
|
15596
16616
|
model,
|
|
15597
16617
|
instructions,
|
|
15598
16618
|
reasoningEffort,
|
|
15599
|
-
metadata: { persona: args.persona, personaVersion, fillableFieldValues: JSON.stringify(valuesMap) }
|
|
16619
|
+
metadata: { persona: args.persona, personaVersion, fillableFieldValues: JSON.stringify(valuesMap) },
|
|
16620
|
+
...args.onNotice ? { onNotice: args.onNotice } : {}
|
|
15600
16621
|
});
|
|
15601
16622
|
}
|
|
15602
16623
|
|
|
@@ -15684,7 +16705,11 @@ var AgentDeployAdvisorCommand = class extends M8tCommand {
|
|
|
15684
16705
|
repoRoot,
|
|
15685
16706
|
persona,
|
|
15686
16707
|
agentName,
|
|
15687
|
-
model: typeof this.model === "string" ? this.model : void 0
|
|
16708
|
+
model: typeof this.model === "string" ? this.model : void 0,
|
|
16709
|
+
// undefined in --output json, which is how the installer runs this command:
|
|
16710
|
+
// its retry classifier jq-parses the captured stream and a stray line there
|
|
16711
|
+
// would make a transient failure look non-retryable.
|
|
16712
|
+
...onProgress ? { onNotice: onProgress } : {}
|
|
15688
16713
|
});
|
|
15689
16714
|
if (mode === "json") {
|
|
15690
16715
|
this.context.stdout.write(
|
|
@@ -26553,7 +27578,7 @@ function buildOccupiedRefusal(args) {
|
|
|
26553
27578
|
// src/commands/bootstrap/launch.ts
|
|
26554
27579
|
var DEFAULT_RG = "rg-m8t-stack";
|
|
26555
27580
|
var DEFAULT_INSTALLER = "ghcr.io/m8t-labs/m8t-installer";
|
|
26556
|
-
var DEFAULT_INSTALLER_TAG = "v0.1.
|
|
27581
|
+
var DEFAULT_INSTALLER_TAG = "v0.1.43";
|
|
26557
27582
|
var ACI_NAME = "m8t-installer";
|
|
26558
27583
|
var MI_NAME = "m8t-installer-mi";
|
|
26559
27584
|
var BootstrapLaunchCommand = class extends M8tCommand {
|