@agiflowai/agent-cli 0.2.2 → 0.2.4

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.
@@ -1,22 +1,22 @@
1
1
  import * as so from "os";
2
- import Er, { homedir as Yn, tmpdir as pS } from "os";
2
+ import Nr, { homedir as Yn, tmpdir as pS } from "os";
3
3
  import * as Wn from "path";
4
- import Le, { join as zt, resolve as En, basename as ao, dirname as ci, parse as dS } from "path";
4
+ import ze, { join as zt, resolve as En, basename as ao, dirname as ci, parse as dS } from "path";
5
5
  import { execSync as Ot, exec as fS, spawn as Ap } from "child_process";
6
6
  import * as Qt from "fs";
7
7
  import Te, { promises as $p, mkdtempSync as hS, writeFileSync as gS, unlinkSync as mS, existsSync as rr, mkdir as Sh, stat as _S, statSync as vS, mkdirSync as bh } from "fs";
8
8
  import { createSlice as dc, createAsyncThunk as fs, configureStore as yS } from "@reduxjs/toolkit";
9
9
  import * as sn from "node:fs/promises";
10
- import * as $r from "node:os";
10
+ import * as Ar from "node:os";
11
11
  import { homedir as Hs } from "node:os";
12
- import * as Rr from "node:path";
12
+ import * as $r from "node:path";
13
13
  import fc from "node:path";
14
14
  import * as SS from "node:crypto";
15
15
  import { randomUUID as bS } from "node:crypto";
16
16
  import "@inquirer/prompts";
17
17
  import { ulid as pt } from "ulidx";
18
18
  import { fileURLToPath as xh } from "node:url";
19
- import * as Nr from "node:fs";
19
+ import * as Rr from "node:fs";
20
20
  import xS from "node:fs";
21
21
  import uo from "pino";
22
22
  import { createServer as kS } from "node:http";
@@ -467,13 +467,13 @@ function zS() {
467
467
  if (Y.isProviderFor(xe, Ve))
468
468
  return W;
469
469
  if (!pe(ce))
470
- for (var ze = we(ce); ; ) {
471
- var Ge = ye(ze);
470
+ for (var Le = we(ce); ; ) {
471
+ var Ge = ye(Le);
472
472
  if (!Ge)
473
473
  return;
474
474
  var lt = X(Ge);
475
475
  if (lt.isProviderFor(xe, Ve))
476
- return Ne(ze), lt;
476
+ return Ne(Le), lt;
477
477
  }
478
478
  }
479
479
  }
@@ -481,23 +481,23 @@ function zS() {
481
481
  return V;
482
482
  }
483
483
  function de(xe, Ve) {
484
- var ze = Ie.get(xe), Ge;
485
- return pe(ze) || (Ge = ze.get(Ve)), pe(Ge) && (Ge = Be(xe, Ve), pe(Ge) || (pe(ze) && (ze = new d(), Ie.set(xe, ze)), ze.set(Ve, Ge))), Ge;
484
+ var Le = Ie.get(xe), Ge;
485
+ return pe(Le) || (Ge = Le.get(Ve)), pe(Ge) && (Ge = Be(xe, Ve), pe(Ge) || (pe(Le) && (Le = new d(), Ie.set(xe, Le)), Le.set(Ve, Ge))), Ge;
486
486
  }
487
487
  function ge(xe) {
488
488
  if (pe(xe))
489
489
  throw new TypeError();
490
490
  return W === xe || Y === xe || !pe(ce) && ce.has(xe);
491
491
  }
