codexuse-cli 6.1.0 → 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -7560,7 +7560,7 @@ function logInfo(...args2) {
7560
7560
  console.info(...args2);
7561
7561
  }
7562
7562
 
7563
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Pipeable.js
7563
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Pipeable.js
7564
7564
  var pipeArguments = (self, args2) => {
7565
7565
  switch (args2.length) {
7566
7566
  case 0:
@@ -7604,7 +7604,7 @@ var Class = /* @__PURE__ */ (function() {
7604
7604
  return PipeableBase;
7605
7605
  })();
7606
7606
 
7607
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Function.js
7607
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Function.js
7608
7608
  var dual = function(arity, body) {
7609
7609
  if (typeof arity === "function") {
7610
7610
  return function() {
@@ -7675,7 +7675,7 @@ function memoizeIdempotent(f) {
7675
7675
  };
7676
7676
  }
7677
7677
 
7678
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/equal.js
7678
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/equal.js
7679
7679
  var getAllObjectKeys = (obj) => {
7680
7680
  const keys4 = new Set(Reflect.ownKeys(obj));
7681
7681
  if (obj.constructor === Object) return keys4;
@@ -7698,7 +7698,7 @@ var getAllObjectKeys = (obj) => {
7698
7698
  };
7699
7699
  var byReferenceInstances = /* @__PURE__ */ new WeakSet();
7700
7700
 
7701
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Predicate.js
7701
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Predicate.js
7702
7702
  function isString(input) {
7703
7703
  return typeof input === "string";
7704
7704
  }
@@ -7746,7 +7746,7 @@ function isError(input) {
7746
7746
  return input instanceof Error;
7747
7747
  }
7748
7748
 
7749
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Hash.js
7749
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Hash.js
7750
7750
  var symbol = "~effect/interfaces/Hash";
7751
7751
  var hash = (self) => {
7752
7752
  switch (typeof self) {
@@ -7870,7 +7870,7 @@ function withVisitedTracking(obj, fn2) {
7870
7870
  return result2;
7871
7871
  }
7872
7872
 
7873
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Equal.js
7873
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Equal.js
7874
7874
  var symbol2 = "~effect/interfaces/Equal";
7875
7875
  function equals() {
7876
7876
  if (arguments.length === 1) {
@@ -8062,7 +8062,7 @@ function makeCompareSet(equivalence) {
8062
8062
  var compareSets = /* @__PURE__ */ makeCompareSet(compareBoth);
8063
8063
  var isEqual = (u) => hasProperty(u, symbol2);
8064
8064
 
8065
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Reducer.js
8065
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Reducer.js
8066
8066
  function make(combine2, initialValue, combineAll) {
8067
8067
  return {
8068
8068
  combine: combine2,
@@ -8077,7 +8077,7 @@ function make(combine2, initialValue, combineAll) {
8077
8077
  };
8078
8078
  }
8079
8079
 
8080
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Equivalence.js
8080
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Equivalence.js
8081
8081
  var make2 = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
8082
8082
  var isStrictEquivalent = (x, y) => x === y;
8083
8083
  var strictEqual = () => isStrictEquivalent;
@@ -8100,10 +8100,10 @@ function Struct(fields) {
8100
8100
  });
8101
8101
  }
8102
8102
 
8103
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/array.js
8103
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/array.js
8104
8104
  var isArrayNonEmpty = (self) => self.length > 0;
8105
8105
 
8106
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/record.js
8106
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/record.js
8107
8107
  function assignProperty(self, key, value3) {
8108
8108
  if (key === "__proto__") {
8109
8109
  Object.defineProperty(self, key, {
@@ -8125,14 +8125,14 @@ function assignProperties(self, source) {
8125
8125
  }
8126
8126
  }
8127
8127
 
8128
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Combiner.js
8128
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Combiner.js
8129
8129
  function make3(combine2) {
8130
8130
  return {
8131
8131
  combine: combine2
8132
8132
  };
8133
8133
  }
8134
8134
 
8135
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Redactable.js
8135
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Redactable.js
8136
8136
  var symbolRedactable = /* @__PURE__ */ Symbol.for("~effect/Redactable");
8137
8137
  var isRedactable = (u) => hasProperty(u, symbolRedactable);
8138
8138
  function redact(u) {
@@ -8154,7 +8154,7 @@ var emptyContext = {
8154
8154
  }
8155
8155
  };
8156
8156
 
8157
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Formatter.js
8157
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Formatter.js
8158
8158
  function format(input, options) {
8159
8159
  const space = options?.space ?? 0;
8160
8160
  const ancestors = /* @__PURE__ */ new WeakSet();
@@ -8255,7 +8255,7 @@ function formatJson(input, options) {
8255
8255
  }, options?.space) ?? "null";
8256
8256
  }
8257
8257
 
8258
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Inspectable.js
8258
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Inspectable.js
8259
8259
  var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
8260
8260
  var toJson = (input) => {
8261
8261
  try {
@@ -8308,7 +8308,7 @@ var Class2 = class {
8308
8308
  }
8309
8309
  };
8310
8310
 
8311
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Utils.js
8311
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Utils.js
8312
8312
  var SingleShotGen = class _SingleShotGen {
8313
8313
  called = false;
8314
8314
  self;
@@ -8368,7 +8368,7 @@ var pickInternalCall = () => {
8368
8368
  };
8369
8369
  var internalCall = /* @__PURE__ */ pickInternalCall();
8370
8370
 
8371
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/core.js
8371
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/core.js
8372
8372
  var EffectTypeId = `~effect/Effect`;
8373
8373
  var ExitTypeId = `~effect/Exit`;
8374
8374
  var effectVariance = {
@@ -8713,7 +8713,7 @@ var DoneVoid = {
8713
8713
  value: void 0
8714
8714
  };
8715
8715
 
8716
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/option.js
8716
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/option.js
8717
8717
  var TypeId = "~effect/data/Option";
8718
8718
  var CommonProto = {
8719
8719
  [TypeId]: {
@@ -8779,7 +8779,7 @@ var some = (value3) => {
8779
8779
  return a;
8780
8780
  };
8781
8781
 
8782
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/result.js
8782
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/result.js
8783
8783
  var TypeId2 = "~effect/data/Result";
8784
8784
  var CommonProto2 = {
8785
8785
  [TypeId2]: {
@@ -8846,7 +8846,7 @@ var succeed = (success) => {
8846
8846
  return a;
8847
8847
  };
8848
8848
 
8849
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Order.js
8849
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Order.js
8850
8850
  function make4(compare) {
8851
8851
  return (self, that) => self === that ? 0 : compare(self, that);
8852
8852
  }
@@ -8876,7 +8876,7 @@ var isGreaterThan = (O) => dual(2, (self, that) => O(self, that) === 1);
8876
8876
  var isLessThanOrEqualTo = (O) => dual(2, (self, that) => O(self, that) !== 1);
8877
8877
  var isGreaterThanOrEqualTo = (O) => dual(2, (self, that) => O(self, that) !== -1);
8878
8878
 
8879
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Option.js
8879
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Option.js
8880
8880
  var none2 = () => none;
8881
8881
  var some2 = some;
8882
8882
  var isOption2 = isOption;
@@ -8905,7 +8905,7 @@ var flatten = /* @__PURE__ */ flatMap(identity);
8905
8905
  var filter = /* @__PURE__ */ dual(2, (self, predicate) => isNone2(self) ? none2() : predicate(self.value) ? some2(self.value) : none2());
8906
8906
  var makeEquivalence = (isEquivalent) => make2((x, y) => isNone2(x) ? isNone2(y) : isNone2(y) ? false : isEquivalent(x.value, y.value));
8907
8907
 
8908
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Result.js
8908
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Result.js
8909
8909
  var succeed2 = succeed;
8910
8910
  var fail2 = fail;
8911
8911
  var try_ = (evaluate2) => {
@@ -8936,7 +8936,7 @@ var match2 = /* @__PURE__ */ dual(2, (self, {
8936
8936
  var getOrElse2 = /* @__PURE__ */ dual(2, (self, onFailure) => isFailure2(self) ? onFailure(self.failure) : self.success);
8937
8937
  var flatMap2 = /* @__PURE__ */ dual(2, (self, f) => isFailure2(self) ? fail2(self.failure) : f(self.success));
8938
8938
 
8939
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Record.js
8939
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Record.js
8940
8940
  var map3 = /* @__PURE__ */ dual(2, (self, f) => {
8941
8941
  const out = {
8942
8942
  ...self
@@ -8948,7 +8948,7 @@ var map3 = /* @__PURE__ */ dual(2, (self, f) => {
8948
8948
  });
8949
8949
  var keys = (self) => Object.keys(self);
8950
8950
 
8951
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Array.js
8951
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Array.js
8952
8952
  var Array2 = globalThis.Array;
8953
8953
  var fromIterable = (collection) => Array2.isArray(collection) ? collection : Array2.from(collection);
8954
8954
  var ensure = (self) => Array2.isArray(self) ? self : [self];
@@ -9022,7 +9022,7 @@ function makeReducerConcat() {
9022
9022
  return reducer;
9023
9023
  }
9024
9024
 
9025
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/BigDecimal.js
9025
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/BigDecimal.js
9026
9026
  var FINITE_INT_REGEXP = /^[+-]?\d+$/;
9027
9027
  var TypeId3 = "~effect/BigDecimal";
9028
9028
  var BigDecimalProto = {
@@ -9251,17 +9251,17 @@ var floor = /* @__PURE__ */ dual(isBigDecimalArgs, (self, scale2 = 0) => {
9251
9251
  return truncated;
9252
9252
  });
9253
9253
 
9254
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Boolean.js
9254
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Boolean.js
9255
9255
  var Boolean2 = globalThis.Boolean;
9256
9256
  var ReducerOr = /* @__PURE__ */ make((a, b) => a || b, false);
9257
9257
 
9258
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Effectable.js
9258
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Effectable.js
9259
9259
  var Prototype2 = (options) => makePrimitiveProto({
9260
9260
  op: options.label,
9261
9261
  [evaluate]: options.evaluate
9262
9262
  });
9263
9263
 
9264
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Context.js
9264
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Context.js
9265
9265
  var ServiceTypeId = "~effect/Context/Service";
9266
9266
  var Service = function() {
9267
9267
  function KeyClass() {
@@ -9438,7 +9438,7 @@ var serviceNotFoundError = (service2) => {
9438
9438
  };
9439
9439
  var Reference = Service;
9440
9440
 
9441
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Duration.js
9441
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Duration.js
9442
9442
  var TypeId5 = "~effect/time/Duration";
9443
9443
  var bigint02 = /* @__PURE__ */ BigInt(0);
9444
9444
  var bigint12 = /* @__PURE__ */ BigInt(1);
@@ -9696,7 +9696,7 @@ var Equivalence2 = (self, that) => matchPair(self, that, {
9696
9696
  });
9697
9697
  var equals3 = /* @__PURE__ */ dual(2, (self, that) => Equivalence2(self, that));
9698
9698
 
9699
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Scheduler.js
9699
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Scheduler.js
9700
9700
  var Scheduler = /* @__PURE__ */ Reference("effect/Scheduler", {
9701
9701
  fiberCached: true,
9702
9702
  defaultValue: () => new MixedScheduler()
@@ -9833,7 +9833,7 @@ var PreventSchedulerYield = /* @__PURE__ */ Reference("effect/Scheduler/PreventS
9833
9833
  defaultValue: () => false
9834
9834
  });
9835
9835
 
9836
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Data.js
9836
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Data.js
9837
9837
  var Class3 = class extends Class {
9838
9838
  constructor(props) {
9839
9839
  super();
@@ -9844,7 +9844,7 @@ var Class3 = class extends Class {
9844
9844
  };
9845
9845
  var TaggedError2 = TaggedError;
9846
9846
 
9847
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Encoding.js
9847
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Encoding.js
9848
9848
  var EncodingErrorTypeId = "~effect/encoding/EncodingError";
9849
9849
  var EncodingError = class extends (/* @__PURE__ */ TaggedError2("EncodingError")) {
9850
9850
  /**
@@ -10017,14 +10017,14 @@ var fromHexChar = (byte) => {
10017
10017
  throw new TypeError("Invalid input");
10018
10018
  };
10019
10019
 
10020
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Tracer.js
10020
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Tracer.js
10021
10021
  var ParentSpanKey = "effect/Tracer/ParentSpan";
10022
10022
  var TracerKey = "effect/Tracer";
10023
10023
 
10024
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/metric.js
10024
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/metric.js
10025
10025
  var FiberRuntimeMetricsKey = "effect/observability/Metric/FiberRuntimeMetricsKey";
10026
10026
 
10027
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/references.js
10027
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/references.js
10028
10028
  var CurrentStackFrame = /* @__PURE__ */ Reference("effect/References/CurrentStackFrame", {
10029
10029
  fiberCached: true,
10030
10030
  defaultValue: constUndefined
@@ -10038,7 +10038,7 @@ var MinimumLogLevel = /* @__PURE__ */ Reference("effect/References/MinimumLogLev
10038
10038
  defaultValue: () => "Info"
10039
10039
  });
10040
10040
 
10041
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/stackTraceLimit.js
10041
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/stackTraceLimit.js
10042
10042
  var isStackTraceLimitWritable = () => {
10043
10043
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
10044
10044
  if (desc === void 0) {
@@ -10055,7 +10055,7 @@ var setStackTraceLimit = (value3) => {
10055
10055
  }
10056
10056
  };
10057
10057
 
10058
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/effect.js
10058
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/effect.js
10059
10059
  var Interrupt = class extends ReasonBase {
10060
10060
  fiberId;
10061
10061
  constructor(fiberId2, annotations = constEmptyAnnotations) {
@@ -10886,7 +10886,7 @@ var iterateEagerImpl = (options) => {
10886
10886
  if (concurrency === 1) {
10887
10887
  return runSequential(state, items, 0, end);
10888
10888
  }
10889
- const orderedStep = opts?.orderedStep === true && concurrency > 1;
10889
+ const orderedStep = opts?.orderedStep === true;
10890
10890
  let done2 = false;
10891
10891
  let parentFiber;
10892
10892
  let fibers;
@@ -11153,7 +11153,7 @@ var logLevelColors = {
11153
11153
  Fatal: [colors.bgBrightRed, colors.black]
11154
11154
  };
11155
11155
 
11156
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Cause.js
11156
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Cause.js
11157
11157
  var isCause2 = isCause;
11158
11158
  var isReason = isCauseReason;
11159
11159
  var isFailReason2 = isFailReason;
@@ -11166,7 +11166,7 @@ var map6 = causeMap;
11166
11166
  var pretty = causePretty;
11167
11167
  var IllegalArgumentError2 = IllegalArgumentError;
11168
11168
 
11169
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Exit.js
11169
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Exit.js
11170
11170
  var isExit2 = isExit;
11171
11171
  var succeed4 = exitSucceed;
11172
11172
  var failCause2 = exitFailCause;
@@ -11175,7 +11175,7 @@ var void_2 = exitVoid;
11175
11175
  var isSuccess3 = exitIsSuccess;
11176
11176
  var isFailure3 = exitIsFailure;
11177
11177
 
11178
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/dateTime.js
11178
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/dateTime.js
11179
11179
  var TypeId6 = "~effect/time/DateTime";
11180
11180
  var TimeZoneTypeId = "~effect/time/DateTime/TimeZone";
11181
11181
  var Proto2 = {
@@ -11569,7 +11569,7 @@ var formatIsoOffset = (self) => {
11569
11569
  };
11570
11570
  var formatIsoZoned = (self) => self.zone._tag === "Offset" ? formatIsoOffset(self) : `${formatIsoOffset(self)}[${self.zone.id}]`;
11571
11571
 
11572
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Number.js
11572
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Number.js
11573
11573
  var Number3 = globalThis.Number;
11574
11574
  var remainder = /* @__PURE__ */ dual(2, (self, divisor) => {
11575
11575
  const selfString = self.toString();
@@ -11610,17 +11610,18 @@ function toScientificInteger(n) {
11610
11610
  var ReducerMax = /* @__PURE__ */ make((a, b) => Math.max(a, b), -Infinity);
11611
11611
  var ReducerMin = /* @__PURE__ */ make((a, b) => Math.min(a, b), Infinity);
11612
11612
 
11613
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/String.js
11613
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/String.js
11614
11614
  var String2 = globalThis.String;
11615
11615
  var trim = (self) => self.trim();
11616
11616
 
11617
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Effect.js
11617
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Effect.js
11618
11618
  var tryPromise2 = tryPromise;
11619
11619
  var succeed5 = succeed3;
11620
11620
  var succeedNone2 = succeedNone;
11621
11621
  var void_3 = void_;
11622
11622
  var fail5 = fail3;
11623
11623
  var failCauseSync2 = failCauseSync;
11624
+ var die2 = die;
11624
11625
  var try_3 = try_2;
11625
11626
  var fromResult2 = fromResult;
11626
11627
  var flatMap4 = flatMap3;
@@ -11638,7 +11639,7 @@ var flatMapEager2 = flatMapEager;
11638
11639
  var catchEager2 = catchEager;
11639
11640
  var fnUntracedEager2 = fnUntracedEager;
11640
11641
 
11641
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/annotations.js
11642
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/annotations.js
11642
11643
  function resolve(ast) {
11643
11644
  return ast.checks ? ast.checks[ast.checks.length - 1].annotations : ast.annotations;
11644
11645
  }
@@ -11661,7 +11662,7 @@ var getExpected = /* @__PURE__ */ memoize((ast) => {
11661
11662
  });
11662
11663
  var annotationExcludedKeys = /* @__PURE__ */ new Set([SENTINELS_ANNOTATION_KEY, STRUCTURAL_ANNOTATION_KEY, "representation", "arbitrary", "brands", "toJsonSchema", "toCode", "toArbitrary", "toEquivalence", "toFormatter", "toCodec", "toCodecJson", "toCodecStringTree", "toCodecIso"]);
11663
11664
 
11664
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/parser.js
11665
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/parser.js
11665
11666
  var missing = /* @__PURE__ */ Symbol();
11666
11667
  var succeed6 = succeed4;
11667
11668
  var missingExit = /* @__PURE__ */ succeed6(missing);
@@ -11669,7 +11670,7 @@ var sameExit = /* @__PURE__ */ succeed6(missing);
11669
11670
  var toOption = (value3) => value3 === missing ? none2() : some2(value3);
11670
11671
  var fromOptionExit = (option2) => option2._tag === "None" ? missingExit : succeed6(option2.value);
11671
11672
 
11672
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/SchemaIssue.js
11673
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/SchemaIssue.js
11673
11674
  var TypeId7 = "~effect/SchemaIssue/Issue";
11674
11675
  function isIssue(u) {
11675
11676
  return hasProperty(u, TypeId7) && u[TypeId7] === TypeId7;
@@ -12012,7 +12013,7 @@ function findMessage(issue) {
12012
12013
  if (typeof message === "string") return message;
12013
12014
  }
12014
12015
 
12015
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/cause.js
12016
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/cause.js
12016
12017
  function getSchemaIssue(cause) {
12017
12018
  let issue;
12018
12019
  for (const reason of cause.reasons) {
@@ -12033,7 +12034,7 @@ function getSchemaIssueOrThrow(cause, message) {
12033
12034
  return issue;
12034
12035
  }
12035
12036
 
12036
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/DateTime.js
12037
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/DateTime.js
12037
12038
  var isDateTime2 = isDateTime;
12038
12039
  var isTimeZone2 = isTimeZone;
12039
12040
  var isTimeZoneOffset2 = isTimeZoneOffset;
@@ -12057,7 +12058,7 @@ var toEpochMillis2 = toEpochMillis;
12057
12058
  var formatIso2 = formatIso;
12058
12059
  var formatIsoZoned2 = formatIsoZoned;
12059
12060
 
12060
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/SchemaGetter.js
12061
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/SchemaGetter.js
12061
12062
  var Getter = class _Getter extends Class {
12062
12063
  run;
12063
12064
  constructor(run2) {
@@ -12344,7 +12345,7 @@ function collectBracketPathEntries(isLeaf) {
12344
12345
  };
12345
12346
  }
12346
12347
 
12347
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/SchemaTransformation.js
12348
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/SchemaTransformation.js
12348
12349
  var Middleware = class _Middleware {
12349
12350
  _tag = "Middleware";
12350
12351
  decode;
@@ -12585,7 +12586,7 @@ var dateTimeZonedFromString = /* @__PURE__ */ transformOrFail2({
12585
12586
  encode: (zoned) => succeed5(formatIsoZoned2(zoned))
12586
12587
  });
12587
12588
 
12588
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/SchemaAST.js
12589
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/SchemaAST.js
12589
12590
  function makeGuard(tag2) {
12590
12591
  return (ast) => ast._tag === tag2;
12591
12592
  }
@@ -12641,11 +12642,17 @@ var Declaration = class _Declaration extends Base2 {
12641
12642
  typeParameters;
12642
12643
  run;
12643
12644
  encodingChecks;
12644
- constructor(typeParameters, run2, annotations, checks, encoding, context2, encodingChecks) {
12645
+ /**
12646
+ * Parser factory {@link flip} swaps in, so a declaration can behave
12647
+ * differently when encoding. `undefined` reuses {@link run}.
12648
+ */
12649
+ encodingRun;
12650
+ constructor(typeParameters, run2, annotations, checks, encoding, context2, encodingChecks, encodingRun) {
12645
12651
  super(annotations, checks, encoding, context2);
12646
12652
  this.typeParameters = typeParameters;
12647
12653
  this.run = run2;
12648
12654
  this.encodingChecks = encodingChecks;
12655
+ this.encodingRun = encodingRun;
12649
12656
  }
12650
12657
  /** @internal */
12651
12658
  getParser() {
@@ -12655,17 +12662,17 @@ var Declaration = class _Declaration extends Base2 {
12655
12662
  return (run2 ??= this.run(this.typeParameters))(input, this, options);
12656
12663
  };
12657
12664
  }
12658
- _rebuild(recur3, checks, encodingChecks) {
12665
+ _rebuild(recur3, checks, encodingChecks, run2, encodingRun) {
12659
12666
  const tps = mapOrSame(this.typeParameters, recur3);
12660
- return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks ? this : new _Declaration(tps, this.run, this.annotations, checks, void 0, this.context, encodingChecks);
12667
+ return tps === this.typeParameters && checks === this.checks && encodingChecks === this.encodingChecks && run2 === this.run && encodingRun === this.encodingRun ? this : new _Declaration(tps, run2, this.annotations, checks, void 0, this.context, encodingChecks, encodingRun);
12661
12668
  }
12662
12669
  /** @internal */
12663
12670
  recur(recur3) {
12664
- return this._rebuild(recur3, this.checks, this.encodingChecks);
12671
+ return this._rebuild(recur3, this.checks, this.encodingChecks, this.run, this.encodingRun);
12665
12672
  }
12666
12673
  /** @internal */
12667
12674
  flip(recur3) {
12668
- return this._rebuild(recur3, this.encodingChecks, this.checks);
12675
+ return this._rebuild(recur3, this.encodingChecks, this.checks, this.encodingRun ?? this.run, this.run);
12669
12676
  }
12670
12677
  /** @internal */
12671
12678
  getExpected() {
@@ -13332,13 +13339,7 @@ var Objects = class _Objects extends Base2 {
13332
13339
  onItem: (s, [key, index2]) => parseIndex(s, key, index2),
13333
13340
  step: (_s, _, exit3) => exit3._tag === "Failure" ? exit3 : void 0
13334
13341
  }) : void 0;
13335
- return fnUntracedEager2(function* (input, options) {
13336
- if (input === missing) {
13337
- return missing;
13338
- }
13339
- if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
13340
- return yield* fail5(new InvalidType(ast, input, options));
13341
- }
13342
+ const compileMembers = () => {
13342
13343
  if (!properties) {
13343
13344
  properties = ast.propertySignatures.map((ps) => ({
13344
13345
  parser: compileConstructorDefault2(ps.type),
@@ -13351,6 +13352,16 @@ var Objects = class _Objects extends Base2 {
13351
13352
  parserValue: compileConstructorDefault2(is3.type)
13352
13353
  })) : void 0;
13353
13354
  }
13355
+ return properties;
13356
+ };
13357
+ const fallback = fnUntracedEager2(function* (input, options) {
13358
+ if (input === missing) {
13359
+ return missing;
13360
+ }
13361
+ if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
13362
+ return yield* fail5(new InvalidType(ast, input, options));
13363
+ }
13364
+ compileMembers();
13354
13365
  const record2 = input;
13355
13366
  const out = {};
13356
13367
  const state = {
@@ -13432,6 +13443,57 @@ var Objects = class _Objects extends Base2 {
13432
13443
  }
13433
13444
  return out;
13434
13445
  });
13446
+ if (indexCount) return fallback;
13447
+ const resume = (state, index2, pending) => {
13448
+ const property = properties[index2];
13449
+ return flatMap4(exit2(pending), (exit3) => {
13450
+ const terminal = stepProperty(state, property, exit3);
13451
+ if (terminal) return terminal;
13452
+ const done2 = () => succeed6(state.out);
13453
+ const eff = parseProperties(state, properties.slice(index2 + 1));
13454
+ return eff ? flatMapEager2(eff, done2) : done2();
13455
+ });
13456
+ };
13457
+ return (input, options) => {
13458
+ if (input === missing) return missingExit;
13459
+ if (options.errors === "all" || options.onExcessProperty !== void 0 || options.propertyOrder === "original" || options.concurrency !== void 0) {
13460
+ return fallback(input, options);
13461
+ }
13462
+ if (!(typeof input === "object" && input !== null && !Array.isArray(input))) {
13463
+ return fail5(new InvalidType(ast, input, options));
13464
+ }
13465
+ const props = compileMembers();
13466
+ const record2 = input;
13467
+ const out = {};
13468
+ const state = {
13469
+ ast,
13470
+ input: record2,
13471
+ out,
13472
+ issues: void 0,
13473
+ options
13474
+ };
13475
+ try {
13476
+ for (let index2 = 0; index2 < props.length; index2++) {
13477
+ const property = props[index2];
13478
+ const name = property.name;
13479
+ const hasKey2 = Object.hasOwn(record2, name);
13480
+ const value3 = hasKey2 ? record2[name] : missing;
13481
+ const exit3 = property.parser(value3, options);
13482
+ if (!effectIsExit(exit3)) {
13483
+ return resume(state, index2, exit3);
13484
+ }
13485
+ if (exit3 === sameExit) {
13486
+ if (hasKey2) assignProperty(out, name, value3);
13487
+ continue;
13488
+ }
13489
+ const terminal = stepProperty(state, property, exit3);
13490
+ if (terminal) return terminal;
13491
+ }
13492
+ } catch (error) {
13493
+ return die2(error);
13494
+ }
13495
+ return succeed6(out);
13496
+ };
13435
13497
  }
13436
13498
  _rebuild(recur3, recurParameter, checks, encodingChecks) {
13437
13499
  const props = mapOrSame(this.propertySignatures, (ps) => {
@@ -13459,6 +13521,28 @@ var Objects = class _Objects extends Base2 {
13459
13521
  return "object";
13460
13522
  }
13461
13523
  };
13524
+ function stepProperty(s, p, exit3) {
13525
+ if (exit3._tag === "Failure") {
13526
+ return wrapPropertyKeyIssue(s, s.ast, p.name, exit3);
13527
+ }
13528
+ if (exit3 === sameExit) return;
13529
+ const value3 = exit3[args];
13530
+ if (value3 !== missing) {
13531
+ assignProperty(s.out, p.name, value3);
13532
+ return;
13533
+ }
13534
+ delete s.out[p.name];
13535
+ if (!isOptional(p.type)) {
13536
+ const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations));
13537
+ if (s.options.errors === "all") {
13538
+ if (s.issues) s.issues.push(issue);
13539
+ else s.issues = [issue];
13540
+ return;
13541
+ } else {
13542
+ return fail4(new Composite(s.ast, [issue], s.input, s.options));
13543
+ }
13544
+ }
13545
+ }
13462
13546
  var parseProperties = /* @__PURE__ */ iterateEager()({
13463
13547
  onItem(s, p) {
13464
13548
  if (!Object.hasOwn(s.input, p.name)) {
@@ -13468,28 +13552,7 @@ var parseProperties = /* @__PURE__ */ iterateEager()({
13468
13552
  assignProperty(s.out, p.name, value3);
13469
13553
  return p.parser(value3, s.options);
13470
13554
  },
13471
- step(s, p, exit3) {
13472
- if (exit3._tag === "Failure") {
13473
- return wrapPropertyKeyIssue(s, s.ast, p.name, exit3);
13474
- }
13475
- if (exit3 === sameExit) return;
13476
- const value3 = exit3[args];
13477
- if (value3 !== missing) {
13478
- assignProperty(s.out, p.name, value3);
13479
- return;
13480
- }
13481
- delete s.out[p.name];
13482
- if (!isOptional(p.type)) {
13483
- const issue = new Pointer([p.name], new MissingKey(p.type.context?.annotations));
13484
- if (s.options.errors === "all") {
13485
- if (s.issues) s.issues.push(issue);
13486
- else s.issues = [issue];
13487
- return;
13488
- } else {
13489
- return fail4(new Composite(s.ast, [issue], s.input, s.options));
13490
- }
13491
- }
13492
- }
13555
+ step: stepProperty
13493
13556
  });
13494
13557
  function combineChecks(a, b) {
13495
13558
  if (!a) return b;
@@ -14572,7 +14635,7 @@ var StringTree = /* @__PURE__ */ new Declaration([], () => (input, ast, options)
14572
14635
  });
14573
14636
  var unknownToStringTree = /* @__PURE__ */ new Link(StringTree, /* @__PURE__ */ passthrough2());
14574
14637
 
14575
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Chunk.js
14638
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Chunk.js
14576
14639
  var TypeId10 = "~effect/collections/Chunk";
14577
14640
  function copy(src, srcPos, dest, destPos, len) {
14578
14641
  for (let i = srcPos; i < Math.min(src.length, srcPos + len); i++) {
@@ -14756,7 +14819,7 @@ var getUnsafe2 = /* @__PURE__ */ dual(2, (self, index2) => {
14756
14819
  });
14757
14820
  var size = (self) => self.length;
14758
14821
 
14759
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Schema.js
14822
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Schema.js
14760
14823
  var Schema_exports = {};
14761
14824
  __export(Schema_exports, {
14762
14825
  Any: () => Any2,
@@ -15109,7 +15172,7 @@ __export(Schema_exports, {
15109
15172
  withDecodingDefaultTypeKey: () => withDecodingDefaultTypeKey
15110
15173
  });
15111
15174
 
15112
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/graph.js
15175
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/graph.js
15113
15176
  var TypeId11 = "~effect/collections/Graph";
15114
15177
  var toImpl = (graph) => graph;
15115
15178
  var edgeEquals = (type, self, that) => (type === "directed" ? self.source === that.source && self.target === that.target : self.source === that.source && self.target === that.target || self.source === that.target && self.target === that.source) && equals(self.data, that.data);
@@ -15230,7 +15293,7 @@ var hydrate = (snapshot2) => {
15230
15293
  return graph;
15231
15294
  };
15232
15295
 
15233
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Graph.js
15296
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Graph.js
15234
15297
  var TypeId12 = TypeId11;
15235
15298
  var isGraph = (u) => hasProperty(u, TypeId12);
15236
15299
  var EdgeIdentity = class _EdgeIdentity {
@@ -15259,7 +15322,7 @@ var EdgeIdentity = class _EdgeIdentity {
15259
15322
  }
15260
15323
  };
15261
15324
 
15262
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/hashMap.js
15325
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/hashMap.js
15263
15326
  var HashMapTypeId = "~effect/collections/HashMap";
15264
15327
  var SHIFT = 5;
15265
15328
  var BUCKET_SIZE = 1 << SHIFT;
@@ -15901,14 +15964,14 @@ var entries = (self) => {
15901
15964
  };
15902
15965
  var size2 = (self) => self.size;
15903
15966
 
15904
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/HashMap.js
15967
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/HashMap.js
15905
15968
  var isHashMap2 = isHashMap;
15906
15969
  var fromIterable4 = fromIterable3;
15907
15970
  var entries2 = entries;
15908
15971
  var toEntries = (self) => Array.from(entries2(self));
15909
15972
  var size3 = size2;
15910
15973
 
15911
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/hashSet.js
15974
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/hashSet.js
15912
15975
  var HashSetTypeId = "~effect/collections/HashSet";
15913
15976
  var HashSetProto = {
15914
15977
  [symbol]() {
@@ -15962,12 +16025,12 @@ var every2 = (self, predicate) => {
15962
16025
  return true;
15963
16026
  };
15964
16027
 
15965
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/HashSet.js
16028
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/HashSet.js
15966
16029
  var fromIterable6 = fromIterable5;
15967
16030
  var isHashSet2 = isHashSet;
15968
16031
  var size5 = size4;
15969
16032
 
15970
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/SchemaParser.js
16033
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/SchemaParser.js
15971
16034
  function makeEffect(schema) {
15972
16035
  const parser = runWithCompiler(constructorCompiler, toType(schema.ast));
15973
16036
  return (input, options) => {
@@ -16265,7 +16328,7 @@ function makeParser(ast, compile, compileConstructorDefault2, constructorDefault
16265
16328
  };
16266
16329
  }
16267
16330
 
16268
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/schema.js
16331
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/schema.js
16269
16332
  var TypeId13 = "~effect/Schema/Schema";
16270
16333
  function makeDeclarationReviver(id2, payloadSchema, revive) {
16271
16334
  return {
@@ -16310,7 +16373,7 @@ function make15(ast, options) {
16310
16373
  return self;
16311
16374
  }
16312
16375
 
16313
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Struct.js
16376
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Struct.js
16314
16377
  var Struct_exports = {};
16315
16378
  __export(Struct_exports, {
16316
16379
  Record: () => Record,
@@ -16413,7 +16476,7 @@ function Record(keys4, value3) {
16413
16476
  return out;
16414
16477
  }
16415
16478
 
16416
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/UndefinedOr.js
16479
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/UndefinedOr.js
16417
16480
  function makeReducer2(combiner2) {
16418
16481
  return make((self, that) => {
16419
16482
  if (self === void 0) return that;
@@ -16422,7 +16485,7 @@ function makeReducer2(combiner2) {
16422
16485
  }, void 0);
16423
16486
  }
16424
16487
 
16425
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/errors.js
16488
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/errors.js
16426
16489
  function errorWithPath(message, path21) {
16427
16490
  if (path21.length > 0) {
16428
16491
  message += `
@@ -16431,7 +16494,7 @@ function errorWithPath(message, path21) {
16431
16494
  return new Error(message);
16432
16495
  }
16433
16496
 
16434
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/toArbitrary.js
16497
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/toArbitrary.js
16435
16498
  var arbitraryMemoMap = /* @__PURE__ */ new WeakMap();
16436
16499
  var suspendDepthIdentifierMap = /* @__PURE__ */ new WeakMap();
16437
16500
  var emptyRecursionStack = [];
@@ -17093,7 +17156,7 @@ function base(ast, path21) {
17093
17156
  }
17094
17157
  }
17095
17158
 
17096
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/toEquivalence.js
17159
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/toEquivalence.js
17097
17160
  var toEquivalence = /* @__PURE__ */ memoize((ast) => {
17098
17161
  return recur2(ast, []);
17099
17162
  });
@@ -17216,7 +17279,7 @@ function recur2(ast, path21) {
17216
17279
  }
17217
17280
  }
17218
17281
 
17219
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/JsonPointer.js
17282
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/JsonPointer.js
17220
17283
  function escapeToken(token) {
17221
17284
  return token.replace(/~/g, "~0").replace(/\//g, "~1");
17222
17285
  }
@@ -17224,73 +17287,23 @@ function unescapeToken(token) {
17224
17287
  return token.replace(/~1/g, "/").replace(/~0/g, "~");
17225
17288
  }
17226
17289
 
17227
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/JsonSchema.js
17228
- var RE_DEFS = /^#\/\$defs(?=\/|$)/;
17229
- var DRAFT_04_COPY_KEYWORDS = /* @__PURE__ */ new Set(["$ref", "type", "required", "enum", "title", "description", "default", "format", "pattern", "minLength", "maxLength", "minItems", "maxItems", "minProperties", "maxProperties", "multipleOf", "uniqueItems"]);
17230
- var DRAFT_07_COPY_KEYWORDS = /* @__PURE__ */ new Set([...DRAFT_04_COPY_KEYWORDS, "const", "examples", "readOnly", "writeOnly", "minimum", "maximum", "exclusiveMinimum", "exclusiveMaximum"]);
17231
- var DRAFT_07_SINGLE_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set(["not", "additionalProperties", "propertyNames"]);
17232
- var MAP_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set(["properties", "patternProperties"]);
17233
- var ARRAY_SUBSCHEMA_KEYWORDS = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf"]);
17290
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/JsonSchema.js
17291
+ var META_SCHEMA_URI_DRAFT_07 = "http://json-schema.org/draft-07/schema#";
17292
+ var META_SCHEMA_URI_DRAFT_2020_12 = "https://json-schema.org/draft/2020-12/schema";
17293
+ function isMetaSchemaUri(value3, uri) {
17294
+ return value3 === uri || value3 === (uri.endsWith("#") ? uri.slice(0, -1) : `${uri}#`);
17295
+ }
17234
17296
  function toDocumentDraft07(document) {
17235
17297
  return {
17236
17298
  dialect: "draft-07",
17237
- schema: toSchemaDraft07(document.schema),
17238
- definitions: map3(document.definitions, toSchemaDraft07)
17299
+ ...convertDocument(document, draft07Adapter)
17239
17300
  };
17240
17301
  }
17241
- function toSchemaDraft07(schema) {
17242
- return transformSchema(schema, (src) => {
17243
- rewriteSchemaRef(src, (ref) => ref.replace(RE_DEFS, "#/definitions"));
17244
- const out = {};
17245
- let prefixItems = void 0;
17246
- let items = void 0;
17247
- for (const k of Object.keys(src)) {
17248
- const v = src[k];
17249
- if (k === "required" && Array.isArray(v) && v.length === 0) continue;
17250
- if (DRAFT_07_COPY_KEYWORDS.has(k)) {
17251
- out[k] = v;
17252
- continue;
17253
- }
17254
- if (MAP_SUBSCHEMA_KEYWORDS.has(k) || ARRAY_SUBSCHEMA_KEYWORDS.has(k) || DRAFT_07_SINGLE_SUBSCHEMA_KEYWORDS.has(k)) {
17255
- out[k] = v;
17256
- continue;
17257
- }
17258
- switch (k) {
17259
- // Tuple handling (2020-12 form)
17260
- case "prefixItems":
17261
- prefixItems = v;
17262
- break;
17263
- case "items":
17264
- items = v;
17265
- break;
17266
- default:
17267
- break;
17268
- }
17269
- }
17270
- if (prefixItems !== void 0) {
17271
- if (Array.isArray(prefixItems)) {
17272
- out.items = prefixItems;
17273
- if (items !== void 0) out.additionalItems = items;
17274
- } else {
17275
- out.items = prefixItems;
17276
- }
17277
- } else if (items !== void 0) {
17278
- out.items = items;
17279
- }
17280
- const $ref = out.$ref;
17281
- if (typeof $ref === "string" && Object.keys(out).length > 1) {
17282
- delete out.$ref;
17283
- out.allOf = [{
17284
- $ref
17285
- }, ...Array.isArray(out.allOf) ? out.allOf : []];
17286
- }
17287
- return out;
17288
- });
17289
- }
17290
17302
  function transformSchema(node, transform3) {
17291
- return walk(node);
17292
- function walk(node2) {
17303
+ return walk(node, false, true);
17304
+ function walk(node2, inheritedResource, isRoot = false) {
17293
17305
  if (!isObject(node2)) return node2;
17306
+ const inEmbeddedResource = inheritedResource || !isRoot && createsResource(node2.$id);
17294
17307
  const out = {};
17295
17308
  for (const key of Object.keys(node2)) {
17296
17309
  const value3 = node2[key];
@@ -17300,13 +17313,13 @@ function transformSchema(node, transform3) {
17300
17313
  case "properties":
17301
17314
  case "patternProperties":
17302
17315
  case "dependentSchemas":
17303
- transformed = mapObject(value3, walk) ?? value3;
17316
+ transformed = mapObject(value3, (value4) => walk(value4, inEmbeddedResource)) ?? value3;
17304
17317
  break;
17305
17318
  case "allOf":
17306
17319
  case "anyOf":
17307
17320
  case "oneOf":
17308
17321
  case "prefixItems":
17309
- transformed = Array.isArray(value3) ? value3.map(walk) : value3;
17322
+ transformed = Array.isArray(value3) ? value3.map((value4) => walk(value4, inEmbeddedResource)) : value3;
17310
17323
  break;
17311
17324
  case "not":
17312
17325
  case "additionalProperties":
@@ -17319,31 +17332,340 @@ function transformSchema(node, transform3) {
17319
17332
  case "then":
17320
17333
  case "else":
17321
17334
  case "contentSchema":
17322
- transformed = walk(value3);
17335
+ transformed = walk(value3, inEmbeddedResource);
17323
17336
  }
17324
17337
  assignProperty(out, key, transformed);
17325
17338
  }
17326
- return transform3(out);
17339
+ transform3(out, inEmbeddedResource);
17340
+ return out;
17327
17341
  }
17328
17342
  }
17329
17343
  function rewriteRefs(schema, rewrite) {
17330
- return transformSchema(schema, (schema2) => rewriteSchemaRef(schema2, rewrite));
17344
+ return transformSchema(schema, (schema2) => {
17345
+ rewriteSchemaRef(schema2, rewrite);
17346
+ });
17331
17347
  }
17332
17348
  function rewriteSchemaRef(schema, rewrite) {
17333
17349
  if (typeof schema.$ref === "string") {
17334
- assignProperty(schema, "$ref", rewrite(schema.$ref));
17350
+ assignProperty(schema, "$ref", rewrite(schema.$ref, "$ref"));
17351
+ }
17352
+ if (typeof schema.$dynamicRef === "string") {
17353
+ assignProperty(schema, "$dynamicRef", rewrite(schema.$dynamicRef, "$dynamicRef"));
17335
17354
  }
17336
- return schema;
17337
17355
  }
17338
17356
  function mapObject(value3, f) {
17339
- return isObject(value3) ? map3(value3, f) : void 0;
17357
+ if (!isObject(value3)) return void 0;
17358
+ const out = {};
17359
+ for (const key of Object.keys(value3)) {
17360
+ assignProperty(out, key, f(value3[key], key));
17361
+ }
17362
+ return out;
17363
+ }
17364
+ function runConverter(adapter, options, use) {
17365
+ const locations = /* @__PURE__ */ new Map();
17366
+ const references = [];
17367
+ let rootUri = ROOT_URI;
17368
+ function convert(root, sourcePath = [], targetPath = []) {
17369
+ if (sourcePath.length === 0 && options?.trackIds) {
17370
+ const id2 = isObject(root) ? getResourceId(root) : void 0;
17371
+ rootUri = resolveResourceUri(id2, ROOT_URI) ?? ROOT_URI;
17372
+ }
17373
+ return loop(root, sourcePath, targetPath, {
17374
+ sourceRoot: [],
17375
+ targetRoot: [],
17376
+ uri: rootUri
17377
+ });
17378
+ }
17379
+ function finish() {
17380
+ for (const [out2, value3, sourceResource] of references) {
17381
+ let reference = value3;
17382
+ const resolved = resolveUrl(value3, sourceResource);
17383
+ if (resolved !== void 0) {
17384
+ const sourcePointer = parsePointerFragment(resolved.hash);
17385
+ resolved.hash = "";
17386
+ if (sourcePointer !== void 0) {
17387
+ const targetPath = locations.get(locationKey(resolved.href, sourcePointer));
17388
+ if (targetPath !== void 0) reference = relocateReference(value3, targetPath);
17389
+ }
17390
+ }
17391
+ assignProperty(out2, "$ref", reference);
17392
+ }
17393
+ }
17394
+ const out = use(convert);
17395
+ finish();
17396
+ return out;
17397
+ function loop(node, sourcePath, targetPath, resourceScope) {
17398
+ if (typeof node === "boolean") {
17399
+ recordLocations(sourcePath, targetPath, resourceScope);
17400
+ return options?.booleanAdapter?.(node) ?? node;
17401
+ }
17402
+ if (!isObject(node)) return node;
17403
+ let currentResourceScope = resourceScope;
17404
+ const id2 = getResourceId(node);
17405
+ if (sourcePath.length > 0 && options?.trackIds && createsResource(id2)) {
17406
+ const uri = resolveResourceUri(id2, resourceScope.uri);
17407
+ if (uri !== void 0) {
17408
+ currentResourceScope = {
17409
+ parent: resourceScope,
17410
+ sourceRoot: sourcePath,
17411
+ targetRoot: targetPath,
17412
+ uri
17413
+ };
17414
+ }
17415
+ }
17416
+ recordLocations(sourcePath, targetPath, currentResourceScope);
17417
+ const currentResource = currentResourceScope.uri;
17418
+ const context2 = {
17419
+ isDocumentRoot: sourcePath.length === 0,
17420
+ schema(value3, sourceKey, targetKey = sourceKey) {
17421
+ return loop(value3, [...sourcePath, sourceKey], [...targetPath, targetKey], currentResourceScope);
17422
+ },
17423
+ schemaAt(value3, sourceSuffix, targetSuffix) {
17424
+ return loop(value3, [...sourcePath, ...sourceSuffix], [...targetPath, ...targetSuffix], currentResourceScope);
17425
+ },
17426
+ schemaArray(value3, sourceKey, targetKey = sourceKey) {
17427
+ return Array.isArray(value3) ? value3.map((item, index2) => loop(item, [...sourcePath, sourceKey, String(index2)], [...targetPath, targetKey, String(index2)], currentResourceScope)) : value3;
17428
+ },
17429
+ schemaMap(value3, sourceKey, targetKey = sourceKey) {
17430
+ if (!isObject(value3)) return value3;
17431
+ return mapObject(value3, (item, key) => loop(item, [...sourcePath, sourceKey, key], [...targetPath, targetKey, key], currentResourceScope));
17432
+ },
17433
+ reference(out2, value3) {
17434
+ if (typeof value3 === "string") {
17435
+ references.push([out2, value3, currentResource]);
17436
+ } else {
17437
+ assignProperty(out2, "$ref", value3);
17438
+ }
17439
+ }
17440
+ };
17441
+ return adapter(node, context2);
17442
+ }
17443
+ function getResourceId(schema) {
17444
+ return options?.ignoreRefSiblings === true && typeof schema.$ref === "string" ? void 0 : schema.$id;
17445
+ }
17446
+ function recordLocations(sourcePath, targetPath, scope2) {
17447
+ if (scope2.parent !== void 0) recordLocations(sourcePath, targetPath, scope2.parent);
17448
+ locations.set(locationKey(scope2.uri, sourcePath.slice(scope2.sourceRoot.length)), targetPath.slice(scope2.targetRoot.length));
17449
+ }
17450
+ }
17451
+ var ROOT_URI = "https://effect.invalid/.json-schema/";
17452
+ function resolveUrl(value3, base2) {
17453
+ return URL.canParse(value3, base2) ? new URL(value3, base2) : void 0;
17454
+ }
17455
+ function resolveResourceUri(value3, base2) {
17456
+ if (typeof value3 !== "string") return void 0;
17457
+ const url = resolveUrl(value3, base2);
17458
+ if (url === void 0) return void 0;
17459
+ url.hash = "";
17460
+ return url.href;
17461
+ }
17462
+ function parsePointerFragment(hash2) {
17463
+ if (hash2.length === 0) return [];
17464
+ let pointer;
17465
+ try {
17466
+ pointer = decodeURIComponent(hash2.slice(1));
17467
+ } catch {
17468
+ return void 0;
17469
+ }
17470
+ if (!pointer.startsWith("/")) return void 0;
17471
+ return /~(?:[^01]|$)/.test(pointer) ? void 0 : pointer.slice(1).split("/").map(unescapeToken);
17472
+ }
17473
+ function relocateReference(reference, targetPath) {
17474
+ const index2 = reference.indexOf("#");
17475
+ if (index2 === -1 && targetPath.length === 0) return reference;
17476
+ const uri = index2 === -1 ? reference : reference.slice(0, index2);
17477
+ return `${uri}${formatPointerFragment(targetPath)}`;
17478
+ }
17479
+ function formatPointerFragment(path21) {
17480
+ return path21.length === 0 ? "#" : `#/${path21.map((token) => encodeURI(escapeToken(token)).replace(/#/g, "%23")).join("/")}`;
17481
+ }
17482
+ function locationKey(resource, pointer) {
17483
+ return `${resource}\0${JSON.stringify(pointer)}`;
17484
+ }
17485
+ function createsResource(id2) {
17486
+ return typeof id2 === "string" && id2.length > 0 && id2[0] !== "#";
17487
+ }
17488
+ function convertDocument(document, adapter, options) {
17489
+ return runConverter(adapter, {
17490
+ ...options,
17491
+ trackIds: true
17492
+ }, (convert) => ({
17493
+ schema: convert(document.schema),
17494
+ definitions: mapObject(document.definitions, (definition, key) => convert(definition, ["$defs", key], ["definitions", key]))
17495
+ }));
17496
+ }
17497
+ var SCHEMA_MAP_KEYWORDS = /* @__PURE__ */ new Set(["properties", "patternProperties"]);
17498
+ var SCHEMA_ARRAY_KEYWORDS = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf"]);
17499
+ var JSON_SCHEMA_SINGLE_KEYWORDS = /* @__PURE__ */ new Set(["not", "additionalProperties", "propertyNames", "contains", "if", "then", "else", "contentSchema"]);
17500
+ function convertSubschemaKeyword(out, key, value3, context2, singleKeywords, mapKeywords = SCHEMA_MAP_KEYWORDS) {
17501
+ let converted;
17502
+ if (mapKeywords.has(key)) converted = context2.schemaMap(value3, key);
17503
+ else if (SCHEMA_ARRAY_KEYWORDS.has(key)) converted = context2.schemaArray(value3, key);
17504
+ else if (singleKeywords.has(key)) converted = context2.schema(value3, key);
17505
+ else return false;
17506
+ assignProperty(out, key, converted);
17507
+ return true;
17508
+ }
17509
+ var PRE_2020_TO_2020_COLLISIONS = ["$anchor", "$defs", "$dynamicAnchor", "$dynamicRef", "$vocabulary", "contentSchema", "dependentRequired", "dependentSchemas", "maxContains", "minContains", "prefixItems", "unevaluatedItems", "unevaluatedProperties"];
17510
+ var DRAFT_07_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "deprecated"];
17511
+ var OPEN_API_30_TO_2020_COLLISIONS = [...PRE_2020_TO_2020_COLLISIONS, "$comment", "$id", "$schema", "const", "contains", "contentEncoding", "contentMediaType", "else", "examples", "if", "patternProperties", "propertyNames", "then"];
17512
+ var ANCHOR_REGEXP = /^[A-Za-z_][-A-Za-z0-9._]*$/;
17513
+ var LEGACY_ID_FRAGMENT_REGEXP = /^[A-Za-z][-A-Za-z0-9._:]*$/;
17514
+ function unsupported(keyword, dialect, details) {
17515
+ throw new Error(`Cannot convert JSON Schema keyword "${keyword}" to ${dialect}: ${details}`);
17516
+ }
17517
+ function rejectKeywordCollisions(source, keywords, targetDialect, sourceDialect) {
17518
+ for (const keyword of keywords) {
17519
+ if (Object.hasOwn(source, keyword)) {
17520
+ unsupported(keyword, targetDialect, `it is not active in ${sourceDialect} but would become active in the target`);
17521
+ }
17522
+ }
17523
+ }
17524
+ var DRAFT_07_TARGET_COLLISIONS = ["additionalItems", "definitions", "dependencies"];
17525
+ function convertMetaSchemaKeyword(out, value3, context2, targetUri, targetDialect) {
17526
+ if (context2.isDocumentRoot) {
17527
+ assignProperty(out, "$schema", isMetaSchemaUri(value3, META_SCHEMA_URI_DRAFT_2020_12) ? targetUri : value3);
17528
+ } else if (!isMetaSchemaUri(value3, META_SCHEMA_URI_DRAFT_2020_12)) {
17529
+ unsupported("$schema", targetDialect, "an embedded resource cannot declare a different dialect");
17530
+ }
17531
+ }
17532
+ function draft07Adapter(source, context2) {
17533
+ rejectKeywordCollisions(source, DRAFT_07_TARGET_COLLISIONS, "Draft-07", "Draft 2020-12");
17534
+ const out = {};
17535
+ let reference = void 0;
17536
+ let prefixItems = void 0;
17537
+ let items = void 0;
17538
+ for (const key of Object.keys(source)) {
17539
+ const value3 = source[key];
17540
+ if (convertSubschemaKeyword(out, key, value3, context2, JSON_SCHEMA_SINGLE_KEYWORDS)) continue;
17541
+ switch (key) {
17542
+ case "$ref":
17543
+ reference = value3;
17544
+ break;
17545
+ case "$schema":
17546
+ convertMetaSchemaKeyword(out, value3, context2, META_SCHEMA_URI_DRAFT_07, "Draft-07");
17547
+ break;
17548
+ case "$id":
17549
+ case "$anchor":
17550
+ break;
17551
+ case "$defs":
17552
+ assignProperty(out, "definitions", context2.schemaMap(value3, key, "definitions"));
17553
+ break;
17554
+ case "prefixItems":
17555
+ prefixItems = value3;
17556
+ break;
17557
+ case "items":
17558
+ items = value3;
17559
+ break;
17560
+ case "dependentRequired":
17561
+ case "dependentSchemas":
17562
+ case "minContains":
17563
+ case "maxContains":
17564
+ break;
17565
+ case "$dynamicRef":
17566
+ case "$dynamicAnchor":
17567
+ case "$vocabulary":
17568
+ case "unevaluatedProperties":
17569
+ case "unevaluatedItems":
17570
+ unsupported(key, "Draft-07", "the target dialect has no equivalent");
17571
+ case "required":
17572
+ if (Array.isArray(value3) && value3.length === 0) break;
17573
+ assignProperty(out, key, value3);
17574
+ break;
17575
+ default:
17576
+ assignProperty(out, key, value3);
17577
+ }
17578
+ }
17579
+ convertTuple(out, prefixItems, items, context2);
17580
+ if (Object.hasOwn(source, "contains")) {
17581
+ const minContains = source.minContains;
17582
+ const maxContains = source.maxContains;
17583
+ if (minContains !== void 0 && minContains !== 1 || maxContains !== void 0) {
17584
+ unsupported("minContains/maxContains", "Draft-07", "contains cardinality cannot be represented");
17585
+ }
17586
+ if (Object.hasOwn(source, "minContains")) assignProperty(out, "minContains", minContains);
17587
+ } else {
17588
+ if (Object.hasOwn(source, "minContains")) assignProperty(out, "minContains", source.minContains);
17589
+ if (Object.hasOwn(source, "maxContains")) assignProperty(out, "maxContains", source.maxContains);
17590
+ }
17591
+ convertDependencies(source, out, context2, "draft-07");
17592
+ convertLegacyId(source, out, "$id", "Draft-07");
17593
+ convertReference(out, reference, context2);
17594
+ return out;
17595
+ }
17596
+ function convertTuple(out, prefixItems, items, context2) {
17597
+ if (prefixItems === void 0) {
17598
+ if (items !== void 0) assignProperty(out, "items", context2.schema(items, "items"));
17599
+ return;
17600
+ }
17601
+ assignProperty(out, "items", context2.schemaArray(prefixItems, "prefixItems", "items"));
17602
+ if (items !== void 0) {
17603
+ assignProperty(out, "additionalItems", context2.schema(items, "items", "additionalItems"));
17604
+ }
17605
+ }
17606
+ function convertReference(out, reference, context2) {
17607
+ if (reference === void 0) return;
17608
+ if (typeof reference === "string" && Object.keys(out).length > 0) {
17609
+ const referenceSchema = {};
17610
+ context2.reference(referenceSchema, reference);
17611
+ appendAllOf(out, referenceSchema);
17612
+ } else {
17613
+ context2.reference(out, reference);
17614
+ }
17615
+ }
17616
+ function convertDependencies(source, out, context2, targetDialect) {
17617
+ const dependentRequired = isObject(source.dependentRequired) ? source.dependentRequired : void 0;
17618
+ const dependentSchemas = isObject(source.dependentSchemas) ? source.dependentSchemas : void 0;
17619
+ if (dependentRequired === void 0 && dependentSchemas === void 0) return;
17620
+ const dependencies = {};
17621
+ const keys4 = /* @__PURE__ */ new Set([...Object.keys(dependentRequired ?? {}), ...Object.keys(dependentSchemas ?? {})]);
17622
+ for (const key of keys4) {
17623
+ const required2 = dependentRequired?.[key];
17624
+ const dependency = dependentSchemas?.[key];
17625
+ const omitRequired = targetDialect === "draft-04" && Array.isArray(required2) && required2.length === 0;
17626
+ if (dependency === void 0) {
17627
+ if (!omitRequired) assignProperty(dependencies, key, required2);
17628
+ } else if (required2 === void 0 || omitRequired) {
17629
+ assignProperty(dependencies, key, context2.schemaAt(dependency, ["dependentSchemas", key], ["dependencies", key]));
17630
+ } else {
17631
+ assignProperty(dependencies, key, {
17632
+ allOf: [context2.schemaAt(dependency, ["dependentSchemas", key], ["dependencies", key, "allOf", "0"]), {
17633
+ required: required2
17634
+ }]
17635
+ });
17636
+ }
17637
+ }
17638
+ if (Object.keys(dependencies).length > 0) assignProperty(out, "dependencies", dependencies);
17639
+ }
17640
+ function appendAllOf(out, schema) {
17641
+ if (Array.isArray(out.allOf)) out.allOf.push(schema);
17642
+ else assignProperty(out, "allOf", [schema]);
17643
+ }
17644
+ function convertLegacyId(source, out, targetKey, dialect) {
17645
+ const id2 = source.$id;
17646
+ const anchor = source.$anchor;
17647
+ if (anchor === void 0) {
17648
+ if (id2 !== void 0) assignProperty(out, targetKey, id2);
17649
+ return;
17650
+ }
17651
+ if (typeof anchor !== "string" || !ANCHOR_REGEXP.test(anchor)) {
17652
+ unsupported("$anchor", dialect, "the anchor is not valid");
17653
+ }
17654
+ if (!LEGACY_ID_FRAGMENT_REGEXP.test(anchor)) {
17655
+ unsupported("$anchor", dialect, "the anchor cannot be represented as a plain-name fragment identifier");
17656
+ }
17657
+ if (id2 === void 0) {
17658
+ assignProperty(out, targetKey, `#${anchor}`);
17659
+ } else {
17660
+ unsupported("$anchor", dialect, "it cannot be combined with the schema $id");
17661
+ }
17340
17662
  }
17341
17663
 
17342
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/RegExp.js
17664
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/RegExp.js
17343
17665
  var RegExp2 = globalThis.RegExp;
17344
17666
  var escape = (string3) => string3.replace(/[/\\^$*+?.()|[\]{}]/g, "\\$&");
17345
17667
 
17346
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/toJsonSchemaDocument.js
17668
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/toJsonSchemaDocument.js
17347
17669
  var jsonSchemaAnnotationExcludedKeys = /* @__PURE__ */ new Set([...annotationExcludedKeys, IDENTIFIER_FALLBACK_KEY, ...jsonSchemaAnnotationKeys]);
17348
17670
  function collectJsonSchemaAnnotations(annotations, options) {
17349
17671
  if (annotations === void 0) return void 0;
@@ -17786,7 +18108,7 @@ function compileJsonSchema(representations, rootPaths, references, options) {
17786
18108
  if (types.length === 0) return {
17787
18109
  not: {}
17788
18110
  };
17789
- if (types.length > 1) {
18111
+ if (representation.mode === "anyOf" && types.length > 1) {
17790
18112
  const compacted = compactEnums(types);
17791
18113
  if (compacted !== void 0) return compacted;
17792
18114
  }
@@ -17880,7 +18202,7 @@ function toJsonSchemaDocument(document, options) {
17880
18202
  };
17881
18203
  }
17882
18204
 
17883
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/schema/toRepresentation.js
18205
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/schema/toRepresentation.js
17884
18206
  var defaultReferencePolicy = ({
17885
18207
  identifier: identifier2
17886
18208
  }) => identifier2;
@@ -18195,7 +18517,7 @@ function toRepresentations(asts, options) {
18195
18517
  }
18196
18518
  }
18197
18519
 
18198
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/JsonPatch.js
18520
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/JsonPatch.js
18199
18521
  function get4(oldValue, newValue) {
18200
18522
  const patches = [];
18201
18523
  getLoop(oldValue, newValue, "", patches);
@@ -18376,7 +18698,7 @@ function rebuildFromStack(stack, newParent) {
18376
18698
  return acc;
18377
18699
  }
18378
18700
 
18379
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Optic.js
18701
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Optic.js
18380
18702
  function makeIso(get5, set2) {
18381
18703
  return make16(primitiveNode("Iso", get5, set2));
18382
18704
  }
@@ -18722,7 +19044,7 @@ function id() {
18722
19044
  return identityIso;
18723
19045
  }
18724
19046
 
18725
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/internal/redacted.js
19047
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/internal/redacted.js
18726
19048
  var redactedRegistry = /* @__PURE__ */ new WeakMap();
18727
19049
  var value = (self) => {
18728
19050
  if (redactedRegistry.has(self)) {
@@ -18732,7 +19054,7 @@ var value = (self) => {
18732
19054
  }
18733
19055
  };
18734
19056
 
18735
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Redacted.js
19057
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Redacted.js
18736
19058
  var TypeId14 = "~effect/data/Redacted";
18737
19059
  var isRedacted = (u) => hasProperty(u, TypeId14);
18738
19060
  var make17 = (value3, options) => {
@@ -18765,7 +19087,7 @@ var Proto3 = {
18765
19087
  var value2 = value;
18766
19088
  var makeEquivalence5 = (isEquivalent) => make2((x, y) => isEquivalent(value2(x), value2(y)));
18767
19089
 
18768
- // ../../node_modules/.bun/effect@4.0.0-rc.111/node_modules/effect/dist/Schema.js
19090
+ // ../../node_modules/.bun/effect@4.0.0-rc.112/node_modules/effect/dist/Schema.js
18769
19091
  var TypeId15 = TypeId13;
18770
19092
  function declareConstructor() {
18771
19093
  return (typeParameters, run2, annotations) => {
@@ -18796,9 +19118,15 @@ var SchemaErrorTypeId = "~effect/SchemaError/SchemaError";
18796
19118
  var SchemaError = class extends (/* @__PURE__ */ TaggedError2("SchemaError")) {
18797
19119
  [SchemaErrorTypeId] = SchemaErrorTypeId;
18798
19120
  constructor(issue) {
18799
- super({
18800
- issue
18801
- });
19121
+ const stackTraceLimit = getStackTraceLimit();
19122
+ setStackTraceLimit(0);
19123
+ try {
19124
+ super({
19125
+ issue
19126
+ });
19127
+ } finally {
19128
+ setStackTraceLimit(stackTraceLimit);
19129
+ }
18802
19130
  }
18803
19131
  get message() {
18804
19132
  return defaultFormatter(this.issue);
@@ -18915,6 +19243,9 @@ function decodeUnknownEffect2(schema, options) {
18915
19243
  };
18916
19244
  }
18917
19245
  function fromIssueEffect(self) {
19246
+ if (effectIsExit(self)) {
19247
+ return fromIssueExit(self);
19248
+ }
18918
19249
  return catchCause2(self, (cause) => failCauseSync2(() => map6(cause, (issue) => new SchemaError(issue))));
18919
19250
  }
18920
19251
  var decodeEffect2 = decodeUnknownEffect2;
@@ -19390,7 +19721,8 @@ function toTaggedUnion(tag2) {
19390
19721
  discriminants,
19391
19722
  isAnyOf,
19392
19723
  guards,
19393
- match: match7
19724
+ match: match7,
19725
+ matchOrElse
19394
19726
  });
19395
19727
  function walk(schema) {
19396
19728
  const ast = schema.ast;
@@ -19429,6 +19761,23 @@ function toTaggedUnion(tag2) {
19429
19761
  const handler = Object.hasOwn(cases2, key) ? cases2[key] : void 0;
19430
19762
  return handler(value3);
19431
19763
  }
19764
+ function matchOrElse() {
19765
+ if (arguments.length === 2) {
19766
+ const cases3 = arguments[0];
19767
+ const orElse2 = arguments[1];
19768
+ return function(value4) {
19769
+ const key2 = value4[tag2];
19770
+ const handler2 = Object.hasOwn(cases3, key2) ? cases3[key2] ?? orElse2 : orElse2;
19771
+ return handler2(value4);
19772
+ };
19773
+ }
19774
+ const value3 = arguments[0];
19775
+ const cases2 = arguments[1];
19776
+ const orElse = arguments[2];
19777
+ const key = value3[tag2];
19778
+ const handler = Object.hasOwn(cases2, key) ? cases2[key] ?? orElse : orElse;
19779
+ return handler(value3);
19780
+ }
19432
19781
  };
19433
19782
  }
19434
19783
  function TaggedUnion(casesByTag) {
@@ -19443,13 +19792,15 @@ function TaggedUnion(casesByTag) {
19443
19792
  const {
19444
19793
  guards,
19445
19794
  isAnyOf,
19446
- match: match7
19795
+ match: match7,
19796
+ matchOrElse
19447
19797
  } = toTaggedUnion("_tag")(union5);
19448
19798
  return make18(union5.ast, {
19449
19799
  cases,
19450
19800
  isAnyOf,
19451
19801
  guards,
19452
- match: match7
19802
+ match: match7,
19803
+ matchOrElse
19453
19804
  });
19454
19805
  }
19455
19806
  function Opaque() {
@@ -25532,7 +25883,6 @@ var CODEX_BRIDGE_PROBE_TTL_MS = 5e3;
25532
25883
  var CODEX_BRIDGE_LAUNCH_WAIT_MS = 3e4;
25533
25884
  var CODEX_LAUNCH_RUNAWAY_STARTUP_MS = 18e4;
25534
25885
  var CODEX_LAUNCH_RUNAWAY_STARTUP_SAMPLE_MS = 2e3;
25535
- var CODEX_LAUNCH_RUNAWAY_LIFETIME_SAMPLE_MS = 5e3;
25536
25886
  var CODEX_LAUNCH_RUNAWAY_THREAD_LIMIT = 180;
25537
25887
  var CODEX_LAUNCH_RUNAWAY_DESCENDANT_LIMIT = 96;
25538
25888
  var CODEX_LAUNCH_RUNAWAY_CONSECUTIVE_SAMPLES = 3;
@@ -25568,6 +25918,28 @@ function logOfficialCodexTakeoverPhase(trace, candidate, phase, context2 = {}) {
25568
25918
  ...context2
25569
25919
  });
25570
25920
  }
25921
+ function normalizeOfficialCodexBridgeActionResult(value3) {
25922
+ if (!value3 || typeof value3 !== "object") {
25923
+ return {
25924
+ status: "failed",
25925
+ message: "The action did not return a verified result."
25926
+ };
25927
+ }
25928
+ const record2 = value3;
25929
+ const status = record2.status === "completed" || record2.status === "pending" || record2.status === "failed" ? record2.status : null;
25930
+ const message = typeof record2.message === "string" ? record2.message.trim().slice(0, 240) : "";
25931
+ if (!status || !message) {
25932
+ return {
25933
+ status: "failed",
25934
+ message: "The action returned an invalid result."
25935
+ };
25936
+ }
25937
+ return {
25938
+ status,
25939
+ message,
25940
+ ...record2.mode === "shared-switch" || record2.mode === "isolated-open" ? { mode: record2.mode } : {}
25941
+ };
25942
+ }
25571
25943
  var officialCodexBridgeActionHandler = null;
25572
25944
  var bridgeActionListeners = /* @__PURE__ */ new Map();
25573
25945
  var bridgeActionListenerReady = /* @__PURE__ */ new Map();
@@ -25701,7 +26073,7 @@ async function officialCodexLiveLoginExpiryGuardMatches(guard) {
25701
26073
  if (account.status !== "observed") {
25702
26074
  return "unknown";
25703
26075
  }
25704
- return expectedAccountMatches(
26076
+ return officialCodexExpectedAccountMatches(
25705
26077
  {
25706
26078
  email: null,
25707
26079
  accountId: guard.accountId,
@@ -26740,6 +27112,9 @@ function createBridgeApplyQolExpression(settings) {
26740
27112
  const conversationTimelineEnabled = ${JSON.stringify(settings.conversationTimelineEnabled === true)};
26741
27113
  const inCodexStatusEnabled = ${JSON.stringify(settings.inCodexStatusEnabled === true)};
26742
27114
  const handoffEnabled = ${JSON.stringify(settings.handoffChipEnabled !== false)};
27115
+ const accountActionMode = ${JSON.stringify(
27116
+ settings.overlayAccountActionMode === "shared-switch" ? "shared-switch" : "isolated-open"
27117
+ )};
26743
27118
  let currentAutoRollDecision = ${JSON.stringify(settings.autoRollDecision ?? null)};
26744
27119
  let currentOverlayAutoRollEnabled = ${JSON.stringify(
26745
27120
  typeof settings.overlayAutoRollEnabled === "boolean" ? settings.overlayAutoRollEnabled : null
@@ -27282,7 +27657,7 @@ function createBridgeApplyQolExpression(settings) {
27282
27657
  const title = document.createElement("span");
27283
27658
  // Names the job, not the brand. The list holds OpenAI accounts and
27284
27659
  // custom-model profiles, so "accounts" was also the wrong word.
27285
- title.textContent = "Switch profile";
27660
+ title.textContent = accountActionMode === "shared-switch" ? "Switch profile" : "Open profile";
27286
27661
  const actionStatus = document.createElement("span");
27287
27662
  actionStatus.className = "codexuse-action-status";
27288
27663
  actionStatus.setAttribute("data-codexuse-action-status", "true");
@@ -27429,7 +27804,12 @@ function createBridgeApplyQolExpression(settings) {
27429
27804
  row.appendChild(meter);
27430
27805
  }
27431
27806
  if (canSwitch) {
27432
- row.setAttribute("aria-label", "Switch to " + label.textContent);
27807
+ row.setAttribute(
27808
+ "aria-label",
27809
+ accountActionMode === "shared-switch"
27810
+ ? "Switch to " + label.textContent
27811
+ : "Open " + label.textContent + " in isolated window"
27812
+ );
27433
27813
  row.addEventListener("click", (event) => {
27434
27814
  event.preventDefault();
27435
27815
  event.stopPropagation();
@@ -28967,7 +29347,8 @@ function normalizeOfficialCodexQolSettings2(value3) {
28967
29347
  canonicalSyncLine: typeof value3.canonicalSyncLine === "string" && value3.canonicalSyncLine.trim() ? value3.canonicalSyncLine.trim().slice(0, 40) : null,
28968
29348
  autoRollDecision: normalizeOverlayAutoRollDecision(value3.autoRollDecision),
28969
29349
  overlayAutoRollEnabled: typeof value3.overlayAutoRollEnabled === "boolean" ? value3.overlayAutoRollEnabled : null,
28970
- overlayRunningThreadHandoffEnabled: typeof value3.overlayRunningThreadHandoffEnabled === "boolean" ? value3.overlayRunningThreadHandoffEnabled : null
29350
+ overlayRunningThreadHandoffEnabled: typeof value3.overlayRunningThreadHandoffEnabled === "boolean" ? value3.overlayRunningThreadHandoffEnabled : null,
29351
+ overlayAccountActionMode: value3.overlayAccountActionMode === "shared-switch" || value3.overlayAccountActionMode === "isolated-open" ? value3.overlayAccountActionMode : null
28971
29352
  };
28972
29353
  }
28973
29354
  function hasActiveQolSettings(settings) {
@@ -29157,7 +29538,7 @@ function createBridgeInstallExpression() {
29157
29538
  const action = request.action;
29158
29539
  state.lastActionRequest = null;
29159
29540
  if (result && typeof result === "object" && result.status === "failed") {
29160
- const message = typeof result.reason === "string" && result.reason ? result.reason : "Did not switch";
29541
+ const message = typeof result.message === "string" && result.message ? result.message : "The action failed";
29161
29542
  state.lastActionMessage = message;
29162
29543
  if (action === "setting" && typeof request.settingKey === "string" && typeof request.settingValue === "boolean") {
29163
29544
  const host = document.getElementById("codexuse-profile-menu-section");
@@ -29172,14 +29553,9 @@ function createBridgeInstallExpression() {
29172
29553
  settleActionMessage(message);
29173
29554
  return true;
29174
29555
  }
29175
- const message =
29176
- action === "switch" ? "Switched"
29177
- : action === "continue" ? "Thread moved"
29178
- : action === "auto-roll-accept" ? "Switched"
29179
- : action === "auto-roll-cancel" ? "Staying here"
29180
- : action === "restart" ? "Restarted"
29181
- : action === "setting" ? "Saved"
29182
- : "Done";
29556
+ const message = result && typeof result.message === "string" && result.message
29557
+ ? result.message
29558
+ : "The action returned an invalid result.";
29183
29559
  state.lastActionMessage = message;
29184
29560
  settleActionMessage(message);
29185
29561
  return true;
@@ -30175,6 +30551,7 @@ async function startOfficialCodexBridgeActionListenerOnce(args2) {
30175
30551
  autoRollDecisionId,
30176
30552
  settingKey,
30177
30553
  settingValue,
30554
+ sourceProcessEpoch: args2.processEpoch,
30178
30555
  cdpPort: args2.cdpPort,
30179
30556
  route: typeof payload.route === "string" ? sanitizeBridgeActionRoute(payload.route) : null,
30180
30557
  activeThreadId: normalizeOfficialCodexThreadId(payload.activeThreadId),
@@ -30184,26 +30561,30 @@ async function startOfficialCodexBridgeActionListenerOnce(args2) {
30184
30561
  void (async () => {
30185
30562
  let result2;
30186
30563
  if (!handler) {
30187
- result2 = { status: "failed", reason: "Action handler is reconnecting" };
30564
+ result2 = { status: "failed", message: "The action handler is reconnecting." };
30188
30565
  } else {
30189
30566
  try {
30190
- result2 = await handler(request);
30567
+ result2 = normalizeOfficialCodexBridgeActionResult(
30568
+ await handler(request)
30569
+ );
30191
30570
  } catch (error) {
30192
- const reason = sanitizeUserFacingError(error) ?? "Action failed";
30571
+ const reason = sanitizeUserFacingError(error) ?? "The action failed.";
30193
30572
  console.warn("[official-codex-bridge-action] Handler failed.", {
30194
30573
  action: request.action,
30195
30574
  error: reason
30196
30575
  });
30197
- result2 = { status: "failed", reason };
30576
+ result2 = { status: "failed", message: reason };
30198
30577
  }
30199
30578
  }
30200
30579
  let serialized;
30201
30580
  try {
30202
- serialized = JSON.stringify(result2 ?? { status: "ok" }) ?? "null";
30581
+ serialized = JSON.stringify(
30582
+ normalizeOfficialCodexBridgeActionResult(result2)
30583
+ );
30203
30584
  } catch {
30204
30585
  serialized = JSON.stringify({
30205
30586
  status: "failed",
30206
- reason: "Action result was invalid"
30587
+ message: "The action result was invalid."
30207
30588
  });
30208
30589
  }
30209
30590
  send("Runtime.evaluate", {
@@ -30345,7 +30726,10 @@ async function reapplyDesiredBridgeSettings(instance, bridge, allowAnyPageTarget
30345
30726
  const qolSettings = normalizeOfficialCodexQolSettings2(
30346
30727
  instance.desiredQolSettings
30347
30728
  );
30348
- const qolExpression = createBridgeApplyQolExpression(qolSettings);
30729
+ const qolExpression = createBridgeApplyQolExpression({
30730
+ ...qolSettings,
30731
+ overlayAccountActionMode: instance.profileHome === null ? "shared-switch" : "isolated-open"
30732
+ });
30349
30733
  const qolValue = await evaluateOfficialCodexBridgeCommand(
30350
30734
  target.webSocketDebuggerUrl,
30351
30735
  "applyQol",
@@ -30976,82 +31360,64 @@ async function readProcessThreadCount(pid) {
30976
31360
  }).length;
30977
31361
  return threadCount > 0 ? threadCount : null;
30978
31362
  }
30979
- function startOfficialCodexLaunchRunawayWatchdog(args2) {
31363
+ function startBoundedOfficialCodexLaunchRunawayWatchdog(args2) {
31364
+ const now2 = args2.now ?? Date.now;
31365
+ const wait = args2.wait ?? sleep3;
31366
+ const deadline = now2() + (args2.startupDeadlineMs ?? CODEX_LAUNCH_RUNAWAY_STARTUP_MS);
31367
+ const sampleMs = args2.sampleMs ?? CODEX_LAUNCH_RUNAWAY_STARTUP_SAMPLE_MS;
31368
+ const consecutiveSampleLimit = args2.consecutiveSampleLimit ?? CODEX_LAUNCH_RUNAWAY_CONSECUTIVE_SAMPLES;
31369
+ const threadLimit = args2.threadLimit ?? CODEX_LAUNCH_RUNAWAY_THREAD_LIMIT;
31370
+ const descendantLimit = args2.descendantLimit ?? CODEX_LAUNCH_RUNAWAY_DESCENDANT_LIMIT;
31371
+ const inspectionFailureLimit = args2.inspectionFailureLimit ?? CODEX_LAUNCH_RUNAWAY_INSPECTION_FAILURE_LIMIT;
31372
+ const evidenceTtlMs = args2.evidenceTtlMs ?? CODEX_LAUNCH_RUNAWAY_EVIDENCE_TTL_MS;
30980
31373
  let cancelled = false;
30981
31374
  const result2 = (async () => {
30982
31375
  let consecutiveRunawaySamples = 0;
30983
31376
  let lastRunawaySampleAt = null;
30984
31377
  let consecutiveInspectionFailures = 0;
30985
- const startedWatchingAt = Date.now();
30986
- while (!cancelled) {
30987
- await sleep3(
30988
- Date.now() - startedWatchingAt < CODEX_LAUNCH_RUNAWAY_STARTUP_MS ? CODEX_LAUNCH_RUNAWAY_STARTUP_SAMPLE_MS : CODEX_LAUNCH_RUNAWAY_LIFETIME_SAMPLE_MS
30989
- );
30990
- if (cancelled) return null;
30991
- let rows;
31378
+ while (!cancelled && now2() < deadline) {
31379
+ await wait(Math.min(sampleMs, Math.max(0, deadline - now2())));
31380
+ if (cancelled || now2() >= deadline) return null;
31381
+ let sample;
30992
31382
  try {
30993
- rows = await readProcessRows();
31383
+ sample = await args2.inspect();
30994
31384
  } catch {
30995
31385
  consecutiveInspectionFailures += 1;
30996
- if (consecutiveInspectionFailures >= CODEX_LAUNCH_RUNAWAY_INSPECTION_FAILURE_LIMIT) {
30997
- console.warn(
30998
- "[official-codex-launch] Runaway watchdog stopped after persistent process-inspection failures.",
30999
- {
31000
- pid: args2.pid,
31001
- startedAt: args2.startedAt,
31002
- cdpPort: args2.cdpPort,
31003
- consecutiveInspectionFailures
31004
- }
31005
- );
31386
+ if (consecutiveInspectionFailures >= inspectionFailureLimit) {
31387
+ args2.onInspectionFailureLimit?.(consecutiveInspectionFailures);
31006
31388
  return null;
31007
31389
  }
31008
31390
  continue;
31009
31391
  }
31010
31392
  consecutiveInspectionFailures = 0;
31011
- const mainRow = rows.find((row) => row.pid === args2.pid) ?? null;
31012
- if (!mainRow || !isMainProcessRow(mainRow, args2.candidate) || mainRow.startedAt !== args2.startedAt || !remoteDebuggingPortMatches(mainRow.args, args2.cdpPort)) {
31393
+ if (!sample.epochMatches) {
31013
31394
  return null;
31014
31395
  }
31015
- const descendantProcessCount = getDescendantPids(args2.pid, rows).length;
31016
- const threadCount = await readProcessThreadCount(args2.pid);
31017
- const runawaySample = threadCount !== null && threadCount >= CODEX_LAUNCH_RUNAWAY_THREAD_LIMIT || descendantProcessCount >= CODEX_LAUNCH_RUNAWAY_DESCENDANT_LIMIT;
31396
+ const runawaySample = sample.threadCount !== null && sample.threadCount >= threadLimit || sample.descendantProcessCount >= descendantLimit;
31018
31397
  if (runawaySample) {
31019
31398
  consecutiveRunawaySamples += 1;
31020
- lastRunawaySampleAt = Date.now();
31021
- } else if (threadCount !== null) {
31399
+ lastRunawaySampleAt = now2();
31400
+ } else if (sample.threadCount !== null) {
31022
31401
  consecutiveRunawaySamples = 0;
31023
31402
  lastRunawaySampleAt = null;
31024
- } else if (lastRunawaySampleAt !== null && Date.now() - lastRunawaySampleAt > CODEX_LAUNCH_RUNAWAY_EVIDENCE_TTL_MS) {
31403
+ } else if (lastRunawaySampleAt !== null && now2() - lastRunawaySampleAt > evidenceTtlMs) {
31025
31404
  consecutiveRunawaySamples = 0;
31026
31405
  lastRunawaySampleAt = null;
31027
31406
  }
31028
- if (consecutiveRunawaySamples < CODEX_LAUNCH_RUNAWAY_CONSECUTIVE_SAMPLES) {
31407
+ if (consecutiveRunawaySamples < consecutiveSampleLimit) {
31029
31408
  continue;
31030
31409
  }
31031
- const remainingPids = await stopOfficialCodexProcessEpoch({
31032
- candidate: args2.candidate,
31033
- pid: args2.pid,
31034
- startedAt: args2.startedAt,
31035
- cdpPort: args2.cdpPort
31036
- }).catch(() => [args2.pid]);
31037
- console.warn("[official-codex-launch] Stopped runaway managed launch.", {
31038
- pid: args2.pid,
31039
- startedAt: args2.startedAt,
31040
- cdpPort: args2.cdpPort,
31041
- threadCount,
31042
- descendantProcessCount,
31043
- remainingPids
31044
- });
31045
- return { threadCount, descendantProcessCount, remainingPids };
31410
+ const runaway = {
31411
+ threadCount: sample.threadCount,
31412
+ descendantProcessCount: sample.descendantProcessCount,
31413
+ remainingPids: await args2.stop()
31414
+ };
31415
+ args2.onRunaway?.(runaway);
31416
+ return runaway;
31046
31417
  }
31047
31418
  return null;
31048
31419
  })().catch((error) => {
31049
- console.warn("[official-codex-launch] Runaway watchdog failed.", {
31050
- pid: args2.pid,
31051
- startedAt: args2.startedAt,
31052
- cdpPort: args2.cdpPort,
31053
- error: sanitizeUserFacingError(error) ?? "process-inspection-failed"
31054
- });
31420
+ args2.onError?.(error);
31055
31421
  return null;
31056
31422
  });
31057
31423
  return {
@@ -31061,6 +31427,59 @@ function startOfficialCodexLaunchRunawayWatchdog(args2) {
31061
31427
  }
31062
31428
  };
31063
31429
  }
31430
+ function startOfficialCodexLaunchRunawayWatchdog(args2) {
31431
+ return startBoundedOfficialCodexLaunchRunawayWatchdog({
31432
+ inspect: async () => {
31433
+ const rows = await readProcessRows();
31434
+ const mainRow = rows.find((row) => row.pid === args2.pid) ?? null;
31435
+ if (!mainRow || !isMainProcessRow(mainRow, args2.candidate) || mainRow.startedAt !== args2.startedAt || !remoteDebuggingPortMatches(mainRow.args, args2.cdpPort)) {
31436
+ return {
31437
+ epochMatches: false,
31438
+ threadCount: null,
31439
+ descendantProcessCount: 0
31440
+ };
31441
+ }
31442
+ const descendantProcessCount = getDescendantPids(args2.pid, rows).length;
31443
+ const threadCount = await readProcessThreadCount(args2.pid);
31444
+ return { epochMatches: true, threadCount, descendantProcessCount };
31445
+ },
31446
+ stop: () => stopOfficialCodexProcessEpoch({
31447
+ candidate: args2.candidate,
31448
+ pid: args2.pid,
31449
+ startedAt: args2.startedAt,
31450
+ cdpPort: args2.cdpPort
31451
+ }).catch(() => [args2.pid]),
31452
+ onRunaway: ({ threadCount, descendantProcessCount, remainingPids }) => {
31453
+ console.warn("[official-codex-launch] Stopped runaway managed launch.", {
31454
+ pid: args2.pid,
31455
+ startedAt: args2.startedAt,
31456
+ cdpPort: args2.cdpPort,
31457
+ threadCount,
31458
+ descendantProcessCount,
31459
+ remainingPids
31460
+ });
31461
+ },
31462
+ onInspectionFailureLimit: (consecutiveInspectionFailures) => {
31463
+ console.warn(
31464
+ "[official-codex-launch] Runaway watchdog stopped after persistent process-inspection failures.",
31465
+ {
31466
+ pid: args2.pid,
31467
+ startedAt: args2.startedAt,
31468
+ cdpPort: args2.cdpPort,
31469
+ consecutiveInspectionFailures
31470
+ }
31471
+ );
31472
+ },
31473
+ onError: (error) => {
31474
+ console.warn("[official-codex-launch] Runaway watchdog failed.", {
31475
+ pid: args2.pid,
31476
+ startedAt: args2.startedAt,
31477
+ cdpPort: args2.cdpPort,
31478
+ error: sanitizeUserFacingError(error) ?? "process-inspection-failed"
31479
+ });
31480
+ }
31481
+ });
31482
+ }
31064
31483
  async function waitForLaunchStepOrRunaway(step, watchdog) {
31065
31484
  const runaway = watchdog.result.then(
31066
31485
  (value3) => value3 ? { kind: "runaway", value: value3 } : new Promise(() => void 0)
@@ -31253,34 +31672,6 @@ async function readManagedInstance(profileName) {
31253
31672
  const state = await getAppState();
31254
31673
  return state.officialCodex.instancesByProfileName[profileName] ?? null;
31255
31674
  }
31256
- function recordManagedLaunchRunaway(args2) {
31257
- void args2.watchdog.result.then(async (runaway) => {
31258
- if (!runaway) return;
31259
- const current = await readManagedInstance(args2.profileName);
31260
- if (!current || current.pid !== args2.pid || current.launchedAt !== args2.startedAt || current.cdpPort !== args2.cdpPort) {
31261
- return;
31262
- }
31263
- const rows = await readProcessRows().catch(() => []);
31264
- const mainStillRunning = rows.some(
31265
- (row) => row.pid === args2.pid && row.startedAt === args2.startedAt && isMainProcessRow(row, args2.candidate) && remoteDebuggingPortMatches(row.args, args2.cdpPort)
31266
- );
31267
- await patchManagedInstance({
31268
- ...current,
31269
- pid: mainStillRunning ? args2.pid : null,
31270
- appServerPid: mainStillRunning ? current.appServerPid : null,
31271
- ...mainStillRunning ? bridgeStateForStoredInstance(current, true, Date.now()) : bridgeStateUnavailable(),
31272
- lastVerifiedAt: Date.now(),
31273
- lastStatus: "failed",
31274
- lastError: mainStillRunning ? "launch-runaway-stop-timeout" : "launch-runaway-detected"
31275
- });
31276
- }).catch((error) => {
31277
- console.warn("[official-codex-launch] Failed to record runaway launch.", {
31278
- profileName: args2.profileName,
31279
- pid: args2.pid,
31280
- error: sanitizeUserFacingError(error) ?? "state-update-failed"
31281
- });
31282
- });
31283
- }
31284
31675
  async function resolveInstanceRuntimeState(args2) {
31285
31676
  const pid = args2.instance.pid;
31286
31677
  if (!pid) {
@@ -31573,9 +31964,15 @@ async function openCodexWithProfileHome(candidate, profileHome, profileName, pre
31573
31964
  };
31574
31965
  }
31575
31966
  const telemetryLabel = `codexuse-profile-${encodeURIComponent(profileName)}`;
31576
- const launchHome = resolveCodexLaunchHome(profileHome);
31577
- const appUserDataDir = options.useDefaultUserData === true ? null : options.userDataDir ?? import_node_path12.default.join(profileHome, "codex-app-user-data");
31578
- const sqliteHome = options.sqliteHome ?? profileHome;
31967
+ const launchConfiguration = resolveOfficialCodexLaunchConfiguration(
31968
+ profileHome,
31969
+ options
31970
+ );
31971
+ const {
31972
+ codexHome: launchHome,
31973
+ sqliteHome,
31974
+ userDataDir: appUserDataDir
31975
+ } = launchConfiguration;
31579
31976
  const activePortPaths = devToolsActivePortPaths(appUserDataDir);
31580
31977
  let child;
31581
31978
  try {
@@ -31870,6 +32267,15 @@ async function signalPids(pids, signal) {
31870
32267
  return signaled;
31871
32268
  }
31872
32269
  var SHARED_CODEX_HOME = resolveDefaultCodexHomeDir();
32270
+ function resolveOfficialCodexLaunchConfiguration(profileHome, options = {}) {
32271
+ return {
32272
+ codexHome: resolveCodexLaunchHome(profileHome),
32273
+ sqliteHome: options.sqliteHome ?? profileHome,
32274
+ // Managed profile windows keep Electron state separate as well as CODEX_HOME.
32275
+ // Callers can supply another isolated directory or explicitly use stock state.
32276
+ userDataDir: options.useDefaultUserData === true ? null : options.userDataDir ?? import_node_path12.default.join(profileHome, "codex-app-user-data")
32277
+ };
32278
+ }
31873
32279
  function resolveOfficialCodexThreadSqliteHome(profileHome) {
31874
32280
  return profileHome === SHARED_CODEX_HOME ? resolveCodexSqliteHomeDir(profileHome) : profileHome;
31875
32281
  }
@@ -31889,7 +32295,7 @@ var sharedHomeCdpWindow = null;
31889
32295
  function normalizedAccountWorkspaceId(value3) {
31890
32296
  return value3?.trim() || "__default__";
31891
32297
  }
31892
- function expectedAccountMatches(expected, observed) {
32298
+ function officialCodexExpectedAccountMatches(expected, observed) {
31893
32299
  const identityMatches = expected.accountId ? observed.accountId === expected.accountId : Boolean(
31894
32300
  expected.email && observed.email && observed.email.toLowerCase() === expected.email.toLowerCase()
31895
32301
  );
@@ -33934,7 +34340,7 @@ async function waitForExpectedOfficialCodexAccount(debuggerUrl, expectedAccount)
33934
34340
  false
33935
34341
  )
33936
34342
  );
33937
- if (observed && expectedAccountMatches(expectedAccount, observed)) {
34343
+ if (observed && officialCodexExpectedAccountMatches(expectedAccount, observed)) {
33938
34344
  return observed;
33939
34345
  }
33940
34346
  } catch {
@@ -34039,7 +34445,7 @@ async function applySharedLaunchFollowUp(args2) {
34039
34445
  readSharedBridgeSnapshot(debuggerUrl)
34040
34446
  ]);
34041
34447
  const expectedDraft = args2.carryDraft && args2.carriedDraft.trim() ? args2.carriedDraft : "";
34042
- if (!finalAccount || !expectedAccountMatches(args2.expectedAccount, finalAccount) || !snapshot2 || snapshot2.activeThreadId !== null || (snapshot2.composerText ?? "") !== expectedDraft) {
34448
+ if (!finalAccount || !officialCodexExpectedAccountMatches(args2.expectedAccount, finalAccount) || !snapshot2 || snapshot2.activeThreadId !== null || (snapshot2.composerText ?? "") !== expectedDraft) {
34043
34449
  return { verified: false, reason: "renderer-postcondition-unverified" };
34044
34450
  }
34045
34451
  return { verified: true, reason: null };
@@ -34161,7 +34567,7 @@ async function attemptOfficialCodexManagedLiveLogin(args2) {
34161
34567
  const notified = await notification.promise;
34162
34568
  notification = null;
34163
34569
  const account = await readSharedOfficialCodexAppAccount();
34164
- if (account.status !== "observed" || !expectedAccountMatches(expectedAccount, account)) {
34570
+ if (account.status !== "observed" || !officialCodexExpectedAccountMatches(expectedAccount, account)) {
34165
34571
  return null;
34166
34572
  }
34167
34573
  await adoptSharedManagedWindow({
@@ -34215,7 +34621,7 @@ async function attemptOfficialCodexManagedLiveLogin(args2) {
34215
34621
  return null;
34216
34622
  }
34217
34623
  const refreshedAccount = await readSharedOfficialCodexAppAccount();
34218
- if (refreshedAccount.status !== "observed" || !expectedAccountMatches(expectedAccount, refreshedAccount)) {
34624
+ if (refreshedAccount.status !== "observed" || !officialCodexExpectedAccountMatches(expectedAccount, refreshedAccount)) {
34219
34625
  return null;
34220
34626
  }
34221
34627
  reconciled = await reconcile(args2.debuggerUrl);
@@ -34357,11 +34763,11 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34357
34763
  if (driveTarget) {
34358
34764
  const managedTarget = driveTarget;
34359
34765
  const mainRow = rows.find((row) => row.pid === managedTarget.pid) ?? null;
34360
- const appServerPid2 = findAppServerPid(rows, managedTarget.pid);
34361
- if (!mainRow?.startedAt || !appServerPid2 || !await attestOfficialCodexProcessEpoch({
34766
+ const appServerPid = findAppServerPid(rows, managedTarget.pid);
34767
+ if (!mainRow?.startedAt || !appServerPid || !await attestOfficialCodexProcessEpoch({
34362
34768
  candidate,
34363
34769
  pid: managedTarget.pid,
34364
- appServerPid: appServerPid2,
34770
+ appServerPid,
34365
34771
  startedAt: mainRow.startedAt,
34366
34772
  cdpPort: managedTarget.cdpPort
34367
34773
  })) {
@@ -34382,12 +34788,12 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34382
34788
  await ensureOfficialCodexBridgeInstalled(debuggerUrl, false);
34383
34789
  } catch {
34384
34790
  }
34385
- let bridge2 = null;
34791
+ let bridge = null;
34386
34792
  if (options.profileName) {
34387
34793
  await adoptSharedManagedWindow({
34388
34794
  candidate,
34389
34795
  pid: managedTarget.pid,
34390
- appServerPid: appServerPid2,
34796
+ appServerPid,
34391
34797
  cdpPort: managedTarget.cdpPort,
34392
34798
  startedAt: mainRow.startedAt,
34393
34799
  profileName: options.profileName,
@@ -34395,19 +34801,19 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34395
34801
  desiredQolSettings: options.desiredQolSettings,
34396
34802
  desiredPowerSettings: options.desiredPowerSettings
34397
34803
  });
34398
- bridge2 = await refreshAdoptedSharedWindow(options.profileName);
34399
- if (bridge2?.bridgeStatus !== "healthy") {
34804
+ bridge = await refreshAdoptedSharedWindow(options.profileName);
34805
+ if (bridge?.bridgeStatus !== "healthy") {
34400
34806
  return {
34401
34807
  status: "failed",
34402
34808
  mechanism: "none",
34403
- reason: bridge2?.bridgeError ?? "bridge-not-healthy",
34809
+ reason: bridge?.bridgeError ?? "bridge-not-healthy",
34404
34810
  pid: managedTarget.pid,
34405
- appServerPid: appServerPid2,
34811
+ appServerPid,
34406
34812
  cdpPort: managedTarget.cdpPort,
34407
- bridgeStatus: bridge2?.bridgeStatus ?? null,
34408
- bridgeError: bridge2?.bridgeError ?? null,
34409
- bridgeActiveThreadId: bridge2?.bridgeActiveThreadId ?? null,
34410
- bridgeWorkspacePath: bridge2?.bridgeWorkspacePath ?? null
34813
+ bridgeStatus: bridge?.bridgeStatus ?? null,
34814
+ bridgeError: bridge?.bridgeError ?? null,
34815
+ bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
34816
+ bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null
34411
34817
  };
34412
34818
  }
34413
34819
  }
@@ -34416,12 +34822,12 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34416
34822
  mechanism: "none",
34417
34823
  reason: null,
34418
34824
  pid: managedTarget.pid,
34419
- appServerPid: appServerPid2,
34825
+ appServerPid,
34420
34826
  cdpPort: managedTarget.cdpPort,
34421
- bridgeStatus: bridge2?.bridgeStatus ?? null,
34422
- bridgeError: bridge2?.bridgeError ?? null,
34423
- bridgeActiveThreadId: bridge2?.bridgeActiveThreadId ?? null,
34424
- bridgeWorkspacePath: bridge2?.bridgeWorkspacePath ?? null
34827
+ bridgeStatus: bridge?.bridgeStatus ?? null,
34828
+ bridgeError: bridge?.bridgeError ?? null,
34829
+ bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
34830
+ bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null
34425
34831
  };
34426
34832
  }
34427
34833
  sharedHomeCdpWindow = null;
@@ -34479,7 +34885,7 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34479
34885
  const live = await attemptOfficialCodexManagedLiveLogin({
34480
34886
  candidate,
34481
34887
  driveTarget: managedTarget,
34482
- appServerPid: appServerPid2,
34888
+ appServerPid,
34483
34889
  startedAt: mainRow.startedAt,
34484
34890
  debuggerUrl: target.webSocketDebuggerUrl,
34485
34891
  sourceSnapshot: snapshot2,
@@ -34593,6 +34999,7 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34593
34999
  reason: launch2.reason ?? null
34594
35000
  });
34595
35001
  if (!launch2.opened || launch2.pid === null || launch2.startedAt === null || launch2.cdpPort === null || !launch2.watchdog) {
35002
+ launch2.watchdog?.cancel();
34596
35003
  return {
34597
35004
  status: "failed",
34598
35005
  reason: launch2.reason ?? "shared-home-launch-failed",
@@ -34600,376 +35007,442 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34600
35007
  closedPreviousWindow: false
34601
35008
  };
34602
35009
  }
34603
- const cdpPort2 = launch2.cdpPort;
34604
- const appServerStep2 = await waitForLaunchStepOrRunaway(
34605
- waitForAppServerPid(launch2.pid, SHARED_CODEX_HOME),
34606
- launch2.watchdog
34607
- );
34608
- if (appServerStep2.kind === "runaway") {
34609
- return {
34610
- status: "failed",
34611
- reason: launchRunawayFailureReason(appServerStep2.value, launch2.pid),
34612
- pid: launch2.pid,
34613
- appServerPid: null,
34614
- cdpPort: cdpPort2,
34615
- closedPreviousWindow: false
34616
- };
34617
- }
34618
- const appServerPid2 = appServerStep2.value;
34619
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-app-server", {
34620
- verified: appServerPid2 !== null
34621
- });
34622
- if (appServerPid2 === null) {
34623
- const remaining = await stopUnverifiedLaunch({
34624
- candidate,
34625
- pid: launch2.pid,
34626
- startedAt: launch2.startedAt,
34627
- cdpPort: cdpPort2
34628
- });
34629
- return {
34630
- status: "failed",
34631
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "app-server-not-verified",
34632
- pid: launch2.pid,
34633
- appServerPid: null,
34634
- cdpPort: cdpPort2,
34635
- closedPreviousWindow: false
34636
- };
34637
- }
34638
- const replacementTarget = await waitForCdpTargetAfterLaunch(cdpPort2);
34639
- if (!replacementTarget?.webSocketDebuggerUrl) {
34640
- const remaining = await stopUnverifiedLaunch({
34641
- candidate,
34642
- pid: launch2.pid,
34643
- startedAt: launch2.startedAt,
34644
- cdpPort: cdpPort2
35010
+ let finalLaunchWatchdog = null;
35011
+ try {
35012
+ const cdpPort = launch2.cdpPort;
35013
+ const appServerStep = await waitForLaunchStepOrRunaway(
35014
+ waitForAppServerPid(launch2.pid, SHARED_CODEX_HOME),
35015
+ launch2.watchdog
35016
+ );
35017
+ if (appServerStep.kind === "runaway") {
35018
+ return {
35019
+ status: "failed",
35020
+ reason: launchRunawayFailureReason(appServerStep.value, launch2.pid),
35021
+ pid: launch2.pid,
35022
+ appServerPid: null,
35023
+ cdpPort,
35024
+ closedPreviousWindow: false
35025
+ };
35026
+ }
35027
+ const appServerPid = appServerStep.value;
35028
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-app-server", {
35029
+ verified: appServerPid !== null
34645
35030
  });
34646
- return {
34647
- status: "failed",
34648
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
34649
- pid: launch2.pid,
34650
- appServerPid: appServerPid2,
34651
- cdpPort: cdpPort2,
34652
- bridgeError: "cdp-target-not-found",
34653
- closedPreviousWindow: false
34654
- };
34655
- }
34656
- const attestedStep2 = await waitForLaunchStepOrRunaway(
34657
- waitForAttestedProcessEpoch({
34658
- candidate,
34659
- pid: launch2.pid,
34660
- appServerPid: appServerPid2,
34661
- startedAt: launch2.startedAt,
34662
- cdpPort: cdpPort2
34663
- }),
34664
- launch2.watchdog
34665
- );
34666
- if (attestedStep2.kind === "runaway") {
34667
- return {
34668
- status: "failed",
34669
- reason: launchRunawayFailureReason(attestedStep2.value, launch2.pid),
34670
- pid: launch2.pid,
34671
- appServerPid: appServerPid2,
34672
- cdpPort: cdpPort2,
34673
- closedPreviousWindow: false
34674
- };
34675
- }
34676
- if (!attestedStep2.value) {
34677
- const remaining = await stopUnverifiedLaunch({
34678
- candidate,
34679
- pid: launch2.pid,
34680
- startedAt: launch2.startedAt,
34681
- cdpPort: cdpPort2
35031
+ if (appServerPid === null) {
35032
+ const remaining = await stopUnverifiedLaunch({
35033
+ candidate,
35034
+ pid: launch2.pid,
35035
+ startedAt: launch2.startedAt,
35036
+ cdpPort
35037
+ });
35038
+ return {
35039
+ status: "failed",
35040
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "app-server-not-verified",
35041
+ pid: launch2.pid,
35042
+ appServerPid: null,
35043
+ cdpPort,
35044
+ closedPreviousWindow: false
35045
+ };
35046
+ }
35047
+ const replacementTarget = await waitForCdpTargetAfterLaunch(cdpPort);
35048
+ if (!replacementTarget?.webSocketDebuggerUrl) {
35049
+ const remaining = await stopUnverifiedLaunch({
35050
+ candidate,
35051
+ pid: launch2.pid,
35052
+ startedAt: launch2.startedAt,
35053
+ cdpPort
35054
+ });
35055
+ return {
35056
+ status: "failed",
35057
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
35058
+ pid: launch2.pid,
35059
+ appServerPid,
35060
+ cdpPort,
35061
+ bridgeError: "cdp-target-not-found",
35062
+ closedPreviousWindow: false
35063
+ };
35064
+ }
35065
+ const attestedStep = await waitForLaunchStepOrRunaway(
35066
+ waitForAttestedProcessEpoch({
35067
+ candidate,
35068
+ pid: launch2.pid,
35069
+ appServerPid,
35070
+ startedAt: launch2.startedAt,
35071
+ cdpPort
35072
+ }),
35073
+ launch2.watchdog
35074
+ );
35075
+ if (attestedStep.kind === "runaway") {
35076
+ return {
35077
+ status: "failed",
35078
+ reason: launchRunawayFailureReason(attestedStep.value, launch2.pid),
35079
+ pid: launch2.pid,
35080
+ appServerPid,
35081
+ cdpPort,
35082
+ closedPreviousWindow: false
35083
+ };
35084
+ }
35085
+ if (!attestedStep.value) {
35086
+ const remaining = await stopUnverifiedLaunch({
35087
+ candidate,
35088
+ pid: launch2.pid,
35089
+ startedAt: launch2.startedAt,
35090
+ cdpPort
35091
+ });
35092
+ return {
35093
+ status: "failed",
35094
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "process-identity-not-verified",
35095
+ pid: launch2.pid,
35096
+ appServerPid,
35097
+ cdpPort,
35098
+ closedPreviousWindow: false
35099
+ };
35100
+ }
35101
+ try {
35102
+ await ensureOfficialCodexBridgeInstalled(
35103
+ replacementTarget.webSocketDebuggerUrl,
35104
+ false
35105
+ );
35106
+ } catch (error) {
35107
+ const remaining = await stopUnverifiedLaunch({
35108
+ candidate,
35109
+ pid: launch2.pid,
35110
+ startedAt: launch2.startedAt,
35111
+ cdpPort
35112
+ });
35113
+ return {
35114
+ status: "failed",
35115
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
35116
+ pid: launch2.pid,
35117
+ appServerPid,
35118
+ cdpPort,
35119
+ bridgeError: sanitizeUserFacingError(error) ?? "bridge-install-failed",
35120
+ closedPreviousWindow: false
35121
+ };
35122
+ }
35123
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-bridge", {
35124
+ healthy: true
34682
35125
  });
34683
- return {
34684
- status: "failed",
34685
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "process-identity-not-verified",
34686
- pid: launch2.pid,
34687
- appServerPid: appServerPid2,
34688
- cdpPort: cdpPort2,
34689
- closedPreviousWindow: false
34690
- };
34691
- }
34692
- try {
34693
- await ensureOfficialCodexBridgeInstalled(
35126
+ const verifierAccount = options.expectedAccount ? await waitForExpectedOfficialCodexAccount(
34694
35127
  replacementTarget.webSocketDebuggerUrl,
34695
- false
35128
+ options.expectedAccount
35129
+ ) : null;
35130
+ if (!options.expectedAccount || !verifierAccount || !officialCodexExpectedAccountMatches(options.expectedAccount, verifierAccount)) {
35131
+ const remaining = await stopUnverifiedLaunch({
35132
+ candidate,
35133
+ pid: launch2.pid,
35134
+ startedAt: launch2.startedAt,
35135
+ cdpPort
35136
+ });
35137
+ return {
35138
+ status: "failed",
35139
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "official-codex-target-account-unverified",
35140
+ pid: launch2.pid,
35141
+ appServerPid,
35142
+ cdpPort,
35143
+ closedPreviousWindow: false
35144
+ };
35145
+ }
35146
+ const verifierSurface = await prepareOfficialCodexRendererSurface(
35147
+ replacementTarget.webSocketDebuggerUrl,
35148
+ true
34696
35149
  );
34697
- } catch (error) {
34698
- const remaining = await stopUnverifiedLaunch({
34699
- candidate,
34700
- pid: launch2.pid,
34701
- startedAt: launch2.startedAt,
34702
- cdpPort: cdpPort2
35150
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-surface", {
35151
+ status: verifierSurface
34703
35152
  });
34704
- return {
34705
- status: "failed",
34706
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
34707
- pid: launch2.pid,
34708
- appServerPid: appServerPid2,
34709
- cdpPort: cdpPort2,
34710
- bridgeError: sanitizeUserFacingError(error) ?? "bridge-install-failed",
34711
- closedPreviousWindow: false
34712
- };
34713
- }
34714
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-bridge", {
34715
- healthy: true
34716
- });
34717
- const verifierAccount = options.expectedAccount ? await waitForExpectedOfficialCodexAccount(
34718
- replacementTarget.webSocketDebuggerUrl,
34719
- options.expectedAccount
34720
- ) : null;
34721
- if (!options.expectedAccount || !verifierAccount || !expectedAccountMatches(options.expectedAccount, verifierAccount)) {
34722
- const remaining = await stopUnverifiedLaunch({
34723
- candidate,
34724
- pid: launch2.pid,
34725
- startedAt: launch2.startedAt,
34726
- cdpPort: cdpPort2
35153
+ if (verifierSurface !== "ready") {
35154
+ const remaining = await stopUnverifiedLaunch({
35155
+ candidate,
35156
+ pid: launch2.pid,
35157
+ startedAt: launch2.startedAt,
35158
+ cdpPort
35159
+ });
35160
+ return {
35161
+ status: "failed",
35162
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "renderer-surface-unavailable",
35163
+ pid: launch2.pid,
35164
+ appServerPid,
35165
+ cdpPort,
35166
+ closedPreviousWindow: false
35167
+ };
35168
+ }
35169
+ if (!await expectedSharedWindowTopologyStillMatches(
35170
+ expectedWindowPreflight,
35171
+ /* @__PURE__ */ new Set([launch2.pid])
35172
+ )) {
35173
+ await stopUnverifiedLaunch({
35174
+ candidate,
35175
+ pid: launch2.pid,
35176
+ startedAt: launch2.startedAt,
35177
+ cdpPort
35178
+ });
35179
+ return {
35180
+ status: "failed",
35181
+ reason: "official-codex-process-state-changed-before-switch",
35182
+ pid: null,
35183
+ closedPreviousWindow: false
35184
+ };
35185
+ }
35186
+ const takeoverVetoReason2 = await resolveStandingTakeoverActivityVeto(options);
35187
+ if (takeoverVetoReason2) {
35188
+ const remaining = await stopUnverifiedLaunch({
35189
+ candidate,
35190
+ pid: launch2.pid,
35191
+ startedAt: launch2.startedAt,
35192
+ cdpPort
35193
+ });
35194
+ return {
35195
+ status: remaining.length > 0 ? "failed" : "skipped",
35196
+ mechanism: "none",
35197
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : takeoverVetoReason2,
35198
+ pid: launch2.pid,
35199
+ appServerPid,
35200
+ cdpPort,
35201
+ closedPreviousWindow: false
35202
+ };
35203
+ }
35204
+ const remainingPlainPids = /* @__PURE__ */ new Set();
35205
+ for (const row of plainSharedRows) {
35206
+ for (const pid of await stopOfficialCodexProcessEpoch({
35207
+ candidate,
35208
+ pid: row.pid,
35209
+ startedAt: row.startedAt,
35210
+ cdpPort: null
35211
+ })) {
35212
+ remainingPlainPids.add(pid);
35213
+ }
35214
+ }
35215
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "previous-window-exit", {
35216
+ remainingCount: remainingPlainPids.size
34727
35217
  });
34728
- return {
34729
- status: "failed",
34730
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "official-codex-target-account-unverified",
34731
- pid: launch2.pid,
34732
- appServerPid: appServerPid2,
34733
- cdpPort: cdpPort2,
34734
- closedPreviousWindow: false
34735
- };
34736
- }
34737
- const verifierSurface = await prepareOfficialCodexRendererSurface(
34738
- replacementTarget.webSocketDebuggerUrl,
34739
- true
34740
- );
34741
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-surface", {
34742
- status: verifierSurface
34743
- });
34744
- if (verifierSurface !== "ready") {
34745
- const remaining = await stopUnverifiedLaunch({
35218
+ if (remainingPlainPids.size > 0) {
35219
+ await stopUnverifiedLaunch({
35220
+ candidate,
35221
+ pid: launch2.pid,
35222
+ startedAt: launch2.startedAt,
35223
+ cdpPort
35224
+ });
35225
+ return {
35226
+ status: "failed",
35227
+ reason: "previous-instance-still-running",
35228
+ pid: null,
35229
+ closedPreviousWindow: false
35230
+ };
35231
+ }
35232
+ closedPreviousWindow = true;
35233
+ await sleep3(POST_EXIT_SETTLE_MS);
35234
+ const remainingVerifierPids = await stopUnverifiedLaunch({
34746
35235
  candidate,
34747
35236
  pid: launch2.pid,
34748
35237
  startedAt: launch2.startedAt,
34749
- cdpPort: cdpPort2
35238
+ cdpPort
34750
35239
  });
34751
- return {
34752
- status: "failed",
34753
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "renderer-surface-unavailable",
34754
- pid: launch2.pid,
34755
- appServerPid: appServerPid2,
34756
- cdpPort: cdpPort2,
34757
- closedPreviousWindow: false
34758
- };
34759
- }
34760
- if (!await expectedSharedWindowTopologyStillMatches(
34761
- expectedWindowPreflight,
34762
- /* @__PURE__ */ new Set([launch2.pid])
34763
- )) {
34764
- await stopUnverifiedLaunch({
34765
- candidate,
34766
- pid: launch2.pid,
34767
- startedAt: launch2.startedAt,
34768
- cdpPort: cdpPort2
35240
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-exit", {
35241
+ remainingCount: remainingVerifierPids.length
34769
35242
  });
34770
- return {
34771
- status: "failed",
34772
- reason: "official-codex-process-state-changed-before-switch",
34773
- pid: null,
34774
- closedPreviousWindow: false
34775
- };
34776
- }
34777
- const takeoverVetoReason2 = await resolveStandingTakeoverActivityVeto(options);
34778
- if (takeoverVetoReason2) {
34779
- const remaining = await stopUnverifiedLaunch({
35243
+ if (remainingVerifierPids.length > 0) {
35244
+ return {
35245
+ status: "failed",
35246
+ reason: "temporary-instance-still-running",
35247
+ pid: launch2.pid,
35248
+ closedPreviousWindow
35249
+ };
35250
+ }
35251
+ sharedHomeCdpWindow = null;
35252
+ rows = await readProcessRows();
35253
+ if (findSharedHomeDebugWindows(rows, candidate).length > 0 || findPlainSharedHomeRows(rows, candidate).length > 0) {
35254
+ return {
35255
+ status: "failed",
35256
+ reason: "official-codex-process-state-changed-before-switch",
35257
+ pid: null,
35258
+ closedPreviousWindow,
35259
+ suppressPlainReopen: true
35260
+ };
35261
+ }
35262
+ const finalLaunch = await openCodexWithProfileHome(
34780
35263
  candidate,
34781
- pid: launch2.pid,
34782
- startedAt: launch2.startedAt,
34783
- cdpPort: cdpPort2
35264
+ SHARED_CODEX_HOME,
35265
+ options.profileName ?? "shared",
35266
+ new Set(rows.map((row) => row.pid)),
35267
+ sharedCodexLaunchOptions(
35268
+ false,
35269
+ options.profileKey ?? options.profileName
35270
+ )
35271
+ );
35272
+ finalLaunchWatchdog = finalLaunch.watchdog;
35273
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "final-launched", {
35274
+ opened: finalLaunch.opened,
35275
+ hasPid: finalLaunch.pid !== null,
35276
+ reason: finalLaunch.reason ?? null
34784
35277
  });
34785
- return {
34786
- status: remaining.length > 0 ? "failed" : "skipped",
34787
- mechanism: "none",
34788
- reason: remaining.length > 0 ? "temporary-instance-still-running" : takeoverVetoReason2,
34789
- pid: launch2.pid,
34790
- appServerPid: appServerPid2,
34791
- cdpPort: cdpPort2,
34792
- closedPreviousWindow: false
34793
- };
34794
- }
34795
- const remainingPlainPids = /* @__PURE__ */ new Set();
34796
- for (const row of plainSharedRows) {
34797
- for (const pid of await stopOfficialCodexProcessEpoch({
34798
- candidate,
34799
- pid: row.pid,
34800
- startedAt: row.startedAt,
34801
- cdpPort: null
34802
- })) {
34803
- remainingPlainPids.add(pid);
35278
+ if (!finalLaunch.opened || finalLaunch.pid === null || finalLaunch.startedAt === null || finalLaunch.cdpPort === null || !finalLaunch.watchdog) {
35279
+ return {
35280
+ status: "failed",
35281
+ reason: finalLaunch.reason ?? "shared-home-launch-failed",
35282
+ pid: null,
35283
+ closedPreviousWindow
35284
+ };
34804
35285
  }
34805
- }
34806
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "previous-window-exit", {
34807
- remainingCount: remainingPlainPids.size
34808
- });
34809
- if (remainingPlainPids.size > 0) {
34810
- await stopUnverifiedLaunch({
34811
- candidate,
34812
- pid: launch2.pid,
34813
- startedAt: launch2.startedAt,
34814
- cdpPort: cdpPort2
35286
+ const finalCdpPort = finalLaunch.cdpPort;
35287
+ const finalAppServerStep = await waitForLaunchStepOrRunaway(
35288
+ waitForAppServerPid(finalLaunch.pid, SHARED_CODEX_HOME),
35289
+ finalLaunch.watchdog
35290
+ );
35291
+ if (finalAppServerStep.kind === "runaway") {
35292
+ return {
35293
+ status: "failed",
35294
+ reason: launchRunawayFailureReason(
35295
+ finalAppServerStep.value,
35296
+ finalLaunch.pid
35297
+ ),
35298
+ pid: finalLaunch.pid,
35299
+ appServerPid: null,
35300
+ cdpPort: finalCdpPort,
35301
+ closedPreviousWindow
35302
+ };
35303
+ }
35304
+ let finalAppServerPid = finalAppServerStep.value;
35305
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "final-app-server", {
35306
+ verified: finalAppServerPid !== null
34815
35307
  });
34816
- return {
34817
- status: "failed",
34818
- reason: "previous-instance-still-running",
34819
- pid: null,
34820
- closedPreviousWindow: false
34821
- };
34822
- }
34823
- closedPreviousWindow = true;
34824
- await sleep3(POST_EXIT_SETTLE_MS);
34825
- const remainingVerifierPids = await stopUnverifiedLaunch({
34826
- candidate,
34827
- pid: launch2.pid,
34828
- startedAt: launch2.startedAt,
34829
- cdpPort: cdpPort2
34830
- });
34831
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "verifier-exit", {
34832
- remainingCount: remainingVerifierPids.length
34833
- });
34834
- if (remainingVerifierPids.length > 0) {
34835
- return {
34836
- status: "failed",
34837
- reason: "temporary-instance-still-running",
34838
- pid: launch2.pid,
34839
- closedPreviousWindow
34840
- };
34841
- }
34842
- sharedHomeCdpWindow = null;
34843
- rows = await readProcessRows();
34844
- if (findSharedHomeDebugWindows(rows, candidate).length > 0 || findPlainSharedHomeRows(rows, candidate).length > 0) {
34845
- return {
34846
- status: "failed",
34847
- reason: "official-codex-process-state-changed-before-switch",
34848
- pid: null,
34849
- closedPreviousWindow,
34850
- suppressPlainReopen: true
34851
- };
34852
- }
34853
- const finalLaunch = await openCodexWithProfileHome(
34854
- candidate,
34855
- SHARED_CODEX_HOME,
34856
- options.profileName ?? "shared",
34857
- new Set(rows.map((row) => row.pid)),
34858
- sharedCodexLaunchOptions(
34859
- false,
34860
- options.profileKey ?? options.profileName
34861
- )
34862
- );
34863
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "final-launched", {
34864
- opened: finalLaunch.opened,
34865
- hasPid: finalLaunch.pid !== null,
34866
- reason: finalLaunch.reason ?? null
34867
- });
34868
- if (!finalLaunch.opened || finalLaunch.pid === null || finalLaunch.startedAt === null || finalLaunch.cdpPort === null || !finalLaunch.watchdog) {
34869
- return {
34870
- status: "failed",
34871
- reason: finalLaunch.reason ?? "shared-home-launch-failed",
34872
- pid: null,
34873
- closedPreviousWindow
34874
- };
34875
- }
34876
- const finalCdpPort = finalLaunch.cdpPort;
34877
- const finalAppServerStep = await waitForLaunchStepOrRunaway(
34878
- waitForAppServerPid(finalLaunch.pid, SHARED_CODEX_HOME),
34879
- finalLaunch.watchdog
34880
- );
34881
- if (finalAppServerStep.kind === "runaway") {
34882
- return {
34883
- status: "failed",
34884
- reason: launchRunawayFailureReason(
34885
- finalAppServerStep.value,
34886
- finalLaunch.pid
34887
- ),
34888
- pid: finalLaunch.pid,
34889
- appServerPid: null,
35308
+ if (finalAppServerPid === null) {
35309
+ const remaining = await stopUnverifiedLaunch({
35310
+ candidate,
35311
+ pid: finalLaunch.pid,
35312
+ startedAt: finalLaunch.startedAt,
35313
+ cdpPort: finalCdpPort
35314
+ });
35315
+ return {
35316
+ status: "failed",
35317
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "app-server-not-verified",
35318
+ pid: finalLaunch.pid,
35319
+ appServerPid: null,
35320
+ cdpPort: finalCdpPort,
35321
+ closedPreviousWindow
35322
+ };
35323
+ }
35324
+ const finalAttestedStep = await waitForLaunchStepOrRunaway(
35325
+ waitForAttestedProcessEpoch({
35326
+ candidate,
35327
+ pid: finalLaunch.pid,
35328
+ appServerPid: finalAppServerPid,
35329
+ startedAt: finalLaunch.startedAt,
35330
+ cdpPort: finalCdpPort
35331
+ }),
35332
+ finalLaunch.watchdog
35333
+ );
35334
+ if (finalAttestedStep.kind === "runaway") {
35335
+ return {
35336
+ status: "failed",
35337
+ reason: launchRunawayFailureReason(
35338
+ finalAttestedStep.value,
35339
+ finalLaunch.pid
35340
+ ),
35341
+ pid: finalLaunch.pid,
35342
+ appServerPid: finalAppServerPid,
35343
+ cdpPort: finalCdpPort,
35344
+ closedPreviousWindow
35345
+ };
35346
+ }
35347
+ if (!finalAttestedStep.value) {
35348
+ const remaining = await stopUnverifiedLaunch({
35349
+ candidate,
35350
+ pid: finalLaunch.pid,
35351
+ startedAt: finalLaunch.startedAt,
35352
+ cdpPort: finalCdpPort
35353
+ });
35354
+ return {
35355
+ status: "failed",
35356
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "process-identity-not-verified",
35357
+ pid: finalLaunch.pid,
35358
+ appServerPid: finalAppServerPid,
35359
+ cdpPort: finalCdpPort,
35360
+ closedPreviousWindow
35361
+ };
35362
+ }
35363
+ sharedHomeCdpWindow = { pid: finalLaunch.pid, cdpPort: finalCdpPort };
35364
+ let bridge = null;
35365
+ if (options.profileName) {
35366
+ await adoptSharedManagedWindow({
35367
+ candidate,
35368
+ pid: finalLaunch.pid,
35369
+ appServerPid: finalAppServerPid,
35370
+ cdpPort: finalCdpPort,
35371
+ startedAt: finalLaunch.startedAt,
35372
+ profileName: options.profileName,
35373
+ profileKey: options.profileKey,
35374
+ desiredQolSettings: options.desiredQolSettings,
35375
+ desiredPowerSettings: options.desiredPowerSettings
35376
+ });
35377
+ bridge = await refreshAdoptedSharedWindow(options.profileName);
35378
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "final-bridge", {
35379
+ healthy: bridge?.bridgeStatus === "healthy",
35380
+ bridgeStatus: bridge?.bridgeStatus ?? null
35381
+ });
35382
+ if (bridge?.bridgeStatus !== "healthy") {
35383
+ const remaining = await stopUnverifiedLaunch({
35384
+ candidate,
35385
+ pid: finalLaunch.pid,
35386
+ startedAt: finalLaunch.startedAt,
35387
+ cdpPort: finalCdpPort
35388
+ });
35389
+ sharedHomeCdpWindow = null;
35390
+ return {
35391
+ status: "failed",
35392
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
35393
+ pid: finalLaunch.pid,
35394
+ appServerPid: finalAppServerPid,
35395
+ cdpPort: finalCdpPort,
35396
+ bridgeStatus: bridge?.bridgeStatus ?? null,
35397
+ bridgeError: bridge?.bridgeError ?? null,
35398
+ bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
35399
+ bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null,
35400
+ closedPreviousWindow
35401
+ };
35402
+ }
35403
+ }
35404
+ const followUp = await applySharedLaunchFollowUp({
34890
35405
  cdpPort: finalCdpPort,
34891
- closedPreviousWindow
34892
- };
34893
- }
34894
- let finalAppServerPid = finalAppServerStep.value;
34895
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "final-app-server", {
34896
- verified: finalAppServerPid !== null
34897
- });
34898
- if (finalAppServerPid === null) {
34899
- const remaining = await stopUnverifiedLaunch({
34900
- candidate,
34901
- pid: finalLaunch.pid,
34902
- startedAt: finalLaunch.startedAt,
34903
- cdpPort: finalCdpPort
35406
+ carriedDraft,
35407
+ carryDraft: options.carryDraft === true,
35408
+ expectedAccount: options.expectedAccount ?? null,
35409
+ allowOnboardingOverride: true
34904
35410
  });
34905
- return {
34906
- status: "failed",
34907
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "app-server-not-verified",
34908
- pid: finalLaunch.pid,
34909
- appServerPid: null,
34910
- cdpPort: finalCdpPort,
34911
- closedPreviousWindow
34912
- };
34913
- }
34914
- const finalAttestedStep = await waitForLaunchStepOrRunaway(
34915
- waitForAttestedProcessEpoch({
35411
+ const reconciliation = await reconcileSharedManagedWindowAfterLaunch({
34916
35412
  candidate,
34917
35413
  pid: finalLaunch.pid,
34918
35414
  appServerPid: finalAppServerPid,
34919
- startedAt: finalLaunch.startedAt,
34920
- cdpPort: finalCdpPort
34921
- }),
34922
- finalLaunch.watchdog
34923
- );
34924
- if (finalAttestedStep.kind === "runaway") {
34925
- return {
34926
- status: "failed",
34927
- reason: launchRunawayFailureReason(
34928
- finalAttestedStep.value,
34929
- finalLaunch.pid
34930
- ),
34931
- pid: finalLaunch.pid,
34932
- appServerPid: finalAppServerPid,
34933
35415
  cdpPort: finalCdpPort,
34934
- closedPreviousWindow
34935
- };
34936
- }
34937
- if (!finalAttestedStep.value) {
34938
- const remaining = await stopUnverifiedLaunch({
34939
- candidate,
34940
- pid: finalLaunch.pid,
34941
35416
  startedAt: finalLaunch.startedAt,
34942
- cdpPort: finalCdpPort
35417
+ profileName: options.profileName,
35418
+ profileKey: options.profileKey,
35419
+ desiredQolSettings: options.desiredQolSettings,
35420
+ desiredPowerSettings: options.desiredPowerSettings,
35421
+ bridge
34943
35422
  });
34944
- return {
34945
- status: "failed",
34946
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "process-identity-not-verified",
34947
- pid: finalLaunch.pid,
34948
- appServerPid: finalAppServerPid,
34949
- cdpPort: finalCdpPort,
34950
- closedPreviousWindow
34951
- };
34952
- }
34953
- sharedHomeCdpWindow = { pid: finalLaunch.pid, cdpPort: finalCdpPort };
34954
- let bridge2 = null;
34955
- if (options.profileName) {
34956
- await adoptSharedManagedWindow({
35423
+ if (reconciliation) {
35424
+ finalAppServerPid = reconciliation.appServerPid;
35425
+ bridge = reconciliation.bridge;
35426
+ }
35427
+ const finalEpoch = reconciliation?.processEpoch ?? null;
35428
+ const finalBridgeVerified = !options.profileName || bridge?.bridgeStatus === "healthy";
35429
+ const finalTopologyVerified = Boolean(
35430
+ finalEpoch && isExclusiveSharedManagedWindow(
35431
+ finalEpoch.rows,
35432
+ candidate,
35433
+ finalLaunch.pid,
35434
+ finalCdpPort
35435
+ )
35436
+ );
35437
+ const accountObservation = finalTopologyVerified && options.expectedAccount ? await readVerifiedTransitionAccountObservation({
34957
35438
  candidate,
34958
35439
  pid: finalLaunch.pid,
34959
35440
  appServerPid: finalAppServerPid,
34960
- cdpPort: finalCdpPort,
34961
35441
  startedAt: finalLaunch.startedAt,
34962
- profileName: options.profileName,
34963
- profileKey: options.profileKey,
34964
- desiredQolSettings: options.desiredQolSettings,
34965
- desiredPowerSettings: options.desiredPowerSettings
34966
- });
34967
- bridge2 = await refreshAdoptedSharedWindow(options.profileName);
34968
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "final-bridge", {
34969
- healthy: bridge2?.bridgeStatus === "healthy",
34970
- bridgeStatus: bridge2?.bridgeStatus ?? null
34971
- });
34972
- if (bridge2?.bridgeStatus !== "healthy") {
35442
+ cdpPort: finalCdpPort,
35443
+ expectedAccount: options.expectedAccount
35444
+ }) : null;
35445
+ if (!followUp.verified || !finalTopologyVerified || !finalBridgeVerified || !accountObservation) {
34973
35446
  const remaining = await stopUnverifiedLaunch({
34974
35447
  candidate,
34975
35448
  pid: finalLaunch.pid,
@@ -34979,114 +35452,47 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
34979
35452
  sharedHomeCdpWindow = null;
34980
35453
  return {
34981
35454
  status: "failed",
34982
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
35455
+ mechanism: "relaunch",
35456
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : !finalEpoch ? "observed-process-identity-changed" : !finalTopologyVerified ? "official-codex-process-state-changed-before-switch" : !finalBridgeVerified ? "bridge-not-healthy-after-launch" : !accountObservation ? "official-codex-target-account-unverified" : followUp.reason,
34983
35457
  pid: finalLaunch.pid,
34984
35458
  appServerPid: finalAppServerPid,
34985
35459
  cdpPort: finalCdpPort,
34986
- bridgeStatus: bridge2?.bridgeStatus ?? null,
34987
- bridgeError: bridge2?.bridgeError ?? null,
34988
- bridgeActiveThreadId: bridge2?.bridgeActiveThreadId ?? null,
34989
- bridgeWorkspacePath: bridge2?.bridgeWorkspacePath ?? null,
34990
- closedPreviousWindow
35460
+ closedPreviousWindow,
35461
+ rendererVerified: false,
35462
+ suppressPlainReopen: true
34991
35463
  };
34992
35464
  }
34993
- }
34994
- const followUp2 = await applySharedLaunchFollowUp({
34995
- cdpPort: finalCdpPort,
34996
- carriedDraft,
34997
- carryDraft: options.carryDraft === true,
34998
- expectedAccount: options.expectedAccount ?? null,
34999
- allowOnboardingOverride: true
35000
- });
35001
- const reconciliation2 = await reconcileSharedManagedWindowAfterLaunch({
35002
- candidate,
35003
- pid: finalLaunch.pid,
35004
- appServerPid: finalAppServerPid,
35005
- cdpPort: finalCdpPort,
35006
- startedAt: finalLaunch.startedAt,
35007
- profileName: options.profileName,
35008
- profileKey: options.profileKey,
35009
- desiredQolSettings: options.desiredQolSettings,
35010
- desiredPowerSettings: options.desiredPowerSettings,
35011
- bridge: bridge2
35012
- });
35013
- if (reconciliation2) {
35014
- finalAppServerPid = reconciliation2.appServerPid;
35015
- bridge2 = reconciliation2.bridge;
35016
- }
35017
- const finalEpoch2 = reconciliation2?.processEpoch ?? null;
35018
- const finalBridgeVerified2 = !options.profileName || bridge2?.bridgeStatus === "healthy";
35019
- const finalTopologyVerified2 = Boolean(
35020
- finalEpoch2 && isExclusiveSharedManagedWindow(
35021
- finalEpoch2.rows,
35022
- candidate,
35023
- finalLaunch.pid,
35024
- finalCdpPort
35025
- )
35026
- );
35027
- const accountObservation2 = finalTopologyVerified2 && options.expectedAccount ? await readVerifiedTransitionAccountObservation({
35028
- candidate,
35029
- pid: finalLaunch.pid,
35030
- appServerPid: finalAppServerPid,
35031
- startedAt: finalLaunch.startedAt,
35032
- cdpPort: finalCdpPort,
35033
- expectedAccount: options.expectedAccount
35034
- }) : null;
35035
- if (!followUp2.verified || !finalTopologyVerified2 || !finalBridgeVerified2 || !accountObservation2) {
35036
- const remaining = await stopUnverifiedLaunch({
35037
- candidate,
35038
- pid: finalLaunch.pid,
35039
- startedAt: finalLaunch.startedAt,
35040
- cdpPort: finalCdpPort
35465
+ if (options.profileName) {
35466
+ await recordOfficialCodexManagedAccountObservation(
35467
+ options.profileName,
35468
+ finalLaunch.pid,
35469
+ finalAppServerPid,
35470
+ finalLaunch.startedAt,
35471
+ finalCdpPort
35472
+ );
35473
+ }
35474
+ logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "completed", {
35475
+ status: "launched"
35041
35476
  });
35042
- sharedHomeCdpWindow = null;
35043
35477
  return {
35044
- status: "failed",
35478
+ status: "launched",
35045
35479
  mechanism: "relaunch",
35046
- reason: remaining.length > 0 ? "temporary-instance-still-running" : !finalEpoch2 ? "observed-process-identity-changed" : !finalTopologyVerified2 ? "official-codex-process-state-changed-before-switch" : !finalBridgeVerified2 ? "bridge-not-healthy-after-launch" : !accountObservation2 ? "official-codex-target-account-unverified" : followUp2.reason,
35480
+ reason: null,
35047
35481
  pid: finalLaunch.pid,
35048
35482
  appServerPid: finalAppServerPid,
35049
35483
  cdpPort: finalCdpPort,
35484
+ bridgeStatus: bridge?.bridgeStatus ?? null,
35485
+ bridgeError: bridge?.bridgeError ?? null,
35486
+ bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
35487
+ bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null,
35050
35488
  closedPreviousWindow,
35051
- rendererVerified: false,
35052
- suppressPlainReopen: true
35489
+ rendererVerified: true,
35490
+ accountObservation
35053
35491
  };
35492
+ } finally {
35493
+ launch2.watchdog.cancel();
35494
+ finalLaunchWatchdog?.cancel();
35054
35495
  }
35055
- if (options.profileName) {
35056
- await recordOfficialCodexManagedAccountObservation(
35057
- options.profileName,
35058
- finalLaunch.pid,
35059
- finalAppServerPid,
35060
- finalLaunch.startedAt,
35061
- finalCdpPort
35062
- );
35063
- recordManagedLaunchRunaway({
35064
- watchdog: finalLaunch.watchdog,
35065
- candidate,
35066
- profileName: options.profileName,
35067
- pid: finalLaunch.pid,
35068
- startedAt: finalLaunch.startedAt,
35069
- cdpPort: finalCdpPort
35070
- });
35071
- }
35072
- logOfficialCodexTakeoverPhase(takeoverTrace, candidate, "completed", {
35073
- status: "launched"
35074
- });
35075
- return {
35076
- status: "launched",
35077
- mechanism: "relaunch",
35078
- reason: null,
35079
- pid: finalLaunch.pid,
35080
- appServerPid: finalAppServerPid,
35081
- cdpPort: finalCdpPort,
35082
- bridgeStatus: bridge2?.bridgeStatus ?? null,
35083
- bridgeError: bridge2?.bridgeError ?? null,
35084
- bridgeActiveThreadId: bridge2?.bridgeActiveThreadId ?? null,
35085
- bridgeWorkspacePath: bridge2?.bridgeWorkspacePath ?? null,
35086
- closedPreviousWindow,
35087
- rendererVerified: true,
35088
- accountObservation: accountObservation2
35089
- };
35090
35496
  }
35091
35497
  if (plainSharedRows.length > 0 && !await expectedSharedWindowTopologyStillMatches(
35092
35498
  expectedWindowPreflight
@@ -35148,6 +35554,7 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
35148
35554
  sharedCodexLaunchOptions(true)
35149
35555
  );
35150
35556
  if (!launch.opened || launch.pid === null || launch.startedAt === null || launch.cdpPort === null || !launch.watchdog) {
35557
+ launch.watchdog?.cancel();
35151
35558
  return {
35152
35559
  status: "failed",
35153
35560
  reason: launch.reason ?? "shared-home-launch-failed",
@@ -35155,90 +35562,154 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
35155
35562
  closedPreviousWindow
35156
35563
  };
35157
35564
  }
35158
- const cdpPort = launch.cdpPort;
35159
- const appServerStep = await waitForLaunchStepOrRunaway(
35160
- waitForAppServerPid(launch.pid, SHARED_CODEX_HOME),
35161
- launch.watchdog
35162
- );
35163
- if (appServerStep.kind === "runaway") {
35164
- return {
35165
- status: "failed",
35166
- reason: launchRunawayFailureReason(appServerStep.value, launch.pid),
35167
- pid: launch.pid,
35168
- appServerPid: null,
35565
+ try {
35566
+ const cdpPort = launch.cdpPort;
35567
+ const appServerStep = await waitForLaunchStepOrRunaway(
35568
+ waitForAppServerPid(launch.pid, SHARED_CODEX_HOME),
35569
+ launch.watchdog
35570
+ );
35571
+ if (appServerStep.kind === "runaway") {
35572
+ return {
35573
+ status: "failed",
35574
+ reason: launchRunawayFailureReason(appServerStep.value, launch.pid),
35575
+ pid: launch.pid,
35576
+ appServerPid: null,
35577
+ cdpPort,
35578
+ closedPreviousWindow
35579
+ };
35580
+ }
35581
+ let appServerPid = appServerStep.value;
35582
+ if (appServerPid === null) {
35583
+ const remaining = await stopUnverifiedLaunch({
35584
+ candidate,
35585
+ pid: launch.pid,
35586
+ startedAt: launch.startedAt,
35587
+ cdpPort
35588
+ });
35589
+ return {
35590
+ status: "failed",
35591
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "app-server-not-verified",
35592
+ pid: launch.pid,
35593
+ appServerPid: null,
35594
+ cdpPort,
35595
+ closedPreviousWindow
35596
+ };
35597
+ }
35598
+ const attestedStep = await waitForLaunchStepOrRunaway(
35599
+ waitForAttestedProcessEpoch({
35600
+ candidate,
35601
+ pid: launch.pid,
35602
+ appServerPid,
35603
+ startedAt: launch.startedAt,
35604
+ cdpPort
35605
+ }),
35606
+ launch.watchdog
35607
+ );
35608
+ if (attestedStep.kind === "runaway") {
35609
+ return {
35610
+ status: "failed",
35611
+ reason: launchRunawayFailureReason(attestedStep.value, launch.pid),
35612
+ pid: launch.pid,
35613
+ appServerPid,
35614
+ cdpPort,
35615
+ closedPreviousWindow
35616
+ };
35617
+ }
35618
+ if (!attestedStep.value) {
35619
+ const remaining = await stopUnverifiedLaunch({
35620
+ candidate,
35621
+ pid: launch.pid,
35622
+ startedAt: launch.startedAt,
35623
+ cdpPort
35624
+ });
35625
+ return {
35626
+ status: "failed",
35627
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "process-identity-not-verified",
35628
+ pid: launch.pid,
35629
+ appServerPid,
35630
+ cdpPort,
35631
+ closedPreviousWindow
35632
+ };
35633
+ }
35634
+ sharedHomeCdpWindow = { pid: launch.pid, cdpPort };
35635
+ let bridge = null;
35636
+ if (options.profileName) {
35637
+ await adoptSharedManagedWindow({
35638
+ candidate,
35639
+ pid: launch.pid,
35640
+ appServerPid,
35641
+ cdpPort,
35642
+ startedAt: launch.startedAt,
35643
+ profileName: options.profileName,
35644
+ profileKey: options.profileKey,
35645
+ desiredQolSettings: options.desiredQolSettings,
35646
+ desiredPowerSettings: options.desiredPowerSettings
35647
+ });
35648
+ bridge = await refreshAdoptedSharedWindow(options.profileName);
35649
+ if (bridge?.bridgeStatus !== "healthy") {
35650
+ const remaining = await stopUnverifiedLaunch({
35651
+ candidate,
35652
+ pid: launch.pid,
35653
+ startedAt: launch.startedAt,
35654
+ cdpPort
35655
+ });
35656
+ sharedHomeCdpWindow = null;
35657
+ return {
35658
+ status: "failed",
35659
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
35660
+ pid: launch.pid,
35661
+ appServerPid,
35662
+ cdpPort,
35663
+ bridgeStatus: bridge?.bridgeStatus ?? null,
35664
+ bridgeError: bridge?.bridgeError ?? null,
35665
+ bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
35666
+ bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null,
35667
+ closedPreviousWindow
35668
+ };
35669
+ }
35670
+ }
35671
+ const followUp = await applySharedLaunchFollowUp({
35169
35672
  cdpPort,
35170
- closedPreviousWindow
35171
- };
35172
- }
35173
- let appServerPid = appServerStep.value;
35174
- if (appServerPid === null) {
35175
- const remaining = await stopUnverifiedLaunch({
35176
- candidate,
35177
- pid: launch.pid,
35178
- startedAt: launch.startedAt,
35179
- cdpPort
35673
+ carriedDraft,
35674
+ carryDraft: options.carryDraft === true,
35675
+ expectedAccount: options.expectedAccount ?? null,
35676
+ allowOnboardingOverride: false
35180
35677
  });
35181
- return {
35182
- status: "failed",
35183
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "app-server-not-verified",
35184
- pid: launch.pid,
35185
- appServerPid: null,
35186
- cdpPort,
35187
- closedPreviousWindow
35188
- };
35189
- }
35190
- const attestedStep = await waitForLaunchStepOrRunaway(
35191
- waitForAttestedProcessEpoch({
35678
+ const reconciliation = await reconcileSharedManagedWindowAfterLaunch({
35192
35679
  candidate,
35193
35680
  pid: launch.pid,
35194
35681
  appServerPid,
35195
- startedAt: launch.startedAt,
35196
- cdpPort
35197
- }),
35198
- launch.watchdog
35199
- );
35200
- if (attestedStep.kind === "runaway") {
35201
- return {
35202
- status: "failed",
35203
- reason: launchRunawayFailureReason(attestedStep.value, launch.pid),
35204
- pid: launch.pid,
35205
- appServerPid,
35206
35682
  cdpPort,
35207
- closedPreviousWindow
35208
- };
35209
- }
35210
- if (!attestedStep.value) {
35211
- const remaining = await stopUnverifiedLaunch({
35212
- candidate,
35213
- pid: launch.pid,
35214
35683
  startedAt: launch.startedAt,
35215
- cdpPort
35684
+ profileName: options.profileName,
35685
+ profileKey: options.profileKey,
35686
+ desiredQolSettings: options.desiredQolSettings,
35687
+ desiredPowerSettings: options.desiredPowerSettings,
35688
+ bridge
35216
35689
  });
35217
- return {
35218
- status: "failed",
35219
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "process-identity-not-verified",
35220
- pid: launch.pid,
35221
- appServerPid,
35222
- cdpPort,
35223
- closedPreviousWindow
35224
- };
35225
- }
35226
- sharedHomeCdpWindow = { pid: launch.pid, cdpPort };
35227
- let bridge = null;
35228
- if (options.profileName) {
35229
- await adoptSharedManagedWindow({
35690
+ if (reconciliation) {
35691
+ appServerPid = reconciliation.appServerPid;
35692
+ bridge = reconciliation.bridge;
35693
+ }
35694
+ const finalEpoch = reconciliation?.processEpoch ?? null;
35695
+ const finalBridgeVerified = !options.profileName || bridge?.bridgeStatus === "healthy";
35696
+ const finalTopologyVerified = Boolean(
35697
+ finalEpoch && isExclusiveSharedManagedWindow(
35698
+ finalEpoch.rows,
35699
+ candidate,
35700
+ launch.pid,
35701
+ cdpPort
35702
+ )
35703
+ );
35704
+ const accountObservation = finalTopologyVerified && options.expectedAccount ? await readVerifiedTransitionAccountObservation({
35230
35705
  candidate,
35231
35706
  pid: launch.pid,
35232
35707
  appServerPid,
35233
- cdpPort,
35234
35708
  startedAt: launch.startedAt,
35235
- profileName: options.profileName,
35236
- profileKey: options.profileKey,
35237
- desiredQolSettings: options.desiredQolSettings,
35238
- desiredPowerSettings: options.desiredPowerSettings
35239
- });
35240
- bridge = await refreshAdoptedSharedWindow(options.profileName);
35241
- if (bridge?.bridgeStatus !== "healthy") {
35709
+ cdpPort,
35710
+ expectedAccount: options.expectedAccount
35711
+ }) : null;
35712
+ if (!followUp.verified || !finalTopologyVerified || !finalBridgeVerified || !accountObservation) {
35242
35713
  const remaining = await stopUnverifiedLaunch({
35243
35714
  candidate,
35244
35715
  pid: launch.pid,
@@ -35248,111 +35719,43 @@ async function applyOfficialCodexLiveAccountSwitchOnce(options = {}, takeoverTra
35248
35719
  sharedHomeCdpWindow = null;
35249
35720
  return {
35250
35721
  status: "failed",
35251
- reason: remaining.length > 0 ? "temporary-instance-still-running" : "bridge-not-healthy-after-launch",
35722
+ mechanism: "relaunch",
35723
+ reason: remaining.length > 0 ? "temporary-instance-still-running" : !finalEpoch ? "observed-process-identity-changed" : !finalTopologyVerified ? "official-codex-process-state-changed-before-switch" : !finalBridgeVerified ? "bridge-not-healthy-after-launch" : !accountObservation ? "official-codex-target-account-unverified" : followUp.reason,
35252
35724
  pid: launch.pid,
35253
35725
  appServerPid,
35254
35726
  cdpPort,
35255
- bridgeStatus: bridge?.bridgeStatus ?? null,
35256
- bridgeError: bridge?.bridgeError ?? null,
35257
- bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
35258
- bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null,
35259
- closedPreviousWindow
35727
+ closedPreviousWindow,
35728
+ rendererVerified: false,
35729
+ suppressPlainReopen: true
35260
35730
  };
35261
35731
  }
35262
- }
35263
- const followUp = await applySharedLaunchFollowUp({
35264
- cdpPort,
35265
- carriedDraft,
35266
- carryDraft: options.carryDraft === true,
35267
- expectedAccount: options.expectedAccount ?? null,
35268
- allowOnboardingOverride: false
35269
- });
35270
- const reconciliation = await reconcileSharedManagedWindowAfterLaunch({
35271
- candidate,
35272
- pid: launch.pid,
35273
- appServerPid,
35274
- cdpPort,
35275
- startedAt: launch.startedAt,
35276
- profileName: options.profileName,
35277
- profileKey: options.profileKey,
35278
- desiredQolSettings: options.desiredQolSettings,
35279
- desiredPowerSettings: options.desiredPowerSettings,
35280
- bridge
35281
- });
35282
- if (reconciliation) {
35283
- appServerPid = reconciliation.appServerPid;
35284
- bridge = reconciliation.bridge;
35285
- }
35286
- const finalEpoch = reconciliation?.processEpoch ?? null;
35287
- const finalBridgeVerified = !options.profileName || bridge?.bridgeStatus === "healthy";
35288
- const finalTopologyVerified = Boolean(
35289
- finalEpoch && isExclusiveSharedManagedWindow(
35290
- finalEpoch.rows,
35291
- candidate,
35292
- launch.pid,
35293
- cdpPort
35294
- )
35295
- );
35296
- const accountObservation = finalTopologyVerified && options.expectedAccount ? await readVerifiedTransitionAccountObservation({
35297
- candidate,
35298
- pid: launch.pid,
35299
- appServerPid,
35300
- startedAt: launch.startedAt,
35301
- cdpPort,
35302
- expectedAccount: options.expectedAccount
35303
- }) : null;
35304
- if (!followUp.verified || !finalTopologyVerified || !finalBridgeVerified || !accountObservation) {
35305
- const remaining = await stopUnverifiedLaunch({
35306
- candidate,
35307
- pid: launch.pid,
35308
- startedAt: launch.startedAt,
35309
- cdpPort
35310
- });
35311
- sharedHomeCdpWindow = null;
35732
+ if (options.profileName) {
35733
+ await recordOfficialCodexManagedAccountObservation(
35734
+ options.profileName,
35735
+ launch.pid,
35736
+ appServerPid,
35737
+ launch.startedAt,
35738
+ cdpPort
35739
+ );
35740
+ }
35312
35741
  return {
35313
- status: "failed",
35742
+ status: "launched",
35314
35743
  mechanism: "relaunch",
35315
- reason: remaining.length > 0 ? "temporary-instance-still-running" : !finalEpoch ? "observed-process-identity-changed" : !finalTopologyVerified ? "official-codex-process-state-changed-before-switch" : !finalBridgeVerified ? "bridge-not-healthy-after-launch" : !accountObservation ? "official-codex-target-account-unverified" : followUp.reason,
35744
+ reason: null,
35316
35745
  pid: launch.pid,
35317
35746
  appServerPid,
35318
35747
  cdpPort,
35748
+ bridgeStatus: bridge?.bridgeStatus ?? null,
35749
+ bridgeError: bridge?.bridgeError ?? null,
35750
+ bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
35751
+ bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null,
35319
35752
  closedPreviousWindow,
35320
- rendererVerified: false,
35321
- suppressPlainReopen: true
35753
+ rendererVerified: true,
35754
+ accountObservation
35322
35755
  };
35756
+ } finally {
35757
+ launch.watchdog.cancel();
35323
35758
  }
35324
- if (options.profileName) {
35325
- await recordOfficialCodexManagedAccountObservation(
35326
- options.profileName,
35327
- launch.pid,
35328
- appServerPid,
35329
- launch.startedAt,
35330
- cdpPort
35331
- );
35332
- recordManagedLaunchRunaway({
35333
- watchdog: launch.watchdog,
35334
- candidate,
35335
- profileName: options.profileName,
35336
- pid: launch.pid,
35337
- startedAt: launch.startedAt,
35338
- cdpPort
35339
- });
35340
- }
35341
- return {
35342
- status: "launched",
35343
- mechanism: "relaunch",
35344
- reason: null,
35345
- pid: launch.pid,
35346
- appServerPid,
35347
- cdpPort,
35348
- bridgeStatus: bridge?.bridgeStatus ?? null,
35349
- bridgeError: bridge?.bridgeError ?? null,
35350
- bridgeActiveThreadId: bridge?.bridgeActiveThreadId ?? null,
35351
- bridgeWorkspacePath: bridge?.bridgeWorkspacePath ?? null,
35352
- closedPreviousWindow,
35353
- rendererVerified: true,
35354
- accountObservation
35355
- };
35356
35759
  }
35357
35760
  function applyOfficialCodexLiveAccountSwitch(options = {}) {
35358
35761
  return enqueueProfileAction("shared-window", async () => {
@@ -35868,6 +36271,8 @@ async function launchOfficialCodexProfileInstanceOnce(options) {
35868
36271
  };
35869
36272
  }
35870
36273
  if (!launch.opened) {
36274
+ launch.watchdog?.cancel();
36275
+ launchedProcess = null;
35871
36276
  const reason = launch.reason ?? "open-failed";
35872
36277
  const failed = failedLaunchState({
35873
36278
  reason,
@@ -36031,14 +36436,7 @@ async function launchOfficialCodexProfileInstanceOnce(options) {
36031
36436
  lastError: null
36032
36437
  };
36033
36438
  await patchManagedInstance(instance);
36034
- recordManagedLaunchRunaway({
36035
- watchdog: launchWatchdog,
36036
- candidate,
36037
- profileName: options.profileName,
36038
- pid: launchedPid,
36039
- startedAt: launch.startedAt,
36040
- cdpPort
36041
- });
36439
+ launchWatchdog.cancel();
36042
36440
  launchedProcess = null;
36043
36441
  return {
36044
36442
  status: "started",
@@ -42744,9 +43142,9 @@ Runs the profile bound to the current workspace. --profile warns when it overrid
42744
43142
  }
42745
43143
  const profileName = readOption(flags, "--profile", "-p");
42746
43144
  const allowedFlags = profileName ? /* @__PURE__ */ new Set(["--profile", "-p", "--strict", profileName, `--profile=${profileName}`]) : /* @__PURE__ */ new Set(["--strict"]);
42747
- const unsupported = flags.filter((entry) => !allowedFlags.has(entry));
42748
- if (unsupported.length > 0) {
42749
- throw new Error(`Unsupported run option: ${unsupported[0]}`);
43145
+ const unsupported2 = flags.filter((entry) => !allowedFlags.has(entry));
43146
+ if (unsupported2.length > 0) {
43147
+ throw new Error(`Unsupported run option: ${unsupported2[0]}`);
42750
43148
  }
42751
43149
  if (codexArgs.some(
42752
43150
  (entry) => entry === "-C" || entry.startsWith("-C") && entry.length > 2 || entry === "--cd" || entry.startsWith("--cd=") || entry === "--cwd" || entry.startsWith("--cwd=")
@@ -46060,7 +46458,7 @@ async function ensureCliStorageReady() {
46060
46458
  }
46061
46459
 
46062
46460
  // src/app/main.ts
46063
- var VERSION = true ? "6.1.0" : "0.0.0";
46461
+ var VERSION = true ? "6.1.1" : "0.0.0";
46064
46462
  async function runCli() {
46065
46463
  const args2 = process.argv.slice(2);
46066
46464
  if (args2.length === 0) {