randmarcomps 1.492.0 → 1.494.0
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/randmarcomps.js +1376 -47
- package/dist/randmarcomps.umd.cjs +168 -68
- package/package.json +2 -2
package/dist/randmarcomps.js
CHANGED
|
@@ -5329,7 +5329,7 @@ var __assign$1 = function() {
|
|
|
5329
5329
|
return t;
|
|
5330
5330
|
}, __assign$1.apply(this, arguments);
|
|
5331
5331
|
};
|
|
5332
|
-
function __rest(e, t) {
|
|
5332
|
+
function __rest$1(e, t) {
|
|
5333
5333
|
var n = {};
|
|
5334
5334
|
for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
|
|
5335
5335
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -5452,7 +5452,7 @@ function createSidecarMedium(e) {
|
|
|
5452
5452
|
return t.options = __assign$1({ async: !0, ssr: !1 }, e), t;
|
|
5453
5453
|
}
|
|
5454
5454
|
var SideCar$1 = function(e) {
|
|
5455
|
-
var t = e.sideCar, n = __rest(e, ["sideCar"]);
|
|
5455
|
+
var t = e.sideCar, n = __rest$1(e, ["sideCar"]);
|
|
5456
5456
|
if (!t)
|
|
5457
5457
|
throw new Error("Sidecar: please provide `sideCar` property to import the right car");
|
|
5458
5458
|
var o = t.read();
|
|
@@ -5470,7 +5470,7 @@ var effectCar = createSidecarMedium(), nothing = function() {
|
|
|
5470
5470
|
onScrollCapture: nothing,
|
|
5471
5471
|
onWheelCapture: nothing,
|
|
5472
5472
|
onTouchMoveCapture: nothing
|
|
5473
|
-
}), l = o[0], d = o[1], f = e.forwardProps, g = e.children, b = e.className, S = e.removeScrollBar, _ = e.enabled, C = e.shards, E = e.sideCar, R = e.noRelative, A = e.noIsolation, M = e.inert, I = e.allowPinchZoom, V = e.as, q = V === void 0 ? "div" : V, Q = e.gapMode, te = __rest(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), j = E, F = useMergeRefs([n, t]), ne = __assign$1(__assign$1({}, te), l);
|
|
5473
|
+
}), l = o[0], d = o[1], f = e.forwardProps, g = e.children, b = e.className, S = e.removeScrollBar, _ = e.enabled, C = e.shards, E = e.sideCar, R = e.noRelative, A = e.noIsolation, M = e.inert, I = e.allowPinchZoom, V = e.as, q = V === void 0 ? "div" : V, Q = e.gapMode, te = __rest$1(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noRelative", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]), j = E, F = useMergeRefs([n, t]), ne = __assign$1(__assign$1({}, te), l);
|
|
5474
5474
|
return React.createElement(
|
|
5475
5475
|
React.Fragment,
|
|
5476
5476
|
null,
|
|
@@ -7321,8 +7321,8 @@ const offset$1 = offset$2, shift$2 = shift$3, flip$1 = flip$2, size$1 = size$2,
|
|
|
7321
7321
|
platform: d
|
|
7322
7322
|
});
|
|
7323
7323
|
};
|
|
7324
|
-
var isClient = typeof document < "u", noop$
|
|
7325
|
-
}, index = isClient ? useLayoutEffect : noop$
|
|
7324
|
+
var isClient = typeof document < "u", noop$3 = function() {
|
|
7325
|
+
}, index = isClient ? useLayoutEffect : noop$3;
|
|
7326
7326
|
function deepEqual$3(e, t) {
|
|
7327
7327
|
if (e === t)
|
|
7328
7328
|
return !0;
|
|
@@ -9001,7 +9001,7 @@ function die(e, ...t) {
|
|
|
9001
9001
|
var O = Object, getPrototypeOf$1 = O.getPrototypeOf, CONSTRUCTOR = "constructor", PROTOTYPE = "prototype", CONFIGURABLE = "configurable", ENUMERABLE = "enumerable", WRITABLE = "writable", VALUE = "value", isDraft = (e) => !!e && !!e[DRAFT_STATE];
|
|
9002
9002
|
function isDraftable(e) {
|
|
9003
9003
|
var t;
|
|
9004
|
-
return e ? isPlainObject$3(e) || isArray$
|
|
9004
|
+
return e ? isPlainObject$3(e) || isArray$3(e) || !!e[DRAFTABLE] || !!((t = e[CONSTRUCTOR]) != null && t[DRAFTABLE]) || isMap(e) || isSet(e) : !1;
|
|
9005
9005
|
}
|
|
9006
9006
|
var objectCtorString = O[PROTOTYPE][CONSTRUCTOR].toString(), cachedCtorStrings = /* @__PURE__ */ new WeakMap();
|
|
9007
9007
|
function isPlainObject$3(e) {
|
|
@@ -9028,7 +9028,7 @@ function each(e, t, n = !0) {
|
|
|
9028
9028
|
}
|
|
9029
9029
|
function getArchtype(e) {
|
|
9030
9030
|
const t = e[DRAFT_STATE];
|
|
9031
|
-
return t ? t.type_ : isArray$
|
|
9031
|
+
return t ? t.type_ : isArray$3(e) ? 1 : isMap(e) ? 2 : isSet(e) ? 3 : 0;
|
|
9032
9032
|
}
|
|
9033
9033
|
var has$1 = (e, t, n = getArchtype(e)) => n === 2 ? e.has(t) : O[PROTOTYPE].hasOwnProperty.call(e, t), get$3 = (e, t, n = getArchtype(e)) => (
|
|
9034
9034
|
// @ts-ignore
|
|
@@ -9039,13 +9039,13 @@ var has$1 = (e, t, n = getArchtype(e)) => n === 2 ? e.has(t) : O[PROTOTYPE].hasO
|
|
|
9039
9039
|
function is$1(e, t) {
|
|
9040
9040
|
return e === t ? e !== 0 || 1 / e === 1 / t : e !== e && t !== t;
|
|
9041
9041
|
}
|
|
9042
|
-
var isArray$
|
|
9042
|
+
var isArray$3 = Array.isArray, isMap = (e) => e instanceof Map, isSet = (e) => e instanceof Set, isObjectish = (e) => typeof e == "object", isFunction$6 = (e) => typeof e == "function", isBoolean$2 = (e) => typeof e == "boolean", getProxyDraft = (e) => isObjectish(e) ? e == null ? void 0 : e[DRAFT_STATE] : null, latest = (e) => e.copy_ || e.base_, getFinalValue = (e) => e.modified_ ? e.copy_ : e.base_;
|
|
9043
9043
|
function shallowCopy(e, t) {
|
|
9044
9044
|
if (isMap(e))
|
|
9045
9045
|
return new Map(e);
|
|
9046
9046
|
if (isSet(e))
|
|
9047
9047
|
return new Set(e);
|
|
9048
|
-
if (isArray$
|
|
9048
|
+
if (isArray$3(e))
|
|
9049
9049
|
return Array[PROTOTYPE].slice.call(e);
|
|
9050
9050
|
const n = isPlainObject$3(e);
|
|
9051
9051
|
if (t === !0 || t === "class_only" && !n) {
|
|
@@ -9241,7 +9241,7 @@ function handleValue(e, t, n) {
|
|
|
9241
9241
|
})), e;
|
|
9242
9242
|
}
|
|
9243
9243
|
function createProxyProxy(e, t) {
|
|
9244
|
-
const n = isArray$
|
|
9244
|
+
const n = isArray$3(e), o = {
|
|
9245
9245
|
type_: n ? 1 : 0,
|
|
9246
9246
|
// Track which produce call this is associated with.
|
|
9247
9247
|
scope_: t ? t.scope_ : getCurrentScope(),
|
|
@@ -9735,7 +9735,7 @@ function enablePatches() {
|
|
|
9735
9735
|
function E(A) {
|
|
9736
9736
|
if (!isDraftable(A))
|
|
9737
9737
|
return A;
|
|
9738
|
-
if (isArray$
|
|
9738
|
+
if (isArray$3(A))
|
|
9739
9739
|
return A.map(E);
|
|
9740
9740
|
if (isMap(A))
|
|
9741
9741
|
return new Map(
|
|
@@ -10517,13 +10517,13 @@ function handleThunkCaseReducerDefinition({
|
|
|
10517
10517
|
options: _
|
|
10518
10518
|
} = n, C = l(e, d, _);
|
|
10519
10519
|
o.exposeAction(t, C), f && o.addCase(C.fulfilled, f), g && o.addCase(C.pending, g), b && o.addCase(C.rejected, b), S && o.addMatcher(C.settled, S), o.exposeCaseReducer(t, {
|
|
10520
|
-
fulfilled: f || noop$
|
|
10521
|
-
pending: g || noop$
|
|
10522
|
-
rejected: b || noop$
|
|
10523
|
-
settled: S || noop$
|
|
10520
|
+
fulfilled: f || noop$2,
|
|
10521
|
+
pending: g || noop$2,
|
|
10522
|
+
rejected: b || noop$2,
|
|
10523
|
+
settled: S || noop$2
|
|
10524
10524
|
});
|
|
10525
10525
|
}
|
|
10526
|
-
function noop$
|
|
10526
|
+
function noop$2() {
|
|
10527
10527
|
}
|
|
10528
10528
|
function formatProdErrorMessage(e) {
|
|
10529
10529
|
return `Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `;
|
|
@@ -20512,7 +20512,7 @@ function Symbol$1(e, t) {
|
|
|
20512
20512
|
return arguments.length ? (n = d ?? null, l) : n;
|
|
20513
20513
|
}, l;
|
|
20514
20514
|
}
|
|
20515
|
-
function noop() {
|
|
20515
|
+
function noop$1() {
|
|
20516
20516
|
}
|
|
20517
20517
|
function point$2(e, t, n) {
|
|
20518
20518
|
e._context.bezierCurveTo(
|
|
@@ -20573,8 +20573,8 @@ function BasisClosed(e) {
|
|
|
20573
20573
|
this._context = e;
|
|
20574
20574
|
}
|
|
20575
20575
|
BasisClosed.prototype = {
|
|
20576
|
-
areaStart: noop,
|
|
20577
|
-
areaEnd: noop,
|
|
20576
|
+
areaStart: noop$1,
|
|
20577
|
+
areaEnd: noop$1,
|
|
20578
20578
|
lineStart: function() {
|
|
20579
20579
|
this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = NaN, this._point = 0;
|
|
20580
20580
|
},
|
|
@@ -20661,8 +20661,8 @@ function LinearClosed(e) {
|
|
|
20661
20661
|
this._context = e;
|
|
20662
20662
|
}
|
|
20663
20663
|
LinearClosed.prototype = {
|
|
20664
|
-
areaStart: noop,
|
|
20665
|
-
areaEnd: noop,
|
|
20664
|
+
areaStart: noop$1,
|
|
20665
|
+
areaEnd: noop$1,
|
|
20666
20666
|
lineStart: function() {
|
|
20667
20667
|
this._point = 0;
|
|
20668
20668
|
},
|
|
@@ -29584,7 +29584,7 @@ function getShortTag(e) {
|
|
|
29584
29584
|
function getStrictProperties(e) {
|
|
29585
29585
|
return getOwnPropertyNames(e).concat(getOwnPropertySymbols(e));
|
|
29586
29586
|
}
|
|
29587
|
-
var hasOwn$
|
|
29587
|
+
var hasOwn$2 = (
|
|
29588
29588
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
29589
29589
|
Object.hasOwn || (function(e, t) {
|
|
29590
29590
|
return hasOwnProperty$1.call(e, t);
|
|
@@ -29694,9 +29694,9 @@ function areUrlsEqual(e, t) {
|
|
|
29694
29694
|
return e.hostname === t.hostname && e.pathname === t.pathname && e.protocol === t.protocol && e.port === t.port && e.hash === t.hash && e.username === t.username && e.password === t.password;
|
|
29695
29695
|
}
|
|
29696
29696
|
function isPropertyEqual(e, t, n, o) {
|
|
29697
|
-
return (o === REACT_OWNER || o === PREACT_OWNER || o === PREACT_VNODE) && (e.$$typeof || t.$$typeof) ? !0 : hasOwn$
|
|
29697
|
+
return (o === REACT_OWNER || o === PREACT_OWNER || o === PREACT_VNODE) && (e.$$typeof || t.$$typeof) ? !0 : hasOwn$2(t, o) && n.equals(e[o], t[o], o, o, e, t, n);
|
|
29698
29698
|
}
|
|
29699
|
-
var ARGUMENTS_TAG = "[object Arguments]", BOOLEAN_TAG = "[object Boolean]", DATE_TAG = "[object Date]", ERROR_TAG = "[object Error]", MAP_TAG = "[object Map]", NUMBER_TAG = "[object Number]", OBJECT_TAG = "[object Object]", REG_EXP_TAG = "[object RegExp]", SET_TAG = "[object Set]", STRING_TAG = "[object String]", URL_TAG = "[object URL]", isArray$
|
|
29699
|
+
var ARGUMENTS_TAG = "[object Arguments]", BOOLEAN_TAG = "[object Boolean]", DATE_TAG = "[object Date]", ERROR_TAG = "[object Error]", MAP_TAG = "[object Map]", NUMBER_TAG = "[object Number]", OBJECT_TAG = "[object Object]", REG_EXP_TAG = "[object RegExp]", SET_TAG = "[object Set]", STRING_TAG = "[object String]", URL_TAG = "[object URL]", isArray$2 = Array.isArray, isTypedArray = typeof ArrayBuffer < "u" && typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView : null, assign = Object.assign, getTag = Object.prototype.toString.call.bind(Object.prototype.toString);
|
|
29700
29700
|
function createEqualityComparator(e) {
|
|
29701
29701
|
var t = e.areArraysEqual, n = e.areDatesEqual, o = e.areErrorsEqual, l = e.areFunctionsEqual, d = e.areMapsEqual, f = e.areNumbersEqual, g = e.areObjectsEqual, b = e.arePrimitiveWrappersEqual, S = e.areRegExpsEqual, _ = e.areSetsEqual, C = e.areTypedArraysEqual, E = e.areUrlsEqual, R = e.unknownTagComparators;
|
|
29702
29702
|
return function(M, I, V) {
|
|
@@ -29714,7 +29714,7 @@ function createEqualityComparator(e) {
|
|
|
29714
29714
|
return !1;
|
|
29715
29715
|
if (Q === Object)
|
|
29716
29716
|
return g(M, I, V);
|
|
29717
|
-
if (isArray$
|
|
29717
|
+
if (isArray$2(M))
|
|
29718
29718
|
return t(M, I, V);
|
|
29719
29719
|
if (isTypedArray != null && isTypedArray(M))
|
|
29720
29720
|
return C(M, I, V);
|
|
@@ -43450,7 +43450,7 @@ class NullLogger {
|
|
|
43450
43450
|
}
|
|
43451
43451
|
}
|
|
43452
43452
|
NullLogger.instance = new NullLogger();
|
|
43453
|
-
const VERSION = "8.0.17";
|
|
43453
|
+
const VERSION$1 = "8.0.17";
|
|
43454
43454
|
class Arg {
|
|
43455
43455
|
static isRequired(t, n) {
|
|
43456
43456
|
if (t == null)
|
|
@@ -43552,7 +43552,7 @@ class ConsoleLogger {
|
|
|
43552
43552
|
}
|
|
43553
43553
|
function getUserAgentHeader() {
|
|
43554
43554
|
let e = "X-SignalR-User-Agent";
|
|
43555
|
-
return Platform.isNode && (e = "User-Agent"), [e, constructUserAgent(VERSION, getOsName(), getRuntime(), getRuntimeVersion())];
|
|
43555
|
+
return Platform.isNode && (e = "User-Agent"), [e, constructUserAgent(VERSION$1, getOsName(), getRuntime(), getRuntimeVersion())];
|
|
43556
43556
|
}
|
|
43557
43557
|
function constructUserAgent(e, t, n, o) {
|
|
43558
43558
|
let l = "Microsoft SignalR/";
|
|
@@ -45001,7 +45001,7 @@ const LogLevelNameMapping = {
|
|
|
45001
45001
|
critical: LogLevel.Critical,
|
|
45002
45002
|
none: LogLevel.None
|
|
45003
45003
|
};
|
|
45004
|
-
function parseLogLevel(e) {
|
|
45004
|
+
function parseLogLevel$1(e) {
|
|
45005
45005
|
const t = LogLevelNameMapping[e.toLowerCase()];
|
|
45006
45006
|
if (typeof t < "u")
|
|
45007
45007
|
return t;
|
|
@@ -45012,7 +45012,7 @@ class HubConnectionBuilder {
|
|
|
45012
45012
|
if (Arg.isRequired(t, "logging"), isLogger(t))
|
|
45013
45013
|
this.logger = t;
|
|
45014
45014
|
else if (typeof t == "string") {
|
|
45015
|
-
const n = parseLogLevel(t);
|
|
45015
|
+
const n = parseLogLevel$1(t);
|
|
45016
45016
|
this.logger = new ConsoleLogger(n);
|
|
45017
45017
|
} else
|
|
45018
45018
|
this.logger = new ConsoleLogger(t);
|
|
@@ -45444,7 +45444,7 @@ var HarmBlockThreshold;
|
|
|
45444
45444
|
})(HarmBlockThreshold || (HarmBlockThreshold = {}));
|
|
45445
45445
|
var FinishReason;
|
|
45446
45446
|
(function(e) {
|
|
45447
|
-
e.FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", e.STOP = "STOP", e.MAX_TOKENS = "MAX_TOKENS", e.SAFETY = "SAFETY", e.RECITATION = "RECITATION", e.LANGUAGE = "LANGUAGE", e.OTHER = "OTHER", e.BLOCKLIST = "BLOCKLIST", e.PROHIBITED_CONTENT = "PROHIBITED_CONTENT", e.SPII = "SPII", e.MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL", e.IMAGE_SAFETY = "IMAGE_SAFETY", e.UNEXPECTED_TOOL_CALL = "UNEXPECTED_TOOL_CALL", e.IMAGE_PROHIBITED_CONTENT = "IMAGE_PROHIBITED_CONTENT", e.NO_IMAGE = "NO_IMAGE";
|
|
45447
|
+
e.FINISH_REASON_UNSPECIFIED = "FINISH_REASON_UNSPECIFIED", e.STOP = "STOP", e.MAX_TOKENS = "MAX_TOKENS", e.SAFETY = "SAFETY", e.RECITATION = "RECITATION", e.LANGUAGE = "LANGUAGE", e.OTHER = "OTHER", e.BLOCKLIST = "BLOCKLIST", e.PROHIBITED_CONTENT = "PROHIBITED_CONTENT", e.SPII = "SPII", e.MALFORMED_FUNCTION_CALL = "MALFORMED_FUNCTION_CALL", e.IMAGE_SAFETY = "IMAGE_SAFETY", e.UNEXPECTED_TOOL_CALL = "UNEXPECTED_TOOL_CALL", e.IMAGE_PROHIBITED_CONTENT = "IMAGE_PROHIBITED_CONTENT", e.NO_IMAGE = "NO_IMAGE", e.IMAGE_RECITATION = "IMAGE_RECITATION", e.IMAGE_OTHER = "IMAGE_OTHER";
|
|
45448
45448
|
})(FinishReason || (FinishReason = {}));
|
|
45449
45449
|
var HarmProbability;
|
|
45450
45450
|
(function(e) {
|
|
@@ -45582,6 +45582,10 @@ var MediaModality;
|
|
|
45582
45582
|
(function(e) {
|
|
45583
45583
|
e.MODALITY_UNSPECIFIED = "MODALITY_UNSPECIFIED", e.TEXT = "TEXT", e.IMAGE = "IMAGE", e.VIDEO = "VIDEO", e.AUDIO = "AUDIO", e.DOCUMENT = "DOCUMENT";
|
|
45584
45584
|
})(MediaModality || (MediaModality = {}));
|
|
45585
|
+
var VadSignalType;
|
|
45586
|
+
(function(e) {
|
|
45587
|
+
e.VAD_SIGNAL_TYPE_UNSPECIFIED = "VAD_SIGNAL_TYPE_UNSPECIFIED", e.VAD_SIGNAL_TYPE_SOS = "VAD_SIGNAL_TYPE_SOS", e.VAD_SIGNAL_TYPE_EOS = "VAD_SIGNAL_TYPE_EOS";
|
|
45588
|
+
})(VadSignalType || (VadSignalType = {}));
|
|
45585
45589
|
var StartSensitivity;
|
|
45586
45590
|
(function(e) {
|
|
45587
45591
|
e.START_SENSITIVITY_UNSPECIFIED = "START_SENSITIVITY_UNSPECIFIED", e.START_SENSITIVITY_HIGH = "START_SENSITIVITY_HIGH", e.START_SENSITIVITY_LOW = "START_SENSITIVITY_LOW";
|
|
@@ -47995,6 +47999,14 @@ class Caches extends BaseModule {
|
|
|
47995
47999
|
}
|
|
47996
48000
|
}
|
|
47997
48001
|
}
|
|
48002
|
+
function __rest(e, t) {
|
|
48003
|
+
var n = {};
|
|
48004
|
+
for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
|
|
48005
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
48006
|
+
for (var l = 0, o = Object.getOwnPropertySymbols(e); l < o.length; l++)
|
|
48007
|
+
t.indexOf(o[l]) < 0 && Object.prototype.propertyIsEnumerable.call(e, o[l]) && (n[o[l]] = e[o[l]]);
|
|
48008
|
+
return n;
|
|
48009
|
+
}
|
|
47998
48010
|
function __values(e) {
|
|
47999
48011
|
var t = typeof Symbol == "function" && Symbol.iterator, n = t && e[t], o = 0;
|
|
48000
48012
|
if (n) return n.call(e);
|
|
@@ -48771,7 +48783,9 @@ function liveConnectConfigToMldev$1(e, t) {
|
|
|
48771
48783
|
]);
|
|
48772
48784
|
t !== void 0 && te != null && setValueByPath(t, ["setup", "contextWindowCompression"], te);
|
|
48773
48785
|
const j = getValueByPath(e, ["proactivity"]);
|
|
48774
|
-
|
|
48786
|
+
if (t !== void 0 && j != null && setValueByPath(t, ["setup", "proactivity"], j), getValueByPath(e, ["explicitVadSignal"]) !== void 0)
|
|
48787
|
+
throw new Error("explicitVadSignal parameter is not supported in Gemini API.");
|
|
48788
|
+
return n;
|
|
48775
48789
|
}
|
|
48776
48790
|
function liveConnectConfigToVertex(e, t) {
|
|
48777
48791
|
const n = {}, o = getValueByPath(e, [
|
|
@@ -48814,8 +48828,8 @@ function liveConnectConfigToVertex(e, t) {
|
|
|
48814
48828
|
t !== void 0 && A != null && setValueByPath(t, ["setup", "systemInstruction"], tContent(A));
|
|
48815
48829
|
const M = getValueByPath(e, ["tools"]);
|
|
48816
48830
|
if (t !== void 0 && M != null) {
|
|
48817
|
-
let
|
|
48818
|
-
Array.isArray(
|
|
48831
|
+
let ne = tTools(M);
|
|
48832
|
+
Array.isArray(ne) && (ne = ne.map((ae) => toolToVertex$1(tTool(ae)))), setValueByPath(t, ["setup", "tools"], ne);
|
|
48819
48833
|
}
|
|
48820
48834
|
const I = getValueByPath(e, [
|
|
48821
48835
|
"sessionResumption"
|
|
@@ -48838,7 +48852,11 @@ function liveConnectConfigToVertex(e, t) {
|
|
|
48838
48852
|
]);
|
|
48839
48853
|
t !== void 0 && te != null && setValueByPath(t, ["setup", "contextWindowCompression"], te);
|
|
48840
48854
|
const j = getValueByPath(e, ["proactivity"]);
|
|
48841
|
-
|
|
48855
|
+
t !== void 0 && j != null && setValueByPath(t, ["setup", "proactivity"], j);
|
|
48856
|
+
const F = getValueByPath(e, [
|
|
48857
|
+
"explicitVadSignal"
|
|
48858
|
+
]);
|
|
48859
|
+
return t !== void 0 && F != null && setValueByPath(t, ["setup", "explicitVadSignal"], F), n;
|
|
48842
48860
|
}
|
|
48843
48861
|
function liveConnectParametersToMldev(e, t) {
|
|
48844
48862
|
const n = {}, o = getValueByPath(t, ["model"]);
|
|
@@ -48938,7 +48956,11 @@ function liveServerMessageFromVertex(e) {
|
|
|
48938
48956
|
const b = getValueByPath(e, [
|
|
48939
48957
|
"sessionResumptionUpdate"
|
|
48940
48958
|
]);
|
|
48941
|
-
|
|
48959
|
+
b != null && setValueByPath(t, ["sessionResumptionUpdate"], b);
|
|
48960
|
+
const S = getValueByPath(e, [
|
|
48961
|
+
"voiceActivityDetectionSignal"
|
|
48962
|
+
]);
|
|
48963
|
+
return S != null && setValueByPath(t, ["voiceActivityDetectionSignal"], S), t;
|
|
48942
48964
|
}
|
|
48943
48965
|
function partToMldev$2(e) {
|
|
48944
48966
|
const t = {}, n = getValueByPath(e, [
|
|
@@ -51101,7 +51123,7 @@ function uploadToFileSearchStoreResumableResponseFromMldev(e) {
|
|
|
51101
51123
|
* Copyright 2025 Google LLC
|
|
51102
51124
|
* SPDX-License-Identifier: Apache-2.0
|
|
51103
51125
|
*/
|
|
51104
|
-
const CONTENT_TYPE_HEADER = "Content-Type", SERVER_TIMEOUT_HEADER = "X-Server-Timeout", USER_AGENT_HEADER = "User-Agent", GOOGLE_API_CLIENT_HEADER = "x-goog-api-client", SDK_VERSION = "1.
|
|
51126
|
+
const CONTENT_TYPE_HEADER = "Content-Type", SERVER_TIMEOUT_HEADER = "X-Server-Timeout", USER_AGENT_HEADER = "User-Agent", GOOGLE_API_CLIENT_HEADER = "x-goog-api-client", SDK_VERSION = "1.33.0", LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`, VERTEX_AI_API_DEFAULT_VERSION = "v1beta1", GOOGLE_AI_API_DEFAULT_VERSION = "v1beta";
|
|
51105
51127
|
class ApiClient {
|
|
51106
51128
|
constructor(t) {
|
|
51107
51129
|
var n, o;
|
|
@@ -53250,7 +53272,9 @@ function liveConnectConfigToMldev(e, t) {
|
|
|
53250
53272
|
]);
|
|
53251
53273
|
t !== void 0 && te != null && setValueByPath(t, ["setup", "contextWindowCompression"], te);
|
|
53252
53274
|
const j = getValueByPath(e, ["proactivity"]);
|
|
53253
|
-
|
|
53275
|
+
if (t !== void 0 && j != null && setValueByPath(t, ["setup", "proactivity"], j), getValueByPath(e, ["explicitVadSignal"]) !== void 0)
|
|
53276
|
+
throw new Error("explicitVadSignal parameter is not supported in Gemini API.");
|
|
53277
|
+
return n;
|
|
53254
53278
|
}
|
|
53255
53279
|
function liveConnectConstraintsToMldev(e, t) {
|
|
53256
53280
|
const n = {}, o = getValueByPath(t, ["model"]);
|
|
@@ -53796,6 +53820,1273 @@ class FileSearchStores extends BaseModule {
|
|
|
53796
53820
|
}
|
|
53797
53821
|
}
|
|
53798
53822
|
}
|
|
53823
|
+
/**
|
|
53824
|
+
* @license
|
|
53825
|
+
* Copyright 2025 Google LLC
|
|
53826
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53827
|
+
*/
|
|
53828
|
+
let uuid4Internal = function() {
|
|
53829
|
+
const { crypto: e } = globalThis;
|
|
53830
|
+
if (e != null && e.randomUUID)
|
|
53831
|
+
return uuid4Internal = e.randomUUID.bind(e), e.randomUUID();
|
|
53832
|
+
const t = new Uint8Array(1), n = e ? () => e.getRandomValues(t)[0] : () => Math.random() * 255 & 255;
|
|
53833
|
+
return "10000000-1000-4000-8000-100000000000".replace(/[018]/g, (o) => (+o ^ n() & 15 >> +o / 4).toString(16));
|
|
53834
|
+
};
|
|
53835
|
+
const uuid4 = () => uuid4Internal();
|
|
53836
|
+
/**
|
|
53837
|
+
* @license
|
|
53838
|
+
* Copyright 2025 Google LLC
|
|
53839
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53840
|
+
*/
|
|
53841
|
+
function isAbortError(e) {
|
|
53842
|
+
return typeof e == "object" && e !== null && // Spec-compliant fetch implementations
|
|
53843
|
+
("name" in e && e.name === "AbortError" || // Expo fetch
|
|
53844
|
+
"message" in e && String(e.message).includes("FetchRequestCanceledException"));
|
|
53845
|
+
}
|
|
53846
|
+
const castToError = (e) => {
|
|
53847
|
+
if (e instanceof Error)
|
|
53848
|
+
return e;
|
|
53849
|
+
if (typeof e == "object" && e !== null) {
|
|
53850
|
+
try {
|
|
53851
|
+
if (Object.prototype.toString.call(e) === "[object Error]") {
|
|
53852
|
+
const t = new Error(e.message, e.cause ? { cause: e.cause } : {});
|
|
53853
|
+
return e.stack && (t.stack = e.stack), e.cause && !t.cause && (t.cause = e.cause), e.name && (t.name = e.name), t;
|
|
53854
|
+
}
|
|
53855
|
+
} catch {
|
|
53856
|
+
}
|
|
53857
|
+
try {
|
|
53858
|
+
return new Error(JSON.stringify(e));
|
|
53859
|
+
} catch {
|
|
53860
|
+
}
|
|
53861
|
+
}
|
|
53862
|
+
return new Error(e);
|
|
53863
|
+
};
|
|
53864
|
+
/**
|
|
53865
|
+
* @license
|
|
53866
|
+
* Copyright 2025 Google LLC
|
|
53867
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53868
|
+
*/
|
|
53869
|
+
class GeminiNextGenAPIClientError extends Error {
|
|
53870
|
+
}
|
|
53871
|
+
class APIError extends GeminiNextGenAPIClientError {
|
|
53872
|
+
constructor(t, n, o, l) {
|
|
53873
|
+
super(`${APIError.makeMessage(t, n, o)}`), this.status = t, this.headers = l, this.error = n;
|
|
53874
|
+
}
|
|
53875
|
+
static makeMessage(t, n, o) {
|
|
53876
|
+
const l = n != null && n.message ? typeof n.message == "string" ? n.message : JSON.stringify(n.message) : n ? JSON.stringify(n) : o;
|
|
53877
|
+
return t && l ? `${t} ${l}` : t ? `${t} status code (no body)` : l || "(no status code or body)";
|
|
53878
|
+
}
|
|
53879
|
+
static generate(t, n, o, l) {
|
|
53880
|
+
if (!t || !l)
|
|
53881
|
+
return new APIConnectionError({ message: o, cause: castToError(n) });
|
|
53882
|
+
const d = n;
|
|
53883
|
+
return t === 400 ? new BadRequestError(t, d, o, l) : t === 401 ? new AuthenticationError(t, d, o, l) : t === 403 ? new PermissionDeniedError(t, d, o, l) : t === 404 ? new NotFoundError(t, d, o, l) : t === 409 ? new ConflictError(t, d, o, l) : t === 422 ? new UnprocessableEntityError(t, d, o, l) : t === 429 ? new RateLimitError(t, d, o, l) : t >= 500 ? new InternalServerError(t, d, o, l) : new APIError(t, d, o, l);
|
|
53884
|
+
}
|
|
53885
|
+
}
|
|
53886
|
+
class APIUserAbortError extends APIError {
|
|
53887
|
+
constructor({ message: t } = {}) {
|
|
53888
|
+
super(void 0, void 0, t || "Request was aborted.", void 0);
|
|
53889
|
+
}
|
|
53890
|
+
}
|
|
53891
|
+
class APIConnectionError extends APIError {
|
|
53892
|
+
constructor({ message: t, cause: n }) {
|
|
53893
|
+
super(void 0, void 0, t || "Connection error.", void 0), n && (this.cause = n);
|
|
53894
|
+
}
|
|
53895
|
+
}
|
|
53896
|
+
class APIConnectionTimeoutError extends APIConnectionError {
|
|
53897
|
+
constructor({ message: t } = {}) {
|
|
53898
|
+
super({ message: t ?? "Request timed out." });
|
|
53899
|
+
}
|
|
53900
|
+
}
|
|
53901
|
+
class BadRequestError extends APIError {
|
|
53902
|
+
}
|
|
53903
|
+
class AuthenticationError extends APIError {
|
|
53904
|
+
}
|
|
53905
|
+
class PermissionDeniedError extends APIError {
|
|
53906
|
+
}
|
|
53907
|
+
class NotFoundError extends APIError {
|
|
53908
|
+
}
|
|
53909
|
+
class ConflictError extends APIError {
|
|
53910
|
+
}
|
|
53911
|
+
class UnprocessableEntityError extends APIError {
|
|
53912
|
+
}
|
|
53913
|
+
class RateLimitError extends APIError {
|
|
53914
|
+
}
|
|
53915
|
+
class InternalServerError extends APIError {
|
|
53916
|
+
}
|
|
53917
|
+
/**
|
|
53918
|
+
* @license
|
|
53919
|
+
* Copyright 2025 Google LLC
|
|
53920
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53921
|
+
*/
|
|
53922
|
+
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i, isAbsoluteURL = (e) => startsWithSchemeRegexp.test(e);
|
|
53923
|
+
let isArrayInternal = (e) => (isArrayInternal = Array.isArray, isArrayInternal(e));
|
|
53924
|
+
const isArray$1 = isArrayInternal;
|
|
53925
|
+
let isReadonlyArrayInternal = isArray$1;
|
|
53926
|
+
const isReadonlyArray = isReadonlyArrayInternal;
|
|
53927
|
+
function isEmptyObj(e) {
|
|
53928
|
+
if (!e)
|
|
53929
|
+
return !0;
|
|
53930
|
+
for (const t in e)
|
|
53931
|
+
return !1;
|
|
53932
|
+
return !0;
|
|
53933
|
+
}
|
|
53934
|
+
function hasOwn$1(e, t) {
|
|
53935
|
+
return Object.prototype.hasOwnProperty.call(e, t);
|
|
53936
|
+
}
|
|
53937
|
+
const validatePositiveInteger = (e, t) => {
|
|
53938
|
+
if (typeof t != "number" || !Number.isInteger(t))
|
|
53939
|
+
throw new GeminiNextGenAPIClientError(`${e} must be an integer`);
|
|
53940
|
+
if (t < 0)
|
|
53941
|
+
throw new GeminiNextGenAPIClientError(`${e} must be a positive integer`);
|
|
53942
|
+
return t;
|
|
53943
|
+
}, safeJSON = (e) => {
|
|
53944
|
+
try {
|
|
53945
|
+
return JSON.parse(e);
|
|
53946
|
+
} catch {
|
|
53947
|
+
return;
|
|
53948
|
+
}
|
|
53949
|
+
};
|
|
53950
|
+
/**
|
|
53951
|
+
* @license
|
|
53952
|
+
* Copyright 2025 Google LLC
|
|
53953
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53954
|
+
*/
|
|
53955
|
+
const sleep$1 = (e) => new Promise((t) => setTimeout(t, e));
|
|
53956
|
+
/**
|
|
53957
|
+
* @license
|
|
53958
|
+
* Copyright 2025 Google LLC
|
|
53959
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53960
|
+
*/
|
|
53961
|
+
const VERSION = "0.0.1";
|
|
53962
|
+
/**
|
|
53963
|
+
* @license
|
|
53964
|
+
* Copyright 2025 Google LLC
|
|
53965
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
53966
|
+
*/
|
|
53967
|
+
function getDetectedPlatform() {
|
|
53968
|
+
return typeof Deno < "u" && Deno.build != null ? "deno" : typeof EdgeRuntime < "u" ? "edge" : Object.prototype.toString.call(typeof globalThis.process < "u" ? globalThis.process : 0) === "[object process]" ? "node" : "unknown";
|
|
53969
|
+
}
|
|
53970
|
+
const getPlatformProperties = () => {
|
|
53971
|
+
var e, t, n, o, l;
|
|
53972
|
+
const d = getDetectedPlatform();
|
|
53973
|
+
if (d === "deno")
|
|
53974
|
+
return {
|
|
53975
|
+
"X-Stainless-Lang": "js",
|
|
53976
|
+
"X-Stainless-Package-Version": VERSION,
|
|
53977
|
+
"X-Stainless-OS": normalizePlatform(Deno.build.os),
|
|
53978
|
+
"X-Stainless-Arch": normalizeArch(Deno.build.arch),
|
|
53979
|
+
"X-Stainless-Runtime": "deno",
|
|
53980
|
+
"X-Stainless-Runtime-Version": typeof Deno.version == "string" ? Deno.version : (t = (e = Deno.version) === null || e === void 0 ? void 0 : e.deno) !== null && t !== void 0 ? t : "unknown"
|
|
53981
|
+
};
|
|
53982
|
+
if (typeof EdgeRuntime < "u")
|
|
53983
|
+
return {
|
|
53984
|
+
"X-Stainless-Lang": "js",
|
|
53985
|
+
"X-Stainless-Package-Version": VERSION,
|
|
53986
|
+
"X-Stainless-OS": "Unknown",
|
|
53987
|
+
"X-Stainless-Arch": `other:${EdgeRuntime}`,
|
|
53988
|
+
"X-Stainless-Runtime": "edge",
|
|
53989
|
+
"X-Stainless-Runtime-Version": globalThis.process.version
|
|
53990
|
+
};
|
|
53991
|
+
if (d === "node")
|
|
53992
|
+
return {
|
|
53993
|
+
"X-Stainless-Lang": "js",
|
|
53994
|
+
"X-Stainless-Package-Version": VERSION,
|
|
53995
|
+
"X-Stainless-OS": normalizePlatform((n = globalThis.process.platform) !== null && n !== void 0 ? n : "unknown"),
|
|
53996
|
+
"X-Stainless-Arch": normalizeArch((o = globalThis.process.arch) !== null && o !== void 0 ? o : "unknown"),
|
|
53997
|
+
"X-Stainless-Runtime": "node",
|
|
53998
|
+
"X-Stainless-Runtime-Version": (l = globalThis.process.version) !== null && l !== void 0 ? l : "unknown"
|
|
53999
|
+
};
|
|
54000
|
+
const f = getBrowserInfo();
|
|
54001
|
+
return f ? {
|
|
54002
|
+
"X-Stainless-Lang": "js",
|
|
54003
|
+
"X-Stainless-Package-Version": VERSION,
|
|
54004
|
+
"X-Stainless-OS": "Unknown",
|
|
54005
|
+
"X-Stainless-Arch": "unknown",
|
|
54006
|
+
"X-Stainless-Runtime": `browser:${f.browser}`,
|
|
54007
|
+
"X-Stainless-Runtime-Version": f.version
|
|
54008
|
+
} : {
|
|
54009
|
+
"X-Stainless-Lang": "js",
|
|
54010
|
+
"X-Stainless-Package-Version": VERSION,
|
|
54011
|
+
"X-Stainless-OS": "Unknown",
|
|
54012
|
+
"X-Stainless-Arch": "unknown",
|
|
54013
|
+
"X-Stainless-Runtime": "unknown",
|
|
54014
|
+
"X-Stainless-Runtime-Version": "unknown"
|
|
54015
|
+
};
|
|
54016
|
+
};
|
|
54017
|
+
function getBrowserInfo() {
|
|
54018
|
+
if (typeof navigator > "u" || !navigator)
|
|
54019
|
+
return null;
|
|
54020
|
+
const e = [
|
|
54021
|
+
{ key: "edge", pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
54022
|
+
{ key: "ie", pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
54023
|
+
{ key: "ie", pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
54024
|
+
{ key: "chrome", pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
54025
|
+
{ key: "firefox", pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
54026
|
+
{ key: "safari", pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ }
|
|
54027
|
+
];
|
|
54028
|
+
for (const { key: t, pattern: n } of e) {
|
|
54029
|
+
const o = n.exec(navigator.userAgent);
|
|
54030
|
+
if (o) {
|
|
54031
|
+
const l = o[1] || 0, d = o[2] || 0, f = o[3] || 0;
|
|
54032
|
+
return { browser: t, version: `${l}.${d}.${f}` };
|
|
54033
|
+
}
|
|
54034
|
+
}
|
|
54035
|
+
return null;
|
|
54036
|
+
}
|
|
54037
|
+
const normalizeArch = (e) => e === "x32" ? "x32" : e === "x86_64" || e === "x64" ? "x64" : e === "arm" ? "arm" : e === "aarch64" || e === "arm64" ? "arm64" : e ? `other:${e}` : "unknown", normalizePlatform = (e) => (e = e.toLowerCase(), e.includes("ios") ? "iOS" : e === "android" ? "Android" : e === "darwin" ? "MacOS" : e === "win32" ? "Windows" : e === "freebsd" ? "FreeBSD" : e === "openbsd" ? "OpenBSD" : e === "linux" ? "Linux" : e ? `Other:${e}` : "Unknown");
|
|
54038
|
+
let _platformHeaders;
|
|
54039
|
+
const getPlatformHeaders = () => _platformHeaders ?? (_platformHeaders = getPlatformProperties());
|
|
54040
|
+
/**
|
|
54041
|
+
* @license
|
|
54042
|
+
* Copyright 2025 Google LLC
|
|
54043
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54044
|
+
*/
|
|
54045
|
+
function getDefaultFetch() {
|
|
54046
|
+
if (typeof fetch < "u")
|
|
54047
|
+
return fetch;
|
|
54048
|
+
throw new Error("`fetch` is not defined as a global; Either pass `fetch` to the client, `new GeminiNextGenAPIClient({ fetch })` or polyfill the global, `globalThis.fetch = fetch`");
|
|
54049
|
+
}
|
|
54050
|
+
function makeReadableStream(...e) {
|
|
54051
|
+
const t = globalThis.ReadableStream;
|
|
54052
|
+
if (typeof t > "u")
|
|
54053
|
+
throw new Error("`ReadableStream` is not defined as a global; You will need to polyfill it, `globalThis.ReadableStream = ReadableStream`");
|
|
54054
|
+
return new t(...e);
|
|
54055
|
+
}
|
|
54056
|
+
function ReadableStreamFrom(e) {
|
|
54057
|
+
let t = Symbol.asyncIterator in e ? e[Symbol.asyncIterator]() : e[Symbol.iterator]();
|
|
54058
|
+
return makeReadableStream({
|
|
54059
|
+
start() {
|
|
54060
|
+
},
|
|
54061
|
+
async pull(n) {
|
|
54062
|
+
const { done: o, value: l } = await t.next();
|
|
54063
|
+
o ? n.close() : n.enqueue(l);
|
|
54064
|
+
},
|
|
54065
|
+
async cancel() {
|
|
54066
|
+
var n;
|
|
54067
|
+
await ((n = t.return) === null || n === void 0 ? void 0 : n.call(t));
|
|
54068
|
+
}
|
|
54069
|
+
});
|
|
54070
|
+
}
|
|
54071
|
+
function ReadableStreamToAsyncIterable(e) {
|
|
54072
|
+
if (e[Symbol.asyncIterator])
|
|
54073
|
+
return e;
|
|
54074
|
+
const t = e.getReader();
|
|
54075
|
+
return {
|
|
54076
|
+
async next() {
|
|
54077
|
+
try {
|
|
54078
|
+
const n = await t.read();
|
|
54079
|
+
return n != null && n.done && t.releaseLock(), n;
|
|
54080
|
+
} catch (n) {
|
|
54081
|
+
throw t.releaseLock(), n;
|
|
54082
|
+
}
|
|
54083
|
+
},
|
|
54084
|
+
async return() {
|
|
54085
|
+
const n = t.cancel();
|
|
54086
|
+
return t.releaseLock(), await n, { done: !0, value: void 0 };
|
|
54087
|
+
},
|
|
54088
|
+
[Symbol.asyncIterator]() {
|
|
54089
|
+
return this;
|
|
54090
|
+
}
|
|
54091
|
+
};
|
|
54092
|
+
}
|
|
54093
|
+
async function CancelReadableStream(e) {
|
|
54094
|
+
var t, n;
|
|
54095
|
+
if (e === null || typeof e != "object")
|
|
54096
|
+
return;
|
|
54097
|
+
if (e[Symbol.asyncIterator]) {
|
|
54098
|
+
await ((n = (t = e[Symbol.asyncIterator]()).return) === null || n === void 0 ? void 0 : n.call(t));
|
|
54099
|
+
return;
|
|
54100
|
+
}
|
|
54101
|
+
const o = e.getReader(), l = o.cancel();
|
|
54102
|
+
o.releaseLock(), await l;
|
|
54103
|
+
}
|
|
54104
|
+
/**
|
|
54105
|
+
* @license
|
|
54106
|
+
* Copyright 2025 Google LLC
|
|
54107
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54108
|
+
*/
|
|
54109
|
+
const FallbackEncoder = ({ headers: e, body: t }) => ({
|
|
54110
|
+
bodyHeaders: {
|
|
54111
|
+
"content-type": "application/json"
|
|
54112
|
+
},
|
|
54113
|
+
body: JSON.stringify(t)
|
|
54114
|
+
});
|
|
54115
|
+
/**
|
|
54116
|
+
* @license
|
|
54117
|
+
* Copyright 2025 Google LLC
|
|
54118
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54119
|
+
*/
|
|
54120
|
+
const checkFileSupport = () => {
|
|
54121
|
+
var e;
|
|
54122
|
+
if (typeof File > "u") {
|
|
54123
|
+
const { process: t } = globalThis, n = typeof ((e = t == null ? void 0 : t.versions) === null || e === void 0 ? void 0 : e.node) == "string" && parseInt(t.versions.node.split(".")) < 20;
|
|
54124
|
+
throw new Error("`File` is not defined as a global, which is required for file uploads." + (n ? " Update to Node 20 LTS or newer, or set `globalThis.File` to `import('node:buffer').File`." : ""));
|
|
54125
|
+
}
|
|
54126
|
+
};
|
|
54127
|
+
function makeFile(e, t, n) {
|
|
54128
|
+
return checkFileSupport(), new File(e, t ?? "unknown_file", n);
|
|
54129
|
+
}
|
|
54130
|
+
function getName(e) {
|
|
54131
|
+
return (typeof e == "object" && e !== null && ("name" in e && e.name && String(e.name) || "url" in e && e.url && String(e.url) || "filename" in e && e.filename && String(e.filename) || "path" in e && e.path && String(e.path)) || "").split(/[\\/]/).pop() || void 0;
|
|
54132
|
+
}
|
|
54133
|
+
const isAsyncIterable = (e) => e != null && typeof e == "object" && typeof e[Symbol.asyncIterator] == "function";
|
|
54134
|
+
/**
|
|
54135
|
+
* @license
|
|
54136
|
+
* Copyright 2025 Google LLC
|
|
54137
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54138
|
+
*/
|
|
54139
|
+
const isBlobLike = (e) => e != null && typeof e == "object" && typeof e.size == "number" && typeof e.type == "string" && typeof e.text == "function" && typeof e.slice == "function" && typeof e.arrayBuffer == "function", isFileLike = (e) => e != null && typeof e == "object" && typeof e.name == "string" && typeof e.lastModified == "number" && isBlobLike(e), isResponseLike = (e) => e != null && typeof e == "object" && typeof e.url == "string" && typeof e.blob == "function";
|
|
54140
|
+
async function toFile(e, t, n) {
|
|
54141
|
+
if (checkFileSupport(), e = await e, isFileLike(e))
|
|
54142
|
+
return e instanceof File ? e : makeFile([await e.arrayBuffer()], e.name);
|
|
54143
|
+
if (isResponseLike(e)) {
|
|
54144
|
+
const l = await e.blob();
|
|
54145
|
+
return t || (t = new URL(e.url).pathname.split(/[\\/]/).pop()), makeFile(await getBytes(l), t, n);
|
|
54146
|
+
}
|
|
54147
|
+
const o = await getBytes(e);
|
|
54148
|
+
if (t || (t = getName(e)), !(n != null && n.type)) {
|
|
54149
|
+
const l = o.find((d) => typeof d == "object" && "type" in d && d.type);
|
|
54150
|
+
typeof l == "string" && (n = Object.assign(Object.assign({}, n), { type: l }));
|
|
54151
|
+
}
|
|
54152
|
+
return makeFile(o, t, n);
|
|
54153
|
+
}
|
|
54154
|
+
async function getBytes(e) {
|
|
54155
|
+
var t, n, o, l, d;
|
|
54156
|
+
let f = [];
|
|
54157
|
+
if (typeof e == "string" || ArrayBuffer.isView(e) || // includes Uint8Array, Buffer, etc.
|
|
54158
|
+
e instanceof ArrayBuffer)
|
|
54159
|
+
f.push(e);
|
|
54160
|
+
else if (isBlobLike(e))
|
|
54161
|
+
f.push(e instanceof Blob ? e : await e.arrayBuffer());
|
|
54162
|
+
else if (isAsyncIterable(e))
|
|
54163
|
+
try {
|
|
54164
|
+
for (var g = !0, b = __asyncValues(e), S; S = await b.next(), t = S.done, !t; g = !0) {
|
|
54165
|
+
l = S.value, g = !1;
|
|
54166
|
+
const _ = l;
|
|
54167
|
+
f.push(...await getBytes(_));
|
|
54168
|
+
}
|
|
54169
|
+
} catch (_) {
|
|
54170
|
+
n = { error: _ };
|
|
54171
|
+
} finally {
|
|
54172
|
+
try {
|
|
54173
|
+
!g && !t && (o = b.return) && await o.call(b);
|
|
54174
|
+
} finally {
|
|
54175
|
+
if (n) throw n.error;
|
|
54176
|
+
}
|
|
54177
|
+
}
|
|
54178
|
+
else {
|
|
54179
|
+
const _ = (d = e == null ? void 0 : e.constructor) === null || d === void 0 ? void 0 : d.name;
|
|
54180
|
+
throw new Error(`Unexpected data type: ${typeof e}${_ ? `; constructor: ${_}` : ""}${propsForError(e)}`);
|
|
54181
|
+
}
|
|
54182
|
+
return f;
|
|
54183
|
+
}
|
|
54184
|
+
function propsForError(e) {
|
|
54185
|
+
return typeof e != "object" || e === null ? "" : `; props: [${Object.getOwnPropertyNames(e).map((n) => `"${n}"`).join(", ")}]`;
|
|
54186
|
+
}
|
|
54187
|
+
/**
|
|
54188
|
+
* @license
|
|
54189
|
+
* Copyright 2025 Google LLC
|
|
54190
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54191
|
+
*/
|
|
54192
|
+
class APIResource {
|
|
54193
|
+
constructor(t) {
|
|
54194
|
+
this._client = t;
|
|
54195
|
+
}
|
|
54196
|
+
}
|
|
54197
|
+
APIResource._key = [];
|
|
54198
|
+
/**
|
|
54199
|
+
* @license
|
|
54200
|
+
* Copyright 2025 Google LLC
|
|
54201
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54202
|
+
*/
|
|
54203
|
+
function encodeURIPath(e) {
|
|
54204
|
+
return e.replace(/[^A-Za-z0-9\-._~!$&'()*+,;=:@]+/g, encodeURIComponent);
|
|
54205
|
+
}
|
|
54206
|
+
const EMPTY = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.create(null)), createPathTagFunction = (e = encodeURIPath) => (function(n, ...o) {
|
|
54207
|
+
if (n.length === 1)
|
|
54208
|
+
return n[0];
|
|
54209
|
+
let l = !1;
|
|
54210
|
+
const d = [], f = n.reduce((_, C, E) => {
|
|
54211
|
+
var R, A, M;
|
|
54212
|
+
/[?#]/.test(C) && (l = !0);
|
|
54213
|
+
const I = o[E];
|
|
54214
|
+
let V = (l ? encodeURIComponent : e)("" + I);
|
|
54215
|
+
return E !== o.length && (I == null || typeof I == "object" && // handle values from other realms
|
|
54216
|
+
I.toString === ((M = Object.getPrototypeOf((A = Object.getPrototypeOf((R = I.hasOwnProperty) !== null && R !== void 0 ? R : EMPTY)) !== null && A !== void 0 ? A : EMPTY)) === null || M === void 0 ? void 0 : M.toString)) && (V = I + "", d.push({
|
|
54217
|
+
start: _.length + C.length,
|
|
54218
|
+
length: V.length,
|
|
54219
|
+
error: `Value of type ${Object.prototype.toString.call(I).slice(8, -1)} is not a valid path parameter`
|
|
54220
|
+
})), _ + C + (E === o.length ? "" : V);
|
|
54221
|
+
}, ""), g = f.split(/[?#]/, 1)[0], b = new RegExp("(?<=^|\\/)(?:\\.|%2e){1,2}(?=\\/|$)", "gi");
|
|
54222
|
+
let S;
|
|
54223
|
+
for (; (S = b.exec(g)) !== null; )
|
|
54224
|
+
d.push({
|
|
54225
|
+
start: S.index,
|
|
54226
|
+
length: S[0].length,
|
|
54227
|
+
error: `Value "${S[0]}" can't be safely passed as a path parameter`
|
|
54228
|
+
});
|
|
54229
|
+
if (d.sort((_, C) => _.start - C.start), d.length > 0) {
|
|
54230
|
+
let _ = 0;
|
|
54231
|
+
const C = d.reduce((E, R) => {
|
|
54232
|
+
const A = " ".repeat(R.start - _), M = "^".repeat(R.length);
|
|
54233
|
+
return _ = R.start + R.length, E + A + M;
|
|
54234
|
+
}, "");
|
|
54235
|
+
throw new GeminiNextGenAPIClientError(`Path parameters result in path with invalid segments:
|
|
54236
|
+
${d.map((E) => E.error).join(`
|
|
54237
|
+
`)}
|
|
54238
|
+
${f}
|
|
54239
|
+
${C}`);
|
|
54240
|
+
}
|
|
54241
|
+
return f;
|
|
54242
|
+
}), path = /* @__PURE__ */ createPathTagFunction(encodeURIPath);
|
|
54243
|
+
/**
|
|
54244
|
+
* @license
|
|
54245
|
+
* Copyright 2025 Google LLC
|
|
54246
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54247
|
+
*/
|
|
54248
|
+
class BaseInteractions extends APIResource {
|
|
54249
|
+
create(t, n) {
|
|
54250
|
+
var o;
|
|
54251
|
+
const { api_version: l = this._client.apiVersion } = t, d = __rest(t, ["api_version"]);
|
|
54252
|
+
if ("model" in d && "agent_config" in d)
|
|
54253
|
+
throw new GeminiNextGenAPIClientError("Invalid request: specified `model` and `agent_config`. If specifying `model`, use `generation_config`.");
|
|
54254
|
+
if ("agent" in d && "generation_config" in d)
|
|
54255
|
+
throw new GeminiNextGenAPIClientError("Invalid request: specified `agent` and `generation_config`. If specifying `agent`, use `agent_config`.");
|
|
54256
|
+
return this._client.post(path`/${l}/interactions`, Object.assign(Object.assign({ body: d }, n), { stream: (o = t.stream) !== null && o !== void 0 ? o : !1 }));
|
|
54257
|
+
}
|
|
54258
|
+
/**
|
|
54259
|
+
* Deletes the interaction by id.
|
|
54260
|
+
*
|
|
54261
|
+
* @example
|
|
54262
|
+
* ```ts
|
|
54263
|
+
* const interaction = await client.interactions.delete('id');
|
|
54264
|
+
* ```
|
|
54265
|
+
*/
|
|
54266
|
+
delete(t, n = {}, o) {
|
|
54267
|
+
const { api_version: l = this._client.apiVersion } = n ?? {};
|
|
54268
|
+
return this._client.delete(path`/${l}/interactions/${t}`, o);
|
|
54269
|
+
}
|
|
54270
|
+
/**
|
|
54271
|
+
* Cancels an interaction by id. This only applies to background interactions that are still running.
|
|
54272
|
+
*
|
|
54273
|
+
* @example
|
|
54274
|
+
* ```ts
|
|
54275
|
+
* const interaction = await client.interactions.cancel('id');
|
|
54276
|
+
* ```
|
|
54277
|
+
*/
|
|
54278
|
+
cancel(t, n = {}, o) {
|
|
54279
|
+
const { api_version: l = this._client.apiVersion } = n ?? {};
|
|
54280
|
+
return this._client.post(path`/${l}/interactions/${t}/cancel`, o);
|
|
54281
|
+
}
|
|
54282
|
+
get(t, n = {}, o) {
|
|
54283
|
+
var l;
|
|
54284
|
+
const d = n ?? {}, { api_version: f = this._client.apiVersion } = d, g = __rest(d, ["api_version"]);
|
|
54285
|
+
return this._client.get(path`/${f}/interactions/${t}`, Object.assign(Object.assign({ query: g }, o), { stream: (l = n == null ? void 0 : n.stream) !== null && l !== void 0 ? l : !1 }));
|
|
54286
|
+
}
|
|
54287
|
+
}
|
|
54288
|
+
BaseInteractions._key = Object.freeze(["interactions"]);
|
|
54289
|
+
class Interactions extends BaseInteractions {
|
|
54290
|
+
}
|
|
54291
|
+
/**
|
|
54292
|
+
* @license
|
|
54293
|
+
* Copyright 2025 Google LLC
|
|
54294
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54295
|
+
*/
|
|
54296
|
+
function concatBytes(e) {
|
|
54297
|
+
let t = 0;
|
|
54298
|
+
for (const l of e)
|
|
54299
|
+
t += l.length;
|
|
54300
|
+
const n = new Uint8Array(t);
|
|
54301
|
+
let o = 0;
|
|
54302
|
+
for (const l of e)
|
|
54303
|
+
n.set(l, o), o += l.length;
|
|
54304
|
+
return n;
|
|
54305
|
+
}
|
|
54306
|
+
let encodeUTF8_;
|
|
54307
|
+
function encodeUTF8(e) {
|
|
54308
|
+
let t;
|
|
54309
|
+
return (encodeUTF8_ ?? (t = new globalThis.TextEncoder(), encodeUTF8_ = t.encode.bind(t)))(e);
|
|
54310
|
+
}
|
|
54311
|
+
let decodeUTF8_;
|
|
54312
|
+
function decodeUTF8(e) {
|
|
54313
|
+
let t;
|
|
54314
|
+
return (decodeUTF8_ ?? (t = new globalThis.TextDecoder(), decodeUTF8_ = t.decode.bind(t)))(e);
|
|
54315
|
+
}
|
|
54316
|
+
/**
|
|
54317
|
+
* @license
|
|
54318
|
+
* Copyright 2025 Google LLC
|
|
54319
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54320
|
+
*/
|
|
54321
|
+
class LineDecoder {
|
|
54322
|
+
constructor() {
|
|
54323
|
+
this.buffer = new Uint8Array(), this.carriageReturnIndex = null;
|
|
54324
|
+
}
|
|
54325
|
+
decode(t) {
|
|
54326
|
+
if (t == null)
|
|
54327
|
+
return [];
|
|
54328
|
+
const n = t instanceof ArrayBuffer ? new Uint8Array(t) : typeof t == "string" ? encodeUTF8(t) : t;
|
|
54329
|
+
this.buffer = concatBytes([this.buffer, n]);
|
|
54330
|
+
const o = [];
|
|
54331
|
+
let l;
|
|
54332
|
+
for (; (l = findNewlineIndex(this.buffer, this.carriageReturnIndex)) != null; ) {
|
|
54333
|
+
if (l.carriage && this.carriageReturnIndex == null) {
|
|
54334
|
+
this.carriageReturnIndex = l.index;
|
|
54335
|
+
continue;
|
|
54336
|
+
}
|
|
54337
|
+
if (this.carriageReturnIndex != null && (l.index !== this.carriageReturnIndex + 1 || l.carriage)) {
|
|
54338
|
+
o.push(decodeUTF8(this.buffer.subarray(0, this.carriageReturnIndex - 1))), this.buffer = this.buffer.subarray(this.carriageReturnIndex), this.carriageReturnIndex = null;
|
|
54339
|
+
continue;
|
|
54340
|
+
}
|
|
54341
|
+
const d = this.carriageReturnIndex !== null ? l.preceding - 1 : l.preceding, f = decodeUTF8(this.buffer.subarray(0, d));
|
|
54342
|
+
o.push(f), this.buffer = this.buffer.subarray(l.index), this.carriageReturnIndex = null;
|
|
54343
|
+
}
|
|
54344
|
+
return o;
|
|
54345
|
+
}
|
|
54346
|
+
flush() {
|
|
54347
|
+
return this.buffer.length ? this.decode(`
|
|
54348
|
+
`) : [];
|
|
54349
|
+
}
|
|
54350
|
+
}
|
|
54351
|
+
LineDecoder.NEWLINE_CHARS = /* @__PURE__ */ new Set([`
|
|
54352
|
+
`, "\r"]);
|
|
54353
|
+
LineDecoder.NEWLINE_REGEXP = /\r\n|[\n\r]/g;
|
|
54354
|
+
function findNewlineIndex(e, t) {
|
|
54355
|
+
for (let l = t ?? 0; l < e.length; l++) {
|
|
54356
|
+
if (e[l] === 10)
|
|
54357
|
+
return { preceding: l, index: l + 1, carriage: !1 };
|
|
54358
|
+
if (e[l] === 13)
|
|
54359
|
+
return { preceding: l, index: l + 1, carriage: !0 };
|
|
54360
|
+
}
|
|
54361
|
+
return null;
|
|
54362
|
+
}
|
|
54363
|
+
function findDoubleNewlineIndex(e) {
|
|
54364
|
+
for (let o = 0; o < e.length - 1; o++) {
|
|
54365
|
+
if (e[o] === 10 && e[o + 1] === 10 || e[o] === 13 && e[o + 1] === 13)
|
|
54366
|
+
return o + 2;
|
|
54367
|
+
if (e[o] === 13 && e[o + 1] === 10 && o + 3 < e.length && e[o + 2] === 13 && e[o + 3] === 10)
|
|
54368
|
+
return o + 4;
|
|
54369
|
+
}
|
|
54370
|
+
return -1;
|
|
54371
|
+
}
|
|
54372
|
+
/**
|
|
54373
|
+
* @license
|
|
54374
|
+
* Copyright 2025 Google LLC
|
|
54375
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54376
|
+
*/
|
|
54377
|
+
const levelNumbers = {
|
|
54378
|
+
off: 0,
|
|
54379
|
+
error: 200,
|
|
54380
|
+
warn: 300,
|
|
54381
|
+
info: 400,
|
|
54382
|
+
debug: 500
|
|
54383
|
+
}, parseLogLevel = (e, t, n) => {
|
|
54384
|
+
if (e) {
|
|
54385
|
+
if (hasOwn$1(levelNumbers, e))
|
|
54386
|
+
return e;
|
|
54387
|
+
loggerFor(n).warn(`${t} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(levelNumbers))}`);
|
|
54388
|
+
}
|
|
54389
|
+
};
|
|
54390
|
+
function noop() {
|
|
54391
|
+
}
|
|
54392
|
+
function makeLogFn(e, t, n) {
|
|
54393
|
+
return !t || levelNumbers[e] > levelNumbers[n] ? noop : t[e].bind(t);
|
|
54394
|
+
}
|
|
54395
|
+
const noopLogger = {
|
|
54396
|
+
error: noop,
|
|
54397
|
+
warn: noop,
|
|
54398
|
+
info: noop,
|
|
54399
|
+
debug: noop
|
|
54400
|
+
};
|
|
54401
|
+
let cachedLoggers = /* @__PURE__ */ new WeakMap();
|
|
54402
|
+
function loggerFor(e) {
|
|
54403
|
+
var t;
|
|
54404
|
+
const n = e.logger, o = (t = e.logLevel) !== null && t !== void 0 ? t : "off";
|
|
54405
|
+
if (!n)
|
|
54406
|
+
return noopLogger;
|
|
54407
|
+
const l = cachedLoggers.get(n);
|
|
54408
|
+
if (l && l[0] === o)
|
|
54409
|
+
return l[1];
|
|
54410
|
+
const d = {
|
|
54411
|
+
error: makeLogFn("error", n, o),
|
|
54412
|
+
warn: makeLogFn("warn", n, o),
|
|
54413
|
+
info: makeLogFn("info", n, o),
|
|
54414
|
+
debug: makeLogFn("debug", n, o)
|
|
54415
|
+
};
|
|
54416
|
+
return cachedLoggers.set(n, [o, d]), d;
|
|
54417
|
+
}
|
|
54418
|
+
const formatRequestDetails = (e) => (e.options && (e.options = Object.assign({}, e.options), delete e.options.headers), e.headers && (e.headers = Object.fromEntries((e.headers instanceof Headers ? [...e.headers] : Object.entries(e.headers)).map(([t, n]) => [
|
|
54419
|
+
t,
|
|
54420
|
+
t.toLowerCase() === "x-goog-api-key" || t.toLowerCase() === "authorization" || t.toLowerCase() === "cookie" || t.toLowerCase() === "set-cookie" ? "***" : n
|
|
54421
|
+
]))), "retryOfRequestLogID" in e && (e.retryOfRequestLogID && (e.retryOf = e.retryOfRequestLogID), delete e.retryOfRequestLogID), e);
|
|
54422
|
+
/**
|
|
54423
|
+
* @license
|
|
54424
|
+
* Copyright 2025 Google LLC
|
|
54425
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54426
|
+
*/
|
|
54427
|
+
class Stream {
|
|
54428
|
+
constructor(t, n, o) {
|
|
54429
|
+
this.iterator = t, this.controller = n, this.client = o;
|
|
54430
|
+
}
|
|
54431
|
+
static fromSSEResponse(t, n, o) {
|
|
54432
|
+
let l = !1;
|
|
54433
|
+
const d = o ? loggerFor(o) : console;
|
|
54434
|
+
function f() {
|
|
54435
|
+
return __asyncGenerator(this, arguments, function* () {
|
|
54436
|
+
var b, S, _, C;
|
|
54437
|
+
if (l)
|
|
54438
|
+
throw new GeminiNextGenAPIClientError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
54439
|
+
l = !0;
|
|
54440
|
+
let E = !1;
|
|
54441
|
+
try {
|
|
54442
|
+
try {
|
|
54443
|
+
for (var R = !0, A = __asyncValues(_iterSSEMessages(t, n)), M; M = yield __await(A.next()), b = M.done, !b; R = !0) {
|
|
54444
|
+
C = M.value, R = !1;
|
|
54445
|
+
const I = C;
|
|
54446
|
+
if (!E)
|
|
54447
|
+
if (I.data.startsWith("[DONE]")) {
|
|
54448
|
+
E = !0;
|
|
54449
|
+
continue;
|
|
54450
|
+
} else
|
|
54451
|
+
try {
|
|
54452
|
+
yield yield __await(JSON.parse(I.data));
|
|
54453
|
+
} catch (V) {
|
|
54454
|
+
throw d.error("Could not parse message into JSON:", I.data), d.error("From chunk:", I.raw), V;
|
|
54455
|
+
}
|
|
54456
|
+
}
|
|
54457
|
+
} catch (I) {
|
|
54458
|
+
S = { error: I };
|
|
54459
|
+
} finally {
|
|
54460
|
+
try {
|
|
54461
|
+
!R && !b && (_ = A.return) && (yield __await(_.call(A)));
|
|
54462
|
+
} finally {
|
|
54463
|
+
if (S) throw S.error;
|
|
54464
|
+
}
|
|
54465
|
+
}
|
|
54466
|
+
E = !0;
|
|
54467
|
+
} catch (I) {
|
|
54468
|
+
if (isAbortError(I))
|
|
54469
|
+
return yield __await(void 0);
|
|
54470
|
+
throw I;
|
|
54471
|
+
} finally {
|
|
54472
|
+
E || n.abort();
|
|
54473
|
+
}
|
|
54474
|
+
});
|
|
54475
|
+
}
|
|
54476
|
+
return new Stream(f, n, o);
|
|
54477
|
+
}
|
|
54478
|
+
/**
|
|
54479
|
+
* Generates a Stream from a newline-separated ReadableStream
|
|
54480
|
+
* where each item is a JSON value.
|
|
54481
|
+
*/
|
|
54482
|
+
static fromReadableStream(t, n, o) {
|
|
54483
|
+
let l = !1;
|
|
54484
|
+
function d() {
|
|
54485
|
+
return __asyncGenerator(this, arguments, function* () {
|
|
54486
|
+
var b, S, _, C;
|
|
54487
|
+
const E = new LineDecoder(), R = ReadableStreamToAsyncIterable(t);
|
|
54488
|
+
try {
|
|
54489
|
+
for (var A = !0, M = __asyncValues(R), I; I = yield __await(M.next()), b = I.done, !b; A = !0) {
|
|
54490
|
+
C = I.value, A = !1;
|
|
54491
|
+
const V = C;
|
|
54492
|
+
for (const q of E.decode(V))
|
|
54493
|
+
yield yield __await(q);
|
|
54494
|
+
}
|
|
54495
|
+
} catch (V) {
|
|
54496
|
+
S = { error: V };
|
|
54497
|
+
} finally {
|
|
54498
|
+
try {
|
|
54499
|
+
!A && !b && (_ = M.return) && (yield __await(_.call(M)));
|
|
54500
|
+
} finally {
|
|
54501
|
+
if (S) throw S.error;
|
|
54502
|
+
}
|
|
54503
|
+
}
|
|
54504
|
+
for (const V of E.flush())
|
|
54505
|
+
yield yield __await(V);
|
|
54506
|
+
});
|
|
54507
|
+
}
|
|
54508
|
+
function f() {
|
|
54509
|
+
return __asyncGenerator(this, arguments, function* () {
|
|
54510
|
+
var b, S, _, C;
|
|
54511
|
+
if (l)
|
|
54512
|
+
throw new GeminiNextGenAPIClientError("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");
|
|
54513
|
+
l = !0;
|
|
54514
|
+
let E = !1;
|
|
54515
|
+
try {
|
|
54516
|
+
try {
|
|
54517
|
+
for (var R = !0, A = __asyncValues(d()), M; M = yield __await(A.next()), b = M.done, !b; R = !0) {
|
|
54518
|
+
C = M.value, R = !1;
|
|
54519
|
+
const I = C;
|
|
54520
|
+
E || I && (yield yield __await(JSON.parse(I)));
|
|
54521
|
+
}
|
|
54522
|
+
} catch (I) {
|
|
54523
|
+
S = { error: I };
|
|
54524
|
+
} finally {
|
|
54525
|
+
try {
|
|
54526
|
+
!R && !b && (_ = A.return) && (yield __await(_.call(A)));
|
|
54527
|
+
} finally {
|
|
54528
|
+
if (S) throw S.error;
|
|
54529
|
+
}
|
|
54530
|
+
}
|
|
54531
|
+
E = !0;
|
|
54532
|
+
} catch (I) {
|
|
54533
|
+
if (isAbortError(I))
|
|
54534
|
+
return yield __await(void 0);
|
|
54535
|
+
throw I;
|
|
54536
|
+
} finally {
|
|
54537
|
+
E || n.abort();
|
|
54538
|
+
}
|
|
54539
|
+
});
|
|
54540
|
+
}
|
|
54541
|
+
return new Stream(f, n, o);
|
|
54542
|
+
}
|
|
54543
|
+
[Symbol.asyncIterator]() {
|
|
54544
|
+
return this.iterator();
|
|
54545
|
+
}
|
|
54546
|
+
/**
|
|
54547
|
+
* Splits the stream into two streams which can be
|
|
54548
|
+
* independently read from at different speeds.
|
|
54549
|
+
*/
|
|
54550
|
+
tee() {
|
|
54551
|
+
const t = [], n = [], o = this.iterator(), l = (d) => ({
|
|
54552
|
+
next: () => {
|
|
54553
|
+
if (d.length === 0) {
|
|
54554
|
+
const f = o.next();
|
|
54555
|
+
t.push(f), n.push(f);
|
|
54556
|
+
}
|
|
54557
|
+
return d.shift();
|
|
54558
|
+
}
|
|
54559
|
+
});
|
|
54560
|
+
return [
|
|
54561
|
+
new Stream(() => l(t), this.controller, this.client),
|
|
54562
|
+
new Stream(() => l(n), this.controller, this.client)
|
|
54563
|
+
];
|
|
54564
|
+
}
|
|
54565
|
+
/**
|
|
54566
|
+
* Converts this stream to a newline-separated ReadableStream of
|
|
54567
|
+
* JSON stringified values in the stream
|
|
54568
|
+
* which can be turned back into a Stream with `Stream.fromReadableStream()`.
|
|
54569
|
+
*/
|
|
54570
|
+
toReadableStream() {
|
|
54571
|
+
const t = this;
|
|
54572
|
+
let n;
|
|
54573
|
+
return makeReadableStream({
|
|
54574
|
+
async start() {
|
|
54575
|
+
n = t[Symbol.asyncIterator]();
|
|
54576
|
+
},
|
|
54577
|
+
async pull(o) {
|
|
54578
|
+
try {
|
|
54579
|
+
const { value: l, done: d } = await n.next();
|
|
54580
|
+
if (d)
|
|
54581
|
+
return o.close();
|
|
54582
|
+
const f = encodeUTF8(JSON.stringify(l) + `
|
|
54583
|
+
`);
|
|
54584
|
+
o.enqueue(f);
|
|
54585
|
+
} catch (l) {
|
|
54586
|
+
o.error(l);
|
|
54587
|
+
}
|
|
54588
|
+
},
|
|
54589
|
+
async cancel() {
|
|
54590
|
+
var o;
|
|
54591
|
+
await ((o = n.return) === null || o === void 0 ? void 0 : o.call(n));
|
|
54592
|
+
}
|
|
54593
|
+
});
|
|
54594
|
+
}
|
|
54595
|
+
}
|
|
54596
|
+
function _iterSSEMessages(e, t) {
|
|
54597
|
+
return __asyncGenerator(this, arguments, function* () {
|
|
54598
|
+
var o, l, d, f;
|
|
54599
|
+
if (!e.body)
|
|
54600
|
+
throw t.abort(), typeof globalThis.navigator < "u" && globalThis.navigator.product === "ReactNative" ? new GeminiNextGenAPIClientError("The default react-native fetch implementation does not support streaming. Please use expo/fetch: https://docs.expo.dev/versions/latest/sdk/expo/#expofetch-api") : new GeminiNextGenAPIClientError("Attempted to iterate over a response with no body");
|
|
54601
|
+
const g = new SSEDecoder(), b = new LineDecoder(), S = ReadableStreamToAsyncIterable(e.body);
|
|
54602
|
+
try {
|
|
54603
|
+
for (var _ = !0, C = __asyncValues(iterSSEChunks(S)), E; E = yield __await(C.next()), o = E.done, !o; _ = !0) {
|
|
54604
|
+
f = E.value, _ = !1;
|
|
54605
|
+
const R = f;
|
|
54606
|
+
for (const A of b.decode(R)) {
|
|
54607
|
+
const M = g.decode(A);
|
|
54608
|
+
M && (yield yield __await(M));
|
|
54609
|
+
}
|
|
54610
|
+
}
|
|
54611
|
+
} catch (R) {
|
|
54612
|
+
l = { error: R };
|
|
54613
|
+
} finally {
|
|
54614
|
+
try {
|
|
54615
|
+
!_ && !o && (d = C.return) && (yield __await(d.call(C)));
|
|
54616
|
+
} finally {
|
|
54617
|
+
if (l) throw l.error;
|
|
54618
|
+
}
|
|
54619
|
+
}
|
|
54620
|
+
for (const R of b.flush()) {
|
|
54621
|
+
const A = g.decode(R);
|
|
54622
|
+
A && (yield yield __await(A));
|
|
54623
|
+
}
|
|
54624
|
+
});
|
|
54625
|
+
}
|
|
54626
|
+
function iterSSEChunks(e) {
|
|
54627
|
+
return __asyncGenerator(this, arguments, function* () {
|
|
54628
|
+
var n, o, l, d;
|
|
54629
|
+
let f = new Uint8Array();
|
|
54630
|
+
try {
|
|
54631
|
+
for (var g = !0, b = __asyncValues(e), S; S = yield __await(b.next()), n = S.done, !n; g = !0) {
|
|
54632
|
+
d = S.value, g = !1;
|
|
54633
|
+
const _ = d;
|
|
54634
|
+
if (_ == null)
|
|
54635
|
+
continue;
|
|
54636
|
+
const C = _ instanceof ArrayBuffer ? new Uint8Array(_) : typeof _ == "string" ? encodeUTF8(_) : _;
|
|
54637
|
+
let E = new Uint8Array(f.length + C.length);
|
|
54638
|
+
E.set(f), E.set(C, f.length), f = E;
|
|
54639
|
+
let R;
|
|
54640
|
+
for (; (R = findDoubleNewlineIndex(f)) !== -1; )
|
|
54641
|
+
yield yield __await(f.slice(0, R)), f = f.slice(R);
|
|
54642
|
+
}
|
|
54643
|
+
} catch (_) {
|
|
54644
|
+
o = { error: _ };
|
|
54645
|
+
} finally {
|
|
54646
|
+
try {
|
|
54647
|
+
!g && !n && (l = b.return) && (yield __await(l.call(b)));
|
|
54648
|
+
} finally {
|
|
54649
|
+
if (o) throw o.error;
|
|
54650
|
+
}
|
|
54651
|
+
}
|
|
54652
|
+
f.length > 0 && (yield yield __await(f));
|
|
54653
|
+
});
|
|
54654
|
+
}
|
|
54655
|
+
class SSEDecoder {
|
|
54656
|
+
constructor() {
|
|
54657
|
+
this.event = null, this.data = [], this.chunks = [];
|
|
54658
|
+
}
|
|
54659
|
+
decode(t) {
|
|
54660
|
+
if (t.endsWith("\r") && (t = t.substring(0, t.length - 1)), !t) {
|
|
54661
|
+
if (!this.event && !this.data.length)
|
|
54662
|
+
return null;
|
|
54663
|
+
const d = {
|
|
54664
|
+
event: this.event,
|
|
54665
|
+
data: this.data.join(`
|
|
54666
|
+
`),
|
|
54667
|
+
raw: this.chunks
|
|
54668
|
+
};
|
|
54669
|
+
return this.event = null, this.data = [], this.chunks = [], d;
|
|
54670
|
+
}
|
|
54671
|
+
if (this.chunks.push(t), t.startsWith(":"))
|
|
54672
|
+
return null;
|
|
54673
|
+
let [n, o, l] = partition(t, ":");
|
|
54674
|
+
return l.startsWith(" ") && (l = l.substring(1)), n === "event" ? this.event = l : n === "data" && this.data.push(l), null;
|
|
54675
|
+
}
|
|
54676
|
+
}
|
|
54677
|
+
function partition(e, t) {
|
|
54678
|
+
const n = e.indexOf(t);
|
|
54679
|
+
return n !== -1 ? [e.substring(0, n), t, e.substring(n + t.length)] : [e, "", ""];
|
|
54680
|
+
}
|
|
54681
|
+
/**
|
|
54682
|
+
* @license
|
|
54683
|
+
* Copyright 2025 Google LLC
|
|
54684
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54685
|
+
*/
|
|
54686
|
+
async function defaultParseResponse(e, t) {
|
|
54687
|
+
const { response: n, requestLogID: o, retryOfRequestLogID: l, startTime: d } = t, f = await (async () => {
|
|
54688
|
+
var g;
|
|
54689
|
+
if (t.options.stream)
|
|
54690
|
+
return loggerFor(e).debug("response", n.status, n.url, n.headers, n.body), t.options.__streamClass ? t.options.__streamClass.fromSSEResponse(n, t.controller, e) : Stream.fromSSEResponse(n, t.controller, e);
|
|
54691
|
+
if (n.status === 204)
|
|
54692
|
+
return null;
|
|
54693
|
+
if (t.options.__binaryResponse)
|
|
54694
|
+
return n;
|
|
54695
|
+
const b = n.headers.get("content-type"), S = (g = b == null ? void 0 : b.split(";")[0]) === null || g === void 0 ? void 0 : g.trim();
|
|
54696
|
+
return (S == null ? void 0 : S.includes("application/json")) || (S == null ? void 0 : S.endsWith("+json")) ? await n.json() : await n.text();
|
|
54697
|
+
})();
|
|
54698
|
+
return loggerFor(e).debug(`[${o}] response parsed`, formatRequestDetails({
|
|
54699
|
+
retryOfRequestLogID: l,
|
|
54700
|
+
url: n.url,
|
|
54701
|
+
status: n.status,
|
|
54702
|
+
body: f,
|
|
54703
|
+
durationMs: Date.now() - d
|
|
54704
|
+
})), f;
|
|
54705
|
+
}
|
|
54706
|
+
/**
|
|
54707
|
+
* @license
|
|
54708
|
+
* Copyright 2025 Google LLC
|
|
54709
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54710
|
+
*/
|
|
54711
|
+
class APIPromise extends Promise {
|
|
54712
|
+
constructor(t, n, o = defaultParseResponse) {
|
|
54713
|
+
super((l) => {
|
|
54714
|
+
l(null);
|
|
54715
|
+
}), this.responsePromise = n, this.parseResponse = o, this.client = t;
|
|
54716
|
+
}
|
|
54717
|
+
_thenUnwrap(t) {
|
|
54718
|
+
return new APIPromise(this.client, this.responsePromise, async (n, o) => t(await this.parseResponse(n, o), o));
|
|
54719
|
+
}
|
|
54720
|
+
/**
|
|
54721
|
+
* Gets the raw `Response` instance instead of parsing the response
|
|
54722
|
+
* data.
|
|
54723
|
+
*
|
|
54724
|
+
* If you want to parse the response body but still get the `Response`
|
|
54725
|
+
* instance, you can use {@link withResponse()}.
|
|
54726
|
+
*
|
|
54727
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
54728
|
+
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
|
|
54729
|
+
* to your `tsconfig.json`.
|
|
54730
|
+
*/
|
|
54731
|
+
asResponse() {
|
|
54732
|
+
return this.responsePromise.then((t) => t.response);
|
|
54733
|
+
}
|
|
54734
|
+
/**
|
|
54735
|
+
* Gets the parsed response data and the raw `Response` instance.
|
|
54736
|
+
*
|
|
54737
|
+
* If you just want to get the raw `Response` instance without parsing it,
|
|
54738
|
+
* you can use {@link asResponse()}.
|
|
54739
|
+
*
|
|
54740
|
+
* 👋 Getting the wrong TypeScript type for `Response`?
|
|
54741
|
+
* Try setting `"moduleResolution": "NodeNext"` or add `"lib": ["DOM"]`
|
|
54742
|
+
* to your `tsconfig.json`.
|
|
54743
|
+
*/
|
|
54744
|
+
async withResponse() {
|
|
54745
|
+
const [t, n] = await Promise.all([this.parse(), this.asResponse()]);
|
|
54746
|
+
return { data: t, response: n };
|
|
54747
|
+
}
|
|
54748
|
+
parse() {
|
|
54749
|
+
return this.parsedPromise || (this.parsedPromise = this.responsePromise.then((t) => this.parseResponse(this.client, t))), this.parsedPromise;
|
|
54750
|
+
}
|
|
54751
|
+
then(t, n) {
|
|
54752
|
+
return this.parse().then(t, n);
|
|
54753
|
+
}
|
|
54754
|
+
catch(t) {
|
|
54755
|
+
return this.parse().catch(t);
|
|
54756
|
+
}
|
|
54757
|
+
finally(t) {
|
|
54758
|
+
return this.parse().finally(t);
|
|
54759
|
+
}
|
|
54760
|
+
}
|
|
54761
|
+
/**
|
|
54762
|
+
* @license
|
|
54763
|
+
* Copyright 2025 Google LLC
|
|
54764
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54765
|
+
*/
|
|
54766
|
+
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol("brand.privateNullableHeaders");
|
|
54767
|
+
function* iterateHeaders(e) {
|
|
54768
|
+
if (!e)
|
|
54769
|
+
return;
|
|
54770
|
+
if (brand_privateNullableHeaders in e) {
|
|
54771
|
+
const { values: o, nulls: l } = e;
|
|
54772
|
+
yield* o.entries();
|
|
54773
|
+
for (const d of l)
|
|
54774
|
+
yield [d, null];
|
|
54775
|
+
return;
|
|
54776
|
+
}
|
|
54777
|
+
let t = !1, n;
|
|
54778
|
+
e instanceof Headers ? n = e.entries() : isReadonlyArray(e) ? n = e : (t = !0, n = Object.entries(e ?? {}));
|
|
54779
|
+
for (let o of n) {
|
|
54780
|
+
const l = o[0];
|
|
54781
|
+
if (typeof l != "string")
|
|
54782
|
+
throw new TypeError("expected header name to be a string");
|
|
54783
|
+
const d = isReadonlyArray(o[1]) ? o[1] : [o[1]];
|
|
54784
|
+
let f = !1;
|
|
54785
|
+
for (const g of d)
|
|
54786
|
+
g !== void 0 && (t && !f && (f = !0, yield [l, null]), yield [l, g]);
|
|
54787
|
+
}
|
|
54788
|
+
}
|
|
54789
|
+
const buildHeaders = (e) => {
|
|
54790
|
+
const t = new Headers(), n = /* @__PURE__ */ new Set();
|
|
54791
|
+
for (const o of e) {
|
|
54792
|
+
const l = /* @__PURE__ */ new Set();
|
|
54793
|
+
for (const [d, f] of iterateHeaders(o)) {
|
|
54794
|
+
const g = d.toLowerCase();
|
|
54795
|
+
l.has(g) || (t.delete(d), l.add(g)), f === null ? (t.delete(d), n.add(g)) : (t.append(d, f), n.delete(g));
|
|
54796
|
+
}
|
|
54797
|
+
}
|
|
54798
|
+
return { [brand_privateNullableHeaders]: !0, values: t, nulls: n };
|
|
54799
|
+
};
|
|
54800
|
+
/**
|
|
54801
|
+
* @license
|
|
54802
|
+
* Copyright 2025 Google LLC
|
|
54803
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54804
|
+
*/
|
|
54805
|
+
const readEnv = (e) => {
|
|
54806
|
+
var t, n, o, l, d, f;
|
|
54807
|
+
if (typeof globalThis.process < "u")
|
|
54808
|
+
return (o = (n = (t = globalThis.process.env) === null || t === void 0 ? void 0 : t[e]) === null || n === void 0 ? void 0 : n.trim()) !== null && o !== void 0 ? o : void 0;
|
|
54809
|
+
if (typeof globalThis.Deno < "u")
|
|
54810
|
+
return (f = (d = (l = globalThis.Deno.env) === null || l === void 0 ? void 0 : l.get) === null || d === void 0 ? void 0 : d.call(l, e)) === null || f === void 0 ? void 0 : f.trim();
|
|
54811
|
+
};
|
|
54812
|
+
/**
|
|
54813
|
+
* @license
|
|
54814
|
+
* Copyright 2025 Google LLC
|
|
54815
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
54816
|
+
*/
|
|
54817
|
+
var _a;
|
|
54818
|
+
class BaseGeminiNextGenAPIClient {
|
|
54819
|
+
/**
|
|
54820
|
+
* API Client for interfacing with the Gemini Next Gen API API.
|
|
54821
|
+
*
|
|
54822
|
+
* @param {string | null | undefined} [opts.apiKey=process.env['GEMINI_API_KEY'] ?? null]
|
|
54823
|
+
* @param {string | undefined} [opts.apiVersion=v1beta]
|
|
54824
|
+
* @param {string} [opts.baseURL=process.env['GEMINI_NEXT_GEN_API_BASE_URL'] ?? https://generativelanguage.googleapis.com] - Override the default base URL for the API.
|
|
54825
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
54826
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
54827
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
54828
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
54829
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
54830
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
54831
|
+
*/
|
|
54832
|
+
constructor(t) {
|
|
54833
|
+
var n, o, l, d, f, g, b, S = t === void 0 ? {} : t, { baseURL: _ = readEnv("GEMINI_NEXT_GEN_API_BASE_URL"), apiKey: C = (n = readEnv("GEMINI_API_KEY")) !== null && n !== void 0 ? n : null, apiVersion: E = "v1beta" } = S, R = __rest(S, ["baseURL", "apiKey", "apiVersion"]);
|
|
54834
|
+
const A = Object.assign(Object.assign({
|
|
54835
|
+
apiKey: C,
|
|
54836
|
+
apiVersion: E
|
|
54837
|
+
}, R), { baseURL: _ || "https://generativelanguage.googleapis.com" });
|
|
54838
|
+
this.baseURL = A.baseURL, this.timeout = (o = A.timeout) !== null && o !== void 0 ? o : BaseGeminiNextGenAPIClient.DEFAULT_TIMEOUT, this.logger = (l = A.logger) !== null && l !== void 0 ? l : console;
|
|
54839
|
+
const M = "warn";
|
|
54840
|
+
this.logLevel = M, this.logLevel = (f = (d = parseLogLevel(A.logLevel, "ClientOptions.logLevel", this)) !== null && d !== void 0 ? d : parseLogLevel(readEnv("GEMINI_NEXT_GEN_API_LOG"), "process.env['GEMINI_NEXT_GEN_API_LOG']", this)) !== null && f !== void 0 ? f : M, this.fetchOptions = A.fetchOptions, this.maxRetries = (g = A.maxRetries) !== null && g !== void 0 ? g : 2, this.fetch = (b = A.fetch) !== null && b !== void 0 ? b : getDefaultFetch(), this.encoder = FallbackEncoder, this._options = A, this.apiKey = C, this.apiVersion = E;
|
|
54841
|
+
}
|
|
54842
|
+
/**
|
|
54843
|
+
* Create a new client instance re-using the same options given to the current client with optional overriding.
|
|
54844
|
+
*/
|
|
54845
|
+
withOptions(t) {
|
|
54846
|
+
return new this.constructor(Object.assign(Object.assign(Object.assign({}, this._options), { baseURL: this.baseURL, maxRetries: this.maxRetries, timeout: this.timeout, logger: this.logger, logLevel: this.logLevel, fetch: this.fetch, fetchOptions: this.fetchOptions, apiKey: this.apiKey, apiVersion: this.apiVersion }), t));
|
|
54847
|
+
}
|
|
54848
|
+
/**
|
|
54849
|
+
* Check whether the base URL is set to its default.
|
|
54850
|
+
*/
|
|
54851
|
+
baseURLOverridden() {
|
|
54852
|
+
return this.baseURL !== "https://generativelanguage.googleapis.com";
|
|
54853
|
+
}
|
|
54854
|
+
defaultQuery() {
|
|
54855
|
+
return this._options.defaultQuery;
|
|
54856
|
+
}
|
|
54857
|
+
validateHeaders({ values: t, nulls: n }) {
|
|
54858
|
+
if (!(this.apiKey && t.get("x-goog-api-key")) && !n.has("x-goog-api-key"))
|
|
54859
|
+
throw new Error('Could not resolve authentication method. Expected the apiKey to be set. Or for the "x-goog-api-key" headers to be explicitly omitted');
|
|
54860
|
+
}
|
|
54861
|
+
async authHeaders(t) {
|
|
54862
|
+
if (this.apiKey != null)
|
|
54863
|
+
return buildHeaders([{ "x-goog-api-key": this.apiKey }]);
|
|
54864
|
+
}
|
|
54865
|
+
/**
|
|
54866
|
+
* Basic re-implementation of `qs.stringify` for primitive types.
|
|
54867
|
+
*/
|
|
54868
|
+
stringifyQuery(t) {
|
|
54869
|
+
return Object.entries(t).filter(([n, o]) => typeof o < "u").map(([n, o]) => {
|
|
54870
|
+
if (typeof o == "string" || typeof o == "number" || typeof o == "boolean")
|
|
54871
|
+
return `${encodeURIComponent(n)}=${encodeURIComponent(o)}`;
|
|
54872
|
+
if (o === null)
|
|
54873
|
+
return `${encodeURIComponent(n)}=`;
|
|
54874
|
+
throw new GeminiNextGenAPIClientError(`Cannot stringify type ${typeof o}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`);
|
|
54875
|
+
}).join("&");
|
|
54876
|
+
}
|
|
54877
|
+
getUserAgent() {
|
|
54878
|
+
return `${this.constructor.name}/JS ${VERSION}`;
|
|
54879
|
+
}
|
|
54880
|
+
defaultIdempotencyKey() {
|
|
54881
|
+
return `stainless-node-retry-${uuid4()}`;
|
|
54882
|
+
}
|
|
54883
|
+
makeStatusError(t, n, o, l) {
|
|
54884
|
+
return APIError.generate(t, n, o, l);
|
|
54885
|
+
}
|
|
54886
|
+
buildURL(t, n, o) {
|
|
54887
|
+
const l = !this.baseURLOverridden() && o || this.baseURL, d = isAbsoluteURL(t) ? new URL(t) : new URL(l + (l.endsWith("/") && t.startsWith("/") ? t.slice(1) : t)), f = this.defaultQuery();
|
|
54888
|
+
return isEmptyObj(f) || (n = Object.assign(Object.assign({}, f), n)), typeof n == "object" && n && !Array.isArray(n) && (d.search = this.stringifyQuery(n)), d.toString();
|
|
54889
|
+
}
|
|
54890
|
+
/**
|
|
54891
|
+
* Used as a callback for mutating the given `FinalRequestOptions` object.
|
|
54892
|
+
*/
|
|
54893
|
+
async prepareOptions(t) {
|
|
54894
|
+
}
|
|
54895
|
+
/**
|
|
54896
|
+
* Used as a callback for mutating the given `RequestInit` object.
|
|
54897
|
+
*
|
|
54898
|
+
* This is useful for cases where you want to add certain headers based off of
|
|
54899
|
+
* the request properties, e.g. `method` or `url`.
|
|
54900
|
+
*/
|
|
54901
|
+
async prepareRequest(t, { url: n, options: o }) {
|
|
54902
|
+
}
|
|
54903
|
+
get(t, n) {
|
|
54904
|
+
return this.methodRequest("get", t, n);
|
|
54905
|
+
}
|
|
54906
|
+
post(t, n) {
|
|
54907
|
+
return this.methodRequest("post", t, n);
|
|
54908
|
+
}
|
|
54909
|
+
patch(t, n) {
|
|
54910
|
+
return this.methodRequest("patch", t, n);
|
|
54911
|
+
}
|
|
54912
|
+
put(t, n) {
|
|
54913
|
+
return this.methodRequest("put", t, n);
|
|
54914
|
+
}
|
|
54915
|
+
delete(t, n) {
|
|
54916
|
+
return this.methodRequest("delete", t, n);
|
|
54917
|
+
}
|
|
54918
|
+
methodRequest(t, n, o) {
|
|
54919
|
+
return this.request(Promise.resolve(o).then((l) => Object.assign({ method: t, path: n }, l)));
|
|
54920
|
+
}
|
|
54921
|
+
request(t, n = null) {
|
|
54922
|
+
return new APIPromise(this, this.makeRequest(t, n, void 0));
|
|
54923
|
+
}
|
|
54924
|
+
async makeRequest(t, n, o) {
|
|
54925
|
+
var l, d, f;
|
|
54926
|
+
const g = await t, b = (l = g.maxRetries) !== null && l !== void 0 ? l : this.maxRetries;
|
|
54927
|
+
n == null && (n = b), await this.prepareOptions(g);
|
|
54928
|
+
const { req: S, url: _, timeout: C } = await this.buildRequest(g, {
|
|
54929
|
+
retryCount: b - n
|
|
54930
|
+
});
|
|
54931
|
+
await this.prepareRequest(S, { url: _, options: g });
|
|
54932
|
+
const E = "log_" + (Math.random() * (1 << 24) | 0).toString(16).padStart(6, "0"), R = o === void 0 ? "" : `, retryOf: ${o}`, A = Date.now();
|
|
54933
|
+
if (loggerFor(this).debug(`[${E}] sending request`, formatRequestDetails({
|
|
54934
|
+
retryOfRequestLogID: o,
|
|
54935
|
+
method: g.method,
|
|
54936
|
+
url: _,
|
|
54937
|
+
options: g,
|
|
54938
|
+
headers: S.headers
|
|
54939
|
+
})), !((d = g.signal) === null || d === void 0) && d.aborted)
|
|
54940
|
+
throw new APIUserAbortError();
|
|
54941
|
+
const M = new AbortController(), I = await this.fetchWithTimeout(_, S, C, M).catch(castToError), V = Date.now();
|
|
54942
|
+
if (I instanceof globalThis.Error) {
|
|
54943
|
+
const Q = `retrying, ${n} attempts remaining`;
|
|
54944
|
+
if (!((f = g.signal) === null || f === void 0) && f.aborted)
|
|
54945
|
+
throw new APIUserAbortError();
|
|
54946
|
+
const te = isAbortError(I) || /timed? ?out/i.test(String(I) + ("cause" in I ? String(I.cause) : ""));
|
|
54947
|
+
if (n)
|
|
54948
|
+
return loggerFor(this).info(`[${E}] connection ${te ? "timed out" : "failed"} - ${Q}`), loggerFor(this).debug(`[${E}] connection ${te ? "timed out" : "failed"} (${Q})`, formatRequestDetails({
|
|
54949
|
+
retryOfRequestLogID: o,
|
|
54950
|
+
url: _,
|
|
54951
|
+
durationMs: V - A,
|
|
54952
|
+
message: I.message
|
|
54953
|
+
})), this.retryRequest(g, n, o ?? E);
|
|
54954
|
+
throw loggerFor(this).info(`[${E}] connection ${te ? "timed out" : "failed"} - error; no more retries left`), loggerFor(this).debug(`[${E}] connection ${te ? "timed out" : "failed"} (error; no more retries left)`, formatRequestDetails({
|
|
54955
|
+
retryOfRequestLogID: o,
|
|
54956
|
+
url: _,
|
|
54957
|
+
durationMs: V - A,
|
|
54958
|
+
message: I.message
|
|
54959
|
+
})), te ? new APIConnectionTimeoutError() : new APIConnectionError({ cause: I });
|
|
54960
|
+
}
|
|
54961
|
+
const q = `[${E}${R}] ${S.method} ${_} ${I.ok ? "succeeded" : "failed"} with status ${I.status} in ${V - A}ms`;
|
|
54962
|
+
if (!I.ok) {
|
|
54963
|
+
const Q = await this.shouldRetry(I);
|
|
54964
|
+
if (n && Q) {
|
|
54965
|
+
const oe = `retrying, ${n} attempts remaining`;
|
|
54966
|
+
return await CancelReadableStream(I.body), loggerFor(this).info(`${q} - ${oe}`), loggerFor(this).debug(`[${E}] response error (${oe})`, formatRequestDetails({
|
|
54967
|
+
retryOfRequestLogID: o,
|
|
54968
|
+
url: I.url,
|
|
54969
|
+
status: I.status,
|
|
54970
|
+
headers: I.headers,
|
|
54971
|
+
durationMs: V - A
|
|
54972
|
+
})), this.retryRequest(g, n, o ?? E, I.headers);
|
|
54973
|
+
}
|
|
54974
|
+
const te = Q ? "error; no more retries left" : "error; not retryable";
|
|
54975
|
+
loggerFor(this).info(`${q} - ${te}`);
|
|
54976
|
+
const j = await I.text().catch((oe) => castToError(oe).message), F = safeJSON(j), ne = F ? void 0 : j;
|
|
54977
|
+
throw loggerFor(this).debug(`[${E}] response error (${te})`, formatRequestDetails({
|
|
54978
|
+
retryOfRequestLogID: o,
|
|
54979
|
+
url: I.url,
|
|
54980
|
+
status: I.status,
|
|
54981
|
+
headers: I.headers,
|
|
54982
|
+
message: ne,
|
|
54983
|
+
durationMs: Date.now() - A
|
|
54984
|
+
})), this.makeStatusError(I.status, F, ne, I.headers);
|
|
54985
|
+
}
|
|
54986
|
+
return loggerFor(this).info(q), loggerFor(this).debug(`[${E}] response start`, formatRequestDetails({
|
|
54987
|
+
retryOfRequestLogID: o,
|
|
54988
|
+
url: I.url,
|
|
54989
|
+
status: I.status,
|
|
54990
|
+
headers: I.headers,
|
|
54991
|
+
durationMs: V - A
|
|
54992
|
+
})), { response: I, options: g, controller: M, requestLogID: E, retryOfRequestLogID: o, startTime: A };
|
|
54993
|
+
}
|
|
54994
|
+
async fetchWithTimeout(t, n, o, l) {
|
|
54995
|
+
const d = n || {}, { signal: f, method: g } = d, b = __rest(d, ["signal", "method"]);
|
|
54996
|
+
f && f.addEventListener("abort", () => l.abort());
|
|
54997
|
+
const S = setTimeout(() => l.abort(), o), _ = globalThis.ReadableStream && b.body instanceof globalThis.ReadableStream || typeof b.body == "object" && b.body !== null && Symbol.asyncIterator in b.body, C = Object.assign(Object.assign(Object.assign({ signal: l.signal }, _ ? { duplex: "half" } : {}), { method: "GET" }), b);
|
|
54998
|
+
g && (C.method = g.toUpperCase());
|
|
54999
|
+
try {
|
|
55000
|
+
return await this.fetch.call(void 0, t, C);
|
|
55001
|
+
} finally {
|
|
55002
|
+
clearTimeout(S);
|
|
55003
|
+
}
|
|
55004
|
+
}
|
|
55005
|
+
async shouldRetry(t) {
|
|
55006
|
+
const n = t.headers.get("x-should-retry");
|
|
55007
|
+
return n === "true" ? !0 : n === "false" ? !1 : t.status === 408 || t.status === 409 || t.status === 429 || t.status >= 500;
|
|
55008
|
+
}
|
|
55009
|
+
async retryRequest(t, n, o, l) {
|
|
55010
|
+
var d;
|
|
55011
|
+
let f;
|
|
55012
|
+
const g = l == null ? void 0 : l.get("retry-after-ms");
|
|
55013
|
+
if (g) {
|
|
55014
|
+
const S = parseFloat(g);
|
|
55015
|
+
Number.isNaN(S) || (f = S);
|
|
55016
|
+
}
|
|
55017
|
+
const b = l == null ? void 0 : l.get("retry-after");
|
|
55018
|
+
if (b && !f) {
|
|
55019
|
+
const S = parseFloat(b);
|
|
55020
|
+
Number.isNaN(S) ? f = Date.parse(b) - Date.now() : f = S * 1e3;
|
|
55021
|
+
}
|
|
55022
|
+
if (!(f && 0 <= f && f < 60 * 1e3)) {
|
|
55023
|
+
const S = (d = t.maxRetries) !== null && d !== void 0 ? d : this.maxRetries;
|
|
55024
|
+
f = this.calculateDefaultRetryTimeoutMillis(n, S);
|
|
55025
|
+
}
|
|
55026
|
+
return await sleep$1(f), this.makeRequest(t, n - 1, o);
|
|
55027
|
+
}
|
|
55028
|
+
calculateDefaultRetryTimeoutMillis(t, n) {
|
|
55029
|
+
const d = n - t, f = Math.min(0.5 * Math.pow(2, d), 8), g = 1 - Math.random() * 0.25;
|
|
55030
|
+
return f * g * 1e3;
|
|
55031
|
+
}
|
|
55032
|
+
async buildRequest(t, { retryCount: n = 0 } = {}) {
|
|
55033
|
+
var o, l, d;
|
|
55034
|
+
const f = Object.assign({}, t), { method: g, path: b, query: S, defaultBaseURL: _ } = f, C = this.buildURL(b, S, _);
|
|
55035
|
+
"timeout" in f && validatePositiveInteger("timeout", f.timeout), f.timeout = (o = f.timeout) !== null && o !== void 0 ? o : this.timeout;
|
|
55036
|
+
const { bodyHeaders: E, body: R } = this.buildBody({ options: f }), A = await this.buildHeaders({ options: t, method: g, bodyHeaders: E, retryCount: n });
|
|
55037
|
+
return { req: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ method: g, headers: A }, f.signal && { signal: f.signal }), globalThis.ReadableStream && R instanceof globalThis.ReadableStream && { duplex: "half" }), R && { body: R }), (l = this.fetchOptions) !== null && l !== void 0 ? l : {}), (d = f.fetchOptions) !== null && d !== void 0 ? d : {}), url: C, timeout: f.timeout };
|
|
55038
|
+
}
|
|
55039
|
+
async buildHeaders({ options: t, method: n, bodyHeaders: o, retryCount: l }) {
|
|
55040
|
+
let d = {};
|
|
55041
|
+
this.idempotencyHeader && n !== "get" && (t.idempotencyKey || (t.idempotencyKey = this.defaultIdempotencyKey()), d[this.idempotencyHeader] = t.idempotencyKey);
|
|
55042
|
+
const f = buildHeaders([
|
|
55043
|
+
d,
|
|
55044
|
+
Object.assign(Object.assign({ Accept: "application/json", "User-Agent": this.getUserAgent(), "X-Stainless-Retry-Count": String(l) }, t.timeout ? { "X-Stainless-Timeout": String(Math.trunc(t.timeout / 1e3)) } : {}), getPlatformHeaders()),
|
|
55045
|
+
await this.authHeaders(t),
|
|
55046
|
+
this._options.defaultHeaders,
|
|
55047
|
+
o,
|
|
55048
|
+
t.headers
|
|
55049
|
+
]);
|
|
55050
|
+
return this.validateHeaders(f), f.values;
|
|
55051
|
+
}
|
|
55052
|
+
buildBody({ options: { body: t, headers: n } }) {
|
|
55053
|
+
if (!t)
|
|
55054
|
+
return { bodyHeaders: void 0, body: void 0 };
|
|
55055
|
+
const o = buildHeaders([n]);
|
|
55056
|
+
return (
|
|
55057
|
+
// Pass raw type verbatim
|
|
55058
|
+
ArrayBuffer.isView(t) || t instanceof ArrayBuffer || t instanceof DataView || typeof t == "string" && // Preserve legacy string encoding behavior for now
|
|
55059
|
+
o.values.has("content-type") || // `Blob` is superset of `File`
|
|
55060
|
+
globalThis.Blob && t instanceof globalThis.Blob || // `FormData` -> `multipart/form-data`
|
|
55061
|
+
t instanceof FormData || // `URLSearchParams` -> `application/x-www-form-urlencoded`
|
|
55062
|
+
t instanceof URLSearchParams || // Send chunked stream (each chunk has own `length`)
|
|
55063
|
+
globalThis.ReadableStream && t instanceof globalThis.ReadableStream ? { bodyHeaders: void 0, body: t } : typeof t == "object" && (Symbol.asyncIterator in t || Symbol.iterator in t && "next" in t && typeof t.next == "function") ? { bodyHeaders: void 0, body: ReadableStreamFrom(t) } : this.encoder({ body: t, headers: o })
|
|
55064
|
+
);
|
|
55065
|
+
}
|
|
55066
|
+
}
|
|
55067
|
+
BaseGeminiNextGenAPIClient.DEFAULT_TIMEOUT = 6e4;
|
|
55068
|
+
class GeminiNextGenAPIClient extends BaseGeminiNextGenAPIClient {
|
|
55069
|
+
constructor() {
|
|
55070
|
+
super(...arguments), this.interactions = new Interactions(this);
|
|
55071
|
+
}
|
|
55072
|
+
}
|
|
55073
|
+
_a = GeminiNextGenAPIClient;
|
|
55074
|
+
GeminiNextGenAPIClient.GeminiNextGenAPIClient = _a;
|
|
55075
|
+
GeminiNextGenAPIClient.GeminiNextGenAPIClientError = GeminiNextGenAPIClientError;
|
|
55076
|
+
GeminiNextGenAPIClient.APIError = APIError;
|
|
55077
|
+
GeminiNextGenAPIClient.APIConnectionError = APIConnectionError;
|
|
55078
|
+
GeminiNextGenAPIClient.APIConnectionTimeoutError = APIConnectionTimeoutError;
|
|
55079
|
+
GeminiNextGenAPIClient.APIUserAbortError = APIUserAbortError;
|
|
55080
|
+
GeminiNextGenAPIClient.NotFoundError = NotFoundError;
|
|
55081
|
+
GeminiNextGenAPIClient.ConflictError = ConflictError;
|
|
55082
|
+
GeminiNextGenAPIClient.RateLimitError = RateLimitError;
|
|
55083
|
+
GeminiNextGenAPIClient.BadRequestError = BadRequestError;
|
|
55084
|
+
GeminiNextGenAPIClient.AuthenticationError = AuthenticationError;
|
|
55085
|
+
GeminiNextGenAPIClient.InternalServerError = InternalServerError;
|
|
55086
|
+
GeminiNextGenAPIClient.PermissionDeniedError = PermissionDeniedError;
|
|
55087
|
+
GeminiNextGenAPIClient.UnprocessableEntityError = UnprocessableEntityError;
|
|
55088
|
+
GeminiNextGenAPIClient.toFile = toFile;
|
|
55089
|
+
GeminiNextGenAPIClient.Interactions = Interactions;
|
|
53799
55090
|
/**
|
|
53800
55091
|
* @license
|
|
53801
55092
|
* Copyright 2025 Google LLC
|
|
@@ -54541,6 +55832,21 @@ class WebAuth {
|
|
|
54541
55832
|
*/
|
|
54542
55833
|
const LANGUAGE_LABEL_PREFIX = "gl-node/";
|
|
54543
55834
|
class GoogleGenAI {
|
|
55835
|
+
get interactions() {
|
|
55836
|
+
if (this._interactions !== void 0)
|
|
55837
|
+
return this._interactions;
|
|
55838
|
+
if (console.warn("GoogleGenAI.interactions: Interactions usage is experimental and may change in future versions."), this.vertexai)
|
|
55839
|
+
throw new Error("This version of the GenAI SDK does not support Vertex AI API for interactions.");
|
|
55840
|
+
const t = this.httpOptions;
|
|
55841
|
+
t != null && t.extraBody && console.warn("GoogleGenAI.interactions: Client level httpOptions.extraBody is not supported by the interactions client and will be ignored.");
|
|
55842
|
+
const n = new GeminiNextGenAPIClient({
|
|
55843
|
+
baseURL: this.apiClient.getBaseUrl(),
|
|
55844
|
+
apiKey: this.apiKey,
|
|
55845
|
+
defaultHeaders: this.apiClient.getDefaultHeaders(),
|
|
55846
|
+
timeout: t == null ? void 0 : t.timeout
|
|
55847
|
+
});
|
|
55848
|
+
return this._interactions = n.interactions, this._interactions;
|
|
55849
|
+
}
|
|
54544
55850
|
constructor(t) {
|
|
54545
55851
|
var n;
|
|
54546
55852
|
if (t.apiKey == null)
|
|
@@ -62959,14 +64265,14 @@ var DisplayNameParts;
|
|
|
62959
64265
|
})(DisplayNameParts || (DisplayNameParts = {}));
|
|
62960
64266
|
function createFormattedDateTimePartsComponent(e) {
|
|
62961
64267
|
var t = function(n) {
|
|
62962
|
-
var o = useIntl(), l = n.value, d = n.children, f = __rest(n, ["value", "children"]), g = typeof l == "string" ? new Date(l || 0) : l, b = e === "formatDate" ? o.formatDateToParts(g, f) : o.formatTimeToParts(g, f);
|
|
64268
|
+
var o = useIntl(), l = n.value, d = n.children, f = __rest$1(n, ["value", "children"]), g = typeof l == "string" ? new Date(l || 0) : l, b = e === "formatDate" ? o.formatDateToParts(g, f) : o.formatTimeToParts(g, f);
|
|
62963
64269
|
return d(b);
|
|
62964
64270
|
};
|
|
62965
64271
|
return t.displayName = DisplayNameParts[e], t;
|
|
62966
64272
|
}
|
|
62967
64273
|
function createFormattedComponent(e) {
|
|
62968
64274
|
var t = function(n) {
|
|
62969
|
-
var o = useIntl(), l = n.value, d = n.children, f = __rest(
|
|
64275
|
+
var o = useIntl(), l = n.value, d = n.children, f = __rest$1(
|
|
62970
64276
|
n,
|
|
62971
64277
|
["value", "children"]
|
|
62972
64278
|
), g = o[e](l, f);
|
|
@@ -78027,7 +79333,7 @@ function requireMd5() {
|
|
|
78027
79333
|
})(md5)), md5.exports;
|
|
78028
79334
|
}
|
|
78029
79335
|
var md5Exports = requireMd5();
|
|
78030
|
-
const bodyKey = "TheRequestBody";
|
|
79336
|
+
const bodyKey = "TheRequestBody", defaultSchemaDescription = "Request body content";
|
|
78031
79337
|
function getHash(e) {
|
|
78032
79338
|
return md5Exports.md5(e).substring(0, 16);
|
|
78033
79339
|
}
|
|
@@ -78045,6 +79351,27 @@ function deduplicateApiFunctions(e) {
|
|
|
78045
79351
|
};
|
|
78046
79352
|
});
|
|
78047
79353
|
}
|
|
79354
|
+
function isSchemaReference(e) {
|
|
79355
|
+
return !!e && "$ref" in e;
|
|
79356
|
+
}
|
|
79357
|
+
function isSchemaObject(e) {
|
|
79358
|
+
return !!e && !("$ref" in e);
|
|
79359
|
+
}
|
|
79360
|
+
function getRequestBodySchema(e) {
|
|
79361
|
+
var o, l;
|
|
79362
|
+
if (!(e != null && e.content)) return;
|
|
79363
|
+
const t = [
|
|
79364
|
+
"application/json",
|
|
79365
|
+
"application/json-patch+json",
|
|
79366
|
+
"multipart/form-data",
|
|
79367
|
+
"text/plain"
|
|
79368
|
+
];
|
|
79369
|
+
for (const d of t) {
|
|
79370
|
+
const f = (o = e.content[d]) == null ? void 0 : o.schema;
|
|
79371
|
+
if (f) return f;
|
|
79372
|
+
}
|
|
79373
|
+
return (l = Object.values(e.content).find((d) => d == null ? void 0 : d.schema)) == null ? void 0 : l.schema;
|
|
79374
|
+
}
|
|
78048
79375
|
async function fetchApiFunctions() {
|
|
78049
79376
|
var e, t, n;
|
|
78050
79377
|
try {
|
|
@@ -78062,24 +79389,26 @@ async function fetchApiFunctions() {
|
|
|
78062
79389
|
C.length > 0 && C[0].toLowerCase() === "v4" ? E = C.length > 1 ? C[1] : "api" : E = C.length > 0 ? C[0] : "api", E = E.replace(/[{}]/g, "");
|
|
78063
79390
|
const R = getHash(f), A = `${S}-${E.toLowerCase()}-${R}`, M = {}, I = [];
|
|
78064
79391
|
(e = _.parameters) == null || e.forEach((ne) => {
|
|
79392
|
+
var Ve;
|
|
79393
|
+
const ae = (Ve = ne.schema) == null ? void 0 : Ve.type, oe = ae === "integer" || ae === "number" ? Type.NUMBER : ae === "boolean" ? Type.BOOLEAN : Type.STRING;
|
|
78065
79394
|
M[ne.name] = {
|
|
78066
|
-
type:
|
|
79395
|
+
type: oe,
|
|
78067
79396
|
description: ne.description || `The ${ne.name} parameter`
|
|
78068
79397
|
}, ne.required && I.push(ne.name);
|
|
78069
79398
|
});
|
|
78070
79399
|
const V = ((t = _.parameters) == null ? void 0 : t.filter((ne) => ne.in === "path").map((ne) => ne.name)) || [];
|
|
78071
79400
|
if ((S === "post" || S === "put") && _.requestBody) {
|
|
78072
|
-
const ne = (
|
|
78073
|
-
if (ne &&
|
|
78074
|
-
const
|
|
79401
|
+
const ne = getRequestBodySchema(_.requestBody), ae = _.requestBody.description || defaultSchemaDescription;
|
|
79402
|
+
if (ne && isSchemaReference(ne) && ne.$ref.startsWith("#/components/schemas/")) {
|
|
79403
|
+
const oe = ne.$ref.substring(21), Ve = l.components.schemas[oe], Ne = isSchemaObject(Ve) ? Ve.properties : void 0, se = Ne ? JSON.stringify(Ne) : "Refer to API schema for details.";
|
|
78075
79404
|
M[bodyKey] = {
|
|
78076
79405
|
type: Type.STRING,
|
|
78077
|
-
description: `${
|
|
79406
|
+
description: `${ae}. Must be a JSON string with these properties: ${se}`
|
|
78078
79407
|
};
|
|
78079
79408
|
} else
|
|
78080
79409
|
M[bodyKey] = {
|
|
78081
79410
|
type: Type.STRING,
|
|
78082
|
-
description:
|
|
79411
|
+
description: ae
|
|
78083
79412
|
};
|
|
78084
79413
|
I.push(bodyKey);
|
|
78085
79414
|
}
|
|
@@ -78124,7 +79453,7 @@ ${_.description}` : _.summary || `${S.toUpperCase()} ${C[C.length - 1]}`,
|
|
|
78124
79453
|
} catch (Ve) {
|
|
78125
79454
|
return console.error(`Error in ${A}:`, Ve), `I'm sorry, I couldn't retrieve the requested information. Error: ${Ve instanceof Error ? Ve.message : "Unknown error"}`;
|
|
78126
79455
|
}
|
|
78127
|
-
}, te = _.tags.at(0), j = (S
|
|
79456
|
+
}, te = ((n = _.tags) == null ? void 0 : n.at(0)) ?? "Partner", j = (S === "get" ? "Fetching data" : "Updating data") + ` - Randmar ${te} API.`, F = `${S} ${f}`;
|
|
78128
79457
|
d.push({
|
|
78129
79458
|
declaration: q,
|
|
78130
79459
|
handler: Q,
|