492
- function Se(xe, Ve, ze) {
493
- if (!ge(ze))
492
+ function Se(xe, Ve, Le) {
493
+ if (!ge(Le))
494
494
  throw new Error("Metadata provider not registered.");
495
495
  var Ge = de(xe, Ve);
496
- if (Ge !== ze) {
496
+ if (Ge !== Le) {
497
497
  if (!pe(Ge))
498
498
  return !1;
499
499
  var lt = Ie.get(xe);
500
- pe(lt) && (lt = new d(), Ie.set(xe, lt)), lt.set(Ve, ze);
500
+ pe(lt) && (lt = new d(), Ie.set(xe, lt)), lt.set(Ve, Le);
501
501
  }
502
502
  return !0;
503
503
  }
@@ -525,18 +525,18 @@ function zS() {
525
525
  };
526
526
  return l.registerProvider(Y), Y;
527
527
  function ce(ge, Se, xe) {
528
- var Ve = W.get(ge), ze = !1;
528
+ var Ve = W.get(ge), Le = !1;
529
529
  if (pe(Ve)) {
530
530
  if (!xe)
531
531
  return;
532
- Ve = new d(), W.set(ge, Ve), ze = !0;
532
+ Ve = new d(), W.set(ge, Ve), Le = !0;
533
533
  }
534
534
  var Ge = Ve.get(Se);
535
535
  if (pe(Ge)) {
536
536
  if (!xe)
537
537
  return;
538
538
  if (Ge = new d(), Ve.set(Se, Ge), !V.setProvider(ge, Se, Y))
539
- throw Ve.delete(Se), ze && W.delete(ge), new Error("Wrong provider for target.");
539
+ throw Ve.delete(Se), Le && W.delete(ge), new Error("Wrong provider for target.");
540
540
  }
541
541
  return Ge;
542
542
  }
@@ -560,13 +560,13 @@ function zS() {
560
560
  return Ve.get(ge);
561
561
  }
562
562
  function ct(ge, Se, xe, Ve) {
563
- var ze = ce(
563
+ var Le = ce(
564
564
  xe,
565
565
  Ve,
566
566
  /*Create*/
567
567
  !0
568
568
  );
569
- ze.set(ge, Se);
569
+ Le.set(ge, Se);
570
570
  }
571
571
  function Be(ge, Se) {
572
572
  var xe = [], Ve = ce(
@@ -577,7 +577,7 @@ function zS() {
577
577
  );
578
578
  if (pe(Ve))
579
579
  return xe;
580
- for (var ze = Ve.keys(), Ge = we(ze), lt = 0; ; ) {
580
+ for (var Le = Ve.keys(), Ge = we(Le), lt = 0; ; ) {
581
581
  var Pt = ye(Ge);
582
582
  if (!Pt)
583
583
  return xe.length = lt, xe;
@@ -604,8 +604,8 @@ function zS() {
604
604
  if (pe(Ve) || !Ve.delete(ge))
605
605
  return !1;
606
606
  if (Ve.size === 0) {
607
- var ze = W.get(Se);
608
- pe(ze) || (ze.delete(xe), ze.size === 0 && W.delete(ze));
607
+ var Le = W.get(Se);
608
+ pe(Le) || (Le.delete(xe), Le.size === 0 && W.delete(Le));
609
609
  }
610
610
  return !0;
611
611
  }
@@ -902,7 +902,7 @@ function pn() {
902
902
  const t = $n(Object, Js) ?? 0;
903
903
  return t === Number.MAX_SAFE_INTEGER ? gc(Object, Js, Number.MIN_SAFE_INTEGER) : hn(Object, Js, () => t, (e) => e + 1), t;
904
904
  }
905
- const wr = { Request: "Request", Singleton: "Singleton", Transient: "Transient" }, nt = { ConstantValue: "ConstantValue", DynamicValue: "DynamicValue", Factory: "Factory", Instance: "Instance", Provider: "Provider", ResolvedValue: "ResolvedValue", ServiceRedirection: "ServiceRedirection" };
905
+ const Er = { Request: "Request", Singleton: "Singleton", Transient: "Transient" }, nt = { ConstantValue: "ConstantValue", DynamicValue: "DynamicValue", Factory: "Factory", Instance: "Instance", Provider: "Provider", ResolvedValue: "ResolvedValue", ServiceRedirection: "ServiceRedirection" };
906
906
  function* Ih(...t) {
907
907
  for (const e of t) yield* e;
908
908
  }
@@ -2113,14 +2113,14 @@ function kc(t, e) {
2113
2113
  return (r, i) => {
2114
2114
  const n = t(i);
2115
2115
  switch (n.scope) {
2116
- case wr.Singleton:
2116
+ case Er.Singleton:
2117
2117
  return n.cache.isRight ? n.cache.value : Kh(n, Ao(r, n, e(r, i)));
2118
- case wr.Request: {
2118
+ case Er.Request: {
2119
2119
  if (r.requestScopeCache.has(n.id)) return r.requestScopeCache.get(n.id);
2120
2120
  const o = Ao(r, n, e(r, i));
2121
2121
  return r.requestScopeCache.set(n.id, o), o;
2122
2122
  }
2123
- case wr.Transient:
2123
+ case Er.Transient:
2124
2124
  return Ao(r, n, e(r, i));
2125
2125
  }
2126
2126
  };
@@ -2308,7 +2308,7 @@ function Bo(t, e) {
2308
2308
  if (e === void 0) return;
2309
2309
  const r = function(n) {
2310
2310
  const o = [];
2311
- for (const s of n) Sb(s) && s.scope === wr.Singleton && s.cache.isRight && o.push(s);
2311
+ for (const s of n) Sb(s) && s.scope === Er.Singleton && s.cache.isRight && o.push(s);
2312
2312
  return o;
2313
2313
  }(e), i = [];
2314
2314
  for (const n of r) {
@@ -2414,13 +2414,13 @@ class Cb {
2414
2414
  return Ec(this.#e);
2415
2415
  }
2416
2416
  inRequestScope() {
2417
- return this.#e.scope = wr.Request, new In(this.#e);
2417
+ return this.#e.scope = Er.Request, new In(this.#e);
2418
2418
  }
2419
2419
  inSingletonScope() {
2420
- return this.#e.scope = wr.Singleton, new In(this.#e);
2420
+ return this.#e.scope = Er.Singleton, new In(this.#e);
2421
2421
  }
2422
2422
  inTransientScope() {
2423
- return this.#e.scope = wr.Transient, new In(this.#e);
2423
+ return this.#e.scope = Er.Transient, new In(this.#e);
2424
2424
  }
2425
2425
  }
2426
2426
  class Zh {
@@ -2440,7 +2440,7 @@ class Zh {
2440
2440
  return this.to(this.#r);
2441
2441
  }
2442
2442
  toConstantValue(e) {
2443
- const r = { cache: { isRight: !1, value: void 0 }, id: pn(), isSatisfiedBy: bn.always, moduleId: this.#t, onActivation: void 0, onDeactivation: void 0, scope: wr.Singleton, serviceIdentifier: this.#r, type: nt.ConstantValue, value: e };
2443
+ const r = { cache: { isRight: !1, value: void 0 }, id: pn(), isSatisfiedBy: bn.always, moduleId: this.#t, onActivation: void 0, onDeactivation: void 0, scope: Er.Singleton, serviceIdentifier: this.#r, type: nt.ConstantValue, value: e };
2444
2444
  return this.#e(r), new In(r);
2445
2445
  }
2446
2446
  toDynamicValue(e) {
@@ -2452,11 +2452,11 @@ class Zh {
2452
2452
  return this.#e(i), new ra(i);
2453
2453
  }
2454
2454
  toFactory(e) {
2455
- const r = { cache: { isRight: !1, value: void 0 }, factory: e, id: pn(), isSatisfiedBy: bn.always, moduleId: this.#t, onActivation: void 0, onDeactivation: void 0, scope: wr.Singleton, serviceIdentifier: this.#r, type: nt.Factory };
2455
+ const r = { cache: { isRight: !1, value: void 0 }, factory: e, id: pn(), isSatisfiedBy: bn.always, moduleId: this.#t, onActivation: void 0, onDeactivation: void 0, scope: Er.Singleton, serviceIdentifier: this.#r, type: nt.Factory };
2456
2456
  return this.#e(r), new In(r);
2457
2457
  }
2458
2458
  toProvider(e) {
2459
- const r = { cache: { isRight: !1, value: void 0 }, id: pn(), isSatisfiedBy: bn.always, moduleId: this.#t, onActivation: void 0, onDeactivation: void 0, provider: e, scope: wr.Singleton, serviceIdentifier: this.#r, type: nt.Provider };
2459
+ const r = { cache: { isRight: !1, value: void 0 }, id: pn(), isSatisfiedBy: bn.always, moduleId: this.#t, onActivation: void 0, onDeactivation: void 0, provider: e, scope: Er.Singleton, serviceIdentifier: this.#r, type: nt.Provider };
2460
2460
  return this.#e(r), new In(r);
2461
2461
  }
2462
2462
  toService(e) {
@@ -2483,7 +2483,7 @@ class Jh {
2483
2483
  return this.#e.onActivation = e, new cu(this.#e);
2484
2484
  }
2485
2485
  onDeactivation(e) {
2486
- if (this.#e.onDeactivation = e, this.#e.scope !== wr.Singleton) throw new Ur(Mr.invalidOperation, `Binding for service "${Yt(this.#e.serviceIdentifier)}" has a deactivation function, but its scope is not singleton. Deactivation functions can only be used with singleton bindings.`);
2486
+ if (this.#e.onDeactivation = e, this.#e.scope !== Er.Singleton) throw new Ur(Mr.invalidOperation, `Binding for service "${Yt(this.#e.serviceIdentifier)}" has a deactivation function, but its scope is not singleton. Deactivation functions can only be used with singleton bindings.`);
2487
2487
  return new cu(this.#e);
2488
2488
  }
2489
2489
  }
@@ -2899,7 +2899,7 @@ class Ob {
2899
2899
  this.#t.push({ activationService: this.#e.activationService.clone(), bindingService: this.#e.bindingService.clone(), deactivationService: this.#e.deactivationService.clone() });
2900
2900
  }
2901
2901
  }
2902
- const Db = wr.Transient;
2902
+ const Db = Er.Transient;
2903
2903
  class ys {
2904
2904
  #e;
2905
2905
  #t;
@@ -3204,7 +3204,7 @@ const Kb = (t) => {
3204
3204
  function gn(t) {
3205
3205
  return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3206
3206
  }
3207
- function Cr(t, e, r) {
3207
+ function wr(t, e, r) {
3208
3208
  const i = new t._zod.constr(e ?? t._zod.def);
3209
3209
  return (!e || r?.parent) && (i._zod.parent = t), i;
3210
3210
  }
@@ -3276,7 +3276,7 @@ function og(t, e) {
3276
3276
  },
3277
3277
  checks: []
3278
3278
  });
3279
- return Cr(t, i);
3279
+ return wr(t, i);
3280
3280
  }
3281
3281
  function sg(t, e) {
3282
3282
  const r = t._zod.def, i = tn(t._zod.def, {
@@ -3291,7 +3291,7 @@ function sg(t, e) {
3291
3291
  },
3292
3292
  checks: []
3293
3293
  });
3294
- return Cr(t, i);
3294
+ return wr(t, i);
3295
3295
  }
3296
3296
  function ag(t, e) {
3297
3297
  if (!Pn(e))
@@ -3306,7 +3306,7 @@ function ag(t, e) {
3306
3306
  },
3307
3307
  checks: []
3308
3308
  });
3309
- return Cr(t, n);
3309
+ return wr(t, n);
3310
3310
  }
3311
3311
  function ug(t, e) {
3312
3312
  if (!Pn(e))
@@ -3319,7 +3319,7 @@ function ug(t, e) {
3319
3319
  },
3320
3320
  checks: t._zod.def.checks
3321
3321
  };
3322
- return Cr(t, r);
3322
+ return wr(t, r);
3323
3323
  }
3324
3324
  function cg(t, e) {
3325
3325
  const r = tn(t._zod.def, {
@@ -3333,7 +3333,7 @@ function cg(t, e) {
3333
3333
  checks: []
3334
3334
  // delete existing checks
3335
3335
  });
3336
- return Cr(t, r);
3336
+ return wr(t, r);
3337
3337
  }
3338
3338
  function lg(t, e, r) {
3339
3339
  const i = tn(e._zod.def, {
@@ -3358,7 +3358,7 @@ function lg(t, e, r) {
3358
3358
  },
3359
3359
  checks: []
3360
3360
  });
3361
- return Cr(e, i);
3361
+ return wr(e, i);
3362
3362
  }
3363
3363
  function pg(t, e, r) {
3364
3364
  const i = tn(e._zod.def, {
@@ -3383,7 +3383,7 @@ function pg(t, e, r) {
3383
3383
  },
3384
3384
  checks: []
3385
3385
  });
3386
- return Cr(e, i);
3386
+ return wr(e, i);
3387
3387
  }
3388
3388
  function wn(t, e = 0) {
3389
3389
  if (t.aborted === !0)
@@ -3482,7 +3482,7 @@ const hg = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3482
3482
  captureStackTrace: Cc,
3483
3483
  cleanEnum: Zb,
3484
3484
  cleanRegex: bs,
3485
- clone: Cr,
3485
+ clone: wr,
3486
3486
  cloneDef: jb,
3487
3487
  createTransparentProxy: Wb,
3488
3488
  defineLazy: et,
@@ -11406,7 +11406,7 @@ const V1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11406
11406
  _uuidv7: rl,
11407
11407
  _void: l_,
11408
11408
  _xid: ul,
11409
- clone: Cr,
11409
+ clone: wr,
11410
11410
  config: ir,
11411
11411
  decode: rx,
11412
11412
  decodeAsync: ix,
@@ -11506,7 +11506,7 @@ const q1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
11506
11506
  ...e.checks ?? [],
11507
11507
  ...r.map((i) => typeof i == "function" ? { _zod: { check: i, def: { check: "custom" }, onattach: [] } } : i)
11508
11508
  ]
11509
- })), t.clone = (r, i) => Cr(t, r, i), t.brand = () => t, t.register = (r, i) => (r.add(t, i), t), t.parse = (r, i) => N_(t, r, i, { callee: t.parse }), t.safeParse = (r, i) => O_(t, r, i), t.parseAsync = async (r, i) => P_(t, r, i, { callee: t.parseAsync }), t.safeParseAsync = async (r, i) => D_(t, r, i), t.spa = t.safeParseAsync, t.encode = (r, i) => B_(t, r, i), t.decode = (r, i) => U_(t, r, i), t.encodeAsync = async (r, i) => M_(t, r, i), t.decodeAsync = async (r, i) => L_(t, r, i), t.safeEncode = (r, i) => z_(t, r, i), t.safeDecode = (r, i) => F_(t, r, i), t.safeEncodeAsync = async (r, i) => j_(t, r, i), t.safeDecodeAsync = async (r, i) => V_(t, r, i), t.refine = (r, i) => t.check(Ev(r, i)), t.superRefine = (r) => t.check(wv(r)), t.overwrite = (r) => t.check(zn(r)), t.optional = () => Go(t), t.nullable = () => qo(t), t.nullish = () => Go(qo(t)), t.nonoptional = (r) => fv(t, r), t.array = () => sr(t), t.or = (r) => or([t, r]), t.and = (r) => ev(t, r), t.transform = (r) => Ho(t, rp(r)), t.default = (r) => lv(t, r), t.prefault = (r) => dv(t, r), t.catch = (r) => mv(t, r), t.pipe = (r) => Ho(t, r), t.readonly = () => yv(t), t.describe = (r) => {
11509
+ })), t.clone = (r, i) => wr(t, r, i), t.brand = () => t, t.register = (r, i) => (r.add(t, i), t), t.parse = (r, i) => N_(t, r, i, { callee: t.parse }), t.safeParse = (r, i) => O_(t, r, i), t.parseAsync = async (r, i) => P_(t, r, i, { callee: t.parseAsync }), t.safeParseAsync = async (r, i) => D_(t, r, i), t.spa = t.safeParseAsync, t.encode = (r, i) => B_(t, r, i), t.decode = (r, i) => U_(t, r, i), t.encodeAsync = async (r, i) => M_(t, r, i), t.decodeAsync = async (r, i) => L_(t, r, i), t.safeEncode = (r, i) => z_(t, r, i), t.safeDecode = (r, i) => F_(t, r, i), t.safeEncodeAsync = async (r, i) => j_(t, r, i), t.safeDecodeAsync = async (r, i) => V_(t, r, i), t.refine = (r, i) => t.check(Ev(r, i)), t.superRefine = (r) => t.check(wv(r)), t.overwrite = (r) => t.check(zn(r)), t.optional = () => Go(t), t.nullable = () => qo(t), t.nullish = () => Go(qo(t)), t.nonoptional = (r) => fv(t, r), t.array = () => sr(t), t.or = (r) => or([t, r]), t.and = (r) => ev(t, r), t.transform = (r) => Ho(t, rp(r)), t.default = (r) => lv(t, r), t.prefault = (r) => dv(t, r), t.catch = (r) => mv(t, r), t.pipe = (r) => Ho(t, r), t.readonly = () => yv(t), t.describe = (r) => {
11510
11510
  const i = t.clone();
11511
11511
  return Cn.add(i, { description: r }), i;
11512
11512
  }, Object.defineProperty(t, "description", {
@@ -11873,7 +11873,7 @@ function _r(t, e, r) {
11873
11873
  });
11874
11874
  }
11875
11875
  function OE(t, e, r) {
11876
- const i = Cr(t);
11876
+ const i = wr(t);
11877
11877
  return i._zod.values = void 0, new tp({
11878
11878
  type: "record",
11879
11879
  keyType: i,
@@ -12327,7 +12327,7 @@ const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
12327
12327
  check: qE,
12328
12328
  cidrv4: cE,
12329
12329
  cidrv6: lE,
12330
- clone: Cr,
12330
+ clone: wr,
12331
12331
  codec: jE,
12332
12332
  coerce: rw,
12333
12333
  config: ir,
@@ -12493,7 +12493,7 @@ let Ko = class {
12493
12493
  this.runtimeConfig = Cv.parse(t), this.appConfig = sw.parse({
12494
12494
  VITE_INJECT_AGIFLOW_APP_ENDPOINT: "https://agiflow.io",
12495
12495
  VITE_INJECT_AGIFLOW_APP_DOCKER_ENDPOINT: "https://agiflow.io",
12496
- VITE_AGENT_CLI_DOCKER_IMAGE: "agiflowai/agent-cli:v0.2.2",
12496
+ VITE_AGENT_CLI_DOCKER_IMAGE: "agiflowai/agent-cli:v0.2.4",
12497
12497
  VITE_AGENT_CLI_DOCKER_NETWORK: "",
12498
12498
  VITE_SAVE_RAW: "",
12499
12499
  VITE_MULTIPLEX_SOCKET_PATH: process.env.VITE_MULTIPLEX_SOCKET_PATH
@@ -13549,13 +13549,13 @@ let Su = class {
13549
13549
  checkHostAuth(t) {
13550
13550
  if (t !== ft.CLAUDE_CODE)
13551
13551
  return !1;
13552
- const e = Er.homedir(), r = Er.platform() === "darwin";
13552
+ const e = Nr.homedir(), r = Nr.platform() === "darwin";
13553
13553
  try {
13554
13554
  if (r) {
13555
- const i = Le.join(e, ".claude_tmp.json"), n = Le.join(e, ".claude_tmp");
13555
+ const i = ze.join(e, ".claude_tmp.json"), n = ze.join(e, ".claude_tmp");
13556
13556
  return Te.existsSync(i) || Te.existsSync(n);
13557
13557
  } else {
13558
- const i = Le.join(e, ".claude.json"), n = Le.join(e, ".claude");
13558
+ const i = ze.join(e, ".claude.json"), n = ze.join(e, ".claude");
13559
13559
  return Te.existsSync(i) || Te.existsSync(n);
13560
13560
  }
13561
13561
  } catch (i) {
@@ -13569,13 +13569,13 @@ let Su = class {
13569
13569
  checkDockerAuth(t) {
13570
13570
  if (t !== ft.CLAUDE_CODE || !this.isDockerAvailableSync())
13571
13571
  return !1;
13572
- const e = Er.homedir(), r = Er.platform() === "darwin";
13572
+ const e = Nr.homedir(), r = Nr.platform() === "darwin";
13573
13573
  try {
13574
13574
  if (r) {
13575
- const i = Le.join(e, ".claude_tmp.json"), n = Le.join(e, ".claude_tmp");
13575
+ const i = ze.join(e, ".claude_tmp.json"), n = ze.join(e, ".claude_tmp");
13576
13576
  return Te.existsSync(i) || Te.existsSync(n);
13577
13577
  } else {
13578
- const i = Le.join(e, ".claude.json"), n = Le.join(e, ".claude");
13578
+ const i = ze.join(e, ".claude.json"), n = ze.join(e, ".claude");
13579
13579
  return Te.existsSync(i) || Te.existsSync(n);
13580
13580
  }
13581
13581
  } catch (i) {
@@ -14393,7 +14393,7 @@ class tt {
14393
14393
  /**
14394
14394
  * Default Agiflow configuration directory
14395
14395
  */
14396
- static AGIFLOW_DIR = Rr.join(Hs(), ".agiflow");
14396
+ static AGIFLOW_DIR = $r.join(Hs(), ".agiflow");
14397
14397
  /**
14398
14398
  * Ensure a directory exists, creating it if necessary
14399
14399
  */
@@ -14421,7 +14421,7 @@ class tt {
14421
14421
  * Write an object to a JSON file
14422
14422
  */
14423
14423
  static async writeJson(e, r, i) {
14424
- await sn.mkdir(Rr.dirname(e), { recursive: !0 });
14424
+ await sn.mkdir($r.dirname(e), { recursive: !0 });
14425
14425
  const n = JSON.stringify(r, null, i?.spaces ?? 2);
14426
14426
  await sn.writeFile(e, n, "utf-8");
14427
14427
  }
@@ -14447,7 +14447,7 @@ class tt {
14447
14447
  * Resolve a path relative to the current working directory
14448
14448
  */
14449
14449
  static resolvePath(...e) {
14450
- return Rr.resolve(process.cwd(), ...e);
14450
+ return $r.resolve(process.cwd(), ...e);
14451
14451
  }
14452
14452
  /**
14453
14453
  * Get files in a directory matching a pattern
@@ -14462,7 +14462,7 @@ class tt {
14462
14462
  * @returns Resolved absolute path
14463
14463
  */
14464
14464
  static getAbsolutePath(e) {
14465
- return e ? e.startsWith("~/") ? Rr.join(Hs(), e.slice(2)) : e === "~" ? Hs() : Rr.isAbsolute(e) ? e : Rr.resolve(process.cwd(), e) : process.cwd();
14465
+ return e ? e.startsWith("~/") ? $r.join(Hs(), e.slice(2)) : e === "~" ? Hs() : $r.isAbsolute(e) ? e : $r.resolve(process.cwd(), e) : process.cwd();
14466
14466
  }
14467
14467
  }
14468
14468
  const oC = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -14470,7 +14470,7 @@ const oC = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
14470
14470
  FileSystemUtils: tt
14471
14471
  }, Symbol.toStringTag, { value: "Module" }));
14472
14472
  function NN(t = !0, e) {
14473
- const i = $r.hostname().replace(/[^a-zA-Z0-9-]/g, "-");
14473
+ const i = Ar.hostname().replace(/[^a-zA-Z0-9-]/g, "-");
14474
14474
  if (t) {
14475
14475
  const n = e || process.cwd(), o = SS.createHash("sha256").update(n).digest("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "").slice(0, 8);
14476
14476
  return `claude-daemon-${i}-${o}`;
@@ -14479,13 +14479,13 @@ function NN(t = !0, e) {
14479
14479
  }
14480
14480
  function sC() {
14481
14481
  return {
14482
- hostname: $r.hostname(),
14483
- platform: $r.platform(),
14484
- arch: $r.arch(),
14485
- release: $r.release(),
14486
- cpus: $r.cpus().length,
14487
- totalMemory: $r.totalmem(),
14488
- type: $r.type()
14482
+ hostname: Ar.hostname(),
14483
+ platform: Ar.platform(),
14484
+ arch: Ar.arch(),
14485
+ release: Ar.release(),
14486
+ cpus: Ar.cpus().length,
14487
+ totalMemory: Ar.totalmem(),
14488
+ type: Ar.type()
14489
14489
  };
14490
14490
  }
14491
14491
  function PN(t) {
@@ -14512,7 +14512,7 @@ function aC(t, e = 3e5, r) {
14512
14512
  return { start: o, stop: s };
14513
14513
  }
14514
14514
  class uC {
14515
- static SESSIONS_FILE = Le.join(tt.AGIFLOW_DIR, "sessions.json");
14515
+ static SESSIONS_FILE = ze.join(tt.AGIFLOW_DIR, "sessions.json");
14516
14516
  /**
14517
14517
  * Get model settings for a specific session
14518
14518
  */
@@ -14942,45 +14942,137 @@ let ku = class {
14942
14942
  return this.clientId;
14943
14943
  }
14944
14944
  /**
14945
- * Exchange verification token for API key
14946
- * Used by UI components after user completes browser authentication
14945
+ * Request a device code from the device authorization endpoint
14946
+ * RFC 8628 Device Authorization Request
14947
14947
  */
14948
- async exchangeTokenForApiKey(t, e) {
14949
- const r = await fetch(`${this.baseUrl}/api/v1/oauth/device/token`, {
14948
+ async requestDeviceCode(t = "openid profile email") {
14949
+ const e = await fetch(`${this.baseUrl}/api/v1/auth/device/code`, {
14950
14950
  method: "POST",
14951
14951
  headers: {
14952
- "Content-Type": "application/x-www-form-urlencoded"
14952
+ "Content-Type": "application/json"
14953
14953
  },
14954
- body: new URLSearchParams({
14955
- grant_type: "urn:ietf:params:oauth:grant-type:device_code",
14956
- device_code: e,
14957
- verification_token: t.trim(),
14958
- client_id: this.clientId
14954
+ body: JSON.stringify({
14955
+ client_id: this.clientId,
14956
+ scope: t
14957
+ })
14958
+ });
14959
+ if (!e.ok) {
14960
+ const r = await e.json().catch(() => ({}));
14961
+ throw new Error(r.error_description || `Device code request failed: ${e.status}`);
14962
+ }
14963
+ return e.json();
14964
+ }
14965
+ /**
14966
+ * Poll for device token using Better Auth's device token endpoint
14967
+ * RFC 8628 Device Access Token Request
14968
+ * Polls until user approves, denies, or token expires
14969
+ */
14970
+ async pollForToken(t, e, r) {
14971
+ let i = e;
14972
+ for (; ; ) {
14973
+ if (r?.signal?.aborted)
14974
+ throw new Error("Polling aborted");
14975
+ await this.sleep(i * 1e3);
14976
+ const n = await fetch(`${this.baseUrl}/api/v1/auth/device/token`, {
14977
+ method: "POST",
14978
+ headers: {
14979
+ "Content-Type": "application/json"
14980
+ },
14981
+ body: JSON.stringify({
14982
+ grant_type: "urn:ietf:params:oauth:grant-type:device_code",
14983
+ device_code: t,
14984
+ client_id: this.clientId
14985
+ })
14986
+ });
14987
+ if (n.ok)
14988
+ return n.json();
14989
+ const o = await n.json().catch(() => ({
14990
+ error: "authorization_pending"
14991
+ }));
14992
+ switch (o.error) {
14993
+ case "authorization_pending":
14994
+ r?.onPending?.();
14995
+ break;
14996
+ case "slow_down":
14997
+ i += 5, r?.onSlowDown?.();
14998
+ break;
14999
+ case "access_denied":
15000
+ throw new Error("Authorization denied by user");
15001
+ case "expired_token":
15002
+ throw new Error("Device code expired. Please start the authorization process again.");
15003
+ default:
15004
+ throw new Error(o.error_description || `Token request failed: ${o.error}`);
15005
+ }
15006
+ }
15007
+ }
15008
+ /**
15009
+ * List user's organizations from the access token
15010
+ * Used to let user select which organization the CLI agent should belong to
15011
+ */
15012
+ async listOrganizations(t) {
15013
+ const e = await fetch(`${this.baseUrl}/api/v1/cli/organizations`, {
15014
+ method: "GET",
15015
+ headers: {
15016
+ "Content-Type": "application/json",
15017
+ Authorization: `Bearer ${t}`
15018
+ }
15019
+ });
15020
+ if (!e.ok) {
15021
+ const i = await e.text();
15022
+ throw new Error(`Failed to list organizations: ${e.status} ${i}`);
15023
+ }
15024
+ return (await e.json()).organizations || [];
15025
+ }
15026
+ /**
15027
+ * Exchange user's access token for an agent API key in a specific organization
15028
+ * Creates or finds CLI daemon agent member and returns its API key
15029
+ */
15030
+ async exchangeForAgentApiKey(t, e) {
15031
+ const r = await fetch(`${this.baseUrl}/api/v1/cli/exchange-for-agent`, {
15032
+ method: "POST",
15033
+ headers: {
15034
+ "Content-Type": "application/json",
15035
+ Authorization: `Bearer ${t}`
15036
+ },
15037
+ body: JSON.stringify({
15038
+ organizationId: e
14959
15039
  })
14960
15040
  });
14961
15041
  if (!r.ok) {
14962
- const o = await r.text();
14963
- throw new Error(`Token exchange failed: ${r.status} ${o}`);
15042
+ const n = await r.text();
15043
+ throw new Error(`Failed to exchange for agent API key: ${r.status} ${n}`);
14964
15044
  }
14965
15045
  const i = await r.json();
14966
- if (!i.api_key)
14967
- throw new Error("Token exchange response missing api_key");
14968
- if (!i.organization_id)
14969
- throw new Error("Token exchange response missing organization_id");
14970
15046
  return {
14971
15047
  api_key: i.api_key,
14972
- key_id: "device-flow",
14973
- expires_at: Date.now() + i.expires_in * 1e3,
15048
+ key_id: i.key_id,
15049
+ expires_at: i.expires_at || Date.now() + 365 * 24 * 60 * 60 * 1e3,
14974
15050
  organization_id: i.organization_id,
14975
15051
  prefix: "agiflow_"
14976
15052
  };
14977
15053
  }
15054
+ /**
15055
+ * @deprecated Use listOrganizations + exchangeForAgentApiKey instead
15056
+ * Kept for backward compatibility
15057
+ */
15058
+ async createApiKeyFromToken(t) {
15059
+ const e = await this.listOrganizations(t);
15060
+ if (e.length === 0)
15061
+ throw new Error("User has no organizations");
15062
+ return this.exchangeForAgentApiKey(t, e[0].id);
15063
+ }
14978
15064
  /**
14979
15065
  * Check if token is still valid (with 5 minute buffer)
14980
15066
  */
14981
15067
  isTokenValid(t) {
14982
15068
  return Date.now() < t - 3e5;
14983
15069
  }
15070
+ /**
15071
+ * Helper to sleep for a specified duration
15072
+ */
15073
+ sleep(t) {
15074
+ return new Promise((e) => setTimeout(e, t));
15075
+ }
14984
15076
  };
14985
15077
  ku = gC([
14986
15078
  Ae(),
@@ -15232,7 +15324,7 @@ var wC = Object.getOwnPropertyDescriptor, CC = (t, e, r, i) => {
15232
15324
  (s = t[o]) && (n = s(n) || n);
15233
15325
  return n;
15234
15326
  };
15235
- const IC = xh(import.meta.url), ia = Le.dirname(IC);
15327
+ const IC = xh(import.meta.url), ia = ze.dirname(IC);
15236
15328
  let wu = class {
15237
15329
  distFolderCache = null;
15238
15330
  hookFileCache = /* @__PURE__ */ new Map();
@@ -15244,13 +15336,13 @@ let wu = class {
15244
15336
  if (this.distFolderCache !== null)
15245
15337
  return this.distFolderCache;
15246
15338
  const t = [
15247
- Le.join(ia, "..", "..", "dist"),
15339
+ ze.join(ia, "..", "..", "dist"),
15248
15340
  // Development structure (src/services/core -> dist)
15249
- Le.join(ia, "..", "dist"),
15341
+ ze.join(ia, "..", "dist"),
15250
15342
  // One level up (services -> dist)
15251
- Le.join(ia, "dist"),
15343
+ ze.join(ia, "dist"),
15252
15344
  // Same level
15253
- Le.join(process.cwd(), "dist")
15345
+ ze.join(process.cwd(), "dist")
15254
15346
  // From current working directory
15255
15347
  ];
15256
15348
  for (const e of t)
@@ -15271,7 +15363,7 @@ let wu = class {
15271
15363
  const e = this.findDistFolder();
15272
15364
  if (!e)
15273
15365
  return this.hookFileCache.set(t, null), null;
15274
- const r = Le.join(e, t);
15366
+ const r = ze.join(e, t);
15275
15367
  return Te.existsSync(r) ? (this.hookFileCache.set(t, r), r) : (this.hookFileCache.set(t, null), null);
15276
15368
  }
15277
15369
  };
@@ -15296,9 +15388,9 @@ let At = class {
15296
15388
  * Uses pino-roll for automatic size-based rotation (max 10MB per file)
15297
15389
  */
15298
15390
  createMultiTransportLogger(t) {
15299
- const e = Rr.join($r.tmpdir(), "agiflow-agents", "logs", `session-${process.pid}`);
15300
- Nr.existsSync(e) || Nr.mkdirSync(e, { recursive: !0 });
15301
- const r = Rr.join(e, "app.log"), i = uo({
15391
+ const e = $r.join(Ar.tmpdir(), "agiflow-agents", "logs", `session-${process.pid}`);
15392
+ Rr.existsSync(e) || Rr.mkdirSync(e, { recursive: !0 });
15393
+ const r = $r.join(e, "app.log"), i = uo({
15302
15394
  level: t,
15303
15395
  formatters: {
15304
15396
  level: (n) => ({ level: n })
@@ -15338,8 +15430,8 @@ let At = class {
15338
15430
  * Get the log file path if file transport is configured
15339
15431
  */
15340
15432
  getLogFilePath() {
15341
- const t = Rr.join($r.tmpdir(), "agiflow-agents", "logs", `session-${process.pid}`);
15342
- return Rr.join(t, "app.log");
15433
+ const t = $r.join(Ar.tmpdir(), "agiflow-agents", "logs", `session-${process.pid}`);
15434
+ return $r.join(t, "app.log");
15343
15435
  }
15344
15436
  /**
15345
15437
  * Log an informational message
@@ -15921,7 +16013,7 @@ let Un = class {
15921
16013
  const t = this.config.unixSocketPath;
15922
16014
  this.actualSocketPath = t;
15923
16015
  const e = fc.dirname(t);
15924
- Nr.existsSync(e) || Nr.mkdirSync(e, { recursive: !0 }), Nr.existsSync(t) && Nr.unlinkSync(t), this.wsServer = new Po({ path: t }), this.logger.info(`MessageMultiplexBroker WebSocket started on Unix socket ${t}`);
16016
+ Rr.existsSync(e) || Rr.mkdirSync(e, { recursive: !0 }), Rr.existsSync(t) && Rr.unlinkSync(t), this.wsServer = new Po({ path: t }), this.logger.info(`MessageMultiplexBroker WebSocket started on Unix socket ${t}`);
15925
16017
  } else {
15926
16018
  const t = this.config.wsPort === 0 || this.config.wsPort === null ? await qC() : this.config.wsPort;
15927
16019
  this.actualPort = t, this.actualHttpPort = t, this.httpServer = kS(async (e, r) => {
@@ -15965,7 +16057,7 @@ let Un = class {
15965
16057
  t.close();
15966
16058
  this.remoteConnections.clear(), this.wsServer && await new Promise((t) => {
15967
16059
  this.wsServer.close(() => {
15968
- this.actualSocketPath && Nr.existsSync(this.actualSocketPath) && Nr.unlinkSync(this.actualSocketPath), t();
16060
+ this.actualSocketPath && Rr.existsSync(this.actualSocketPath) && Rr.unlinkSync(this.actualSocketPath), t();
15969
16061
  });
15970
16062
  }), this.httpServer && await new Promise((t) => {
15971
16063
  this.httpServer.close(() => {
@@ -19301,7 +19393,7 @@ let Bu = class {
19301
19393
  const t = this.agentConfigService.getStoredAgentSessionId();
19302
19394
  if (t)
19303
19395
  try {
19304
- const { createGetAgentStatus: e } = await Promise.resolve().then(() => pT), { createSendAgentStatus: r } = await Promise.resolve().then(() => fI), { AGENT_STATUS: i } = await import("./index-DFH7PylK.mjs"), n = e(t, t), a = (await this.multiplexClient.request(n))?.payload?.result || i.IDLE;
19396
+ const { createGetAgentStatus: e } = await Promise.resolve().then(() => pT), { createSendAgentStatus: r } = await Promise.resolve().then(() => fI), { AGENT_STATUS: i } = await import("./index-qyLMfqDP.mjs"), n = e(t, t), a = (await this.multiplexClient.request(n))?.payload?.result || i.IDLE;
19305
19397
  await this.multiplexClient.publish(
19306
19398
  r(t, {
19307
19399
  agentType: this.agentConfigService.getAgentType() ?? void 0,
@@ -21213,7 +21305,7 @@ let ts = class {
21213
21305
  * Middleware layers wrap around this with setup (BEFORE) and cleanup (AFTER)
21214
21306
  */
21215
21307
  async launchPty(t) {
21216
- const { AGENT_STATUS: e } = await import("./index-DFH7PylK.mjs"), r = t.metadata.agentCommand, i = t.metadata.agentArgs;
21308
+ const { AGENT_STATUS: e } = await import("./index-qyLMfqDP.mjs"), r = t.metadata.agentCommand, i = t.metadata.agentArgs;
21217
21309
  if (!r)
21218
21310
  throw new Error("launchPty requires metadata.agentCommand to be set by middleware");
21219
21311
  const n = await this.getAgentEnvironmentVariablesForContext(t);
@@ -21407,14 +21499,14 @@ class cy {
21407
21499
  * Write JSON file to temporary directory
21408
21500
  */
21409
21501
  async writeTempJsonFile(e, r) {
21410
- const i = Le.join(Er.tmpdir(), e);
21502
+ const i = ze.join(Nr.tmpdir(), e);
21411
21503
  return await To.writeFile(i, JSON.stringify(r, null, 2), "utf8"), this.logger.info(`Created temp file: ${i}`), i;
21412
21504
  }
21413
21505
  /**
21414
21506
  * Write JSON file synchronously to temporary directory
21415
21507
  */
21416
21508
  writeTempJsonFileSync(e, r) {
21417
- const i = Le.join(Er.tmpdir(), e);
21509
+ const i = ze.join(Nr.tmpdir(), e);
21418
21510
  return Te.writeFileSync(i, JSON.stringify(r, null, 2), "utf8"), this.logger.info(`Created temp file: ${i}`), i;
21419
21511
  }
21420
21512
  /**
@@ -21431,13 +21523,13 @@ class cy {
21431
21523
  * Find git repository root starting from directory
21432
21524
  */
21433
21525
  async findGitRepoRoot(e) {
21434
- let r = Le.resolve(e);
21435
- const i = Le.parse(r).root;
21526
+ let r = ze.resolve(e);
21527
+ const i = ze.parse(r).root;
21436
21528
  for (; r !== i; ) {
21437
- const n = Le.join(r, ".git");
21529
+ const n = ze.join(r, ".git");
21438
21530
  if (Te.existsSync(n))
21439
21531
  return r;
21440
- r = Le.dirname(r);
21532
+ r = ze.dirname(r);
21441
21533
  }
21442
21534
  return null;
21443
21535
  }
@@ -21445,7 +21537,7 @@ class cy {
21445
21537
  * Ensure .gitignore contains the specified entry
21446
21538
  */
21447
21539
  async ensureGitignoreEntry(e, r) {
21448
- const i = Le.join(e, ".gitignore");
21540
+ const i = ze.join(e, ".gitignore");
21449
21541
  try {
21450
21542
  let n = "";
21451
21543
  if (Te.existsSync(i) && (n = Te.readFileSync(i, "utf8")), n.split(`
@@ -21512,7 +21604,7 @@ class hT extends cy {
21512
21604
  r ? (n = await this.createTempSettingsFile(e), n && (e.metadata.tempSettingsPath = n, e.registerTempFile(n))) : await this.addPostToolUseHook(e);
21513
21605
  const o = this.writeMcpConfigFile(i, e.agentSessionId);
21514
21606
  o && (e.metadata.mcpConfigPath = o, e.registerTempFile(o));
21515
- const s = Le.join(e.workingDir, ".mcp.json"), a = this.writeProjectMcpConfigFile(
21607
+ const s = ze.join(e.workingDir, ".mcp.json"), a = this.writeProjectMcpConfigFile(
21516
21608
  s,
21517
21609
  i,
21518
21610
  e.agentSessionId
@@ -21590,69 +21682,19 @@ class hT extends cy {
21590
21682
  }
21591
21683
  /**
21592
21684
  * Write MCP server configuration file
21593
- * Handles special processing for one-mcp servers with remote config
21594
21685
  */
21595
21686
  writeMcpConfigFile(e, r) {
21596
21687
  if (e)
21597
21688
  try {
21598
21689
  const i = this.normalizeMcpServers(e);
21599
21690
  if (Object.keys(i).length === 0) return;
21600
- const o = { mcpServers: this.processOneMcpServers(i, r) }, s = `claude-mcps-${r}.json`;
21601
- return this.writeTempJsonFileSync(s, o);
21691
+ const n = { mcpServers: i }, o = `claude-mcps-${r}.json`;
21692
+ return this.writeTempJsonFileSync(o, n);
21602
21693
  } catch (i) {
21603
21694
  this.logger.warn("Failed to write MCP config file", i);
21604
21695
  return;
21605
21696
  }
21606
21697
  }
21607
- /**
21608
- * Process MCP servers, creating YAML configs for one-mcp servers with remote config
21609
- */
21610
- processOneMcpServers(e, r) {
21611
- const i = {};
21612
- for (const [n, o] of Object.entries(e))
21613
- this.isOneMcpWithRemoteConfig(o) ? i[n] = this.createOneMcpConfigWithYaml(o, r, n) : i[n] = o;
21614
- return i;
21615
- }
21616
- /**
21617
- * Check if a server config is one-mcp with AGIFLOW_MCP_CONFIG_URL
21618
- */
21619
- isOneMcpWithRemoteConfig(e) {
21620
- if (!e.command || !e.args) return !1;
21621
- const r = e.args.includes("@agiflowai/one-mcp") || e.args.some((n) => n.includes("one-mcp")), i = e.env?.AGIFLOW_MCP_CONFIG_URL;
21622
- return r && i;
21623
- }
21624
- /**
21625
- * Create one-mcp config with YAML file and updated args
21626
- */
21627
- createOneMcpConfigWithYaml(e, r, i) {
21628
- const n = e.env.AGIFLOW_MCP_CONFIG_URL, o = e.env.AGIFLOW_MCP_API_KEY || "${AGIFLOW_MCP_API_KEY}", s = this.generateOneMcpYamlConfig(n, o), a = `one-mcp-config-${i}-${r}.yaml`, u = Le.join(Er.tmpdir(), a);
21629
- Te.writeFileSync(u, s, "utf8"), this.logger.info(`Created one-mcp YAML config: ${u}`);
21630
- const f = [...e.args || [], "--config", u], _ = {};
21631
- if (e.env)
21632
- for (const [m, d] of Object.entries(e.env))
21633
- m !== "AGIFLOW_MCP_CONFIG_URL" && (_[m] = d);
21634
- return {
21635
- ...e,
21636
- args: f,
21637
- env: Object.keys(_).length > 0 ? _ : void 0
21638
- };
21639
- }
21640
- /**
21641
- * Generate YAML content for one-mcp remote config
21642
- */
21643
- generateOneMcpYamlConfig(e, r) {
21644
- return `# Auto-generated one-mcp config for Agiflow remote MCP servers
21645
- mcpServers: {}
21646
- remoteConfigs:
21647
- - url: "${e}"
21648
- headers:
21649
- x-api-key: "${r}"
21650
- security:
21651
- allowPrivateIPs: true
21652
- enforceHttps: false
21653
- mergeStrategy: remote-priority
21654
- `;
21655
- }
21656
21698
  /**
21657
21699
  * Write merged project MCP config (removes duplicates with agent config)
21658
21700
  */
@@ -21714,7 +21756,7 @@ remoteConfigs:
21714
21756
  * Add PostToolUse hook to local settings file (Legacy Claude Code < 2.0)
21715
21757
  */
21716
21758
  async addPostToolUseHook(e) {
21717
- const r = Le.join(e.workingDir, ".claude", "settings.local.json"), i = Le.dirname(r);
21759
+ const r = ze.join(e.workingDir, ".claude", "settings.local.json"), i = ze.dirname(r);
21718
21760
  try {
21719
21761
  await To.mkdir(i, { recursive: !0 });
21720
21762
  let n = {};
@@ -21769,9 +21811,9 @@ class gT extends cy {
21769
21811
  try {
21770
21812
  const n = this.convertToGeminiFormat(e);
21771
21813
  if (Object.keys(n).length === 0) return null;
21772
- const o = await this.findGitRepoRoot(r), s = o || Er.homedir();
21814
+ const o = await this.findGitRepoRoot(r), s = o || Nr.homedir();
21773
21815
  this.logger.debug(`Using base directory for Gemini extension: ${s}`);
21774
- const a = Le.join(s, ".gemini", "extensions");
21816
+ const a = ze.join(s, ".gemini", "extensions");
21775
21817
  Te.existsSync(a) || (Te.mkdirSync(a, { recursive: !0 }), this.logger.debug(`Created directory: ${a}`));
21776
21818
  const u = {
21777
21819
  name: "agiflow-mcps",
@@ -21779,7 +21821,7 @@ class gT extends cy {
21779
21821
  mcpServers: n,
21780
21822
  contextFileName: "GEMINI.md",
21781
21823
  excludeTools: ["run_shell_command"]
21782
- }, f = Le.join(a, "agiflow-extension.json");
21824
+ }, f = ze.join(a, "agiflow-extension.json");
21783
21825
  return Te.writeFileSync(f, JSON.stringify(u, null, 2), "utf8"), this.logger.info(`Gemini extension config written to: ${f}`), o && await this.ensureGitignoreEntry(o, ".gemini/extensions/agiflow-extension.json"), f;
21784
21826
  } catch (n) {
21785
21827
  return this.logger.warn("Failed to write Gemini extension config file", n), null;
@@ -21841,13 +21883,13 @@ class tr {
21841
21883
  // Getters to compute paths at runtime (not at module load time)
21842
21884
  // This ensures os.homedir() returns the correct value inside Docker containers
21843
21885
  static get credentialsDir() {
21844
- return Le.join(Er.homedir(), ".claude_credentials");
21886
+ return ze.join(Nr.homedir(), ".claude_credentials");
21845
21887
  }
21846
21888
  static get sourceFile() {
21847
- return Le.join(tr.credentialsDir, ".claude.json");
21889
+ return ze.join(tr.credentialsDir, ".claude.json");
21848
21890
  }
21849
21891
  static get targetFile() {
21850
- return Le.join(Er.homedir(), ".claude.json");
21892
+ return ze.join(Nr.homedir(), ".claude.json");
21851
21893
  }
21852
21894
  /**
21853
21895
  * Before: Copy credentials from mounted folder to home directory
@@ -22414,7 +22456,7 @@ class ET extends dy {
22414
22456
  if (!e.length) return;
22415
22457
  const i = (/* @__PURE__ */ new Date()).toISOString();
22416
22458
  try {
22417
- const { createSelectComponent: n, createToolInvocationInput: o } = await import("./index-C_8Nd03u.mjs"), { createRequestApproval: s } = await Promise.resolve().then(() => Bi), a = e.map((_) => ({ label: _.text, value: _.number, selected: !!_.selected })), u = n(a), c = o(!1, u), f = s(r.agentSessionId, {
22459
+ const { createSelectComponent: n, createToolInvocationInput: o } = await import("./index-D-edidE4.mjs"), { createRequestApproval: s } = await Promise.resolve().then(() => Bi), a = e.map((_) => ({ label: _.text, value: _.number, selected: !!_.selected })), u = n(a), c = o(!1, u), f = s(r.agentSessionId, {
22418
22460
  toolName: "selectOption",
22419
22461
  toolArgs: { timestamp: i, options: a },
22420
22462
  input: c
@@ -22817,7 +22859,7 @@ let rs = class extends ts {
22817
22859
  this.logger.info(`Sending autonomous prompt: ${o}`), this.sendInputToPty(o), setTimeout(() => {
22818
22860
  this.sendInputToPty("\r");
22819
22861
  }, 50);
22820
- }, 18e3));
22862
+ }, 15e3));
22821
22863
  }
22822
22864
  }
22823
22865
  /**
@@ -22848,7 +22890,7 @@ let rs = class extends ts {
22848
22890
  */
22849
22891
  writeSessionSettings(t, e, r, i, n) {
22850
22892
  try {
22851
- const o = Le.join(Er.homedir(), ".agiflow"), s = Le.join(o, "sessions.json");
22893
+ const o = ze.join(Nr.homedir(), ".agiflow"), s = ze.join(o, "sessions.json");
22852
22894
  Te.existsSync(o) || Te.mkdirSync(o, { recursive: !0 });
22853
22895
  let a = {};
22854
22896
  if (Te.existsSync(s))
@@ -23141,7 +23183,7 @@ let is = class {
23141
23183
  const d = `agiflow_node_modules_${hs.createHash("md5").update(e.workingDir).digest("hex").substring(0, 12)}`;
23142
23184
  n.push("-v", `${d}:/workspace/node_modules`), this.logger.debug(`Mounting node_modules as named volume: ${d} -> /workspace/node_modules`);
23143
23185
  }
23144
- const f = Le.join(Er.homedir(), ".agiflow");
23186
+ const f = ze.join(Nr.homedir(), ".agiflow");
23145
23187
  if (Qt.existsSync(f) ? (n.push("-v", `${f}:/home/node/.agiflow:ro`), this.logger.debug(`Mounting credentials directory: ${f} -> /home/node/.agiflow`)) : this.logger.warn(`Credentials directory not found at: ${f}`), e.additionalVolumes && e.additionalVolumes.length > 0)
23146
23188
  for (const m of e.additionalVolumes) {
23147
23189
  let d;
@@ -25386,7 +25428,7 @@ let Hu = class {
25386
25428
  const r = ["api-key.json", "credentials.json"];
25387
25429
  let i = 0;
25388
25430
  for (const n of r) {
25389
- const o = Le.join(tt.AGIFLOW_DIR, n);
25431
+ const o = ze.join(tt.AGIFLOW_DIR, n);
25390
25432
  await tt.exists(o) && (await tt.remove(o), i++, t.verbose && console.log(Qe.blue("ℹ"), `Removed: ${n}`));
25391
25433
  }
25392
25434
  i === 0 ? console.log(Qe.blue("ℹ"), "No credential files found. You are already logged out.") : console.log(Qe.green("✓"), `Successfully logged out and removed ${i} credential file(s)`);
@@ -27964,11 +28006,11 @@ let kr = class {
27964
28006
  */
27965
28007
  readAuthFile() {
27966
28008
  try {
27967
- if (!Nr.existsSync(kr.AUTH_FILE_PATH))
28009
+ if (!Rr.existsSync(kr.AUTH_FILE_PATH))
27968
28010
  return this.logger?.warn("[CodexAuth] Auth file does not exist", {
27969
28011
  path: kr.AUTH_FILE_PATH
27970
28012
  }), null;
27971
- const t = Nr.readFileSync(kr.AUTH_FILE_PATH, "utf-8");
28013
+ const t = Rr.readFileSync(kr.AUTH_FILE_PATH, "utf-8");
27972
28014
  return JSON.parse(t);
27973
28015
  } catch (t) {
27974
28016
  return this.logger?.error("[CodexAuth] Failed to read auth file", t), null;
@@ -28048,13 +28090,13 @@ let kr = class {
28048
28090
  this.logger?.error("[CodexAuth] Cannot save tokens - auth file not found");
28049
28091
  return;
28050
28092
  }
28051
- e.tokens = t, e.last_refresh = (/* @__PURE__ */ new Date()).toISOString(), Nr.writeFileSync(kr.AUTH_FILE_PATH, JSON.stringify(e, null, 2), "utf-8");
28093
+ e.tokens = t, e.last_refresh = (/* @__PURE__ */ new Date()).toISOString(), Rr.writeFileSync(kr.AUTH_FILE_PATH, JSON.stringify(e, null, 2), "utf-8");
28052
28094
  } catch (e) {
28053
28095
  this.logger?.error("[CodexAuth] Failed to save tokens", e);
28054
28096
  }
28055
28097
  }
28056
28098
  };
28057
- fp(kr, "AUTH_FILE_PATH", Rr.join($r.homedir(), ".codex", "auth.json"));
28099
+ fp(kr, "AUTH_FILE_PATH", $r.join(Ar.homedir(), ".codex", "auth.json"));
28058
28100
  fp(kr, "TOKEN_REFRESH_URL", "https://auth.openai.com/oauth/token");
28059
28101
  fp(kr, "CLIENT_ID", "app_EMoamEEZ73f0CkXaXp7hrann");
28060
28102
  kr = u2([
@@ -31667,12 +31709,12 @@ function Ls() {
31667
31709
  gt > 0 ? (j.lShiftTo(gt, se), ee.lShiftTo(gt, D)) : (j.copyTo(se), ee.copyTo(D));
31668
31710
  var Zt = se.t, yr = se.data[Zt - 1];
31669
31711
  if (yr != 0) {
31670
- var cr = yr * (1 << this.F1) + (Zt > 1 ? se.data[Zt - 2] >> this.F2 : 0), Zr = this.FV / cr, io = (1 << this.F1) / cr, Tr = 1 << this.F2, Ar = D.t, oo = Ar - Zt, on = $ ?? i();
31712
+ var cr = yr * (1 << this.F1) + (Zt > 1 ? se.data[Zt - 2] >> this.F2 : 0), Zr = this.FV / cr, io = (1 << this.F1) / cr, Ir = 1 << this.F2, Tr = D.t, oo = Tr - Zt, on = $ ?? i();
31671
31713
  for (se.dlShiftTo(oo, on), D.compareTo(on) >= 0 && (D.data[D.t++] = 1, D.subTo(on, D)), r.ONE.dlShiftTo(Zt, on), on.subTo(se, se); se.t < Zt; ) se.data[se.t++] = 0;
31672
31714
  for (; --oo >= 0; ) {
31673
- var qs = D.data[--Ar] == yr ? this.DM : Math.floor(D.data[Ar] * Zr + (D.data[Ar - 1] + Tr) * io);
31674
- if ((D.data[Ar] += se.am(0, qs, D, oo, 0, Zt)) < qs)
31675
- for (se.dlShiftTo(oo, on), D.subTo(on, D); D.data[Ar] < --qs; ) D.subTo(on, D);
31715
+ var qs = D.data[--Tr] == yr ? this.DM : Math.floor(D.data[Tr] * Zr + (D.data[Tr - 1] + Ir) * io);
31716
+ if ((D.data[Tr] += se.am(0, qs, D, oo, 0, Zt)) < qs)
31717
+ for (se.dlShiftTo(oo, on), D.subTo(on, D); D.data[Tr] < --qs; ) D.subTo(on, D);
31676
31718
  }
31677
31719
  $ != null && (D.drShiftTo(Zt, $), be != me && r.ZERO.subTo($, $)), D.t = Zt, D.clamp(), gt > 0 && D.rShiftTo(gt, D), be < 0 && r.ZERO.subTo(D, D);
31678
31720
  }
@@ -31908,7 +31950,7 @@ function Ls() {
31908
31950
  var D = r.ONE.shiftLeft(C);
31909
31951
  return this.bitwiseTo(D, $, D), D;
31910
31952
  }
31911
- function ze(C) {
31953
+ function Le(C) {
31912
31954
  return this.changeBit(C, It);
31913
31955
  }
31914
31956
  function Ge(C) {
@@ -32029,7 +32071,7 @@ function Ls() {
32029
32071
  for (se.sqrTo(be[1], yr); me <= Zt; )
32030
32072
  be[me] = i(), se.mulTo(yr, be[me - 2], be[me]), me += 2;
32031
32073
  }
32032
- var cr = C.t - 1, Zr, io = !0, Tr = i(), Ar;
32074
+ var cr = C.t - 1, Zr, io = !0, Ir = i(), Tr;
32033
32075
  for (D = g(C.data[cr]) - 1; cr >= 0; ) {
32034
32076
  for (D >= gt ? Zr = C.data[cr] >> D - gt & Zt : (Zr = (C.data[cr] & (1 << D + 1) - 1) << gt - D, cr > 0 && (Zr |= C.data[cr - 1] >> this.DB + D - gt)), me = j; (Zr & 1) == 0; )
32035
32077
  Zr >>= 1, --me;
@@ -32037,11 +32079,11 @@ function Ls() {
32037
32079
  be[Zr].copyTo(ee), io = !1;
32038
32080
  else {
32039
32081
  for (; me > 1; )
32040
- se.sqrTo(ee, Tr), se.sqrTo(Tr, ee), me -= 2;
32041
- me > 0 ? se.sqrTo(ee, Tr) : (Ar = ee, ee = Tr, Tr = Ar), se.mulTo(Tr, be[Zr], ee);
32082
+ se.sqrTo(ee, Ir), se.sqrTo(Ir, ee), me -= 2;
32083
+ me > 0 ? se.sqrTo(ee, Ir) : (Tr = ee, ee = Ir, Ir = Tr), se.mulTo(Ir, be[Zr], ee);
32042
32084
  }
32043
32085
  for (; cr >= 0 && (C.data[cr] & 1 << D) == 0; )
32044
- se.sqrTo(ee, Tr), Ar = ee, ee = Tr, Tr = Ar, --D < 0 && (D = this.DB - 1, --cr);
32086
+ se.sqrTo(ee, Ir), Tr = ee, ee = Ir, Ir = Tr, --D < 0 && (D = this.DB - 1, --cr);
32045
32087
  }
32046
32088
  return se.revert(ee);
32047
32089
  }
@@ -32081,18 +32123,18 @@ function Ls() {
32081
32123
  else return me;
32082
32124
  return me.signum() < 0 ? me.add(C) : me;
32083
32125
  }
32084
- var Ir = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509], aS = (1 << 26) / Ir[Ir.length - 1];
32126
+ var Cr = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509], aS = (1 << 26) / Cr[Cr.length - 1];
32085
32127
  function uS(C) {
32086
32128
  var $, D = this.abs();
32087
- if (D.t == 1 && D.data[0] <= Ir[Ir.length - 1]) {
32088
- for ($ = 0; $ < Ir.length; ++$)
32089
- if (D.data[0] == Ir[$]) return !0;
32129
+ if (D.t == 1 && D.data[0] <= Cr[Cr.length - 1]) {
32130
+ for ($ = 0; $ < Cr.length; ++$)
32131
+ if (D.data[0] == Cr[$]) return !0;
32090
32132
  return !1;
32091
32133
  }
32092
32134
  if (D.isEven()) return !1;
32093
- for ($ = 1; $ < Ir.length; ) {
32094
- for (var j = Ir[$], ee = $ + 1; ee < Ir.length && j < aS; ) j *= Ir[ee++];
32095
- for (j = D.modInt(j); $ < ee; ) if (j % Ir[$++] == 0) return !1;
32135
+ for ($ = 1; $ < Cr.length; ) {
32136
+ for (var j = Cr[$], ee = $ + 1; ee < Cr.length && j < aS; ) j *= Cr[ee++];
32137
+ for (j = D.modInt(j); $ < ee; ) if (j % Cr[$++] == 0) return !1;
32096
32138
  }
32097
32139
  return D.millerRabin(C);
32098
32140
  }
@@ -32121,7 +32163,7 @@ function Ls() {
32121
32163
  }
32122
32164
  };
32123
32165
  }
32124
- return r.prototype.chunkSize = we, r.prototype.toRadix = ye, r.prototype.fromRadix = Ne, r.prototype.fromNumber = Ye, r.prototype.bitwiseTo = dt, r.prototype.changeBit = Ve, r.prototype.addTo = Pt, r.prototype.dMultiply = qt, r.prototype.dAddOffset = Ht, r.prototype.multiplyLowerTo = Jy, r.prototype.multiplyUpperTo = Yy, r.prototype.modInt = oS, r.prototype.millerRabin = cS, r.prototype.clone = L, r.prototype.intValue = B, r.prototype.byteValue = Q, r.prototype.shortValue = ve, r.prototype.signum = X, r.prototype.toByteArray = je, r.prototype.equals = bt, r.prototype.min = Ct, r.prototype.max = Et, r.prototype.and = yt, r.prototype.or = Nt, r.prototype.xor = W, r.prototype.andNot = ce, r.prototype.not = Ie, r.prototype.shiftLeft = rt, r.prototype.shiftRight = ct, r.prototype.getLowestSetBit = de, r.prototype.bitCount = Se, r.prototype.testBit = xe, r.prototype.setBit = ze, r.prototype.clearBit = Ge, r.prototype.flipBit = lt, r.prototype.add = Dt, r.prototype.subtract = Bt, r.prototype.multiply = Ft, r.prototype.divide = jt, r.prototype.remainder = Vt, r.prototype.divideAndRemainder = Gt, r.prototype.modPow = nS, r.prototype.modInverse = sS, r.prototype.pow = Zy, r.prototype.gcd = iS, r.prototype.isProbablePrime = uS, Aa;
32166
+ return r.prototype.chunkSize = we, r.prototype.toRadix = ye, r.prototype.fromRadix = Ne, r.prototype.fromNumber = Ye, r.prototype.bitwiseTo = dt, r.prototype.changeBit = Ve, r.prototype.addTo = Pt, r.prototype.dMultiply = qt, r.prototype.dAddOffset = Ht, r.prototype.multiplyLowerTo = Jy, r.prototype.multiplyUpperTo = Yy, r.prototype.modInt = oS, r.prototype.millerRabin = cS, r.prototype.clone = L, r.prototype.intValue = B, r.prototype.byteValue = Q, r.prototype.shortValue = ve, r.prototype.signum = X, r.prototype.toByteArray = je, r.prototype.equals = bt, r.prototype.min = Ct, r.prototype.max = Et, r.prototype.and = yt, r.prototype.or = Nt, r.prototype.xor = W, r.prototype.andNot = ce, r.prototype.not = Ie, r.prototype.shiftLeft = rt, r.prototype.shiftRight = ct, r.prototype.getLowestSetBit = de, r.prototype.bitCount = Se, r.prototype.testBit = xe, r.prototype.setBit = Le, r.prototype.clearBit = Ge, r.prototype.flipBit = lt, r.prototype.add = Dt, r.prototype.subtract = Bt, r.prototype.multiply = Ft, r.prototype.divide = jt, r.prototype.remainder = Vt, r.prototype.divideAndRemainder = Gt, r.prototype.modPow = nS, r.prototype.modInverse = sS, r.prototype.pow = Zy, r.prototype.gcd = iS, r.prototype.isProbablePrime = uS, Aa;
32125
32167
  }
32126
32168
  var $a = { exports: {} }, Ra = { exports: {} }, Ef;
32127
32169
  function to() {
@@ -38501,8 +38543,8 @@ function _2() {
38501
38543
  Me(E, N, N);
38502
38544
  }
38503
38545
  function Me(E, N, R) {
38504
- var v, A, L = 0, B = 0, Q = 0, ve = 0, we = 0, X = 0, ye = 0, Ne = 0, Ye = 0, je = 0, bt = 0, Ct = 0, Et = 0, dt = 0, vt = 0, yt = 0, It = 0, Nt = 0, V = 0, W = 0, Y = 0, ce = 0, Ie = 0, rt = 0, ct = 0, Be = 0, de = 0, ge = 0, Se = 0, xe = 0, Ve = 0, ze = R[0], Ge = R[1], lt = R[2], Pt = R[3], Dt = R[4], Bt = R[5], Ft = R[6], jt = R[7], Vt = R[8], Gt = R[9], qt = R[10], Ht = R[11], Tt = R[12], Mt = R[13], Kt = R[14], Wt = R[15];
38505
- v = N[0], L += v * ze, B += v * Ge, Q += v * lt, ve += v * Pt, we += v * Dt, X += v * Bt, ye += v * Ft, Ne += v * jt, Ye += v * Vt, je += v * Gt, bt += v * qt, Ct += v * Ht, Et += v * Tt, dt += v * Mt, vt += v * Kt, yt += v * Wt, v = N[1], B += v * ze, Q += v * Ge, ve += v * lt, we += v * Pt, X += v * Dt, ye += v * Bt, Ne += v * Ft, Ye += v * jt, je += v * Vt, bt += v * Gt, Ct += v * qt, Et += v * Ht, dt += v * Tt, vt += v * Mt, yt += v * Kt, It += v * Wt, v = N[2], Q += v * ze, ve += v * Ge, we += v * lt, X += v * Pt, ye += v * Dt, Ne += v * Bt, Ye += v * Ft, je += v * jt, bt += v * Vt, Ct += v * Gt, Et += v * qt, dt += v * Ht, vt += v * Tt, yt += v * Mt, It += v * Kt, Nt += v * Wt, v = N[3], ve += v * ze, we += v * Ge, X += v * lt, ye += v * Pt, Ne += v * Dt, Ye += v * Bt, je += v * Ft, bt += v * jt, Ct += v * Vt, Et += v * Gt, dt += v * qt, vt += v * Ht, yt += v * Tt, It += v * Mt, Nt += v * Kt, V += v * Wt, v = N[4], we += v * ze, X += v * Ge, ye += v * lt, Ne += v * Pt, Ye += v * Dt, je += v * Bt, bt += v * Ft, Ct += v * jt, Et += v * Vt, dt += v * Gt, vt += v * qt, yt += v * Ht, It += v * Tt, Nt += v * Mt, V += v * Kt, W += v * Wt, v = N[5], X += v * ze, ye += v * Ge, Ne += v * lt, Ye += v * Pt, je += v * Dt, bt += v * Bt, Ct += v * Ft, Et += v * jt, dt += v * Vt, vt += v * Gt, yt += v * qt, It += v * Ht, Nt += v * Tt, V += v * Mt, W += v * Kt, Y += v * Wt, v = N[6], ye += v * ze, Ne += v * Ge, Ye += v * lt, je += v * Pt, bt += v * Dt, Ct += v * Bt, Et += v * Ft, dt += v * jt, vt += v * Vt, yt += v * Gt, It += v * qt, Nt += v * Ht, V += v * Tt, W += v * Mt, Y += v * Kt, ce += v * Wt, v = N[7], Ne += v * ze, Ye += v * Ge, je += v * lt, bt += v * Pt, Ct += v * Dt, Et += v * Bt, dt += v * Ft, vt += v * jt, yt += v * Vt, It += v * Gt, Nt += v * qt, V += v * Ht, W += v * Tt, Y += v * Mt, ce += v * Kt, Ie += v * Wt, v = N[8], Ye += v * ze, je += v * Ge, bt += v * lt, Ct += v * Pt, Et += v * Dt, dt += v * Bt, vt += v * Ft, yt += v * jt, It += v * Vt, Nt += v * Gt, V += v * qt, W += v * Ht, Y += v * Tt, ce += v * Mt, Ie += v * Kt, rt += v * Wt, v = N[9], je += v * ze, bt += v * Ge, Ct += v * lt, Et += v * Pt, dt += v * Dt, vt += v * Bt, yt += v * Ft, It += v * jt, Nt += v * Vt, V += v * Gt, W += v * qt, Y += v * Ht, ce += v * Tt, Ie += v * Mt, rt += v * Kt, ct += v * Wt, v = N[10], bt += v * ze, Ct += v * Ge, Et += v * lt, dt += v * Pt, vt += v * Dt, yt += v * Bt, It += v * Ft, Nt += v * jt, V += v * Vt, W += v * Gt, Y += v * qt, ce += v * Ht, Ie += v * Tt, rt += v * Mt, ct += v * Kt, Be += v * Wt, v = N[11], Ct += v * ze, Et += v * Ge, dt += v * lt, vt += v * Pt, yt += v * Dt, It += v * Bt, Nt += v * Ft, V += v * jt, W += v * Vt, Y += v * Gt, ce += v * qt, Ie += v * Ht, rt += v * Tt, ct += v * Mt, Be += v * Kt, de += v * Wt, v = N[12], Et += v * ze, dt += v * Ge, vt += v * lt, yt += v * Pt, It += v * Dt, Nt += v * Bt, V += v * Ft, W += v * jt, Y += v * Vt, ce += v * Gt, Ie += v * qt, rt += v * Ht, ct += v * Tt, Be += v * Mt, de += v * Kt, ge += v * Wt, v = N[13], dt += v * ze, vt += v * Ge, yt += v * lt, It += v * Pt, Nt += v * Dt, V += v * Bt, W += v * Ft, Y += v * jt, ce += v * Vt, Ie += v * Gt, rt += v * qt, ct += v * Ht, Be += v * Tt, de += v * Mt, ge += v * Kt, Se += v * Wt, v = N[14], vt += v * ze, yt += v * Ge, It += v * lt, Nt += v * Pt, V += v * Dt, W += v * Bt, Y += v * Ft, ce += v * jt, Ie += v * Vt, rt += v * Gt, ct += v * qt, Be += v * Ht, de += v * Tt, ge += v * Mt, Se += v * Kt, xe += v * Wt, v = N[15], yt += v * ze, It += v * Ge, Nt += v * lt, V += v * Pt, W += v * Dt, Y += v * Bt, ce += v * Ft, Ie += v * jt, rt += v * Vt, ct += v * Gt, Be += v * qt, de += v * Ht, ge += v * Tt, Se += v * Mt, xe += v * Kt, Ve += v * Wt, L += 38 * It, B += 38 * Nt, Q += 38 * V, ve += 38 * W, we += 38 * Y, X += 38 * ce, ye += 38 * Ie, Ne += 38 * rt, Ye += 38 * ct, je += 38 * Be, bt += 38 * de, Ct += 38 * ge, Et += 38 * Se, dt += 38 * xe, vt += 38 * Ve, A = 1, v = L + A + 65535, A = Math.floor(v / 65536), L = v - A * 65536, v = B + A + 65535, A = Math.floor(v / 65536), B = v - A * 65536, v = Q + A + 65535, A = Math.floor(v / 65536), Q = v - A * 65536, v = ve + A + 65535, A = Math.floor(v / 65536), ve = v - A * 65536, v = we + A + 65535, A = Math.floor(v / 65536), we = v - A * 65536, v = X + A + 65535, A = Math.floor(v / 65536), X = v - A * 65536, v = ye + A + 65535, A = Math.floor(v / 65536), ye = v - A * 65536, v = Ne + A + 65535, A = Math.floor(v / 65536), Ne = v - A * 65536, v = Ye + A + 65535, A = Math.floor(v / 65536), Ye = v - A * 65536, v = je + A + 65535, A = Math.floor(v / 65536), je = v - A * 65536, v = bt + A + 65535, A = Math.floor(v / 65536), bt = v - A * 65536, v = Ct + A + 65535, A = Math.floor(v / 65536), Ct = v - A * 65536, v = Et + A + 65535, A = Math.floor(v / 65536), Et = v - A * 65536, v = dt + A + 65535, A = Math.floor(v / 65536), dt = v - A * 65536, v = vt + A + 65535, A = Math.floor(v / 65536), vt = v - A * 65536, v = yt + A + 65535, A = Math.floor(v / 65536), yt = v - A * 65536, L += A - 1 + 37 * (A - 1), A = 1, v = L + A + 65535, A = Math.floor(v / 65536), L = v - A * 65536, v = B + A + 65535, A = Math.floor(v / 65536), B = v - A * 65536, v = Q + A + 65535, A = Math.floor(v / 65536), Q = v - A * 65536, v = ve + A + 65535, A = Math.floor(v / 65536), ve = v - A * 65536, v = we + A + 65535, A = Math.floor(v / 65536), we = v - A * 65536, v = X + A + 65535, A = Math.floor(v / 65536), X = v - A * 65536, v = ye + A + 65535, A = Math.floor(v / 65536), ye = v - A * 65536, v = Ne + A + 65535, A = Math.floor(v / 65536), Ne = v - A * 65536, v = Ye + A + 65535, A = Math.floor(v / 65536), Ye = v - A * 65536, v = je + A + 65535, A = Math.floor(v / 65536), je = v - A * 65536, v = bt + A + 65535, A = Math.floor(v / 65536), bt = v - A * 65536, v = Ct + A + 65535, A = Math.floor(v / 65536), Ct = v - A * 65536, v = Et + A + 65535, A = Math.floor(v / 65536), Et = v - A * 65536, v = dt + A + 65535, A = Math.floor(v / 65536), dt = v - A * 65536, v = vt + A + 65535, A = Math.floor(v / 65536), vt = v - A * 65536, v = yt + A + 65535, A = Math.floor(v / 65536), yt = v - A * 65536, L += A - 1 + 37 * (A - 1), E[0] = L, E[1] = B, E[2] = Q, E[3] = ve, E[4] = we, E[5] = X, E[6] = ye, E[7] = Ne, E[8] = Ye, E[9] = je, E[10] = bt, E[11] = Ct, E[12] = Et, E[13] = dt, E[14] = vt, E[15] = yt;
38546
+ var v, A, L = 0, B = 0, Q = 0, ve = 0, we = 0, X = 0, ye = 0, Ne = 0, Ye = 0, je = 0, bt = 0, Ct = 0, Et = 0, dt = 0, vt = 0, yt = 0, It = 0, Nt = 0, V = 0, W = 0, Y = 0, ce = 0, Ie = 0, rt = 0, ct = 0, Be = 0, de = 0, ge = 0, Se = 0, xe = 0, Ve = 0, Le = R[0], Ge = R[1], lt = R[2], Pt = R[3], Dt = R[4], Bt = R[5], Ft = R[6], jt = R[7], Vt = R[8], Gt = R[9], qt = R[10], Ht = R[11], Tt = R[12], Mt = R[13], Kt = R[14], Wt = R[15];
38547
+ v = N[0], L += v * Le, B += v * Ge, Q += v * lt, ve += v * Pt, we += v * Dt, X += v * Bt, ye += v * Ft, Ne += v * jt, Ye += v * Vt, je += v * Gt, bt += v * qt, Ct += v * Ht, Et += v * Tt, dt += v * Mt, vt += v * Kt, yt += v * Wt, v = N[1], B += v * Le, Q += v * Ge, ve += v * lt, we += v * Pt, X += v * Dt, ye += v * Bt, Ne += v * Ft, Ye += v * jt, je += v * Vt, bt += v * Gt, Ct += v * qt, Et += v * Ht, dt += v * Tt, vt += v * Mt, yt += v * Kt, It += v * Wt, v = N[2], Q += v * Le, ve += v * Ge, we += v * lt, X += v * Pt, ye += v * Dt, Ne += v * Bt, Ye += v * Ft, je += v * jt, bt += v * Vt, Ct += v * Gt, Et += v * qt, dt += v * Ht, vt += v * Tt, yt += v * Mt, It += v * Kt, Nt += v * Wt, v = N[3], ve += v * Le, we += v * Ge, X += v * lt, ye += v * Pt, Ne += v * Dt, Ye += v * Bt, je += v * Ft, bt += v * jt, Ct += v * Vt, Et += v * Gt, dt += v * qt, vt += v * Ht, yt += v * Tt, It += v * Mt, Nt += v * Kt, V += v * Wt, v = N[4], we += v * Le, X += v * Ge, ye += v * lt, Ne += v * Pt, Ye += v * Dt, je += v * Bt, bt += v * Ft, Ct += v * jt, Et += v * Vt, dt += v * Gt, vt += v * qt, yt += v * Ht, It += v * Tt, Nt += v * Mt, V += v * Kt, W += v * Wt, v = N[5], X += v * Le, ye += v * Ge, Ne += v * lt, Ye += v * Pt, je += v * Dt, bt += v * Bt, Ct += v * Ft, Et += v * jt, dt += v * Vt, vt += v * Gt, yt += v * qt, It += v * Ht, Nt += v * Tt, V += v * Mt, W += v * Kt, Y += v * Wt, v = N[6], ye += v * Le, Ne += v * Ge, Ye += v * lt, je += v * Pt, bt += v * Dt, Ct += v * Bt, Et += v * Ft, dt += v * jt, vt += v * Vt, yt += v * Gt, It += v * qt, Nt += v * Ht, V += v * Tt, W += v * Mt, Y += v * Kt, ce += v * Wt, v = N[7], Ne += v * Le, Ye += v * Ge, je += v * lt, bt += v * Pt, Ct += v * Dt, Et += v * Bt, dt += v * Ft, vt += v * jt, yt += v * Vt, It += v * Gt, Nt += v * qt, V += v * Ht, W += v * Tt, Y += v * Mt, ce += v * Kt, Ie += v * Wt, v = N[8], Ye += v * Le, je += v * Ge, bt += v * lt, Ct += v * Pt, Et += v * Dt, dt += v * Bt, vt += v * Ft, yt += v * jt, It += v * Vt, Nt += v * Gt, V += v * qt, W += v * Ht, Y += v * Tt, ce += v * Mt, Ie += v * Kt, rt += v * Wt, v = N[9], je += v * Le, bt += v * Ge, Ct += v * lt, Et += v * Pt, dt += v * Dt, vt += v * Bt, yt += v * Ft, It += v * jt, Nt += v * Vt, V += v * Gt, W += v * qt, Y += v * Ht, ce += v * Tt, Ie += v * Mt, rt += v * Kt, ct += v * Wt, v = N[10], bt += v * Le, Ct += v * Ge, Et += v * lt, dt += v * Pt, vt += v * Dt, yt += v * Bt, It += v * Ft, Nt += v * jt, V += v * Vt, W += v * Gt, Y += v * qt, ce += v * Ht, Ie += v * Tt, rt += v * Mt, ct += v * Kt, Be += v * Wt, v = N[11], Ct += v * Le, Et += v * Ge, dt += v * lt, vt += v * Pt, yt += v * Dt, It += v * Bt, Nt += v * Ft, V += v * jt, W += v * Vt, Y += v * Gt, ce += v * qt, Ie += v * Ht, rt += v * Tt, ct += v * Mt, Be += v * Kt, de += v * Wt, v = N[12], Et += v * Le, dt += v * Ge, vt += v * lt, yt += v * Pt, It += v * Dt, Nt += v * Bt, V += v * Ft, W += v * jt, Y += v * Vt, ce += v * Gt, Ie += v * qt, rt += v * Ht, ct += v * Tt, Be += v * Mt, de += v * Kt, ge += v * Wt, v = N[13], dt += v * Le, vt += v * Ge, yt += v * lt, It += v * Pt, Nt += v * Dt, V += v * Bt, W += v * Ft, Y += v * jt, ce += v * Vt, Ie += v * Gt, rt += v * qt, ct += v * Ht, Be += v * Tt, de += v * Mt, ge += v * Kt, Se += v * Wt, v = N[14], vt += v * Le, yt += v * Ge, It += v * lt, Nt += v * Pt, V += v * Dt, W += v * Bt, Y += v * Ft, ce += v * jt, Ie += v * Vt, rt += v * Gt, ct += v * qt, Be += v * Ht, de += v * Tt, ge += v * Mt, Se += v * Kt, xe += v * Wt, v = N[15], yt += v * Le, It += v * Ge, Nt += v * lt, V += v * Pt, W += v * Dt, Y += v * Bt, ce += v * Ft, Ie += v * jt, rt += v * Vt, ct += v * Gt, Be += v * qt, de += v * Ht, ge += v * Tt, Se += v * Mt, xe += v * Kt, Ve += v * Wt, L += 38 * It, B += 38 * Nt, Q += 38 * V, ve += 38 * W, we += 38 * Y, X += 38 * ce, ye += 38 * Ie, Ne += 38 * rt, Ye += 38 * ct, je += 38 * Be, bt += 38 * de, Ct += 38 * ge, Et += 38 * Se, dt += 38 * xe, vt += 38 * Ve, A = 1, v = L + A + 65535, A = Math.floor(v / 65536), L = v - A * 65536, v = B + A + 65535, A = Math.floor(v / 65536), B = v - A * 65536, v = Q + A + 65535, A = Math.floor(v / 65536), Q = v - A * 65536, v = ve + A + 65535, A = Math.floor(v / 65536), ve = v - A * 65536, v = we + A + 65535, A = Math.floor(v / 65536), we = v - A * 65536, v = X + A + 65535, A = Math.floor(v / 65536), X = v - A * 65536, v = ye + A + 65535, A = Math.floor(v / 65536), ye = v - A * 65536, v = Ne + A + 65535, A = Math.floor(v / 65536), Ne = v - A * 65536, v = Ye + A + 65535, A = Math.floor(v / 65536), Ye = v - A * 65536, v = je + A + 65535, A = Math.floor(v / 65536), je = v - A * 65536, v = bt + A + 65535, A = Math.floor(v / 65536), bt = v - A * 65536, v = Ct + A + 65535, A = Math.floor(v / 65536), Ct = v - A * 65536, v = Et + A + 65535, A = Math.floor(v / 65536), Et = v - A * 65536, v = dt + A + 65535, A = Math.floor(v / 65536), dt = v - A * 65536, v = vt + A + 65535, A = Math.floor(v / 65536), vt = v - A * 65536, v = yt + A + 65535, A = Math.floor(v / 65536), yt = v - A * 65536, L += A - 1 + 37 * (A - 1), A = 1, v = L + A + 65535, A = Math.floor(v / 65536), L = v - A * 65536, v = B + A + 65535, A = Math.floor(v / 65536), B = v - A * 65536, v = Q + A + 65535, A = Math.floor(v / 65536), Q = v - A * 65536, v = ve + A + 65535, A = Math.floor(v / 65536), ve = v - A * 65536, v = we + A + 65535, A = Math.floor(v / 65536), we = v - A * 65536, v = X + A + 65535, A = Math.floor(v / 65536), X = v - A * 65536, v = ye + A + 65535, A = Math.floor(v / 65536), ye = v - A * 65536, v = Ne + A + 65535, A = Math.floor(v / 65536), Ne = v - A * 65536, v = Ye + A + 65535, A = Math.floor(v / 65536), Ye = v - A * 65536, v = je + A + 65535, A = Math.floor(v / 65536), je = v - A * 65536, v = bt + A + 65535, A = Math.floor(v / 65536), bt = v - A * 65536, v = Ct + A + 65535, A = Math.floor(v / 65536), Ct = v - A * 65536, v = Et + A + 65535, A = Math.floor(v / 65536), Et = v - A * 65536, v = dt + A + 65535, A = Math.floor(v / 65536), dt = v - A * 65536, v = vt + A + 65535, A = Math.floor(v / 65536), vt = v - A * 65536, v = yt + A + 65535, A = Math.floor(v / 65536), yt = v - A * 65536, L += A - 1 + 37 * (A - 1), E[0] = L, E[1] = B, E[2] = Q, E[3] = ve, E[4] = we, E[5] = X, E[6] = ye, E[7] = Ne, E[8] = Ye, E[9] = je, E[10] = bt, E[11] = Ct, E[12] = Et, E[13] = dt, E[14] = vt, E[15] = yt;
38506
38548
  }
38507
38549
  return ja;
38508
38550
  }
@@ -41368,10 +41410,10 @@ class Tp {
41368
41410
  logger;
41369
41411
  static create(e, r, i) {
41370
41412
  const n = new Tp();
41371
- n.logger = r, n.baseCAFolder = e, n.certsFolder = Le.join(n.baseCAFolder, "certs"), n.keysFolder = Le.join(n.baseCAFolder, "keys"), Qa.sync(n.baseCAFolder), Qa.sync(n.certsFolder), Qa.sync(n.keysFolder), er.series(
41413
+ n.logger = r, n.baseCAFolder = e, n.certsFolder = ze.join(n.baseCAFolder, "certs"), n.keysFolder = ze.join(n.baseCAFolder, "keys"), Qa.sync(n.baseCAFolder), Qa.sync(n.certsFolder), Qa.sync(n.keysFolder), er.series(
41372
41414
  [
41373
41415
  (o) => {
41374
- Te.existsSync(Le.join(n.certsFolder, "ca.pem")) ? n.loadCA(o) : n.generateCA(o);
41416
+ Te.existsSync(ze.join(n.certsFolder, "ca.pem")) ? n.loadCA(o) : n.generateCA(o);
41375
41417
  }
41376
41418
  ],
41377
41419
  (o) => o ? i(o) : i(null, n)
@@ -41393,9 +41435,9 @@ class Tp {
41393
41435
  const n = ar.createCertificate();
41394
41436
  n.publicKey = i.publicKey, n.serialNumber = this.randomSerialNumber(), n.validity.notBefore = /* @__PURE__ */ new Date(), n.validity.notBefore.setDate(n.validity.notBefore.getDate() - 1), n.validity.notAfter = /* @__PURE__ */ new Date(), n.validity.notAfter.setFullYear(n.validity.notBefore.getFullYear() + 1), n.setSubject(vh), n.setIssuer(vh), n.setExtensions(xR), n.sign(i.privateKey, _h.sha256.create()), this.CAcert = n, this.CAkeys = i;
41395
41437
  const o = [
41396
- Te.writeFile.bind(null, Le.join(this.certsFolder, "ca.pem"), ar.certificateToPem(n)),
41397
- Te.writeFile.bind(null, Le.join(this.keysFolder, "ca.private.key"), ar.privateKeyToPem(i.privateKey)),
41398
- Te.writeFile.bind(null, Le.join(this.keysFolder, "ca.public.key"), ar.publicKeyToPem(i.publicKey))
41438
+ Te.writeFile.bind(null, ze.join(this.certsFolder, "ca.pem"), ar.certificateToPem(n)),
41439
+ Te.writeFile.bind(null, ze.join(this.keysFolder, "ca.private.key"), ar.privateKeyToPem(i.privateKey)),
41440
+ Te.writeFile.bind(null, ze.join(this.keysFolder, "ca.public.key"), ar.publicKeyToPem(i.publicKey))
41399
41441
  ];
41400
41442
  er.parallel(o, e);
41401
41443
  });
@@ -41405,13 +41447,13 @@ class Tp {
41405
41447
  er.auto(
41406
41448
  {
41407
41449
  certPEM(i) {
41408
- Te.readFile(Le.join(r.certsFolder, "ca.pem"), "utf-8", i);
41450
+ Te.readFile(ze.join(r.certsFolder, "ca.pem"), "utf-8", i);
41409
41451
  },
41410
41452
  keyPrivatePEM(i) {
41411
- Te.readFile(Le.join(r.keysFolder, "ca.private.key"), "utf-8", i);
41453
+ Te.readFile(ze.join(r.keysFolder, "ca.private.key"), "utf-8", i);
41412
41454
  },
41413
41455
  keyPublicPEM(i) {
41414
- Te.readFile(Le.join(r.keysFolder, "ca.public.key"), "utf-8", i);
41456
+ Te.readFile(ze.join(r.keysFolder, "ca.public.key"), "utf-8", i);
41415
41457
  }
41416
41458
  },
41417
41459
  (i, n) => i ? e(i) : (r.CAcert = ar.certificateFromPem(n.certPEM), r.CAkeys = {
@@ -41535,7 +41577,7 @@ let eu = class Kn {
41535
41577
  }
41536
41578
  listen(e, r = () => {
41537
41579
  }) {
41538
- return this.options = e || {}, this.httpPort = e.port || e.port === 0 ? e.port : 8080, this.httpHost = e.host || "localhost", this.timeout = e.timeout || 0, this.keepAlive = !!e.keepAlive, this.httpAgent = typeof e.httpAgent < "u" ? e.httpAgent : new Ks.Agent({ keepAlive: this.keepAlive }), this.httpsAgent = typeof e.httpsAgent < "u" ? e.httpsAgent : new Ws.Agent({ keepAlive: this.keepAlive }), this.forceSNI = !!e.forceSNI, this.forceSNI, this.httpsPort = this.forceSNI ? e.httpsPort : void 0, this.sslCaDir = e.sslCaDir || Le.resolve(process.cwd(), ".http-mitm-proxy"), Tp.create(this.sslCaDir, this.logger, (i, n) => {
41580
+ return this.options = e || {}, this.httpPort = e.port || e.port === 0 ? e.port : 8080, this.httpHost = e.host || "localhost", this.timeout = e.timeout || 0, this.keepAlive = !!e.keepAlive, this.httpAgent = typeof e.httpAgent < "u" ? e.httpAgent : new Ks.Agent({ keepAlive: this.keepAlive }), this.httpsAgent = typeof e.httpsAgent < "u" ? e.httpsAgent : new Ws.Agent({ keepAlive: this.keepAlive }), this.forceSNI = !!e.forceSNI, this.forceSNI, this.httpsPort = this.forceSNI ? e.httpsPort : void 0, this.sslCaDir = e.sslCaDir || ze.resolve(process.cwd(), ".http-mitm-proxy"), Tp.create(this.sslCaDir, this.logger, (i, n) => {
41539
41581
  if (i)
41540
41582
  return r(i);
41541
41583
  this.ca = n, this.sslServers = {}, this.sslSemaphores = {}, this.connectRequests = {}, this.httpServer = Ks.createServer(), this.httpServer.timeout = this.timeout, this.httpServer.on("connect", this._onHttpServerConnect.bind(this)), this.httpServer.on("request", this._onHttpServerRequest.bind(this, !1)), this.wsServer = new Po({ server: this.httpServer }), this.wsServer.on("error", this._onError.bind(this, "HTTP_SERVER_ERROR", null)), this.wsServer.on("connection", (s, a) => {
@@ -42828,4 +42870,4 @@ export {
42828
42870
  gw as y,
42829
42871
  $v as z
42830
42872
  };
42831
- //# sourceMappingURL=index-C0rzZTeN.mjs.map
42873
+ //# sourceMappingURL=index-qm8Y_t_Z.mjs.map