cascade-ai 0.49.0 → 0.51.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.
@@ -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((resolve, reject) => {
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
- resolve(await input(attemptNumber));
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 isPlainObject6 = function isPlainObject7(obj) {
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 && (isPlainObject6(copy) || (copyIsArray = isArray4(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 && isPlainObject6(src) ? 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((resolve) => {
10475
- setTimeout(resolve, delay2);
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((resolve, reject) => {
11375
- req2.once("response", resolve).once("error", reject).end();
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((resolve, reject) => {
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
- resolve({
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((resolve) => resolve(value));
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((resolve, reject) => {
12027
- reader._closedPromise_resolve = 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((resolve, reject) => {
12202
- resolvePromise = resolve;
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((resolve, reject) => {
12308
- resolvePromise = resolve;
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((resolve, reject) => {
13328
- resolvePromise = resolve;
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((resolve, reject) => {
13640
+ const promise = newPromise((resolve2, reject) => {
13641
13641
  stream2._pendingAbortRequest = {
13642
13642
  _promise: void 0,
13643
- _resolve: 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((resolve, reject) => {
13660
+ const promise = newPromise((resolve2, reject) => {
13661
13661
  const closeRequest = {
13662
- _resolve: 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((resolve, reject) => {
13675
+ const promise = newPromise((resolve2, reject) => {
13676
13676
  const writeRequest = {
13677
- _resolve: 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((resolve, reject) => {
14294
- writer._closedPromise_resolve = 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((resolve, reject) => {
14331
- writer._readyPromise_resolve = 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((resolve, reject) => {
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
- resolve(void 0);
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((resolve) => {
14845
- resolveCancelPromise = resolve;
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((resolve) => {
14937
- resolveCancelPromise = resolve;
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((resolve) => {
15718
- startPromise_resolve = 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((resolve) => {
15812
- stream2._backpressureChangePromise_resolve = 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((resolve, reject) => {
15981
- controller._finishPromise_resolve = 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((resolve, reject) => {
16008
- controller._finishPromise_resolve = 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((resolve, reject) => {
16039
- controller._finishPromise_resolve = 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((resolve, reject) => {
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
- resolve(response2);
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
- resolve(fetch4(new Request4(locationURL, requestOptions)));
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
- resolve(response);
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
- resolve(response);
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
- resolve(response);
18148
+ resolve2(response);
18149
18149
  });
18150
18150
  raw.once("end", () => {
18151
18151
  if (!response) {
18152
18152
  response = new Response4(body, responseOptions);
18153
- resolve(response);
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
- resolve(response);
18165
+ resolve2(response);
18166
18166
  return;
18167
18167
  }
18168
18168
  response = new Response4(body, responseOptions);
18169
- resolve(response);
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((resolve, reject) => {
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
- resolve();
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((resolve, reject) => {
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
- resolve();
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((resolve, reject) => {
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 resolve();
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((resolve, reject) => {
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 resolve(response);
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((resolve, reject) => {
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 resolve(r4);
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 resolve(client);
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((resolve) => {
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
- resolve(projectId);
27682
+ resolve2(projectId);
27683
27683
  return;
27684
27684
  } catch (e3) {
27685
27685
  }
27686
27686
  }
27687
- resolve(null);
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(resolve, reject) {
34836
+ child = new nativePromise(function(resolve2, reject) {
34837
34837
  parent2.then(function(value) {
34838
- resolve(_clone(value, depth2 - 1));
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 = resolve.call(this, root, ref);
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 resolve(root, ref) {
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 resolve(baseURI, relativeURI, options) {
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(resolve, reject) {
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
- resolve(is2);
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((resolve, reject) => {
168089
+ const step = (i4) => new Promise((resolve2, reject) => {
168090
168090
  if (i4 === pathEnv.length)
168091
- return opt.all && found.length ? resolve(found) : reject(getNotFoundError(cmd));
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
- resolve(subStep(p3, i4, 0));
168096
+ resolve2(subStep(p3, i4, 0));
168097
168097
  });
168098
- const subStep = (p3, i4, ii2) => new Promise((resolve, reject) => {
168098
+ const subStep = (p3, i4, ii2) => new Promise((resolve2, reject) => {
168099
168099
  if (ii2 === pathExt.length)
168100
- return resolve(step(i4 + 1));
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 resolve(p3 + ext);
168107
+ return resolve2(p3 + ext);
168108
168108
  }
168109
- return resolve(subStep(p3, i4, ii2 + 1));
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 isPlainObject5(candidate) {
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((resolve) => {
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
- resolve();
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 resolve;
172578
+ let resolve2;
172579
172579
  const promise = new Promise((r4) => {
172580
- resolve = r4;
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 resolve = this._consumeWaitUntilCycle();
172612
+ const resolve2 = this._consumeWaitUntilCycle();
172613
172613
  try {
172614
172614
  await super.flush();
172615
172615
  } catch {
172616
172616
  } finally {
172617
- resolve?.();
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((resolve) => {
172716
+ return new Promise((resolve2) => {
172717
172717
  const timeout = setTimeout(() => {
172718
172718
  cleanup();
172719
- resolve(false);
172719
+ resolve2(false);
172720
172720
  }, timeoutMs);
172721
172721
  const cleanup = this._events.on("localEvaluationFlagsLoaded", (count) => {
172722
172722
  clearTimeout(timeout);
172723
172723
  cleanup();
172724
- resolve(count > 0);
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 resolve = this._consumeWaitUntilCycle();
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
- resolve?.();
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 (isPlainObject5(value) && groups && key in groups) {
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(resolve, reject) {
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
- resolve(buf);
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 normalizeType(value) {
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 normalizeType(value);
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 isPlainObject6 = gPO ? gPO(obj) === Object.prototype : obj instanceof Object || obj.constructor === Object;
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 = !isPlainObject6 && toStringTag && Object(obj) === obj && toStringTag in obj ? $slice.call(toStr(obj), 8, -1) : protoTag ? "Object" : "";
188174
- var constructorTag = isPlainObject6 || typeof obj.constructor !== "function" ? "" : obj.constructor.name ? obj.constructor.name + " " : "";
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 resolve = path28.resolve;
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 = resolve(root, name);
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 resolve2(dir, file) {
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 resolve = path28.resolve;
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 ? resolve(opts.root) : null;
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 = resolve(String(path29));
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 = resolve(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 resolve = __require("path").resolve;
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", resolve("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 normalizeType = require_utils5().normalizeType;
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 resolve = path28.resolve;
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 ? resolve(path29) : path29;
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", normalizeType(key).value);
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 resolve = __require("path").resolve;
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 = resolve(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(resolve, reject) {
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
- resolve(res);
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(resolve, reject) {
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
- resolve(res);
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(resolve, reject) {
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
- resolve(res);
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((resolve, reject) => {
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 resolve(responses);
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((resolve, reject) => {
205010
+ return new Promise((resolve2, reject) => {
205011
205011
  args.push((arg1, arg2) => {
205012
205012
  if (withErr) {
205013
- return arg1 ? reject(arg1) : resolve(arg2);
205013
+ return arg1 ? reject(arg1) : resolve2(arg2);
205014
205014
  } else {
205015
- return resolve(arg1);
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((resolve, reject) => {
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 resolve(responses);
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((resolve, reject) => {
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((resolve, reject) => {
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((resolve) => {
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
- resolve();
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 isPlainObject6(value) {
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 = isPlainObject6;
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 isPlainObject6 = require_lodash5();
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: isPlainObject6, message: '"header" must be an object' },
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 (!isPlainObject6(object3)) {
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((resolve) => setTimeout(resolve, ms2));
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((resolve) => {
217610
- resolve(null);
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((resolve, reject) => {
219031
- __classPrivateFieldSet(this, _BetaMessageStream_resolveConnectedPromise, resolve, "f");
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((resolve, reject) => {
219035
- __classPrivateFieldSet(this, _BetaMessageStream_resolveEndPromise, resolve, "f");
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((resolve, reject) => {
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, resolve);
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((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
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 resolve;
219621
+ let resolve2;
219622
219622
  let reject;
219623
219623
  const promise = new Promise((res, rej) => {
219624
- resolve = res;
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((resolve, reject) => {
221308
- __classPrivateFieldSet(this, _MessageStream_resolveConnectedPromise, resolve, "f");
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((resolve, reject) => {
221312
- __classPrivateFieldSet(this, _MessageStream_resolveEndPromise, resolve, "f");
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((resolve, reject) => {
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, resolve);
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((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
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.49.0";
224250
+ var CASCADE_VERSION = "0.51.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 NON_CHAT_PATTERNS = [
224764
- "embed",
224763
+ var MODALITY_PATTERNS = [
224764
+ ["embedding", ["embed"]],
224765
224765
  // text-embedding-3, nomic-embed, mxbai-embed, snowflake-arctic-embed
224766
- "(?:^|[-_/])tts(?:[-_/]|$)",
224767
- "text-to-speech",
224768
- "speech",
224769
- // text-to-speech
224770
- "whisper",
224771
- "transcrib",
224772
- "(?:^|[-_/])stt(?:[-_/]|$)",
224773
- // speech-to-text
224774
- "dall[-]?e",
224775
- "imagen",
224776
- "image-generation",
224777
- "gpt-image",
224778
- "(?:^|[-_/])image(?:[-_/]|$)",
224779
- "stable-diffusion",
224780
- "sdxl",
224781
- "flux",
224782
- // image gen
224783
- "moderation",
224784
- "(?:^|[-_/])guard(?:[-_/]|$)",
224785
- // moderation / safety
224786
- "rerank",
224787
- "(?:^|[-_/])audio(?:[-_/]|$)",
224788
- "native-audio",
224789
- "realtime",
224790
- // audio / realtime
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
- var NON_CHAT = new RegExp(NON_CHAT_PATTERNS.join("|"), "i");
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(resolve, reject) {
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
- resolve(Buffer.concat(accum, accumBytes));
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(resolve, reject) {
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
- resolve(fetch3(new Request3(locationURL, requestOpts)));
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
- resolve(response);
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
- resolve(response);
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
- resolve(response);
226565
+ resolve2(response);
226575
226566
  });
226576
226567
  raw.on("end", function() {
226577
226568
  if (!response) {
226578
226569
  response = new Response3(body, response_options);
226579
- resolve(response);
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
- resolve(response);
226578
+ resolve2(response);
226588
226579
  return;
226589
226580
  }
226590
226581
  response = new Response3(body, response_options);
226591
- resolve(response);
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((resolve) => {
227633
- resolve(null);
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((resolve) => setTimeout(resolve, ms2));
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((resolve, reject) => {
228640
- __classPrivateFieldSet8(this, _EventStream_resolveConnectedPromise, resolve, "f");
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((resolve, reject) => {
228644
- __classPrivateFieldSet8(this, _EventStream_resolveEndPromise, resolve, "f");
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((resolve, reject) => {
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, resolve);
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((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
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((resolve, reject) => readQueue.push({ resolve, reject })).then((chunk2) => chunk2 ? { value: chunk2, done: false } : { value: void 0, done: true });
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((resolve, reject) => readQueue.push({ resolve, reject })).then((event2) => event2 ? { value: event2, done: false } : { value: void 0, done: true });
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(resolve, reject) {
238389
- v6 = o3[n8](v6), settle(resolve, reject, v6.done, v6.value);
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(resolve, reject, d2, v6) {
238384
+ function settle(resolve2, reject, d2, v6) {
238394
238385
  Promise.resolve(v6).then(function(v7) {
238395
- resolve({ value: v7, done: d2 });
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((resolve) => {
244839
- onopenResolve = resolve;
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((resolve) => {
245080
- onopenResolve = resolve;
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((resolve) => setTimeout(resolve, ms2));
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((resolve) => {
248994
- resolve(null);
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: tool.inputSchema
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((resolve, reject) => {
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
- resolve(nodeHttpFetch(nextUrl, nextInit, redirectCount + 1));
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
- resolve(new Response(stream2, {
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((resolve) => setTimeout(resolve, waitMs));
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((resolve, reject) => {
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
- resolve(release);
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;
@@ -253768,6 +253882,14 @@ var BaseTier = class extends EventEmitter__default.default {
253768
253882
  this.emit("tier:status", event);
253769
253883
  }
253770
253884
  /** Record the model serving this tier; future status events carry it. */
253885
+ /**
253886
+ * The model actually serving this tier ("provider:id"), once one has been
253887
+ * chosen. The run breaker reads it to attribute a failure to a model rather
253888
+ * than to the subtask that happened to hit it.
253889
+ */
253890
+ getServingModel() {
253891
+ return this.servingModel;
253892
+ }
253771
253893
  setServingModel(model) {
253772
253894
  this.servingModel = model || void 0;
253773
253895
  }
@@ -254399,8 +254521,11 @@ Now execute your subtask using this context where relevant.`
254399
254521
  const result = await this.runAgentLoop(systemPrompt, this.tools);
254400
254522
  output = result.output;
254401
254523
  toolCalls = result.toolCalls;
254402
- this.sendStatusUpdate({ progressPct: 65, currentAction: "Verifying required artifacts", status: "IN_PROGRESS" });
254403
- const artifactCheck = await this.verifyArtifacts(assignment);
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: [] };
254404
254529
  if (!artifactCheck.ok) {
254405
254530
  correctionAttempts = 1;
254406
254531
  issues.push(...artifactCheck.issues);
@@ -254680,11 +254805,11 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
254680
254805
  if (!wasApproved) return `Tool ${tc.name} was denied by user.`;
254681
254806
  } else {
254682
254807
  const LEGACY_APPROVAL_TIMEOUT_MS = 6e5;
254683
- const legacyDecision = await new Promise((resolve) => {
254808
+ const legacyDecision = await new Promise((resolve2) => {
254684
254809
  const eventName = `tool:approval-response:${this.id}-${tc.id}`;
254685
254810
  const timer = setTimeout(() => {
254686
254811
  this.removeAllListeners(eventName);
254687
- resolve({ approved: false });
254812
+ resolve2({ approved: false });
254688
254813
  }, LEGACY_APPROVAL_TIMEOUT_MS);
254689
254814
  timer.unref?.();
254690
254815
  this.emit("tool:approval-request", {
@@ -254697,7 +254822,7 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
254697
254822
  });
254698
254823
  this.once(eventName, (d2) => {
254699
254824
  clearTimeout(timer);
254700
- resolve(d2);
254825
+ resolve2(d2);
254701
254826
  });
254702
254827
  });
254703
254828
  if (legacyDecision.always) this.sessionApprovals.set(tc.name, legacyDecision.approved);
@@ -254717,6 +254842,9 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
254717
254842
  tierId: this.id,
254718
254843
  sessionId: this.taskId,
254719
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 } : {},
254720
254848
  saveSnapshot: async (path28, content) => {
254721
254849
  this.store?.addFileSnapshot(this.taskId, path28, content);
254722
254850
  },
@@ -254764,7 +254892,8 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
254764
254892
  const result = await this.toolRegistry.execute(altTool, tc.input, {
254765
254893
  tierId: this.id,
254766
254894
  sessionId: this.taskId,
254767
- requireApproval: false
254895
+ requireApproval: false,
254896
+ ...this.signal ? { signal: this.signal } : {}
254768
254897
  });
254769
254898
  const str2 = typeof result === "string" ? result : JSON.stringify(result);
254770
254899
  if (!str2.startsWith("Tool error:") && !str2.startsWith("Error:")) {
@@ -254786,7 +254915,8 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : "") + textToolSuffix,
254786
254915
  const result = await this.toolRegistry.execute(newToolName, tc.input, {
254787
254916
  tierId: this.id,
254788
254917
  sessionId: this.taskId,
254789
- requireApproval: false
254918
+ requireApproval: false,
254919
+ ...this.signal ? { signal: this.signal } : {}
254790
254920
  });
254791
254921
  const str2 = typeof result === "string" ? result : JSON.stringify(result);
254792
254922
  if (!str2.startsWith("Tool error:")) return `[Synthesized ${newToolName}]: ${str2}`;
@@ -255204,7 +255334,7 @@ var PeerBus = class extends EventEmitter__default.default {
255204
255334
  this.outputs.set(subtaskId, entry);
255205
255335
  this.emit("output:ready", entry);
255206
255336
  const waiting = this.waiters.get(subtaskId) ?? [];
255207
- for (const resolve of waiting) resolve(entry);
255337
+ for (const resolve2 of waiting) resolve2(entry);
255208
255338
  this.waiters.delete(subtaskId);
255209
255339
  }
255210
255340
  /**
@@ -255235,10 +255365,10 @@ var PeerBus = class extends EventEmitter__default.default {
255235
255365
  waitFor(subtaskId, timeoutMs = 12e4) {
255236
255366
  const existing = this.outputs.get(subtaskId);
255237
255367
  if (existing && !this.retryPending.has(subtaskId)) return Promise.resolve(existing);
255238
- return new Promise((resolve, reject) => {
255368
+ return new Promise((resolve2, reject) => {
255239
255369
  const resolver = (output) => {
255240
255370
  clearTimeout(timer);
255241
- resolve(output);
255371
+ resolve2(output);
255242
255372
  };
255243
255373
  const timer = setTimeout(() => {
255244
255374
  const waiting = this.waiters.get(subtaskId);
@@ -255292,10 +255422,10 @@ var PeerBus = class extends EventEmitter__default.default {
255292
255422
  */
255293
255423
  collect(timeoutMs) {
255294
255424
  const collected = [...this.broadcastLog];
255295
- return new Promise((resolve) => {
255425
+ return new Promise((resolve2) => {
255296
255426
  const timer = setTimeout(() => {
255297
255427
  off();
255298
- resolve(collected);
255428
+ resolve2(collected);
255299
255429
  }, timeoutMs);
255300
255430
  const handler = (msg) => {
255301
255431
  collected.push({ fromId: msg.fromId, payload: msg.payload, timestamp: msg.timestamp });
@@ -255309,7 +255439,7 @@ var PeerBus = class extends EventEmitter__default.default {
255309
255439
  const broadcasters = new Set(collected.map((m3) => m3.fromId));
255310
255440
  if (broadcasters.size >= this.members.size) {
255311
255441
  off();
255312
- resolve(collected);
255442
+ resolve2(collected);
255313
255443
  }
255314
255444
  };
255315
255445
  this.on("broadcast", checkComplete);
@@ -255327,7 +255457,7 @@ var PeerBus = class extends EventEmitter__default.default {
255327
255457
  return;
255328
255458
  }
255329
255459
  this.emitCoordination(tierId, `\u23F3 waiting for ${filePath} (held by ${existing.holderId})`);
255330
- return new Promise((resolve, reject) => {
255460
+ return new Promise((resolve2, reject) => {
255331
255461
  const timer = setTimeout(() => {
255332
255462
  reject(new Error(`File lock timeout for ${filePath} (held by ${existing.holderId})`));
255333
255463
  }, timeoutMs);
@@ -255335,7 +255465,7 @@ var PeerBus = class extends EventEmitter__default.default {
255335
255465
  clearTimeout(timer);
255336
255466
  this.fileLocks.set(filePath, { holderId: tierId, lockedAt: (/* @__PURE__ */ new Date()).toISOString(), waiters: [] });
255337
255467
  this.emitCoordination(tierId, `\u{1F512} locked ${filePath}`);
255338
- resolve();
255468
+ resolve2();
255339
255469
  });
255340
255470
  });
255341
255471
  }
@@ -255360,11 +255490,11 @@ var PeerBus = class extends EventEmitter__default.default {
255360
255490
  */
255361
255491
  waitForFileRelease(filePath, timeoutMs = 3e4) {
255362
255492
  if (!this.fileLocks.has(filePath)) return Promise.resolve();
255363
- return new Promise((resolve, reject) => {
255493
+ return new Promise((resolve2, reject) => {
255364
255494
  const timer = setTimeout(() => reject(new Error(`Timeout waiting for file release: ${filePath}`)), timeoutMs);
255365
255495
  this.once(`file:released:${filePath}`, () => {
255366
255496
  clearTimeout(timer);
255367
- resolve();
255497
+ resolve2();
255368
255498
  });
255369
255499
  });
255370
255500
  }
@@ -255430,13 +255560,13 @@ var PeerBus = class extends EventEmitter__default.default {
255430
255560
  this.emit(`barrier:${barrierName}`);
255431
255561
  return;
255432
255562
  }
255433
- return new Promise((resolve, reject) => {
255563
+ return new Promise((resolve2, reject) => {
255434
255564
  const timer = setTimeout(() => {
255435
255565
  reject(new Error(`Barrier timeout: ${barrierName} (${bar.arrived.size}/${bar.total} arrived)`));
255436
255566
  }, 12e4);
255437
255567
  this.once(`barrier:${barrierName}`, () => {
255438
255568
  clearTimeout(timer);
255439
- resolve();
255569
+ resolve2();
255440
255570
  });
255441
255571
  });
255442
255572
  }
@@ -255503,6 +255633,7 @@ var T2Manager = class extends BaseTier {
255503
255633
  escalations = [];
255504
255634
  peerSyncBuffer = [];
255505
255635
  store;
255636
+ runBreaker;
255506
255637
  t3PeerBus = new PeerBus();
255507
255638
  // ← T3↔T3 bus (local to this T2)
255508
255639
  t2PeerBus;
@@ -255533,6 +255664,15 @@ var T2Manager = class extends BaseTier {
255533
255664
  this.router = router;
255534
255665
  this.toolRegistry = toolRegistry;
255535
255666
  }
255667
+ /**
255668
+ * Share the run-wide circuit breaker. Every T2 in a run gets the SAME
255669
+ * instance: three sections each failing once against a dead model is the
255670
+ * same fact as one section failing three times, and a per-section breaker
255671
+ * would never see it.
255672
+ */
255673
+ setRunBreaker(breaker) {
255674
+ this.runBreaker = breaker;
255675
+ }
255536
255676
  setStore(store) {
255537
255677
  this.store = store;
255538
255678
  }
@@ -255656,7 +255796,8 @@ Guidance (must be followed): ${decision.note}`
255656
255796
  const overallStatus = this.determineStatus(t3Results);
255657
255797
  const isOk = overallStatus === "COMPLETED" || overallStatus === "PARTIAL";
255658
255798
  this.setStatus(isOk ? "COMPLETED" : "FAILED", summary);
255659
- this.sendStatusUpdate({ progressPct: 100, currentAction: "Section complete", status: "IN_PROGRESS", output: summary });
255799
+ const sectionAction = overallStatus === "COMPLETED" ? "Section complete" : overallStatus === "PARTIAL" ? "Section partially complete \u2014 some subtasks failed" : overallStatus === "ESCALATED" ? "Section escalated \u2014 needs a decision" : "Section failed \u2014 no subtask completed";
255800
+ this.sendStatusUpdate({ progressPct: 100, currentAction: sectionAction, status: "IN_PROGRESS", output: summary });
255660
255801
  const result = {
255661
255802
  sectionId: assignment.sectionId,
255662
255803
  sectionTitle: assignment.sectionTitle,
@@ -255826,6 +255967,24 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : ""),
255826
255967
  const reinforceCfg = this.router.getReinforcementsConfig?.() ?? { enabled: false, maxPerSection: 4 };
255827
255968
  let reinforcementsAdded = 0;
255828
255969
  while (remaining.size > 0) {
255970
+ if (this.runBreaker?.isOpen()) {
255971
+ const why = this.runBreaker.skipMessage();
255972
+ this.log(`Run breaker open \u2014 skipping ${remaining.size} remaining subtask(s)`);
255973
+ for (const id of remaining) {
255974
+ this.t3PeerBus.publish(this.id, id, why, "FAILED");
255975
+ resultMap.set(id, {
255976
+ subtaskId: id,
255977
+ status: "FAILED",
255978
+ output: why,
255979
+ testResults: { checksRun: [], passed: [], failed: [] },
255980
+ issues: [why],
255981
+ peerSyncsUsed: [],
255982
+ correctionAttempts: 0
255983
+ });
255984
+ }
255985
+ remaining.clear();
255986
+ break;
255987
+ }
255829
255988
  const runnableIds = [...remaining].filter((id) => (inDegree.get(id) ?? 0) === 0);
255830
255989
  if (runnableIds.length === 0) {
255831
255990
  const fallbackId = [...remaining].sort(
@@ -255928,8 +256087,32 @@ HIERARCHY CONTEXT: ${this.hierarchyContext}` : ""),
255928
256087
  remaining.delete(id);
255929
256088
  const r4 = waveResults[i4];
255930
256089
  if (r4.status === "rejected") {
255931
- this.log(`T3 worker ${id} failed: ${r4.reason instanceof Error ? r4.reason.message : String(r4.reason)} \u2014 retrying once`);
255932
256090
  const assignment = sanitizedAssignments.find((a2) => a2.subtaskId === id);
256091
+ const failedModel = workerMap.get(id)?.getServingModel();
256092
+ const tripped = this.runBreaker?.record(r4.reason, failedModel);
256093
+ if (tripped) {
256094
+ this.log(`Run breaker opened: ${tripped.failures} consecutive ${tripped.kind} failures on ${tripped.modelId} \u2014 stopping`);
256095
+ this.emit("run:breaker", tripped);
256096
+ }
256097
+ if (this.runBreaker?.isOpen()) {
256098
+ const why = this.runBreaker.skipMessage();
256099
+ this.log(`T3 worker ${id} failed and the run breaker is open \u2014 not retrying`);
256100
+ this.t3PeerBus.publish(this.id, id, why, "FAILED");
256101
+ resultMap.set(id, {
256102
+ subtaskId: id,
256103
+ status: "FAILED",
256104
+ output: why,
256105
+ testResults: { checksRun: [], passed: [], failed: [] },
256106
+ issues: [why],
256107
+ peerSyncsUsed: [],
256108
+ correctionAttempts: 0
256109
+ });
256110
+ for (const dependent of adj.get(id) ?? []) {
256111
+ inDegree.set(dependent, Math.max(0, (inDegree.get(dependent) ?? 0) - 1));
256112
+ }
256113
+ continue;
256114
+ }
256115
+ this.log(`T3 worker ${id} failed: ${r4.reason instanceof Error ? r4.reason.message : String(r4.reason)} \u2014 retrying once`);
255933
256116
  try {
255934
256117
  const retried = await this.retryT3(assignment, taskId);
255935
256118
  resultMap.set(id, retried);
@@ -256261,6 +256444,7 @@ var T1Administrator = class extends BaseTier {
256261
256444
  t2Managers = /* @__PURE__ */ new Map();
256262
256445
  escalations = [];
256263
256446
  store;
256447
+ runBreaker;
256264
256448
  t2PeerBus = new PeerBus();
256265
256449
  permissionEscalator;
256266
256450
  toolCreator;
@@ -256275,6 +256459,10 @@ var T1Administrator = class extends BaseTier {
256275
256459
  this.toolRegistry = toolRegistry;
256276
256460
  this.config = config2;
256277
256461
  }
256462
+ /** Share the run-wide circuit breaker with every section manager. */
256463
+ setRunBreaker(breaker) {
256464
+ this.runBreaker = breaker;
256465
+ }
256278
256466
  setStore(store) {
256279
256467
  this.store = store;
256280
256468
  }
@@ -256637,6 +256825,7 @@ SPEC RULES \u2014 each subtask is a self-contained spec slice (workers execute f
256637
256825
  };
256638
256826
  const managers = sections.map((section) => {
256639
256827
  const manager = new T2Manager(this.router, this.toolRegistry, this.id);
256828
+ if (this.runBreaker) manager.setRunBreaker(this.runBreaker);
256640
256829
  manager.setHierarchyContext(`You are a T2 Manager for the section "${section.sectionTitle}". You are part of a COMPLEX task overseen by T1 Administrator.`);
256641
256830
  if (this.store) {
256642
256831
  manager.setStore(this.store);
@@ -256922,8 +257111,155 @@ Reply with exactly one word: YES, NO, or UNSURE.
256922
257111
  }
256923
257112
  };
256924
257113
 
256925
- // src/tools/registry.ts
256926
- var import_ignore = __toESM(require_ignore(), 1);
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
+ // Listed so `describe()` can tell the truth about what exists, and so the
257157
+ // planner is told video is out of reach rather than left to invent a tool.
257158
+ // Veo is a long-running operation: submit, poll, then fetch bytes from a
257159
+ // signed URL. That is a different execution shape from every other entry
257160
+ // here and is not wired up — claiming otherwise would produce a tool that
257161
+ // fails at call time instead of an honest "not yet".
257162
+ modality: "video",
257163
+ provider: "gemini",
257164
+ modelId: "veo-3.1-generate-001",
257165
+ api: "gemini-predict",
257166
+ unsupported: "Veo runs as a long-running operation (submit \u2192 poll \u2192 fetch). Not wired up yet."
257167
+ }
257168
+ ];
257169
+ function capabilityCost(cap) {
257170
+ const match = findPricing(cap.modelId, cap.provider, {
257171
+ fallbackProviders: cap.provider === "gemini" ? ["vertex"] : []
257172
+ });
257173
+ const rate = match?.entry.rates?.[0];
257174
+ if (!rate) return null;
257175
+ const unitLabel = {
257176
+ per_image: "per image",
257177
+ per_second: "per second of video",
257178
+ per_character: "per character",
257179
+ per_audio_minute: "per audio minute"
257180
+ };
257181
+ const unit = unitLabel[rate.unit] ?? rate.unit;
257182
+ const amount = rate.amount;
257183
+ const shown = amount < 1e-3 ? amount.toExponential(2) : amount.toFixed(4);
257184
+ return { label: `$${shown} ${unit}`, amount, unit };
257185
+ }
257186
+ var MultimodalRegistry = class {
257187
+ /** Provider types the user has actually configured a key for. */
257188
+ available;
257189
+ constructor(availableProviders) {
257190
+ this.available = new Set(availableProviders);
257191
+ }
257192
+ /** Every capability whose provider is configured AND which Cascade can call. */
257193
+ usable(modality) {
257194
+ return CAPABILITIES.filter(
257195
+ (c4) => !c4.unsupported && this.available.has(c4.provider) && (!modality || c4.modality === modality)
257196
+ );
257197
+ }
257198
+ /** Modalities this account can actually generate right now. */
257199
+ availableModalities() {
257200
+ return [...new Set(this.usable().map((c4) => c4.modality))];
257201
+ }
257202
+ /**
257203
+ * Pick a model for a modality.
257204
+ *
257205
+ * Ranked models beat unranked ones, then higher quality, then lower unit
257206
+ * price. An explicit `preferModel` wins outright when it is usable — the user
257207
+ * naming a model is a stronger signal than any prior.
257208
+ */
257209
+ select(modality, opts = {}) {
257210
+ const pool = this.usable(modality);
257211
+ if (!pool.length) return null;
257212
+ if (opts.preferModel) {
257213
+ const wanted = pool.find((c4) => c4.modelId === opts.preferModel);
257214
+ if (wanted) {
257215
+ return { capability: wanted, cost: capabilityCost(wanted), reason: `Requested explicitly: ${wanted.modelId}.` };
257216
+ }
257217
+ }
257218
+ const scored = pool.map((c4) => ({ c: c4, cost: capabilityCost(c4) })).sort((a2, b3) => {
257219
+ const qa = a2.c.quality ?? -1;
257220
+ const qb = b3.c.quality ?? -1;
257221
+ if (qa !== qb) return qb - qa;
257222
+ const pa = a2.cost?.amount ?? Number.POSITIVE_INFINITY;
257223
+ const pb = b3.cost?.amount ?? Number.POSITIVE_INFINITY;
257224
+ return pa - pb;
257225
+ });
257226
+ const best = scored[0];
257227
+ const ranked = best.c.quality !== void 0;
257228
+ 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.";
257229
+ return { capability: best.c, cost: best.cost, reason };
257230
+ }
257231
+ /**
257232
+ * A plain-language account of what this account can and cannot generate —
257233
+ * including the things it cannot, and why. The planner sees this, so being
257234
+ * candid here is what stops it inventing a `generate_music` call.
257235
+ */
257236
+ describe() {
257237
+ const lines = [];
257238
+ const usable = this.usable();
257239
+ if (usable.length) {
257240
+ lines.push("Generation models available on your configured providers:");
257241
+ for (const modality of ["image", "speech", "transcription", "video"]) {
257242
+ const forModality = usable.filter((c4) => c4.modality === modality);
257243
+ if (!forModality.length) continue;
257244
+ const shown = forModality.map((c4) => {
257245
+ const cost = capabilityCost(c4);
257246
+ return `${c4.modelId}${cost ? ` (${cost.label})` : ""}`;
257247
+ });
257248
+ lines.push(` ${modality}: ${shown.join(", ")}`);
257249
+ }
257250
+ } else {
257251
+ lines.push("No generation models are available \u2014 none of your configured providers offers one.");
257252
+ }
257253
+ const blocked = CAPABILITIES.filter((c4) => c4.unsupported && this.available.has(c4.provider));
257254
+ for (const c4 of blocked) {
257255
+ lines.push(` ${c4.modality}: ${c4.modelId} exists on your account but is not callable. ${c4.unsupported}`);
257256
+ }
257257
+ lines.push(
257258
+ " music: no supported provider exposes a music-generation API, so Cascade cannot generate music."
257259
+ );
257260
+ return lines.join("\n");
257261
+ }
257262
+ };
256927
257263
 
256928
257264
  // src/tools/base.ts
256929
257265
  var BaseTool = class {
@@ -256943,7 +257279,449 @@ var BaseTool = class {
256943
257279
  }
256944
257280
  };
256945
257281
 
256946
- // src/tools/shell.ts
257282
+ // src/core/router/provider-errors.ts
257283
+ var SYSTEMIC = /* @__PURE__ */ new Set([
257284
+ "rate_limit",
257285
+ "quota_exhausted",
257286
+ "auth",
257287
+ "model_unavailable"
257288
+ ]);
257289
+ function isSystemicKind(kind2) {
257290
+ return SYSTEMIC.has(kind2);
257291
+ }
257292
+ function statusOf(err) {
257293
+ if (!err || typeof err !== "object") return void 0;
257294
+ const e3 = err;
257295
+ for (const key of ["status", "statusCode", "code"]) {
257296
+ const v6 = e3[key];
257297
+ if (typeof v6 === "number" && v6 >= 100 && v6 < 600) return v6;
257298
+ }
257299
+ const resp = e3["response"];
257300
+ if (resp && typeof resp["status"] === "number") return resp["status"];
257301
+ const inner = e3["error"];
257302
+ if (inner && typeof inner["code"] === "number") return inner["code"];
257303
+ return void 0;
257304
+ }
257305
+ function messageOf(err) {
257306
+ if (err instanceof Error) return err.message;
257307
+ if (typeof err === "string") return err;
257308
+ if (err && typeof err === "object") {
257309
+ const e3 = err;
257310
+ if (typeof e3["message"] === "string") return e3["message"];
257311
+ const inner = e3["error"];
257312
+ if (inner && typeof inner["message"] === "string") return inner["message"];
257313
+ try {
257314
+ return JSON.stringify(err);
257315
+ } catch {
257316
+ }
257317
+ }
257318
+ return String(err);
257319
+ }
257320
+ function classifyProviderError(err) {
257321
+ const raw = messageOf(err).trim();
257322
+ const status = statusOf(err);
257323
+ const m3 = raw.toLowerCase();
257324
+ const kind2 = (() => {
257325
+ if (status === 429) {
257326
+ return /quota|billing|credit|exceeded your current quota|insufficient/.test(m3) ? "quota_exhausted" : "rate_limit";
257327
+ }
257328
+ if (status === 401 || status === 403) return "auth";
257329
+ if (status === 404) return "model_unavailable";
257330
+ if (/rate limit|too many requests|resource_exhausted/.test(m3)) {
257331
+ return /quota|billing|credit|insufficient/.test(m3) ? "quota_exhausted" : "rate_limit";
257332
+ }
257333
+ if (/quota|billing|insufficient_quota|insufficient credit|payment required/.test(m3)) return "quota_exhausted";
257334
+ if (/api key|unauthorized|authentication|permission denied|invalid[_ ]api/.test(m3)) return "auth";
257335
+ if (/model .*(not found|does not exist|unavailable)|no such model|unknown model|not supported for/.test(m3)) {
257336
+ return "model_unavailable";
257337
+ }
257338
+ if (/context length|too many tokens|maximum context|prompt is too long|input too long/.test(m3)) return "context_length";
257339
+ if (/safety|content filter|blocked|recitation|prohibited/.test(m3)) return "content_filter";
257340
+ if (/econnreset|etimedout|enotfound|socket hang up|network|fetch failed|aborted/.test(m3)) return "network";
257341
+ return "unknown";
257342
+ })();
257343
+ return { kind: kind2, systemic: isSystemicKind(kind2), status, raw };
257344
+ }
257345
+ function describeProviderError(c4, modelId) {
257346
+ const on = modelId ? ` on ${modelId}` : "";
257347
+ const detail = c4.raw ? ` Provider said: ${c4.raw}` : "";
257348
+ switch (c4.kind) {
257349
+ case "rate_limit":
257350
+ return `Rate limit hit${on}. The provider is throttling requests \u2014 lower the number of parallel workers, or use a model with a higher requests-per-minute allowance.${detail}`;
257351
+ case "quota_exhausted":
257352
+ return `Quota or billing limit reached${on}. This will not recover on its own \u2014 check the provider's billing page, or switch this tier to a different provider.${detail}`;
257353
+ case "auth":
257354
+ return `Authentication failed${on}. The API key is missing, expired, or lacks access to this model \u2014 re-check the key in Settings > Providers.${detail}`;
257355
+ case "model_unavailable":
257356
+ return `Model unavailable${on}. The id may be wrong, retired, or not enabled for this API key \u2014 pick a different model for this tier.${detail}`;
257357
+ case "context_length":
257358
+ return `The prompt was too long${on}. Reduce the attached context, or use a model with a larger context window for this tier.${detail}`;
257359
+ case "content_filter":
257360
+ return `The provider's safety filter refused this request${on}.${detail}`;
257361
+ case "network":
257362
+ return `Network error reaching the provider${on}. This is usually transient.${detail}`;
257363
+ default:
257364
+ return `The model call failed${on}.${detail}`;
257365
+ }
257366
+ }
257367
+
257368
+ // src/core/multimodal/generate.ts
257369
+ var DEFAULT_TIMEOUT_MS = 12e4;
257370
+ async function callProvider(fn, modelId) {
257371
+ try {
257372
+ return await fn();
257373
+ } catch (err) {
257374
+ const classified = classifyProviderError(err);
257375
+ throw new Error(describeProviderError(classified, modelId));
257376
+ }
257377
+ }
257378
+ async function postJson(url2, body, headers, signal) {
257379
+ const ac = new AbortController();
257380
+ const timer = setTimeout(() => ac.abort(), DEFAULT_TIMEOUT_MS);
257381
+ const onAbort = () => ac.abort();
257382
+ signal?.addEventListener("abort", onAbort);
257383
+ try {
257384
+ const res = await fetch(url2, {
257385
+ method: "POST",
257386
+ headers: { "Content-Type": "application/json", ...headers },
257387
+ body: JSON.stringify(body),
257388
+ signal: ac.signal
257389
+ });
257390
+ if (!res.ok) {
257391
+ const text = await res.text().catch(() => "");
257392
+ throw Object.assign(new Error(text || res.statusText), { status: res.status });
257393
+ }
257394
+ return res;
257395
+ } finally {
257396
+ clearTimeout(timer);
257397
+ signal?.removeEventListener("abort", onAbort);
257398
+ }
257399
+ }
257400
+ function baseUrlFor(cfg, fallback) {
257401
+ return (cfg.baseUrl ?? fallback).replace(/\/+$/, "");
257402
+ }
257403
+ function stamp(ext) {
257404
+ return `cascade-${Date.now()}.${ext}`;
257405
+ }
257406
+ async function generateImage(cap, cfg, req, signal) {
257407
+ return callProvider(async () => {
257408
+ if (cap.api === "openai-images") {
257409
+ const url2 = `${baseUrlFor(cfg, "https://api.openai.com/v1")}/images/generations`;
257410
+ const res = await postJson(url2, {
257411
+ model: cap.modelId,
257412
+ prompt: req.prompt,
257413
+ size: req.size ?? "1024x1024",
257414
+ n: 1,
257415
+ // b64 rather than a URL: see the file header — provider URLs expire.
257416
+ response_format: "b64_json"
257417
+ }, { Authorization: `Bearer ${cfg.apiKey ?? ""}` }, signal);
257418
+ const body = await res.json();
257419
+ const first3 = body.data?.[0];
257420
+ if (!first3?.b64_json) throw new Error("Image response contained no image data.");
257421
+ return {
257422
+ data: Buffer.from(first3.b64_json, "base64"),
257423
+ mimeType: "image/png",
257424
+ filename: stamp("png"),
257425
+ modelId: cap.modelId,
257426
+ provider: cap.provider,
257427
+ ...first3.revised_prompt ? { revisedPrompt: first3.revised_prompt } : {}
257428
+ };
257429
+ }
257430
+ if (cap.api === "gemini-predict") {
257431
+ const base = baseUrlFor(cfg, "https://generativelanguage.googleapis.com/v1beta");
257432
+ const url2 = `${base}/models/${encodeURIComponent(cap.modelId)}:predict`;
257433
+ const res = await postJson(url2, {
257434
+ instances: [{ prompt: req.prompt }],
257435
+ parameters: { sampleCount: 1 }
257436
+ }, { "x-goog-api-key": cfg.apiKey ?? "" }, signal);
257437
+ const body = await res.json();
257438
+ const first3 = body.predictions?.[0];
257439
+ if (!first3?.bytesBase64Encoded) throw new Error("Image response contained no image data.");
257440
+ const mimeType = first3.mimeType ?? "image/png";
257441
+ return {
257442
+ data: Buffer.from(first3.bytesBase64Encoded, "base64"),
257443
+ mimeType,
257444
+ filename: stamp(mimeType.includes("jpeg") ? "jpg" : "png"),
257445
+ modelId: cap.modelId,
257446
+ provider: cap.provider
257447
+ };
257448
+ }
257449
+ throw new Error(`${cap.modelId} is not an image generator.`);
257450
+ }, cap.modelId);
257451
+ }
257452
+ async function generateSpeech(cap, cfg, req, signal) {
257453
+ return callProvider(async () => {
257454
+ if (cap.api !== "openai-speech") throw new Error(`${cap.modelId} is not a speech model.`);
257455
+ const format = req.format ?? "mp3";
257456
+ const url2 = `${baseUrlFor(cfg, "https://api.openai.com/v1")}/audio/speech`;
257457
+ const res = await postJson(url2, {
257458
+ model: cap.modelId,
257459
+ input: req.text,
257460
+ voice: req.voice ?? "alloy",
257461
+ response_format: format
257462
+ }, { Authorization: `Bearer ${cfg.apiKey ?? ""}` }, signal);
257463
+ const mime = {
257464
+ mp3: "audio/mpeg",
257465
+ opus: "audio/opus",
257466
+ aac: "audio/aac",
257467
+ flac: "audio/flac",
257468
+ wav: "audio/wav"
257469
+ };
257470
+ return {
257471
+ data: Buffer.from(await res.arrayBuffer()),
257472
+ mimeType: mime[format] ?? "application/octet-stream",
257473
+ filename: stamp(format),
257474
+ modelId: cap.modelId,
257475
+ provider: cap.provider
257476
+ };
257477
+ }, cap.modelId);
257478
+ }
257479
+ async function transcribeAudio(cap, cfg, req, signal) {
257480
+ return callProvider(async () => {
257481
+ if (cap.api !== "openai-transcriptions") throw new Error(`${cap.modelId} is not a transcription model.`);
257482
+ const url2 = `${baseUrlFor(cfg, "https://api.openai.com/v1")}/audio/transcriptions`;
257483
+ const form = new FormData();
257484
+ form.append("model", cap.modelId);
257485
+ if (req.language) form.append("language", req.language);
257486
+ form.append("file", new Blob([new Uint8Array(req.audio)]), req.filename);
257487
+ const ac = new AbortController();
257488
+ const timer = setTimeout(() => ac.abort(), DEFAULT_TIMEOUT_MS);
257489
+ const onAbort = () => ac.abort();
257490
+ signal?.addEventListener("abort", onAbort);
257491
+ try {
257492
+ const res = await fetch(url2, {
257493
+ method: "POST",
257494
+ headers: { Authorization: `Bearer ${cfg.apiKey ?? ""}` },
257495
+ body: form,
257496
+ signal: ac.signal
257497
+ });
257498
+ if (!res.ok) {
257499
+ const text = await res.text().catch(() => "");
257500
+ throw Object.assign(new Error(text || res.statusText), { status: res.status });
257501
+ }
257502
+ const body = await res.json();
257503
+ return { text: body.text ?? "", modelId: cap.modelId };
257504
+ } finally {
257505
+ clearTimeout(timer);
257506
+ signal?.removeEventListener("abort", onAbort);
257507
+ }
257508
+ }, cap.modelId);
257509
+ }
257510
+
257511
+ // src/tools/generate-media.ts
257512
+ function resolve(deps, modality, preferModel) {
257513
+ const selected = deps.registry.select(modality, preferModel ? { preferModel } : {});
257514
+ if (!selected) {
257515
+ return { ok: false, error: `No ${modality} model is available on your configured providers.` };
257516
+ }
257517
+ const cfg = deps.lookupProvider(selected.capability.provider);
257518
+ if (!cfg) {
257519
+ return {
257520
+ ok: false,
257521
+ error: `${selected.capability.modelId} needs the ${selected.capability.provider} provider, which is not configured.`
257522
+ };
257523
+ }
257524
+ return { ok: true, selected, cfg };
257525
+ }
257526
+ var GenerateImageTool = class extends BaseTool {
257527
+ constructor(deps) {
257528
+ super();
257529
+ this.deps = deps;
257530
+ }
257531
+ deps;
257532
+ name = "generate_image";
257533
+ 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.";
257534
+ inputSchema = {
257535
+ type: "object",
257536
+ properties: {
257537
+ prompt: { type: "string", description: "What the image should show. Be specific about subject, style and composition." },
257538
+ size: { type: "string", description: 'Pixel size, e.g. "1024x1024" (default), "1792x1024", "1024x1792".' },
257539
+ model: { type: "string", description: "Optional: force a specific image model instead of the automatic choice." }
257540
+ },
257541
+ required: ["prompt"]
257542
+ };
257543
+ async execute(input, options) {
257544
+ const prompt = String(input["prompt"] ?? "").trim();
257545
+ if (!prompt) return 'Provide a "prompt" describing the image.';
257546
+ const r4 = resolve(this.deps, "image", input["model"] ? String(input["model"]) : void 0);
257547
+ if (!r4.ok) return r4.error;
257548
+ const size = input["size"] ? String(input["size"]) : void 0;
257549
+ const asset = await generateImage(
257550
+ r4.selected.capability,
257551
+ r4.cfg,
257552
+ { prompt, ...size ? { size } : {} },
257553
+ options.signal
257554
+ );
257555
+ const location = await this.deps.sink(asset);
257556
+ return [
257557
+ `Image generated and saved to ${location}.`,
257558
+ `Model: ${asset.modelId} \u2014 ${r4.selected.reason}`,
257559
+ // DALL·E rewrites the prompt before drawing; the model needs to know what
257560
+ // was actually rendered, not what it asked for, or its description of the
257561
+ // result will not match the image.
257562
+ asset.revisedPrompt ? `The provider rewrote the prompt to: ${asset.revisedPrompt}` : ""
257563
+ ].filter(Boolean).join("\n");
257564
+ }
257565
+ };
257566
+ var GenerateSpeechTool = class extends BaseTool {
257567
+ constructor(deps) {
257568
+ super();
257569
+ this.deps = deps;
257570
+ }
257571
+ deps;
257572
+ name = "generate_speech";
257573
+ 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.";
257574
+ inputSchema = {
257575
+ type: "object",
257576
+ properties: {
257577
+ text: { type: "string", description: "The text to speak." },
257578
+ voice: { type: "string", description: "Voice id: alloy, echo, fable, onyx, nova, shimmer. Default alloy." },
257579
+ format: { type: "string", description: "Audio format: mp3 (default), opus, aac, flac, wav." },
257580
+ model: { type: "string", description: "Optional: force a specific speech model." }
257581
+ },
257582
+ required: ["text"]
257583
+ };
257584
+ async execute(input, options) {
257585
+ const text = String(input["text"] ?? "").trim();
257586
+ if (!text) return 'Provide "text" to speak.';
257587
+ const r4 = resolve(this.deps, "speech", input["model"] ? String(input["model"]) : void 0);
257588
+ if (!r4.ok) return r4.error;
257589
+ const fmt = String(input["format"] ?? "mp3");
257590
+ const allowed = ["mp3", "opus", "aac", "flac", "wav"];
257591
+ const format = allowed.includes(fmt) ? fmt : "mp3";
257592
+ const asset = await generateSpeech(
257593
+ r4.selected.capability,
257594
+ r4.cfg,
257595
+ { text, voice: input["voice"] ? String(input["voice"]) : void 0, format },
257596
+ options.signal
257597
+ );
257598
+ const location = await this.deps.sink(asset);
257599
+ return `Speech generated and saved to ${location}.
257600
+ Model: ${asset.modelId} \u2014 ${r4.selected.reason}`;
257601
+ }
257602
+ };
257603
+ var TranscribeAudioTool = class extends BaseTool {
257604
+ constructor(deps, readFile) {
257605
+ super();
257606
+ this.deps = deps;
257607
+ this.readFile = readFile;
257608
+ }
257609
+ deps;
257610
+ readFile;
257611
+ name = "transcribe_audio";
257612
+ 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.";
257613
+ inputSchema = {
257614
+ type: "object",
257615
+ properties: {
257616
+ path: { type: "string", description: "Path to the audio file to transcribe." },
257617
+ language: { type: "string", description: 'Optional ISO-639-1 language hint, e.g. "en", improves accuracy.' },
257618
+ model: { type: "string", description: "Optional: force a specific transcription model." }
257619
+ },
257620
+ required: ["path"]
257621
+ };
257622
+ async execute(input, options) {
257623
+ const filePath = String(input["path"] ?? "").trim();
257624
+ if (!filePath) return 'Provide a "path" to the audio file.';
257625
+ const r4 = resolve(this.deps, "transcription", input["model"] ? String(input["model"]) : void 0);
257626
+ if (!r4.ok) return r4.error;
257627
+ let audio;
257628
+ try {
257629
+ audio = await this.readFile(filePath);
257630
+ } catch {
257631
+ return `Could not read the audio file at ${filePath}.`;
257632
+ }
257633
+ const { text, modelId } = await transcribeAudio(
257634
+ r4.selected.capability,
257635
+ r4.cfg,
257636
+ {
257637
+ audio,
257638
+ filename: filePath.split(/[\\/]/).pop() || "audio",
257639
+ ...input["language"] ? { language: String(input["language"]) } : {}
257640
+ },
257641
+ options.signal
257642
+ );
257643
+ return text ? `Transcript (${modelId}):
257644
+
257645
+ ${text}` : `${modelId} returned an empty transcript \u2014 the file may be silent or in an unsupported format.`;
257646
+ }
257647
+ };
257648
+ function buildMediaTools(deps, readFile) {
257649
+ const tools = [];
257650
+ const modalities = new Set(deps.registry.availableModalities());
257651
+ if (modalities.has("image")) tools.push(new GenerateImageTool(deps));
257652
+ if (modalities.has("speech")) tools.push(new GenerateSpeechTool(deps));
257653
+ if (modalities.has("transcription") && readFile) tools.push(new TranscribeAudioTool(deps, readFile));
257654
+ return tools;
257655
+ }
257656
+
257657
+ // src/core/run-breaker.ts
257658
+ var DEFAULT_FAILURE_THRESHOLD = 3;
257659
+ var RunBreaker = class {
257660
+ threshold;
257661
+ /** modelId → consecutive systemic failures of the SAME kind. */
257662
+ counts = /* @__PURE__ */ new Map();
257663
+ trip = null;
257664
+ constructor(threshold = DEFAULT_FAILURE_THRESHOLD) {
257665
+ this.threshold = Math.max(1, threshold);
257666
+ }
257667
+ /**
257668
+ * Record a failed model call. Returns the trip if this failure is the one
257669
+ * that opened the breaker, otherwise null.
257670
+ *
257671
+ * A non-systemic failure RESETS the model's counter: it is evidence the model
257672
+ * is reachable and answering, which is exactly what a systemic streak claims
257673
+ * it is not.
257674
+ */
257675
+ record(err, modelId) {
257676
+ if (this.trip) return null;
257677
+ const id = modelId?.trim() || "unknown-model";
257678
+ const c4 = classifyProviderError(err);
257679
+ if (!c4.systemic) {
257680
+ this.counts.delete(id);
257681
+ return null;
257682
+ }
257683
+ const prev = this.counts.get(id);
257684
+ const n8 = prev && prev.kind === c4.kind ? prev.n + 1 : 1;
257685
+ this.counts.set(id, { kind: c4.kind, n: n8, last: c4 });
257686
+ if (n8 >= this.threshold) {
257687
+ this.trip = {
257688
+ modelId: id,
257689
+ kind: c4.kind,
257690
+ failures: n8,
257691
+ message: describeProviderError(c4, id)
257692
+ };
257693
+ return this.trip;
257694
+ }
257695
+ return null;
257696
+ }
257697
+ /** True once the run should stop launching work that would fail identically. */
257698
+ isOpen() {
257699
+ return this.trip !== null;
257700
+ }
257701
+ /** Why the breaker opened, or null while it is closed. */
257702
+ reason() {
257703
+ return this.trip;
257704
+ }
257705
+ /**
257706
+ * One line for a worker/section that never ran because the breaker was
257707
+ * already open. Says the work was skipped deliberately — not that it failed
257708
+ * on its own merits, which is what an empty FAILED status would imply.
257709
+ */
257710
+ skipMessage() {
257711
+ const t4 = this.trip;
257712
+ if (!t4) return "Skipped.";
257713
+ return `Skipped \u2014 the run stopped after ${t4.failures} consecutive failures on ${t4.modelId}. ${t4.message}`;
257714
+ }
257715
+ /** Test/diagnostic view of the per-model streaks. */
257716
+ streaks() {
257717
+ const out = {};
257718
+ for (const [k4, v6] of this.counts) out[k4] = { kind: v6.kind, n: v6.n };
257719
+ return out;
257720
+ }
257721
+ };
257722
+
257723
+ // src/tools/registry.ts
257724
+ var import_ignore = __toESM(require_ignore(), 1);
256947
257725
  var execAsync = util$1.promisify(child_process.exec);
256948
257726
  var ShellTool = class extends BaseTool {
256949
257727
  name = "shell";
@@ -284525,7 +285303,7 @@ var PDFCreateTool = class extends BaseTool {
284525
285303
  if (!fs11__namespace.default.existsSync(dir)) {
284526
285304
  fs11__namespace.default.mkdirSync(dir, { recursive: true });
284527
285305
  }
284528
- return new Promise((resolve, reject) => {
285306
+ return new Promise((resolve2, reject) => {
284529
285307
  try {
284530
285308
  const doc = new PDFDocument({ margin: 50 });
284531
285309
  const stream2 = fs11__namespace.default.createWriteStream(filePath);
@@ -284543,7 +285321,7 @@ var PDFCreateTool = class extends BaseTool {
284543
285321
  });
284544
285322
  doc.end();
284545
285323
  stream2.on("finish", () => {
284546
- resolve(`Successfully created PDF at ${filePath} (${content.length} characters)`);
285324
+ resolve2(`Successfully created PDF at ${filePath} (${content.length} characters)`);
284547
285325
  });
284548
285326
  stream2.on("error", (err) => {
284549
285327
  reject(new Error(`Failed to write PDF: ${err.message}`));
@@ -284615,7 +285393,7 @@ var CodeInterpreterTool = class extends BaseTool {
284615
285393
  const filePath = path26__namespace.default.join(tmpDir, fileName);
284616
285394
  fs11__namespace.default.writeFileSync(filePath, code, "utf-8");
284617
285395
  const execArgs = [filePath, ...args];
284618
- return new Promise((resolve) => {
285396
+ return new Promise((resolve2) => {
284619
285397
  const startMs = Date.now();
284620
285398
  child_process.execFile(cmdPrefix, execArgs, { cwd: this.workspaceRoot, timeout: 3e4 }, (error2, stdout, stderr) => {
284621
285399
  const duration3 = Date.now() - startMs;
@@ -284629,17 +285407,17 @@ var CodeInterpreterTool = class extends BaseTool {
284629
285407
  if (error2) {
284630
285408
  const timedOut = error2.killed && duration3 >= 3e4;
284631
285409
  if (timedOut) {
284632
- resolve(`Execution timed out after 30s. Consider breaking the task into smaller pieces.
285410
+ resolve2(`Execution timed out after 30s. Consider breaking the task into smaller pieces.
284633
285411
  Partial stdout: ${stdout}
284634
285412
  Stderr: ${stderr}`);
284635
285413
  } else {
284636
- resolve(`Execution failed (${duration3}ms):
285414
+ resolve2(`Execution failed (${duration3}ms):
284637
285415
  Error: ${error2.message}
284638
285416
  Stderr: ${stderr}
284639
285417
  Stdout: ${stdout}`);
284640
285418
  }
284641
285419
  } else {
284642
- resolve(`Execution successful (${duration3}ms):
285420
+ resolve2(`Execution successful (${duration3}ms):
284643
285421
  Stdout: ${stdout}
284644
285422
  Stderr: ${stderr}`);
284645
285423
  }
@@ -285293,7 +286071,7 @@ var ToolRegistry = class extends EventEmitter__default.default {
285293
286071
  */
285294
286072
  waitForTool(toolName, timeoutMs = 6e4) {
285295
286073
  if (this.tools.has(toolName)) return Promise.resolve();
285296
- return new Promise((resolve, reject) => {
286074
+ return new Promise((resolve2, reject) => {
285297
286075
  const timer = setTimeout(() => {
285298
286076
  this.off("tool:added", handler);
285299
286077
  reject(new Error(`Timeout waiting for tool: ${toolName}`));
@@ -285302,7 +286080,7 @@ var ToolRegistry = class extends EventEmitter__default.default {
285302
286080
  if (name === toolName) {
285303
286081
  clearTimeout(timer);
285304
286082
  this.off("tool:added", handler);
285305
- resolve();
286083
+ resolve2();
285306
286084
  }
285307
286085
  };
285308
286086
  this.on("tool:added", handler);
@@ -289553,7 +290331,7 @@ __export(util_exports, {
289553
290331
  getParsedType: () => getParsedType2,
289554
290332
  getSizableOrigin: () => getSizableOrigin,
289555
290333
  isObject: () => isObject2,
289556
- isPlainObject: () => isPlainObject3,
290334
+ isPlainObject: () => isPlainObject4,
289557
290335
  issue: () => issue,
289558
290336
  joinValues: () => joinValues,
289559
290337
  jsonStringifyReplacer: () => jsonStringifyReplacer,
@@ -289697,7 +290475,7 @@ var allowsEval = cached(() => {
289697
290475
  return false;
289698
290476
  }
289699
290477
  });
289700
- function isPlainObject3(o3) {
290478
+ function isPlainObject4(o3) {
289701
290479
  if (isObject2(o3) === false)
289702
290480
  return false;
289703
290481
  const ctor = o3.constructor;
@@ -289882,7 +290660,7 @@ function omit(schema, mask) {
289882
290660
  });
289883
290661
  }
289884
290662
  function extend(schema, shape) {
289885
- if (!isPlainObject3(shape)) {
290663
+ if (!isPlainObject4(shape)) {
289886
290664
  throw new Error("Invalid input to extend: expected a plain object");
289887
290665
  }
289888
290666
  const def = {
@@ -291531,7 +292309,7 @@ function mergeValues2(a2, b3) {
291531
292309
  if (a2 instanceof Date && b3 instanceof Date && +a2 === +b3) {
291532
292310
  return { valid: true, data: a2 };
291533
292311
  }
291534
- if (isPlainObject3(a2) && isPlainObject3(b3)) {
292312
+ if (isPlainObject4(a2) && isPlainObject4(b3)) {
291535
292313
  const bKeys = Object.keys(b3);
291536
292314
  const sharedKeys = Object.keys(a2).filter((key) => bKeys.indexOf(key) !== -1);
291537
292315
  const newObj = { ...a2, ...b3 };
@@ -291588,7 +292366,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
291588
292366
  $ZodType.init(inst, def);
291589
292367
  inst._zod.parse = (payload, ctx) => {
291590
292368
  const input = payload.value;
291591
- if (!isPlainObject3(input)) {
292369
+ if (!isPlainObject4(input)) {
291592
292370
  payload.issues.push({
291593
292371
  expected: "record",
291594
292372
  code: "invalid_type",
@@ -295458,7 +296236,7 @@ var Protocol = class {
295458
296236
  return;
295459
296237
  }
295460
296238
  const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
295461
- await new Promise((resolve) => setTimeout(resolve, pollInterval));
296239
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
295462
296240
  options?.signal?.throwIfAborted();
295463
296241
  }
295464
296242
  } catch (error2) {
@@ -295475,7 +296253,7 @@ var Protocol = class {
295475
296253
  */
295476
296254
  request(request, resultSchema, options) {
295477
296255
  const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
295478
- return new Promise((resolve, reject) => {
296256
+ return new Promise((resolve2, reject) => {
295479
296257
  const earlyReject = (error2) => {
295480
296258
  reject(error2);
295481
296259
  };
@@ -295553,7 +296331,7 @@ var Protocol = class {
295553
296331
  if (!parseResult.success) {
295554
296332
  reject(parseResult.error);
295555
296333
  } else {
295556
- resolve(parseResult.data);
296334
+ resolve2(parseResult.data);
295557
296335
  }
295558
296336
  } catch (error2) {
295559
296337
  reject(error2);
@@ -295814,12 +296592,12 @@ var Protocol = class {
295814
296592
  }
295815
296593
  } catch {
295816
296594
  }
295817
- return new Promise((resolve, reject) => {
296595
+ return new Promise((resolve2, reject) => {
295818
296596
  if (signal.aborted) {
295819
296597
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
295820
296598
  return;
295821
296599
  }
295822
- const timeoutId = setTimeout(resolve, interval);
296600
+ const timeoutId = setTimeout(resolve2, interval);
295823
296601
  signal.addEventListener("abort", () => {
295824
296602
  clearTimeout(timeoutId);
295825
296603
  reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
@@ -295892,7 +296670,7 @@ var Protocol = class {
295892
296670
  };
295893
296671
  }
295894
296672
  };
295895
- function isPlainObject4(value) {
296673
+ function isPlainObject5(value) {
295896
296674
  return value !== null && typeof value === "object" && !Array.isArray(value);
295897
296675
  }
295898
296676
  function mergeCapabilities(base, additional) {
@@ -295903,7 +296681,7 @@ function mergeCapabilities(base, additional) {
295903
296681
  if (addValue === void 0)
295904
296682
  continue;
295905
296683
  const baseValue = result[k4];
295906
- if (isPlainObject4(baseValue) && isPlainObject4(addValue)) {
296684
+ if (isPlainObject5(baseValue) && isPlainObject5(addValue)) {
295907
296685
  result[k4] = { ...baseValue, ...addValue };
295908
296686
  } else {
295909
296687
  result[k4] = addValue;
@@ -296752,7 +297530,7 @@ var StdioClientTransport = class {
296752
297530
  if (this._process) {
296753
297531
  throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");
296754
297532
  }
296755
- return new Promise((resolve, reject) => {
297533
+ return new Promise((resolve2, reject) => {
296756
297534
  this._process = (0, import_cross_spawn.default)(this._serverParams.command, this._serverParams.args ?? [], {
296757
297535
  // merge default env with server env because mcp server needs some env vars
296758
297536
  env: {
@@ -296769,7 +297547,7 @@ var StdioClientTransport = class {
296769
297547
  this.onerror?.(error2);
296770
297548
  });
296771
297549
  this._process.on("spawn", () => {
296772
- resolve();
297550
+ resolve2();
296773
297551
  });
296774
297552
  this._process.on("close", (_code) => {
296775
297553
  this._process = void 0;
@@ -296828,22 +297606,22 @@ var StdioClientTransport = class {
296828
297606
  if (this._process) {
296829
297607
  const processToClose = this._process;
296830
297608
  this._process = void 0;
296831
- const closePromise = new Promise((resolve) => {
297609
+ const closePromise = new Promise((resolve2) => {
296832
297610
  processToClose.once("close", () => {
296833
- resolve();
297611
+ resolve2();
296834
297612
  });
296835
297613
  });
296836
297614
  try {
296837
297615
  processToClose.stdin?.end();
296838
297616
  } catch {
296839
297617
  }
296840
- await Promise.race([closePromise, new Promise((resolve) => setTimeout(resolve, 2e3).unref())]);
297618
+ await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
296841
297619
  if (processToClose.exitCode === null) {
296842
297620
  try {
296843
297621
  processToClose.kill("SIGTERM");
296844
297622
  } catch {
296845
297623
  }
296846
- await Promise.race([closePromise, new Promise((resolve) => setTimeout(resolve, 2e3).unref())]);
297624
+ await Promise.race([closePromise, new Promise((resolve2) => setTimeout(resolve2, 2e3).unref())]);
296847
297625
  }
296848
297626
  if (processToClose.exitCode === null) {
296849
297627
  try {
@@ -296855,15 +297633,15 @@ var StdioClientTransport = class {
296855
297633
  this._readBuffer.clear();
296856
297634
  }
296857
297635
  send(message) {
296858
- return new Promise((resolve) => {
297636
+ return new Promise((resolve2) => {
296859
297637
  if (!this._process?.stdin) {
296860
297638
  throw new Error("Not connected");
296861
297639
  }
296862
297640
  const json = serializeMessage(message);
296863
297641
  if (this._process.stdin.write(json)) {
296864
- resolve();
297642
+ resolve2();
296865
297643
  } else {
296866
- this._process.stdin.once("drain", resolve);
297644
+ this._process.stdin.once("drain", resolve2);
296867
297645
  }
296868
297646
  });
296869
297647
  }
@@ -298691,7 +299469,7 @@ var SSEClientTransport = class {
298691
299469
  }
298692
299470
  _startOrAuth() {
298693
299471
  const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
298694
- return new Promise((resolve, reject) => {
299472
+ return new Promise((resolve2, reject) => {
298695
299473
  this._eventSource = new EventSource(this._url.href, {
298696
299474
  ...this._eventSourceInit,
298697
299475
  fetch: async (url2, init2) => {
@@ -298712,7 +299490,7 @@ var SSEClientTransport = class {
298712
299490
  this._abortController = new AbortController();
298713
299491
  this._eventSource.onerror = (event) => {
298714
299492
  if (event.code === 401 && this._authProvider) {
298715
- this._authThenStart().then(resolve, reject);
299493
+ this._authThenStart().then(resolve2, reject);
298716
299494
  return;
298717
299495
  }
298718
299496
  const error2 = new SseError(event.code, event.message, event);
@@ -298734,7 +299512,7 @@ var SSEClientTransport = class {
298734
299512
  void this.close();
298735
299513
  return;
298736
299514
  }
298737
- resolve();
299515
+ resolve2();
298738
299516
  });
298739
299517
  this._eventSource.onmessage = (event) => {
298740
299518
  const messageEvent = event;
@@ -299380,20 +300158,20 @@ var PermissionEscalator = class extends EventEmitter__default.default {
299380
300158
  resolver(decision);
299381
300159
  }
299382
300160
  waitForUserDecision(req) {
299383
- return new Promise((resolve) => {
300161
+ return new Promise((resolve2) => {
299384
300162
  let timer;
299385
300163
  const wrappedResolver = (decision) => {
299386
300164
  if (timer) clearTimeout(timer);
299387
300165
  if (decision.always) {
299388
300166
  this.taskWideCache.set(req.toolName, decision.approved);
299389
300167
  }
299390
- resolve(decision);
300168
+ resolve2(decision);
299391
300169
  };
299392
300170
  this.pendingUserDecisions.set(req.id, wrappedResolver);
299393
300171
  if (this.approvalTimeoutMs > 0 && Number.isFinite(this.approvalTimeoutMs)) {
299394
300172
  timer = setTimeout(() => {
299395
300173
  if (this.pendingUserDecisions.delete(req.id)) {
299396
- resolve({
300174
+ resolve2({
299397
300175
  requestId: req.id,
299398
300176
  approved: false,
299399
300177
  decidedBy: "USER",
@@ -299562,6 +300340,14 @@ var BudgetConfigSchema = external_exports.object({
299562
300340
  maxTokensPerRun: external_exports.number().int().positive().default(2e5),
299563
300341
  /** Optional hard per-task cost ceiling (USD). Unset = only the token cap applies. */
299564
300342
  maxCostPerRunUsd: external_exports.number().positive().optional(),
300343
+ /**
300344
+ * Consecutive systemic failures against ONE model before the run stops
300345
+ * launching work that would fail the same way (dead key, wrong model id,
300346
+ * exhausted quota). Lower reacts sooner and wastes less; higher absorbs a
300347
+ * longer transient before giving up. Only failures that will certainly repeat
300348
+ * are counted — see core/run-breaker.ts.
300349
+ */
300350
+ failureThreshold: external_exports.number().int().min(1).max(20).default(3),
299565
300351
  warnAtPct: external_exports.number().default(80)
299566
300352
  });
299567
300353
  var WorkspaceConfigSchema = external_exports.object({
@@ -299849,6 +300635,23 @@ var noopTelemetry = {
299849
300635
  }
299850
300636
  };
299851
300637
 
300638
+ // src/core/router/feedback-prior.ts
300639
+ var MAX_FEEDBACK_ADJUSTMENT = 0.05;
300640
+ var PRIOR_STRENGTH = 10;
300641
+ function feedbackAdjustment(counts) {
300642
+ const good = Math.max(0, Math.floor(counts.good));
300643
+ const bad = Math.max(0, Math.floor(counts.bad));
300644
+ const n8 = good + bad;
300645
+ if (n8 === 0) return 0;
300646
+ const half = PRIOR_STRENGTH / 2;
300647
+ const shrunk = (good + half) / (n8 + PRIOR_STRENGTH);
300648
+ return (shrunk - 0.5) * 2 * MAX_FEEDBACK_ADJUSTMENT;
300649
+ }
300650
+ function applyFeedback(score01, counts) {
300651
+ const adjusted = score01 + feedbackAdjustment(counts);
300652
+ return Math.max(0, Math.min(1, adjusted));
300653
+ }
300654
+
299852
300655
  // src/core/router/task-analyzer.ts
299853
300656
  var CODE_SIGNALS = [
299854
300657
  /\b(?:function|class|interface|async|await|import|export|const|let|var|def|return|if|else|for|while|try|catch)\b/,
@@ -299923,6 +300726,8 @@ var TASK_TYPE_TAGS = {
299923
300726
  };
299924
300727
  var TaskAnalyzer = class {
299925
300728
  tracker;
300729
+ /** Per-model thumbs counts, when the host collects them. */
300730
+ feedback;
299926
300731
  bias;
299927
300732
  lastProfile = null;
299928
300733
  lastSelectedModels = /* @__PURE__ */ new Map();
@@ -299930,6 +300735,14 @@ var TaskAnalyzer = class {
299930
300735
  this.tracker = tracker;
299931
300736
  this.bias = bias;
299932
300737
  }
300738
+ /**
300739
+ * Supply per-model rating counts. Optional by design: a host that collects no
300740
+ * feedback (the CLI, a fresh install) scores exactly as it did before, since
300741
+ * feedbackAdjustment returns 0 for an empty record.
300742
+ */
300743
+ setFeedbackSource(source) {
300744
+ this.feedback = source;
300745
+ }
299933
300746
  setTracker(tracker) {
299934
300747
  this.tracker = tracker;
299935
300748
  }
@@ -300013,7 +300826,10 @@ var TaskAnalyzer = class {
300013
300826
  const perf = this.tracker?.performanceScore(model.id, profile.type) ?? 0.5;
300014
300827
  const costEff = this.costEfficiency(model, profile.complexity);
300015
300828
  const match = this.taskMatchScore(model, profile);
300016
- const benchmark = 0.3 + 0.7 * benchmarkScore01(model, profile.type);
300829
+ const rated = this.feedback?.(model.id);
300830
+ const publicScore = benchmarkScore01(model, profile.type);
300831
+ const adjusted = rated ? applyFeedback(publicScore, rated) : publicScore;
300832
+ const benchmark = 0.3 + 0.7 * adjusted;
300017
300833
  switch (this.bias) {
300018
300834
  case "quality":
300019
300835
  return perf * match * benchmark ** 2 * (0.85 + 0.15 * costEff);
@@ -300415,10 +301231,10 @@ var DynamicTool = class extends BaseTool {
300415
301231
  `;
300416
301232
  const script = await isolate.compileScript(bootstrap);
300417
301233
  const runPromise = script.run(context, { timeout: timeoutMs, promise: true }).then((v6) => String(v6 ?? ""));
300418
- const timeoutPromise = new Promise((resolve) => {
301234
+ const timeoutPromise = new Promise((resolve2) => {
300419
301235
  const t4 = setTimeout(() => {
300420
301236
  dispose();
300421
- resolve(`Dynamic tool "${this.name}" timed out after ${timeoutMs}ms and was terminated.`);
301237
+ resolve2(`Dynamic tool "${this.name}" timed out after ${timeoutMs}ms and was terminated.`);
300422
301238
  }, timeoutMs + 500);
300423
301239
  t4.unref?.();
300424
301240
  });
@@ -300436,7 +301252,7 @@ var DynamicTool = class extends BaseTool {
300436
301252
  /** Spawn the worker, service its callTool/fetch bridge, enforce the kill timeout. */
300437
301253
  runInWorker(input, callTool) {
300438
301254
  const timeoutMs = Math.max(200, Number(process.env["CASCADE_DYNAMIC_TOOL_TIMEOUT_MS"]) || DYNAMIC_TOOL_TIMEOUT_MS);
300439
- return new Promise((resolve) => {
301255
+ return new Promise((resolve2) => {
300440
301256
  let settled = false;
300441
301257
  const worker = new worker_threads.Worker(HARNESS_SRC, {
300442
301258
  eval: true,
@@ -300448,7 +301264,7 @@ var DynamicTool = class extends BaseTool {
300448
301264
  settled = true;
300449
301265
  clearTimeout(timer);
300450
301266
  void worker.terminate();
300451
- resolve(value);
301267
+ resolve2(value);
300452
301268
  };
300453
301269
  const timer = setTimeout(
300454
301270
  () => finish(`Dynamic tool "${this.name}" timed out after ${timeoutMs}ms and was terminated.`),
@@ -302004,6 +302820,7 @@ ${prompt}`;
302004
302820
  var Cascade = class _Cascade extends EventEmitter__default.default {
302005
302821
  router;
302006
302822
  toolRegistry;
302823
+ multimodal;
302007
302824
  mcpClient;
302008
302825
  codeIndex;
302009
302826
  config;
@@ -302042,6 +302859,10 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
302042
302859
  }
302043
302860
  });
302044
302861
  this.toolRegistry = new ToolRegistry(this.config.tools, workspacePath);
302862
+ this.multimodal = new MultimodalRegistry(
302863
+ (this.config.providers ?? []).map((p3) => p3.type)
302864
+ );
302865
+ this.registerMediaTools(workspacePath);
302045
302866
  this.telemetry = config2.telemetry?.enabled ? new Telemetry(config2.telemetry, config2.telemetry.distinctId ?? "anonymous") : noopTelemetry;
302046
302867
  this.worldStateDB = new WorldStateDB(this.workspacePath, this.config.workspace?.debugWorldState ?? false);
302047
302868
  this.router.setWorldStateDB(this.worldStateDB);
@@ -302095,14 +302916,14 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
302095
302916
  if (this.listenerCount("mcp:approval-required") === 0) {
302096
302917
  return false;
302097
302918
  }
302098
- return await new Promise((resolve) => {
302099
- this.pendingMcpApprovals.set(server.name, resolve);
302919
+ return await new Promise((resolve2) => {
302920
+ this.pendingMcpApprovals.set(server.name, resolve2);
302100
302921
  const timeout = setTimeout(() => {
302101
- if (this.pendingMcpApprovals.delete(server.name)) resolve(false);
302922
+ if (this.pendingMcpApprovals.delete(server.name)) resolve2(false);
302102
302923
  }, 3e4);
302103
302924
  const wrap = (approved) => {
302104
302925
  clearTimeout(timeout);
302105
- resolve(approved);
302926
+ resolve2(approved);
302106
302927
  };
302107
302928
  this.pendingMcpApprovals.set(server.name, wrap);
302108
302929
  this.emit("mcp:approval-required", { server });
@@ -302176,17 +302997,17 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
302176
302997
  }
302177
302998
  const t2Count = plan.sections.length;
302178
302999
  const t3Count = plan.sections.reduce((sum, s3) => sum + (s3.t3Subtasks?.length ?? 0), 0);
302179
- return await new Promise((resolve) => {
303000
+ return await new Promise((resolve2) => {
302180
303001
  const timeout = setTimeout(() => {
302181
303002
  if (this.pendingPlanApproval) {
302182
303003
  this.pendingPlanApproval = void 0;
302183
- resolve({ approved: true });
303004
+ resolve2({ approved: true });
302184
303005
  }
302185
303006
  }, 12e4);
302186
303007
  this.pendingPlanApproval = (decision) => {
302187
303008
  clearTimeout(timeout);
302188
303009
  this.pendingPlanApproval = void 0;
302189
- resolve(decision);
303010
+ resolve2(decision);
302190
303011
  };
302191
303012
  this.emit("plan:approval-required", {
302192
303013
  taskId,
@@ -302219,17 +303040,17 @@ var Cascade = class _Cascade extends EventEmitter__default.default {
302219
303040
  }
302220
303041
  async requestContextApproval(info) {
302221
303042
  if (this.listenerCount("context:approval-required") === 0) return true;
302222
- return await new Promise((resolve) => {
303043
+ return await new Promise((resolve2) => {
302223
303044
  const timeout = setTimeout(() => {
302224
303045
  if (this.pendingContextApproval) {
302225
303046
  this.pendingContextApproval = void 0;
302226
- resolve(true);
303047
+ resolve2(true);
302227
303048
  }
302228
303049
  }, 12e4);
302229
303050
  this.pendingContextApproval = (approved) => {
302230
303051
  clearTimeout(timeout);
302231
303052
  this.pendingContextApproval = void 0;
302232
- resolve(approved);
303053
+ resolve2(approved);
302233
303054
  };
302234
303055
  this.emit("context:approval-required", info);
302235
303056
  });
@@ -302309,6 +303130,55 @@ ${input}` }],
302309
303130
  if (this.store) t1.setStore(this.store);
302310
303131
  return t1.previewPlan(prompt);
302311
303132
  }
303133
+ /**
303134
+ * Register image / speech / transcription tools for the modalities this
303135
+ * config can actually serve.
303136
+ *
303137
+ * The sink writes bytes into the workspace, because that is what a desktop or
303138
+ * CLI run wants and it keeps a generated asset indistinguishable from any
303139
+ * other file the run produced. A host with different storage (the cloud
303140
+ * server stores a file row) constructs the tools itself via buildMediaTools
303141
+ * with its own sink.
303142
+ */
303143
+ registerMediaTools(workspacePath) {
303144
+ const allowlist = this.config.tools?.enabledTools;
303145
+ const permitted = (name) => !allowlist || allowlist.includes(name);
303146
+ const tools = buildMediaTools(
303147
+ {
303148
+ registry: this.multimodal,
303149
+ lookupProvider: (provider) => (this.config.providers ?? []).find((p3) => p3.type === provider),
303150
+ sink: async (asset) => {
303151
+ const fsp = await import('fs/promises');
303152
+ const nodePath = await import('path');
303153
+ const dir = nodePath.join(workspacePath, "generated");
303154
+ await fsp.mkdir(dir, { recursive: true });
303155
+ const dest = nodePath.join(dir, asset.filename);
303156
+ await fsp.writeFile(dest, asset.data);
303157
+ return nodePath.relative(workspacePath, dest);
303158
+ }
303159
+ },
303160
+ async (p3) => {
303161
+ const fsp = await import('fs/promises');
303162
+ return fsp.readFile(p3);
303163
+ }
303164
+ );
303165
+ for (const tool of tools) {
303166
+ if (!permitted(tool.name)) continue;
303167
+ tool.setWorkspaceRoot(workspacePath);
303168
+ this.toolRegistry.register(tool);
303169
+ }
303170
+ }
303171
+ /**
303172
+ * Supply per-model thumbs-up/down counts so Auto routing can weigh how models
303173
+ * have actually performed for this user, on top of public benchmarks.
303174
+ *
303175
+ * Optional everywhere: with no source, or an empty record, scoring is
303176
+ * byte-identical to before. The adjustment is capped and sample-size shrunk —
303177
+ * see core/router/feedback-prior.ts.
303178
+ */
303179
+ setFeedbackSource(source) {
303180
+ this.router.setFeedbackSource(source);
303181
+ }
302312
303182
  /** True when a task stopped at the budget cap and can be resumed via /continue. */
302313
303183
  hasResumableRun() {
302314
303184
  return this.lastInterruptedRun != null;
@@ -302798,6 +303668,7 @@ ${prompt}` : prompt;
302798
303668
  if (toolCreator) toolCreator.setPermissionEscalator(escalator);
302799
303669
  const rootPrompt = buildContextualPrompt(options.prompt, options.conversationHistory);
302800
303670
  let finalOutput = "";
303671
+ const runBreaker = new RunBreaker(this.config.budget?.failureThreshold);
302801
303672
  let t2Results = [];
302802
303673
  let runError = null;
302803
303674
  let identityPrompt = "";
@@ -302866,6 +303737,7 @@ ${prompt}` : prompt;
302866
303737
  this.emit("tier:status", { tierId: "t3-root", status: "COMPLETED", role: "T3" });
302867
303738
  } else if (complexity === "Moderate") {
302868
303739
  const t22 = new T2Manager(this.router, this.toolRegistry, "root");
303740
+ t22.setRunBreaker(runBreaker);
302869
303741
  t22.setPresenter(true);
302870
303742
  t22.setHierarchyContext("You are the ROOT Manager for this task. There is no T1 Administrator involved in this run. You are responsible for decomposing the task and managing T3 workers directly.");
302871
303743
  if (identityPrompt) {
@@ -302926,6 +303798,7 @@ _(incomplete: ${reasons.join("; ")})_` : partial2;
302926
303798
  }
302927
303799
  } else {
302928
303800
  const t1 = new T1Administrator(this.router, this.toolRegistry, this.config);
303801
+ t1.setRunBreaker(runBreaker);
302929
303802
  t1.setPresenter(true);
302930
303803
  t1.setHierarchyContext("You are the top-level Administrator. You are responsible for the overall plan and supervising multiple T2 Managers.");
302931
303804
  if (identityPrompt) {
@@ -302950,6 +303823,20 @@ _(incomplete: ${reasons.join("; ")})_` : partial2;
302950
303823
  finalOutput = result.output;
302951
303824
  t2Results = result.t2Results;
302952
303825
  }
303826
+ const trip = runBreaker.reason();
303827
+ if (trip) {
303828
+ finalOutput = [
303829
+ `\u26A0 **Run stopped early \u2014 ${trip.modelId} was failing every request.**`,
303830
+ "",
303831
+ trip.message,
303832
+ "",
303833
+ `Cascade stopped after ${trip.failures} consecutive failures rather than retrying every remaining subtask against the same model, which would have cost more and produced the same result.`,
303834
+ finalOutput ? `
303835
+ ---
303836
+
303837
+ ${finalOutput}` : ""
303838
+ ].join("\n").trimEnd();
303839
+ }
302953
303840
  } catch (err) {
302954
303841
  if (err instanceof CascadeCancelledError || err instanceof Error && err.name === "AbortError" || options.signal?.aborted) {
302955
303842
  this.emit("run:cancelled", {
@@ -304958,12 +305845,12 @@ var promisifyStore = (passedStore) => {
304958
305845
  const legacyStore = passedStore;
304959
305846
  class PromisifiedStore {
304960
305847
  async increment(key) {
304961
- return new Promise((resolve, reject) => {
305848
+ return new Promise((resolve2, reject) => {
304962
305849
  legacyStore.incr(
304963
305850
  key,
304964
305851
  (error2, totalHits, resetTime) => {
304965
305852
  if (error2) reject(error2);
304966
- resolve({ totalHits, resetTime });
305853
+ resolve2({ totalHits, resetTime });
304967
305854
  }
304968
305855
  );
304969
305856
  });
@@ -305738,12 +306625,12 @@ var DashboardServer = class {
305738
306625
  console.warn("\u26A0 Dashboard auth is DISABLED while bound to a non-loopback interface \u2014 this allows unauthenticated remote task execution.");
305739
306626
  }
305740
306627
  }
305741
- await new Promise((resolve, reject) => {
306628
+ await new Promise((resolve2, reject) => {
305742
306629
  const onError2 = (err) => reject(err);
305743
306630
  this.httpServer.once("error", onError2);
305744
306631
  this.httpServer.listen(this.port, this.host, () => {
305745
306632
  this.httpServer.off("error", onError2);
305746
- resolve();
306633
+ resolve2();
305747
306634
  });
305748
306635
  });
305749
306636
  try {
@@ -305767,8 +306654,8 @@ var DashboardServer = class {
305767
306654
  } catch {
305768
306655
  }
305769
306656
  this.globalStore = null;
305770
- await new Promise((resolve, reject) => {
305771
- this.httpServer.close((err) => err ? reject(err) : resolve());
306657
+ await new Promise((resolve2, reject) => {
306658
+ this.httpServer.close((err) => err ? reject(err) : resolve2());
305772
306659
  });
305773
306660
  }
305774
306661
  getSocket() {
@@ -305965,8 +306852,8 @@ var DashboardServer = class {
305965
306852
  * timeout denies it.
305966
306853
  */
305967
306854
  makeApprovalCallback(sessionId) {
305968
- return (request) => new Promise((resolve) => {
305969
- this.pendingApprovals.set(request.id, { resolve, sessionId });
306855
+ return (request) => new Promise((resolve2) => {
306856
+ this.pendingApprovals.set(request.id, { resolve: resolve2, sessionId });
305970
306857
  });
305971
306858
  }
305972
306859
  /**
@@ -307278,8 +308165,8 @@ var CloudClient = class _CloudClient {
307278
308165
  }
307279
308166
  };
307280
308167
  function sleep4(ms2, signal) {
307281
- return new Promise((resolve, reject) => {
307282
- const t4 = setTimeout(resolve, ms2);
308168
+ return new Promise((resolve2, reject) => {
308169
+ const t4 = setTimeout(resolve2, ms2);
307283
308170
  signal?.addEventListener("abort", () => {
307284
308171
  clearTimeout(t4);
307285
308172
  reject(new Error("aborted"));