clisbot 0.1.54-beta.1 → 0.1.54-beta.3

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.
Files changed (2) hide show
  1. package/dist/main.js +721 -285
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -13037,10 +13037,10 @@ var require_follow_redirects = __commonJS((exports, module) => {
13037
13037
  if (++this._redirectCount > this._options.maxRedirects) {
13038
13038
  throw new TooManyRedirectsError;
13039
13039
  }
13040
- var requestHeaders;
13040
+ var requestHeaders2;
13041
13041
  var beforeRedirect = this._options.beforeRedirect;
13042
13042
  if (beforeRedirect) {
13043
- requestHeaders = Object.assign({
13043
+ requestHeaders2 = Object.assign({
13044
13044
  Host: response.req.getHeader("host")
13045
13045
  }, this._options.headers);
13046
13046
  }
@@ -13069,7 +13069,7 @@ var require_follow_redirects = __commonJS((exports, module) => {
13069
13069
  var requestDetails = {
13070
13070
  url: currentUrl,
13071
13071
  method,
13072
- headers: requestHeaders
13072
+ headers: requestHeaders2
13073
13073
  };
13074
13074
  beforeRedirect(this._options, responseDetails, requestDetails);
13075
13075
  this._sanitizeOptions(this._options);
@@ -15747,7 +15747,7 @@ var require_axios = __commonJS((exports, module) => {
15747
15747
  return new Promise(function dispatchXhrRequest(resolve, reject) {
15748
15748
  const _config = resolveConfig(config);
15749
15749
  let requestData = _config.data;
15750
- const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
15750
+ const requestHeaders2 = AxiosHeaders.from(_config.headers).normalize();
15751
15751
  let {
15752
15752
  responseType,
15753
15753
  onUploadProgress,
@@ -15824,9 +15824,9 @@ var require_axios = __commonJS((exports, module) => {
15824
15824
  reject(new AxiosError(timeoutErrorMessage, transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED, config, request));
15825
15825
  request = null;
15826
15826
  };
15827
- requestData === undefined && requestHeaders.setContentType(null);
15827
+ requestData === undefined && requestHeaders2.setContentType(null);
15828
15828
  if ("setRequestHeader" in request) {
15829
- utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
15829
+ utils$1.forEach(requestHeaders2.toJSON(), function setRequestHeader(val, key) {
15830
15830
  request.setRequestHeader(key, val);
15831
15831
  });
15832
15832
  }
@@ -15990,10 +15990,10 @@ var require_axios = __commonJS((exports, module) => {
15990
15990
  isFunction
15991
15991
  } = utils$1;
15992
15992
  var globalFetchAPI = (({
15993
- Request,
15993
+ Request: Request2,
15994
15994
  Response: Response2
15995
15995
  }) => ({
15996
- Request,
15996
+ Request: Request2,
15997
15997
  Response: Response2
15998
15998
  }))(utils$1.global);
15999
15999
  var {
@@ -16013,21 +16013,21 @@ var require_axios = __commonJS((exports, module) => {
16013
16013
  }, globalFetchAPI, env);
16014
16014
  const {
16015
16015
  fetch: envFetch,
16016
- Request,
16016
+ Request: Request2,
16017
16017
  Response: Response2
16018
16018
  } = env;
16019
16019
  const isFetchSupported = envFetch ? isFunction(envFetch) : typeof fetch === "function";
16020
- const isRequestSupported = isFunction(Request);
16020
+ const isRequestSupported = isFunction(Request2);
16021
16021
  const isResponseSupported = isFunction(Response2);
16022
16022
  if (!isFetchSupported) {
16023
16023
  return false;
16024
16024
  }
16025
16025
  const isReadableStreamSupported = isFetchSupported && isFunction(ReadableStream$1);
16026
- const encodeText = isFetchSupported && (typeof TextEncoder$1 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder$1) : async (str) => new Uint8Array(await new Request(str).arrayBuffer()));
16026
+ const encodeText = isFetchSupported && (typeof TextEncoder$1 === "function" ? ((encoder) => (str) => encoder.encode(str))(new TextEncoder$1) : async (str) => new Uint8Array(await new Request2(str).arrayBuffer()));
16027
16027
  const supportsRequestStream = isRequestSupported && isReadableStreamSupported && test(() => {
16028
16028
  let duplexAccessed = false;
16029
16029
  const body = new ReadableStream$1;
16030
- const hasContentType = new Request(platform.origin, {
16030
+ const hasContentType = new Request2(platform.origin, {
16031
16031
  body,
16032
16032
  method: "POST",
16033
16033
  get duplex() {
@@ -16061,7 +16061,7 @@ var require_axios = __commonJS((exports, module) => {
16061
16061
  return body.size;
16062
16062
  }
16063
16063
  if (utils$1.isSpecCompliantForm(body)) {
16064
- const _request = new Request(platform.origin, {
16064
+ const _request = new Request2(platform.origin, {
16065
16065
  method: "POST",
16066
16066
  body
16067
16067
  });
@@ -16106,7 +16106,7 @@ var require_axios = __commonJS((exports, module) => {
16106
16106
  let requestContentLength;
16107
16107
  try {
16108
16108
  if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
16109
- let _request = new Request(url2, {
16109
+ let _request = new Request2(url2, {
16110
16110
  method: "POST",
16111
16111
  body: data,
16112
16112
  duplex: "half"
@@ -16123,7 +16123,7 @@ var require_axios = __commonJS((exports, module) => {
16123
16123
  if (!utils$1.isString(withCredentials)) {
16124
16124
  withCredentials = withCredentials ? "include" : "omit";
16125
16125
  }
16126
- const isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
16126
+ const isCredentialsSupported = isRequestSupported && "credentials" in Request2.prototype;
16127
16127
  const resolvedOptions = {
16128
16128
  ...fetchOptions,
16129
16129
  signal: composedSignal,
@@ -16133,7 +16133,7 @@ var require_axios = __commonJS((exports, module) => {
16133
16133
  duplex: "half",
16134
16134
  credentials: isCredentialsSupported ? withCredentials : undefined
16135
16135
  };
16136
- request = isRequestSupported && new Request(url2, resolvedOptions);
16136
+ request = isRequestSupported && new Request2(url2, resolvedOptions);
16137
16137
  let response = await (isRequestSupported ? _fetch(request, fetchOptions) : _fetch(url2, resolvedOptions));
16138
16138
  const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
16139
16139
  if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
@@ -16177,10 +16177,10 @@ var require_axios = __commonJS((exports, module) => {
16177
16177
  let env = config && config.env || {};
16178
16178
  const {
16179
16179
  fetch: fetch2,
16180
- Request,
16180
+ Request: Request2,
16181
16181
  Response: Response2
16182
16182
  } = env;
16183
- const seeds = [Request, Response2, fetch2];
16183
+ const seeds = [Request2, Response2, fetch2];
16184
16184
  let len = seeds.length, i = len, seed, target, map = seedCache;
16185
16185
  while (i--) {
16186
16186
  seed = seeds[i];
@@ -20591,34 +20591,34 @@ var require_logger2 = __commonJS((exports) => {
20591
20591
  var require_safe_buffer = __commonJS((exports, module) => {
20592
20592
  /*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
20593
20593
  var buffer = __require("buffer");
20594
- var Buffer2 = buffer.Buffer;
20594
+ var Buffer3 = buffer.Buffer;
20595
20595
  function copyProps(src, dst) {
20596
20596
  for (var key in src) {
20597
20597
  dst[key] = src[key];
20598
20598
  }
20599
20599
  }
20600
- if (Buffer2.from && Buffer2.alloc && Buffer2.allocUnsafe && Buffer2.allocUnsafeSlow) {
20600
+ if (Buffer3.from && Buffer3.alloc && Buffer3.allocUnsafe && Buffer3.allocUnsafeSlow) {
20601
20601
  module.exports = buffer;
20602
20602
  } else {
20603
20603
  copyProps(buffer, exports);
20604
20604
  exports.Buffer = SafeBuffer;
20605
20605
  }
20606
20606
  function SafeBuffer(arg, encodingOrOffset, length) {
20607
- return Buffer2(arg, encodingOrOffset, length);
20607
+ return Buffer3(arg, encodingOrOffset, length);
20608
20608
  }
20609
- SafeBuffer.prototype = Object.create(Buffer2.prototype);
20610
- copyProps(Buffer2, SafeBuffer);
20609
+ SafeBuffer.prototype = Object.create(Buffer3.prototype);
20610
+ copyProps(Buffer3, SafeBuffer);
20611
20611
  SafeBuffer.from = function(arg, encodingOrOffset, length) {
20612
20612
  if (typeof arg === "number") {
20613
20613
  throw new TypeError("Argument must not be a number");
20614
20614
  }
20615
- return Buffer2(arg, encodingOrOffset, length);
20615
+ return Buffer3(arg, encodingOrOffset, length);
20616
20616
  };
20617
20617
  SafeBuffer.alloc = function(size, fill, encoding) {
20618
20618
  if (typeof size !== "number") {
20619
20619
  throw new TypeError("Argument must be a number");
20620
20620
  }
20621
- var buf = Buffer2(size);
20621
+ var buf = Buffer3(size);
20622
20622
  if (fill !== undefined) {
20623
20623
  if (typeof encoding === "string") {
20624
20624
  buf.fill(fill, encoding);
@@ -20634,7 +20634,7 @@ var require_safe_buffer = __commonJS((exports, module) => {
20634
20634
  if (typeof size !== "number") {
20635
20635
  throw new TypeError("Argument must be a number");
20636
20636
  }
20637
- return Buffer2(size);
20637
+ return Buffer3(size);
20638
20638
  };
20639
20639
  SafeBuffer.allocUnsafeSlow = function(size) {
20640
20640
  if (typeof size !== "number") {
@@ -20646,7 +20646,7 @@ var require_safe_buffer = __commonJS((exports, module) => {
20646
20646
 
20647
20647
  // node_modules/jws/lib/data-stream.js
20648
20648
  var require_data_stream = __commonJS((exports, module) => {
20649
- var Buffer2 = require_safe_buffer().Buffer;
20649
+ var Buffer3 = require_safe_buffer().Buffer;
20650
20650
  var Stream = __require("stream");
20651
20651
  var util3 = __require("util");
20652
20652
  function DataStream(data) {
@@ -20654,11 +20654,11 @@ var require_data_stream = __commonJS((exports, module) => {
20654
20654
  this.writable = true;
20655
20655
  this.readable = true;
20656
20656
  if (!data) {
20657
- this.buffer = Buffer2.alloc(0);
20657
+ this.buffer = Buffer3.alloc(0);
20658
20658
  return this;
20659
20659
  }
20660
20660
  if (typeof data.pipe === "function") {
20661
- this.buffer = Buffer2.alloc(0);
20661
+ this.buffer = Buffer3.alloc(0);
20662
20662
  data.pipe(this);
20663
20663
  return this;
20664
20664
  }
@@ -20676,7 +20676,7 @@ var require_data_stream = __commonJS((exports, module) => {
20676
20676
  }
20677
20677
  util3.inherits(DataStream, Stream);
20678
20678
  DataStream.prototype.write = function write(data) {
20679
- this.buffer = Buffer2.concat([this.buffer, Buffer2.from(data)]);
20679
+ this.buffer = Buffer3.concat([this.buffer, Buffer3.from(data)]);
20680
20680
  this.emit("data", data);
20681
20681
  };
20682
20682
  DataStream.prototype.end = function end(data) {
@@ -20713,7 +20713,7 @@ var require_param_bytes_for_alg = __commonJS((exports, module) => {
20713
20713
 
20714
20714
  // node_modules/ecdsa-sig-formatter/src/ecdsa-sig-formatter.js
20715
20715
  var require_ecdsa_sig_formatter = __commonJS((exports, module) => {
20716
- var Buffer2 = require_safe_buffer().Buffer;
20716
+ var Buffer3 = require_safe_buffer().Buffer;
20717
20717
  var getParamBytesForAlg = require_param_bytes_for_alg();
20718
20718
  var MAX_OCTET = 128;
20719
20719
  var CLASS_UNIVERSAL = 0;
@@ -20726,10 +20726,10 @@ var require_ecdsa_sig_formatter = __commonJS((exports, module) => {
20726
20726
  return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
20727
20727
  }
20728
20728
  function signatureAsBuffer(signature) {
20729
- if (Buffer2.isBuffer(signature)) {
20729
+ if (Buffer3.isBuffer(signature)) {
20730
20730
  return signature;
20731
20731
  } else if (typeof signature === "string") {
20732
- return Buffer2.from(signature, "base64");
20732
+ return Buffer3.from(signature, "base64");
20733
20733
  }
20734
20734
  throw new TypeError("ECDSA signature must be a Base64 string or a Buffer");
20735
20735
  }
@@ -20777,7 +20777,7 @@ var require_ecdsa_sig_formatter = __commonJS((exports, module) => {
20777
20777
  throw new Error('Expected to consume entire buffer, but "' + (inputLength - offset) + '" bytes remain');
20778
20778
  }
20779
20779
  var rPadding = paramBytes - rLength, sPadding = paramBytes - sLength;
20780
- var dst = Buffer2.allocUnsafe(rPadding + rLength + sPadding + sLength);
20780
+ var dst = Buffer3.allocUnsafe(rPadding + rLength + sPadding + sLength);
20781
20781
  for (offset = 0;offset < rPadding; ++offset) {
20782
20782
  dst[offset] = 0;
20783
20783
  }
@@ -20815,7 +20815,7 @@ var require_ecdsa_sig_formatter = __commonJS((exports, module) => {
20815
20815
  var sLength = paramBytes - sPadding;
20816
20816
  var rsBytes = 1 + 1 + rLength + 1 + 1 + sLength;
20817
20817
  var shortLength = rsBytes < MAX_OCTET;
20818
- var dst = Buffer2.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
20818
+ var dst = Buffer3.allocUnsafe((shortLength ? 2 : 3) + rsBytes);
20819
20819
  var offset = 0;
20820
20820
  dst[offset++] = ENCODED_TAG_SEQ;
20821
20821
  if (shortLength) {
@@ -20850,11 +20850,11 @@ var require_ecdsa_sig_formatter = __commonJS((exports, module) => {
20850
20850
 
20851
20851
  // node_modules/buffer-equal-constant-time/index.js
20852
20852
  var require_buffer_equal_constant_time = __commonJS((exports, module) => {
20853
- var Buffer2 = __require("buffer").Buffer;
20853
+ var Buffer3 = __require("buffer").Buffer;
20854
20854
  var SlowBuffer = __require("buffer").SlowBuffer;
20855
20855
  module.exports = bufferEq;
20856
20856
  function bufferEq(a, b) {
20857
- if (!Buffer2.isBuffer(a) || !Buffer2.isBuffer(b)) {
20857
+ if (!Buffer3.isBuffer(a) || !Buffer3.isBuffer(b)) {
20858
20858
  return false;
20859
20859
  }
20860
20860
  if (a.length !== b.length) {
@@ -20867,21 +20867,21 @@ var require_buffer_equal_constant_time = __commonJS((exports, module) => {
20867
20867
  return c === 0;
20868
20868
  }
20869
20869
  bufferEq.install = function() {
20870
- Buffer2.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
20870
+ Buffer3.prototype.equal = SlowBuffer.prototype.equal = function equal(that) {
20871
20871
  return bufferEq(this, that);
20872
20872
  };
20873
20873
  };
20874
- var origBufEqual = Buffer2.prototype.equal;
20874
+ var origBufEqual = Buffer3.prototype.equal;
20875
20875
  var origSlowBufEqual = SlowBuffer.prototype.equal;
20876
20876
  bufferEq.restore = function() {
20877
- Buffer2.prototype.equal = origBufEqual;
20877
+ Buffer3.prototype.equal = origBufEqual;
20878
20878
  SlowBuffer.prototype.equal = origSlowBufEqual;
20879
20879
  };
20880
20880
  });
20881
20881
 
20882
20882
  // node_modules/jwa/index.js
20883
20883
  var require_jwa = __commonJS((exports, module) => {
20884
- var Buffer2 = require_safe_buffer().Buffer;
20884
+ var Buffer3 = require_safe_buffer().Buffer;
20885
20885
  var crypto3 = __require("crypto");
20886
20886
  var formatEcdsa = require_ecdsa_sig_formatter();
20887
20887
  var util3 = __require("util");
@@ -20897,7 +20897,7 @@ var require_jwa = __commonJS((exports, module) => {
20897
20897
  MSG_INVALID_SECRET += "or a KeyObject";
20898
20898
  }
20899
20899
  function checkIsPublicKey(key) {
20900
- if (Buffer2.isBuffer(key)) {
20900
+ if (Buffer3.isBuffer(key)) {
20901
20901
  return;
20902
20902
  }
20903
20903
  if (typeof key === "string") {
@@ -20920,7 +20920,7 @@ var require_jwa = __commonJS((exports, module) => {
20920
20920
  }
20921
20921
  }
20922
20922
  function checkIsPrivateKey(key) {
20923
- if (Buffer2.isBuffer(key)) {
20923
+ if (Buffer3.isBuffer(key)) {
20924
20924
  return;
20925
20925
  }
20926
20926
  if (typeof key === "string") {
@@ -20932,7 +20932,7 @@ var require_jwa = __commonJS((exports, module) => {
20932
20932
  throw typeError(MSG_INVALID_SIGNER_KEY);
20933
20933
  }
20934
20934
  function checkIsSecretKey(key) {
20935
- if (Buffer2.isBuffer(key)) {
20935
+ if (Buffer3.isBuffer(key)) {
20936
20936
  return;
20937
20937
  }
20938
20938
  if (typeof key === "string") {
@@ -20970,7 +20970,7 @@ var require_jwa = __commonJS((exports, module) => {
20970
20970
  return new TypeError(errMsg);
20971
20971
  }
20972
20972
  function bufferOrString(obj) {
20973
- return Buffer2.isBuffer(obj) || typeof obj === "string";
20973
+ return Buffer3.isBuffer(obj) || typeof obj === "string";
20974
20974
  }
20975
20975
  function normalizeInput(thing) {
20976
20976
  if (!bufferOrString(thing))
@@ -21001,7 +21001,7 @@ var require_jwa = __commonJS((exports, module) => {
21001
21001
  function createHmacVerifier(bits) {
21002
21002
  return function verify(thing, signature, secret) {
21003
21003
  var computedSig = createHmacSigner(bits)(thing, secret);
21004
- return timingSafeEqual2(Buffer2.from(signature), Buffer2.from(computedSig));
21004
+ return timingSafeEqual2(Buffer3.from(signature), Buffer3.from(computedSig));
21005
21005
  };
21006
21006
  }
21007
21007
  function createKeySigner(bits) {
@@ -21105,11 +21105,11 @@ var require_jwa = __commonJS((exports, module) => {
21105
21105
 
21106
21106
  // node_modules/jws/lib/tostring.js
21107
21107
  var require_tostring = __commonJS((exports, module) => {
21108
- var Buffer2 = __require("buffer").Buffer;
21108
+ var Buffer3 = __require("buffer").Buffer;
21109
21109
  module.exports = function toString(obj) {
21110
21110
  if (typeof obj === "string")
21111
21111
  return obj;
21112
- if (typeof obj === "number" || Buffer2.isBuffer(obj))
21112
+ if (typeof obj === "number" || Buffer3.isBuffer(obj))
21113
21113
  return obj.toString();
21114
21114
  return JSON.stringify(obj);
21115
21115
  };
@@ -21117,14 +21117,14 @@ var require_tostring = __commonJS((exports, module) => {
21117
21117
 
21118
21118
  // node_modules/jws/lib/sign-stream.js
21119
21119
  var require_sign_stream = __commonJS((exports, module) => {
21120
- var Buffer2 = require_safe_buffer().Buffer;
21120
+ var Buffer3 = require_safe_buffer().Buffer;
21121
21121
  var DataStream = require_data_stream();
21122
21122
  var jwa = require_jwa();
21123
21123
  var Stream = __require("stream");
21124
21124
  var toString = require_tostring();
21125
21125
  var util3 = __require("util");
21126
21126
  function base64url(string, encoding) {
21127
- return Buffer2.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
21127
+ return Buffer3.from(string, encoding).toString("base64").replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
21128
21128
  }
21129
21129
  function jwsSecuredInput(header, payload, encoding) {
21130
21130
  encoding = encoding || "utf8";
@@ -21190,7 +21190,7 @@ var require_sign_stream = __commonJS((exports, module) => {
21190
21190
 
21191
21191
  // node_modules/jws/lib/verify-stream.js
21192
21192
  var require_verify_stream = __commonJS((exports, module) => {
21193
- var Buffer2 = require_safe_buffer().Buffer;
21193
+ var Buffer3 = require_safe_buffer().Buffer;
21194
21194
  var DataStream = require_data_stream();
21195
21195
  var jwa = require_jwa();
21196
21196
  var Stream = __require("stream");
@@ -21211,7 +21211,7 @@ var require_verify_stream = __commonJS((exports, module) => {
21211
21211
  }
21212
21212
  function headerFromJWS(jwsSig) {
21213
21213
  var encodedHeader = jwsSig.split(".", 1)[0];
21214
- return safeJsonParse(Buffer2.from(encodedHeader, "base64").toString("binary"));
21214
+ return safeJsonParse(Buffer3.from(encodedHeader, "base64").toString("binary"));
21215
21215
  }
21216
21216
  function securedInputFromJWS(jwsSig) {
21217
21217
  return jwsSig.split(".", 2).join(".");
@@ -21222,7 +21222,7 @@ var require_verify_stream = __commonJS((exports, module) => {
21222
21222
  function payloadFromJWS(jwsSig, encoding) {
21223
21223
  encoding = encoding || "utf8";
21224
21224
  var payload = jwsSig.split(".")[1];
21225
- return Buffer2.from(payload, "base64").toString(encoding);
21225
+ return Buffer3.from(payload, "base64").toString(encoding);
21226
21226
  }
21227
21227
  function isValidJws(string) {
21228
21228
  return JWS_REGEX.test(string) && !!headerFromJWS(string);
@@ -26005,7 +26005,7 @@ var require_http_errors = __commonJS((exports, module) => {
26005
26005
  // node_modules/safer-buffer/safer.js
26006
26006
  var require_safer = __commonJS((exports, module) => {
26007
26007
  var buffer = __require("buffer");
26008
- var Buffer2 = buffer.Buffer;
26008
+ var Buffer3 = buffer.Buffer;
26009
26009
  var safer = {};
26010
26010
  var key;
26011
26011
  for (key in buffer) {
@@ -26016,14 +26016,14 @@ var require_safer = __commonJS((exports, module) => {
26016
26016
  safer[key] = buffer[key];
26017
26017
  }
26018
26018
  var Safer = safer.Buffer = {};
26019
- for (key in Buffer2) {
26020
- if (!Buffer2.hasOwnProperty(key))
26019
+ for (key in Buffer3) {
26020
+ if (!Buffer3.hasOwnProperty(key))
26021
26021
  continue;
26022
26022
  if (key === "allocUnsafe" || key === "allocUnsafeSlow")
26023
26023
  continue;
26024
- Safer[key] = Buffer2[key];
26024
+ Safer[key] = Buffer3[key];
26025
26025
  }
26026
- safer.Buffer.prototype = Buffer2.prototype;
26026
+ safer.Buffer.prototype = Buffer3.prototype;
26027
26027
  if (!Safer.from || Safer.from === Uint8Array.from) {
26028
26028
  Safer.from = function(value, encodingOrOffset, length) {
26029
26029
  if (typeof value === "number") {
@@ -26032,7 +26032,7 @@ var require_safer = __commonJS((exports, module) => {
26032
26032
  if (value && typeof value.length === "undefined") {
26033
26033
  throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof value);
26034
26034
  }
26035
- return Buffer2(value, encodingOrOffset, length);
26035
+ return Buffer3(value, encodingOrOffset, length);
26036
26036
  };
26037
26037
  }
26038
26038
  if (!Safer.alloc) {
@@ -26043,7 +26043,7 @@ var require_safer = __commonJS((exports, module) => {
26043
26043
  if (size < 0 || size >= 2 * (1 << 30)) {
26044
26044
  throw new RangeError('The value "' + size + '" is invalid for option "size"');
26045
26045
  }
26046
- var buf = Buffer2(size);
26046
+ var buf = Buffer3(size);
26047
26047
  if (!fill || fill.length === 0) {
26048
26048
  buf.fill(0);
26049
26049
  } else if (typeof encoding === "string") {
@@ -26128,7 +26128,7 @@ var require_merge_exports = __commonJS((exports, module) => {
26128
26128
 
26129
26129
  // node_modules/iconv-lite/encodings/internal.js
26130
26130
  var require_internal = __commonJS((exports, module) => {
26131
- var Buffer2 = require_safer().Buffer;
26131
+ var Buffer3 = require_safer().Buffer;
26132
26132
  module.exports = {
26133
26133
  utf8: { type: "_internal", bomAware: true },
26134
26134
  cesu8: { type: "_internal", bomAware: true },
@@ -26150,7 +26150,7 @@ var require_internal = __commonJS((exports, module) => {
26150
26150
  } else if (this.enc === "cesu8") {
26151
26151
  this.enc = "utf8";
26152
26152
  this.encoder = InternalEncoderCesu8;
26153
- if (Buffer2.from("eda0bdedb2a9", "hex").toString() !== "\uD83D\uDCA9") {
26153
+ if (Buffer3.from("eda0bdedb2a9", "hex").toString() !== "\uD83D\uDCA9") {
26154
26154
  this.decoder = InternalDecoderCesu8;
26155
26155
  this.defaultCharUnicode = iconv.defaultCharUnicode;
26156
26156
  }
@@ -26163,8 +26163,8 @@ var require_internal = __commonJS((exports, module) => {
26163
26163
  this.decoder = new StringDecoder(codec.enc);
26164
26164
  }
26165
26165
  InternalDecoder.prototype.write = function(buf) {
26166
- if (!Buffer2.isBuffer(buf)) {
26167
- buf = Buffer2.from(buf);
26166
+ if (!Buffer3.isBuffer(buf)) {
26167
+ buf = Buffer3.from(buf);
26168
26168
  }
26169
26169
  return this.decoder.write(buf);
26170
26170
  };
@@ -26175,7 +26175,7 @@ var require_internal = __commonJS((exports, module) => {
26175
26175
  this.enc = codec.enc;
26176
26176
  }
26177
26177
  InternalEncoder.prototype.write = function(str) {
26178
- return Buffer2.from(str, this.enc);
26178
+ return Buffer3.from(str, this.enc);
26179
26179
  };
26180
26180
  InternalEncoder.prototype.end = function() {};
26181
26181
  function InternalEncoderBase64(options, codec) {
@@ -26186,14 +26186,14 @@ var require_internal = __commonJS((exports, module) => {
26186
26186
  var completeQuads = str.length - str.length % 4;
26187
26187
  this.prevStr = str.slice(completeQuads);
26188
26188
  str = str.slice(0, completeQuads);
26189
- return Buffer2.from(str, "base64");
26189
+ return Buffer3.from(str, "base64");
26190
26190
  };
26191
26191
  InternalEncoderBase64.prototype.end = function() {
26192
- return Buffer2.from(this.prevStr, "base64");
26192
+ return Buffer3.from(this.prevStr, "base64");
26193
26193
  };
26194
26194
  function InternalEncoderCesu8(options, codec) {}
26195
26195
  InternalEncoderCesu8.prototype.write = function(str) {
26196
- var buf = Buffer2.alloc(str.length * 3);
26196
+ var buf = Buffer3.alloc(str.length * 3);
26197
26197
  var bufIdx = 0;
26198
26198
  for (var i = 0;i < str.length; i++) {
26199
26199
  var charCode = str.charCodeAt(i);
@@ -26288,20 +26288,20 @@ var require_internal = __commonJS((exports, module) => {
26288
26288
  str = str.slice(0, str.length - 1);
26289
26289
  }
26290
26290
  }
26291
- return Buffer2.from(str, this.enc);
26291
+ return Buffer3.from(str, this.enc);
26292
26292
  };
26293
26293
  InternalEncoderUtf8.prototype.end = function() {
26294
26294
  if (this.highSurrogate) {
26295
26295
  var str = this.highSurrogate;
26296
26296
  this.highSurrogate = "";
26297
- return Buffer2.from(str, this.enc);
26297
+ return Buffer3.from(str, this.enc);
26298
26298
  }
26299
26299
  };
26300
26300
  });
26301
26301
 
26302
26302
  // node_modules/iconv-lite/encodings/utf32.js
26303
26303
  var require_utf32 = __commonJS((exports) => {
26304
- var Buffer2 = require_safer().Buffer;
26304
+ var Buffer3 = require_safer().Buffer;
26305
26305
  exports._utf32 = Utf32Codec;
26306
26306
  function Utf32Codec(codecOptions, iconv) {
26307
26307
  this.iconv = iconv;
@@ -26319,8 +26319,8 @@ var require_utf32 = __commonJS((exports) => {
26319
26319
  this.highSurrogate = 0;
26320
26320
  }
26321
26321
  Utf32Encoder.prototype.write = function(str) {
26322
- var src = Buffer2.from(str, "ucs2");
26323
- var dst = Buffer2.alloc(src.length * 2);
26322
+ var src = Buffer3.from(str, "ucs2");
26323
+ var dst = Buffer3.alloc(src.length * 2);
26324
26324
  var write32 = this.isLE ? dst.writeUInt32LE : dst.writeUInt32BE;
26325
26325
  var offset = 0;
26326
26326
  for (var i = 0;i < src.length; i += 2) {
@@ -26356,7 +26356,7 @@ var require_utf32 = __commonJS((exports) => {
26356
26356
  if (!this.highSurrogate) {
26357
26357
  return;
26358
26358
  }
26359
- var buf = Buffer2.alloc(4);
26359
+ var buf = Buffer3.alloc(4);
26360
26360
  if (this.isLE) {
26361
26361
  buf.writeUInt32LE(this.highSurrogate, 0);
26362
26362
  } else {
@@ -26376,7 +26376,7 @@ var require_utf32 = __commonJS((exports) => {
26376
26376
  }
26377
26377
  var i = 0;
26378
26378
  var codepoint = 0;
26379
- var dst = Buffer2.alloc(src.length + 4);
26379
+ var dst = Buffer3.alloc(src.length + 4);
26380
26380
  var offset = 0;
26381
26381
  var isLE = this.isLE;
26382
26382
  var overflow = this.overflow;
@@ -26535,7 +26535,7 @@ var require_utf32 = __commonJS((exports) => {
26535
26535
 
26536
26536
  // node_modules/iconv-lite/encodings/utf16.js
26537
26537
  var require_utf16 = __commonJS((exports) => {
26538
- var Buffer2 = require_safer().Buffer;
26538
+ var Buffer3 = require_safer().Buffer;
26539
26539
  exports.utf16be = Utf16BECodec;
26540
26540
  function Utf16BECodec() {}
26541
26541
  Utf16BECodec.prototype.encoder = Utf16BEEncoder;
@@ -26543,7 +26543,7 @@ var require_utf16 = __commonJS((exports) => {
26543
26543
  Utf16BECodec.prototype.bomAware = true;
26544
26544
  function Utf16BEEncoder() {}
26545
26545
  Utf16BEEncoder.prototype.write = function(str) {
26546
- var buf = Buffer2.from(str, "ucs2");
26546
+ var buf = Buffer3.from(str, "ucs2");
26547
26547
  for (var i = 0;i < buf.length; i += 2) {
26548
26548
  var tmp = buf[i];
26549
26549
  buf[i] = buf[i + 1];
@@ -26559,7 +26559,7 @@ var require_utf16 = __commonJS((exports) => {
26559
26559
  if (buf.length == 0) {
26560
26560
  return "";
26561
26561
  }
26562
- var buf2 = Buffer2.alloc(buf.length + 1);
26562
+ var buf2 = Buffer3.alloc(buf.length + 1);
26563
26563
  var i = 0;
26564
26564
  var j = 0;
26565
26565
  if (this.overflowByte !== -1) {
@@ -26678,7 +26678,7 @@ var require_utf16 = __commonJS((exports) => {
26678
26678
 
26679
26679
  // node_modules/iconv-lite/encodings/utf7.js
26680
26680
  var require_utf7 = __commonJS((exports) => {
26681
- var Buffer2 = require_safer().Buffer;
26681
+ var Buffer3 = require_safer().Buffer;
26682
26682
  exports.utf7 = Utf7Codec;
26683
26683
  exports.unicode11utf7 = "utf7";
26684
26684
  function Utf7Codec(codecOptions, iconv) {
@@ -26692,7 +26692,7 @@ var require_utf7 = __commonJS((exports) => {
26692
26692
  this.iconv = codec.iconv;
26693
26693
  }
26694
26694
  Utf7Encoder.prototype.write = function(str) {
26695
- return Buffer2.from(str.replace(nonDirectChars, function(chunk) {
26695
+ return Buffer3.from(str.replace(nonDirectChars, function(chunk) {
26696
26696
  return "+" + (chunk === "+" ? "" : this.iconv.encode(chunk, "utf16-be").toString("base64").replace(/=+$/, "")) + "-";
26697
26697
  }.bind(this)));
26698
26698
  };
@@ -26729,7 +26729,7 @@ var require_utf7 = __commonJS((exports) => {
26729
26729
  res += "+";
26730
26730
  } else {
26731
26731
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii");
26732
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
26732
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
26733
26733
  }
26734
26734
  if (buf[i2] != minusChar) {
26735
26735
  i2--;
@@ -26747,7 +26747,7 @@ var require_utf7 = __commonJS((exports) => {
26747
26747
  var canBeDecoded = b64str.length - b64str.length % 8;
26748
26748
  base64Accum = b64str.slice(canBeDecoded);
26749
26749
  b64str = b64str.slice(0, canBeDecoded);
26750
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
26750
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
26751
26751
  }
26752
26752
  this.inBase64 = inBase64;
26753
26753
  this.base64Accum = base64Accum;
@@ -26756,7 +26756,7 @@ var require_utf7 = __commonJS((exports) => {
26756
26756
  Utf7Decoder.prototype.end = function() {
26757
26757
  var res = "";
26758
26758
  if (this.inBase64 && this.base64Accum.length > 0) {
26759
- res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
26759
+ res = this.iconv.decode(Buffer3.from(this.base64Accum, "base64"), "utf16-be");
26760
26760
  }
26761
26761
  this.inBase64 = false;
26762
26762
  this.base64Accum = "";
@@ -26772,14 +26772,14 @@ var require_utf7 = __commonJS((exports) => {
26772
26772
  function Utf7IMAPEncoder(options, codec) {
26773
26773
  this.iconv = codec.iconv;
26774
26774
  this.inBase64 = false;
26775
- this.base64Accum = Buffer2.alloc(6);
26775
+ this.base64Accum = Buffer3.alloc(6);
26776
26776
  this.base64AccumIdx = 0;
26777
26777
  }
26778
26778
  Utf7IMAPEncoder.prototype.write = function(str) {
26779
26779
  var inBase64 = this.inBase64;
26780
26780
  var base64Accum = this.base64Accum;
26781
26781
  var base64AccumIdx = this.base64AccumIdx;
26782
- var buf = Buffer2.alloc(str.length * 5 + 10);
26782
+ var buf = Buffer3.alloc(str.length * 5 + 10);
26783
26783
  var bufIdx = 0;
26784
26784
  for (var i2 = 0;i2 < str.length; i2++) {
26785
26785
  var uChar = str.charCodeAt(i2);
@@ -26818,7 +26818,7 @@ var require_utf7 = __commonJS((exports) => {
26818
26818
  return buf.slice(0, bufIdx);
26819
26819
  };
26820
26820
  Utf7IMAPEncoder.prototype.end = function() {
26821
- var buf = Buffer2.alloc(10);
26821
+ var buf = Buffer3.alloc(10);
26822
26822
  var bufIdx = 0;
26823
26823
  if (this.inBase64) {
26824
26824
  if (this.base64AccumIdx > 0) {
@@ -26855,7 +26855,7 @@ var require_utf7 = __commonJS((exports) => {
26855
26855
  res += "&";
26856
26856
  } else {
26857
26857
  var b64str = base64Accum + this.iconv.decode(buf.slice(lastI, i2), "ascii").replace(/,/g, "/");
26858
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
26858
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
26859
26859
  }
26860
26860
  if (buf[i2] != minusChar) {
26861
26861
  i2--;
@@ -26873,7 +26873,7 @@ var require_utf7 = __commonJS((exports) => {
26873
26873
  var canBeDecoded = b64str.length - b64str.length % 8;
26874
26874
  base64Accum = b64str.slice(canBeDecoded);
26875
26875
  b64str = b64str.slice(0, canBeDecoded);
26876
- res += this.iconv.decode(Buffer2.from(b64str, "base64"), "utf16-be");
26876
+ res += this.iconv.decode(Buffer3.from(b64str, "base64"), "utf16-be");
26877
26877
  }
26878
26878
  this.inBase64 = inBase64;
26879
26879
  this.base64Accum = base64Accum;
@@ -26882,7 +26882,7 @@ var require_utf7 = __commonJS((exports) => {
26882
26882
  Utf7IMAPDecoder.prototype.end = function() {
26883
26883
  var res = "";
26884
26884
  if (this.inBase64 && this.base64Accum.length > 0) {
26885
- res = this.iconv.decode(Buffer2.from(this.base64Accum, "base64"), "utf16-be");
26885
+ res = this.iconv.decode(Buffer3.from(this.base64Accum, "base64"), "utf16-be");
26886
26886
  }
26887
26887
  this.inBase64 = false;
26888
26888
  this.base64Accum = "";
@@ -26892,7 +26892,7 @@ var require_utf7 = __commonJS((exports) => {
26892
26892
 
26893
26893
  // node_modules/iconv-lite/encodings/sbcs-codec.js
26894
26894
  var require_sbcs_codec = __commonJS((exports) => {
26895
- var Buffer2 = require_safer().Buffer;
26895
+ var Buffer3 = require_safer().Buffer;
26896
26896
  exports._sbcs = SBCSCodec;
26897
26897
  function SBCSCodec(codecOptions, iconv) {
26898
26898
  if (!codecOptions) {
@@ -26908,8 +26908,8 @@ var require_sbcs_codec = __commonJS((exports) => {
26908
26908
  }
26909
26909
  codecOptions.chars = asciiString + codecOptions.chars;
26910
26910
  }
26911
- this.decodeBuf = Buffer2.from(codecOptions.chars, "ucs2");
26912
- var encodeBuf = Buffer2.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
26911
+ this.decodeBuf = Buffer3.from(codecOptions.chars, "ucs2");
26912
+ var encodeBuf = Buffer3.alloc(65536, iconv.defaultCharSingleByte.charCodeAt(0));
26913
26913
  for (var i = 0;i < codecOptions.chars.length; i++) {
26914
26914
  encodeBuf[codecOptions.chars.charCodeAt(i)] = i;
26915
26915
  }
@@ -26921,7 +26921,7 @@ var require_sbcs_codec = __commonJS((exports) => {
26921
26921
  this.encodeBuf = codec.encodeBuf;
26922
26922
  }
26923
26923
  SBCSEncoder.prototype.write = function(str) {
26924
- var buf = Buffer2.alloc(str.length);
26924
+ var buf = Buffer3.alloc(str.length);
26925
26925
  for (var i = 0;i < str.length; i++) {
26926
26926
  buf[i] = this.encodeBuf[str.charCodeAt(i)];
26927
26927
  }
@@ -26933,7 +26933,7 @@ var require_sbcs_codec = __commonJS((exports) => {
26933
26933
  }
26934
26934
  SBCSDecoder.prototype.write = function(buf) {
26935
26935
  var decodeBuf = this.decodeBuf;
26936
- var newBuf = Buffer2.alloc(buf.length * 2);
26936
+ var newBuf = Buffer3.alloc(buf.length * 2);
26937
26937
  var idx1 = 0;
26938
26938
  var idx2 = 0;
26939
26939
  for (var i = 0;i < buf.length; i++) {
@@ -27554,7 +27554,7 @@ var require_sbcs_data_generated = __commonJS((exports, module) => {
27554
27554
 
27555
27555
  // node_modules/iconv-lite/encodings/dbcs-codec.js
27556
27556
  var require_dbcs_codec = __commonJS((exports) => {
27557
- var Buffer2 = require_safer().Buffer;
27557
+ var Buffer3 = require_safer().Buffer;
27558
27558
  exports._dbcs = DBCSCodec;
27559
27559
  var UNASSIGNED = -1;
27560
27560
  var GB18030_CODE = -2;
@@ -27793,7 +27793,7 @@ var require_dbcs_codec = __commonJS((exports) => {
27793
27793
  this.gb18030 = codec.gb18030;
27794
27794
  }
27795
27795
  DBCSEncoder.prototype.write = function(str) {
27796
- var newBuf = Buffer2.alloc(str.length * (this.gb18030 ? 4 : 3));
27796
+ var newBuf = Buffer3.alloc(str.length * (this.gb18030 ? 4 : 3));
27797
27797
  var leadSurrogate = this.leadSurrogate;
27798
27798
  var seqObj = this.seqObj;
27799
27799
  var nextChar = -1;
@@ -27897,7 +27897,7 @@ var require_dbcs_codec = __commonJS((exports) => {
27897
27897
  if (this.leadSurrogate === -1 && this.seqObj === undefined) {
27898
27898
  return;
27899
27899
  }
27900
- var newBuf = Buffer2.alloc(10);
27900
+ var newBuf = Buffer3.alloc(10);
27901
27901
  var j = 0;
27902
27902
  if (this.seqObj) {
27903
27903
  var dbcsCode = this.seqObj[DEF_CHAR];
@@ -27927,7 +27927,7 @@ var require_dbcs_codec = __commonJS((exports) => {
27927
27927
  this.gb18030 = codec.gb18030;
27928
27928
  }
27929
27929
  DBCSDecoder.prototype.write = function(buf) {
27930
- var newBuf = Buffer2.alloc(buf.length * 2);
27930
+ var newBuf = Buffer3.alloc(buf.length * 2);
27931
27931
  var nodeIdx = this.nodeIdx;
27932
27932
  var prevBytes = this.prevBytes;
27933
27933
  var prevOffset = this.prevBytes.length;
@@ -29437,7 +29437,7 @@ var require_encodings = __commonJS((exports, module) => {
29437
29437
 
29438
29438
  // node_modules/iconv-lite/lib/streams.js
29439
29439
  var require_streams = __commonJS((exports, module) => {
29440
- var Buffer2 = require_safer().Buffer;
29440
+ var Buffer3 = require_safer().Buffer;
29441
29441
  module.exports = function(streamModule) {
29442
29442
  var Transform = streamModule.Transform;
29443
29443
  function IconvLiteEncoderStream(conv, options) {
@@ -29479,7 +29479,7 @@ var require_streams = __commonJS((exports, module) => {
29479
29479
  chunks.push(chunk);
29480
29480
  });
29481
29481
  this.on("end", function() {
29482
- cb(null, Buffer2.concat(chunks));
29482
+ cb(null, Buffer3.concat(chunks));
29483
29483
  });
29484
29484
  return this;
29485
29485
  };
@@ -29493,7 +29493,7 @@ var require_streams = __commonJS((exports, module) => {
29493
29493
  constructor: { value: IconvLiteDecoderStream }
29494
29494
  });
29495
29495
  IconvLiteDecoderStream.prototype._transform = function(chunk, encoding, done) {
29496
- if (!Buffer2.isBuffer(chunk) && !(chunk instanceof Uint8Array)) {
29496
+ if (!Buffer3.isBuffer(chunk) && !(chunk instanceof Uint8Array)) {
29497
29497
  return done(new Error("Iconv decoding stream needs buffers as its input."));
29498
29498
  }
29499
29499
  try {
@@ -29535,7 +29535,7 @@ var require_streams = __commonJS((exports, module) => {
29535
29535
 
29536
29536
  // node_modules/iconv-lite/lib/index.js
29537
29537
  var require_lib = __commonJS((exports, module) => {
29538
- var Buffer2 = require_safer().Buffer;
29538
+ var Buffer3 = require_safer().Buffer;
29539
29539
  var bomHandling = require_bom_handling();
29540
29540
  var mergeModules = require_merge_exports();
29541
29541
  exports.encodings = null;
@@ -29546,7 +29546,7 @@ var require_lib = __commonJS((exports, module) => {
29546
29546
  var encoder = exports.getEncoder(encoding, options);
29547
29547
  var res = encoder.write(str);
29548
29548
  var trail = encoder.end();
29549
- return trail && trail.length > 0 ? Buffer2.concat([res, trail]) : res;
29549
+ return trail && trail.length > 0 ? Buffer3.concat([res, trail]) : res;
29550
29550
  };
29551
29551
  exports.decode = function decode(buf, encoding, options) {
29552
29552
  if (typeof buf === "string") {
@@ -29554,7 +29554,7 @@ var require_lib = __commonJS((exports, module) => {
29554
29554
  console.error("Iconv-lite warning: decode()-ing strings is deprecated. Refer to https://github.com/ashtuchkin/iconv-lite/wiki/Use-Buffers-when-decoding");
29555
29555
  exports.skipDecodeWarning = true;
29556
29556
  }
29557
- buf = Buffer2.from("" + (buf || ""), "binary");
29557
+ buf = Buffer3.from("" + (buf || ""), "binary");
29558
29558
  }
29559
29559
  var decoder = exports.getDecoder(encoding, options);
29560
29560
  var res = decoder.write(buf);
@@ -48737,7 +48737,7 @@ var require_utils3 = __commonJS((exports) => {
48737
48737
  var proxyaddr = require_proxy_addr();
48738
48738
  var qs = require_lib3();
48739
48739
  var querystring = __require("node:querystring");
48740
- var { Buffer: Buffer2 } = __require("node:buffer");
48740
+ var { Buffer: Buffer3 } = __require("node:buffer");
48741
48741
  exports.methods = METHODS.map((method) => method.toLowerCase());
48742
48742
  exports.etag = createETagGenerator({ weak: false });
48743
48743
  exports.wetag = createETagGenerator({ weak: true });
@@ -48843,7 +48843,7 @@ var require_utils3 = __commonJS((exports) => {
48843
48843
  };
48844
48844
  function createETagGenerator(options) {
48845
48845
  return function generateETag(body, encoding) {
48846
- var buf = !Buffer2.isBuffer(body) ? Buffer2.from(body, encoding) : body;
48846
+ var buf = !Buffer3.isBuffer(body) ? Buffer3.from(body, encoding) : body;
48847
48847
  return etag(buf, options);
48848
48848
  };
48849
48849
  }
@@ -51757,7 +51757,7 @@ var require_response2 = __commonJS((exports, module) => {
51757
51757
  var extname = path2.extname;
51758
51758
  var resolve = path2.resolve;
51759
51759
  var vary = require_vary();
51760
- var { Buffer: Buffer2 } = __require("node:buffer");
51760
+ var { Buffer: Buffer3 } = __require("node:buffer");
51761
51761
  var res = Object.create(http.ServerResponse.prototype);
51762
51762
  module.exports = res;
51763
51763
  res.status = function status(code) {
@@ -51821,12 +51821,12 @@ var require_response2 = __commonJS((exports, module) => {
51821
51821
  var generateETag = !this.get("ETag") && typeof etagFn === "function";
51822
51822
  var len;
51823
51823
  if (chunk !== undefined) {
51824
- if (Buffer2.isBuffer(chunk)) {
51824
+ if (Buffer3.isBuffer(chunk)) {
51825
51825
  len = chunk.length;
51826
51826
  } else if (!generateETag && chunk.length < 1000) {
51827
- len = Buffer2.byteLength(chunk, encoding);
51827
+ len = Buffer3.byteLength(chunk, encoding);
51828
51828
  } else {
51829
- chunk = Buffer2.from(chunk, encoding);
51829
+ chunk = Buffer3.from(chunk, encoding);
51830
51830
  encoding = undefined;
51831
51831
  len = chunk.length;
51832
51832
  }
@@ -52091,7 +52091,7 @@ var require_response2 = __commonJS((exports, module) => {
52091
52091
  }
52092
52092
  });
52093
52093
  this.status(status);
52094
- this.set("Content-Length", Buffer2.byteLength(body));
52094
+ this.set("Content-Length", Buffer3.byteLength(body));
52095
52095
  if (this.req.method === "HEAD") {
52096
52096
  this.end();
52097
52097
  } else {
@@ -83338,7 +83338,7 @@ import { chmod, open, readFile as readFile2, rename, unlink, writeFile as writeF
83338
83338
  import { basename, dirname as dirname2, join as join3 } from "node:path";
83339
83339
  var DEFAULT_JSON_FILE_LOCK_OPTIONS = {
83340
83340
  retries: {
83341
- retries: 10,
83341
+ retries: 20,
83342
83342
  factor: 2,
83343
83343
  minTimeout: 50,
83344
83344
  maxTimeout: 2000,
@@ -88771,6 +88771,11 @@ import { dirname as dirname6, join as join8, sep } from "node:path";
88771
88771
  // src/control/runner/runner-exit-diagnostics.ts
88772
88772
  import { unlink as unlink2 } from "node:fs/promises";
88773
88773
  import { dirname as dirname5, join as join7 } from "node:path";
88774
+ var RUNNER_EXIT_SENTINEL_PREFIX = "[clisbot] runner exited with status";
88775
+ var RUNNER_EXIT_LINGER_SECONDS = 8;
88776
+ function paneShowsRunnerExitSentinel(snapshot) {
88777
+ return snapshot.includes(RUNNER_EXIT_SENTINEL_PREFIX);
88778
+ }
88774
88779
  function shellQuote(value) {
88775
88780
  if (/^[a-zA-Z0-9_./:@=-]+$/.test(value)) {
88776
88781
  return value;
@@ -88787,6 +88792,7 @@ function getRunnerExitRecordPath(stateDir, sessionName) {
88787
88792
  return join7(stateDir, "runner-exits", `${sanitizeSessionName2(sessionName)}.json`);
88788
88793
  }
88789
88794
  function buildRunnerLaunchCommand(params) {
88795
+ const exitLingerSeconds = params.exitLingerSeconds ?? RUNNER_EXIT_LINGER_SECONDS;
88790
88796
  const runnerCommand = buildCommandString(params.command, params.args);
88791
88797
  const exitRecordPath = getRunnerExitRecordPath(params.stateDir, params.sessionName);
88792
88798
  const exitWriterScript = [
@@ -88809,6 +88815,7 @@ function buildRunnerLaunchCommand(params) {
88809
88815
  runnerCommand,
88810
88816
  "status=$?",
88811
88817
  `node -e ${shellQuote(exitWriterScript)} ${shellQuote(exitRecordPath)} ${shellQuote(params.sessionName)} "$status" ${shellQuote(runnerCommand)} || true`,
88818
+ `if [ "$status" -ne 0 ]; then echo ${shellQuote(`${RUNNER_EXIT_SENTINEL_PREFIX} `)}"$status"; sleep ${exitLingerSeconds}; fi`,
88812
88819
  'exit "$status"'
88813
88820
  ].join("; ");
88814
88821
  }
@@ -89194,7 +89201,15 @@ class SessionStore {
89194
89201
  if (!await fileExists(this.storePath)) {
89195
89202
  return {};
89196
89203
  }
89197
- const text = await readTextFile(this.storePath);
89204
+ let text;
89205
+ try {
89206
+ text = await readTextFile(this.storePath);
89207
+ } catch (error) {
89208
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
89209
+ return {};
89210
+ }
89211
+ throw error;
89212
+ }
89198
89213
  if (!text.trim()) {
89199
89214
  return {};
89200
89215
  }
@@ -92140,9 +92155,8 @@ var PASTE_CONFIRM_MAX_ATTEMPTS = 3;
92140
92155
  var PASTE_CAPTURE_REVALIDATE_POLL_INTERVAL_MS = 40;
92141
92156
  var PASTE_CAPTURE_REVALIDATE_MAX_WAIT_MS = 160;
92142
92157
  var SUBMIT_CONFIRM_POLL_INTERVAL_MS = 40;
92143
- var SUBMIT_CONFIRM_MAX_WAIT_MS = 160;
92144
- var SUBMIT_SNAPSHOT_CONFIRM_POLL_INTERVAL_MS = 40;
92145
- var SUBMIT_SNAPSHOT_CONFIRM_MAX_WAIT_MS = 320;
92158
+ var SUBMIT_CONFIRM_MAX_WAIT_MS = 600;
92159
+ var SUBMIT_ENTER_MAX_ATTEMPTS = 3;
92146
92160
  var POST_STATUS_SETTLE_POLL_INTERVAL_MS = 40;
92147
92161
  var POST_STATUS_SETTLE_QUIET_WINDOW_MS = 80;
92148
92162
  var POST_STATUS_SETTLE_MAX_WAIT_MS = 240;
@@ -92152,9 +92166,11 @@ var TMUX_SERVER_UNAVAILABLE_PATTERN = /(?:No such file or directory|error connec
92152
92166
 
92153
92167
  class TmuxBootstrapSessionLostError extends Error {
92154
92168
  sessionName;
92155
- constructor(sessionName, detail) {
92169
+ lastSnapshot;
92170
+ constructor(sessionName, detail, lastSnapshot = "") {
92156
92171
  super(`tmux bootstrap lost session "${sessionName}": ${detail}`);
92157
92172
  this.sessionName = sessionName;
92173
+ this.lastSnapshot = lastSnapshot;
92158
92174
  this.name = "TmuxBootstrapSessionLostError";
92159
92175
  }
92160
92176
  }
@@ -92170,7 +92186,11 @@ class TmuxPasteUnconfirmedError extends Error {
92170
92186
 
92171
92187
  class TmuxSubmitUnconfirmedError extends Error {
92172
92188
  constructor() {
92173
- super("tmux submit was not confirmed after Enter. The pane state did not change, so clisbot did not treat the prompt as truthfully submitted.");
92189
+ super([
92190
+ "tmux submit was not confirmed after Enter: the pane did not change, so clisbot does not treat the prompt as truthfully submitted.",
92191
+ "The runner may be busy, redrawing slowly, or showing a blocking prompt.",
92192
+ "Check the live pane with `clisbot watch --latest --lines 100`; if your text is sitting unsubmitted there, send /nudge, otherwise resend the message."
92193
+ ].join(" "));
92174
92194
  this.name = "TmuxSubmitUnconfirmedError";
92175
92195
  }
92176
92196
  }
@@ -92207,36 +92227,97 @@ async function submitTmuxSessionInput(params) {
92207
92227
  }
92208
92228
  const preSubmitState = pasteDelivery.state;
92209
92229
  const preSubmitSnapshot = normalizePaneText(await params.tmux.capturePane(params.sessionName, captureLines));
92210
- await params.tmux.sendKey(params.sessionName, "Enter");
92211
- const submitted = await waitForPaneSubmitConfirmation({
92212
- tmux: params.tmux,
92213
- sessionName: params.sessionName,
92214
- baseline: preSubmitState,
92215
- baselineSnapshot: preSubmitSnapshot,
92216
- captureLines
92217
- });
92218
- if (submitted.confirmed) {
92219
- return { submittedSnapshot: preSubmitSnapshot };
92220
- }
92221
- logLatencyDebug("tmux-submit-enter-retry", params.timingContext, {
92222
- sessionName: params.sessionName
92223
- });
92224
- await params.tmux.sendKey(params.sessionName, "Enter");
92225
- const retrySubmitted = await waitForPaneSubmitConfirmation({
92226
- tmux: params.tmux,
92227
- sessionName: params.sessionName,
92228
- baseline: preSubmitState,
92229
- baselineSnapshot: preSubmitSnapshot,
92230
- captureLines
92231
- });
92232
- if (retrySubmitted.confirmed) {
92233
- return { submittedSnapshot: preSubmitSnapshot };
92230
+ for (let attempt = 1;attempt <= SUBMIT_ENTER_MAX_ATTEMPTS; attempt += 1) {
92231
+ if (attempt > 1) {
92232
+ logLatencyDebug("tmux-submit-enter-retry", params.timingContext, {
92233
+ sessionName: params.sessionName,
92234
+ attempt
92235
+ });
92236
+ }
92237
+ await params.tmux.sendKey(params.sessionName, "Enter");
92238
+ const outcome = await waitForSubmitSettled({
92239
+ tmux: params.tmux,
92240
+ sessionName: params.sessionName,
92241
+ baseline: preSubmitState,
92242
+ baselineSnapshot: preSubmitSnapshot,
92243
+ text: params.text,
92244
+ captureLines
92245
+ });
92246
+ if (outcome === "submitted") {
92247
+ return { submittedSnapshot: preSubmitSnapshot };
92248
+ }
92234
92249
  }
92235
92250
  logLatencyDebug("tmux-submit-unconfirmed", params.timingContext, {
92236
92251
  sessionName: params.sessionName
92237
92252
  });
92238
92253
  throw new TmuxSubmitUnconfirmedError;
92239
92254
  }
92255
+ async function waitForSubmitSettled(params) {
92256
+ const deadline = Date.now() + SUBMIT_CONFIRM_MAX_WAIT_MS;
92257
+ let sawChange = false;
92258
+ while (true) {
92259
+ let changed = sawChange;
92260
+ if (!changed) {
92261
+ const state = await params.tmux.getPaneState(params.sessionName);
92262
+ changed = hasPaneStateChanged(params.baseline, state);
92263
+ }
92264
+ const snapshot = normalizePaneText(await params.tmux.capturePane(params.sessionName, params.captureLines));
92265
+ if (!changed) {
92266
+ changed = snapshot !== params.baselineSnapshot;
92267
+ }
92268
+ if (changed) {
92269
+ sawChange = true;
92270
+ if (!paneShowsPendingComposerText(snapshot, params.text)) {
92271
+ return "submitted";
92272
+ }
92273
+ }
92274
+ const remainingMs = deadline - Date.now();
92275
+ if (remainingMs <= 0) {
92276
+ return sawChange ? "pending-input" : "unchanged";
92277
+ }
92278
+ await sleep(Math.min(SUBMIT_CONFIRM_POLL_INTERVAL_MS, remainingMs));
92279
+ }
92280
+ }
92281
+ var COMPOSER_HINT_LINE_PATTERN = /^\?\s+for shortcuts|^Type your message or @path\/to\/file|^\d+%\s+context left|^press enter to send/i;
92282
+ var COMPOSER_RUNNING_INDICATOR_PATTERN = /esc to interrupt/i;
92283
+ var COMPOSER_BORDER_LINE_PATTERN = /^[─━═╌╍╭╮╰╯┌┐└┘+|\-_=\s]+$/;
92284
+ var COMPOSER_TAIL_SCAN_LINES = 12;
92285
+ function paneShowsPendingComposerText(snapshot, text) {
92286
+ const lastPromptLine = collapseWhitespace(lastNonEmptyLine(text));
92287
+ if (!lastPromptLine) {
92288
+ return false;
92289
+ }
92290
+ const lines = trimBlankLines(splitNormalizedLines(snapshot));
92291
+ for (let index = lines.length - 1;index >= Math.max(0, lines.length - COMPOSER_TAIL_SCAN_LINES); index -= 1) {
92292
+ const line = (lines[index] ?? "").trim();
92293
+ if (!line || COMPOSER_HINT_LINE_PATTERN.test(line) || isPromptMetadataLine(line)) {
92294
+ continue;
92295
+ }
92296
+ if (COMPOSER_RUNNING_INDICATOR_PATTERN.test(line)) {
92297
+ return false;
92298
+ }
92299
+ if (COMPOSER_BORDER_LINE_PATTERN.test(line)) {
92300
+ continue;
92301
+ }
92302
+ const stripped = stripComposerChrome(line);
92303
+ if (!stripped) {
92304
+ return false;
92305
+ }
92306
+ return stripped === lastPromptLine;
92307
+ }
92308
+ return false;
92309
+ }
92310
+ function stripComposerChrome(line) {
92311
+ return collapseWhitespace(line.replace(/^[│┃]\s*/, "").replace(/\s*[│┃]$/, "").replace(/^[›❯>]+\s*/, ""));
92312
+ }
92313
+ function lastNonEmptyLine(text) {
92314
+ const lines = text.split(`
92315
+ `).map((line) => line.trim()).filter(Boolean);
92316
+ return lines[lines.length - 1] ?? "";
92317
+ }
92318
+ function collapseWhitespace(value) {
92319
+ return value.replace(/\s+/g, " ").trim();
92320
+ }
92240
92321
  async function captureTmuxSessionIdentity(params) {
92241
92322
  await acceptTmuxStartupContinuePromptIfPresent({
92242
92323
  tmux: params.tmux,
@@ -92381,7 +92462,7 @@ async function waitForTmuxSessionBootstrap(params) {
92381
92462
  continue;
92382
92463
  }
92383
92464
  if (isBootstrapSessionGoneError(error)) {
92384
- throw buildBootstrapSessionLostError(params.sessionName, error);
92465
+ throw buildBootstrapSessionLostError(params.sessionName, error, lastSnapshot);
92385
92466
  }
92386
92467
  throw error;
92387
92468
  }
@@ -92399,6 +92480,18 @@ async function waitForTmuxSessionBootstrap(params) {
92399
92480
  await sleep(SESSION_BOOTSTRAP_POLL_INTERVAL_MS);
92400
92481
  continue;
92401
92482
  }
92483
+ if (params.resumeRejection?.detect(snapshot)) {
92484
+ return {
92485
+ status: "resume-rejected",
92486
+ snapshot
92487
+ };
92488
+ }
92489
+ if (params.exitDetection?.detect(snapshot)) {
92490
+ return {
92491
+ status: "exited",
92492
+ snapshot
92493
+ };
92494
+ }
92402
92495
  for (const blocker of blockerPatterns) {
92403
92496
  if (blocker.regex.test(snapshot)) {
92404
92497
  return {
@@ -92449,56 +92542,6 @@ async function acceptStartupContinuePrompt(params) {
92449
92542
  return;
92450
92543
  }
92451
92544
  }
92452
- async function waitForPaneSubmitConfirmation(params) {
92453
- const deadline = Date.now() + SUBMIT_CONFIRM_MAX_WAIT_MS;
92454
- while (true) {
92455
- const state = await params.tmux.getPaneState(params.sessionName);
92456
- if (hasPaneStateChanged(params.baseline, state)) {
92457
- return {
92458
- confirmed: true,
92459
- snapshot: normalizePaneText(await params.tmux.capturePane(params.sessionName, params.captureLines))
92460
- };
92461
- }
92462
- const snapshotChange = await waitForPaneSubmitSnapshotConfirmation({
92463
- tmux: params.tmux,
92464
- sessionName: params.sessionName,
92465
- baselineSnapshot: params.baselineSnapshot,
92466
- captureLines: params.captureLines,
92467
- maxWaitMs: Math.min(SUBMIT_SNAPSHOT_CONFIRM_MAX_WAIT_MS, Math.max(0, deadline - Date.now()))
92468
- });
92469
- if (snapshotChange.confirmed) {
92470
- return snapshotChange;
92471
- }
92472
- const remainingMs = deadline - Date.now();
92473
- if (remainingMs <= 0) {
92474
- return {
92475
- confirmed: false,
92476
- snapshot: params.baselineSnapshot
92477
- };
92478
- }
92479
- await sleep(Math.min(SUBMIT_CONFIRM_POLL_INTERVAL_MS, remainingMs));
92480
- }
92481
- }
92482
- async function waitForPaneSubmitSnapshotConfirmation(params) {
92483
- const deadline = Date.now() + params.maxWaitMs;
92484
- while (true) {
92485
- const snapshot = normalizePaneText(await params.tmux.capturePane(params.sessionName, params.captureLines));
92486
- if (snapshot !== params.baselineSnapshot) {
92487
- return {
92488
- confirmed: true,
92489
- snapshot
92490
- };
92491
- }
92492
- const remainingMs = deadline - Date.now();
92493
- if (remainingMs <= 0) {
92494
- return {
92495
- confirmed: false,
92496
- snapshot: params.baselineSnapshot
92497
- };
92498
- }
92499
- await sleep(Math.min(SUBMIT_SNAPSHOT_CONFIRM_POLL_INTERVAL_MS, remainingMs));
92500
- }
92501
- }
92502
92545
  async function deliverTmuxPasteWithConfirmation(params) {
92503
92546
  for (let attempt = 1;attempt <= PASTE_CONFIRM_MAX_ATTEMPTS; attempt += 1) {
92504
92547
  if (attempt > 1) {
@@ -92637,9 +92680,9 @@ function isBootstrapSessionGoneError(error) {
92637
92680
  const message = error instanceof Error ? error.message : String(error);
92638
92681
  return TMUX_MISSING_SESSION_PATTERN.test(message) || TMUX_SERVER_UNAVAILABLE_PATTERN.test(message);
92639
92682
  }
92640
- function buildBootstrapSessionLostError(sessionName, error) {
92683
+ function buildBootstrapSessionLostError(sessionName, error, lastSnapshot = "") {
92641
92684
  const message = error instanceof Error ? error.message : String(error);
92642
- return new TmuxBootstrapSessionLostError(sessionName, message);
92685
+ return new TmuxBootstrapSessionLostError(sessionName, message, lastSnapshot);
92643
92686
  }
92644
92687
  function arePaneStatesEqual(left, right) {
92645
92688
  return left.cursorX === right.cursorX && left.cursorY === right.cursorY && left.historySize === right.historySize;
@@ -92855,6 +92898,132 @@ function escapeRegExp(raw) {
92855
92898
  return raw.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
92856
92899
  }
92857
92900
 
92901
+ // src/runners/resume-rejection.ts
92902
+ var RESUME_REJECTED_PATTERNS = [
92903
+ /no saved session found with id/i,
92904
+ /no conversation found with session id/i,
92905
+ /no conversation found to resume/i,
92906
+ /no session found with id/i,
92907
+ /could not find (?:a )?session (?:with )?id/i
92908
+ ];
92909
+ function paneShowsResumeRejected(snapshot) {
92910
+ if (!snapshot) {
92911
+ return false;
92912
+ }
92913
+ return RESUME_REJECTED_PATTERNS.some((pattern) => pattern.test(snapshot));
92914
+ }
92915
+
92916
+ class RunnerResumeRejectedError extends Error {
92917
+ sessionName;
92918
+ storedSessionId;
92919
+ lastPane;
92920
+ constructor(sessionName, storedSessionId, lastPane = "") {
92921
+ super(`Runner session "${sessionName}" could not resume stored session id ${storedSessionId}: the runner reported that this saved session no longer exists.`);
92922
+ this.sessionName = sessionName;
92923
+ this.storedSessionId = storedSessionId;
92924
+ this.lastPane = lastPane;
92925
+ this.name = "RunnerResumeRejectedError";
92926
+ }
92927
+ }
92928
+
92929
+ // src/runners/runner-state-failures.ts
92930
+ var STATE_CONTENTION_PATTERNS = [
92931
+ /database (?:table )?is locked/i,
92932
+ /SQLITE_BUSY/i,
92933
+ /timed out waiting for state db backfill/i,
92934
+ /unable to open database file/i
92935
+ ];
92936
+ var STATE_CORRUPTION_PATTERNS = [
92937
+ /file is not a database/i,
92938
+ /database disk image is malformed/i,
92939
+ /migration \d+ was previously applied but has been modified/i,
92940
+ /cannot access its local database/i
92941
+ ];
92942
+ function paneShowsRunnerStateContention(snapshot) {
92943
+ if (!snapshot) {
92944
+ return false;
92945
+ }
92946
+ return STATE_CONTENTION_PATTERNS.some((pattern) => pattern.test(snapshot));
92947
+ }
92948
+ function paneShowsRunnerStateCorruption(snapshot) {
92949
+ if (!snapshot) {
92950
+ return false;
92951
+ }
92952
+ return STATE_CORRUPTION_PATTERNS.some((pattern) => pattern.test(snapshot));
92953
+ }
92954
+
92955
+ class RunnerStateContentionError extends Error {
92956
+ sessionName;
92957
+ lastPane;
92958
+ constructor(sessionName, lastPane = "") {
92959
+ super([
92960
+ `Runner session "${sessionName}" could not start because the runner's local state database is locked by another running runner process (shared CODEX_HOME contention).`,
92961
+ "Nothing was lost: the stored session id and saved conversation were preserved.",
92962
+ "Resend your prompt to retry once the other run settles.",
92963
+ "If this keeps happening, avoid starting many runner sessions at the same time or give this agent its own CODEX_HOME."
92964
+ ].join(" "));
92965
+ this.sessionName = sessionName;
92966
+ this.lastPane = lastPane;
92967
+ this.name = "RunnerStateContentionError";
92968
+ }
92969
+ }
92970
+
92971
+ class RunnerStateCorruptionError extends Error {
92972
+ sessionName;
92973
+ lastPane;
92974
+ constructor(sessionName, lastPane = "") {
92975
+ super([
92976
+ `Runner session "${sessionName}" cannot start: the runner reported that its local state database is corrupted or version-mismatched.`,
92977
+ "Retrying will not help. An operator must repair the runner state in CODEX_HOME (for codex this is usually state_5.sqlite / logs_2.sqlite; see the runner's own error output).",
92978
+ "The stored session id was preserved for after the repair."
92979
+ ].join(" "));
92980
+ this.sessionName = sessionName;
92981
+ this.lastPane = lastPane;
92982
+ this.name = "RunnerStateCorruptionError";
92983
+ }
92984
+ }
92985
+
92986
+ // src/agents/session/run-recovery.ts
92987
+ var MID_RUN_RECOVERY_MAX_ATTEMPTS = 2;
92988
+ var MID_RUN_RECOVERY_CONTINUE_PROMPT = "continue exactly where you left off";
92989
+ function mergeRunSnapshot(snapshotPrefix, snapshot) {
92990
+ return appendInteractionText(snapshotPrefix, snapshot);
92991
+ }
92992
+ function buildRunRecoveryNote(kind, params) {
92993
+ const storedIdDetail = params?.storedSessionId ? ` (stored session id ${params.storedSessionId})` : "";
92994
+ if (kind === "resume-attempt") {
92995
+ const attempt = params?.attempt ?? 1;
92996
+ const maxAttempts = params?.maxAttempts ?? MID_RUN_RECOVERY_MAX_ATTEMPTS;
92997
+ return `Runner session was lost. Attempting recovery ${attempt}/${maxAttempts} by reopening the same conversation context.`;
92998
+ }
92999
+ if (kind === "resume-success") {
93000
+ return "Recovery succeeded. Asking the runner to continue exactly where it left off.";
93001
+ }
93002
+ if (kind === "fresh-attempt") {
93003
+ return "The previous runner session could not be resumed. Opening a fresh runner session 2/2 without replaying your prompt.";
93004
+ }
93005
+ if (kind === "resume-failed") {
93006
+ return `The previous runner session could not be resumed${storedIdDetail}. The stored session id was preserved so the conversation can still be retried.`;
93007
+ }
93008
+ if (kind === "manual-new-required") {
93009
+ return [
93010
+ `The previous runner session could not be resumed, so the interrupted run stopped${storedIdDetail}.`,
93011
+ "clisbot preserved the stored session id instead of silently opening a new conversation, because the run was already in progress and its context may matter.",
93012
+ "Next steps: resend your prompt - clisbot will retry resuming this conversation and automatically fall back to a fresh one if the runner no longer has it.",
93013
+ "Send `/new` first if you prefer to start a clean conversation."
93014
+ ].join(" ");
93015
+ }
93016
+ return "The previous runner session could not be resumed. clisbot opened a new fresh session, but did not replay your prompt because the prior conversation context is no longer guaranteed. Please resend the full prompt/context to continue.";
93017
+ }
93018
+ function buildResumeRejectedFreshStartNote(params) {
93019
+ const cause = params.reason === "rejected" ? `the runner reported that saved session ${params.storedSessionId} no longer exists` : `the runner kept exiting while resuming saved session ${params.storedSessionId}`;
93020
+ const inspectHint = params.resumeCommand ? ` To inspect the old session manually, try \`${params.resumeCommand}\` in the workspace terminal.` : "";
93021
+ return [
93022
+ `The previous runner conversation could not be resumed: ${cause}.`,
93023
+ "clisbot opened a fresh conversation and is running your prompt there; earlier conversation context is not carried over."
93024
+ ].join(" ") + inspectHint;
93025
+ }
93026
+
92858
93027
  // src/agents/runtime/runner-service.ts
92859
93028
  var TMUX_MISSING_SESSION_PATTERN2 = /(?:can't find session:|no server running on )/i;
92860
93029
  var TMUX_SERVER_UNAVAILABLE_PATTERN2 = /(?:No such file or directory|error connecting to|failed to connect to server)/i;
@@ -92865,7 +93034,6 @@ var SESSION_READY_CAPTURE_RETRY_DELAY_MS = 100;
92865
93034
  var STARTUP_SESSION_ID_CAPTURE_RETRY_COUNT = 2;
92866
93035
  var STARTUP_SESSION_ID_CAPTURE_RETRY_DELAY_MS = 500;
92867
93036
  var SESSION_ID_CAPTURE_FAILURE_COOLDOWN_MS = 15000;
92868
- var PRESERVED_SESSION_ID_RETRY_MESSAGE = "The previous runner session could not be resumed. clisbot preserved the stored session id instead of opening a new conversation automatically. Use `/new` if you want to trigger a new runner conversation, then resend the prompt.";
92869
93037
  function summarizeSnapshot(snapshot) {
92870
93038
  const compact = snapshot.split(`
92871
93039
  `).map((line) => line.trim()).filter(Boolean).join(" ").slice(0, 220);
@@ -92916,15 +93084,18 @@ class RunnerService {
92916
93084
  async mapSessionError(error, sessionName, action, lastSnapshot = "") {
92917
93085
  if (isRecoverableStartupSessionLoss(error)) {
92918
93086
  const exitRecord = await readRunnerExitRecord(this.loadedConfig.stateDir, sessionName);
93087
+ const paneSnapshot = lastSnapshot || (error instanceof TmuxBootstrapSessionLostError ? error.lastSnapshot : "");
92919
93088
  console.error("runner session disappeared", {
92920
93089
  sessionName,
92921
93090
  action,
92922
93091
  exitCode: exitRecord?.exitCode,
92923
93092
  exitedAt: exitRecord?.exitedAt,
92924
93093
  runnerCommand: exitRecord?.command,
92925
- lastVisiblePane: lastSnapshot ? summarizeSnapshot(lastSnapshot).trim() : undefined
93094
+ lastVisiblePane: paneSnapshot ? summarizeSnapshot(paneSnapshot).trim() : undefined
92926
93095
  });
92927
- return new Error(`Runner session "${sessionName}" disappeared ${action}.`);
93096
+ const exitDetail = typeof exitRecord?.exitCode === "number" ? ` The runner process exited with code ${exitRecord.exitCode}.` : "";
93097
+ const nextStep = action === "while the prompt was running" ? `The prompt may have partially run; check ${renderCliCommand("watch --latest --lines 100", { inline: true })} before resending.` : "Your prompt was not submitted; resend it to retry.";
93098
+ return new Error(`Runner session "${sessionName}" disappeared ${action}.${exitDetail} ${nextStep} If this keeps happening, verify the runner CLI starts cleanly in the workspace terminal and inspect ${renderCliCommand("logs", { inline: true })}.${summarizeSnapshot(paneSnapshot)}`);
92928
93099
  }
92929
93100
  if (isTransientTmuxTargetError(error)) {
92930
93101
  return new Error(`Runner session "${sessionName}" lost its tmux target ${action}. clisbot stayed alive, but this request could not continue cleanly. Retry once. If it keeps happening, inspect ${renderCliCommand("status", { inline: true })} and ${renderCliCommand("logs", { inline: true })}.${summarizeSnapshot(lastSnapshot)}`);
@@ -93022,7 +93193,7 @@ class RunnerService {
93022
93193
  pollIntervalMs: capture.pollIntervalMs
93023
93194
  });
93024
93195
  }
93025
- async retryRunnerRestartPreservingSessionId(target, resolved, remainingFreshRetries) {
93196
+ async retryRunnerRestartPreservingSessionId(target, resolved, remainingFreshRetries, startupNotes) {
93026
93197
  if (remainingFreshRetries <= 0) {
93027
93198
  return null;
93028
93199
  }
@@ -93031,44 +93202,113 @@ class RunnerService {
93031
93202
  await sleep(resolved.runner.startupRetryDelayMs);
93032
93203
  }
93033
93204
  return this.ensureSessionReady(target, {
93034
- remainingFreshRetries: remainingFreshRetries - 1
93205
+ remainingFreshRetries: remainingFreshRetries - 1,
93206
+ startupNotes
93207
+ });
93208
+ }
93209
+ classifyRunnerStartupExit(resolved, snapshot) {
93210
+ if (paneShowsRunnerStateCorruption(snapshot)) {
93211
+ return new RunnerStateCorruptionError(resolved.sessionName, snapshot);
93212
+ }
93213
+ if (paneShowsRunnerStateContention(snapshot)) {
93214
+ return new RunnerStateContentionError(resolved.sessionName, snapshot);
93215
+ }
93216
+ return new TmuxBootstrapSessionLostError(resolved.sessionName, "runner exited during startup", snapshot);
93217
+ }
93218
+ async retryAfterStateContention(target, resolved, remainingFreshRetries, startupNotes) {
93219
+ if (remainingFreshRetries <= 0) {
93220
+ return null;
93221
+ }
93222
+ const attempt = resolved.runner.startupRetryCount - remainingFreshRetries + 1;
93223
+ const backoffMs = resolved.runner.startupRetryDelayMs * attempt + Math.floor(Math.random() * 250);
93224
+ console.log(`clisbot runner state database contention for ${resolved.sessionName}; retrying startup with the preserved session id in ${backoffMs}ms`);
93225
+ await this.killRunnerAndPreserveSessionId(resolved);
93226
+ if (backoffMs > 0) {
93227
+ await sleep(backoffMs);
93228
+ }
93229
+ return this.ensureSessionReady(target, {
93230
+ remainingFreshRetries: remainingFreshRetries - 1,
93231
+ startupNotes
93035
93232
  });
93036
93233
  }
93037
- async retryAfterStartupFault(target, resolved, error, remainingFreshRetries, allowFreshResumeFallback) {
93234
+ async retryAfterStartupFault(target, resolved, error, remainingFreshRetries, allowFreshResumeFallback, startupNotes) {
93235
+ if (error instanceof RunnerStateContentionError) {
93236
+ return this.retryAfterStateContention(target, resolved, remainingFreshRetries, startupNotes);
93237
+ }
93238
+ if (error instanceof RunnerStateCorruptionError) {
93239
+ return null;
93240
+ }
93038
93241
  if (allowFreshResumeFallback) {
93039
- const resumedFresh = await this.retryFreshStartAfterStoredResumeFailure(target, resolved, error, remainingFreshRetries);
93040
- if (resumedFresh) {
93041
- return resumedFresh;
93242
+ const fallback = await this.fallBackToFreshAfterRejectedResume(target, resolved, error, remainingFreshRetries, startupNotes);
93243
+ if (fallback) {
93244
+ return fallback;
93042
93245
  }
93043
93246
  }
93044
93247
  if (!isRetryableFreshStartFault(error)) {
93045
93248
  return null;
93046
93249
  }
93047
- return this.retryRunnerRestartPreservingSessionId(target, resolved, remainingFreshRetries);
93250
+ return this.retryRunnerRestartPreservingSessionId(target, resolved, remainingFreshRetries, startupNotes);
93048
93251
  }
93049
- async retryFreshStartAfterStoredResumeFailure(target, resolved, error, remainingFreshRetries) {
93252
+ async classifyRejectedResumeStartup(resolved, error, remainingFreshRetries) {
93253
+ const storedSessionId = (await this.sessionMapping.get(resolved.sessionKey))?.sessionId?.trim() || "";
93254
+ if (!storedSessionId) {
93255
+ return null;
93256
+ }
93257
+ if (error instanceof RunnerResumeRejectedError) {
93258
+ return { storedSessionId, reason: "rejected" };
93259
+ }
93260
+ if (error instanceof TmuxBootstrapSessionLostError && paneShowsResumeRejected(error.lastSnapshot)) {
93261
+ return { storedSessionId, reason: "rejected" };
93262
+ }
93050
93263
  if (!isRecoverableStartupSessionLoss(error)) {
93051
93264
  return null;
93052
93265
  }
93053
93266
  if (resolved.runner.sessionId.resume.mode !== "command" || resolved.runner.sessionId.create.mode !== "runner") {
93054
93267
  return null;
93055
93268
  }
93056
- const existing = await this.sessionMapping.get(resolved.sessionKey);
93057
- if (!existing?.sessionId) {
93269
+ if (remainingFreshRetries > 0) {
93058
93270
  return null;
93059
93271
  }
93060
93272
  const exitRecord = await readRunnerExitRecord(this.loadedConfig.stateDir, resolved.sessionName);
93061
93273
  if (!exitRecord || exitRecord.exitCode === 0) {
93062
93274
  return null;
93063
93275
  }
93064
- console.log(`clisbot preserved stored sessionId after failed runner resume startup ${resolved.sessionName}`);
93065
- await this.sessionMapping.touch(resolved, {
93276
+ return { storedSessionId, reason: "exit" };
93277
+ }
93278
+ async fallBackToFreshAfterRejectedResume(target, resolved, error, remainingFreshRetries, startupNotes) {
93279
+ const rejection = await this.classifyRejectedResumeStartup(resolved, error, remainingFreshRetries);
93280
+ if (!rejection) {
93281
+ return null;
93282
+ }
93283
+ console.log(`clisbot resume rejected for ${resolved.sessionName}; opening a fresh runner conversation`, {
93284
+ storedSessionId: rejection.storedSessionId,
93285
+ reason: rejection.reason
93286
+ });
93287
+ await this.tmux.killSession(resolved.sessionName).catch(() => {
93288
+ return;
93289
+ });
93290
+ await this.sessionMapping.clearActive(resolved, {
93066
93291
  runnerCommand: resolved.runner.command
93067
93292
  });
93068
- throw new Error(PRESERVED_SESSION_ID_RETRY_MESSAGE);
93293
+ startupNotes?.push(buildResumeRejectedFreshStartNote({
93294
+ storedSessionId: rejection.storedSessionId,
93295
+ reason: rejection.reason,
93296
+ resumeCommand: this.renderRunnerResumeCommand(resolved, rejection.storedSessionId)
93297
+ }));
93298
+ return this.ensureSessionReady(target, {
93299
+ remainingFreshRetries: resolved.runner.startupRetryCount,
93300
+ startupNotes
93301
+ });
93302
+ }
93303
+ renderRunnerResumeCommand(resolved, sessionId) {
93304
+ if (resolved.runner.sessionId.resume.mode !== "command") {
93305
+ return;
93306
+ }
93307
+ const launch = this.buildRunnerArgs(resolved, { sessionId, resume: true });
93308
+ return [launch.command, ...launch.args].join(" ");
93069
93309
  }
93070
- async retryAfterStartupTimeout(target, resolved, remainingFreshRetries) {
93071
- return this.retryRunnerRestartPreservingSessionId(target, resolved, remainingFreshRetries);
93310
+ async retryAfterStartupTimeout(target, resolved, remainingFreshRetries, startupNotes) {
93311
+ return this.retryRunnerRestartPreservingSessionId(target, resolved, remainingFreshRetries, startupNotes);
93072
93312
  }
93073
93313
  resolveRemainingFreshRetries(resolved, options) {
93074
93314
  if (typeof options.remainingFreshRetries === "number") {
@@ -93162,21 +93402,28 @@ class RunnerService {
93162
93402
  const preparedMapping = await this.sessionMapping.prepareStartup(resolved);
93163
93403
  const serverRunning = await this.tmux.isServerRunning();
93164
93404
  if (serverRunning && await this.tmux.hasSession(resolved.sessionName)) {
93165
- logLatencyDebug("ensure-session-ready-existing-session", timingContext, {
93166
- hasStoredSessionId: Boolean(preparedMapping.storedSessionId)
93167
- });
93168
- try {
93169
- await clearRunnerExitRecord(this.loadedConfig.stateDir, resolved.sessionName);
93170
- await this.acceptStartupContinuePromptIfPresent(resolved);
93171
- await this.syncActiveSessionMappingForResolvedTarget(resolved);
93172
- } catch (error) {
93173
- throw await this.mapSessionError(error, resolved.sessionName, "during startup");
93405
+ const lingeringExitSnapshot = await this.captureSessionSnapshot(resolved).catch(() => "");
93406
+ if (paneShowsRunnerExitSentinel(lingeringExitSnapshot)) {
93407
+ await this.tmux.killSession(resolved.sessionName).catch(() => {
93408
+ return;
93409
+ });
93410
+ } else {
93411
+ logLatencyDebug("ensure-session-ready-existing-session", timingContext, {
93412
+ hasStoredSessionId: Boolean(preparedMapping.storedSessionId)
93413
+ });
93414
+ try {
93415
+ await clearRunnerExitRecord(this.loadedConfig.stateDir, resolved.sessionName);
93416
+ await this.acceptStartupContinuePromptIfPresent(resolved);
93417
+ await this.syncActiveSessionMappingForResolvedTarget(resolved);
93418
+ } catch (error) {
93419
+ throw await this.mapSessionError(error, resolved.sessionName, "during startup");
93420
+ }
93421
+ logLatencyDebug("ensure-session-ready-complete", timingContext, {
93422
+ startupDelayMs: 0,
93423
+ reusedSession: true
93424
+ });
93425
+ return resolved;
93174
93426
  }
93175
- logLatencyDebug("ensure-session-ready-complete", timingContext, {
93176
- startupDelayMs: 0,
93177
- reusedSession: true
93178
- });
93179
- return resolved;
93180
93427
  }
93181
93428
  if (!resolved.session.createIfMissing) {
93182
93429
  throw new Error(`tmux session "${resolved.sessionName}" does not exist`);
@@ -93221,24 +93468,38 @@ class RunnerService {
93221
93468
  startupDelayMs: resolved.runner.startupDelayMs,
93222
93469
  trustWorkspace: resolved.runner.trustWorkspace,
93223
93470
  readyPattern: resolved.runner.startupReadyPattern,
93224
- blockers: resolved.runner.startupBlockers
93471
+ blockers: resolved.runner.startupBlockers,
93472
+ resumeRejection: resumingExistingSession && storedOrExplicitSessionId ? { detect: paneShowsResumeRejected } : undefined,
93473
+ exitDetection: { detect: paneShowsRunnerExitSentinel }
93225
93474
  });
93475
+ if (bootstrapResult.status === "exited") {
93476
+ await this.tmux.killSession(resolved.sessionName).catch(() => {
93477
+ return;
93478
+ });
93479
+ throw this.classifyRunnerStartupExit(resolved, bootstrapResult.snapshot);
93480
+ }
93481
+ if (bootstrapResult.status === "resume-rejected") {
93482
+ await this.tmux.killSession(resolved.sessionName).catch(() => {
93483
+ return;
93484
+ });
93485
+ throw new RunnerResumeRejectedError(resolved.sessionName, storedOrExplicitSessionId, bootstrapResult.snapshot);
93486
+ }
93226
93487
  if (bootstrapResult.status === "blocked") {
93227
93488
  await this.abortUnreadySession(resolved, bootstrapResult.message, bootstrapResult.snapshot);
93228
93489
  }
93229
93490
  if (bootstrapResult.status === "timeout" && resolved.runner.startupReadyPattern) {
93230
- const retried = await this.retryAfterStartupTimeout(target, resolved, remainingFreshRetries);
93491
+ const retried = await this.retryAfterStartupTimeout(target, resolved, remainingFreshRetries, options.startupNotes);
93231
93492
  if (retried) {
93232
93493
  return retried;
93233
93494
  }
93234
- await this.abortUnreadySession(resolved, `Runner session "${resolved.sessionName}" did not reach the configured ready state within ${resolved.runner.startupDelayMs}ms.`, bootstrapResult.snapshot);
93495
+ await this.abortUnreadySession(resolved, `Runner session "${resolved.sessionName}" did not reach the configured ready state within ${resolved.runner.startupDelayMs}ms, so your prompt was not submitted. Verify that \`${resolved.runner.command}\` starts cleanly in the workspace terminal, then resend. Inspect ${renderCliCommand("runner inspect --latest --lines 120", { inline: true })} and ${renderCliCommand("logs", { inline: true })} if it keeps happening.`, bootstrapResult.snapshot);
93235
93496
  }
93236
93497
  await this.finalizeSessionStartup(resolved, {
93237
93498
  storedOrExplicitSessionId,
93238
93499
  runnerCommand: runnerLaunch.command
93239
93500
  });
93240
93501
  } catch (error) {
93241
- const retried = await this.retryAfterStartupFault(target, resolved, error, remainingFreshRetries, options.allowFreshRetry !== false);
93502
+ const retried = await this.retryAfterStartupFault(target, resolved, error, remainingFreshRetries, options.allowFreshRetry !== false, options.startupNotes);
93242
93503
  if (retried) {
93243
93504
  return retried;
93244
93505
  }
@@ -93301,30 +93562,65 @@ class RunnerService {
93301
93562
  return normalizePaneText(await this.tmux.capturePane(resolved.sessionName, resolved.stream.captureLines));
93302
93563
  }
93303
93564
  async ensureRunnerReady(target, options = {}) {
93565
+ const startupNotes = [];
93304
93566
  let resolved = await this.ensureSessionReady(target, {
93305
93567
  allowFreshRetry: options.allowFreshRetryBeforePrompt,
93306
- timingContext: options.timingContext
93568
+ timingContext: options.timingContext,
93569
+ startupNotes
93307
93570
  });
93308
93571
  try {
93309
93572
  return {
93310
93573
  resolved,
93311
- initialSnapshot: await this.captureSessionSnapshot(resolved)
93574
+ initialSnapshot: await this.captureSessionSnapshot(resolved),
93575
+ startupNotes
93312
93576
  };
93313
93577
  } catch (error) {
93314
93578
  if (options.allowFreshRetryBeforePrompt === false || !isRecoverableStartupSessionLoss(error)) {
93315
93579
  throw await this.mapSessionError(error, resolved.sessionName, "before prompt submission", resolved.sessionName ? await this.captureSessionSnapshot(resolved).catch(() => "") : "");
93316
93580
  }
93317
- const retried = await this.retryRunnerRestartPreservingSessionId(target, resolved, resolved.runner.startupRetryCount);
93581
+ const retried = await this.retryRunnerRestartPreservingSessionId(target, resolved, resolved.runner.startupRetryCount, startupNotes);
93318
93582
  if (!retried) {
93319
93583
  throw await this.mapSessionError(error, resolved.sessionName, "before prompt submission", resolved.sessionName ? await this.captureSessionSnapshot(resolved).catch(() => "") : "");
93320
93584
  }
93321
93585
  resolved = retried;
93322
93586
  return {
93323
93587
  resolved,
93324
- initialSnapshot: await this.captureSessionSnapshot(resolved)
93588
+ initialSnapshot: await this.captureSessionSnapshot(resolved),
93589
+ startupNotes
93325
93590
  };
93326
93591
  }
93327
93592
  }
93593
+ async recaptureSessionIdAfterRun(target) {
93594
+ const resolved = this.resolveTarget(target);
93595
+ if (resolved.runner.sessionId.capture.mode !== "status-command") {
93596
+ return null;
93597
+ }
93598
+ const existing = await this.sessionMapping.get(resolved.sessionKey);
93599
+ if (existing?.sessionId) {
93600
+ return existing.sessionId;
93601
+ }
93602
+ if (!await this.tmux.hasSession(resolved.sessionName)) {
93603
+ return null;
93604
+ }
93605
+ let sessionId = null;
93606
+ try {
93607
+ sessionId = await this.captureSessionIdFromRunner(resolved);
93608
+ } catch (error) {
93609
+ console.warn(`clisbot post-run session id recapture failed for ${resolved.sessionName}`, error);
93610
+ this.deferSessionIdCapture(resolved.sessionKey);
93611
+ return null;
93612
+ }
93613
+ if (!sessionId) {
93614
+ this.deferSessionIdCapture(resolved.sessionKey);
93615
+ return null;
93616
+ }
93617
+ const recorded = await this.recordActiveSessionIdBestEffort(resolved, sessionId);
93618
+ if (!recorded) {
93619
+ return null;
93620
+ }
93621
+ console.log(`clisbot captured durable session id after run completion for ${resolved.sessionName}`);
93622
+ return sessionId;
93623
+ }
93328
93624
  canRecoverMidRun(error) {
93329
93625
  return isRecoverableStartupSessionLoss(error) || isTransientTmuxTargetError(error);
93330
93626
  }
@@ -93459,7 +93755,9 @@ class RunnerService {
93459
93755
  throw new Error(`${command} completed and clisbot captured session id ${sessionId}, but could not persist it. The durable session mapping was left unchanged.${details}`);
93460
93756
  }
93461
93757
  async killRunnerAndPreserveSessionId(resolved) {
93462
- await this.tmux.killSession(resolved.sessionName);
93758
+ await this.tmux.killSession(resolved.sessionName).catch(() => {
93759
+ return;
93760
+ });
93463
93761
  await this.sessionMapping.touch(resolved, {
93464
93762
  runnerCommand: resolved.runner.command
93465
93763
  });
@@ -93581,33 +93879,6 @@ class RunnerService {
93581
93879
  }
93582
93880
  }
93583
93881
 
93584
- // src/agents/session/run-recovery.ts
93585
- var MID_RUN_RECOVERY_MAX_ATTEMPTS = 2;
93586
- var MID_RUN_RECOVERY_CONTINUE_PROMPT = "continue exactly where you left off";
93587
- function mergeRunSnapshot(snapshotPrefix, snapshot) {
93588
- return appendInteractionText(snapshotPrefix, snapshot);
93589
- }
93590
- function buildRunRecoveryNote(kind, params) {
93591
- if (kind === "resume-attempt") {
93592
- const attempt = params?.attempt ?? 1;
93593
- const maxAttempts = params?.maxAttempts ?? MID_RUN_RECOVERY_MAX_ATTEMPTS;
93594
- return `Runner session was lost. Attempting recovery ${attempt}/${maxAttempts} by reopening the same conversation context.`;
93595
- }
93596
- if (kind === "resume-success") {
93597
- return "Recovery succeeded. Asking the runner to continue exactly where it left off.";
93598
- }
93599
- if (kind === "fresh-attempt") {
93600
- return "The previous runner session could not be resumed. Opening a fresh runner session 2/2 without replaying your prompt.";
93601
- }
93602
- if (kind === "resume-failed") {
93603
- return "The previous runner session could not be resumed. The stored session id was preserved; use `/new` to intentionally trigger a new runner conversation.";
93604
- }
93605
- if (kind === "manual-new-required") {
93606
- return "The previous runner session could not be resumed. clisbot preserved the stored session id instead of opening a new conversation automatically. Use `/new` if you want to trigger a new runner conversation, then resend the prompt.";
93607
- }
93608
- return "The previous runner session could not be resumed. clisbot opened a new fresh session, but did not replay your prompt because the prior conversation context is no longer guaranteed. Please resend the full prompt/context to continue.";
93609
- }
93610
-
93611
93882
  // src/runners/tmux/run-monitor.ts
93612
93883
  var FIRST_OUTPUT_POLL_INTERVAL_MS = 250;
93613
93884
  var RUNNING_REWRITE_PREVIEW_MAX_LINES = 8;
@@ -93793,8 +94064,10 @@ function isRetryableObserverDeliveryError(error) {
93793
94064
  }
93794
94065
  function buildMissingSessionIdStartupWarning() {
93795
94066
  return [
93796
- "Runner session started, but clisbot could not capture a durable session id yet.",
93797
- "This session is running, but it is not resumable until a session id is captured and persisted."
94067
+ "Runner session started, but clisbot could not capture a durable session id yet,",
94068
+ "so this conversation is not resumable if the runner restarts.",
94069
+ "clisbot keeps retrying automatically and will persist the id once the runner reports it; no action is needed.",
94070
+ "If this warning keeps appearing, the runner status output may have changed; check the pane with `clisbot watch --latest`."
93798
94071
  ].join(" ");
93799
94072
  }
93800
94073
 
@@ -93921,7 +94194,7 @@ class SessionService {
93921
94194
  });
93922
94195
  try {
93923
94196
  await this.sessionState.markPromptAdmitted(provisionalResolved);
93924
- const { resolved, initialSnapshot } = await this.runnerSessions.ensureRunnerReady(target, {
94197
+ const { resolved, initialSnapshot, startupNotes } = await this.runnerSessions.ensureRunnerReady(target, {
93925
94198
  ...options,
93926
94199
  timingContext: observer.timingContext
93927
94200
  });
@@ -93952,6 +94225,17 @@ class SessionService {
93952
94225
  state: "running",
93953
94226
  startedAt
93954
94227
  });
94228
+ for (const startupNote of startupNotes ?? []) {
94229
+ await this.notifyRunObservers(run, this.createRunUpdate({
94230
+ resolved,
94231
+ status: "running",
94232
+ snapshot: "",
94233
+ fullSnapshot: initialSnapshot,
94234
+ initialSnapshot,
94235
+ note: startupNote,
94236
+ forceVisible: true
94237
+ }));
94238
+ }
93955
94239
  if (!run.sessionId) {
93956
94240
  await this.notifyRunObservers(run, this.createRunUpdate({
93957
94241
  resolved,
@@ -94219,6 +94503,14 @@ class SessionService {
94219
94503
  if (!run) {
94220
94504
  return;
94221
94505
  }
94506
+ if (!run.sessionId) {
94507
+ try {
94508
+ run.sessionId = await this.runnerSessions.recaptureSessionIdAfterRun({
94509
+ agentId: run.resolved.agentId,
94510
+ sessionKey: run.resolved.sessionKey
94511
+ }) ?? undefined;
94512
+ } catch {}
94513
+ }
94222
94514
  await this.sessionState.setSessionRuntime(run.resolved, {
94223
94515
  state: "idle"
94224
94516
  });
@@ -94356,8 +94648,10 @@ class SessionService {
94356
94648
  return true;
94357
94649
  }
94358
94650
  if (await this.requiresManualNewAfterFailedResume(currentRun)) {
94359
- await this.notifyRecoveryStep(currentRun, buildRunRecoveryNote("resume-failed"));
94360
- await this.failActiveRun(sessionKey, currentRun.runId, new Error(buildRunRecoveryNote("manual-new-required")));
94651
+ await this.notifyRecoveryStep(currentRun, buildRunRecoveryNote("resume-failed", { storedSessionId: currentRun.sessionId }));
94652
+ await this.failActiveRun(sessionKey, currentRun.runId, new Error(buildRunRecoveryNote("manual-new-required", {
94653
+ storedSessionId: currentRun.sessionId
94654
+ })));
94361
94655
  return true;
94362
94656
  }
94363
94657
  await this.notifyRecoveryStep(currentRun, buildRunRecoveryNote("fresh-attempt"));
@@ -97828,6 +98122,129 @@ function isTerminalResultStatus(status) {
97828
98122
  return ["completed", "failed", "filtered", "expired", "stopped"].includes(status);
97829
98123
  }
97830
98124
 
98125
+ // src/channels/api/http-listener.ts
98126
+ import { Buffer as Buffer2 } from "node:buffer";
98127
+ import { createServer } from "node:http";
98128
+ var FORCE_CLOSE_TIMEOUT_MS = 1000;
98129
+ function requestHeaders(request) {
98130
+ const headers = new Headers;
98131
+ for (const [key, value] of Object.entries(request.headers)) {
98132
+ if (Array.isArray(value)) {
98133
+ for (const item of value) {
98134
+ headers.append(key, item);
98135
+ }
98136
+ } else if (value != null) {
98137
+ headers.set(key, value);
98138
+ }
98139
+ }
98140
+ return headers;
98141
+ }
98142
+ async function readRequestBody(request) {
98143
+ const chunks = [];
98144
+ for await (const chunk of request) {
98145
+ chunks.push(Buffer2.isBuffer(chunk) ? chunk : Buffer2.from(chunk));
98146
+ }
98147
+ return Buffer2.concat(chunks);
98148
+ }
98149
+ function requestUrl(request, host) {
98150
+ const protocol = request.headers["x-forwarded-proto"] ?? "http";
98151
+ const requestHost = request.headers.host ?? host;
98152
+ return `${Array.isArray(protocol) ? protocol[0] : protocol}://${requestHost}${request.url ?? "/"}`;
98153
+ }
98154
+ async function toWebRequest(request, host) {
98155
+ const method = request.method ?? "GET";
98156
+ const bodyAllowed = method !== "GET" && method !== "HEAD";
98157
+ return new Request(requestUrl(request, host), {
98158
+ method,
98159
+ headers: requestHeaders(request),
98160
+ body: bodyAllowed ? await readRequestBody(request) : undefined
98161
+ });
98162
+ }
98163
+ async function writeWebResponse(response, target) {
98164
+ target.statusCode = response.status;
98165
+ response.headers.forEach((value, key) => {
98166
+ target.setHeader(key, value);
98167
+ });
98168
+ if (!response.body) {
98169
+ target.end();
98170
+ return;
98171
+ }
98172
+ target.end(Buffer2.from(await response.arrayBuffer()));
98173
+ }
98174
+ function closeServer(server, force) {
98175
+ return new Promise((resolve, reject) => {
98176
+ let settled = false;
98177
+ let timeout;
98178
+ const finish = (error) => {
98179
+ if (settled) {
98180
+ return;
98181
+ }
98182
+ settled = true;
98183
+ if (timeout) {
98184
+ clearTimeout(timeout);
98185
+ }
98186
+ if (error) {
98187
+ reject(error);
98188
+ } else {
98189
+ resolve();
98190
+ }
98191
+ };
98192
+ if (!server.listening) {
98193
+ if (force) {
98194
+ server.closeAllConnections?.();
98195
+ }
98196
+ finish();
98197
+ return;
98198
+ }
98199
+ server.close((error) => {
98200
+ if (error?.code === "ERR_SERVER_NOT_RUNNING") {
98201
+ finish();
98202
+ return;
98203
+ }
98204
+ if (error) {
98205
+ finish(error);
98206
+ } else {
98207
+ finish();
98208
+ }
98209
+ });
98210
+ if (force) {
98211
+ server.closeAllConnections?.();
98212
+ server.closeIdleConnections?.();
98213
+ timeout = setTimeout(() => finish(), FORCE_CLOSE_TIMEOUT_MS);
98214
+ timeout.unref?.();
98215
+ }
98216
+ });
98217
+ }
98218
+ async function startApiHttpListener(params) {
98219
+ const server = createServer(async (request, response) => {
98220
+ try {
98221
+ await writeWebResponse(await params.handle(await toWebRequest(request, params.host), request.socket.remoteAddress), response);
98222
+ } catch (error) {
98223
+ response.statusCode = 500;
98224
+ response.setHeader("content-type", "application/json");
98225
+ response.end(JSON.stringify({
98226
+ error: "api_listener_failed",
98227
+ detail: error instanceof Error ? error.message : String(error)
98228
+ }, null, 2));
98229
+ }
98230
+ });
98231
+ await new Promise((resolve, reject) => {
98232
+ server.once("error", reject);
98233
+ server.listen(params.port, params.host, () => {
98234
+ server.off("error", reject);
98235
+ resolve();
98236
+ });
98237
+ });
98238
+ const address = server.address();
98239
+ return {
98240
+ host: params.host,
98241
+ port: typeof address === "object" && address ? address.port : params.port,
98242
+ stop: async (force = false) => {
98243
+ await closeServer(server, force);
98244
+ }
98245
+ };
98246
+ }
98247
+
97831
98248
  // src/channels/api/stop.ts
97832
98249
  async function authorizeStopRequest(params) {
97833
98250
  const rawBody = await params.request.text();
@@ -97993,14 +98410,14 @@ class ApiChannelService {
97993
98410
  }
97994
98411
  async start() {
97995
98412
  const providerConfig = resolveApiProviderConfig(this.dependencies.loadedConfig.raw.bots.api);
97996
- this.server = Bun.serve({
97997
- hostname: providerConfig.defaults.listener.host,
98413
+ this.server = await startApiHttpListener({
98414
+ host: providerConfig.defaults.listener.host,
97998
98415
  port: providerConfig.defaults.listener.port,
97999
- fetch: (request, server) => this.handleRequest(request, server.requestIP(request)?.address ?? undefined)
98416
+ handle: (request, remoteAddress) => this.handleRequest(request, remoteAddress)
98000
98417
  });
98001
98418
  }
98002
98419
  async stop() {
98003
- this.server?.stop(true);
98420
+ await this.server?.stop(true);
98004
98421
  this.server = undefined;
98005
98422
  }
98006
98423
  async handleRequest(request, remoteAddress) {
@@ -101150,6 +101567,7 @@ import { readFile as readFile3 } from "node:fs/promises";
101150
101567
 
101151
101568
  // src/channels/slack/content.ts
101152
101569
  var SLACK_MAX_BLOCKS = 50;
101570
+ var SLACK_BULLET_MARKERS = ["•", "◦", "▪"];
101153
101571
  function normalizeMarkdownLinks(text) {
101154
101572
  return text.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_match, label, href) => {
101155
101573
  const trimmedHref = href.trim();
@@ -101162,6 +101580,20 @@ function normalizeMarkdownLinks(text) {
101162
101580
  function renderInlineMarkdownToSlackMrkdwn(text) {
101163
101581
  return normalizeMarkdownLinks(text).replace(/~~([^~]+)~~/g, "~$1~").replace(/\*\*([^*\n][\s\S]*?[^*\n])\*\*/g, "*$1*");
101164
101582
  }
101583
+ function trimOuterBlankLines(text) {
101584
+ return text.replace(/^\n+/, "").replace(/\n+$/, "");
101585
+ }
101586
+ function getMarkdownListDepth(rawIndent) {
101587
+ const width = rawIndent.replaceAll("\t", " ").length;
101588
+ return Math.floor(width / 2);
101589
+ }
101590
+ function renderSlackListIndent(depth) {
101591
+ return " ".repeat(Math.min(Math.max(depth, 0), 6));
101592
+ }
101593
+ function renderSlackBulletPrefix(depth) {
101594
+ const marker = SLACK_BULLET_MARKERS[Math.min(depth, SLACK_BULLET_MARKERS.length - 1)] ?? SLACK_BULLET_MARKERS[0];
101595
+ return `${renderSlackListIndent(depth)}${marker}`;
101596
+ }
101165
101597
  function stripMarkdownInline(text) {
101166
101598
  return text.replace(/`([^`\n]+)`/g, "$1").replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, "$1").replace(/\*\*([^*\n][\s\S]*?[^*\n])\*\*/g, "$1").replace(/\*([^*\n][\s\S]*?[^*\n])\*/g, "$1").replace(/~~([^~]+)~~/g, "$1").trim();
101167
101599
  }
@@ -101242,10 +101674,10 @@ function parseSlackBlocksInput(text) {
101242
101674
  return validateSlackBlocksArray(parsed);
101243
101675
  }
101244
101676
  function renderMarkdownToSlackMrkdwn(markdown) {
101245
- const normalized = markdown.replaceAll(`\r
101677
+ const normalized = trimOuterBlankLines(markdown.replaceAll(`\r
101246
101678
  `, `
101247
101679
  `).replaceAll("\r", `
101248
- `).trim();
101680
+ `));
101249
101681
  if (!normalized) {
101250
101682
  return "";
101251
101683
  }
@@ -101260,13 +101692,15 @@ function renderMarkdownToSlackMrkdwn(markdown) {
101260
101692
  }
101261
101693
  return content;
101262
101694
  }
101263
- const bulletMatch = line.match(/^\s*[-*+]\s+(.+)$/);
101695
+ const bulletMatch = line.match(/^(\s*)[-*+]\s+(.+)$/);
101264
101696
  if (bulletMatch) {
101265
- return `• ${renderInlineMarkdownToSlackMrkdwn(bulletMatch[1] ?? "")}`;
101697
+ const depth = getMarkdownListDepth(bulletMatch[1] ?? "");
101698
+ return `${renderSlackBulletPrefix(depth)} ${renderInlineMarkdownToSlackMrkdwn(bulletMatch[2] ?? "")}`;
101266
101699
  }
101267
- const orderedMatch = line.match(/^\s*(\d+)\.\s+(.+)$/);
101700
+ const orderedMatch = line.match(/^(\s*)(\d+)\.\s+(.+)$/);
101268
101701
  if (orderedMatch) {
101269
- return `${orderedMatch[1]}. ${renderInlineMarkdownToSlackMrkdwn(orderedMatch[2] ?? "")}`;
101702
+ const depth = getMarkdownListDepth(orderedMatch[1] ?? "");
101703
+ return `${renderSlackListIndent(depth)}${orderedMatch[2]}. ${renderInlineMarkdownToSlackMrkdwn(orderedMatch[3] ?? "")}`;
101270
101704
  }
101271
101705
  return renderInlineMarkdownToSlackMrkdwn(line);
101272
101706
  }).join(`
@@ -101331,10 +101765,10 @@ function renderMarkdownTableToFallbackSlackBlock(headers, rows) {
101331
101765
  };
101332
101766
  }
101333
101767
  function renderMarkdownToSlackBlocks(markdown) {
101334
- const normalized = markdown.replaceAll(`\r
101768
+ const normalized = trimOuterBlankLines(markdown.replaceAll(`\r
101335
101769
  `, `
101336
101770
  `).replaceAll("\r", `
101337
- `).trim();
101771
+ `));
101338
101772
  if (!normalized) {
101339
101773
  return [];
101340
101774
  }
@@ -101368,7 +101802,7 @@ function renderMarkdownToSlackBlocks(markdown) {
101368
101802
  return;
101369
101803
  }
101370
101804
  const text = paragraph.join(`
101371
- `).trim();
101805
+ `).trimEnd();
101372
101806
  if (text) {
101373
101807
  const shouldRenderAsPreamble = !hasSeenHeading && firstHeadingLineIndex > 0 && blocks.length === 0;
101374
101808
  pushBlock({
@@ -101483,14 +101917,16 @@ ${codeLines.join(`
101483
101917
  }
101484
101918
  continue;
101485
101919
  }
101486
- const bulletMatch = line.match(/^\s*[-*+]\s+(.+)$/);
101920
+ const bulletMatch = line.match(/^(\s*)[-*+]\s+(.+)$/);
101487
101921
  if (bulletMatch) {
101488
- paragraph.push(`• ${renderInlineMarkdownToSlackMrkdwn(bulletMatch[1] ?? "")}`);
101922
+ const depth = getMarkdownListDepth(bulletMatch[1] ?? "");
101923
+ paragraph.push(`${renderSlackBulletPrefix(depth)} ${renderInlineMarkdownToSlackMrkdwn(bulletMatch[2] ?? "")}`);
101489
101924
  continue;
101490
101925
  }
101491
- const orderedMatch = line.match(/^\s*(\d+)\.\s+(.+)$/);
101926
+ const orderedMatch = line.match(/^(\s*)(\d+)\.\s+(.+)$/);
101492
101927
  if (orderedMatch) {
101493
- paragraph.push(`${orderedMatch[1]}. ${renderInlineMarkdownToSlackMrkdwn(orderedMatch[2] ?? "")}`);
101928
+ const depth = getMarkdownListDepth(orderedMatch[1] ?? "");
101929
+ paragraph.push(`${renderSlackListIndent(depth)}${orderedMatch[2]}. ${renderInlineMarkdownToSlackMrkdwn(orderedMatch[3] ?? "")}`);
101494
101930
  continue;
101495
101931
  }
101496
101932
  paragraph.push(renderInlineMarkdownToSlackMrkdwn(line));