cascade-ai 0.50.0 → 0.52.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/cli.cjs +930 -133
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +930 -133
- package/dist/cli.js.map +1 -1
- package/dist/desktop-core.cjs +1137 -347
- package/dist/index.cjs +916 -124
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +102 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +916 -124
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/desktop-core.cjs
CHANGED
|
@@ -9931,7 +9931,7 @@ var require_p_retry = __commonJS({
|
|
|
9931
9931
|
return error2;
|
|
9932
9932
|
};
|
|
9933
9933
|
var isNetworkError = (errorMessage) => networkErrorMsgs.includes(errorMessage);
|
|
9934
|
-
var pRetry2 = (input, options) => new Promise((
|
|
9934
|
+
var pRetry2 = (input, options) => new Promise((resolve2, reject) => {
|
|
9935
9935
|
options = {
|
|
9936
9936
|
onFailedAttempt: () => {
|
|
9937
9937
|
},
|
|
@@ -9941,7 +9941,7 @@ var require_p_retry = __commonJS({
|
|
|
9941
9941
|
const operation = retry.operation(options);
|
|
9942
9942
|
operation.attempt(async (attemptNumber) => {
|
|
9943
9943
|
try {
|
|
9944
|
-
|
|
9944
|
+
resolve2(await input(attemptNumber));
|
|
9945
9945
|
} catch (error2) {
|
|
9946
9946
|
if (!(error2 instanceof Error)) {
|
|
9947
9947
|
reject(new TypeError(`Non-error was thrown: "${error2}". You should only throw errors.`));
|
|
@@ -9987,7 +9987,7 @@ var require_extend = __commonJS({
|
|
|
9987
9987
|
}
|
|
9988
9988
|
return toStr.call(arr) === "[object Array]";
|
|
9989
9989
|
};
|
|
9990
|
-
var
|
|
9990
|
+
var isPlainObject7 = function isPlainObject8(obj) {
|
|
9991
9991
|
if (!obj || toStr.call(obj) !== "[object Object]") {
|
|
9992
9992
|
return false;
|
|
9993
9993
|
}
|
|
@@ -10044,12 +10044,12 @@ var require_extend = __commonJS({
|
|
|
10044
10044
|
src = getProperty(target, name);
|
|
10045
10045
|
copy = getProperty(options, name);
|
|
10046
10046
|
if (target !== copy) {
|
|
10047
|
-
if (deep && copy && (
|
|
10047
|
+
if (deep && copy && (isPlainObject7(copy) || (copyIsArray = isArray4(copy)))) {
|
|
10048
10048
|
if (copyIsArray) {
|
|
10049
10049
|
copyIsArray = false;
|
|
10050
10050
|
clone4 = src && isArray4(src) ? src : [];
|
|
10051
10051
|
} else {
|
|
10052
|
-
clone4 = src &&
|
|
10052
|
+
clone4 = src && isPlainObject7(src) ? src : {};
|
|
10053
10053
|
}
|
|
10054
10054
|
setProperty(target, { name, newValue: extend2(deep, clone4, copy) });
|
|
10055
10055
|
} else if (typeof copy !== "undefined") {
|
|
@@ -10471,8 +10471,8 @@ var require_retry3 = __commonJS({
|
|
|
10471
10471
|
}
|
|
10472
10472
|
const delay2 = getNextRetryDelay(config2);
|
|
10473
10473
|
err.config.retryConfig.currentRetryAttempt += 1;
|
|
10474
|
-
const backoff = config2.retryBackoff ? config2.retryBackoff(err, delay2) : new Promise((
|
|
10475
|
-
setTimeout(
|
|
10474
|
+
const backoff = config2.retryBackoff ? config2.retryBackoff(err, delay2) : new Promise((resolve2) => {
|
|
10475
|
+
setTimeout(resolve2, delay2);
|
|
10476
10476
|
});
|
|
10477
10477
|
if (config2.onRetryAttempt) {
|
|
10478
10478
|
await config2.onRetryAttempt(err);
|
|
@@ -11371,8 +11371,8 @@ var require_helpers = __commonJS({
|
|
|
11371
11371
|
function req(url2, opts = {}) {
|
|
11372
11372
|
const href = typeof url2 === "string" ? url2 : url2.href;
|
|
11373
11373
|
const req2 = (href.startsWith("https:") ? https4 : http7).request(url2, opts);
|
|
11374
|
-
const promise = new Promise((
|
|
11375
|
-
req2.once("response",
|
|
11374
|
+
const promise = new Promise((resolve2, reject) => {
|
|
11375
|
+
req2.once("response", resolve2).once("error", reject).end();
|
|
11376
11376
|
});
|
|
11377
11377
|
req2.then = promise.then.bind(promise);
|
|
11378
11378
|
return req2;
|
|
@@ -11547,7 +11547,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
11547
11547
|
var debug_1 = __importDefault(require_src());
|
|
11548
11548
|
var debug3 = (0, debug_1.default)("https-proxy-agent:parse-proxy-response");
|
|
11549
11549
|
function parseProxyResponse(socket) {
|
|
11550
|
-
return new Promise((
|
|
11550
|
+
return new Promise((resolve2, reject) => {
|
|
11551
11551
|
let buffersLength = 0;
|
|
11552
11552
|
const buffers = [];
|
|
11553
11553
|
function read() {
|
|
@@ -11613,7 +11613,7 @@ var require_parse_proxy_response = __commonJS({
|
|
|
11613
11613
|
}
|
|
11614
11614
|
debug3("got proxy server response: %o %o", firstLine, headers);
|
|
11615
11615
|
cleanup();
|
|
11616
|
-
|
|
11616
|
+
resolve2({
|
|
11617
11617
|
connect: {
|
|
11618
11618
|
statusCode,
|
|
11619
11619
|
statusText,
|
|
@@ -11853,7 +11853,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
11853
11853
|
return new originalPromise(executor);
|
|
11854
11854
|
}
|
|
11855
11855
|
function promiseResolvedWith(value) {
|
|
11856
|
-
return newPromise((
|
|
11856
|
+
return newPromise((resolve2) => resolve2(value));
|
|
11857
11857
|
}
|
|
11858
11858
|
function promiseRejectedWith(reason) {
|
|
11859
11859
|
return originalPromiseReject(reason);
|
|
@@ -12023,8 +12023,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
12023
12023
|
return new TypeError("Cannot " + name + " a stream using a released reader");
|
|
12024
12024
|
}
|
|
12025
12025
|
function defaultReaderClosedPromiseInitialize(reader) {
|
|
12026
|
-
reader._closedPromise = newPromise((
|
|
12027
|
-
reader._closedPromise_resolve =
|
|
12026
|
+
reader._closedPromise = newPromise((resolve2, reject) => {
|
|
12027
|
+
reader._closedPromise_resolve = resolve2;
|
|
12028
12028
|
reader._closedPromise_reject = reject;
|
|
12029
12029
|
});
|
|
12030
12030
|
}
|
|
@@ -12198,8 +12198,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
12198
12198
|
}
|
|
12199
12199
|
let resolvePromise;
|
|
12200
12200
|
let rejectPromise;
|
|
12201
|
-
const promise = newPromise((
|
|
12202
|
-
resolvePromise =
|
|
12201
|
+
const promise = newPromise((resolve2, reject) => {
|
|
12202
|
+
resolvePromise = resolve2;
|
|
12203
12203
|
rejectPromise = reject;
|
|
12204
12204
|
});
|
|
12205
12205
|
const readRequest = {
|
|
@@ -12304,8 +12304,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
12304
12304
|
const reader = this._reader;
|
|
12305
12305
|
let resolvePromise;
|
|
12306
12306
|
let rejectPromise;
|
|
12307
|
-
const promise = newPromise((
|
|
12308
|
-
resolvePromise =
|
|
12307
|
+
const promise = newPromise((resolve2, reject) => {
|
|
12308
|
+
resolvePromise = resolve2;
|
|
12309
12309
|
rejectPromise = reject;
|
|
12310
12310
|
});
|
|
12311
12311
|
const readRequest = {
|
|
@@ -13324,8 +13324,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
13324
13324
|
}
|
|
13325
13325
|
let resolvePromise;
|
|
13326
13326
|
let rejectPromise;
|
|
13327
|
-
const promise = newPromise((
|
|
13328
|
-
resolvePromise =
|
|
13327
|
+
const promise = newPromise((resolve2, reject) => {
|
|
13328
|
+
resolvePromise = resolve2;
|
|
13329
13329
|
rejectPromise = reject;
|
|
13330
13330
|
});
|
|
13331
13331
|
const readIntoRequest = {
|
|
@@ -13637,10 +13637,10 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
13637
13637
|
wasAlreadyErroring = true;
|
|
13638
13638
|
reason = void 0;
|
|
13639
13639
|
}
|
|
13640
|
-
const promise = newPromise((
|
|
13640
|
+
const promise = newPromise((resolve2, reject) => {
|
|
13641
13641
|
stream2._pendingAbortRequest = {
|
|
13642
13642
|
_promise: void 0,
|
|
13643
|
-
_resolve:
|
|
13643
|
+
_resolve: resolve2,
|
|
13644
13644
|
_reject: reject,
|
|
13645
13645
|
_reason: reason,
|
|
13646
13646
|
_wasAlreadyErroring: wasAlreadyErroring
|
|
@@ -13657,9 +13657,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
13657
13657
|
if (state === "closed" || state === "errored") {
|
|
13658
13658
|
return promiseRejectedWith(new TypeError(`The stream (in ${state} state) is not in the writable state and cannot be closed`));
|
|
13659
13659
|
}
|
|
13660
|
-
const promise = newPromise((
|
|
13660
|
+
const promise = newPromise((resolve2, reject) => {
|
|
13661
13661
|
const closeRequest = {
|
|
13662
|
-
_resolve:
|
|
13662
|
+
_resolve: resolve2,
|
|
13663
13663
|
_reject: reject
|
|
13664
13664
|
};
|
|
13665
13665
|
stream2._closeRequest = closeRequest;
|
|
@@ -13672,9 +13672,9 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
13672
13672
|
return promise;
|
|
13673
13673
|
}
|
|
13674
13674
|
function WritableStreamAddWriteRequest(stream2) {
|
|
13675
|
-
const promise = newPromise((
|
|
13675
|
+
const promise = newPromise((resolve2, reject) => {
|
|
13676
13676
|
const writeRequest = {
|
|
13677
|
-
_resolve:
|
|
13677
|
+
_resolve: resolve2,
|
|
13678
13678
|
_reject: reject
|
|
13679
13679
|
};
|
|
13680
13680
|
stream2._writeRequests.push(writeRequest);
|
|
@@ -14290,8 +14290,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
14290
14290
|
return new TypeError("Cannot " + name + " a stream using a released writer");
|
|
14291
14291
|
}
|
|
14292
14292
|
function defaultWriterClosedPromiseInitialize(writer) {
|
|
14293
|
-
writer._closedPromise = newPromise((
|
|
14294
|
-
writer._closedPromise_resolve =
|
|
14293
|
+
writer._closedPromise = newPromise((resolve2, reject) => {
|
|
14294
|
+
writer._closedPromise_resolve = resolve2;
|
|
14295
14295
|
writer._closedPromise_reject = reject;
|
|
14296
14296
|
writer._closedPromiseState = "pending";
|
|
14297
14297
|
});
|
|
@@ -14327,8 +14327,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
14327
14327
|
writer._closedPromiseState = "resolved";
|
|
14328
14328
|
}
|
|
14329
14329
|
function defaultWriterReadyPromiseInitialize(writer) {
|
|
14330
|
-
writer._readyPromise = newPromise((
|
|
14331
|
-
writer._readyPromise_resolve =
|
|
14330
|
+
writer._readyPromise = newPromise((resolve2, reject) => {
|
|
14331
|
+
writer._readyPromise_resolve = resolve2;
|
|
14332
14332
|
writer._readyPromise_reject = reject;
|
|
14333
14333
|
});
|
|
14334
14334
|
writer._readyPromiseState = "pending";
|
|
@@ -14415,7 +14415,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
14415
14415
|
source._disturbed = true;
|
|
14416
14416
|
let shuttingDown = false;
|
|
14417
14417
|
let currentWrite = promiseResolvedWith(void 0);
|
|
14418
|
-
return newPromise((
|
|
14418
|
+
return newPromise((resolve2, reject) => {
|
|
14419
14419
|
let abortAlgorithm;
|
|
14420
14420
|
if (signal !== void 0) {
|
|
14421
14421
|
abortAlgorithm = () => {
|
|
@@ -14560,7 +14560,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
14560
14560
|
if (isError2) {
|
|
14561
14561
|
reject(error2);
|
|
14562
14562
|
} else {
|
|
14563
|
-
|
|
14563
|
+
resolve2(void 0);
|
|
14564
14564
|
}
|
|
14565
14565
|
return null;
|
|
14566
14566
|
}
|
|
@@ -14841,8 +14841,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
14841
14841
|
let branch1;
|
|
14842
14842
|
let branch2;
|
|
14843
14843
|
let resolveCancelPromise;
|
|
14844
|
-
const cancelPromise = newPromise((
|
|
14845
|
-
resolveCancelPromise =
|
|
14844
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
14845
|
+
resolveCancelPromise = resolve2;
|
|
14846
14846
|
});
|
|
14847
14847
|
function pullAlgorithm() {
|
|
14848
14848
|
if (reading) {
|
|
@@ -14933,8 +14933,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
14933
14933
|
let branch1;
|
|
14934
14934
|
let branch2;
|
|
14935
14935
|
let resolveCancelPromise;
|
|
14936
|
-
const cancelPromise = newPromise((
|
|
14937
|
-
resolveCancelPromise =
|
|
14936
|
+
const cancelPromise = newPromise((resolve2) => {
|
|
14937
|
+
resolveCancelPromise = resolve2;
|
|
14938
14938
|
});
|
|
14939
14939
|
function forwardReaderError(thisReader) {
|
|
14940
14940
|
uponRejection(thisReader._closedPromise, (r4) => {
|
|
@@ -15714,8 +15714,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
15714
15714
|
const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1);
|
|
15715
15715
|
const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy);
|
|
15716
15716
|
let startPromise_resolve;
|
|
15717
|
-
const startPromise = newPromise((
|
|
15718
|
-
startPromise_resolve =
|
|
15717
|
+
const startPromise = newPromise((resolve2) => {
|
|
15718
|
+
startPromise_resolve = resolve2;
|
|
15719
15719
|
});
|
|
15720
15720
|
InitializeTransformStream(this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm);
|
|
15721
15721
|
SetUpTransformStreamDefaultControllerFromTransformer(this, transformer);
|
|
@@ -15808,8 +15808,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
15808
15808
|
if (stream2._backpressureChangePromise !== void 0) {
|
|
15809
15809
|
stream2._backpressureChangePromise_resolve();
|
|
15810
15810
|
}
|
|
15811
|
-
stream2._backpressureChangePromise = newPromise((
|
|
15812
|
-
stream2._backpressureChangePromise_resolve =
|
|
15811
|
+
stream2._backpressureChangePromise = newPromise((resolve2) => {
|
|
15812
|
+
stream2._backpressureChangePromise_resolve = resolve2;
|
|
15813
15813
|
});
|
|
15814
15814
|
stream2._backpressure = backpressure;
|
|
15815
15815
|
}
|
|
@@ -15977,8 +15977,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
15977
15977
|
return controller._finishPromise;
|
|
15978
15978
|
}
|
|
15979
15979
|
const readable = stream2._readable;
|
|
15980
|
-
controller._finishPromise = newPromise((
|
|
15981
|
-
controller._finishPromise_resolve =
|
|
15980
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
15981
|
+
controller._finishPromise_resolve = resolve2;
|
|
15982
15982
|
controller._finishPromise_reject = reject;
|
|
15983
15983
|
});
|
|
15984
15984
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -16004,8 +16004,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
16004
16004
|
return controller._finishPromise;
|
|
16005
16005
|
}
|
|
16006
16006
|
const readable = stream2._readable;
|
|
16007
|
-
controller._finishPromise = newPromise((
|
|
16008
|
-
controller._finishPromise_resolve =
|
|
16007
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
16008
|
+
controller._finishPromise_resolve = resolve2;
|
|
16009
16009
|
controller._finishPromise_reject = reject;
|
|
16010
16010
|
});
|
|
16011
16011
|
const flushPromise = controller._flushAlgorithm();
|
|
@@ -16035,8 +16035,8 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
16035
16035
|
return controller._finishPromise;
|
|
16036
16036
|
}
|
|
16037
16037
|
const writable = stream2._writable;
|
|
16038
|
-
controller._finishPromise = newPromise((
|
|
16039
|
-
controller._finishPromise_resolve =
|
|
16038
|
+
controller._finishPromise = newPromise((resolve2, reject) => {
|
|
16039
|
+
controller._finishPromise_resolve = resolve2;
|
|
16040
16040
|
controller._finishPromise_reject = reject;
|
|
16041
16041
|
});
|
|
16042
16042
|
const cancelPromise = controller._cancelAlgorithm(reason);
|
|
@@ -17943,7 +17943,7 @@ __export(src_exports, {
|
|
|
17943
17943
|
isRedirect: () => isRedirect
|
|
17944
17944
|
});
|
|
17945
17945
|
async function fetch4(url2, options_) {
|
|
17946
|
-
return new Promise((
|
|
17946
|
+
return new Promise((resolve2, reject) => {
|
|
17947
17947
|
const request = new Request4(url2, options_);
|
|
17948
17948
|
const { parsedURL, options } = getNodeRequestOptions2(request);
|
|
17949
17949
|
if (!supportedSchemas.has(parsedURL.protocol)) {
|
|
@@ -17952,7 +17952,7 @@ async function fetch4(url2, options_) {
|
|
|
17952
17952
|
if (parsedURL.protocol === "data:") {
|
|
17953
17953
|
const data = dist_default(request.url);
|
|
17954
17954
|
const response2 = new Response4(data, { headers: { "Content-Type": data.typeFull } });
|
|
17955
|
-
|
|
17955
|
+
resolve2(response2);
|
|
17956
17956
|
return;
|
|
17957
17957
|
}
|
|
17958
17958
|
const send = (parsedURL.protocol === "https:" ? https2__default.default : http2__default.default).request;
|
|
@@ -18074,7 +18074,7 @@ async function fetch4(url2, options_) {
|
|
|
18074
18074
|
if (responseReferrerPolicy) {
|
|
18075
18075
|
requestOptions.referrerPolicy = responseReferrerPolicy;
|
|
18076
18076
|
}
|
|
18077
|
-
|
|
18077
|
+
resolve2(fetch4(new Request4(locationURL, requestOptions)));
|
|
18078
18078
|
finalize();
|
|
18079
18079
|
return;
|
|
18080
18080
|
}
|
|
@@ -18107,7 +18107,7 @@ async function fetch4(url2, options_) {
|
|
|
18107
18107
|
const codings = headers.get("Content-Encoding");
|
|
18108
18108
|
if (!request.compress || request.method === "HEAD" || codings === null || response_.statusCode === 204 || response_.statusCode === 304) {
|
|
18109
18109
|
response = new Response4(body, responseOptions);
|
|
18110
|
-
|
|
18110
|
+
resolve2(response);
|
|
18111
18111
|
return;
|
|
18112
18112
|
}
|
|
18113
18113
|
const zlibOptions = {
|
|
@@ -18121,7 +18121,7 @@ async function fetch4(url2, options_) {
|
|
|
18121
18121
|
}
|
|
18122
18122
|
});
|
|
18123
18123
|
response = new Response4(body, responseOptions);
|
|
18124
|
-
|
|
18124
|
+
resolve2(response);
|
|
18125
18125
|
return;
|
|
18126
18126
|
}
|
|
18127
18127
|
if (codings === "deflate" || codings === "x-deflate") {
|
|
@@ -18145,12 +18145,12 @@ async function fetch4(url2, options_) {
|
|
|
18145
18145
|
});
|
|
18146
18146
|
}
|
|
18147
18147
|
response = new Response4(body, responseOptions);
|
|
18148
|
-
|
|
18148
|
+
resolve2(response);
|
|
18149
18149
|
});
|
|
18150
18150
|
raw.once("end", () => {
|
|
18151
18151
|
if (!response) {
|
|
18152
18152
|
response = new Response4(body, responseOptions);
|
|
18153
|
-
|
|
18153
|
+
resolve2(response);
|
|
18154
18154
|
}
|
|
18155
18155
|
});
|
|
18156
18156
|
return;
|
|
@@ -18162,11 +18162,11 @@ async function fetch4(url2, options_) {
|
|
|
18162
18162
|
}
|
|
18163
18163
|
});
|
|
18164
18164
|
response = new Response4(body, responseOptions);
|
|
18165
|
-
|
|
18165
|
+
resolve2(response);
|
|
18166
18166
|
return;
|
|
18167
18167
|
}
|
|
18168
18168
|
response = new Response4(body, responseOptions);
|
|
18169
|
-
|
|
18169
|
+
resolve2(response);
|
|
18170
18170
|
});
|
|
18171
18171
|
writeToStream2(request_, request).catch(reject);
|
|
18172
18172
|
});
|
|
@@ -24194,7 +24194,7 @@ var require_jwtaccess = __commonJS({
|
|
|
24194
24194
|
}
|
|
24195
24195
|
}
|
|
24196
24196
|
fromStreamAsync(inputStream) {
|
|
24197
|
-
return new Promise((
|
|
24197
|
+
return new Promise((resolve2, reject) => {
|
|
24198
24198
|
if (!inputStream) {
|
|
24199
24199
|
reject(new Error("Must pass in a stream containing the service account auth settings."));
|
|
24200
24200
|
}
|
|
@@ -24203,7 +24203,7 @@ var require_jwtaccess = __commonJS({
|
|
|
24203
24203
|
try {
|
|
24204
24204
|
const data = JSON.parse(s3);
|
|
24205
24205
|
this.fromJSON(data);
|
|
24206
|
-
|
|
24206
|
+
resolve2();
|
|
24207
24207
|
} catch (err) {
|
|
24208
24208
|
reject(err);
|
|
24209
24209
|
}
|
|
@@ -24441,7 +24441,7 @@ var require_jwtclient = __commonJS({
|
|
|
24441
24441
|
}
|
|
24442
24442
|
}
|
|
24443
24443
|
fromStreamAsync(inputStream) {
|
|
24444
|
-
return new Promise((
|
|
24444
|
+
return new Promise((resolve2, reject) => {
|
|
24445
24445
|
if (!inputStream) {
|
|
24446
24446
|
throw new Error("Must pass in a stream containing the service account auth settings.");
|
|
24447
24447
|
}
|
|
@@ -24450,7 +24450,7 @@ var require_jwtclient = __commonJS({
|
|
|
24450
24450
|
try {
|
|
24451
24451
|
const data = JSON.parse(s3);
|
|
24452
24452
|
this.fromJSON(data);
|
|
24453
|
-
|
|
24453
|
+
resolve2();
|
|
24454
24454
|
} catch (e3) {
|
|
24455
24455
|
reject(e3);
|
|
24456
24456
|
}
|
|
@@ -24582,7 +24582,7 @@ var require_refreshclient = __commonJS({
|
|
|
24582
24582
|
}
|
|
24583
24583
|
}
|
|
24584
24584
|
async fromStreamAsync(inputStream) {
|
|
24585
|
-
return new Promise((
|
|
24585
|
+
return new Promise((resolve2, reject) => {
|
|
24586
24586
|
if (!inputStream) {
|
|
24587
24587
|
return reject(new Error("Must pass in a stream containing the user refresh token."));
|
|
24588
24588
|
}
|
|
@@ -24591,7 +24591,7 @@ var require_refreshclient = __commonJS({
|
|
|
24591
24591
|
try {
|
|
24592
24592
|
const data = JSON.parse(s3);
|
|
24593
24593
|
this.fromJSON(data);
|
|
24594
|
-
return
|
|
24594
|
+
return resolve2();
|
|
24595
24595
|
} catch (err) {
|
|
24596
24596
|
return reject(err);
|
|
24597
24597
|
}
|
|
@@ -26411,7 +26411,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
26411
26411
|
* @return A promise that resolves with the executable response.
|
|
26412
26412
|
*/
|
|
26413
26413
|
retrieveResponseFromExecutable(envMap) {
|
|
26414
|
-
return new Promise((
|
|
26414
|
+
return new Promise((resolve2, reject) => {
|
|
26415
26415
|
const child = childProcess.spawn(this.commandComponents[0], this.commandComponents.slice(1), {
|
|
26416
26416
|
env: { ...process.env, ...Object.fromEntries(envMap) }
|
|
26417
26417
|
});
|
|
@@ -26433,7 +26433,7 @@ var require_pluggable_auth_handler = __commonJS({
|
|
|
26433
26433
|
try {
|
|
26434
26434
|
const responseJson = JSON.parse(output);
|
|
26435
26435
|
const response = new executable_response_1.ExecutableResponse(responseJson);
|
|
26436
|
-
return
|
|
26436
|
+
return resolve2(response);
|
|
26437
26437
|
} catch (error2) {
|
|
26438
26438
|
if (error2 instanceof executable_response_1.ExecutableResponseError) {
|
|
26439
26439
|
return reject(error2);
|
|
@@ -27618,7 +27618,7 @@ var require_googleauth = __commonJS({
|
|
|
27618
27618
|
}
|
|
27619
27619
|
}
|
|
27620
27620
|
fromStreamAsync(inputStream, options) {
|
|
27621
|
-
return new Promise((
|
|
27621
|
+
return new Promise((resolve2, reject) => {
|
|
27622
27622
|
if (!inputStream) {
|
|
27623
27623
|
throw new Error("Must pass in a stream containing the Google auth settings.");
|
|
27624
27624
|
}
|
|
@@ -27628,7 +27628,7 @@ var require_googleauth = __commonJS({
|
|
|
27628
27628
|
try {
|
|
27629
27629
|
const data = JSON.parse(chunks.join(""));
|
|
27630
27630
|
const r4 = this._cacheClientFromJSON(data, options);
|
|
27631
|
-
return
|
|
27631
|
+
return resolve2(r4);
|
|
27632
27632
|
} catch (err) {
|
|
27633
27633
|
if (!this.keyFilename)
|
|
27634
27634
|
throw err;
|
|
@@ -27638,7 +27638,7 @@ var require_googleauth = __commonJS({
|
|
|
27638
27638
|
});
|
|
27639
27639
|
this.cachedCredential = client;
|
|
27640
27640
|
this.setGapicJWTValues(client);
|
|
27641
|
-
return
|
|
27641
|
+
return resolve2(client);
|
|
27642
27642
|
}
|
|
27643
27643
|
} catch (err) {
|
|
27644
27644
|
return reject(err);
|
|
@@ -27674,17 +27674,17 @@ var require_googleauth = __commonJS({
|
|
|
27674
27674
|
* Run the Google Cloud SDK command that prints the default project ID
|
|
27675
27675
|
*/
|
|
27676
27676
|
async getDefaultServiceProjectId() {
|
|
27677
|
-
return new Promise((
|
|
27677
|
+
return new Promise((resolve2) => {
|
|
27678
27678
|
(0, child_process_1.exec)("gcloud config config-helper --format json", (err, stdout) => {
|
|
27679
27679
|
if (!err && stdout) {
|
|
27680
27680
|
try {
|
|
27681
27681
|
const projectId = JSON.parse(stdout).configuration.properties.core.project;
|
|
27682
|
-
|
|
27682
|
+
resolve2(projectId);
|
|
27683
27683
|
return;
|
|
27684
27684
|
} catch (e3) {
|
|
27685
27685
|
}
|
|
27686
27686
|
}
|
|
27687
|
-
|
|
27687
|
+
resolve2(null);
|
|
27688
27688
|
});
|
|
27689
27689
|
});
|
|
27690
27690
|
}
|
|
@@ -34833,9 +34833,9 @@ var require_clone = __commonJS({
|
|
|
34833
34833
|
} else if (_instanceof(parent2, nativeSet)) {
|
|
34834
34834
|
child = new nativeSet();
|
|
34835
34835
|
} else if (_instanceof(parent2, nativePromise)) {
|
|
34836
|
-
child = new nativePromise(function(
|
|
34836
|
+
child = new nativePromise(function(resolve2, reject) {
|
|
34837
34837
|
parent2.then(function(value) {
|
|
34838
|
-
|
|
34838
|
+
resolve2(_clone(value, depth2 - 1));
|
|
34839
34839
|
}, function(err) {
|
|
34840
34840
|
reject(_clone(err, depth2 - 1));
|
|
34841
34841
|
});
|
|
@@ -164064,7 +164064,7 @@ var require_compile = __commonJS({
|
|
|
164064
164064
|
const schOrFunc = root.refs[ref];
|
|
164065
164065
|
if (schOrFunc)
|
|
164066
164066
|
return schOrFunc;
|
|
164067
|
-
let _sch =
|
|
164067
|
+
let _sch = resolve2.call(this, root, ref);
|
|
164068
164068
|
if (_sch === void 0) {
|
|
164069
164069
|
const schema = (_a5 = root.localRefs) === null || _a5 === void 0 ? void 0 : _a5[ref];
|
|
164070
164070
|
const { schemaId } = this.opts;
|
|
@@ -164091,7 +164091,7 @@ var require_compile = __commonJS({
|
|
|
164091
164091
|
function sameSchemaEnv(s1, s22) {
|
|
164092
164092
|
return s1.schema === s22.schema && s1.root === s22.root && s1.baseId === s22.baseId;
|
|
164093
164093
|
}
|
|
164094
|
-
function
|
|
164094
|
+
function resolve2(root, ref) {
|
|
164095
164095
|
let sch;
|
|
164096
164096
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
164097
164097
|
ref = sch;
|
|
@@ -164719,7 +164719,7 @@ var require_fast_uri = __commonJS({
|
|
|
164719
164719
|
}
|
|
164720
164720
|
return uri;
|
|
164721
164721
|
}
|
|
164722
|
-
function
|
|
164722
|
+
function resolve2(baseURI, relativeURI, options) {
|
|
164723
164723
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
164724
164724
|
const resolved = resolveComponent(parse5(baseURI, schemelessOptions), parse5(relativeURI, schemelessOptions), schemelessOptions, true);
|
|
164725
164725
|
schemelessOptions.skipEscape = true;
|
|
@@ -164977,7 +164977,7 @@ var require_fast_uri = __commonJS({
|
|
|
164977
164977
|
var fastUri = {
|
|
164978
164978
|
SCHEMES,
|
|
164979
164979
|
normalize: normalize3,
|
|
164980
|
-
resolve,
|
|
164980
|
+
resolve: resolve2,
|
|
164981
164981
|
resolveComponent,
|
|
164982
164982
|
equal,
|
|
164983
164983
|
serialize,
|
|
@@ -168015,12 +168015,12 @@ var require_isexe = __commonJS({
|
|
|
168015
168015
|
if (typeof Promise !== "function") {
|
|
168016
168016
|
throw new TypeError("callback not provided");
|
|
168017
168017
|
}
|
|
168018
|
-
return new Promise(function(
|
|
168018
|
+
return new Promise(function(resolve2, reject) {
|
|
168019
168019
|
isexe(path28, options || {}, function(er2, is2) {
|
|
168020
168020
|
if (er2) {
|
|
168021
168021
|
reject(er2);
|
|
168022
168022
|
} else {
|
|
168023
|
-
|
|
168023
|
+
resolve2(is2);
|
|
168024
168024
|
}
|
|
168025
168025
|
});
|
|
168026
168026
|
});
|
|
@@ -168086,27 +168086,27 @@ var require_which = __commonJS({
|
|
|
168086
168086
|
opt = {};
|
|
168087
168087
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
168088
168088
|
const found = [];
|
|
168089
|
-
const step = (i4) => new Promise((
|
|
168089
|
+
const step = (i4) => new Promise((resolve2, reject) => {
|
|
168090
168090
|
if (i4 === pathEnv.length)
|
|
168091
|
-
return opt.all && found.length ?
|
|
168091
|
+
return opt.all && found.length ? resolve2(found) : reject(getNotFoundError(cmd));
|
|
168092
168092
|
const ppRaw = pathEnv[i4];
|
|
168093
168093
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
168094
168094
|
const pCmd = path28.join(pathPart, cmd);
|
|
168095
168095
|
const p3 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
168096
|
-
|
|
168096
|
+
resolve2(subStep(p3, i4, 0));
|
|
168097
168097
|
});
|
|
168098
|
-
const subStep = (p3, i4, ii2) => new Promise((
|
|
168098
|
+
const subStep = (p3, i4, ii2) => new Promise((resolve2, reject) => {
|
|
168099
168099
|
if (ii2 === pathExt.length)
|
|
168100
|
-
return
|
|
168100
|
+
return resolve2(step(i4 + 1));
|
|
168101
168101
|
const ext = pathExt[ii2];
|
|
168102
168102
|
isexe(p3 + ext, { pathExt: pathExtExe }, (er2, is2) => {
|
|
168103
168103
|
if (!er2 && is2) {
|
|
168104
168104
|
if (opt.all)
|
|
168105
168105
|
found.push(p3 + ext);
|
|
168106
168106
|
else
|
|
168107
|
-
return
|
|
168107
|
+
return resolve2(p3 + ext);
|
|
168108
168108
|
}
|
|
168109
|
-
return
|
|
168109
|
+
return resolve2(subStep(p3, i4, ii2 + 1));
|
|
168110
168110
|
});
|
|
168111
168111
|
});
|
|
168112
168112
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -168890,7 +168890,7 @@ function isErrorEvent(event) {
|
|
|
168890
168890
|
function isEvent(candidate) {
|
|
168891
168891
|
return "undefined" != typeof Event && isInstanceOf(candidate, Event);
|
|
168892
168892
|
}
|
|
168893
|
-
function
|
|
168893
|
+
function isPlainObject6(candidate) {
|
|
168894
168894
|
return isBuiltin(candidate, "Object");
|
|
168895
168895
|
}
|
|
168896
168896
|
function isInstanceOf(candidate, base) {
|
|
@@ -171212,14 +171212,14 @@ async function addSourceContext(frames) {
|
|
|
171212
171212
|
return frames;
|
|
171213
171213
|
}
|
|
171214
171214
|
function getContextLinesFromFile(path28, ranges, output) {
|
|
171215
|
-
return new Promise((
|
|
171215
|
+
return new Promise((resolve2) => {
|
|
171216
171216
|
const stream2 = fs11.createReadStream(path28);
|
|
171217
171217
|
const lineReaded = readline.createInterface({
|
|
171218
171218
|
input: stream2
|
|
171219
171219
|
});
|
|
171220
171220
|
function destroyStreamAndResolve() {
|
|
171221
171221
|
stream2.destroy();
|
|
171222
|
-
|
|
171222
|
+
resolve2();
|
|
171223
171223
|
}
|
|
171224
171224
|
let lineNumber = 0;
|
|
171225
171225
|
let currentRangeIndex = 0;
|
|
@@ -172575,9 +172575,9 @@ var init_client = __esm({
|
|
|
172575
172575
|
if (!waitUntil) return;
|
|
172576
172576
|
if (this.disabled || this.optedOut) return;
|
|
172577
172577
|
if (!this._waitUntilCycle) {
|
|
172578
|
-
let
|
|
172578
|
+
let resolve2;
|
|
172579
172579
|
const promise = new Promise((r4) => {
|
|
172580
|
-
|
|
172580
|
+
resolve2 = r4;
|
|
172581
172581
|
});
|
|
172582
172582
|
try {
|
|
172583
172583
|
waitUntil(promise);
|
|
@@ -172585,7 +172585,7 @@ var init_client = __esm({
|
|
|
172585
172585
|
return;
|
|
172586
172586
|
}
|
|
172587
172587
|
this._waitUntilCycle = {
|
|
172588
|
-
resolve,
|
|
172588
|
+
resolve: resolve2,
|
|
172589
172589
|
startedAt: Date.now(),
|
|
172590
172590
|
timer: void 0
|
|
172591
172591
|
};
|
|
@@ -172609,12 +172609,12 @@ var init_client = __esm({
|
|
|
172609
172609
|
return cycle?.resolve;
|
|
172610
172610
|
}
|
|
172611
172611
|
async resolveWaitUntilFlush() {
|
|
172612
|
-
const
|
|
172612
|
+
const resolve2 = this._consumeWaitUntilCycle();
|
|
172613
172613
|
try {
|
|
172614
172614
|
await super.flush();
|
|
172615
172615
|
} catch {
|
|
172616
172616
|
} finally {
|
|
172617
|
-
|
|
172617
|
+
resolve2?.();
|
|
172618
172618
|
}
|
|
172619
172619
|
}
|
|
172620
172620
|
getPersistedProperty(key) {
|
|
@@ -172713,15 +172713,15 @@ var init_client = __esm({
|
|
|
172713
172713
|
async waitForLocalEvaluationReady(timeoutMs = THIRTY_SECONDS) {
|
|
172714
172714
|
if (this.isLocalEvaluationReady()) return true;
|
|
172715
172715
|
if (void 0 === this.featureFlagsPoller) return false;
|
|
172716
|
-
return new Promise((
|
|
172716
|
+
return new Promise((resolve2) => {
|
|
172717
172717
|
const timeout = setTimeout(() => {
|
|
172718
172718
|
cleanup();
|
|
172719
|
-
|
|
172719
|
+
resolve2(false);
|
|
172720
172720
|
}, timeoutMs);
|
|
172721
172721
|
const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
|
|
172722
172722
|
clearTimeout(timeout);
|
|
172723
172723
|
cleanup();
|
|
172724
|
-
|
|
172724
|
+
resolve2(count > 0);
|
|
172725
172725
|
});
|
|
172726
172726
|
});
|
|
172727
172727
|
}
|
|
@@ -173176,13 +173176,13 @@ var init_client = __esm({
|
|
|
173176
173176
|
this.context?.enter(data, options);
|
|
173177
173177
|
}
|
|
173178
173178
|
async _shutdown(shutdownTimeoutMs) {
|
|
173179
|
-
const
|
|
173179
|
+
const resolve2 = this._consumeWaitUntilCycle();
|
|
173180
173180
|
await this.featureFlagsPoller?.stopPoller(shutdownTimeoutMs);
|
|
173181
173181
|
this.errorTracking.shutdown();
|
|
173182
173182
|
try {
|
|
173183
173183
|
return await super._shutdown(shutdownTimeoutMs);
|
|
173184
173184
|
} finally {
|
|
173185
|
-
|
|
173185
|
+
resolve2?.();
|
|
173186
173186
|
}
|
|
173187
173187
|
}
|
|
173188
173188
|
async _requestRemoteConfigPayload(flagKey) {
|
|
@@ -173220,7 +173220,7 @@ var init_client = __esm({
|
|
|
173220
173220
|
};
|
|
173221
173221
|
const personProperties = {};
|
|
173222
173222
|
const groupProperties = {};
|
|
173223
|
-
for (const [key, value] of Object.entries(eventProperties)) if (
|
|
173223
|
+
for (const [key, value] of Object.entries(eventProperties)) if (isPlainObject6(value) && groups && key in groups) {
|
|
173224
173224
|
const groupProps = {};
|
|
173225
173225
|
for (const [groupKey, groupValue] of Object.entries(value)) groupProps[String(groupKey)] = String(groupValue);
|
|
173226
173226
|
groupProperties[String(key)] = groupProps;
|
|
@@ -178400,10 +178400,10 @@ var require_raw_body = __commonJS({
|
|
|
178400
178400
|
if (done) {
|
|
178401
178401
|
return readStream(stream2, encoding, length, limit2, wrap(done));
|
|
178402
178402
|
}
|
|
178403
|
-
return new Promise(function executor(
|
|
178403
|
+
return new Promise(function executor(resolve2, reject) {
|
|
178404
178404
|
readStream(stream2, encoding, length, limit2, function onRead(err, buf) {
|
|
178405
178405
|
if (err) return reject(err);
|
|
178406
|
-
|
|
178406
|
+
resolve2(buf);
|
|
178407
178407
|
});
|
|
178408
178408
|
});
|
|
178409
178409
|
}
|
|
@@ -187652,7 +187652,7 @@ var require_type_is = __commonJS({
|
|
|
187652
187652
|
}
|
|
187653
187653
|
return true;
|
|
187654
187654
|
}
|
|
187655
|
-
function
|
|
187655
|
+
function normalizeType2(value) {
|
|
187656
187656
|
var type = typer.parse(value);
|
|
187657
187657
|
type.parameters = void 0;
|
|
187658
187658
|
return typer.format(type);
|
|
@@ -187662,7 +187662,7 @@ var require_type_is = __commonJS({
|
|
|
187662
187662
|
return null;
|
|
187663
187663
|
}
|
|
187664
187664
|
try {
|
|
187665
|
-
return
|
|
187665
|
+
return normalizeType2(value);
|
|
187666
187666
|
} catch (err) {
|
|
187667
187667
|
return null;
|
|
187668
187668
|
}
|
|
@@ -188168,10 +188168,10 @@ var require_object_inspect = __commonJS({
|
|
|
188168
188168
|
}
|
|
188169
188169
|
if (!isDate(obj) && !isRegExp(obj)) {
|
|
188170
188170
|
var ys2 = arrObjKeys(obj, inspect2);
|
|
188171
|
-
var
|
|
188171
|
+
var isPlainObject7 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
|
|
188172
188172
|
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
188173
|
-
var stringTag = !
|
|
188174
|
-
var constructorTag =
|
|
188173
|
+
var stringTag = !isPlainObject7 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
|
|
188174
|
+
var constructorTag = isPlainObject7 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
|
|
188175
188175
|
var tag = constructorTag + (stringTag || protoTag ? "[" + $join.call($concat.call([], stringTag || [], protoTag || []), ": ") + "] " : "");
|
|
188176
188176
|
if (ys2.length === 0) {
|
|
188177
188177
|
return tag + "{}";
|
|
@@ -191823,7 +191823,7 @@ var require_view = __commonJS({
|
|
|
191823
191823
|
var basename4 = path28.basename;
|
|
191824
191824
|
var extname = path28.extname;
|
|
191825
191825
|
var join = path28.join;
|
|
191826
|
-
var
|
|
191826
|
+
var resolve2 = path28.resolve;
|
|
191827
191827
|
module.exports = View;
|
|
191828
191828
|
function View(name, options) {
|
|
191829
191829
|
var opts = options || {};
|
|
@@ -191857,7 +191857,7 @@ var require_view = __commonJS({
|
|
|
191857
191857
|
debug3('lookup "%s"', name);
|
|
191858
191858
|
for (var i4 = 0; i4 < roots.length && !path29; i4++) {
|
|
191859
191859
|
var root = roots[i4];
|
|
191860
|
-
var loc =
|
|
191860
|
+
var loc = resolve2(root, name);
|
|
191861
191861
|
var dir = dirname2(loc);
|
|
191862
191862
|
var file = basename4(loc);
|
|
191863
191863
|
path29 = this.resolve(dir, file);
|
|
@@ -191868,7 +191868,7 @@ var require_view = __commonJS({
|
|
|
191868
191868
|
debug3('render "%s"', this.path);
|
|
191869
191869
|
this.engine(this.path, options, callback);
|
|
191870
191870
|
};
|
|
191871
|
-
View.prototype.resolve = function
|
|
191871
|
+
View.prototype.resolve = function resolve3(dir, file) {
|
|
191872
191872
|
var ext = this.ext;
|
|
191873
191873
|
var path29 = join(dir, file);
|
|
191874
191874
|
var stat3 = tryStat(path29);
|
|
@@ -192447,7 +192447,7 @@ var require_send = __commonJS({
|
|
|
192447
192447
|
var extname = path28.extname;
|
|
192448
192448
|
var join = path28.join;
|
|
192449
192449
|
var normalize3 = path28.normalize;
|
|
192450
|
-
var
|
|
192450
|
+
var resolve2 = path28.resolve;
|
|
192451
192451
|
var sep3 = path28.sep;
|
|
192452
192452
|
var BYTES_RANGE_REGEXP = /^ *bytes=/;
|
|
192453
192453
|
var MAX_MAXAGE = 60 * 60 * 24 * 365 * 1e3;
|
|
@@ -192484,7 +192484,7 @@ var require_send = __commonJS({
|
|
|
192484
192484
|
this._maxage = opts.maxAge || opts.maxage;
|
|
192485
192485
|
this._maxage = typeof this._maxage === "string" ? ms2(this._maxage) : Number(this._maxage);
|
|
192486
192486
|
this._maxage = !isNaN(this._maxage) ? Math.min(Math.max(0, this._maxage), MAX_MAXAGE) : 0;
|
|
192487
|
-
this._root = opts.root ?
|
|
192487
|
+
this._root = opts.root ? resolve2(opts.root) : null;
|
|
192488
192488
|
if (!this._root && opts.from) {
|
|
192489
192489
|
this.from(opts.from);
|
|
192490
192490
|
}
|
|
@@ -192508,7 +192508,7 @@ var require_send = __commonJS({
|
|
|
192508
192508
|
return this;
|
|
192509
192509
|
}, "send.index: pass index as option");
|
|
192510
192510
|
SendStream.prototype.root = function root(path29) {
|
|
192511
|
-
this._root =
|
|
192511
|
+
this._root = resolve2(String(path29));
|
|
192512
192512
|
debug3("root %s", this._root);
|
|
192513
192513
|
return this;
|
|
192514
192514
|
};
|
|
@@ -192672,7 +192672,7 @@ var require_send = __commonJS({
|
|
|
192672
192672
|
return res;
|
|
192673
192673
|
}
|
|
192674
192674
|
parts = normalize3(path29).split(sep3);
|
|
192675
|
-
path29 =
|
|
192675
|
+
path29 = resolve2(path29);
|
|
192676
192676
|
}
|
|
192677
192677
|
if (containsDotFile(parts)) {
|
|
192678
192678
|
var access = this._dotfiles;
|
|
@@ -193940,7 +193940,7 @@ var require_application = __commonJS({
|
|
|
193940
193940
|
var deprecate4 = require_depd()("express");
|
|
193941
193941
|
var flatten = require_array_flatten();
|
|
193942
193942
|
var merge2 = require_utils_merge();
|
|
193943
|
-
var
|
|
193943
|
+
var resolve2 = __require("path").resolve;
|
|
193944
193944
|
var setPrototypeOf = require_setprototypeof();
|
|
193945
193945
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
193946
193946
|
var slice = Array.prototype.slice;
|
|
@@ -193979,7 +193979,7 @@ var require_application = __commonJS({
|
|
|
193979
193979
|
this.mountpath = "/";
|
|
193980
193980
|
this.locals.settings = this.settings;
|
|
193981
193981
|
this.set("view", View);
|
|
193982
|
-
this.set("views",
|
|
193982
|
+
this.set("views", resolve2("views"));
|
|
193983
193983
|
this.set("jsonp callback name", "callback");
|
|
193984
193984
|
if (env === "production") {
|
|
193985
193985
|
this.enable("view cache");
|
|
@@ -195207,14 +195207,14 @@ var require_response = __commonJS({
|
|
|
195207
195207
|
var statuses = require_statuses();
|
|
195208
195208
|
var merge2 = require_utils_merge();
|
|
195209
195209
|
var sign = require_cookie_signature().sign;
|
|
195210
|
-
var
|
|
195210
|
+
var normalizeType2 = require_utils5().normalizeType;
|
|
195211
195211
|
var normalizeTypes = require_utils5().normalizeTypes;
|
|
195212
195212
|
var setCharset = require_utils5().setCharset;
|
|
195213
195213
|
var cookie = require_cookie();
|
|
195214
195214
|
var send = require_send();
|
|
195215
195215
|
var extname = path28.extname;
|
|
195216
195216
|
var mime = send.mime;
|
|
195217
|
-
var
|
|
195217
|
+
var resolve2 = path28.resolve;
|
|
195218
195218
|
var vary = require_vary();
|
|
195219
195219
|
var res = Object.create(http7.ServerResponse.prototype);
|
|
195220
195220
|
module.exports = res;
|
|
@@ -195473,7 +195473,7 @@ var require_response = __commonJS({
|
|
|
195473
195473
|
}
|
|
195474
195474
|
opts = Object.create(opts);
|
|
195475
195475
|
opts.headers = headers;
|
|
195476
|
-
var fullPath = !opts.root ?
|
|
195476
|
+
var fullPath = !opts.root ? resolve2(path29) : path29;
|
|
195477
195477
|
return this.sendFile(fullPath, opts, done);
|
|
195478
195478
|
};
|
|
195479
195479
|
res.contentType = res.type = function contentType(type) {
|
|
@@ -195489,7 +195489,7 @@ var require_response = __commonJS({
|
|
|
195489
195489
|
var key = keys.length > 0 ? req.accepts(keys) : false;
|
|
195490
195490
|
this.vary("Accept");
|
|
195491
195491
|
if (key) {
|
|
195492
|
-
this.set("Content-Type",
|
|
195492
|
+
this.set("Content-Type", normalizeType2(key).value);
|
|
195493
195493
|
obj[key](req, this, next);
|
|
195494
195494
|
} else if (obj.default) {
|
|
195495
195495
|
obj.default(req, this, next);
|
|
@@ -195738,7 +195738,7 @@ var require_serve_static = __commonJS({
|
|
|
195738
195738
|
var encodeUrl = require_encodeurl();
|
|
195739
195739
|
var escapeHtml = require_escape_html();
|
|
195740
195740
|
var parseUrl = require_parseurl();
|
|
195741
|
-
var
|
|
195741
|
+
var resolve2 = __require("path").resolve;
|
|
195742
195742
|
var send = require_send();
|
|
195743
195743
|
var url2 = __require("url");
|
|
195744
195744
|
module.exports = serveStatic;
|
|
@@ -195758,7 +195758,7 @@ var require_serve_static = __commonJS({
|
|
|
195758
195758
|
throw new TypeError("option setHeaders must be function");
|
|
195759
195759
|
}
|
|
195760
195760
|
opts.maxage = opts.maxage || opts.maxAge || 0;
|
|
195761
|
-
opts.root =
|
|
195761
|
+
opts.root = resolve2(root);
|
|
195762
195762
|
var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
|
|
195763
195763
|
return function serveStatic2(req, res, next) {
|
|
195764
195764
|
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
@@ -195990,13 +195990,13 @@ var require_bcrypt = __commonJS({
|
|
|
195990
195990
|
throw Error("Illegal callback: " + typeof callback);
|
|
195991
195991
|
_async(callback);
|
|
195992
195992
|
} else
|
|
195993
|
-
return new Promise(function(
|
|
195993
|
+
return new Promise(function(resolve2, reject) {
|
|
195994
195994
|
_async(function(err, res) {
|
|
195995
195995
|
if (err) {
|
|
195996
195996
|
reject(err);
|
|
195997
195997
|
return;
|
|
195998
195998
|
}
|
|
195999
|
-
|
|
195999
|
+
resolve2(res);
|
|
196000
196000
|
});
|
|
196001
196001
|
});
|
|
196002
196002
|
};
|
|
@@ -196025,13 +196025,13 @@ var require_bcrypt = __commonJS({
|
|
|
196025
196025
|
throw Error("Illegal callback: " + typeof callback);
|
|
196026
196026
|
_async(callback);
|
|
196027
196027
|
} else
|
|
196028
|
-
return new Promise(function(
|
|
196028
|
+
return new Promise(function(resolve2, reject) {
|
|
196029
196029
|
_async(function(err, res) {
|
|
196030
196030
|
if (err) {
|
|
196031
196031
|
reject(err);
|
|
196032
196032
|
return;
|
|
196033
196033
|
}
|
|
196034
|
-
|
|
196034
|
+
resolve2(res);
|
|
196035
196035
|
});
|
|
196036
196036
|
});
|
|
196037
196037
|
};
|
|
@@ -196076,13 +196076,13 @@ var require_bcrypt = __commonJS({
|
|
|
196076
196076
|
throw Error("Illegal callback: " + typeof callback);
|
|
196077
196077
|
_async(callback);
|
|
196078
196078
|
} else
|
|
196079
|
-
return new Promise(function(
|
|
196079
|
+
return new Promise(function(resolve2, reject) {
|
|
196080
196080
|
_async(function(err, res) {
|
|
196081
196081
|
if (err) {
|
|
196082
196082
|
reject(err);
|
|
196083
196083
|
return;
|
|
196084
196084
|
}
|
|
196085
|
-
|
|
196085
|
+
resolve2(res);
|
|
196086
196086
|
});
|
|
196087
196087
|
});
|
|
196088
196088
|
};
|
|
@@ -204648,13 +204648,13 @@ var require_broadcast_operator = __commonJS({
|
|
|
204648
204648
|
* @return a Promise that will be fulfilled when all clients have acknowledged the event
|
|
204649
204649
|
*/
|
|
204650
204650
|
emitWithAck(ev, ...args) {
|
|
204651
|
-
return new Promise((
|
|
204651
|
+
return new Promise((resolve2, reject) => {
|
|
204652
204652
|
args.push((err, responses) => {
|
|
204653
204653
|
if (err) {
|
|
204654
204654
|
err.responses = responses;
|
|
204655
204655
|
return reject(err);
|
|
204656
204656
|
} else {
|
|
204657
|
-
return
|
|
204657
|
+
return resolve2(responses);
|
|
204658
204658
|
}
|
|
204659
204659
|
});
|
|
204660
204660
|
this.emit(ev, ...args);
|
|
@@ -205007,12 +205007,12 @@ var require_socket2 = __commonJS({
|
|
|
205007
205007
|
*/
|
|
205008
205008
|
emitWithAck(ev, ...args) {
|
|
205009
205009
|
const withErr = this.flags.timeout !== void 0;
|
|
205010
|
-
return new Promise((
|
|
205010
|
+
return new Promise((resolve2, reject) => {
|
|
205011
205011
|
args.push((arg1, arg2) => {
|
|
205012
205012
|
if (withErr) {
|
|
205013
|
-
return arg1 ? reject(arg1) :
|
|
205013
|
+
return arg1 ? reject(arg1) : resolve2(arg2);
|
|
205014
205014
|
} else {
|
|
205015
|
-
return
|
|
205015
|
+
return resolve2(arg1);
|
|
205016
205016
|
}
|
|
205017
205017
|
});
|
|
205018
205018
|
this.emit(ev, ...args);
|
|
@@ -206081,13 +206081,13 @@ var require_namespace = __commonJS({
|
|
|
206081
206081
|
* @return a Promise that will be fulfilled when all servers have acknowledged the event
|
|
206082
206082
|
*/
|
|
206083
206083
|
serverSideEmitWithAck(ev, ...args) {
|
|
206084
|
-
return new Promise((
|
|
206084
|
+
return new Promise((resolve2, reject) => {
|
|
206085
206085
|
args.push((err, responses) => {
|
|
206086
206086
|
if (err) {
|
|
206087
206087
|
err.responses = responses;
|
|
206088
206088
|
return reject(err);
|
|
206089
206089
|
} else {
|
|
206090
|
-
return
|
|
206090
|
+
return resolve2(responses);
|
|
206091
206091
|
}
|
|
206092
206092
|
});
|
|
206093
206093
|
this.serverSideEmit(ev, ...args);
|
|
@@ -207693,7 +207693,7 @@ var require_cluster_adapter = __commonJS({
|
|
|
207693
207693
|
return localSockets;
|
|
207694
207694
|
}
|
|
207695
207695
|
const requestId = randomId();
|
|
207696
|
-
return new Promise((
|
|
207696
|
+
return new Promise((resolve2, reject) => {
|
|
207697
207697
|
const timeout = setTimeout(() => {
|
|
207698
207698
|
const storedRequest2 = this.requests.get(requestId);
|
|
207699
207699
|
if (storedRequest2) {
|
|
@@ -207703,7 +207703,7 @@ var require_cluster_adapter = __commonJS({
|
|
|
207703
207703
|
}, opts.flags.timeout || DEFAULT_TIMEOUT);
|
|
207704
207704
|
const storedRequest = {
|
|
207705
207705
|
type: MessageType.FETCH_SOCKETS,
|
|
207706
|
-
resolve,
|
|
207706
|
+
resolve: resolve2,
|
|
207707
207707
|
timeout,
|
|
207708
207708
|
current: 0,
|
|
207709
207709
|
expected: expectedResponseCount,
|
|
@@ -207914,7 +207914,7 @@ var require_cluster_adapter = __commonJS({
|
|
|
207914
207914
|
return localSockets;
|
|
207915
207915
|
}
|
|
207916
207916
|
const requestId = randomId();
|
|
207917
|
-
return new Promise((
|
|
207917
|
+
return new Promise((resolve2, reject) => {
|
|
207918
207918
|
const timeout = setTimeout(() => {
|
|
207919
207919
|
const storedRequest2 = this.customRequests.get(requestId);
|
|
207920
207920
|
if (storedRequest2) {
|
|
@@ -207924,7 +207924,7 @@ var require_cluster_adapter = __commonJS({
|
|
|
207924
207924
|
}, opts.flags.timeout || DEFAULT_TIMEOUT);
|
|
207925
207925
|
const storedRequest = {
|
|
207926
207926
|
type: MessageType.FETCH_SOCKETS,
|
|
207927
|
-
resolve,
|
|
207927
|
+
resolve: resolve2,
|
|
207928
207928
|
timeout,
|
|
207929
207929
|
missingUids: /* @__PURE__ */ new Set([...this.nodesMap.keys()]),
|
|
207930
207930
|
responses: localSockets
|
|
@@ -208747,13 +208747,13 @@ var require_dist7 = __commonJS({
|
|
|
208747
208747
|
this.engine.close();
|
|
208748
208748
|
(0, uws_1.restoreAdapter)();
|
|
208749
208749
|
if (this.httpServer) {
|
|
208750
|
-
return new Promise((
|
|
208750
|
+
return new Promise((resolve2) => {
|
|
208751
208751
|
this.httpServer.close((err) => {
|
|
208752
208752
|
fn && fn(err);
|
|
208753
208753
|
if (err) {
|
|
208754
208754
|
debug3("server was not running");
|
|
208755
208755
|
}
|
|
208756
|
-
|
|
208756
|
+
resolve2();
|
|
208757
208757
|
});
|
|
208758
208758
|
});
|
|
208759
208759
|
} else {
|
|
@@ -212487,7 +212487,7 @@ var require_lodash5 = __commonJS({
|
|
|
212487
212487
|
function isObjectLike(value) {
|
|
212488
212488
|
return !!value && typeof value == "object";
|
|
212489
212489
|
}
|
|
212490
|
-
function
|
|
212490
|
+
function isPlainObject7(value) {
|
|
212491
212491
|
if (!isObjectLike(value) || objectToString2.call(value) != objectTag || isHostObject(value)) {
|
|
212492
212492
|
return false;
|
|
212493
212493
|
}
|
|
@@ -212498,7 +212498,7 @@ var require_lodash5 = __commonJS({
|
|
|
212498
212498
|
var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
212499
212499
|
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
|
212500
212500
|
}
|
|
212501
|
-
module.exports =
|
|
212501
|
+
module.exports = isPlainObject7;
|
|
212502
212502
|
}
|
|
212503
212503
|
});
|
|
212504
212504
|
|
|
@@ -212611,7 +212611,7 @@ var require_sign2 = __commonJS({
|
|
|
212611
212611
|
var isBoolean2 = require_lodash2();
|
|
212612
212612
|
var isInteger = require_lodash3();
|
|
212613
212613
|
var isNumber2 = require_lodash4();
|
|
212614
|
-
var
|
|
212614
|
+
var isPlainObject7 = require_lodash5();
|
|
212615
212615
|
var isString2 = require_lodash6();
|
|
212616
212616
|
var once = require_lodash7();
|
|
212617
212617
|
var { KeyObject, createSecretKey, createPrivateKey } = __require("crypto");
|
|
@@ -212630,7 +212630,7 @@ var require_sign2 = __commonJS({
|
|
|
212630
212630
|
return isString2(value) || Array.isArray(value);
|
|
212631
212631
|
}, message: '"audience" must be a string or array' },
|
|
212632
212632
|
algorithm: { isValid: includes2.bind(null, SUPPORTED_ALGS), message: '"algorithm" must be a valid string enum value' },
|
|
212633
|
-
header: { isValid:
|
|
212633
|
+
header: { isValid: isPlainObject7, message: '"header" must be an object' },
|
|
212634
212634
|
encoding: { isValid: isString2, message: '"encoding" must be a string' },
|
|
212635
212635
|
issuer: { isValid: isString2, message: '"issuer" must be a string' },
|
|
212636
212636
|
subject: { isValid: isString2, message: '"subject" must be a string' },
|
|
@@ -212647,7 +212647,7 @@ var require_sign2 = __commonJS({
|
|
|
212647
212647
|
nbf: { isValid: isNumber2, message: '"nbf" should be a number of seconds' }
|
|
212648
212648
|
};
|
|
212649
212649
|
function validate2(schema, allowUnknown, object3, parameterName) {
|
|
212650
|
-
if (!
|
|
212650
|
+
if (!isPlainObject7(object3)) {
|
|
212651
212651
|
throw new Error('Expected "' + parameterName + '" to be a plain object.');
|
|
212652
212652
|
}
|
|
212653
212653
|
Object.keys(object3).forEach(function(key) {
|
|
@@ -216892,7 +216892,7 @@ var safeJSON = (text) => {
|
|
|
216892
216892
|
};
|
|
216893
216893
|
|
|
216894
216894
|
// node_modules/@anthropic-ai/sdk/internal/utils/sleep.mjs
|
|
216895
|
-
var sleep = (ms2) => new Promise((
|
|
216895
|
+
var sleep = (ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2));
|
|
216896
216896
|
|
|
216897
216897
|
// node_modules/@anthropic-ai/sdk/version.mjs
|
|
216898
216898
|
var VERSION = "0.90.0";
|
|
@@ -217606,8 +217606,8 @@ function addRequestID(value, response) {
|
|
|
217606
217606
|
var _APIPromise_client;
|
|
217607
217607
|
var APIPromise = class _APIPromise extends Promise {
|
|
217608
217608
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse) {
|
|
217609
|
-
super((
|
|
217610
|
-
|
|
217609
|
+
super((resolve2) => {
|
|
217610
|
+
resolve2(null);
|
|
217611
217611
|
});
|
|
217612
217612
|
this.responsePromise = responsePromise;
|
|
217613
217613
|
this.parseResponse = parseResponse2;
|
|
@@ -219027,12 +219027,12 @@ var BetaMessageStream = class _BetaMessageStream {
|
|
|
219027
219027
|
}
|
|
219028
219028
|
return this._emit("error", new AnthropicError(String(error2)));
|
|
219029
219029
|
});
|
|
219030
|
-
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((
|
|
219031
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise,
|
|
219030
|
+
__classPrivateFieldSet(this, _BetaMessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
219031
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve2, "f");
|
|
219032
219032
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectConnectedPromise, reject, "f");
|
|
219033
219033
|
}));
|
|
219034
|
-
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((
|
|
219035
|
-
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise,
|
|
219034
|
+
__classPrivateFieldSet(this, _BetaMessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
219035
|
+
__classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve2, "f");
|
|
219036
219036
|
__classPrivateFieldSet(this, _BetaMessageStream_rejectEndPromise, reject, "f");
|
|
219037
219037
|
}));
|
|
219038
219038
|
__classPrivateFieldGet(this, _BetaMessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -219202,11 +219202,11 @@ var BetaMessageStream = class _BetaMessageStream {
|
|
|
219202
219202
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
219203
219203
|
*/
|
|
219204
219204
|
emitted(event) {
|
|
219205
|
-
return new Promise((
|
|
219205
|
+
return new Promise((resolve2, reject) => {
|
|
219206
219206
|
__classPrivateFieldSet(this, _BetaMessageStream_catchingPromiseCreated, true);
|
|
219207
219207
|
if (event !== "error")
|
|
219208
219208
|
this.once("error", reject);
|
|
219209
|
-
this.once(event,
|
|
219209
|
+
this.once(event, resolve2);
|
|
219210
219210
|
});
|
|
219211
219211
|
}
|
|
219212
219212
|
async done() {
|
|
@@ -219546,7 +219546,7 @@ var BetaMessageStream = class _BetaMessageStream {
|
|
|
219546
219546
|
if (done) {
|
|
219547
219547
|
return { value: void 0, done: true };
|
|
219548
219548
|
}
|
|
219549
|
-
return new Promise((
|
|
219549
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
219550
219550
|
}
|
|
219551
219551
|
const chunk = pushQueue.shift();
|
|
219552
219552
|
return { value: chunk, done: false };
|
|
@@ -219618,13 +219618,13 @@ var _BetaToolRunner_iterationCount;
|
|
|
219618
219618
|
var _BetaToolRunner_checkAndCompact;
|
|
219619
219619
|
var _BetaToolRunner_generateToolResponse;
|
|
219620
219620
|
function promiseWithResolvers() {
|
|
219621
|
-
let
|
|
219621
|
+
let resolve2;
|
|
219622
219622
|
let reject;
|
|
219623
219623
|
const promise = new Promise((res, rej) => {
|
|
219624
|
-
|
|
219624
|
+
resolve2 = res;
|
|
219625
219625
|
reject = rej;
|
|
219626
219626
|
});
|
|
219627
|
-
return { promise, resolve, reject };
|
|
219627
|
+
return { promise, resolve: resolve2, reject };
|
|
219628
219628
|
}
|
|
219629
219629
|
var BetaToolRunner = class {
|
|
219630
219630
|
constructor(client, params, options) {
|
|
@@ -221304,12 +221304,12 @@ var MessageStream = class _MessageStream {
|
|
|
221304
221304
|
}
|
|
221305
221305
|
return this._emit("error", new AnthropicError(String(error2)));
|
|
221306
221306
|
});
|
|
221307
|
-
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((
|
|
221308
|
-
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise,
|
|
221307
|
+
__classPrivateFieldSet(this, _MessageStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
221308
|
+
__classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve2, "f");
|
|
221309
221309
|
__classPrivateFieldSet(this, _MessageStream_rejectConnectedPromise, reject, "f");
|
|
221310
221310
|
}));
|
|
221311
|
-
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((
|
|
221312
|
-
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise,
|
|
221311
|
+
__classPrivateFieldSet(this, _MessageStream_endPromise, new Promise((resolve2, reject) => {
|
|
221312
|
+
__classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve2, "f");
|
|
221313
221313
|
__classPrivateFieldSet(this, _MessageStream_rejectEndPromise, reject, "f");
|
|
221314
221314
|
}));
|
|
221315
221315
|
__classPrivateFieldGet(this, _MessageStream_connectedPromise, "f").catch(() => {
|
|
@@ -221479,11 +221479,11 @@ var MessageStream = class _MessageStream {
|
|
|
221479
221479
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
221480
221480
|
*/
|
|
221481
221481
|
emitted(event) {
|
|
221482
|
-
return new Promise((
|
|
221482
|
+
return new Promise((resolve2, reject) => {
|
|
221483
221483
|
__classPrivateFieldSet(this, _MessageStream_catchingPromiseCreated, true);
|
|
221484
221484
|
if (event !== "error")
|
|
221485
221485
|
this.once("error", reject);
|
|
221486
|
-
this.once(event,
|
|
221486
|
+
this.once(event, resolve2);
|
|
221487
221487
|
});
|
|
221488
221488
|
}
|
|
221489
221489
|
async done() {
|
|
@@ -221798,7 +221798,7 @@ var MessageStream = class _MessageStream {
|
|
|
221798
221798
|
if (done) {
|
|
221799
221799
|
return { value: void 0, done: true };
|
|
221800
221800
|
}
|
|
221801
|
-
return new Promise((
|
|
221801
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
221802
221802
|
}
|
|
221803
221803
|
const chunk = pushQueue.shift();
|
|
221804
221804
|
return { value: chunk, done: false };
|
|
@@ -224247,7 +224247,7 @@ function reconcilePrice(model, live) {
|
|
|
224247
224247
|
}
|
|
224248
224248
|
|
|
224249
224249
|
// src/constants.ts
|
|
224250
|
-
var CASCADE_VERSION = "0.
|
|
224250
|
+
var CASCADE_VERSION = "0.52.0";
|
|
224251
224251
|
var CASCADE_CONFIG_DIR = ".cascade";
|
|
224252
224252
|
var CASCADE_MD_FILE = "CASCADE.md";
|
|
224253
224253
|
var CASCADE_IGNORE_FILE = ".cascadeignore";
|
|
@@ -224760,46 +224760,37 @@ var BaseProvider = class {
|
|
|
224760
224760
|
};
|
|
224761
224761
|
|
|
224762
224762
|
// src/providers/model-filter.ts
|
|
224763
|
-
var
|
|
224764
|
-
"embed",
|
|
224763
|
+
var MODALITY_PATTERNS = [
|
|
224764
|
+
["embedding", ["embed"]],
|
|
224765
224765
|
// text-embedding-3, nomic-embed, mxbai-embed, snowflake-arctic-embed
|
|
224766
|
-
"(?:^|[-_/])
|
|
224767
|
-
"text-to-speech",
|
|
224768
|
-
"
|
|
224769
|
-
|
|
224770
|
-
|
|
224771
|
-
|
|
224772
|
-
|
|
224773
|
-
|
|
224774
|
-
|
|
224775
|
-
|
|
224776
|
-
|
|
224777
|
-
|
|
224778
|
-
|
|
224779
|
-
"
|
|
224780
|
-
"
|
|
224781
|
-
"
|
|
224782
|
-
|
|
224783
|
-
|
|
224784
|
-
|
|
224785
|
-
|
|
224786
|
-
|
|
224787
|
-
|
|
224788
|
-
|
|
224789
|
-
|
|
224790
|
-
|
|
224791
|
-
"veo",
|
|
224792
|
-
"sora",
|
|
224793
|
-
"(?:^|[-_/])video(?:[-_/]|$)",
|
|
224794
|
-
// video
|
|
224795
|
-
"(?:^|[-_/])aqa(?:[-_/]|$)",
|
|
224796
|
-
// attributed QA
|
|
224797
|
-
"(?:^|[-_/])live(?:[-_/]|$)",
|
|
224798
|
-
// live-audio variants
|
|
224799
|
-
"(?:^|[-_/])(?:davinci|babbage)(?:[-_/]|$)"
|
|
224800
|
-
// legacy completion-only base models
|
|
224766
|
+
["transcription", ["whisper", "transcrib", "(?:^|[-_/])stt(?:[-_/]|$)"]],
|
|
224767
|
+
["speech", ["(?:^|[-_/])tts(?:[-_/]|$)", "text-to-speech", "speech"]],
|
|
224768
|
+
["video", ["veo", "sora", "(?:^|[-_/])video(?:[-_/]|$)"]],
|
|
224769
|
+
["image", [
|
|
224770
|
+
"dall[-]?e",
|
|
224771
|
+
"imagen",
|
|
224772
|
+
"image-generation",
|
|
224773
|
+
"gpt-image",
|
|
224774
|
+
"(?:^|[-_/])image(?:[-_/]|$)",
|
|
224775
|
+
"stable-diffusion",
|
|
224776
|
+
"sdxl",
|
|
224777
|
+
"flux"
|
|
224778
|
+
]],
|
|
224779
|
+
["moderation", ["moderation", "(?:^|[-_/])guard(?:[-_/]|$)"]],
|
|
224780
|
+
["rerank", ["rerank"]],
|
|
224781
|
+
["realtime", [
|
|
224782
|
+
"(?:^|[-_/])audio(?:[-_/]|$)",
|
|
224783
|
+
"native-audio",
|
|
224784
|
+
"realtime",
|
|
224785
|
+
"(?:^|[-_/])live(?:[-_/]|$)",
|
|
224786
|
+
// live-audio variants
|
|
224787
|
+
"(?:^|[-_/])aqa(?:[-_/]|$)"
|
|
224788
|
+
// attributed QA
|
|
224789
|
+
]],
|
|
224790
|
+
["legacy-completion", ["(?:^|[-_/])(?:davinci|babbage)(?:[-_/]|$)"]]
|
|
224801
224791
|
];
|
|
224802
|
-
|
|
224792
|
+
MODALITY_PATTERNS.map(([m3, pats]) => [m3, new RegExp(pats.join("|"), "i")]);
|
|
224793
|
+
var NON_CHAT = new RegExp(MODALITY_PATTERNS.flatMap(([, p3]) => p3).join("|"), "i");
|
|
224803
224794
|
function isChatModel(id, methods) {
|
|
224804
224795
|
if (methods && methods.length > 0) {
|
|
224805
224796
|
const canGenerate = methods.some((m3) => /generatecontent|generatemessage|chat|completion/i.test(m3));
|
|
@@ -225686,7 +225677,7 @@ function consumeBody() {
|
|
|
225686
225677
|
let accum = [];
|
|
225687
225678
|
let accumBytes = 0;
|
|
225688
225679
|
let abort = false;
|
|
225689
|
-
return new Body.Promise(function(
|
|
225680
|
+
return new Body.Promise(function(resolve2, reject) {
|
|
225690
225681
|
let resTimeout;
|
|
225691
225682
|
if (_this4.timeout) {
|
|
225692
225683
|
resTimeout = setTimeout(function() {
|
|
@@ -225720,7 +225711,7 @@ function consumeBody() {
|
|
|
225720
225711
|
}
|
|
225721
225712
|
clearTimeout(resTimeout);
|
|
225722
225713
|
try {
|
|
225723
|
-
|
|
225714
|
+
resolve2(Buffer.concat(accum, accumBytes));
|
|
225724
225715
|
} catch (err) {
|
|
225725
225716
|
reject(new FetchError(`Could not create Buffer from response body for ${_this4.url}: ${err.message}`, "system", err));
|
|
225726
225717
|
}
|
|
@@ -226395,7 +226386,7 @@ function fetch3(url2, opts) {
|
|
|
226395
226386
|
throw new Error("native promise missing, set fetch.Promise to your favorite alternative");
|
|
226396
226387
|
}
|
|
226397
226388
|
Body.Promise = fetch3.Promise;
|
|
226398
|
-
return new fetch3.Promise(function(
|
|
226389
|
+
return new fetch3.Promise(function(resolve2, reject) {
|
|
226399
226390
|
const request = new Request3(url2, opts);
|
|
226400
226391
|
const options = getNodeRequestOptions(request);
|
|
226401
226392
|
const send = (options.protocol === "https:" ? https2__default.default : http2__default.default).request;
|
|
@@ -226528,7 +226519,7 @@ function fetch3(url2, opts) {
|
|
|
226528
226519
|
requestOpts.body = void 0;
|
|
226529
226520
|
requestOpts.headers.delete("content-length");
|
|
226530
226521
|
}
|
|
226531
|
-
|
|
226522
|
+
resolve2(fetch3(new Request3(locationURL, requestOpts)));
|
|
226532
226523
|
finalize();
|
|
226533
226524
|
return;
|
|
226534
226525
|
}
|
|
@@ -226549,7 +226540,7 @@ function fetch3(url2, opts) {
|
|
|
226549
226540
|
const codings = headers.get("Content-Encoding");
|
|
226550
226541
|
if (!request.compress || request.method === "HEAD" || codings === null || res.statusCode === 204 || res.statusCode === 304) {
|
|
226551
226542
|
response = new Response3(body, response_options);
|
|
226552
|
-
|
|
226543
|
+
resolve2(response);
|
|
226553
226544
|
return;
|
|
226554
226545
|
}
|
|
226555
226546
|
const zlibOptions = {
|
|
@@ -226559,7 +226550,7 @@ function fetch3(url2, opts) {
|
|
|
226559
226550
|
if (codings == "gzip" || codings == "x-gzip") {
|
|
226560
226551
|
body = body.pipe(zlib__default.default.createGunzip(zlibOptions));
|
|
226561
226552
|
response = new Response3(body, response_options);
|
|
226562
|
-
|
|
226553
|
+
resolve2(response);
|
|
226563
226554
|
return;
|
|
226564
226555
|
}
|
|
226565
226556
|
if (codings == "deflate" || codings == "x-deflate") {
|
|
@@ -226571,12 +226562,12 @@ function fetch3(url2, opts) {
|
|
|
226571
226562
|
body = body.pipe(zlib__default.default.createInflateRaw());
|
|
226572
226563
|
}
|
|
226573
226564
|
response = new Response3(body, response_options);
|
|
226574
|
-
|
|
226565
|
+
resolve2(response);
|
|
226575
226566
|
});
|
|
226576
226567
|
raw.on("end", function() {
|
|
226577
226568
|
if (!response) {
|
|
226578
226569
|
response = new Response3(body, response_options);
|
|
226579
|
-
|
|
226570
|
+
resolve2(response);
|
|
226580
226571
|
}
|
|
226581
226572
|
});
|
|
226582
226573
|
return;
|
|
@@ -226584,11 +226575,11 @@ function fetch3(url2, opts) {
|
|
|
226584
226575
|
if (codings == "br" && typeof zlib__default.default.createBrotliDecompress === "function") {
|
|
226585
226576
|
body = body.pipe(zlib__default.default.createBrotliDecompress());
|
|
226586
226577
|
response = new Response3(body, response_options);
|
|
226587
|
-
|
|
226578
|
+
resolve2(response);
|
|
226588
226579
|
return;
|
|
226589
226580
|
}
|
|
226590
226581
|
response = new Response3(body, response_options);
|
|
226591
|
-
|
|
226582
|
+
resolve2(response);
|
|
226592
226583
|
});
|
|
226593
226584
|
writeToStream(req, request);
|
|
226594
226585
|
});
|
|
@@ -227629,8 +227620,8 @@ function _addRequestID(value, response) {
|
|
|
227629
227620
|
}
|
|
227630
227621
|
var APIPromise2 = class _APIPromise extends Promise {
|
|
227631
227622
|
constructor(responsePromise, parseResponse2 = defaultParseResponse2) {
|
|
227632
|
-
super((
|
|
227633
|
-
|
|
227623
|
+
super((resolve2) => {
|
|
227624
|
+
resolve2(null);
|
|
227634
227625
|
});
|
|
227635
227626
|
this.responsePromise = responsePromise;
|
|
227636
227627
|
this.parseResponse = parseResponse2;
|
|
@@ -228205,7 +228196,7 @@ var startsWithSchemeRegexp2 = /^[a-z][a-z0-9+.-]*:/i;
|
|
|
228205
228196
|
var isAbsoluteURL2 = (url2) => {
|
|
228206
228197
|
return startsWithSchemeRegexp2.test(url2);
|
|
228207
228198
|
};
|
|
228208
|
-
var sleep2 = (ms2) => new Promise((
|
|
228199
|
+
var sleep2 = (ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2));
|
|
228209
228200
|
var validatePositiveInteger2 = (name, n8) => {
|
|
228210
228201
|
if (typeof n8 !== "number" || !Number.isInteger(n8)) {
|
|
228211
228202
|
throw new OpenAIError(`${name} must be an integer`);
|
|
@@ -228636,12 +228627,12 @@ var EventStream = class {
|
|
|
228636
228627
|
_EventStream_errored.set(this, false);
|
|
228637
228628
|
_EventStream_aborted.set(this, false);
|
|
228638
228629
|
_EventStream_catchingPromiseCreated.set(this, false);
|
|
228639
|
-
__classPrivateFieldSet8(this, _EventStream_connectedPromise, new Promise((
|
|
228640
|
-
__classPrivateFieldSet8(this, _EventStream_resolveConnectedPromise,
|
|
228630
|
+
__classPrivateFieldSet8(this, _EventStream_connectedPromise, new Promise((resolve2, reject) => {
|
|
228631
|
+
__classPrivateFieldSet8(this, _EventStream_resolveConnectedPromise, resolve2, "f");
|
|
228641
228632
|
__classPrivateFieldSet8(this, _EventStream_rejectConnectedPromise, reject, "f");
|
|
228642
228633
|
}));
|
|
228643
|
-
__classPrivateFieldSet8(this, _EventStream_endPromise, new Promise((
|
|
228644
|
-
__classPrivateFieldSet8(this, _EventStream_resolveEndPromise,
|
|
228634
|
+
__classPrivateFieldSet8(this, _EventStream_endPromise, new Promise((resolve2, reject) => {
|
|
228635
|
+
__classPrivateFieldSet8(this, _EventStream_resolveEndPromise, resolve2, "f");
|
|
228645
228636
|
__classPrivateFieldSet8(this, _EventStream_rejectEndPromise, reject, "f");
|
|
228646
228637
|
}));
|
|
228647
228638
|
__classPrivateFieldGet9(this, _EventStream_connectedPromise, "f").catch(() => {
|
|
@@ -228725,11 +228716,11 @@ var EventStream = class {
|
|
|
228725
228716
|
* const message = await stream.emitted('message') // rejects if the stream errors
|
|
228726
228717
|
*/
|
|
228727
228718
|
emitted(event) {
|
|
228728
|
-
return new Promise((
|
|
228719
|
+
return new Promise((resolve2, reject) => {
|
|
228729
228720
|
__classPrivateFieldSet8(this, _EventStream_catchingPromiseCreated, true);
|
|
228730
228721
|
if (event !== "error")
|
|
228731
228722
|
this.once("error", reject);
|
|
228732
|
-
this.once(event,
|
|
228723
|
+
this.once(event, resolve2);
|
|
228733
228724
|
});
|
|
228734
228725
|
}
|
|
228735
228726
|
async done() {
|
|
@@ -228880,7 +228871,7 @@ var AssistantStream = class _AssistantStream extends EventStream {
|
|
|
228880
228871
|
if (done) {
|
|
228881
228872
|
return { value: void 0, done: true };
|
|
228882
228873
|
}
|
|
228883
|
-
return new Promise((
|
|
228874
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
228884
228875
|
}
|
|
228885
228876
|
const chunk = pushQueue.shift();
|
|
228886
228877
|
return { value: chunk, done: false };
|
|
@@ -230485,7 +230476,7 @@ var ChatCompletionStream = class _ChatCompletionStream extends AbstractChatCompl
|
|
|
230485
230476
|
if (done) {
|
|
230486
230477
|
return { value: void 0, done: true };
|
|
230487
230478
|
}
|
|
230488
|
-
return new Promise((
|
|
230479
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
|
|
230489
230480
|
}
|
|
230490
230481
|
const chunk = pushQueue.shift();
|
|
230491
230482
|
return { value: chunk, done: false };
|
|
@@ -232131,7 +232122,7 @@ var ResponseStream = class _ResponseStream extends EventStream {
|
|
|
232131
232122
|
if (done) {
|
|
232132
232123
|
return { value: void 0, done: true };
|
|
232133
232124
|
}
|
|
232134
|
-
return new Promise((
|
|
232125
|
+
return new Promise((resolve2, reject) => readQueue.push({ resolve: resolve2, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
|
|
232135
232126
|
}
|
|
232136
232127
|
const event = pushQueue.shift();
|
|
232137
232128
|
return { value: event, done: false };
|
|
@@ -238385,14 +238376,14 @@ function __asyncValues(o3) {
|
|
|
238385
238376
|
}, i4);
|
|
238386
238377
|
function verb(n8) {
|
|
238387
238378
|
i4[n8] = o3[n8] && function(v6) {
|
|
238388
|
-
return new Promise(function(
|
|
238389
|
-
v6 = o3[n8](v6), settle(
|
|
238379
|
+
return new Promise(function(resolve2, reject) {
|
|
238380
|
+
v6 = o3[n8](v6), settle(resolve2, reject, v6.done, v6.value);
|
|
238390
238381
|
});
|
|
238391
238382
|
};
|
|
238392
238383
|
}
|
|
238393
|
-
function settle(
|
|
238384
|
+
function settle(resolve2, reject, d2, v6) {
|
|
238394
238385
|
Promise.resolve(v6).then(function(v7) {
|
|
238395
|
-
|
|
238386
|
+
resolve2({ value: v7, done: d2 });
|
|
238396
238387
|
}, reject);
|
|
238397
238388
|
}
|
|
238398
238389
|
}
|
|
@@ -244835,8 +244826,8 @@ var LiveMusic = class {
|
|
|
244835
244826
|
const url2 = `${websocketBaseUrl}/ws/google.ai.generativelanguage.${apiVersion}.GenerativeService.BidiGenerateMusic?key=${apiKey}`;
|
|
244836
244827
|
let onopenResolve = () => {
|
|
244837
244828
|
};
|
|
244838
|
-
const onopenPromise = new Promise((
|
|
244839
|
-
onopenResolve =
|
|
244829
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
244830
|
+
onopenResolve = resolve2;
|
|
244840
244831
|
});
|
|
244841
244832
|
const callbacks = params.callbacks;
|
|
244842
244833
|
const onopenAwaitedCallback = function() {
|
|
@@ -245076,8 +245067,8 @@ var Live = class {
|
|
|
245076
245067
|
}
|
|
245077
245068
|
let onopenResolve = () => {
|
|
245078
245069
|
};
|
|
245079
|
-
const onopenPromise = new Promise((
|
|
245080
|
-
onopenResolve =
|
|
245070
|
+
const onopenPromise = new Promise((resolve2) => {
|
|
245071
|
+
onopenResolve = resolve2;
|
|
245081
245072
|
});
|
|
245082
245073
|
const callbacks = params.callbacks;
|
|
245083
245074
|
const onopenAwaitedCallback = function() {
|
|
@@ -248142,7 +248133,7 @@ var safeJSON3 = (text) => {
|
|
|
248142
248133
|
return void 0;
|
|
248143
248134
|
}
|
|
248144
248135
|
};
|
|
248145
|
-
var sleep$1 = (ms2) => new Promise((
|
|
248136
|
+
var sleep$1 = (ms2) => new Promise((resolve2) => setTimeout(resolve2, ms2));
|
|
248146
248137
|
function getDefaultFetch2() {
|
|
248147
248138
|
if (typeof fetch !== "undefined") {
|
|
248148
248139
|
return fetch;
|
|
@@ -248990,8 +248981,8 @@ async function defaultParseResponse3(client, props) {
|
|
|
248990
248981
|
}
|
|
248991
248982
|
var APIPromise3 = class _APIPromise extends Promise {
|
|
248992
248983
|
constructor(client, responsePromise, parseResponse2 = defaultParseResponse3) {
|
|
248993
|
-
super((
|
|
248994
|
-
|
|
248984
|
+
super((resolve2) => {
|
|
248985
|
+
resolve2(null);
|
|
248995
248986
|
});
|
|
248996
248987
|
this.responsePromise = responsePromise;
|
|
248997
248988
|
this.parseResponse = parseResponse2;
|
|
@@ -251229,6 +251220,113 @@ function getApiKeyFromEnv() {
|
|
|
251229
251220
|
return envGoogleApiKey || envGeminiApiKey || void 0;
|
|
251230
251221
|
}
|
|
251231
251222
|
|
|
251223
|
+
// src/providers/gemini-schema.ts
|
|
251224
|
+
var ALLOWED_KEYS = /* @__PURE__ */ new Set([
|
|
251225
|
+
"type",
|
|
251226
|
+
"format",
|
|
251227
|
+
"title",
|
|
251228
|
+
"description",
|
|
251229
|
+
"nullable",
|
|
251230
|
+
"enum",
|
|
251231
|
+
"items",
|
|
251232
|
+
"properties",
|
|
251233
|
+
"required",
|
|
251234
|
+
"propertyOrdering",
|
|
251235
|
+
"minItems",
|
|
251236
|
+
"maxItems",
|
|
251237
|
+
"minProperties",
|
|
251238
|
+
"maxProperties",
|
|
251239
|
+
"minimum",
|
|
251240
|
+
"maximum",
|
|
251241
|
+
"minLength",
|
|
251242
|
+
"maxLength",
|
|
251243
|
+
"pattern",
|
|
251244
|
+
"example",
|
|
251245
|
+
"default",
|
|
251246
|
+
"anyOf"
|
|
251247
|
+
]);
|
|
251248
|
+
var ALLOWED_TYPES = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "array", "object"]);
|
|
251249
|
+
function isPlainObject3(v6) {
|
|
251250
|
+
return typeof v6 === "object" && v6 !== null && !Array.isArray(v6);
|
|
251251
|
+
}
|
|
251252
|
+
function normalizeType(value) {
|
|
251253
|
+
if (typeof value === "string") {
|
|
251254
|
+
return ALLOWED_TYPES.has(value) ? { type: value } : {};
|
|
251255
|
+
}
|
|
251256
|
+
if (Array.isArray(value)) {
|
|
251257
|
+
const types3 = value.filter((t4) => typeof t4 === "string");
|
|
251258
|
+
const nullable2 = types3.includes("null");
|
|
251259
|
+
const concrete = types3.find((t4) => t4 !== "null" && ALLOWED_TYPES.has(t4));
|
|
251260
|
+
return {
|
|
251261
|
+
...concrete ? { type: concrete } : {},
|
|
251262
|
+
...nullable2 ? { nullable: true } : {}
|
|
251263
|
+
};
|
|
251264
|
+
}
|
|
251265
|
+
return {};
|
|
251266
|
+
}
|
|
251267
|
+
function normalizeEnum(value) {
|
|
251268
|
+
if (!Array.isArray(value) || value.length === 0) return void 0;
|
|
251269
|
+
return value.map((v6) => typeof v6 === "string" ? v6 : JSON.stringify(v6));
|
|
251270
|
+
}
|
|
251271
|
+
function sanitizeGeminiSchema(schema) {
|
|
251272
|
+
if (!isPlainObject3(schema)) return void 0;
|
|
251273
|
+
const out = {};
|
|
251274
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
251275
|
+
if (!ALLOWED_KEYS.has(key)) continue;
|
|
251276
|
+
switch (key) {
|
|
251277
|
+
case "type": {
|
|
251278
|
+
Object.assign(out, normalizeType(value));
|
|
251279
|
+
break;
|
|
251280
|
+
}
|
|
251281
|
+
case "enum": {
|
|
251282
|
+
const e3 = normalizeEnum(value);
|
|
251283
|
+
if (e3) out["enum"] = e3;
|
|
251284
|
+
break;
|
|
251285
|
+
}
|
|
251286
|
+
case "properties": {
|
|
251287
|
+
if (!isPlainObject3(value)) break;
|
|
251288
|
+
const props = {};
|
|
251289
|
+
for (const [propName, propSchema] of Object.entries(value)) {
|
|
251290
|
+
const cleaned = sanitizeGeminiSchema(propSchema);
|
|
251291
|
+
props[propName] = cleaned && Object.keys(cleaned).length ? cleaned : { type: "string" };
|
|
251292
|
+
}
|
|
251293
|
+
out["properties"] = props;
|
|
251294
|
+
break;
|
|
251295
|
+
}
|
|
251296
|
+
case "items": {
|
|
251297
|
+
const cleaned = sanitizeGeminiSchema(value);
|
|
251298
|
+
if (cleaned) out["items"] = cleaned;
|
|
251299
|
+
break;
|
|
251300
|
+
}
|
|
251301
|
+
case "anyOf": {
|
|
251302
|
+
if (!Array.isArray(value)) break;
|
|
251303
|
+
const variants = value.map((v6) => sanitizeGeminiSchema(v6)).filter((v6) => !!v6 && Object.keys(v6).length > 0);
|
|
251304
|
+
if (variants.length) out["anyOf"] = variants;
|
|
251305
|
+
break;
|
|
251306
|
+
}
|
|
251307
|
+
case "required": {
|
|
251308
|
+
if (Array.isArray(value)) {
|
|
251309
|
+
out["required"] = value.filter((r4) => typeof r4 === "string");
|
|
251310
|
+
}
|
|
251311
|
+
break;
|
|
251312
|
+
}
|
|
251313
|
+
default:
|
|
251314
|
+
out[key] = value;
|
|
251315
|
+
}
|
|
251316
|
+
}
|
|
251317
|
+
if (!out["type"] && out["properties"]) out["type"] = "object";
|
|
251318
|
+
if (!out["type"] && out["items"]) out["type"] = "array";
|
|
251319
|
+
return out;
|
|
251320
|
+
}
|
|
251321
|
+
function toGeminiParameters(inputSchema) {
|
|
251322
|
+
const cleaned = sanitizeGeminiSchema(inputSchema);
|
|
251323
|
+
if (!cleaned) return void 0;
|
|
251324
|
+
const props = cleaned["properties"];
|
|
251325
|
+
if (isPlainObject3(props) && Object.keys(props).length === 0) return void 0;
|
|
251326
|
+
if (Object.keys(cleaned).length === 0) return void 0;
|
|
251327
|
+
return cleaned;
|
|
251328
|
+
}
|
|
251329
|
+
|
|
251232
251330
|
// src/providers/gemini.ts
|
|
251233
251331
|
var GeminiProvider = class extends BaseProvider {
|
|
251234
251332
|
client;
|
|
@@ -251450,7 +251548,12 @@ var GeminiProvider = class extends BaseProvider {
|
|
|
251450
251548
|
return {
|
|
251451
251549
|
name: tool.name,
|
|
251452
251550
|
description: tool.description,
|
|
251453
|
-
parameters
|
|
251551
|
+
// Convert, never cast. Gemini's parameters field is an OpenAPI subset
|
|
251552
|
+
// that 400s on unknown keys, and MCP servers ship schemas carrying their
|
|
251553
|
+
// own extensions (GitHub's adds `x-mcp-header` to every header-bound
|
|
251554
|
+
// property). Casting sent those through verbatim and every request failed
|
|
251555
|
+
// before the model saw it. See providers/gemini-schema.ts.
|
|
251556
|
+
parameters: toGeminiParameters(tool.inputSchema)
|
|
251454
251557
|
};
|
|
251455
251558
|
}
|
|
251456
251559
|
};
|
|
@@ -251478,7 +251581,7 @@ async function nodeHttpFetch(input, init2 = {}, redirectCount = 0) {
|
|
|
251478
251581
|
headers["accept-encoding"] = "gzip, deflate, br";
|
|
251479
251582
|
}
|
|
251480
251583
|
const body = init2.body == null ? void 0 : typeof init2.body === "string" ? init2.body : Buffer.from(init2.body);
|
|
251481
|
-
return new Promise((
|
|
251584
|
+
return new Promise((resolve2, reject) => {
|
|
251482
251585
|
const req = lib.request(
|
|
251483
251586
|
{
|
|
251484
251587
|
hostname: u2.hostname,
|
|
@@ -251495,7 +251598,7 @@ async function nodeHttpFetch(input, init2 = {}, redirectCount = 0) {
|
|
|
251495
251598
|
const nextUrl = new URL(location, u2).href;
|
|
251496
251599
|
const downgrade = status === 303 || (status === 301 || status === 302) && method !== "GET" && method !== "HEAD";
|
|
251497
251600
|
const nextInit = downgrade ? { ...init2, method: "GET", body: void 0 } : init2;
|
|
251498
|
-
|
|
251601
|
+
resolve2(nodeHttpFetch(nextUrl, nextInit, redirectCount + 1));
|
|
251499
251602
|
return;
|
|
251500
251603
|
}
|
|
251501
251604
|
const encoding = (res.headers["content-encoding"] ?? "").toLowerCase();
|
|
@@ -251510,7 +251613,7 @@ async function nodeHttpFetch(input, init2 = {}, redirectCount = 0) {
|
|
|
251510
251613
|
if (Array.isArray(v6)) respHeaders.set(k4, v6.join(", "));
|
|
251511
251614
|
else if (typeof v6 === "string") respHeaders.set(k4, v6);
|
|
251512
251615
|
}
|
|
251513
|
-
|
|
251616
|
+
resolve2(new Response(stream2, {
|
|
251514
251617
|
status,
|
|
251515
251618
|
statusText: res.statusMessage ?? "",
|
|
251516
251619
|
headers: respHeaders
|
|
@@ -252157,7 +252260,7 @@ var TpmLimiter = class {
|
|
|
252157
252260
|
}
|
|
252158
252261
|
const deficit = want - bucket.available;
|
|
252159
252262
|
const waitMs = Math.max(50, Math.ceil(deficit / bucket.tokensPerMinute * 6e4));
|
|
252160
|
-
await new Promise((
|
|
252263
|
+
await new Promise((resolve2) => setTimeout(resolve2, waitMs));
|
|
252161
252264
|
}
|
|
252162
252265
|
}
|
|
252163
252266
|
/**
|
|
@@ -252220,14 +252323,14 @@ var LocalRequestQueue = class {
|
|
|
252220
252323
|
this.active++;
|
|
252221
252324
|
return this.makeRelease();
|
|
252222
252325
|
}
|
|
252223
|
-
return new Promise((
|
|
252326
|
+
return new Promise((resolve2, reject) => {
|
|
252224
252327
|
let settled = false;
|
|
252225
252328
|
let timer;
|
|
252226
252329
|
const resolver = (release) => {
|
|
252227
252330
|
if (settled) return;
|
|
252228
252331
|
settled = true;
|
|
252229
252332
|
if (timer !== void 0) clearTimeout(timer);
|
|
252230
|
-
|
|
252333
|
+
resolve2(release);
|
|
252231
252334
|
};
|
|
252232
252335
|
if (timeoutMs !== void 0 && timeoutMs > 0) {
|
|
252233
252336
|
timer = setTimeout(() => {
|
|
@@ -252858,6 +252961,7 @@ var CascadeRouter = class _CascadeRouter extends EventEmitter__default.default {
|
|
|
252858
252961
|
tpmLimiter;
|
|
252859
252962
|
localQueue;
|
|
252860
252963
|
taskAnalyzer;
|
|
252964
|
+
pendingFeedbackSource;
|
|
252861
252965
|
worldStateDB;
|
|
252862
252966
|
privacyPaths;
|
|
252863
252967
|
guidanceQueue;
|
|
@@ -253312,8 +253416,18 @@ var CascadeRouter = class _CascadeRouter extends EventEmitter__default.default {
|
|
|
253312
253416
|
return windows.length ? Math.min(...windows) : void 0;
|
|
253313
253417
|
}
|
|
253314
253418
|
/** Wire the Cascade Auto task analyzer used for per-subtask model routing. */
|
|
253419
|
+
/**
|
|
253420
|
+
* Feed per-model thumbs counts into Auto routing. Forwarded to the analyzer
|
|
253421
|
+
* because that is where the public benchmark score is combined; the prior
|
|
253422
|
+
* adjusts that number rather than sitting anywhere else in the pipeline.
|
|
253423
|
+
*/
|
|
253424
|
+
setFeedbackSource(source) {
|
|
253425
|
+
this.taskAnalyzer?.setFeedbackSource(source);
|
|
253426
|
+
this.pendingFeedbackSource = source;
|
|
253427
|
+
}
|
|
253315
253428
|
setTaskAnalyzer(analyzer) {
|
|
253316
253429
|
this.taskAnalyzer = analyzer;
|
|
253430
|
+
if (this.pendingFeedbackSource) analyzer.setFeedbackSource(this.pendingFeedbackSource);
|
|
253317
253431
|
}
|
|
253318
253432
|
setWorldStateDB(db) {
|
|
253319
253433
|
this.worldStateDB = db;
|
|
@@ -254407,8 +254521,11 @@ Now execute your subtask using this context where relevant.`
|
|
|
254407
254521
|
const result = await this.runAgentLoop(systemPrompt, this.tools);
|
|
254408
254522
|
output = result.output;
|
|
254409
254523
|
toolCalls = result.toolCalls;
|
|
254410
|
-
this.
|
|
254411
|
-
|
|
254524
|
+
const mustProduceArtifact = this.requiresArtifact();
|
|
254525
|
+
if (mustProduceArtifact) {
|
|
254526
|
+
this.sendStatusUpdate({ progressPct: 65, currentAction: "Verifying required artifacts", status: "IN_PROGRESS" });
|
|
254527
|
+
}
|
|
254528
|
+
const artifactCheck = mustProduceArtifact ? await this.verifyArtifacts(assignment) : { ok: true, issues: [] };
|
|
254412
254529
|
if (!artifactCheck.ok) {
|
|
254413
254530
|
correctionAttempts = 1;
|
|
254414
254531
|
issues.push(...artifactCheck.issues);
|
|
@@ -254688,11 +254805,11 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
254688
254805
|
if (!wasApproved) return `Tool ${tc.name} was denied by user.`;
|
|
254689
254806
|
} else {
|
|
254690
254807
|
const LEGACY_APPROVAL_TIMEOUT_MS = 6e5;
|
|
254691
|
-
const legacyDecision = await new Promise((
|
|
254808
|
+
const legacyDecision = await new Promise((resolve2) => {
|
|
254692
254809
|
const eventName = `tool:approval-response:${this.id}-${tc.id}`;
|
|
254693
254810
|
const timer = setTimeout(() => {
|
|
254694
254811
|
this.removeAllListeners(eventName);
|
|
254695
|
-
|
|
254812
|
+
resolve2({ approved: false });
|
|
254696
254813
|
}, LEGACY_APPROVAL_TIMEOUT_MS);
|
|
254697
254814
|
timer.unref?.();
|
|
254698
254815
|
this.emit("tool:approval-request", {
|
|
@@ -254705,7 +254822,7 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
254705
254822
|
});
|
|
254706
254823
|
this.once(eventName, (d2) => {
|
|
254707
254824
|
clearTimeout(timer);
|
|
254708
|
-
|
|
254825
|
+
resolve2(d2);
|
|
254709
254826
|
});
|
|
254710
254827
|
});
|
|
254711
254828
|
if (legacyDecision.always) this.sessionApprovals.set(tc.name, legacyDecision.approved);
|
|
@@ -254725,6 +254842,9 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
254725
254842
|
tierId: this.id,
|
|
254726
254843
|
sessionId: this.taskId,
|
|
254727
254844
|
requireApproval: false,
|
|
254845
|
+
// Media generation can run for a minute; without this a cancelled run
|
|
254846
|
+
// still pays for an image nobody will see.
|
|
254847
|
+
...this.signal ? { signal: this.signal } : {},
|
|
254728
254848
|
saveSnapshot: async (path28, content) => {
|
|
254729
254849
|
this.store?.addFileSnapshot(this.taskId, path28, content);
|
|
254730
254850
|
},
|
|
@@ -254772,7 +254892,8 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
254772
254892
|
const result = await this.toolRegistry.execute(altTool, tc.input, {
|
|
254773
254893
|
tierId: this.id,
|
|
254774
254894
|
sessionId: this.taskId,
|
|
254775
|
-
requireApproval: false
|
|
254895
|
+
requireApproval: false,
|
|
254896
|
+
...this.signal ? { signal: this.signal } : {}
|
|
254776
254897
|
});
|
|
254777
254898
|
const str2 = typeof result === "string" ? result : JSON.stringify(result);
|
|
254778
254899
|
if (!str2.startsWith("Tool error:") && !str2.startsWith("Error:")) {
|
|
@@ -254794,7 +254915,8 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
|
|
|
254794
254915
|
const result = await this.toolRegistry.execute(newToolName, tc.input, {
|
|
254795
254916
|
tierId: this.id,
|
|
254796
254917
|
sessionId: this.taskId,
|
|
254797
|
-
requireApproval: false
|
|
254918
|
+
requireApproval: false,
|
|
254919
|
+
...this.signal ? { signal: this.signal } : {}
|
|
254798
254920
|
});
|
|
254799
254921
|
const str2 = typeof result === "string" ? result : JSON.stringify(result);
|
|
254800
254922
|
if (!str2.startsWith("Tool error:")) return `[Synthesized ${newToolName}]: ${str2}`;
|
|
@@ -255212,7 +255334,7 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255212
255334
|
this.outputs.set(subtaskId, entry);
|
|
255213
255335
|
this.emit("output:ready", entry);
|
|
255214
255336
|
const waiting = this.waiters.get(subtaskId) ?? [];
|
|
255215
|
-
for (const
|
|
255337
|
+
for (const resolve2 of waiting) resolve2(entry);
|
|
255216
255338
|
this.waiters.delete(subtaskId);
|
|
255217
255339
|
}
|
|
255218
255340
|
/**
|
|
@@ -255243,10 +255365,10 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255243
255365
|
waitFor(subtaskId, timeoutMs = 12e4) {
|
|
255244
255366
|
const existing = this.outputs.get(subtaskId);
|
|
255245
255367
|
if (existing && !this.retryPending.has(subtaskId)) return Promise.resolve(existing);
|
|
255246
|
-
return new Promise((
|
|
255368
|
+
return new Promise((resolve2, reject) => {
|
|
255247
255369
|
const resolver = (output) => {
|
|
255248
255370
|
clearTimeout(timer);
|
|
255249
|
-
|
|
255371
|
+
resolve2(output);
|
|
255250
255372
|
};
|
|
255251
255373
|
const timer = setTimeout(() => {
|
|
255252
255374
|
const waiting = this.waiters.get(subtaskId);
|
|
@@ -255300,10 +255422,10 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255300
255422
|
*/
|
|
255301
255423
|
collect(timeoutMs) {
|
|
255302
255424
|
const collected = [...this.broadcastLog];
|
|
255303
|
-
return new Promise((
|
|
255425
|
+
return new Promise((resolve2) => {
|
|
255304
255426
|
const timer = setTimeout(() => {
|
|
255305
255427
|
off();
|
|
255306
|
-
|
|
255428
|
+
resolve2(collected);
|
|
255307
255429
|
}, timeoutMs);
|
|
255308
255430
|
const handler = (msg) => {
|
|
255309
255431
|
collected.push({ fromId: msg.fromId, payload: msg.payload, timestamp: msg.timestamp });
|
|
@@ -255317,7 +255439,7 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255317
255439
|
const broadcasters = new Set(collected.map((m3) => m3.fromId));
|
|
255318
255440
|
if (broadcasters.size >= this.members.size) {
|
|
255319
255441
|
off();
|
|
255320
|
-
|
|
255442
|
+
resolve2(collected);
|
|
255321
255443
|
}
|
|
255322
255444
|
};
|
|
255323
255445
|
this.on("broadcast", checkComplete);
|
|
@@ -255335,7 +255457,7 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255335
255457
|
return;
|
|
255336
255458
|
}
|
|
255337
255459
|
this.emitCoordination(tierId, `\u23F3 waiting for ${filePath} (held by ${existing.holderId})`);
|
|
255338
|
-
return new Promise((
|
|
255460
|
+
return new Promise((resolve2, reject) => {
|
|
255339
255461
|
const timer = setTimeout(() => {
|
|
255340
255462
|
reject(new Error(`File lock timeout for ${filePath} (held by ${existing.holderId})`));
|
|
255341
255463
|
}, timeoutMs);
|
|
@@ -255343,7 +255465,7 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255343
255465
|
clearTimeout(timer);
|
|
255344
255466
|
this.fileLocks.set(filePath, { holderId: tierId, lockedAt: (/* @__PURE__ */ new Date()).toISOString(), waiters: [] });
|
|
255345
255467
|
this.emitCoordination(tierId, `\u{1F512} locked ${filePath}`);
|
|
255346
|
-
|
|
255468
|
+
resolve2();
|
|
255347
255469
|
});
|
|
255348
255470
|
});
|
|
255349
255471
|
}
|
|
@@ -255368,11 +255490,11 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255368
255490
|
*/
|
|
255369
255491
|
waitForFileRelease(filePath, timeoutMs = 3e4) {
|
|
255370
255492
|
if (!this.fileLocks.has(filePath)) return Promise.resolve();
|
|
255371
|
-
return new Promise((
|
|
255493
|
+
return new Promise((resolve2, reject) => {
|
|
255372
255494
|
const timer = setTimeout(() => reject(new Error(`Timeout waiting for file release: ${filePath}`)), timeoutMs);
|
|
255373
255495
|
this.once(`file:released:${filePath}`, () => {
|
|
255374
255496
|
clearTimeout(timer);
|
|
255375
|
-
|
|
255497
|
+
resolve2();
|
|
255376
255498
|
});
|
|
255377
255499
|
});
|
|
255378
255500
|
}
|
|
@@ -255438,13 +255560,13 @@ var PeerBus = class extends EventEmitter__default.default {
|
|
|
255438
255560
|
this.emit(`barrier:${barrierName}`);
|
|
255439
255561
|
return;
|
|
255440
255562
|
}
|
|
255441
|
-
return new Promise((
|
|
255563
|
+
return new Promise((resolve2, reject) => {
|
|
255442
255564
|
const timer = setTimeout(() => {
|
|
255443
255565
|
reject(new Error(`Barrier timeout: ${barrierName} (${bar.arrived.size}/${bar.total} arrived)`));
|
|
255444
255566
|
}, 12e4);
|
|
255445
255567
|
this.once(`barrier:${barrierName}`, () => {
|
|
255446
255568
|
clearTimeout(timer);
|
|
255447
|
-
|
|
255569
|
+
resolve2();
|
|
255448
255570
|
});
|
|
255449
255571
|
});
|
|
255450
255572
|
}
|
|
@@ -256989,6 +257111,170 @@ Reply with exactly one word: YES, NO, or UNSURE.
|
|
|
256989
257111
|
}
|
|
256990
257112
|
};
|
|
256991
257113
|
|
|
257114
|
+
// src/core/multimodal/registry.ts
|
|
257115
|
+
var CAPABILITIES = [
|
|
257116
|
+
// ── Image ──
|
|
257117
|
+
{
|
|
257118
|
+
modality: "image",
|
|
257119
|
+
provider: "openai",
|
|
257120
|
+
modelId: "dall-e-3",
|
|
257121
|
+
api: "openai-images"
|
|
257122
|
+
},
|
|
257123
|
+
{
|
|
257124
|
+
modality: "image",
|
|
257125
|
+
provider: "gemini",
|
|
257126
|
+
modelId: "gemini-3-pro-image",
|
|
257127
|
+
api: "gemini-predict"
|
|
257128
|
+
},
|
|
257129
|
+
// ── Speech (text → audio) ──
|
|
257130
|
+
{
|
|
257131
|
+
modality: "speech",
|
|
257132
|
+
provider: "openai",
|
|
257133
|
+
modelId: "tts-1",
|
|
257134
|
+
api: "openai-speech"
|
|
257135
|
+
},
|
|
257136
|
+
{
|
|
257137
|
+
// The only quality claim in this table that needs no leaderboard: OpenAI
|
|
257138
|
+
// ships these as the same voice at two fidelities and charges double for
|
|
257139
|
+
// this one. That is the vendor's own ordering, not an inference.
|
|
257140
|
+
modality: "speech",
|
|
257141
|
+
provider: "openai",
|
|
257142
|
+
modelId: "tts-1-hd",
|
|
257143
|
+
api: "openai-speech",
|
|
257144
|
+
quality: 70,
|
|
257145
|
+
qualityBasis: "OpenAI's own hd variant of tts-1, priced 2x"
|
|
257146
|
+
},
|
|
257147
|
+
// ── Transcription (audio → text) ──
|
|
257148
|
+
{
|
|
257149
|
+
modality: "transcription",
|
|
257150
|
+
provider: "openai",
|
|
257151
|
+
modelId: "whisper-1",
|
|
257152
|
+
api: "openai-transcriptions"
|
|
257153
|
+
},
|
|
257154
|
+
// ── Video ──
|
|
257155
|
+
{
|
|
257156
|
+
// Long-running: submit returns an operation name, the video lands minutes
|
|
257157
|
+
// later, and the bytes come from a short-lived signed URL. generate.ts owns
|
|
257158
|
+
// that polling loop; the registry only records the shape via `api`.
|
|
257159
|
+
modality: "video",
|
|
257160
|
+
provider: "gemini",
|
|
257161
|
+
modelId: "veo-3.1-generate-001",
|
|
257162
|
+
api: "gemini-predict-lro"
|
|
257163
|
+
}
|
|
257164
|
+
];
|
|
257165
|
+
function capabilityCost(cap) {
|
|
257166
|
+
const match = findPricing(cap.modelId, cap.provider, {
|
|
257167
|
+
fallbackProviders: cap.provider === "gemini" ? ["vertex"] : []
|
|
257168
|
+
});
|
|
257169
|
+
const rate = match?.entry.rates?.[0];
|
|
257170
|
+
if (!rate) return null;
|
|
257171
|
+
const unitLabel = {
|
|
257172
|
+
per_image: "per image",
|
|
257173
|
+
per_second: "per second of video",
|
|
257174
|
+
per_character: "per character",
|
|
257175
|
+
per_audio_minute: "per audio minute"
|
|
257176
|
+
};
|
|
257177
|
+
const unit = unitLabel[rate.unit] ?? rate.unit;
|
|
257178
|
+
const amount = rate.amount;
|
|
257179
|
+
const shown = amount < 1e-3 ? amount.toExponential(2) : amount.toFixed(4);
|
|
257180
|
+
return { label: `$${shown} ${unit}`, amount, unit };
|
|
257181
|
+
}
|
|
257182
|
+
var MultimodalRegistry = class {
|
|
257183
|
+
/** Provider types the user has actually configured a key for. */
|
|
257184
|
+
available;
|
|
257185
|
+
constructor(availableProviders) {
|
|
257186
|
+
this.available = new Set(availableProviders);
|
|
257187
|
+
}
|
|
257188
|
+
/** Every capability whose provider is configured AND which Cascade can call. */
|
|
257189
|
+
usable(modality) {
|
|
257190
|
+
return CAPABILITIES.filter(
|
|
257191
|
+
(c4) => !c4.unsupported && this.available.has(c4.provider) && (!modality || c4.modality === modality)
|
|
257192
|
+
);
|
|
257193
|
+
}
|
|
257194
|
+
/** Modalities this account can actually generate right now. */
|
|
257195
|
+
availableModalities() {
|
|
257196
|
+
return [...new Set(this.usable().map((c4) => c4.modality))];
|
|
257197
|
+
}
|
|
257198
|
+
/**
|
|
257199
|
+
* Pick a model for a modality.
|
|
257200
|
+
*
|
|
257201
|
+
* Ranked models beat unranked ones, then higher quality, then lower unit
|
|
257202
|
+
* price. An explicit `preferModel` wins outright when it is usable — the user
|
|
257203
|
+
* naming a model is a stronger signal than any prior.
|
|
257204
|
+
*/
|
|
257205
|
+
select(modality, opts = {}) {
|
|
257206
|
+
const pool = this.usable(modality);
|
|
257207
|
+
if (!pool.length) return null;
|
|
257208
|
+
if (opts.preferModel) {
|
|
257209
|
+
const wanted = pool.find((c4) => c4.modelId === opts.preferModel);
|
|
257210
|
+
if (wanted) {
|
|
257211
|
+
return { capability: wanted, cost: capabilityCost(wanted), reason: `Requested explicitly: ${wanted.modelId}.` };
|
|
257212
|
+
}
|
|
257213
|
+
}
|
|
257214
|
+
const scored = pool.map((c4) => ({ c: c4, cost: capabilityCost(c4) })).sort((a2, b3) => {
|
|
257215
|
+
const qa = a2.c.quality ?? -1;
|
|
257216
|
+
const qb = b3.c.quality ?? -1;
|
|
257217
|
+
if (qa !== qb) return qb - qa;
|
|
257218
|
+
const pa = a2.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
257219
|
+
const pb = b3.cost?.amount ?? Number.POSITIVE_INFINITY;
|
|
257220
|
+
return pa - pb;
|
|
257221
|
+
});
|
|
257222
|
+
const best = scored[0];
|
|
257223
|
+
const ranked = best.c.quality !== void 0;
|
|
257224
|
+
const reason = ranked ? `${best.c.modelId} (${best.c.provider}) \u2014 ranked highest for ${modality}: ${best.c.qualityBasis}.` + (best.cost ? ` ${best.cost.label}.` : "") : `${best.c.modelId} (${best.c.provider}) \u2014 cheapest usable ${modality} model` + (best.cost ? ` at ${best.cost.label}` : "") + ". No published quality ranking is applied for this modality, so this is a cost choice, not a quality one.";
|
|
257225
|
+
return { capability: best.c, cost: best.cost, reason };
|
|
257226
|
+
}
|
|
257227
|
+
/**
|
|
257228
|
+
* A plain-language account of what this account can and cannot generate —
|
|
257229
|
+
* including the things it cannot, and why. The planner sees this, so being
|
|
257230
|
+
* candid here is what stops it inventing a `generate_music` call.
|
|
257231
|
+
*/
|
|
257232
|
+
describe() {
|
|
257233
|
+
const lines = [];
|
|
257234
|
+
const usable = this.usable();
|
|
257235
|
+
if (usable.length) {
|
|
257236
|
+
lines.push("Generation models available on your configured providers:");
|
|
257237
|
+
for (const modality of ["image", "speech", "transcription", "video"]) {
|
|
257238
|
+
const forModality = usable.filter((c4) => c4.modality === modality);
|
|
257239
|
+
if (!forModality.length) continue;
|
|
257240
|
+
const shown = forModality.map((c4) => {
|
|
257241
|
+
const cost = capabilityCost(c4);
|
|
257242
|
+
return `${c4.modelId}${cost ? ` (${cost.label})` : ""}`;
|
|
257243
|
+
});
|
|
257244
|
+
lines.push(` ${modality}: ${shown.join(", ")}`);
|
|
257245
|
+
}
|
|
257246
|
+
} else {
|
|
257247
|
+
lines.push("No generation models are available \u2014 none of your configured providers offers one.");
|
|
257248
|
+
}
|
|
257249
|
+
const blocked = CAPABILITIES.filter((c4) => c4.unsupported && this.available.has(c4.provider));
|
|
257250
|
+
for (const c4 of blocked) {
|
|
257251
|
+
lines.push(` ${c4.modality}: ${c4.modelId} exists on your account but is not callable. ${c4.unsupported}`);
|
|
257252
|
+
}
|
|
257253
|
+
lines.push(
|
|
257254
|
+
" music: no supported provider exposes a music-generation API, so Cascade cannot generate music."
|
|
257255
|
+
);
|
|
257256
|
+
return lines.join("\n");
|
|
257257
|
+
}
|
|
257258
|
+
};
|
|
257259
|
+
|
|
257260
|
+
// src/tools/base.ts
|
|
257261
|
+
var BaseTool = class {
|
|
257262
|
+
workspaceRoot = process.cwd();
|
|
257263
|
+
setWorkspaceRoot(root) {
|
|
257264
|
+
this.workspaceRoot = root;
|
|
257265
|
+
}
|
|
257266
|
+
isDangerous() {
|
|
257267
|
+
return false;
|
|
257268
|
+
}
|
|
257269
|
+
getDefinition() {
|
|
257270
|
+
return {
|
|
257271
|
+
name: this.name,
|
|
257272
|
+
description: this.description,
|
|
257273
|
+
inputSchema: this.inputSchema
|
|
257274
|
+
};
|
|
257275
|
+
}
|
|
257276
|
+
};
|
|
257277
|
+
|
|
256992
257278
|
// src/core/router/provider-errors.ts
|
|
256993
257279
|
var SYSTEMIC = /* @__PURE__ */ new Set([
|
|
256994
257280
|
"rate_limit",
|
|
@@ -257053,7 +257339,7 @@ function classifyProviderError(err) {
|
|
|
257053
257339
|
return { kind: kind2, systemic: isSystemicKind(kind2), status, raw };
|
|
257054
257340
|
}
|
|
257055
257341
|
function describeProviderError(c4, modelId) {
|
|
257056
|
-
const on = ` on ${modelId}` ;
|
|
257342
|
+
const on = modelId ? ` on ${modelId}` : "";
|
|
257057
257343
|
const detail = c4.raw ? ` Provider said: ${c4.raw}` : "";
|
|
257058
257344
|
switch (c4.kind) {
|
|
257059
257345
|
case "rate_limit":
|
|
@@ -257075,6 +257361,417 @@ function describeProviderError(c4, modelId) {
|
|
|
257075
257361
|
}
|
|
257076
257362
|
}
|
|
257077
257363
|
|
|
257364
|
+
// src/core/multimodal/generate.ts
|
|
257365
|
+
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
257366
|
+
async function callProvider(fn, modelId) {
|
|
257367
|
+
try {
|
|
257368
|
+
return await fn();
|
|
257369
|
+
} catch (err) {
|
|
257370
|
+
const classified = classifyProviderError(err);
|
|
257371
|
+
throw new Error(describeProviderError(classified, modelId));
|
|
257372
|
+
}
|
|
257373
|
+
}
|
|
257374
|
+
async function postJson(url2, body, headers, signal) {
|
|
257375
|
+
const ac = new AbortController();
|
|
257376
|
+
const timer = setTimeout(() => ac.abort(), DEFAULT_TIMEOUT_MS);
|
|
257377
|
+
const onAbort = () => ac.abort();
|
|
257378
|
+
signal?.addEventListener("abort", onAbort);
|
|
257379
|
+
try {
|
|
257380
|
+
const res = await fetch(url2, {
|
|
257381
|
+
method: "POST",
|
|
257382
|
+
headers: { "Content-Type": "application/json", ...headers },
|
|
257383
|
+
body: JSON.stringify(body),
|
|
257384
|
+
signal: ac.signal
|
|
257385
|
+
});
|
|
257386
|
+
if (!res.ok) {
|
|
257387
|
+
const text = await res.text().catch(() => "");
|
|
257388
|
+
throw Object.assign(new Error(text || res.statusText), { status: res.status });
|
|
257389
|
+
}
|
|
257390
|
+
return res;
|
|
257391
|
+
} finally {
|
|
257392
|
+
clearTimeout(timer);
|
|
257393
|
+
signal?.removeEventListener("abort", onAbort);
|
|
257394
|
+
}
|
|
257395
|
+
}
|
|
257396
|
+
function baseUrlFor(cfg, fallback) {
|
|
257397
|
+
return (cfg.baseUrl ?? fallback).replace(/\/+$/, "");
|
|
257398
|
+
}
|
|
257399
|
+
function stamp(ext) {
|
|
257400
|
+
return `cascade-${Date.now()}.${ext}`;
|
|
257401
|
+
}
|
|
257402
|
+
async function generateImage(cap, cfg, req, signal) {
|
|
257403
|
+
return callProvider(async () => {
|
|
257404
|
+
if (cap.api === "openai-images") {
|
|
257405
|
+
const url2 = `${baseUrlFor(cfg, "https://api.openai.com/v1")}/images/generations`;
|
|
257406
|
+
const res = await postJson(url2, {
|
|
257407
|
+
model: cap.modelId,
|
|
257408
|
+
prompt: req.prompt,
|
|
257409
|
+
size: req.size ?? "1024x1024",
|
|
257410
|
+
n: 1,
|
|
257411
|
+
// b64 rather than a URL: see the file header — provider URLs expire.
|
|
257412
|
+
response_format: "b64_json"
|
|
257413
|
+
}, { Authorization: `Bearer ${cfg.apiKey ?? ""}` }, signal);
|
|
257414
|
+
const body = await res.json();
|
|
257415
|
+
const first3 = body.data?.[0];
|
|
257416
|
+
if (!first3?.b64_json) throw new Error("Image response contained no image data.");
|
|
257417
|
+
return {
|
|
257418
|
+
data: Buffer.from(first3.b64_json, "base64"),
|
|
257419
|
+
mimeType: "image/png",
|
|
257420
|
+
filename: stamp("png"),
|
|
257421
|
+
modelId: cap.modelId,
|
|
257422
|
+
provider: cap.provider,
|
|
257423
|
+
...first3.revised_prompt ? { revisedPrompt: first3.revised_prompt } : {}
|
|
257424
|
+
};
|
|
257425
|
+
}
|
|
257426
|
+
if (cap.api === "gemini-predict") {
|
|
257427
|
+
const base = baseUrlFor(cfg, "https://generativelanguage.googleapis.com/v1beta");
|
|
257428
|
+
const url2 = `${base}/models/${encodeURIComponent(cap.modelId)}:predict`;
|
|
257429
|
+
const res = await postJson(url2, {
|
|
257430
|
+
instances: [{ prompt: req.prompt }],
|
|
257431
|
+
parameters: { sampleCount: 1 }
|
|
257432
|
+
}, { "x-goog-api-key": cfg.apiKey ?? "" }, signal);
|
|
257433
|
+
const body = await res.json();
|
|
257434
|
+
const first3 = body.predictions?.[0];
|
|
257435
|
+
if (!first3?.bytesBase64Encoded) throw new Error("Image response contained no image data.");
|
|
257436
|
+
const mimeType = first3.mimeType ?? "image/png";
|
|
257437
|
+
return {
|
|
257438
|
+
data: Buffer.from(first3.bytesBase64Encoded, "base64"),
|
|
257439
|
+
mimeType,
|
|
257440
|
+
filename: stamp(mimeType.includes("jpeg") ? "jpg" : "png"),
|
|
257441
|
+
modelId: cap.modelId,
|
|
257442
|
+
provider: cap.provider
|
|
257443
|
+
};
|
|
257444
|
+
}
|
|
257445
|
+
throw new Error(`${cap.modelId} is not an image generator.`);
|
|
257446
|
+
}, cap.modelId);
|
|
257447
|
+
}
|
|
257448
|
+
async function generateSpeech(cap, cfg, req, signal) {
|
|
257449
|
+
return callProvider(async () => {
|
|
257450
|
+
if (cap.api !== "openai-speech") throw new Error(`${cap.modelId} is not a speech model.`);
|
|
257451
|
+
const format = req.format ?? "mp3";
|
|
257452
|
+
const url2 = `${baseUrlFor(cfg, "https://api.openai.com/v1")}/audio/speech`;
|
|
257453
|
+
const res = await postJson(url2, {
|
|
257454
|
+
model: cap.modelId,
|
|
257455
|
+
input: req.text,
|
|
257456
|
+
voice: req.voice ?? "alloy",
|
|
257457
|
+
response_format: format
|
|
257458
|
+
}, { Authorization: `Bearer ${cfg.apiKey ?? ""}` }, signal);
|
|
257459
|
+
const mime = {
|
|
257460
|
+
mp3: "audio/mpeg",
|
|
257461
|
+
opus: "audio/opus",
|
|
257462
|
+
aac: "audio/aac",
|
|
257463
|
+
flac: "audio/flac",
|
|
257464
|
+
wav: "audio/wav"
|
|
257465
|
+
};
|
|
257466
|
+
return {
|
|
257467
|
+
data: Buffer.from(await res.arrayBuffer()),
|
|
257468
|
+
mimeType: mime[format] ?? "application/octet-stream",
|
|
257469
|
+
filename: stamp(format),
|
|
257470
|
+
modelId: cap.modelId,
|
|
257471
|
+
provider: cap.provider
|
|
257472
|
+
};
|
|
257473
|
+
}, cap.modelId);
|
|
257474
|
+
}
|
|
257475
|
+
var VIDEO_POLL_INTERVAL_MS = 1e4;
|
|
257476
|
+
var VIDEO_TIMEOUT_MS = 8 * 6e4;
|
|
257477
|
+
function sleep4(ms2, signal) {
|
|
257478
|
+
return new Promise((resolve2, reject) => {
|
|
257479
|
+
if (signal?.aborted) return reject(new Error("Cancelled."));
|
|
257480
|
+
const timer = setTimeout(() => {
|
|
257481
|
+
signal?.removeEventListener("abort", onAbort);
|
|
257482
|
+
resolve2();
|
|
257483
|
+
}, ms2);
|
|
257484
|
+
function onAbort() {
|
|
257485
|
+
clearTimeout(timer);
|
|
257486
|
+
reject(new Error("Cancelled."));
|
|
257487
|
+
}
|
|
257488
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
257489
|
+
});
|
|
257490
|
+
}
|
|
257491
|
+
async function generateVideo(cap, cfg, req, signal, onProgress) {
|
|
257492
|
+
return callProvider(async () => {
|
|
257493
|
+
if (cap.api !== "gemini-predict-lro") throw new Error(`${cap.modelId} is not a video generator.`);
|
|
257494
|
+
const base = baseUrlFor(cfg, "https://generativelanguage.googleapis.com/v1beta");
|
|
257495
|
+
const key = cfg.apiKey ?? "";
|
|
257496
|
+
const headers = { "x-goog-api-key": key };
|
|
257497
|
+
const submit = await postJson(
|
|
257498
|
+
`${base}/models/${encodeURIComponent(cap.modelId)}:predictLongRunning`,
|
|
257499
|
+
{
|
|
257500
|
+
instances: [{ prompt: req.prompt }],
|
|
257501
|
+
parameters: {
|
|
257502
|
+
aspectRatio: req.aspectRatio ?? "16:9",
|
|
257503
|
+
...req.seconds ? { durationSeconds: req.seconds } : {}
|
|
257504
|
+
}
|
|
257505
|
+
},
|
|
257506
|
+
headers,
|
|
257507
|
+
signal
|
|
257508
|
+
);
|
|
257509
|
+
const started = await submit.json();
|
|
257510
|
+
if (!started.name) throw new Error("Video request was accepted but returned no operation to poll.");
|
|
257511
|
+
onProgress?.(`Video generation started (${cap.modelId}). This usually takes 1-3 minutes.`);
|
|
257512
|
+
const deadline = Date.now() + VIDEO_TIMEOUT_MS;
|
|
257513
|
+
let operation = {};
|
|
257514
|
+
while (Date.now() < deadline) {
|
|
257515
|
+
await sleep4(VIDEO_POLL_INTERVAL_MS, signal);
|
|
257516
|
+
const poll = await fetch(`${base}/${started.name}`, { headers, signal });
|
|
257517
|
+
if (!poll.ok) {
|
|
257518
|
+
const text = await poll.text().catch(() => "");
|
|
257519
|
+
throw Object.assign(new Error(text || poll.statusText), { status: poll.status });
|
|
257520
|
+
}
|
|
257521
|
+
operation = await poll.json();
|
|
257522
|
+
if (operation.done) break;
|
|
257523
|
+
onProgress?.("Still rendering\u2026");
|
|
257524
|
+
}
|
|
257525
|
+
if (!operation.done) {
|
|
257526
|
+
throw new Error(
|
|
257527
|
+
`Video was still rendering after ${Math.round(VIDEO_TIMEOUT_MS / 6e4)} minutes. It may still complete on the provider side, but Cascade stopped waiting.`
|
|
257528
|
+
);
|
|
257529
|
+
}
|
|
257530
|
+
if (operation.error?.message) throw new Error(operation.error.message);
|
|
257531
|
+
const uri = operation.response?.generateVideoResponse?.generatedSamples?.[0]?.video?.uri;
|
|
257532
|
+
if (!uri) throw new Error("Video finished but the response contained no video.");
|
|
257533
|
+
const media = await fetch(uri, { headers, signal });
|
|
257534
|
+
if (!media.ok) throw new Error(`Video finished but could not be downloaded (HTTP ${media.status}).`);
|
|
257535
|
+
return {
|
|
257536
|
+
data: Buffer.from(await media.arrayBuffer()),
|
|
257537
|
+
mimeType: "video/mp4",
|
|
257538
|
+
filename: stamp("mp4"),
|
|
257539
|
+
modelId: cap.modelId,
|
|
257540
|
+
provider: cap.provider
|
|
257541
|
+
};
|
|
257542
|
+
}, cap.modelId);
|
|
257543
|
+
}
|
|
257544
|
+
async function transcribeAudio(cap, cfg, req, signal) {
|
|
257545
|
+
return callProvider(async () => {
|
|
257546
|
+
if (cap.api !== "openai-transcriptions") throw new Error(`${cap.modelId} is not a transcription model.`);
|
|
257547
|
+
const url2 = `${baseUrlFor(cfg, "https://api.openai.com/v1")}/audio/transcriptions`;
|
|
257548
|
+
const form = new FormData();
|
|
257549
|
+
form.append("model", cap.modelId);
|
|
257550
|
+
if (req.language) form.append("language", req.language);
|
|
257551
|
+
form.append("file", new Blob([new Uint8Array(req.audio)]), req.filename);
|
|
257552
|
+
const ac = new AbortController();
|
|
257553
|
+
const timer = setTimeout(() => ac.abort(), DEFAULT_TIMEOUT_MS);
|
|
257554
|
+
const onAbort = () => ac.abort();
|
|
257555
|
+
signal?.addEventListener("abort", onAbort);
|
|
257556
|
+
try {
|
|
257557
|
+
const res = await fetch(url2, {
|
|
257558
|
+
method: "POST",
|
|
257559
|
+
headers: { Authorization: `Bearer ${cfg.apiKey ?? ""}` },
|
|
257560
|
+
body: form,
|
|
257561
|
+
signal: ac.signal
|
|
257562
|
+
});
|
|
257563
|
+
if (!res.ok) {
|
|
257564
|
+
const text = await res.text().catch(() => "");
|
|
257565
|
+
throw Object.assign(new Error(text || res.statusText), { status: res.status });
|
|
257566
|
+
}
|
|
257567
|
+
const body = await res.json();
|
|
257568
|
+
return { text: body.text ?? "", modelId: cap.modelId };
|
|
257569
|
+
} finally {
|
|
257570
|
+
clearTimeout(timer);
|
|
257571
|
+
signal?.removeEventListener("abort", onAbort);
|
|
257572
|
+
}
|
|
257573
|
+
}, cap.modelId);
|
|
257574
|
+
}
|
|
257575
|
+
|
|
257576
|
+
// src/tools/generate-media.ts
|
|
257577
|
+
function resolve(deps, modality, preferModel) {
|
|
257578
|
+
const selected = deps.registry.select(modality, preferModel ? { preferModel } : {});
|
|
257579
|
+
if (!selected) {
|
|
257580
|
+
return { ok: false, error: `No ${modality} model is available on your configured providers.` };
|
|
257581
|
+
}
|
|
257582
|
+
const cfg = deps.lookupProvider(selected.capability.provider);
|
|
257583
|
+
if (!cfg) {
|
|
257584
|
+
return {
|
|
257585
|
+
ok: false,
|
|
257586
|
+
error: `${selected.capability.modelId} needs the ${selected.capability.provider} provider, which is not configured.`
|
|
257587
|
+
};
|
|
257588
|
+
}
|
|
257589
|
+
return { ok: true, selected, cfg };
|
|
257590
|
+
}
|
|
257591
|
+
var GenerateImageTool = class extends BaseTool {
|
|
257592
|
+
constructor(deps) {
|
|
257593
|
+
super();
|
|
257594
|
+
this.deps = deps;
|
|
257595
|
+
}
|
|
257596
|
+
deps;
|
|
257597
|
+
name = "generate_image";
|
|
257598
|
+
description = "Generate an image from a text description using the best available image model. Returns where the image was saved. Use when the user asks for a picture, illustration, diagram render, logo or any visual asset.";
|
|
257599
|
+
inputSchema = {
|
|
257600
|
+
type: "object",
|
|
257601
|
+
properties: {
|
|
257602
|
+
prompt: { type: "string", description: "What the image should show. Be specific about subject, style and composition." },
|
|
257603
|
+
size: { type: "string", description: 'Pixel size, e.g. "1024x1024" (default), "1792x1024", "1024x1792".' },
|
|
257604
|
+
model: { type: "string", description: "Optional: force a specific image model instead of the automatic choice." }
|
|
257605
|
+
},
|
|
257606
|
+
required: ["prompt"]
|
|
257607
|
+
};
|
|
257608
|
+
async execute(input, options) {
|
|
257609
|
+
const prompt = String(input["prompt"] ?? "").trim();
|
|
257610
|
+
if (!prompt) return 'Provide a "prompt" describing the image.';
|
|
257611
|
+
const r4 = resolve(this.deps, "image", input["model"] ? String(input["model"]) : void 0);
|
|
257612
|
+
if (!r4.ok) return r4.error;
|
|
257613
|
+
const size = input["size"] ? String(input["size"]) : void 0;
|
|
257614
|
+
const asset = await generateImage(
|
|
257615
|
+
r4.selected.capability,
|
|
257616
|
+
r4.cfg,
|
|
257617
|
+
{ prompt, ...size ? { size } : {} },
|
|
257618
|
+
options.signal
|
|
257619
|
+
);
|
|
257620
|
+
const location = await this.deps.sink(asset);
|
|
257621
|
+
return [
|
|
257622
|
+
`Image generated and saved to ${location}.`,
|
|
257623
|
+
`Model: ${asset.modelId} \u2014 ${r4.selected.reason}`,
|
|
257624
|
+
// DALL·E rewrites the prompt before drawing; the model needs to know what
|
|
257625
|
+
// was actually rendered, not what it asked for, or its description of the
|
|
257626
|
+
// result will not match the image.
|
|
257627
|
+
asset.revisedPrompt ? `The provider rewrote the prompt to: ${asset.revisedPrompt}` : ""
|
|
257628
|
+
].filter(Boolean).join("\n");
|
|
257629
|
+
}
|
|
257630
|
+
};
|
|
257631
|
+
var GenerateSpeechTool = class extends BaseTool {
|
|
257632
|
+
constructor(deps) {
|
|
257633
|
+
super();
|
|
257634
|
+
this.deps = deps;
|
|
257635
|
+
}
|
|
257636
|
+
deps;
|
|
257637
|
+
name = "generate_speech";
|
|
257638
|
+
description = "Turn text into spoken audio using the best available text-to-speech model. Returns where the audio was saved. Use when the user asks for narration, a voiceover or an audio version of some text.";
|
|
257639
|
+
inputSchema = {
|
|
257640
|
+
type: "object",
|
|
257641
|
+
properties: {
|
|
257642
|
+
text: { type: "string", description: "The text to speak." },
|
|
257643
|
+
voice: { type: "string", description: "Voice id: alloy, echo, fable, onyx, nova, shimmer. Default alloy." },
|
|
257644
|
+
format: { type: "string", description: "Audio format: mp3 (default), opus, aac, flac, wav." },
|
|
257645
|
+
model: { type: "string", description: "Optional: force a specific speech model." }
|
|
257646
|
+
},
|
|
257647
|
+
required: ["text"]
|
|
257648
|
+
};
|
|
257649
|
+
async execute(input, options) {
|
|
257650
|
+
const text = String(input["text"] ?? "").trim();
|
|
257651
|
+
if (!text) return 'Provide "text" to speak.';
|
|
257652
|
+
const r4 = resolve(this.deps, "speech", input["model"] ? String(input["model"]) : void 0);
|
|
257653
|
+
if (!r4.ok) return r4.error;
|
|
257654
|
+
const fmt = String(input["format"] ?? "mp3");
|
|
257655
|
+
const allowed = ["mp3", "opus", "aac", "flac", "wav"];
|
|
257656
|
+
const format = allowed.includes(fmt) ? fmt : "mp3";
|
|
257657
|
+
const asset = await generateSpeech(
|
|
257658
|
+
r4.selected.capability,
|
|
257659
|
+
r4.cfg,
|
|
257660
|
+
{ text, voice: input["voice"] ? String(input["voice"]) : void 0, format },
|
|
257661
|
+
options.signal
|
|
257662
|
+
);
|
|
257663
|
+
const location = await this.deps.sink(asset);
|
|
257664
|
+
return `Speech generated and saved to ${location}.
|
|
257665
|
+
Model: ${asset.modelId} \u2014 ${r4.selected.reason}`;
|
|
257666
|
+
}
|
|
257667
|
+
};
|
|
257668
|
+
var DEFAULT_VIDEO_SECONDS = 5;
|
|
257669
|
+
var MAX_VIDEO_SECONDS = 8;
|
|
257670
|
+
var GenerateVideoTool = class extends BaseTool {
|
|
257671
|
+
constructor(deps) {
|
|
257672
|
+
super();
|
|
257673
|
+
this.deps = deps;
|
|
257674
|
+
}
|
|
257675
|
+
deps;
|
|
257676
|
+
name = "generate_video";
|
|
257677
|
+
// The price is in the description on purpose. Video is ~1000x the cost of an
|
|
257678
|
+
// image per call, it is billed per SECOND, and the model choosing the
|
|
257679
|
+
// duration is the one deciding the bill — so the number has to be where the
|
|
257680
|
+
// model reads before calling, not only in the result afterwards.
|
|
257681
|
+
description = "Generate a short video clip from a text description. EXPENSIVE and slow: billed per second of output (about $0.40/second, so a 5-second clip costs roughly $2) and takes 1-3 minutes. Only use when the user explicitly asks for a video, and prefer the shortest duration that satisfies the request.";
|
|
257682
|
+
inputSchema = {
|
|
257683
|
+
type: "object",
|
|
257684
|
+
properties: {
|
|
257685
|
+
prompt: { type: "string", description: "What the video should show: subject, action, camera movement, style." },
|
|
257686
|
+
seconds: { type: "number", description: `Clip length, 1-${MAX_VIDEO_SECONDS} seconds (default ${DEFAULT_VIDEO_SECONDS}). Billed per second \u2014 keep it short.` },
|
|
257687
|
+
aspectRatio: { type: "string", description: 'Frame shape: "16:9" (default) or "9:16" for vertical.' },
|
|
257688
|
+
model: { type: "string", description: "Optional: force a specific video model." }
|
|
257689
|
+
},
|
|
257690
|
+
required: ["prompt"]
|
|
257691
|
+
};
|
|
257692
|
+
async execute(input, options) {
|
|
257693
|
+
const prompt = String(input["prompt"] ?? "").trim();
|
|
257694
|
+
if (!prompt) return 'Provide a "prompt" describing the video.';
|
|
257695
|
+
const r4 = resolve(this.deps, "video", input["model"] ? String(input["model"]) : void 0);
|
|
257696
|
+
if (!r4.ok) return r4.error;
|
|
257697
|
+
const asked = typeof input["seconds"] === "number" ? input["seconds"] : DEFAULT_VIDEO_SECONDS;
|
|
257698
|
+
const seconds = Math.max(1, Math.min(MAX_VIDEO_SECONDS, Math.round(asked)));
|
|
257699
|
+
const asset = await generateVideo(
|
|
257700
|
+
r4.selected.capability,
|
|
257701
|
+
r4.cfg,
|
|
257702
|
+
{
|
|
257703
|
+
prompt,
|
|
257704
|
+
seconds,
|
|
257705
|
+
...input["aspectRatio"] ? { aspectRatio: String(input["aspectRatio"]) } : {}
|
|
257706
|
+
},
|
|
257707
|
+
options.signal,
|
|
257708
|
+
// Progress goes to the run log so a two-minute wait doesn't look like a
|
|
257709
|
+
// hang — the single most likely reason someone kills a working render.
|
|
257710
|
+
(note) => options.onProgress?.(note)
|
|
257711
|
+
);
|
|
257712
|
+
const location = await this.deps.sink(asset);
|
|
257713
|
+
const unit = r4.selected.cost;
|
|
257714
|
+
const estimate = unit ? ` Estimated cost: $${(unit.amount * seconds).toFixed(2)} (${seconds}s x ${unit.label}).` : "";
|
|
257715
|
+
const clamped = seconds !== Math.round(asked) ? ` Duration was clamped to ${seconds}s (max ${MAX_VIDEO_SECONDS}).` : "";
|
|
257716
|
+
return `Video generated and saved to ${location}.
|
|
257717
|
+
Model: ${asset.modelId}.${estimate}${clamped}`;
|
|
257718
|
+
}
|
|
257719
|
+
};
|
|
257720
|
+
var TranscribeAudioTool = class extends BaseTool {
|
|
257721
|
+
constructor(deps, readFile) {
|
|
257722
|
+
super();
|
|
257723
|
+
this.deps = deps;
|
|
257724
|
+
this.readFile = readFile;
|
|
257725
|
+
}
|
|
257726
|
+
deps;
|
|
257727
|
+
readFile;
|
|
257728
|
+
name = "transcribe_audio";
|
|
257729
|
+
description = "Transcribe a local audio file to text using the best available speech-to-text model. Use when the user supplies audio and wants its contents in writing.";
|
|
257730
|
+
inputSchema = {
|
|
257731
|
+
type: "object",
|
|
257732
|
+
properties: {
|
|
257733
|
+
path: { type: "string", description: "Path to the audio file to transcribe." },
|
|
257734
|
+
language: { type: "string", description: 'Optional ISO-639-1 language hint, e.g. "en", improves accuracy.' },
|
|
257735
|
+
model: { type: "string", description: "Optional: force a specific transcription model." }
|
|
257736
|
+
},
|
|
257737
|
+
required: ["path"]
|
|
257738
|
+
};
|
|
257739
|
+
async execute(input, options) {
|
|
257740
|
+
const filePath = String(input["path"] ?? "").trim();
|
|
257741
|
+
if (!filePath) return 'Provide a "path" to the audio file.';
|
|
257742
|
+
const r4 = resolve(this.deps, "transcription", input["model"] ? String(input["model"]) : void 0);
|
|
257743
|
+
if (!r4.ok) return r4.error;
|
|
257744
|
+
let audio;
|
|
257745
|
+
try {
|
|
257746
|
+
audio = await this.readFile(filePath);
|
|
257747
|
+
} catch {
|
|
257748
|
+
return `Could not read the audio file at ${filePath}.`;
|
|
257749
|
+
}
|
|
257750
|
+
const { text, modelId } = await transcribeAudio(
|
|
257751
|
+
r4.selected.capability,
|
|
257752
|
+
r4.cfg,
|
|
257753
|
+
{
|
|
257754
|
+
audio,
|
|
257755
|
+
filename: filePath.split(/[\\/]/).pop() || "audio",
|
|
257756
|
+
...input["language"] ? { language: String(input["language"]) } : {}
|
|
257757
|
+
},
|
|
257758
|
+
options.signal
|
|
257759
|
+
);
|
|
257760
|
+
return text ? `Transcript (${modelId}):
|
|
257761
|
+
|
|
257762
|
+
${text}` : `${modelId} returned an empty transcript \u2014 the file may be silent or in an unsupported format.`;
|
|
257763
|
+
}
|
|
257764
|
+
};
|
|
257765
|
+
function buildMediaTools(deps, readFile) {
|
|
257766
|
+
const tools = [];
|
|
257767
|
+
const modalities = new Set(deps.registry.availableModalities());
|
|
257768
|
+
if (modalities.has("image")) tools.push(new GenerateImageTool(deps));
|
|
257769
|
+
if (modalities.has("speech")) tools.push(new GenerateSpeechTool(deps));
|
|
257770
|
+
if (modalities.has("video")) tools.push(new GenerateVideoTool(deps));
|
|
257771
|
+
if (modalities.has("transcription") && readFile) tools.push(new TranscribeAudioTool(deps, readFile));
|
|
257772
|
+
return tools;
|
|
257773
|
+
}
|
|
257774
|
+
|
|
257078
257775
|
// src/core/run-breaker.ts
|
|
257079
257776
|
var DEFAULT_FAILURE_THRESHOLD = 3;
|
|
257080
257777
|
var RunBreaker = class {
|
|
@@ -257143,26 +257840,6 @@ var RunBreaker = class {
|
|
|
257143
257840
|
|
|
257144
257841
|
// src/tools/registry.ts
|
|
257145
257842
|
var import_ignore = __toESM(require_ignore(), 1);
|
|
257146
|
-
|
|
257147
|
-
// src/tools/base.ts
|
|
257148
|
-
var BaseTool = class {
|
|
257149
|
-
workspaceRoot = process.cwd();
|
|
257150
|
-
setWorkspaceRoot(root) {
|
|
257151
|
-
this.workspaceRoot = root;
|
|
257152
|
-
}
|
|
257153
|
-
isDangerous() {
|
|
257154
|
-
return false;
|
|
257155
|
-
}
|
|
257156
|
-
getDefinition() {
|
|
257157
|
-
return {
|
|
257158
|
-
name: this.name,
|
|
257159
|
-
description: this.description,
|
|
257160
|
-
inputSchema: this.inputSchema
|
|
257161
|
-
};
|
|
257162
|
-
}
|
|
257163
|
-
};
|
|
257164
|
-
|
|
257165
|
-
// src/tools/shell.ts
|
|
257166
257843
|
var execAsync = util$1.promisify(child_process.exec);
|
|
257167
257844
|
var ShellTool = class extends BaseTool {
|
|
257168
257845
|
name = "shell";
|
|
@@ -284744,7 +285421,7 @@ var PDFCreateTool = class extends BaseTool {
|
|
|
284744
285421
|
if (!fs11__namespace.default.existsSync(dir)) {
|
|
284745
285422
|
fs11__namespace.default.mkdirSync(dir, { recursive: true });
|
|
284746
285423
|
}
|
|
284747
|
-
return new Promise((
|
|
285424
|
+
return new Promise((resolve2, reject) => {
|
|
284748
285425
|
try {
|
|
284749
285426
|
const doc = new PDFDocument({ margin: 50 });
|
|
284750
285427
|
const stream2 = fs11__namespace.default.createWriteStream(filePath);
|
|
@@ -284762,7 +285439,7 @@ var PDFCreateTool = class extends BaseTool {
|
|
|
284762
285439
|
});
|
|
284763
285440
|
doc.end();
|
|
284764
285441
|
stream2.on("finish", () => {
|
|
284765
|
-
|
|
285442
|
+
resolve2(`Successfully created PDF at ${filePath} (${content.length} characters)`);
|
|
284766
285443
|
});
|
|
284767
285444
|
stream2.on("error", (err) => {
|
|
284768
285445
|
reject(new Error(`Failed to write PDF: ${err.message}`));
|
|
@@ -284834,7 +285511,7 @@ var CodeInterpreterTool = class extends BaseTool {
|
|
|
284834
285511
|
const filePath = path26__namespace.default.join(tmpDir, fileName);
|
|
284835
285512
|
fs11__namespace.default.writeFileSync(filePath, code, "utf-8");
|
|
284836
285513
|
const execArgs = [filePath, ...args];
|
|
284837
|
-
return new Promise((
|
|
285514
|
+
return new Promise((resolve2) => {
|
|
284838
285515
|
const startMs = Date.now();
|
|
284839
285516
|
child_process.execFile(cmdPrefix, execArgs, { cwd: this.workspaceRoot, timeout: 3e4 }, (error2, stdout, stderr) => {
|
|
284840
285517
|
const duration3 = Date.now() - startMs;
|
|
@@ -284848,17 +285525,17 @@ var CodeInterpreterTool = class extends BaseTool {
|
|
|
284848
285525
|
if (error2) {
|
|
284849
285526
|
const timedOut = error2.killed && duration3 >= 3e4;
|
|
284850
285527
|
if (timedOut) {
|
|
284851
|
-
|
|
285528
|
+
resolve2(`Execution timed out after 30s. Consider breaking the task into smaller pieces.
|
|
284852
285529
|
Partial stdout: ${stdout}
|
|
284853
285530
|
Stderr: ${stderr}`);
|
|
284854
285531
|
} else {
|
|
284855
|
-
|
|
285532
|
+
resolve2(`Execution failed (${duration3}ms):
|
|
284856
285533
|
Error: ${error2.message}
|
|
284857
285534
|
Stderr: ${stderr}
|
|
284858
285535
|
Stdout: ${stdout}`);
|
|
284859
285536
|
}
|
|
284860
285537
|
} else {
|
|
284861
|
-
|
|
285538
|
+
resolve2(`Execution successful (${duration3}ms):
|
|
284862
285539
|
Stdout: ${stdout}
|
|
284863
285540
|
Stderr: ${stderr}`);
|
|
284864
285541
|
}
|
|
@@ -285512,7 +286189,7 @@ var ToolRegistry = class extends EventEmitter__default.default {
|
|
|
285512
286189
|
*/
|
|
285513
286190
|
waitForTool(toolName, timeoutMs = 6e4) {
|
|
285514
286191
|
if (this.tools.has(toolName)) return Promise.resolve();
|
|
285515
|
-
return new Promise((
|
|
286192
|
+
return new Promise((resolve2, reject) => {
|
|
285516
286193
|
const timer = setTimeout(() => {
|
|
285517
286194
|
this.off("tool:added", handler);
|
|
285518
286195
|
reject(new Error(`Timeout waiting for tool: ${toolName}`));
|
|
@@ -285521,7 +286198,7 @@ var ToolRegistry = class extends EventEmitter__default.default {
|
|
|
285521
286198
|
if (name === toolName) {
|
|
285522
286199
|
clearTimeout(timer);
|
|
285523
286200
|
this.off("tool:added", handler);
|
|
285524
|
-
|
|
286201
|
+
resolve2();
|
|
285525
286202
|
}
|
|
285526
286203
|
};
|
|
285527
286204
|
this.on("tool:added", handler);
|
|
@@ -289772,7 +290449,7 @@ __export(util_exports, {
|
|
|
289772
290449
|
getParsedType: () => getParsedType2,
|
|
289773
290450
|
getSizableOrigin: () => getSizableOrigin,
|
|
289774
290451
|
isObject: () => isObject2,
|
|
289775
|
-
isPlainObject: () =>
|
|
290452
|
+
isPlainObject: () => isPlainObject4,
|
|
289776
290453
|
issue: () => issue,
|
|
289777
290454
|
joinValues: () => joinValues,
|
|
289778
290455
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
@@ -289916,7 +290593,7 @@ var allowsEval = cached(() => {
|
|
|
289916
290593
|
return false;
|
|
289917
290594
|
}
|
|
289918
290595
|
});
|
|
289919
|
-
function
|
|
290596
|
+
function isPlainObject4(o3) {
|
|
289920
290597
|
if (isObject2(o3) === false)
|
|
289921
290598
|
return false;
|
|
289922
290599
|
const ctor = o3.constructor;
|
|
@@ -290101,7 +290778,7 @@ function omit(schema, mask) {
|
|
|
290101
290778
|
});
|
|
290102
290779
|
}
|
|
290103
290780
|
function extend(schema, shape) {
|
|
290104
|
-
if (!
|
|
290781
|
+
if (!isPlainObject4(shape)) {
|
|
290105
290782
|
throw new Error("Invalid input to extend: expected a plain object");
|
|
290106
290783
|
}
|
|
290107
290784
|
const def = {
|
|
@@ -291750,7 +292427,7 @@ function mergeValues2(a2, b3) {
|
|
|
291750
292427
|
if (a2 instanceof Date && b3 instanceof Date && +a2 === +b3) {
|
|
291751
292428
|
return { valid: true, data: a2 };
|
|
291752
292429
|
}
|
|
291753
|
-
if (
|
|
292430
|
+
if (isPlainObject4(a2) && isPlainObject4(b3)) {
|
|
291754
292431
|
const bKeys = Object.keys(b3);
|
|
291755
292432
|
const sharedKeys = Object.keys(a2).filter((key) => bKeys.indexOf(key) !== -1);
|
|
291756
292433
|
const newObj = { ...a2, ...b3 };
|
|
@@ -291807,7 +292484,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
291807
292484
|
$ZodType.init(inst, def);
|
|
291808
292485
|
inst._zod.parse = (payload, ctx) => {
|
|
291809
292486
|
const input = payload.value;
|
|
291810
|
-
if (!
|
|
292487
|
+
if (!isPlainObject4(input)) {
|
|
291811
292488
|
payload.issues.push({
|
|
291812
292489
|
expected: "record",
|
|
291813
292490
|
code: "invalid_type",
|
|
@@ -295677,7 +296354,7 @@ var Protocol = class {
|
|
|
295677
296354
|
return;
|
|
295678
296355
|
}
|
|
295679
296356
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
295680
|
-
await new Promise((
|
|
296357
|
+
await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
|
|
295681
296358
|
options?.signal?.throwIfAborted();
|
|
295682
296359
|
}
|
|
295683
296360
|
} catch (error2) {
|
|
@@ -295694,7 +296371,7 @@ var Protocol = class {
|
|
|
295694
296371
|
*/
|
|
295695
296372
|
request(request, resultSchema, options) {
|
|
295696
296373
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
295697
|
-
return new Promise((
|
|
296374
|
+
return new Promise((resolve2, reject) => {
|
|
295698
296375
|
const earlyReject = (error2) => {
|
|
295699
296376
|
reject(error2);
|
|
295700
296377
|
};
|
|
@@ -295772,7 +296449,7 @@ var Protocol = class {
|
|
|
295772
296449
|
if (!parseResult.success) {
|
|
295773
296450
|
reject(parseResult.error);
|
|
295774
296451
|
} else {
|
|
295775
|
-
|
|
296452
|
+
resolve2(parseResult.data);
|
|
295776
296453
|
}
|
|
295777
296454
|
} catch (error2) {
|
|
295778
296455
|
reject(error2);
|
|
@@ -296033,12 +296710,12 @@ var Protocol = class {
|
|
|
296033
296710
|
}
|
|
296034
296711
|
} catch {
|
|
296035
296712
|
}
|
|
296036
|
-
return new Promise((
|
|
296713
|
+
return new Promise((resolve2, reject) => {
|
|
296037
296714
|
if (signal.aborted) {
|
|
296038
296715
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
296039
296716
|
return;
|
|
296040
296717
|
}
|
|
296041
|
-
const timeoutId = setTimeout(
|
|
296718
|
+
const timeoutId = setTimeout(resolve2, interval);
|
|
296042
296719
|
signal.addEventListener("abort", () => {
|
|
296043
296720
|
clearTimeout(timeoutId);
|
|
296044
296721
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -296111,7 +296788,7 @@ var Protocol = class {
|
|
|
296111
296788
|
};
|
|
296112
296789
|
}
|
|
296113
296790
|
};
|
|
296114
|
-
function
|
|
296791
|
+
function isPlainObject5(value) {
|
|
296115
296792
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
296116
296793
|
}
|
|
296117
296794
|
function mergeCapabilities(base, additional) {
|
|
@@ -296122,7 +296799,7 @@ function mergeCapabilities(base, additional) {
|
|
|
296122
296799
|
if (addValue === void 0)
|
|
296123
296800
|
continue;
|
|
296124
296801
|
const baseValue = result[k4];
|
|
296125
|
-
if (
|
|
296802
|
+
if (isPlainObject5(baseValue) && isPlainObject5(addValue)) {
|
|
296126
296803
|
result[k4] = { ...baseValue, ...addValue };
|
|
296127
296804
|
} else {
|
|
296128
296805
|
result[k4] = addValue;
|
|
@@ -296971,7 +297648,7 @@ var StdioClientTransport = class {
|
|
|
296971
297648
|
if (this._process) {
|
|
296972
297649
|
throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
|
|
296973
297650
|
}
|
|
296974
|
-
return new Promise((
|
|
297651
|
+
return new Promise((resolve2, reject) => {
|
|
296975
297652
|
this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
|
|
296976
297653
|
// merge default env with server env because mcp server needs some env vars
|
|
296977
297654
|
env: {
|
|
@@ -296988,7 +297665,7 @@ var StdioClientTransport = class {
|
|
|
296988
297665
|
this.onerror?.(error2);
|
|
296989
297666
|
});
|
|
296990
297667
|
this._process.on("spawn", () => {
|
|
296991
|
-
|
|
297668
|
+
resolve2();
|
|
296992
297669
|
});
|
|
296993
297670
|
this._process.on("close", (_code) => {
|
|
296994
297671
|
this._process = void 0;
|
|
@@ -297047,22 +297724,22 @@ var StdioClientTransport = class {
|
|
|
297047
297724
|
if (this._process) {
|
|
297048
297725
|
const processToClose = this._process;
|
|
297049
297726
|
this._process = void 0;
|
|
297050
|
-
const closePromise = new Promise((
|
|
297727
|
+
const closePromise = new Promise((resolve2) => {
|
|
297051
297728
|
processToClose.once("close", () => {
|
|
297052
|
-
|
|
297729
|
+
resolve2();
|
|
297053
297730
|
});
|
|
297054
297731
|
});
|
|
297055
297732
|
try {
|
|
297056
297733
|
processToClose.stdin?.end();
|
|
297057
297734
|
} catch {
|
|
297058
297735
|
}
|
|
297059
|
-
await Promise.race([closePromise, new Promise((
|
|
297736
|
+
await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
|
|
297060
297737
|
if (processToClose.exitCode === null) {
|
|
297061
297738
|
try {
|
|
297062
297739
|
processToClose.kill("SIGTERM");
|
|
297063
297740
|
} catch {
|
|
297064
297741
|
}
|
|
297065
|
-
await Promise.race([closePromise, new Promise((
|
|
297742
|
+
await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
|
|
297066
297743
|
}
|
|
297067
297744
|
if (processToClose.exitCode === null) {
|
|
297068
297745
|
try {
|
|
@@ -297074,15 +297751,15 @@ var StdioClientTransport = class {
|
|
|
297074
297751
|
this._readBuffer.clear();
|
|
297075
297752
|
}
|
|
297076
297753
|
send(message) {
|
|
297077
|
-
return new Promise((
|
|
297754
|
+
return new Promise((resolve2) => {
|
|
297078
297755
|
if (!this._process?.stdin) {
|
|
297079
297756
|
throw new Error("Not connected");
|
|
297080
297757
|
}
|
|
297081
297758
|
const json = serializeMessage(message);
|
|
297082
297759
|
if (this._process.stdin.write(json)) {
|
|
297083
|
-
|
|
297760
|
+
resolve2();
|
|
297084
297761
|
} else {
|
|
297085
|
-
this._process.stdin.once("drain",
|
|
297762
|
+
this._process.stdin.once("drain", resolve2);
|
|
297086
297763
|
}
|
|
297087
297764
|
});
|
|
297088
297765
|
}
|
|
@@ -298910,7 +299587,7 @@ var SSEClientTransport = class {
|
|
|
298910
299587
|
}
|
|
298911
299588
|
_startOrAuth() {
|
|
298912
299589
|
const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
|
|
298913
|
-
return new Promise((
|
|
299590
|
+
return new Promise((resolve2, reject) => {
|
|
298914
299591
|
this._eventSource = new EventSource(this._url.href, {
|
|
298915
299592
|
...this._eventSourceInit,
|
|
298916
299593
|
fetch: async (url2, init2) => {
|
|
@@ -298931,7 +299608,7 @@ var SSEClientTransport = class {
|
|
|
298931
299608
|
this._abortController = new AbortController();
|
|
298932
299609
|
this._eventSource.onerror = (event) => {
|
|
298933
299610
|
if (event.code === 401 && this._authProvider) {
|
|
298934
|
-
this._authThenStart().then(
|
|
299611
|
+
this._authThenStart().then(resolve2, reject);
|
|
298935
299612
|
return;
|
|
298936
299613
|
}
|
|
298937
299614
|
const error2 = new SseError(event.code, event.message, event);
|
|
@@ -298953,7 +299630,7 @@ var SSEClientTransport = class {
|
|
|
298953
299630
|
void this.close();
|
|
298954
299631
|
return;
|
|
298955
299632
|
}
|
|
298956
|
-
|
|
299633
|
+
resolve2();
|
|
298957
299634
|
});
|
|
298958
299635
|
this._eventSource.onmessage = (event) => {
|
|
298959
299636
|
const messageEvent = event;
|
|
@@ -299599,20 +300276,20 @@ var PermissionEscalator = class extends EventEmitter__default.default {
|
|
|
299599
300276
|
resolver(decision);
|
|
299600
300277
|
}
|
|
299601
300278
|
waitForUserDecision(req) {
|
|
299602
|
-
return new Promise((
|
|
300279
|
+
return new Promise((resolve2) => {
|
|
299603
300280
|
let timer;
|
|
299604
300281
|
const wrappedResolver = (decision) => {
|
|
299605
300282
|
if (timer) clearTimeout(timer);
|
|
299606
300283
|
if (decision.always) {
|
|
299607
300284
|
this.taskWideCache.set(req.toolName, decision.approved);
|
|
299608
300285
|
}
|
|
299609
|
-
|
|
300286
|
+
resolve2(decision);
|
|
299610
300287
|
};
|
|
299611
300288
|
this.pendingUserDecisions.set(req.id, wrappedResolver);
|
|
299612
300289
|
if (this.approvalTimeoutMs > 0 && Number.isFinite(this.approvalTimeoutMs)) {
|
|
299613
300290
|
timer = setTimeout(() => {
|
|
299614
300291
|
if (this.pendingUserDecisions.delete(req.id)) {
|
|
299615
|
-
|
|
300292
|
+
resolve2({
|
|
299616
300293
|
requestId: req.id,
|
|
299617
300294
|
approved: false,
|
|
299618
300295
|
decidedBy: "USER",
|
|
@@ -299713,7 +300390,14 @@ var ToolsConfigSchema = external_exports.object({
|
|
|
299713
300390
|
* built-in tool (shell/file/git/…) from existing at all, rather than just
|
|
299714
300391
|
* gating it behind approval. Omitted = full default set (unchanged).
|
|
299715
300392
|
*/
|
|
299716
|
-
enabledTools: external_exports.array(external_exports.string()).optional()
|
|
300393
|
+
enabledTools: external_exports.array(external_exports.string()).optional(),
|
|
300394
|
+
/**
|
|
300395
|
+
* Tools to remove even when they would otherwise be registered. Unlike
|
|
300396
|
+
* `enabledTools` (an allowlist over the built-in set), this also reaches
|
|
300397
|
+
* tools registered outside it — MCP tools and media generation — which is
|
|
300398
|
+
* the only way to turn those off.
|
|
300399
|
+
*/
|
|
300400
|
+
disabledTools: external_exports.array(external_exports.string()).optional()
|
|
299717
300401
|
});
|
|
299718
300402
|
var HookDefinitionSchema = external_exports.object({
|
|
299719
300403
|
name: external_exports.string().optional(),
|
|
@@ -299781,6 +300465,14 @@ var BudgetConfigSchema = external_exports.object({
|
|
|
299781
300465
|
maxTokensPerRun: external_exports.number().int().positive().default(2e5),
|
|
299782
300466
|
/** Optional hard per-task cost ceiling (USD). Unset = only the token cap applies. */
|
|
299783
300467
|
maxCostPerRunUsd: external_exports.number().positive().optional(),
|
|
300468
|
+
/**
|
|
300469
|
+
* Consecutive systemic failures against ONE model before the run stops
|
|
300470
|
+
* launching work that would fail the same way (dead key, wrong model id,
|
|
300471
|
+
* exhausted quota). Lower reacts sooner and wastes less; higher absorbs a
|
|
300472
|
+
* longer transient before giving up. Only failures that will certainly repeat
|
|
300473
|
+
* are counted — see core/run-breaker.ts.
|
|
300474
|
+
*/
|
|
300475
|
+
failureThreshold: external_exports.number().int().min(1).max(20).default(3),
|
|
299784
300476
|
warnAtPct: external_exports.number().default(80)
|
|
299785
300477
|
});
|
|
299786
300478
|
var WorkspaceConfigSchema = external_exports.object({
|
|
@@ -300068,6 +300760,23 @@ var noopTelemetry = {
|
|
|
300068
300760
|
}
|
|
300069
300761
|
};
|
|
300070
300762
|
|
|
300763
|
+
// src/core/router/feedback-prior.ts
|
|
300764
|
+
var MAX_FEEDBACK_ADJUSTMENT = 0.05;
|
|
300765
|
+
var PRIOR_STRENGTH = 10;
|
|
300766
|
+
function feedbackAdjustment(counts) {
|
|
300767
|
+
const good = Math.max(0, Math.floor(counts.good));
|
|
300768
|
+
const bad = Math.max(0, Math.floor(counts.bad));
|
|
300769
|
+
const n8 = good + bad;
|
|
300770
|
+
if (n8 === 0) return 0;
|
|
300771
|
+
const half = PRIOR_STRENGTH / 2;
|
|
300772
|
+
const shrunk = (good + half) / (n8 + PRIOR_STRENGTH);
|
|
300773
|
+
return (shrunk - 0.5) * 2 * MAX_FEEDBACK_ADJUSTMENT;
|
|
300774
|
+
}
|
|
300775
|
+
function applyFeedback(score01, counts) {
|
|
300776
|
+
const adjusted = score01 + feedbackAdjustment(counts);
|
|
300777
|
+
return Math.max(0, Math.min(1, adjusted));
|
|
300778
|
+
}
|
|
300779
|
+
|
|
300071
300780
|
// src/core/router/task-analyzer.ts
|
|
300072
300781
|
var CODE_SIGNALS = [
|
|
300073
300782
|
/\b(?:function|class|interface|async|await|import|export|const|let|var|def|return|if|else|for|while|try|catch)\b/,
|
|
@@ -300142,6 +300851,8 @@ var TASK_TYPE_TAGS = {
|
|
|
300142
300851
|
};
|
|
300143
300852
|
var TaskAnalyzer = class {
|
|
300144
300853
|
tracker;
|
|
300854
|
+
/** Per-model thumbs counts, when the host collects them. */
|
|
300855
|
+
feedback;
|
|
300145
300856
|
bias;
|
|
300146
300857
|
lastProfile = null;
|
|
300147
300858
|
lastSelectedModels = /* @__PURE__ */ new Map();
|
|
@@ -300149,6 +300860,14 @@ var TaskAnalyzer = class {
|
|
|
300149
300860
|
this.tracker = tracker;
|
|
300150
300861
|
this.bias = bias;
|
|
300151
300862
|
}
|
|
300863
|
+
/**
|
|
300864
|
+
* Supply per-model rating counts. Optional by design: a host that collects no
|
|
300865
|
+
* feedback (the CLI, a fresh install) scores exactly as it did before, since
|
|
300866
|
+
* feedbackAdjustment returns 0 for an empty record.
|
|
300867
|
+
*/
|
|
300868
|
+
setFeedbackSource(source) {
|
|
300869
|
+
this.feedback = source;
|
|
300870
|
+
}
|
|
300152
300871
|
setTracker(tracker) {
|
|
300153
300872
|
this.tracker = tracker;
|
|
300154
300873
|
}
|
|
@@ -300232,7 +300951,10 @@ var TaskAnalyzer = class {
|
|
|
300232
300951
|
const perf = this.tracker?.performanceScore(model.id, profile.type) ?? 0.5;
|
|
300233
300952
|
const costEff = this.costEfficiency(model, profile.complexity);
|
|
300234
300953
|
const match = this.taskMatchScore(model, profile);
|
|
300235
|
-
const
|
|
300954
|
+
const rated = this.feedback?.(model.id);
|
|
300955
|
+
const publicScore = benchmarkScore01(model, profile.type);
|
|
300956
|
+
const adjusted = rated ? applyFeedback(publicScore, rated) : publicScore;
|
|
300957
|
+
const benchmark = 0.3 + 0.7 * adjusted;
|
|
300236
300958
|
switch (this.bias) {
|
|
300237
300959
|
case "quality":
|
|
300238
300960
|
return perf * match * benchmark ** 2 * (0.85 + 0.15 * costEff);
|
|
@@ -300634,10 +301356,10 @@ var DynamicTool = class extends BaseTool {
|
|
|
300634
301356
|
`;
|
|
300635
301357
|
const script = await isolate.compileScript(bootstrap);
|
|
300636
301358
|
const runPromise = script.run(context, { timeout: timeoutMs, promise: true }).then((v6) => String(v6 ?? ""));
|
|
300637
|
-
const timeoutPromise = new Promise((
|
|
301359
|
+
const timeoutPromise = new Promise((resolve2) => {
|
|
300638
301360
|
const t4 = setTimeout(() => {
|
|
300639
301361
|
dispose();
|
|
300640
|
-
|
|
301362
|
+
resolve2(`Dynamic tool "${this.name}" timed out after ${timeoutMs}ms and was terminated.`);
|
|
300641
301363
|
}, timeoutMs + 500);
|
|
300642
301364
|
t4.unref?.();
|
|
300643
301365
|
});
|
|
@@ -300655,7 +301377,7 @@ var DynamicTool = class extends BaseTool {
|
|
|
300655
301377
|
/** Spawn the worker, service its callTool/fetch bridge, enforce the kill timeout. */
|
|
300656
301378
|
runInWorker(input, callTool) {
|
|
300657
301379
|
const timeoutMs = Math.max(200, Number(process.env["CASCADE_DYNAMIC_TOOL_TIMEOUT_MS"]) || DYNAMIC_TOOL_TIMEOUT_MS);
|
|
300658
|
-
return new Promise((
|
|
301380
|
+
return new Promise((resolve2) => {
|
|
300659
301381
|
let settled = false;
|
|
300660
301382
|
const worker = new worker_threads.Worker(HARNESS_SRC, {
|
|
300661
301383
|
eval: true,
|
|
@@ -300667,7 +301389,7 @@ var DynamicTool = class extends BaseTool {
|
|
|
300667
301389
|
settled = true;
|
|
300668
301390
|
clearTimeout(timer);
|
|
300669
301391
|
void worker.terminate();
|
|
300670
|
-
|
|
301392
|
+
resolve2(value);
|
|
300671
301393
|
};
|
|
300672
301394
|
const timer = setTimeout(
|
|
300673
301395
|
() => finish(`Dynamic tool "${this.name}" timed out after ${timeoutMs}ms and was terminated.`),
|
|
@@ -302223,6 +302945,8 @@ ${prompt}`;
|
|
|
302223
302945
|
var Cascade = class _Cascade extends EventEmitter__default.default {
|
|
302224
302946
|
router;
|
|
302225
302947
|
toolRegistry;
|
|
302948
|
+
multimodal;
|
|
302949
|
+
mediaSink;
|
|
302226
302950
|
mcpClient;
|
|
302227
302951
|
codeIndex;
|
|
302228
302952
|
config;
|
|
@@ -302261,6 +302985,10 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
|
|
|
302261
302985
|
}
|
|
302262
302986
|
});
|
|
302263
302987
|
this.toolRegistry = new ToolRegistry(this.config.tools, workspacePath);
|
|
302988
|
+
this.multimodal = new MultimodalRegistry(
|
|
302989
|
+
(this.config.providers ?? []).map((p3) => p3.type)
|
|
302990
|
+
);
|
|
302991
|
+
this.registerMediaTools(workspacePath);
|
|
302264
302992
|
this.telemetry = config2.telemetry?.enabled ? new Telemetry(config2.telemetry, config2.telemetry.distinctId ?? "anonymous") : noopTelemetry;
|
|
302265
302993
|
this.worldStateDB = new WorldStateDB(this.workspacePath, this.config.workspace?.debugWorldState ?? false);
|
|
302266
302994
|
this.router.setWorldStateDB(this.worldStateDB);
|
|
@@ -302314,14 +303042,14 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
|
|
|
302314
303042
|
if (this.listenerCount("mcp:approval-required") === 0) {
|
|
302315
303043
|
return false;
|
|
302316
303044
|
}
|
|
302317
|
-
return await new Promise((
|
|
302318
|
-
this.pendingMcpApprovals.set(server.name,
|
|
303045
|
+
return await new Promise((resolve2) => {
|
|
303046
|
+
this.pendingMcpApprovals.set(server.name, resolve2);
|
|
302319
303047
|
const timeout = setTimeout(() => {
|
|
302320
|
-
if (this.pendingMcpApprovals.delete(server.name))
|
|
303048
|
+
if (this.pendingMcpApprovals.delete(server.name)) resolve2(false);
|
|
302321
303049
|
}, 3e4);
|
|
302322
303050
|
const wrap = (approved) => {
|
|
302323
303051
|
clearTimeout(timeout);
|
|
302324
|
-
|
|
303052
|
+
resolve2(approved);
|
|
302325
303053
|
};
|
|
302326
303054
|
this.pendingMcpApprovals.set(server.name, wrap);
|
|
302327
303055
|
this.emit("mcp:approval-required", { server });
|
|
@@ -302395,17 +303123,17 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
|
|
|
302395
303123
|
}
|
|
302396
303124
|
const t2Count = plan.sections.length;
|
|
302397
303125
|
const t3Count = plan.sections.reduce((sum, s3) => sum + (s3.t3Subtasks?.length ?? 0), 0);
|
|
302398
|
-
return await new Promise((
|
|
303126
|
+
return await new Promise((resolve2) => {
|
|
302399
303127
|
const timeout = setTimeout(() => {
|
|
302400
303128
|
if (this.pendingPlanApproval) {
|
|
302401
303129
|
this.pendingPlanApproval = void 0;
|
|
302402
|
-
|
|
303130
|
+
resolve2({ approved: true });
|
|
302403
303131
|
}
|
|
302404
303132
|
}, 12e4);
|
|
302405
303133
|
this.pendingPlanApproval = (decision) => {
|
|
302406
303134
|
clearTimeout(timeout);
|
|
302407
303135
|
this.pendingPlanApproval = void 0;
|
|
302408
|
-
|
|
303136
|
+
resolve2(decision);
|
|
302409
303137
|
};
|
|
302410
303138
|
this.emit("plan:approval-required", {
|
|
302411
303139
|
taskId,
|
|
@@ -302438,17 +303166,17 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
|
|
|
302438
303166
|
}
|
|
302439
303167
|
async requestContextApproval(info) {
|
|
302440
303168
|
if (this.listenerCount("context:approval-required") === 0) return true;
|
|
302441
|
-
return await new Promise((
|
|
303169
|
+
return await new Promise((resolve2) => {
|
|
302442
303170
|
const timeout = setTimeout(() => {
|
|
302443
303171
|
if (this.pendingContextApproval) {
|
|
302444
303172
|
this.pendingContextApproval = void 0;
|
|
302445
|
-
|
|
303173
|
+
resolve2(true);
|
|
302446
303174
|
}
|
|
302447
303175
|
}, 12e4);
|
|
302448
303176
|
this.pendingContextApproval = (approved) => {
|
|
302449
303177
|
clearTimeout(timeout);
|
|
302450
303178
|
this.pendingContextApproval = void 0;
|
|
302451
|
-
|
|
303179
|
+
resolve2(approved);
|
|
302452
303180
|
};
|
|
302453
303181
|
this.emit("context:approval-required", info);
|
|
302454
303182
|
});
|
|
@@ -302528,6 +303256,68 @@ ${input}` }],
|
|
|
302528
303256
|
if (this.store) t1.setStore(this.store);
|
|
302529
303257
|
return t1.previewPlan(prompt);
|
|
302530
303258
|
}
|
|
303259
|
+
/**
|
|
303260
|
+
* Register image / speech / transcription tools for the modalities this
|
|
303261
|
+
* config can actually serve.
|
|
303262
|
+
*
|
|
303263
|
+
* The sink writes bytes into the workspace, because that is what a desktop or
|
|
303264
|
+
* CLI run wants and it keeps a generated asset indistinguishable from any
|
|
303265
|
+
* other file the run produced. A host with different storage (the cloud
|
|
303266
|
+
* server stores a file row) constructs the tools itself via buildMediaTools
|
|
303267
|
+
* with its own sink.
|
|
303268
|
+
*/
|
|
303269
|
+
/**
|
|
303270
|
+
* Replace where generated media is written.
|
|
303271
|
+
*
|
|
303272
|
+
* The default sink writes into the workspace, which is what a desktop or CLI
|
|
303273
|
+
* run wants. A host with different storage — the cloud server keeps a file
|
|
303274
|
+
* row plus bytes under the tenant's directory — supplies its own here, and
|
|
303275
|
+
* the media tools are rebuilt around it. Re-registering by name replaces the
|
|
303276
|
+
* existing tools rather than duplicating them.
|
|
303277
|
+
*/
|
|
303278
|
+
setMediaSink(sink) {
|
|
303279
|
+
this.mediaSink = sink;
|
|
303280
|
+
this.registerMediaTools(this.workspacePath);
|
|
303281
|
+
}
|
|
303282
|
+
registerMediaTools(workspacePath) {
|
|
303283
|
+
const denied = new Set(this.config.tools?.disabledTools ?? []);
|
|
303284
|
+
const permitted = (name) => !denied.has(name);
|
|
303285
|
+
const tools = buildMediaTools(
|
|
303286
|
+
{
|
|
303287
|
+
registry: this.multimodal,
|
|
303288
|
+
lookupProvider: (provider) => (this.config.providers ?? []).find((p3) => p3.type === provider),
|
|
303289
|
+
sink: this.mediaSink ?? (async (asset) => {
|
|
303290
|
+
const fsp = await import('fs/promises');
|
|
303291
|
+
const nodePath = await import('path');
|
|
303292
|
+
const dir = nodePath.join(workspacePath, "generated");
|
|
303293
|
+
await fsp.mkdir(dir, { recursive: true });
|
|
303294
|
+
const dest = nodePath.join(dir, asset.filename);
|
|
303295
|
+
await fsp.writeFile(dest, asset.data);
|
|
303296
|
+
return nodePath.relative(workspacePath, dest);
|
|
303297
|
+
})
|
|
303298
|
+
},
|
|
303299
|
+
async (p3) => {
|
|
303300
|
+
const fsp = await import('fs/promises');
|
|
303301
|
+
return fsp.readFile(p3);
|
|
303302
|
+
}
|
|
303303
|
+
);
|
|
303304
|
+
for (const tool of tools) {
|
|
303305
|
+
if (!permitted(tool.name)) continue;
|
|
303306
|
+
tool.setWorkspaceRoot(workspacePath);
|
|
303307
|
+
this.toolRegistry.register(tool);
|
|
303308
|
+
}
|
|
303309
|
+
}
|
|
303310
|
+
/**
|
|
303311
|
+
* Supply per-model thumbs-up/down counts so Auto routing can weigh how models
|
|
303312
|
+
* have actually performed for this user, on top of public benchmarks.
|
|
303313
|
+
*
|
|
303314
|
+
* Optional everywhere: with no source, or an empty record, scoring is
|
|
303315
|
+
* byte-identical to before. The adjustment is capped and sample-size shrunk —
|
|
303316
|
+
* see core/router/feedback-prior.ts.
|
|
303317
|
+
*/
|
|
303318
|
+
setFeedbackSource(source) {
|
|
303319
|
+
this.router.setFeedbackSource(source);
|
|
303320
|
+
}
|
|
302531
303321
|
/** True when a task stopped at the budget cap and can be resumed via /continue. */
|
|
302532
303322
|
hasResumableRun() {
|
|
302533
303323
|
return this.lastInterruptedRun != null;
|
|
@@ -303017,7 +303807,7 @@ ${prompt}` : prompt;
|
|
|
303017
303807
|
if (toolCreator) toolCreator.setPermissionEscalator(escalator);
|
|
303018
303808
|
const rootPrompt = buildContextualPrompt(options.prompt, options.conversationHistory);
|
|
303019
303809
|
let finalOutput = "";
|
|
303020
|
-
const runBreaker = new RunBreaker();
|
|
303810
|
+
const runBreaker = new RunBreaker(this.config.budget?.failureThreshold);
|
|
303021
303811
|
let t2Results = [];
|
|
303022
303812
|
let runError = null;
|
|
303023
303813
|
let identityPrompt = "";
|
|
@@ -305194,12 +305984,12 @@ var promisifyStore = (passedStore) => {
|
|
|
305194
305984
|
const legacyStore = passedStore;
|
|
305195
305985
|
class PromisifiedStore {
|
|
305196
305986
|
async increment(key) {
|
|
305197
|
-
return new Promise((
|
|
305987
|
+
return new Promise((resolve2, reject) => {
|
|
305198
305988
|
legacyStore.incr(
|
|
305199
305989
|
key,
|
|
305200
305990
|
(error2, totalHits, resetTime) => {
|
|
305201
305991
|
if (error2) reject(error2);
|
|
305202
|
-
|
|
305992
|
+
resolve2({ totalHits, resetTime });
|
|
305203
305993
|
}
|
|
305204
305994
|
);
|
|
305205
305995
|
});
|
|
@@ -305974,12 +306764,12 @@ var DashboardServer = class {
|
|
|
305974
306764
|
console.warn("\u26A0 Dashboard auth is DISABLED while bound to a non-loopback interface \u2014 this allows unauthenticated remote task execution.");
|
|
305975
306765
|
}
|
|
305976
306766
|
}
|
|
305977
|
-
await new Promise((
|
|
306767
|
+
await new Promise((resolve2, reject) => {
|
|
305978
306768
|
const onError2 = (err) => reject(err);
|
|
305979
306769
|
this.httpServer.once("error", onError2);
|
|
305980
306770
|
this.httpServer.listen(this.port, this.host, () => {
|
|
305981
306771
|
this.httpServer.off("error", onError2);
|
|
305982
|
-
|
|
306772
|
+
resolve2();
|
|
305983
306773
|
});
|
|
305984
306774
|
});
|
|
305985
306775
|
try {
|
|
@@ -306003,8 +306793,8 @@ var DashboardServer = class {
|
|
|
306003
306793
|
} catch {
|
|
306004
306794
|
}
|
|
306005
306795
|
this.globalStore = null;
|
|
306006
|
-
await new Promise((
|
|
306007
|
-
this.httpServer.close((err) => err ? reject(err) :
|
|
306796
|
+
await new Promise((resolve2, reject) => {
|
|
306797
|
+
this.httpServer.close((err) => err ? reject(err) : resolve2());
|
|
306008
306798
|
});
|
|
306009
306799
|
}
|
|
306010
306800
|
getSocket() {
|
|
@@ -306201,8 +306991,8 @@ var DashboardServer = class {
|
|
|
306201
306991
|
* timeout denies it.
|
|
306202
306992
|
*/
|
|
306203
306993
|
makeApprovalCallback(sessionId) {
|
|
306204
|
-
return (request) => new Promise((
|
|
306205
|
-
this.pendingApprovals.set(request.id, { resolve, sessionId });
|
|
306994
|
+
return (request) => new Promise((resolve2) => {
|
|
306995
|
+
this.pendingApprovals.set(request.id, { resolve: resolve2, sessionId });
|
|
306206
306996
|
});
|
|
306207
306997
|
}
|
|
306208
306998
|
/**
|
|
@@ -307302,7 +308092,7 @@ var CloudClient = class _CloudClient {
|
|
|
307302
308092
|
const deadline = Date.now() + start.expiresIn * 1e3;
|
|
307303
308093
|
while (Date.now() < deadline) {
|
|
307304
308094
|
if (opts.signal?.aborted) throw new Error("Sign-in cancelled.");
|
|
307305
|
-
await
|
|
308095
|
+
await sleep5(interval * 1e3, opts.signal);
|
|
307306
308096
|
const r4 = await this.pollDevice(start.deviceCode);
|
|
307307
308097
|
if (r4 === "slow_down") {
|
|
307308
308098
|
interval += 5;
|
|
@@ -307513,9 +308303,9 @@ var CloudClient = class _CloudClient {
|
|
|
307513
308303
|
this.store.clear();
|
|
307514
308304
|
}
|
|
307515
308305
|
};
|
|
307516
|
-
function
|
|
307517
|
-
return new Promise((
|
|
307518
|
-
const t4 = setTimeout(
|
|
308306
|
+
function sleep5(ms2, signal) {
|
|
308307
|
+
return new Promise((resolve2, reject) => {
|
|
308308
|
+
const t4 = setTimeout(resolve2, ms2);
|
|
307519
308309
|
signal?.addEventListener("abort", () => {
|
|
307520
308310
|
clearTimeout(t4);
|
|
307521
308311
|
reject(new Error("aborted"));
|