@pensar/apex 0.0.91-canary.d27b6cce → 0.0.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/build/index.js +318 -347
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -31971,7 +31971,7 @@ var package_default2;
31971
31971
  var init_package = __esm(() => {
31972
31972
  package_default2 = {
31973
31973
  name: "@pensar/apex",
31974
- version: "0.0.91-canary.d27b6cce",
31974
+ version: "0.0.91",
31975
31975
  description: "AI-powered penetration testing CLI tool with terminal UI",
31976
31976
  module: "src/tui/index.tsx",
31977
31977
  main: "build/index.js",
@@ -105652,10 +105652,9 @@ class PlaywrightMcpSession {
105652
105652
  }
105653
105653
  function createBrowserTools(targetUrl, evidenceDir, mode = "pentest", logger, abortSignal, headless) {
105654
105654
  const session = new PlaywrightMcpSession(headless ?? defaultHeadless);
105655
- if (abortSignal) {
105656
- const onAbort = () => session.disconnect().catch(() => {});
105657
- abortSignal.addEventListener("abort", onAbort, { once: true });
105658
- }
105655
+ abortSignal?.addEventListener("abort", () => {
105656
+ session.disconnect().catch(() => {});
105657
+ });
105659
105658
  if (!existsSync11(evidenceDir)) {
105660
105659
  mkdirSync3(evidenceDir, { recursive: true });
105661
105660
  }
@@ -108518,17 +108517,9 @@ function runScript(runner, scriptPath, timeout, abortSignal) {
108518
108517
  let stderr = "";
108519
108518
  let killed = false;
108520
108519
  let resolved = false;
108521
- let abortCleanup;
108522
- if (abortSignal) {
108523
- const handler = () => killProcess();
108524
- abortSignal.addEventListener("abort", handler, { once: true });
108525
- abortCleanup = () => abortSignal.removeEventListener("abort", handler);
108526
- }
108527
108520
  const safeResolve = (result) => {
108528
108521
  if (!resolved) {
108529
108522
  resolved = true;
108530
- clearTimeout(timeoutTimer);
108531
- abortCleanup?.();
108532
108523
  resolve4(result);
108533
108524
  }
108534
108525
  };
@@ -108562,11 +108553,18 @@ function runScript(runner, scriptPath, timeout, abortSignal) {
108562
108553
  stderr += data.toString();
108563
108554
  });
108564
108555
  child.on("close", (code) => {
108556
+ clearTimeout(timeoutTimer);
108565
108557
  safeResolve({ stdout, stderr, exitCode: code ?? 1 });
108566
108558
  });
108567
108559
  child.on("error", (err) => {
108560
+ clearTimeout(timeoutTimer);
108568
108561
  safeResolve({ stdout, stderr, exitCode: 1 });
108569
108562
  });
108563
+ if (abortSignal) {
108564
+ const handler = () => killProcess();
108565
+ abortSignal.addEventListener("abort", handler, { once: true });
108566
+ child.on("close", () => abortSignal.removeEventListener("abort", handler));
108567
+ }
108570
108568
  });
108571
108569
  }
108572
108570
  var MAX_POC_ATTEMPTS = 3, createPocInputSchema;
@@ -108801,23 +108799,6 @@ search with flags or a more specific directory if results are truncated.`,
108801
108799
  });
108802
108800
  let stdout = "";
108803
108801
  let stderr = "";
108804
- let resolved = false;
108805
- let abortCleanup;
108806
- if (ctx4.abortSignal) {
108807
- const abortHandler = () => child.kill("SIGTERM");
108808
- ctx4.abortSignal.addEventListener("abort", abortHandler, {
108809
- once: true
108810
- });
108811
- abortCleanup = () => ctx4.abortSignal.removeEventListener("abort", abortHandler);
108812
- }
108813
- const safeResolve = (result) => {
108814
- if (resolved)
108815
- return;
108816
- resolved = true;
108817
- clearTimeout(timeout);
108818
- abortCleanup?.();
108819
- resolve4(result);
108820
- };
108821
108802
  const timeout = setTimeout(() => {
108822
108803
  child.kill("SIGTERM");
108823
108804
  }, 30000);
@@ -108828,6 +108809,7 @@ search with flags or a more specific directory if results are truncated.`,
108828
108809
  stderr += data.toString();
108829
108810
  });
108830
108811
  child.on("close", (code) => {
108812
+ clearTimeout(timeout);
108831
108813
  const noMatch = code === 1 && stderr === "";
108832
108814
  const matchCount = stdout ? stdout.trimEnd().split(`
108833
108815
  `).length : 0;
@@ -108835,7 +108817,7 @@ search with flags or a more specific directory if results are truncated.`,
108835
108817
  const output = truncated ? `${stdout.substring(0, 50000)}
108836
108818
 
108837
108819
  (truncated — narrow your search)` : stdout || "(no matches)";
108838
- safeResolve({
108820
+ resolve4({
108839
108821
  success: code === 0 || noMatch,
108840
108822
  error: noMatch || code === 0 ? "" : stderr || `Exit code: ${code}`,
108841
108823
  output,
@@ -108844,7 +108826,8 @@ search with flags or a more specific directory if results are truncated.`,
108844
108826
  });
108845
108827
  });
108846
108828
  child.on("error", (err) => {
108847
- safeResolve({
108829
+ clearTimeout(timeout);
108830
+ resolve4({
108848
108831
  success: false,
108849
108832
  error: err.message,
108850
108833
  output: "",
@@ -108852,6 +108835,15 @@ search with flags or a more specific directory if results are truncated.`,
108852
108835
  command
108853
108836
  });
108854
108837
  });
108838
+ if (ctx4.abortSignal) {
108839
+ const abortHandler = () => child.kill("SIGTERM");
108840
+ ctx4.abortSignal.addEventListener("abort", abortHandler, {
108841
+ once: true
108842
+ });
108843
+ child.on("close", () => {
108844
+ ctx4.abortSignal.removeEventListener("abort", abortHandler);
108845
+ });
108846
+ }
108855
108847
  });
108856
108848
  }
108857
108849
  });
@@ -272358,7 +272350,7 @@ var useTerminalDimensions = () => {
272358
272350
  };
272359
272351
 
272360
272352
  // src/tui/index.tsx
272361
- var import_react87 = __toESM(require_react(), 1);
272353
+ var import_react89 = __toESM(require_react(), 1);
272362
272354
 
272363
272355
  // src/tui/components/footer.tsx
272364
272356
  import os6 from "os";
@@ -273829,7 +273821,7 @@ function CommandProvider({
273829
273821
  }
273830
273822
 
273831
273823
  // src/tui/components/commands/sessions-display.tsx
273832
- var import_react24 = __toESM(require_react(), 1);
273824
+ var import_react22 = __toESM(require_react(), 1);
273833
273825
 
273834
273826
  // src/tui/context/focus.tsx
273835
273827
  var import_react18 = __toESM(require_react(), 1);
@@ -273898,29 +273890,10 @@ function openSessionReport(sessionRootPath) {
273898
273890
  }
273899
273891
  }
273900
273892
 
273901
- // src/tui/context/dimensions.tsx
273902
- var import_react19 = __toESM(require_react(), 1);
273903
- var DimensionsContext = import_react19.createContext(null);
273904
- function TerminalDimensionsProvider({
273905
- children
273906
- }) {
273907
- const dimensions = useTerminalDimensions();
273908
- return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(DimensionsContext.Provider, {
273909
- value: dimensions,
273910
- children
273911
- }, undefined, false, undefined, this);
273912
- }
273913
- function useDimensions() {
273914
- const ctx3 = import_react19.useContext(DimensionsContext);
273915
- if (!ctx3)
273916
- throw new Error("useDimensions() must be used within <TerminalDimensionsProvider>");
273917
- return ctx3;
273918
- }
273919
-
273920
273893
  // src/tui/context/dialog.tsx
273921
- var import_react22 = __toESM(require_react(), 1);
273894
+ var import_react20 = __toESM(require_react(), 1);
273922
273895
  function Dialog({ size = "medium", onClose, children }) {
273923
- const dimensions = useDimensions();
273896
+ const dimensions = useTerminalDimensions();
273924
273897
  const renderer = useRenderer();
273925
273898
  const { colors: themeColors } = useTheme();
273926
273899
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
@@ -273955,14 +273928,14 @@ function Dialog({ size = "medium", onClose, children }) {
273955
273928
  }, undefined, false, undefined, this)
273956
273929
  }, undefined, false, undefined, this);
273957
273930
  }
273958
- var DialogContext = import_react22.createContext(null);
273931
+ var DialogContext = import_react20.createContext(null);
273959
273932
  function DialogProvider({ children }) {
273960
- const [stack, setStack] = import_react22.useState([]);
273961
- const [size, setSize] = import_react22.useState("medium");
273962
- const [externalDialogOpen, setExternalDialogOpen] = import_react22.useState(false);
273933
+ const [stack, setStack] = import_react20.useState([]);
273934
+ const [size, setSize] = import_react20.useState("medium");
273935
+ const [externalDialogOpen, setExternalDialogOpen] = import_react20.useState(false);
273963
273936
  const renderer = useRenderer();
273964
- const focusRef = import_react22.useRef(null);
273965
- const refocus = import_react22.useCallback(() => {
273937
+ const focusRef = import_react20.useRef(null);
273938
+ const refocus = import_react20.useCallback(() => {
273966
273939
  setTimeout(() => {
273967
273940
  const focus = focusRef.current;
273968
273941
  if (!focus)
@@ -273984,7 +273957,7 @@ function DialogProvider({ children }) {
273984
273957
  focus.focus();
273985
273958
  }, 1);
273986
273959
  }, [renderer]);
273987
- const clear = import_react22.useCallback(() => {
273960
+ const clear = import_react20.useCallback(() => {
273988
273961
  for (const item of stack) {
273989
273962
  if (item.onClose)
273990
273963
  item.onClose();
@@ -273993,7 +273966,7 @@ function DialogProvider({ children }) {
273993
273966
  setStack([]);
273994
273967
  refocus();
273995
273968
  }, [stack, refocus]);
273996
- const replace = import_react22.useCallback((element, onClose) => {
273969
+ const replace = import_react20.useCallback((element, onClose) => {
273997
273970
  if (stack.length === 0) {
273998
273971
  focusRef.current = renderer.currentFocusedRenderable;
273999
273972
  }
@@ -274038,7 +274011,7 @@ function DialogProvider({ children }) {
274038
274011
  }, undefined, true, undefined, this);
274039
274012
  }
274040
274013
  function useDialog() {
274041
- const value = import_react22.useContext(DialogContext);
274014
+ const value = import_react20.useContext(DialogContext);
274042
274015
  if (!value) {
274043
274016
  throw new Error("useDialog must be used within a DialogProvider");
274044
274017
  }
@@ -274103,7 +274076,7 @@ function findChildById(scrollBox, id) {
274103
274076
  // src/tui/hooks/use-sessions-list.ts
274104
274077
  init_session();
274105
274078
  init_report();
274106
- var import_react23 = __toESM(require_react(), 1);
274079
+ var import_react21 = __toESM(require_react(), 1);
274107
274080
  import { existsSync as existsSync7, readdirSync } from "fs";
274108
274081
  import { join as join3 } from "path";
274109
274082
  function countFindings(findingsPath) {
@@ -274119,10 +274092,10 @@ function checkHasReport(rootPath) {
274119
274092
  return existsSync7(join3(rootPath, REPORT_FILENAME_MD));
274120
274093
  }
274121
274094
  function useSessionsList() {
274122
- const [allSessions, setAllSessions] = import_react23.useState([]);
274123
- const [loading, setLoading] = import_react23.useState(true);
274124
- const [searchTerm, setSearchTerm] = import_react23.useState("");
274125
- const loadSessions = import_react23.useCallback(async () => {
274095
+ const [allSessions, setAllSessions] = import_react21.useState([]);
274096
+ const [loading, setLoading] = import_react21.useState(true);
274097
+ const [searchTerm, setSearchTerm] = import_react21.useState("");
274098
+ const loadSessions = import_react21.useCallback(async () => {
274126
274099
  setLoading(true);
274127
274100
  try {
274128
274101
  const enriched = [];
@@ -274145,10 +274118,10 @@ function useSessionsList() {
274145
274118
  setLoading(false);
274146
274119
  }
274147
274120
  }, []);
274148
- import_react23.useEffect(() => {
274121
+ import_react21.useEffect(() => {
274149
274122
  loadSessions();
274150
274123
  }, [loadSessions]);
274151
- const deleteSession = import_react23.useCallback(async (id) => {
274124
+ const deleteSession = import_react21.useCallback(async (id) => {
274152
274125
  await sessions.remove({ sessionId: id });
274153
274126
  await loadSessions();
274154
274127
  }, [loadSessions]);
@@ -274207,10 +274180,10 @@ function useSessionsList() {
274207
274180
  function SessionsDisplay({ onClose }) {
274208
274181
  const { colors: colors2 } = useTheme();
274209
274182
  const { refocusPrompt } = useFocus();
274210
- const [selectedIndex, setSelectedIndex] = import_react24.useState(0);
274211
- const [statusMessage, setStatusMessage] = import_react24.useState("");
274183
+ const [selectedIndex, setSelectedIndex] = import_react22.useState(0);
274184
+ const [statusMessage, setStatusMessage] = import_react22.useState("");
274212
274185
  const route = useRoute();
274213
- const scroll = import_react24.useRef(null);
274186
+ const scroll = import_react22.useRef(null);
274214
274187
  const {
274215
274188
  groupedSessions,
274216
274189
  visualOrderSessions,
@@ -274226,7 +274199,7 @@ function SessionsDisplay({ onClose }) {
274226
274199
  setTimeout(() => setStatusMessage(""), 2000);
274227
274200
  }
274228
274201
  }
274229
- import_react24.useEffect(() => {
274202
+ import_react22.useEffect(() => {
274230
274203
  if (visualOrderSessions.length > 0 && selectedIndex >= visualOrderSessions.length) {
274231
274204
  setSelectedIndex(visualOrderSessions.length - 1);
274232
274205
  } else if (visualOrderSessions.length === 0) {
@@ -274498,7 +274471,7 @@ function SessionsDisplay({ onClose }) {
274498
274471
  }
274499
274472
 
274500
274473
  // src/tui/components/commands/config-dialog.tsx
274501
- var import_react27 = __toESM(require_react(), 1);
274474
+ var import_react25 = __toESM(require_react(), 1);
274502
274475
 
274503
274476
  // src/tui/components/alert-dialog.tsx
274504
274477
  function AlertDialog({
@@ -274511,7 +274484,7 @@ function AlertDialog({
274511
274484
  size = "medium"
274512
274485
  }) {
274513
274486
  const { colors: colors2 } = useTheme();
274514
- const dimensions = useDimensions();
274487
+ const dimensions = useTerminalDimensions();
274515
274488
  const renderer = useRenderer();
274516
274489
  useKeyboard((key) => {
274517
274490
  if (!open)
@@ -274585,8 +274558,8 @@ function AlertDialog({
274585
274558
  init_config2();
274586
274559
  function ConfigDialog() {
274587
274560
  const route = useRoute();
274588
- const [open, setOpen] = import_react27.useState(false);
274589
- import_react27.useEffect(() => {
274561
+ const [open, setOpen] = import_react25.useState(false);
274562
+ import_react25.useEffect(() => {
274590
274563
  if (route.data.type === "base" && route.data.path === "config") {
274591
274564
  setOpen(true);
274592
274565
  } else {
@@ -274600,8 +274573,8 @@ function ConfigDialog() {
274600
274573
  path: "home"
274601
274574
  });
274602
274575
  };
274603
- const [appConfig, setAppConfig] = import_react27.useState(null);
274604
- import_react27.useEffect(() => {
274576
+ const [appConfig, setAppConfig] = import_react25.useState(null);
274577
+ import_react25.useEffect(() => {
274605
274578
  async function getConfig() {
274606
274579
  const _appConfig = await config2.get();
274607
274580
  setAppConfig(_appConfig);
@@ -274676,11 +274649,11 @@ var import_react38 = __toESM(require_react(), 1);
274676
274649
 
274677
274650
  // src/tui/context/config.tsx
274678
274651
  init_config2();
274679
- var import_react28 = __toESM(require_react(), 1);
274680
- var ctx3 = import_react28.createContext(null);
274652
+ var import_react26 = __toESM(require_react(), 1);
274653
+ var ctx3 = import_react26.createContext(null);
274681
274654
  function ConfigProvider({ children, config: config3 }) {
274682
- const [appConfig, setAppConfig] = import_react28.useState(config3);
274683
- const value = import_react28.useMemo(() => ({
274655
+ const [appConfig, setAppConfig] = import_react26.useState(config3);
274656
+ const value = import_react26.useMemo(() => ({
274684
274657
  data: appConfig,
274685
274658
  update: async (newConfig) => {
274686
274659
  await config2.update(newConfig);
@@ -274700,7 +274673,7 @@ function ConfigProvider({ children, config: config3 }) {
274700
274673
  }, undefined, false, undefined, this);
274701
274674
  }
274702
274675
  var useConfig = () => {
274703
- const config3 = import_react28.useContext(ctx3);
274676
+ const config3 = import_react26.useContext(ctx3);
274704
274677
  if (!config3) {
274705
274678
  throw new Error("useConfig must be called within a ConfigProvider");
274706
274679
  }
@@ -274708,10 +274681,10 @@ var useConfig = () => {
274708
274681
  };
274709
274682
 
274710
274683
  // src/tui/components/chat/home-view.tsx
274711
- var import_react33 = __toESM(require_react(), 1);
274684
+ var import_react32 = __toESM(require_react(), 1);
274712
274685
 
274713
274686
  // src/tui/components/chat/petri-animation.tsx
274714
- var import_react29 = __toESM(require_react(), 1);
274687
+ var import_react27 = __toESM(require_react(), 1);
274715
274688
 
274716
274689
  // src/tui/components/chat/lib/play-core/num.ts
274717
274690
  function clamp(x2, min, max) {
@@ -274807,8 +274780,8 @@ function stopGlobalTick2() {
274807
274780
  }
274808
274781
  }
274809
274782
  function useGlobalTick2() {
274810
- const [, setTick] = import_react29.useState(0);
274811
- import_react29.useEffect(() => {
274783
+ const [, setTick] = import_react27.useState(0);
274784
+ import_react27.useEffect(() => {
274812
274785
  const listener = () => setTick((t2) => t2 + 1);
274813
274786
  globalListeners2.add(listener);
274814
274787
  startGlobalTick2();
@@ -274833,19 +274806,19 @@ function PetriAnimation({
274833
274806
  height = 0.4,
274834
274807
  width = "100%"
274835
274808
  }) {
274836
- const dimensions = useDimensions();
274809
+ const dimensions = useTerminalDimensions();
274837
274810
  const tick = useGlobalTick2();
274838
274811
  const { colors: colors2 } = useTheme();
274839
- const simulationRef = import_react29.useRef(null);
274840
- const [frame, setFrame] = import_react29.useState([]);
274841
- const gradientColors = import_react29.useMemo(() => generateGradient(colors2.primary, 9), [colors2.primary]);
274842
- const actualHeight = import_react29.useMemo(() => {
274812
+ const simulationRef = import_react27.useRef(null);
274813
+ const [frame, setFrame] = import_react27.useState([]);
274814
+ const gradientColors = import_react27.useMemo(() => generateGradient(colors2.primary, 9), [colors2.primary]);
274815
+ const actualHeight = import_react27.useMemo(() => {
274843
274816
  if (typeof height === "number" && height <= 1) {
274844
274817
  return Math.floor(dimensions.height * height);
274845
274818
  }
274846
274819
  return typeof height === "number" ? height : Math.floor(dimensions.height * 0.4);
274847
274820
  }, [height, dimensions.height]);
274848
- const actualWidth = import_react29.useMemo(() => {
274821
+ const actualWidth = import_react27.useMemo(() => {
274849
274822
  if (typeof width === "number" && width <= 1) {
274850
274823
  return Math.floor(dimensions.width * width);
274851
274824
  }
@@ -274854,7 +274827,7 @@ function PetriAnimation({
274854
274827
  }
274855
274828
  return typeof width === "number" ? width : dimensions.width;
274856
274829
  }, [width, dimensions.width]);
274857
- import_react29.useEffect(() => {
274830
+ import_react27.useEffect(() => {
274858
274831
  if (actualWidth <= 0 || actualHeight <= 0)
274859
274832
  return;
274860
274833
  if (!simulationRef.current) {
@@ -274863,7 +274836,7 @@ function PetriAnimation({
274863
274836
  simulationRef.current.resize(actualWidth, actualHeight);
274864
274837
  }
274865
274838
  }, [actualWidth, actualHeight]);
274866
- import_react29.useEffect(() => {
274839
+ import_react27.useEffect(() => {
274867
274840
  if (simulationRef.current) {
274868
274841
  simulationRef.current.step();
274869
274842
  setFrame(simulationRef.current.render());
@@ -274889,7 +274862,7 @@ function getRowColor(rowIdx, totalRows, gradient) {
274889
274862
  }
274890
274863
 
274891
274864
  // src/tui/components/shared/prompt-input.tsx
274892
- var import_react31 = __toESM(require_react(), 1);
274865
+ var import_react30 = __toESM(require_react(), 1);
274893
274866
 
274894
274867
  // src/tui/components/shared/prompt-input-logic.ts
274895
274868
  function filterSuggestions(inputValue, options, maxSuggestions) {
@@ -275010,13 +274983,13 @@ function shouldResetHistory(historyIndex, isNavigatingHistory) {
275010
274983
  }
275011
274984
 
275012
274985
  // src/tui/components/shared/use-paste-extmarks.ts
275013
- var import_react30 = __toESM(require_react(), 1);
274986
+ var import_react29 = __toESM(require_react(), 1);
275014
274987
  var LARGE_PASTE_MIN_LINES = 5;
275015
274988
  var LARGE_PASTE_MIN_CHARS = 500;
275016
274989
  function usePasteExtmarks(textareaRef) {
275017
- const countRef = import_react30.useRef(0);
275018
- const typeIdRef = import_react30.useRef(-1);
275019
- const dataRef = import_react30.useRef(new Map);
274990
+ const countRef = import_react29.useRef(0);
274991
+ const typeIdRef = import_react29.useRef(-1);
274992
+ const dataRef = import_react29.useRef(new Map);
275020
274993
  const clearPaste = () => {
275021
274994
  textareaRef.current?.extmarks.clear();
275022
274995
  countRef.current = 0;
@@ -275086,7 +275059,7 @@ var chatKeyBindings = [
275086
275059
  { name: "return", shift: true, action: "newline" },
275087
275060
  { name: "linefeed", shift: true, action: "newline" }
275088
275061
  ];
275089
- var PromptInput = import_react31.forwardRef(function PromptInput2({
275062
+ var PromptInput = import_react30.forwardRef(function PromptInput2({
275090
275063
  width,
275091
275064
  minHeight = 1,
275092
275065
  maxHeight = 6,
@@ -275111,31 +275084,31 @@ var PromptInput = import_react31.forwardRef(function PromptInput2({
275111
275084
  const { colors: colors2 } = useTheme();
275112
275085
  const { inputValue, setInputValue } = useInput();
275113
275086
  const { registerPromptRef } = useFocus();
275114
- const textareaRef = import_react31.useRef(null);
275115
- const [selectedSuggestionIndex, setSelectedSuggestionIndex] = import_react31.useState(-1);
275116
- const [historyIndex, setHistoryIndex] = import_react31.useState(-1);
275117
- const savedInputRef = import_react31.useRef("");
275118
- const historyRef = import_react31.useRef(commandHistory);
275087
+ const textareaRef = import_react30.useRef(null);
275088
+ const [selectedSuggestionIndex, setSelectedSuggestionIndex] = import_react30.useState(-1);
275089
+ const [historyIndex, setHistoryIndex] = import_react30.useState(-1);
275090
+ const savedInputRef = import_react30.useRef("");
275091
+ const historyRef = import_react30.useRef(commandHistory);
275119
275092
  historyRef.current = commandHistory;
275120
- const isNavigatingHistoryRef = import_react31.useRef(false);
275121
- const selectedIndexRef = import_react31.useRef(selectedSuggestionIndex);
275122
- const suggestionsRef = import_react31.useRef([]);
275123
- const onCommandExecuteRef = import_react31.useRef(onCommandExecute);
275093
+ const isNavigatingHistoryRef = import_react30.useRef(false);
275094
+ const selectedIndexRef = import_react30.useRef(selectedSuggestionIndex);
275095
+ const suggestionsRef = import_react30.useRef([]);
275096
+ const onCommandExecuteRef = import_react30.useRef(onCommandExecute);
275124
275097
  onCommandExecuteRef.current = onCommandExecute;
275125
- const onSubmitRef = import_react31.useRef(onSubmit);
275098
+ const onSubmitRef = import_react30.useRef(onSubmit);
275126
275099
  onSubmitRef.current = onSubmit;
275127
275100
  const { handlePaste, resolveText, clearPaste } = usePasteExtmarks(textareaRef);
275128
- const suggestions = import_react31.useMemo(() => enableAutocomplete ? filterSuggestions(inputValue, autocompleteOptions, maxSuggestions) : [], [enableAutocomplete, autocompleteOptions, inputValue, maxSuggestions]);
275129
- import_react31.useEffect(() => {
275101
+ const suggestions = import_react30.useMemo(() => enableAutocomplete ? filterSuggestions(inputValue, autocompleteOptions, maxSuggestions) : [], [enableAutocomplete, autocompleteOptions, inputValue, maxSuggestions]);
275102
+ import_react30.useEffect(() => {
275130
275103
  suggestionsRef.current = suggestions;
275131
275104
  }, [suggestions]);
275132
- import_react31.useEffect(() => {
275105
+ import_react30.useEffect(() => {
275133
275106
  selectedIndexRef.current = selectedSuggestionIndex;
275134
275107
  }, [selectedSuggestionIndex]);
275135
- import_react31.useEffect(() => {
275108
+ import_react30.useEffect(() => {
275136
275109
  setSelectedSuggestionIndex(suggestions.length > 0 ? 0 : -1);
275137
275110
  }, [suggestions.length]);
275138
- const imperativeRef = import_react31.useRef({
275111
+ const imperativeRef = import_react30.useRef({
275139
275112
  focus: () => textareaRef.current?.focus(),
275140
275113
  blur: () => textareaRef.current?.blur(),
275141
275114
  reset: () => {
@@ -275152,11 +275125,11 @@ var PromptInput = import_react31.forwardRef(function PromptInput2({
275152
275125
  getValue: () => inputValue,
275153
275126
  getTextareaRef: () => textareaRef.current
275154
275127
  });
275155
- import_react31.useEffect(() => {
275128
+ import_react30.useEffect(() => {
275156
275129
  imperativeRef.current.getValue = () => inputValue;
275157
275130
  }, [inputValue]);
275158
- import_react31.useImperativeHandle(ref, () => imperativeRef.current, []);
275159
- import_react31.useEffect(() => {
275131
+ import_react30.useImperativeHandle(ref, () => imperativeRef.current, []);
275132
+ import_react30.useEffect(() => {
275160
275133
  registerPromptRef(imperativeRef.current);
275161
275134
  return () => registerPromptRef(null);
275162
275135
  }, [registerPromptRef]);
@@ -275372,41 +275345,41 @@ function getEntries() {
275372
275345
  // src/tui/components/chat/home-view.tsx
275373
275346
  function HomeView({ onNavigate, onStartSession }) {
275374
275347
  const { colors: colors2 } = useTheme();
275375
- const dimensions = useDimensions();
275348
+ const dimensions = useTerminalDimensions();
275376
275349
  const config3 = useConfig();
275377
275350
  const route = useRoute();
275378
275351
  const { executeCommand, autocompleteOptions, resolveSkillContent, skills } = useCommand();
275379
275352
  const { setInputValue } = useInput();
275380
275353
  const { promptRef } = useFocus();
275381
275354
  const { externalDialogOpen, stack } = useDialog();
275382
- const [hintMessage, setHintMessage] = import_react33.useState(null);
275383
- const [commandHistory, setCommandHistory] = import_react33.useState(getEntries);
275384
- import_react33.useEffect(() => {
275355
+ const [hintMessage, setHintMessage] = import_react32.useState(null);
275356
+ const [commandHistory, setCommandHistory] = import_react32.useState(getEntries);
275357
+ import_react32.useEffect(() => {
275385
275358
  load().then(setCommandHistory);
275386
275359
  }, []);
275387
- const launchOperator = import_react33.useCallback((message, options) => {
275360
+ const launchOperator = import_react32.useCallback((message, options) => {
275388
275361
  route.navigate({
275389
275362
  type: "operator",
275390
275363
  initialMessage: message,
275391
275364
  initialConfig: { requireApproval: options?.requireApproval ?? true }
275392
275365
  });
275393
275366
  }, [route]);
275394
- const pushHistory = import_react33.useCallback((entry) => {
275367
+ const pushHistory = import_react32.useCallback((entry) => {
275395
275368
  push(entry).then(() => setCommandHistory([...getEntries()]));
275396
275369
  }, []);
275397
- const handleSubmit = import_react33.useCallback((value) => {
275370
+ const handleSubmit = import_react32.useCallback((value) => {
275398
275371
  if (!value.trim())
275399
275372
  return;
275400
275373
  pushHistory(value.trim());
275401
275374
  launchOperator(value.trim());
275402
275375
  }, [launchOperator, pushHistory]);
275403
- import_react33.useEffect(() => {
275376
+ import_react32.useEffect(() => {
275404
275377
  if (!hintMessage)
275405
275378
  return;
275406
275379
  const timer = setTimeout(() => setHintMessage(null), 3000);
275407
275380
  return () => clearTimeout(timer);
275408
275381
  }, [hintMessage]);
275409
- const handleCommandExecute = import_react33.useCallback(async (command) => {
275382
+ const handleCommandExecute = import_react32.useCallback(async (command) => {
275410
275383
  const trimmed = command.trim();
275411
275384
  pushHistory(trimmed);
275412
275385
  const parts = trimmed.replace(/^\/+/, "").split(/\s+/);
@@ -278270,7 +278243,7 @@ function ToastItem({
278270
278243
  }
278271
278244
  function ToastContainer() {
278272
278245
  const { toasts, dismiss } = useToast();
278273
- const dims = useDimensions();
278246
+ const dims = useTerminalDimensions();
278274
278247
  if (toasts.length === 0)
278275
278248
  return null;
278276
278249
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
@@ -278291,11 +278264,11 @@ function ToastContainer() {
278291
278264
  }
278292
278265
 
278293
278266
  // src/tui/components/error-boundary.tsx
278294
- var import_react52 = __toESM(require_react(), 1);
278267
+ var import_react53 = __toESM(require_react(), 1);
278295
278268
  var MAX_ERRORS = 3;
278296
278269
  var ERROR_WINDOW_MS = 5000;
278297
278270
 
278298
- class ErrorBoundaryInner extends import_react52.default.Component {
278271
+ class ErrorBoundaryInner extends import_react53.default.Component {
278299
278272
  state = {
278300
278273
  hasError: false,
278301
278274
  errorTimestamps: [],
@@ -278326,10 +278299,10 @@ class ErrorBoundaryInner extends import_react52.default.Component {
278326
278299
  }
278327
278300
  function ErrorBoundary2({ children }) {
278328
278301
  const { toast } = useToast();
278329
- const handleError = import_react52.useCallback((message) => {
278302
+ const handleError = import_react53.useCallback((message) => {
278330
278303
  toast(message, "error");
278331
278304
  }, [toast]);
278332
- return import_react52.default.createElement(ErrorBoundaryInner, { onError: handleError }, children);
278305
+ return import_react53.default.createElement(ErrorBoundaryInner, { onError: handleError }, children);
278333
278306
  }
278334
278307
 
278335
278308
  // src/tui/index.tsx
@@ -278440,16 +278413,16 @@ function ShortcutsDialog({
278440
278413
  }
278441
278414
 
278442
278415
  // src/tui/components/commands/help-dialog.tsx
278443
- var import_react54 = __toESM(require_react(), 1);
278416
+ var import_react55 = __toESM(require_react(), 1);
278444
278417
  function HelpDialog() {
278445
278418
  const { colors: colors2 } = useTheme();
278446
278419
  const { commands: commands2 } = useCommand();
278447
278420
  const route = useRoute();
278448
- const dimensions = useDimensions();
278449
- const [selectedIndex, setSelectedIndex] = import_react54.useState(0);
278450
- const [showDetail, setShowDetail] = import_react54.useState(false);
278451
- const scrollboxRef = import_react54.useRef(null);
278452
- const commandsByCategory = import_react54.useMemo(() => {
278421
+ const dimensions = useTerminalDimensions();
278422
+ const [selectedIndex, setSelectedIndex] = import_react55.useState(0);
278423
+ const [showDetail, setShowDetail] = import_react55.useState(false);
278424
+ const scrollboxRef = import_react55.useRef(null);
278425
+ const commandsByCategory = import_react55.useMemo(() => {
278453
278426
  const grouped = {};
278454
278427
  for (const cmd of commands2) {
278455
278428
  const category = cmd.category || "Other";
@@ -278460,15 +278433,15 @@ function HelpDialog() {
278460
278433
  }
278461
278434
  return grouped;
278462
278435
  }, [commands2]);
278463
- const flatCommands = import_react54.useMemo(() => {
278436
+ const flatCommands = import_react55.useMemo(() => {
278464
278437
  return commands2;
278465
278438
  }, [commands2]);
278466
- import_react54.useEffect(() => {
278439
+ import_react55.useEffect(() => {
278467
278440
  if (selectedIndex >= flatCommands.length) {
278468
278441
  setSelectedIndex(Math.max(0, flatCommands.length - 1));
278469
278442
  }
278470
278443
  }, [flatCommands.length, selectedIndex]);
278471
- import_react54.useEffect(() => {
278444
+ import_react55.useEffect(() => {
278472
278445
  scrollToIndex(scrollboxRef.current, selectedIndex, flatCommands, (cmd) => cmd.name);
278473
278446
  }, [selectedIndex, flatCommands]);
278474
278447
  const handleClose = () => {
@@ -278903,24 +278876,24 @@ function ModelsDisplay() {
278903
278876
  }
278904
278877
 
278905
278878
  // src/tui/components/commands/auth-flow.tsx
278906
- var import_react57 = __toESM(require_react(), 1);
278879
+ var import_react58 = __toESM(require_react(), 1);
278907
278880
  init_config2();
278908
278881
  function AuthFlow({ onClose }) {
278909
278882
  const { colors: colors2 } = useTheme();
278910
278883
  const appConfig = useConfig();
278911
278884
  const isConnected = !!(appConfig.data.accessToken || appConfig.data.pensarAPIKey);
278912
- const [step, setStep] = import_react57.useState(isConnected ? "success" : "start");
278913
- const [error40, setError] = import_react57.useState(null);
278914
- const [authMode, setAuthMode] = import_react57.useState(null);
278915
- const [deviceInfo, setDeviceInfo] = import_react57.useState(null);
278916
- const [legacyDeviceInfo, setLegacyDeviceInfo] = import_react57.useState(null);
278917
- const [workspaces, setWorkspaces] = import_react57.useState([]);
278918
- const [selectedWorkspace, setSelectedWorkspace] = import_react57.useState(null);
278919
- const [selectedIndex, setSelectedIndex] = import_react57.useState(0);
278920
- const [billingUrl, setBillingUrl] = import_react57.useState(null);
278921
- const [balance, setBalance] = import_react57.useState(null);
278922
- const pollingRef = import_react57.useRef(null);
278923
- const cancelledRef = import_react57.useRef(false);
278885
+ const [step, setStep] = import_react58.useState(isConnected ? "success" : "start");
278886
+ const [error40, setError] = import_react58.useState(null);
278887
+ const [authMode, setAuthMode] = import_react58.useState(null);
278888
+ const [deviceInfo, setDeviceInfo] = import_react58.useState(null);
278889
+ const [legacyDeviceInfo, setLegacyDeviceInfo] = import_react58.useState(null);
278890
+ const [workspaces, setWorkspaces] = import_react58.useState([]);
278891
+ const [selectedWorkspace, setSelectedWorkspace] = import_react58.useState(null);
278892
+ const [selectedIndex, setSelectedIndex] = import_react58.useState(0);
278893
+ const [billingUrl, setBillingUrl] = import_react58.useState(null);
278894
+ const [balance, setBalance] = import_react58.useState(null);
278895
+ const pollingRef = import_react58.useRef(null);
278896
+ const cancelledRef = import_react58.useRef(false);
278924
278897
  const connectedWorkspace = appConfig.data.workspaceSlug ? { name: appConfig.data.workspaceSlug, slug: appConfig.data.workspaceSlug } : null;
278925
278898
  const goHome = () => {
278926
278899
  onClose();
@@ -278932,7 +278905,7 @@ function AuthFlow({ onClose }) {
278932
278905
  pollingRef.current = null;
278933
278906
  }
278934
278907
  };
278935
- import_react57.useEffect(() => {
278908
+ import_react58.useEffect(() => {
278936
278909
  return cleanup;
278937
278910
  }, []);
278938
278911
  const openUrl = (url2) => {
@@ -279565,14 +279538,14 @@ function AuthFlow({ onClose }) {
279565
279538
  }
279566
279539
 
279567
279540
  // src/tui/components/commands/credits-flow.tsx
279568
- var import_react59 = __toESM(require_react(), 1);
279541
+ var import_react60 = __toESM(require_react(), 1);
279569
279542
  init_tokenRefresh();
279570
279543
  function CreditsFlow({ onOpenAuthDialog }) {
279571
279544
  const route = useRoute();
279572
279545
  const appConfig = useConfig();
279573
- const [step, setStep] = import_react59.useState("loading");
279574
- const [credits, setCredits] = import_react59.useState(null);
279575
- const [error40, setError] = import_react59.useState(null);
279546
+ const [step, setStep] = import_react60.useState("loading");
279547
+ const [credits, setCredits] = import_react60.useState(null);
279548
+ const [error40, setError] = import_react60.useState(null);
279576
279549
  const creditsUrl = `${getPensarConsoleUrl()}/credits`;
279577
279550
  const goHome = () => {
279578
279551
  route.navigate({ type: "base", path: "home" });
@@ -279630,7 +279603,7 @@ function CreditsFlow({ onOpenAuthDialog }) {
279630
279603
  setStep("display");
279631
279604
  }
279632
279605
  };
279633
- import_react59.useEffect(() => {
279606
+ import_react60.useEffect(() => {
279634
279607
  fetchBalance();
279635
279608
  }, []);
279636
279609
  useKeyboard((key) => {
@@ -279869,10 +279842,10 @@ function CreditsFlow({ onOpenAuthDialog }) {
279869
279842
  }
279870
279843
 
279871
279844
  // src/tui/context/keybinding.tsx
279872
- var import_react65 = __toESM(require_react(), 1);
279845
+ var import_react66 = __toESM(require_react(), 1);
279873
279846
 
279874
279847
  // src/tui/keybindings/keybind.tsx
279875
- var import_react61 = __toESM(require_react(), 1);
279848
+ var import_react62 = __toESM(require_react(), 1);
279876
279849
 
279877
279850
  // src/tui/keybindings/actions.ts
279878
279851
  var movementActions = [
@@ -280124,7 +280097,7 @@ var allActions = [
280124
280097
  var actionsByKey = new Map(allActions.map((action) => [action.key, action]));
280125
280098
  var actionsById = new Map(allActions.map((action) => [action.id, action]));
280126
280099
  // src/tui/keybindings/keybind.tsx
280127
- var LeaderKeyContext = import_react61.createContext(null);
280100
+ var LeaderKeyContext = import_react62.createContext(null);
280128
280101
  // src/tui/keybindings/registry.ts
280129
280102
  function createKeybindings(deps) {
280130
280103
  const {
@@ -280305,7 +280278,7 @@ function matchesKeybind(pressed, combo) {
280305
280278
  }
280306
280279
 
280307
280280
  // src/tui/context/keybinding.tsx
280308
- var KeybindingContext = import_react65.createContext(undefined);
280281
+ var KeybindingContext = import_react66.createContext(undefined);
280309
280282
  function KeybindingProvider({
280310
280283
  children,
280311
280284
  deps
@@ -280345,7 +280318,7 @@ function KeybindingProvider({
280345
280318
  }
280346
280319
 
280347
280320
  // src/tui/components/pentest/pentest.tsx
280348
- var import_react73 = __toESM(require_react(), 1);
280321
+ var import_react75 = __toESM(require_react(), 1);
280349
280322
  init_report();
280350
280323
  import { existsSync as existsSync26, readdirSync as readdirSync6, readFileSync as readFileSync12 } from "fs";
280351
280324
  import { join as join27 } from "path";
@@ -280486,7 +280459,7 @@ Found ${findings.length} vulnerabilities`);
280486
280459
  init_utils();
280487
280460
 
280488
280461
  // src/tui/components/agent-display.tsx
280489
- var import_react72 = __toESM(require_react(), 1);
280462
+ var import_react73 = __toESM(require_react(), 1);
280490
280463
 
280491
280464
  // node_modules/marked/lib/marked.esm.js
280492
280465
  function L2() {
@@ -282818,14 +282791,14 @@ ${preview}${suffix}` : preview + suffix || "POC passed",
282818
282791
  return null;
282819
282792
  }
282820
282793
  // src/tui/components/shared/ascii-spinner.tsx
282821
- var import_react66 = __toESM(require_react(), 1);
282794
+ var import_react67 = __toESM(require_react(), 1);
282822
282795
  var SPINNER_FRAMES = ["/", "-", "\\", "|"];
282823
282796
  var SPINNER_INTERVAL = 100;
282824
282797
  function AsciiSpinner({ label, fg: fg2 }) {
282825
282798
  const { colors: colors2 } = useTheme();
282826
282799
  const spinnerColor = fg2 ?? colors2.info;
282827
- const [frame, setFrame] = import_react66.useState(0);
282828
- import_react66.useEffect(() => {
282800
+ const [frame, setFrame] = import_react67.useState(0);
282801
+ import_react67.useEffect(() => {
282829
282802
  const interval = setInterval(() => {
282830
282803
  setFrame((f3) => (f3 + 1) % SPINNER_FRAMES.length);
282831
282804
  }, SPINNER_INTERVAL);
@@ -282837,7 +282810,7 @@ function AsciiSpinner({ label, fg: fg2 }) {
282837
282810
  }, undefined, false, undefined, this);
282838
282811
  }
282839
282812
  // src/tui/components/shared/tool-renderer.tsx
282840
- var import_react67 = __toESM(require_react(), 1);
282813
+ var import_react68 = __toESM(require_react(), 1);
282841
282814
  var TOOLS_WITH_LOG_WINDOW = new Set([
282842
282815
  "execute_command",
282843
282816
  "run_attack_surface",
@@ -282850,13 +282823,13 @@ var TOOLS_WITH_LOG_WINDOW = new Set([
282850
282823
  "document_vulnerability"
282851
282824
  ]);
282852
282825
  var DEFAULT_SUBAGENT_LOG_LINES = 5;
282853
- var ToolRenderer = import_react67.memo(function ToolRenderer2({
282826
+ var ToolRenderer = import_react68.memo(function ToolRenderer2({
282854
282827
  message,
282855
282828
  verbose = false,
282856
282829
  expandedLogs = false
282857
282830
  }) {
282858
282831
  const { colors: colors2 } = useTheme();
282859
- const [showOutput, setShowOutput] = import_react67.useState(false);
282832
+ const [showOutput, setShowOutput] = import_react68.useState(false);
282860
282833
  if (!isToolMessage(message)) {
282861
282834
  return null;
282862
282835
  }
@@ -282996,7 +282969,7 @@ var ToolRenderer = import_react67.memo(function ToolRenderer2({
282996
282969
  ]
282997
282970
  }, undefined, true, undefined, this);
282998
282971
  });
282999
- var SubagentLogWindow = import_react67.memo(function SubagentLogWindow2({
282972
+ var SubagentLogWindow = import_react68.memo(function SubagentLogWindow2({
283000
282973
  subagentId,
283001
282974
  entry,
283002
282975
  expandedLogs
@@ -283053,8 +283026,8 @@ var SubagentLogWindow = import_react67.memo(function SubagentLogWindow2({
283053
283026
  }, undefined, true, undefined, this);
283054
283027
  });
283055
283028
  // src/tui/components/shared/message-renderer.tsx
283056
- var import_react68 = __toESM(require_react(), 1);
283057
- var MessageRenderer = import_react68.memo(function MessageRenderer2({
283029
+ var import_react69 = __toESM(require_react(), 1);
283030
+ var MessageRenderer = import_react69.memo(function MessageRenderer2({
283058
283031
  message,
283059
283032
  isStreaming = false,
283060
283033
  verbose = false,
@@ -283064,7 +283037,7 @@ var MessageRenderer = import_react68.memo(function MessageRenderer2({
283064
283037
  }) {
283065
283038
  const { colors: colors2 } = useTheme();
283066
283039
  const content = typeof message.content === "string" ? message.content : JSON.stringify(message.content);
283067
- const displayContent = import_react68.useMemo(() => message.role === "assistant" ? markdownToStyledText(content, colors2) : content, [content, message.role, colors2]);
283040
+ const displayContent = import_react69.useMemo(() => message.role === "assistant" ? markdownToStyledText(content, colors2) : content, [content, message.role, colors2]);
283068
283041
  if (isToolMessage(message)) {
283069
283042
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToolRenderer, {
283070
283043
  message,
@@ -283176,9 +283149,9 @@ var MessageRenderer = import_react68.memo(function MessageRenderer2({
283176
283149
  }, undefined, false, undefined, this);
283177
283150
  });
283178
283151
  // src/tui/components/shared/approval-prompt.tsx
283179
- var import_react69 = __toESM(require_react(), 1);
283152
+ var import_react70 = __toESM(require_react(), 1);
283180
283153
  // src/tui/components/shared/message-reducer.ts
283181
- var import_react71 = __toESM(require_react(), 1);
283154
+ var import_react72 = __toESM(require_react(), 1);
283182
283155
  // src/tui/components/agent-display.tsx
283183
283156
  function getStableKey(item, contextId = "root") {
283184
283157
  if ("messages" in item) {
@@ -283254,11 +283227,11 @@ function AgentDisplay({
283254
283227
  ]
283255
283228
  }, undefined, true, undefined, this);
283256
283229
  }
283257
- var SubAgentDisplay = import_react72.memo(function SubAgentDisplay2({
283230
+ var SubAgentDisplay = import_react73.memo(function SubAgentDisplay2({
283258
283231
  subagent
283259
283232
  }) {
283260
283233
  const { colors: colors2 } = useTheme();
283261
- const [open, setOpen] = import_react72.useState(false);
283234
+ const [open, setOpen] = import_react73.useState(false);
283262
283235
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
283263
283236
  height: open ? 40 : "auto",
283264
283237
  onMouseDown: () => setOpen(!open),
@@ -283313,11 +283286,11 @@ var SubAgentDisplay = import_react72.memo(function SubAgentDisplay2({
283313
283286
  ]
283314
283287
  }, undefined, true, undefined, this);
283315
283288
  });
283316
- var AgentMessage = import_react72.memo(function AgentMessage2({
283289
+ var AgentMessage = import_react73.memo(function AgentMessage2({
283317
283290
  message
283318
283291
  }) {
283319
283292
  const { colors: colors2 } = useTheme();
283320
- const dimensions = useDimensions();
283293
+ const dimensions = useTerminalDimensions();
283321
283294
  let content = "";
283322
283295
  if (typeof message.content === "string") {
283323
283296
  content = message.content;
@@ -283422,8 +283395,8 @@ var AgentMessage = import_react72.memo(function AgentMessage2({
283422
283395
  });
283423
283396
  function ToolDetails({ message }) {
283424
283397
  const { colors: colors2 } = useTheme();
283425
- const [showArgs, setShowArgs] = import_react72.useState(false);
283426
- const [showResult, setShowResult] = import_react72.useState(false);
283398
+ const [showArgs, setShowArgs] = import_react73.useState(false);
283399
+ const [showResult, setShowResult] = import_react73.useState(false);
283427
283400
  if (message.role !== "tool") {
283428
283401
  return null;
283429
283402
  }
@@ -283529,27 +283502,27 @@ function Pentest({
283529
283502
  const config3 = useConfig();
283530
283503
  const { model, setThinking, setIsExecuting, isExecuting } = useAgent();
283531
283504
  const { stack, externalDialogOpen } = useDialog();
283532
- const [session, setSession] = import_react73.useState(null);
283533
- const [error40, setError] = import_react73.useState(null);
283534
- const [phase, setPhase] = import_react73.useState("loading");
283535
- const [abortController, setAbortController] = import_react73.useState(null);
283536
- const [panelMessages, setPanelMessages] = import_react73.useState([]);
283537
- const panelTextRef = import_react73.useRef("");
283538
- const panelSourceRef = import_react73.useRef(null);
283539
- const [pentestAgents, setPentestAgents] = import_react73.useState({});
283540
- const pentestTextRefs = import_react73.useRef({});
283541
- const [assets, setAssets] = import_react73.useState([]);
283542
- const [viewMode, setViewMode] = import_react73.useState("overview");
283543
- const [selectedAgentId, setSelectedAgentId] = import_react73.useState(null);
283544
- const [focusedIndex, setFocusedIndex] = import_react73.useState(0);
283545
- const [showOrchestratorPanel, setShowOrchestratorPanel] = import_react73.useState(false);
283546
- const [startTime, setStartTime] = import_react73.useState(null);
283547
- const pentestAgentList = import_react73.useMemo(() => Object.values(pentestAgents).sort((a, b3) => a.createdAt.getTime() - b3.createdAt.getTime()), [pentestAgents]);
283548
- const selectedAgent = import_react73.useMemo(() => selectedAgentId ? pentestAgents[selectedAgentId] ?? null : null, [pentestAgents, selectedAgentId]);
283549
- const { width: termWidth } = useDimensions();
283505
+ const [session, setSession] = import_react75.useState(null);
283506
+ const [error40, setError] = import_react75.useState(null);
283507
+ const [phase, setPhase] = import_react75.useState("loading");
283508
+ const [abortController, setAbortController] = import_react75.useState(null);
283509
+ const [panelMessages, setPanelMessages] = import_react75.useState([]);
283510
+ const panelTextRef = import_react75.useRef("");
283511
+ const panelSourceRef = import_react75.useRef(null);
283512
+ const [pentestAgents, setPentestAgents] = import_react75.useState({});
283513
+ const pentestTextRefs = import_react75.useRef({});
283514
+ const [assets, setAssets] = import_react75.useState([]);
283515
+ const [viewMode, setViewMode] = import_react75.useState("overview");
283516
+ const [selectedAgentId, setSelectedAgentId] = import_react75.useState(null);
283517
+ const [focusedIndex, setFocusedIndex] = import_react75.useState(0);
283518
+ const [showOrchestratorPanel, setShowOrchestratorPanel] = import_react75.useState(false);
283519
+ const [startTime, setStartTime] = import_react75.useState(null);
283520
+ const pentestAgentList = import_react75.useMemo(() => Object.values(pentestAgents).sort((a, b3) => a.createdAt.getTime() - b3.createdAt.getTime()), [pentestAgents]);
283521
+ const selectedAgent = import_react75.useMemo(() => selectedAgentId ? pentestAgents[selectedAgentId] ?? null : null, [pentestAgents, selectedAgentId]);
283522
+ const { width: termWidth } = useTerminalDimensions();
283550
283523
  const gridAvailableWidth = showOrchestratorPanel ? Math.floor((termWidth - 4) / 2) - 2 : termWidth - ORCHESTRATOR_PANEL_WIDTH - GRID_OUTER_PADDING;
283551
283524
  const gridColumns = Math.max(1, Math.floor((gridAvailableWidth + GRID_GAP) / (CARD_MIN_WIDTH + GRID_GAP)));
283552
- import_react73.useEffect(() => {
283525
+ import_react75.useEffect(() => {
283553
283526
  async function load2() {
283554
283527
  try {
283555
283528
  let s2;
@@ -283607,7 +283580,7 @@ function Pentest({
283607
283580
  }
283608
283581
  load2();
283609
283582
  }, [sessionId]);
283610
- import_react73.useEffect(() => {
283583
+ import_react75.useEffect(() => {
283611
283584
  if (!session)
283612
283585
  return;
283613
283586
  const assetsPath = join27(session.rootPath, "assets");
@@ -283630,12 +283603,12 @@ function Pentest({
283630
283603
  const interval = setInterval(readAssets, 2000);
283631
283604
  return () => clearInterval(interval);
283632
283605
  }, [session]);
283633
- import_react73.useEffect(() => {
283606
+ import_react75.useEffect(() => {
283634
283607
  return () => {
283635
283608
  abortController?.abort();
283636
283609
  };
283637
283610
  }, [abortController]);
283638
- const ensurePentestAgent = import_react73.useCallback((subagentId) => {
283611
+ const ensurePentestAgent = import_react75.useCallback((subagentId) => {
283639
283612
  setPentestAgents((prev) => {
283640
283613
  if (prev[subagentId])
283641
283614
  return prev;
@@ -283652,7 +283625,7 @@ function Pentest({
283652
283625
  };
283653
283626
  });
283654
283627
  }, []);
283655
- const handleSubagentSpawn = import_react73.useCallback(({
283628
+ const handleSubagentSpawn = import_react75.useCallback(({
283656
283629
  subagentId,
283657
283630
  input
283658
283631
  }) => {
@@ -283672,7 +283645,7 @@ function Pentest({
283672
283645
  }
283673
283646
  }));
283674
283647
  }, []);
283675
- const handleSubagentComplete = import_react73.useCallback(({ subagentId, status }) => {
283648
+ const handleSubagentComplete = import_react75.useCallback(({ subagentId, status }) => {
283676
283649
  if (!subagentId.startsWith("pentest-agent-"))
283677
283650
  return;
283678
283651
  setPentestAgents((prev) => {
@@ -283685,7 +283658,7 @@ function Pentest({
283685
283658
  };
283686
283659
  });
283687
283660
  }, []);
283688
- const appendPanelText = import_react73.useCallback((source, text2) => {
283661
+ const appendPanelText = import_react75.useCallback((source, text2) => {
283689
283662
  if (panelSourceRef.current !== source) {
283690
283663
  panelTextRef.current = "";
283691
283664
  panelSourceRef.current = source;
@@ -283710,7 +283683,7 @@ function Pentest({
283710
283683
  ];
283711
283684
  });
283712
283685
  }, []);
283713
- const appendPentestText = import_react73.useCallback((subagentId, text2) => {
283686
+ const appendPentestText = import_react75.useCallback((subagentId, text2) => {
283714
283687
  ensurePentestAgent(subagentId);
283715
283688
  if (!pentestTextRefs.current[subagentId]) {
283716
283689
  pentestTextRefs.current[subagentId] = "";
@@ -283743,8 +283716,8 @@ function Pentest({
283743
283716
  };
283744
283717
  });
283745
283718
  }, [ensurePentestAgent]);
283746
- const toolArgsDeltaRef = import_react73.useRef(new Map);
283747
- const addPanelStreamingToolCall = import_react73.useCallback((toolCallId, toolName) => {
283719
+ const toolArgsDeltaRef = import_react75.useRef(new Map);
283720
+ const addPanelStreamingToolCall = import_react75.useCallback((toolCallId, toolName) => {
283748
283721
  panelTextRef.current = "";
283749
283722
  panelSourceRef.current = null;
283750
283723
  toolArgsDeltaRef.current.set(toolCallId, "");
@@ -283763,7 +283736,7 @@ function Pentest({
283763
283736
  return [...prev, msg];
283764
283737
  });
283765
283738
  }, []);
283766
- const appendPanelToolCallDelta = import_react73.useCallback((toolCallId, argsTextDelta) => {
283739
+ const appendPanelToolCallDelta = import_react75.useCallback((toolCallId, argsTextDelta) => {
283767
283740
  const prev = toolArgsDeltaRef.current.get(toolCallId) ?? "";
283768
283741
  const accumulated = prev + argsTextDelta;
283769
283742
  toolArgsDeltaRef.current.set(toolCallId, accumulated);
@@ -283786,7 +283759,7 @@ function Pentest({
283786
283759
  return updated;
283787
283760
  });
283788
283761
  }, []);
283789
- const addPanelToolCall = import_react73.useCallback((toolCallId, toolName, args) => {
283762
+ const addPanelToolCall = import_react75.useCallback((toolCallId, toolName, args) => {
283790
283763
  panelTextRef.current = "";
283791
283764
  panelSourceRef.current = null;
283792
283765
  toolArgsDeltaRef.current.delete(toolCallId);
@@ -283818,7 +283791,7 @@ function Pentest({
283818
283791
  ];
283819
283792
  });
283820
283793
  }, []);
283821
- const addPentestStreamingToolCall = import_react73.useCallback((subagentId, toolCallId, toolName) => {
283794
+ const addPentestStreamingToolCall = import_react75.useCallback((subagentId, toolCallId, toolName) => {
283822
283795
  pentestTextRefs.current[subagentId] = "";
283823
283796
  ensurePentestAgent(subagentId);
283824
283797
  toolArgsDeltaRef.current.set(toolCallId, "");
@@ -283843,7 +283816,7 @@ function Pentest({
283843
283816
  };
283844
283817
  });
283845
283818
  }, [ensurePentestAgent]);
283846
- const appendPentestToolCallDelta = import_react73.useCallback((subagentId, toolCallId, argsTextDelta) => {
283819
+ const appendPentestToolCallDelta = import_react75.useCallback((subagentId, toolCallId, argsTextDelta) => {
283847
283820
  const prev = toolArgsDeltaRef.current.get(toolCallId) ?? "";
283848
283821
  const accumulated = prev + argsTextDelta;
283849
283822
  toolArgsDeltaRef.current.set(toolCallId, accumulated);
@@ -283869,7 +283842,7 @@ function Pentest({
283869
283842
  return { ...agents, [subagentId]: { ...agent, messages: updatedMsgs } };
283870
283843
  });
283871
283844
  }, []);
283872
- const addPentestToolCall = import_react73.useCallback((subagentId, toolCallId, toolName, args) => {
283845
+ const addPentestToolCall = import_react75.useCallback((subagentId, toolCallId, toolName, args) => {
283873
283846
  pentestTextRefs.current[subagentId] = "";
283874
283847
  ensurePentestAgent(subagentId);
283875
283848
  toolArgsDeltaRef.current.delete(toolCallId);
@@ -283930,12 +283903,12 @@ function Pentest({
283930
283903
  }
283931
283904
  ];
283932
283905
  };
283933
- const updatePanelToolResult = import_react73.useCallback((toolCallId, toolName, result) => {
283906
+ const updatePanelToolResult = import_react75.useCallback((toolCallId, toolName, result) => {
283934
283907
  panelTextRef.current = "";
283935
283908
  panelSourceRef.current = null;
283936
283909
  setPanelMessages((prev) => toolResultUpdater(prev, toolCallId, toolName, result));
283937
283910
  }, []);
283938
- const updatePentestToolResult = import_react73.useCallback((subagentId, toolCallId, toolName, result) => {
283911
+ const updatePentestToolResult = import_react75.useCallback((subagentId, toolCallId, toolName, result) => {
283939
283912
  pentestTextRefs.current[subagentId] = "";
283940
283913
  setPentestAgents((prev) => {
283941
283914
  const agent = prev[subagentId];
@@ -283950,7 +283923,7 @@ function Pentest({
283950
283923
  };
283951
283924
  });
283952
283925
  }, []);
283953
- const startPentest = import_react73.useCallback(async (s2) => {
283926
+ const startPentest = import_react75.useCallback(async (s2) => {
283954
283927
  setPhase("discovery");
283955
283928
  setStartTime(new Date);
283956
283929
  setIsExecuting(true);
@@ -284077,7 +284050,7 @@ function Pentest({
284077
284050
  handleSubagentSpawn,
284078
284051
  handleSubagentComplete
284079
284052
  ]);
284080
- import_react73.useEffect(() => {
284053
+ import_react75.useEffect(() => {
284081
284054
  if (phase === "completed") {
284082
284055
  setFocusedIndex(pentestAgentList.length);
284083
284056
  }
@@ -284140,7 +284113,7 @@ function Pentest({
284140
284113
  }
284141
284114
  }
284142
284115
  });
284143
- const openReport = import_react73.useCallback(() => {
284116
+ const openReport = import_react75.useCallback(() => {
284144
284117
  if (!session)
284145
284118
  return;
284146
284119
  const err = openSessionReport(session.rootPath);
@@ -284325,7 +284298,7 @@ function OrchestratorPanel({
284325
284298
  }) {
284326
284299
  const { colors: colors2 } = useTheme();
284327
284300
  const isRunning = phase !== "loading" && phase !== "completed" && phase !== "error";
284328
- const assetSummary = import_react73.useMemo(() => {
284301
+ const assetSummary = import_react75.useMemo(() => {
284329
284302
  const byType = {};
284330
284303
  for (const a of assets) {
284331
284304
  const key = a.assetType;
@@ -284568,13 +284541,13 @@ function AgentCardGrid({
284568
284541
  onSelectAgent
284569
284542
  }) {
284570
284543
  const { colors: colors2 } = useTheme();
284571
- const scrollRef = import_react73.useRef(null);
284572
- import_react73.useEffect(() => {
284544
+ const scrollRef = import_react75.useRef(null);
284545
+ import_react75.useEffect(() => {
284573
284546
  const agent = agents[focusedIndex];
284574
284547
  if (agent)
284575
284548
  scrollToChild(scrollRef.current, agent.id);
284576
284549
  }, [focusedIndex, agents]);
284577
- const rows = import_react73.useMemo(() => {
284550
+ const rows = import_react75.useMemo(() => {
284578
284551
  const result = [];
284579
284552
  for (let i2 = 0;i2 < agents.length; i2 += gridColumns) {
284580
284553
  result.push(agents.slice(i2, i2 + gridColumns));
@@ -284631,14 +284604,14 @@ function AgentCard({
284631
284604
  completed: colors2.primary,
284632
284605
  failed: colors2.error
284633
284606
  }[agent.status];
284634
- const lastActivity = import_react73.useMemo(() => {
284607
+ const lastActivity = import_react75.useMemo(() => {
284635
284608
  const last = agent.messages[agent.messages.length - 1];
284636
284609
  if (!last)
284637
284610
  return "Starting...";
284638
284611
  const text2 = typeof last.content === "string" ? last.content.replace(/\n/g, " ").trim() : "Working...";
284639
284612
  return text2.length > 50 ? text2.substring(0, 47) + "..." : text2;
284640
284613
  }, [agent.messages]);
284641
- const toolCalls = import_react73.useMemo(() => agent.messages.filter((m4) => m4.role === "tool").length, [agent.messages]);
284614
+ const toolCalls = import_react75.useMemo(() => agent.messages.filter((m4) => m4.role === "tool").length, [agent.messages]);
284642
284615
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
284643
284616
  id: agent.id,
284644
284617
  flexGrow: 1,
@@ -284826,8 +284799,8 @@ function MetricsBar({
284826
284799
  isExecuting
284827
284800
  }) {
284828
284801
  const { colors: colors2 } = useTheme();
284829
- const [now2, setNow] = import_react73.useState(Date.now());
284830
- import_react73.useEffect(() => {
284802
+ const [now2, setNow] = import_react75.useState(Date.now());
284803
+ import_react75.useEffect(() => {
284831
284804
  if (!isExecuting)
284832
284805
  return;
284833
284806
  const interval = setInterval(() => setNow(Date.now()), 1000);
@@ -284970,7 +284943,7 @@ function MetricsBar({
284970
284943
  }
284971
284944
 
284972
284945
  // src/tui/components/operator-dashboard/index.tsx
284973
- var import_react78 = __toESM(require_react(), 1);
284946
+ var import_react80 = __toESM(require_react(), 1);
284974
284947
  init_session();
284975
284948
 
284976
284949
  // src/core/api/offesecAgent.ts
@@ -285073,7 +285046,7 @@ function InlineApprovalPrompt2({ approval }) {
285073
285046
  }
285074
285047
 
285075
285048
  // src/tui/components/chat/loading-indicator.tsx
285076
- var import_react75 = __toESM(require_react(), 1);
285049
+ var import_react77 = __toESM(require_react(), 1);
285077
285050
  var SPINNER_FRAMES2 = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
285078
285051
  var SPINNER_INTERVAL2 = 80;
285079
285052
  var DOTS_FRAMES = ["", ".", "..", "..."];
@@ -285084,15 +285057,15 @@ function LoadingIndicator({
285084
285057
  toolName
285085
285058
  }) {
285086
285059
  const { colors: colors2 } = useTheme();
285087
- const [spinnerFrame, setSpinnerFrame] = import_react75.useState(0);
285088
- const [dotsFrame, setDotsFrame] = import_react75.useState(0);
285089
- import_react75.useEffect(() => {
285060
+ const [spinnerFrame, setSpinnerFrame] = import_react77.useState(0);
285061
+ const [dotsFrame, setDotsFrame] = import_react77.useState(0);
285062
+ import_react77.useEffect(() => {
285090
285063
  const interval = setInterval(() => {
285091
285064
  setSpinnerFrame((f3) => (f3 + 1) % SPINNER_FRAMES2.length);
285092
285065
  }, SPINNER_INTERVAL2);
285093
285066
  return () => clearInterval(interval);
285094
285067
  }, []);
285095
- import_react75.useEffect(() => {
285068
+ import_react77.useEffect(() => {
285096
285069
  const interval = setInterval(() => {
285097
285070
  setDotsFrame((f3) => (f3 + 1) % DOTS_FRAMES.length);
285098
285071
  }, DOTS_INTERVAL);
@@ -285346,7 +285319,7 @@ function MessageList({
285346
285319
  }
285347
285320
 
285348
285321
  // src/tui/components/chat/input-area.tsx
285349
- var import_react76 = __toESM(require_react(), 1);
285322
+ var import_react78 = __toESM(require_react(), 1);
285350
285323
  function NormalInputAreaInner({
285351
285324
  value,
285352
285325
  onChange,
@@ -285368,10 +285341,10 @@ function NormalInputAreaInner({
285368
285341
  }) {
285369
285342
  const { colors: colors2, theme, mode: colorMode } = useTheme();
285370
285343
  const { inputValue, setInputValue } = useInput();
285371
- const promptRef = import_react76.useRef(null);
285372
- const isExternalUpdate = import_react76.useRef(false);
285373
- const prevValueRef = import_react76.useRef(value);
285374
- import_react76.useEffect(() => {
285344
+ const promptRef = import_react78.useRef(null);
285345
+ const isExternalUpdate = import_react78.useRef(false);
285346
+ const prevValueRef = import_react78.useRef(value);
285347
+ import_react78.useEffect(() => {
285375
285348
  const prevValue = prevValueRef.current;
285376
285349
  prevValueRef.current = value;
285377
285350
  if (value !== prevValue && value !== inputValue) {
@@ -285380,7 +285353,7 @@ function NormalInputAreaInner({
285380
285353
  promptRef.current?.setValue(value);
285381
285354
  }
285382
285355
  }, [value, inputValue, setInputValue]);
285383
- import_react76.useEffect(() => {
285356
+ import_react78.useEffect(() => {
285384
285357
  if (isExternalUpdate.current) {
285385
285358
  isExternalUpdate.current = false;
285386
285359
  return;
@@ -285555,7 +285528,7 @@ function ApprovalInputArea2({
285555
285528
  lastDeclineNote
285556
285529
  }) {
285557
285530
  const { colors: colors2 } = useTheme();
285558
- const [focusedElement, setFocusedElement] = import_react76.useState(0);
285531
+ const [focusedElement, setFocusedElement] = import_react78.useState(0);
285559
285532
  useKeyboard((key) => {
285560
285533
  if (key.name === "up") {
285561
285534
  setFocusedElement((prev) => Math.max(0, prev - 1));
@@ -285882,29 +285855,29 @@ function OperatorDashboard({
285882
285855
  clear: clearDialog,
285883
285856
  setSize: setDialogSize
285884
285857
  } = useDialog();
285885
- const autocompleteOptions = import_react78.useMemo(() => {
285858
+ const autocompleteOptions = import_react80.useMemo(() => {
285886
285859
  const skillSlugs = new Set(skills.map((s2) => `/${slugify(s2.name)}`));
285887
285860
  return filterOperatorAutocomplete(allAutocompleteOptions, skillSlugs);
285888
285861
  }, [allAutocompleteOptions, skills]);
285889
- const [session, setSession] = import_react78.useState(null);
285890
- const [loading, setLoading] = import_react78.useState(true);
285891
- const [error40, setError] = import_react78.useState(null);
285892
- const pendingNameRef = import_react78.useRef(null);
285893
- const [status, setStatus] = import_react78.useState("idle");
285894
- const abortControllerRef = import_react78.useRef(null);
285895
- const generationRef = import_react78.useRef(0);
285896
- const cancelHandleRef = import_react78.useRef({
285862
+ const [session, setSession] = import_react80.useState(null);
285863
+ const [loading, setLoading] = import_react80.useState(true);
285864
+ const [error40, setError] = import_react80.useState(null);
285865
+ const pendingNameRef = import_react80.useRef(null);
285866
+ const [status, setStatus] = import_react80.useState("idle");
285867
+ const abortControllerRef = import_react80.useRef(null);
285868
+ const generationRef = import_react80.useRef(0);
285869
+ const cancelHandleRef = import_react80.useRef({
285897
285870
  cancel: () => false
285898
285871
  });
285899
- const commandCancelledRef = import_react78.useRef(false);
285900
- const [messages, setMessages] = import_react78.useState([]);
285901
- const textRef = import_react78.useRef("");
285902
- const conversationRef = import_react78.useRef([]);
285903
- const [inputValue, setInputValue] = import_react78.useState("");
285904
- const [queuedMessages, setQueuedMessages] = import_react78.useState([]);
285905
- const [selectedQueueIndex, setSelectedQueueIndex] = import_react78.useState(-1);
285906
- const queuedMessagesRef = import_react78.useRef([]);
285907
- import_react78.useEffect(() => {
285872
+ const commandCancelledRef = import_react80.useRef(false);
285873
+ const [messages, setMessages] = import_react80.useState([]);
285874
+ const textRef = import_react80.useRef("");
285875
+ const conversationRef = import_react80.useRef([]);
285876
+ const [inputValue, setInputValue] = import_react80.useState("");
285877
+ const [queuedMessages, setQueuedMessages] = import_react80.useState([]);
285878
+ const [selectedQueueIndex, setSelectedQueueIndex] = import_react80.useState(-1);
285879
+ const queuedMessagesRef = import_react80.useRef([]);
285880
+ import_react80.useEffect(() => {
285908
285881
  queuedMessagesRef.current = queuedMessages;
285909
285882
  if (queuedMessages.length === 0) {
285910
285883
  setSelectedQueueIndex(-1);
@@ -285912,17 +285885,17 @@ function OperatorDashboard({
285912
285885
  setSelectedQueueIndex(queuedMessages.length - 1);
285913
285886
  }
285914
285887
  }, [queuedMessages, selectedQueueIndex]);
285915
- const [operatorState, setOperatorState] = import_react78.useState(() => createInitialOperatorState("manual", true));
285916
- const approvalGateRef = import_react78.useRef(new ApprovalGate({ requireApproval: true }));
285917
- const [pendingApprovals, setPendingApprovals] = import_react78.useState([]);
285918
- const [lastApprovedAction, setLastApprovedAction] = import_react78.useState(null);
285919
- const [verboseMode, setVerboseMode] = import_react78.useState(false);
285920
- const [expandedLogs, setExpandedLogs] = import_react78.useState(false);
285921
- const tokenUsageRef = import_react78.useRef(tokenUsage);
285922
- import_react78.useEffect(() => {
285888
+ const [operatorState, setOperatorState] = import_react80.useState(() => createInitialOperatorState("manual", true));
285889
+ const approvalGateRef = import_react80.useRef(new ApprovalGate({ requireApproval: true }));
285890
+ const [pendingApprovals, setPendingApprovals] = import_react80.useState([]);
285891
+ const [lastApprovedAction, setLastApprovedAction] = import_react80.useState(null);
285892
+ const [verboseMode, setVerboseMode] = import_react80.useState(false);
285893
+ const [expandedLogs, setExpandedLogs] = import_react80.useState(false);
285894
+ const tokenUsageRef = import_react80.useRef(tokenUsage);
285895
+ import_react80.useEffect(() => {
285923
285896
  tokenUsageRef.current = tokenUsage;
285924
285897
  }, [tokenUsage]);
285925
- import_react78.useEffect(() => {
285898
+ import_react80.useEffect(() => {
285926
285899
  const gate = approvalGateRef.current;
285927
285900
  const onApprovalNeeded = () => {
285928
285901
  setPendingApprovals(gate.getPendingApprovals());
@@ -285944,7 +285917,7 @@ function OperatorDashboard({
285944
285917
  gate.off("approval-resolved", onApprovalResolved);
285945
285918
  };
285946
285919
  }, []);
285947
- import_react78.useEffect(() => {
285920
+ import_react80.useEffect(() => {
285948
285921
  async function loadSession() {
285949
285922
  try {
285950
285923
  if (sessionId) {
@@ -286001,10 +285974,10 @@ function OperatorDashboard({
286001
285974
  }
286002
285975
  loadSession();
286003
285976
  }, [sessionId]);
286004
- import_react78.useEffect(() => {
285977
+ import_react80.useEffect(() => {
286005
285978
  return () => setSessionCwd(null);
286006
285979
  }, [setSessionCwd]);
286007
- import_react78.useEffect(() => {
285980
+ import_react80.useEffect(() => {
286008
285981
  if (!session)
286009
285982
  return;
286010
285983
  resetTokenUsage();
@@ -286022,7 +285995,7 @@ function OperatorDashboard({
286022
285995
  });
286023
285996
  } catch {}
286024
285997
  }, [session, addTokenUsage, resetTokenUsage]);
286025
- const appendText = import_react78.useCallback((text2) => {
285998
+ const appendText = import_react80.useCallback((text2) => {
286026
285999
  textRef.current += text2;
286027
286000
  const accumulated = textRef.current;
286028
286001
  setMessages((prev) => {
@@ -286038,8 +286011,8 @@ function OperatorDashboard({
286038
286011
  ];
286039
286012
  });
286040
286013
  }, []);
286041
- const toolArgsDeltaRef = import_react78.useRef(new Map);
286042
- const addStreamingToolCall = import_react78.useCallback((toolCallId, toolName) => {
286014
+ const toolArgsDeltaRef = import_react80.useRef(new Map);
286015
+ const addStreamingToolCall = import_react80.useCallback((toolCallId, toolName) => {
286043
286016
  textRef.current = "";
286044
286017
  toolArgsDeltaRef.current.set(toolCallId, {
286045
286018
  toolName,
@@ -286058,7 +286031,7 @@ function OperatorDashboard({
286058
286031
  }
286059
286032
  ]);
286060
286033
  }, []);
286061
- const appendToolCallDelta = import_react78.useCallback((toolCallId, argsTextDelta) => {
286034
+ const appendToolCallDelta = import_react80.useCallback((toolCallId, argsTextDelta) => {
286062
286035
  const entry = toolArgsDeltaRef.current.get(toolCallId);
286063
286036
  const accumulated = (entry?.accumulated ?? "") + argsTextDelta;
286064
286037
  toolArgsDeltaRef.current.set(toolCallId, {
@@ -286080,7 +286053,7 @@ function OperatorDashboard({
286080
286053
  return updated;
286081
286054
  });
286082
286055
  }, []);
286083
- const addToolCall = import_react78.useCallback((toolCallId, toolName, args) => {
286056
+ const addToolCall = import_react80.useCallback((toolCallId, toolName, args) => {
286084
286057
  textRef.current = "";
286085
286058
  toolArgsDeltaRef.current.delete(toolCallId);
286086
286059
  setMessages((prev) => {
@@ -286109,7 +286082,7 @@ function OperatorDashboard({
286109
286082
  ];
286110
286083
  });
286111
286084
  }, []);
286112
- const updateToolResult = import_react78.useCallback((toolCallId, _toolName, result) => {
286085
+ const updateToolResult = import_react80.useCallback((toolCallId, _toolName, result) => {
286113
286086
  textRef.current = "";
286114
286087
  setMessages((prev) => {
286115
286088
  const idx = prev.findIndex((m4) => isToolMessage(m4) && m4.toolCallId === toolCallId);
@@ -286120,10 +286093,10 @@ function OperatorDashboard({
286120
286093
  return updated;
286121
286094
  });
286122
286095
  }, []);
286123
- const cmdOutputBufRef = import_react78.useRef("");
286124
- const cmdFlushTimerRef = import_react78.useRef(null);
286096
+ const cmdOutputBufRef = import_react80.useRef("");
286097
+ const cmdFlushTimerRef = import_react80.useRef(null);
286125
286098
  const MAX_LOG_LINES = 200;
286126
- const flushCommandOutput = import_react78.useCallback(() => {
286099
+ const flushCommandOutput = import_react80.useCallback(() => {
286127
286100
  const buf = cmdOutputBufRef.current;
286128
286101
  if (!buf)
286129
286102
  return;
@@ -286153,7 +286126,7 @@ function OperatorDashboard({
286153
286126
  return updated;
286154
286127
  });
286155
286128
  }, []);
286156
- const onCommandOutput = import_react78.useCallback((data) => {
286129
+ const onCommandOutput = import_react80.useCallback((data) => {
286157
286130
  cmdOutputBufRef.current += data;
286158
286131
  if (!cmdFlushTimerRef.current) {
286159
286132
  cmdFlushTimerRef.current = setInterval(() => {
@@ -286161,7 +286134,7 @@ function OperatorDashboard({
286161
286134
  }, 150);
286162
286135
  }
286163
286136
  }, [flushCommandOutput]);
286164
- import_react78.useEffect(() => {
286137
+ import_react80.useEffect(() => {
286165
286138
  return () => {
286166
286139
  if (cmdFlushTimerRef.current) {
286167
286140
  clearInterval(cmdFlushTimerRef.current);
@@ -286169,7 +286142,7 @@ function OperatorDashboard({
286169
286142
  }
286170
286143
  };
286171
286144
  }, []);
286172
- const appendLogToActiveTool = import_react78.useCallback((line) => {
286145
+ const appendLogToActiveTool = import_react80.useCallback((line) => {
286173
286146
  setMessages((prev) => {
286174
286147
  const idx = prev.findLastIndex((m4) => isToolMessage(m4) && (m4.status === "pending" || m4.status === "streaming"));
286175
286148
  if (idx === -1)
@@ -286184,7 +286157,7 @@ function OperatorDashboard({
286184
286157
  return updated;
286185
286158
  });
286186
286159
  }, []);
286187
- const initSubagent = import_react78.useCallback((subagentId, name26) => {
286160
+ const initSubagent = import_react80.useCallback((subagentId, name26) => {
286188
286161
  setMessages((prev) => {
286189
286162
  const idx = prev.findLastIndex((m4) => isToolMessage(m4) && (m4.status === "pending" || m4.status === "streaming"));
286190
286163
  if (idx === -1)
@@ -286199,7 +286172,7 @@ function OperatorDashboard({
286199
286172
  return updated;
286200
286173
  });
286201
286174
  }, []);
286202
- const completeSubagent = import_react78.useCallback((subagentId, status2) => {
286175
+ const completeSubagent = import_react80.useCallback((subagentId, status2) => {
286203
286176
  setMessages((prev) => {
286204
286177
  const idx = prev.findLastIndex((m4) => isToolMessage(m4) && (m4.status === "pending" || m4.status === "streaming"));
286205
286178
  if (idx === -1)
@@ -286217,7 +286190,7 @@ function OperatorDashboard({
286217
286190
  return updated;
286218
286191
  });
286219
286192
  }, []);
286220
- const appendLogToSubagent = import_react78.useCallback((subagentId, line) => {
286193
+ const appendLogToSubagent = import_react80.useCallback((subagentId, line) => {
286221
286194
  setMessages((prev) => {
286222
286195
  const idx = prev.findLastIndex((m4) => isToolMessage(m4) && (m4.status === "pending" || m4.status === "streaming"));
286223
286196
  if (idx === -1)
@@ -286239,13 +286212,13 @@ function OperatorDashboard({
286239
286212
  return updated;
286240
286213
  });
286241
286214
  }, []);
286242
- const handleApprove = import_react78.useCallback(() => {
286215
+ const handleApprove = import_react80.useCallback(() => {
286243
286216
  const pending = approvalGateRef.current.getPendingApprovals();
286244
286217
  if (pending.length > 0) {
286245
286218
  approvalGateRef.current.approve(pending[0].id);
286246
286219
  }
286247
286220
  }, []);
286248
- const handleAutoApprove = import_react78.useCallback(() => {
286221
+ const handleAutoApprove = import_react80.useCallback(() => {
286249
286222
  approvalGateRef.current.updateConfig({ requireApproval: false });
286250
286223
  setOperatorState((prev) => ({ ...prev, requireApproval: false }));
286251
286224
  const pending = approvalGateRef.current.getPendingApprovals();
@@ -286253,7 +286226,7 @@ function OperatorDashboard({
286253
286226
  approvalGateRef.current.approve(p.id);
286254
286227
  }
286255
286228
  }, []);
286256
- const runAgent = import_react78.useCallback(async (prompt) => {
286229
+ const runAgent = import_react80.useCallback(async (prompt) => {
286257
286230
  if (abortControllerRef.current) {
286258
286231
  abortControllerRef.current.abort();
286259
286232
  abortControllerRef.current = null;
@@ -286467,7 +286440,7 @@ function OperatorDashboard({
286467
286440
  setThinking,
286468
286441
  setIsExecuting
286469
286442
  ]);
286470
- const handleSubmit = import_react78.useCallback((value) => {
286443
+ const handleSubmit = import_react80.useCallback((value) => {
286471
286444
  const pending = approvalGateRef.current.getPendingApprovals();
286472
286445
  const result = resolveSubmit(value, status, pending.length > 0);
286473
286446
  if (result.denyPending) {
@@ -286485,16 +286458,16 @@ function OperatorDashboard({
286485
286458
  setInputValue("");
286486
286459
  runAgent(result.prompt);
286487
286460
  }, [status, runAgent]);
286488
- const initialMessageSentRef = import_react78.useRef(false);
286489
- const runAgentRef = import_react78.useRef(runAgent);
286461
+ const initialMessageSentRef = import_react80.useRef(false);
286462
+ const runAgentRef = import_react80.useRef(runAgent);
286490
286463
  runAgentRef.current = runAgent;
286491
- import_react78.useEffect(() => {
286464
+ import_react80.useEffect(() => {
286492
286465
  if (!loading && initialMessage && !initialMessageSentRef.current) {
286493
286466
  initialMessageSentRef.current = true;
286494
286467
  runAgentRef.current(initialMessage);
286495
286468
  }
286496
286469
  }, [loading, initialMessage]);
286497
- import_react78.useEffect(() => {
286470
+ import_react80.useEffect(() => {
286498
286471
  if (status !== "idle")
286499
286472
  return;
286500
286473
  const queue = queuedMessagesRef.current;
@@ -286505,7 +286478,7 @@ function OperatorDashboard({
286505
286478
  setSelectedQueueIndex(-1);
286506
286479
  runAgentRef.current(next);
286507
286480
  }, [status]);
286508
- const showModelPicker = import_react78.useCallback(() => {
286481
+ const showModelPicker = import_react80.useCallback(() => {
286509
286482
  setDialogSize("large");
286510
286483
  showDialog(/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
286511
286484
  flexDirection: "column",
@@ -286567,7 +286540,7 @@ function OperatorDashboard({
286567
286540
  clearDialog,
286568
286541
  setDialogSize
286569
286542
  ]);
286570
- const handleCommandExecute = import_react78.useCallback(async (command) => {
286543
+ const handleCommandExecute = import_react80.useCallback(async (command) => {
286571
286544
  const action = routeCommand(command, resolveSkillContent);
286572
286545
  switch (action.type) {
286573
286546
  case "show-models":
@@ -286585,7 +286558,7 @@ function OperatorDashboard({
286585
286558
  return;
286586
286559
  }
286587
286560
  }, [resolveSkillContent, handleSubmit, executeCommand2, showModelPicker]);
286588
- const handleAbort = import_react78.useCallback(() => {
286561
+ const handleAbort = import_react80.useCallback(() => {
286589
286562
  if (!abortControllerRef.current)
286590
286563
  return;
286591
286564
  const action = resolveAbortAction(commandCancelledRef.current, () => cancelHandleRef.current.cancel());
@@ -286635,7 +286608,7 @@ function OperatorDashboard({
286635
286608
  ];
286636
286609
  });
286637
286610
  }, [session, setThinking, setIsExecuting]);
286638
- const toggleApproval = import_react78.useCallback(() => {
286611
+ const toggleApproval = import_react80.useCallback(() => {
286639
286612
  setOperatorState((prev) => {
286640
286613
  const newVal = !prev.requireApproval;
286641
286614
  approvalGateRef.current.updateConfig({ requireApproval: newVal });
@@ -286869,10 +286842,10 @@ function OperatorDashboard({
286869
286842
  }
286870
286843
 
286871
286844
  // src/tui/components/commands/theme-picker.tsx
286872
- var import_react80 = __toESM(require_react(), 1);
286845
+ var import_react82 = __toESM(require_react(), 1);
286873
286846
  init_config2();
286874
286847
  function ThemePicker({ onClose }) {
286875
- const dimensions = useDimensions();
286848
+ const dimensions = useTerminalDimensions();
286876
286849
  const {
286877
286850
  colors: colors2,
286878
286851
  theme,
@@ -286882,15 +286855,15 @@ function ThemePicker({ onClose }) {
286882
286855
  toggleMode,
286883
286856
  setMode
286884
286857
  } = useTheme();
286885
- const [selectedIndex, setSelectedIndex] = import_react80.useState(() => Math.max(0, availableThemes.indexOf(theme.name)));
286886
- const originalThemeRef = import_react80.useRef(theme.name);
286887
- const originalModeRef = import_react80.useRef(mode);
286888
- const handleClose = import_react80.useCallback(() => {
286858
+ const [selectedIndex, setSelectedIndex] = import_react82.useState(() => Math.max(0, availableThemes.indexOf(theme.name)));
286859
+ const originalThemeRef = import_react82.useRef(theme.name);
286860
+ const originalModeRef = import_react82.useRef(mode);
286861
+ const handleClose = import_react82.useCallback(() => {
286889
286862
  setTheme(originalThemeRef.current);
286890
286863
  setMode(originalModeRef.current);
286891
286864
  onClose();
286892
286865
  }, [setTheme, setMode, onClose]);
286893
- const handleConfirm = import_react80.useCallback(async () => {
286866
+ const handleConfirm = import_react82.useCallback(async () => {
286894
286867
  const currentThemeName = availableThemes[selectedIndex];
286895
286868
  if (currentThemeName) {
286896
286869
  await config2.update({ theme: currentThemeName });
@@ -287019,16 +286992,16 @@ function ThemePicker({ onClose }) {
287019
286992
  }
287020
286993
 
287021
286994
  // src/tui/components/commands/create-skill-wizard.tsx
287022
- var import_react82 = __toESM(require_react(), 1);
286995
+ var import_react84 = __toESM(require_react(), 1);
287023
286996
  function CreateSkillWizard() {
287024
286997
  const { colors: colors2 } = useTheme();
287025
286998
  const route = useRoute();
287026
- const [step, setStep] = import_react82.useState("name");
287027
- const [name26, setName] = import_react82.useState("");
287028
- const [description, setDescription] = import_react82.useState("");
287029
- const [content, setContent] = import_react82.useState("");
287030
- const [error40, setError] = import_react82.useState(null);
287031
- const [confirmFocused, setConfirmFocused] = import_react82.useState(0);
286999
+ const [step, setStep] = import_react84.useState("name");
287000
+ const [name26, setName] = import_react84.useState("");
287001
+ const [description, setDescription] = import_react84.useState("");
287002
+ const [content, setContent] = import_react84.useState("");
287003
+ const [error40, setError] = import_react84.useState(null);
287004
+ const [confirmFocused, setConfirmFocused] = import_react84.useState(0);
287032
287005
  const slug = slugify(name26);
287033
287006
  async function handleSave() {
287034
287007
  if (!name26.trim() || !content.trim())
@@ -289904,7 +289877,7 @@ async function detectTerminalMode(timeoutMs = 1000) {
289904
289877
  }
289905
289878
 
289906
289879
  // src/tui/console-theme.ts
289907
- var import_react84 = __toESM(require_react(), 1);
289880
+ var import_react86 = __toESM(require_react(), 1);
289908
289881
  var withAlpha = (rgba, a) => RGBA.fromValues(rgba.r, rgba.g, rgba.b, a);
289909
289882
  var overlayThemeRef = {
289910
289883
  current: null
@@ -289927,7 +289900,7 @@ function buildConsoleOptions(themeColors) {
289927
289900
  function ConsoleThemeSync() {
289928
289901
  const { colors: colors2 } = useTheme();
289929
289902
  const renderer = useRenderer();
289930
- import_react84.useEffect(() => {
289903
+ import_react86.useEffect(() => {
289931
289904
  overlayThemeRef.current = colors2;
289932
289905
  const c = renderer.console;
289933
289906
  c.backgroundColor = withAlpha(colors2.backgroundPanel, 0.85);
@@ -290015,17 +289988,17 @@ function setupAutoCopy(renderer, copyToClipboard) {
290015
289988
 
290016
289989
  // src/tui/index.tsx
290017
289990
  function App({ appConfig }) {
290018
- const [focusIndex, setFocusIndex] = import_react87.useState(0);
290019
- const [cwd, setCwd] = import_react87.useState(process.cwd());
290020
- const [ctrlCPressTime, setCtrlCPressTime] = import_react87.useState(null);
290021
- const [showExitWarning, setShowExitWarning] = import_react87.useState(false);
290022
- const [inputKey, setInputKey] = import_react87.useState(0);
290023
- const [showSessionsDialog, setShowSessionsDialog] = import_react87.useState(false);
290024
- const [showShortcutsDialog, setShowShortcutsDialog] = import_react87.useState(false);
290025
- const [showThemeDialog, setShowThemeDialog] = import_react87.useState(false);
290026
- const [showAuthDialog, setShowAuthDialog] = import_react87.useState(false);
290027
- const [showPentestDialog, setShowPentestDialog] = import_react87.useState(false);
290028
- const [pendingPentestFlags, setPendingPentestFlags] = import_react87.useState(undefined);
289991
+ const [focusIndex, setFocusIndex] = import_react89.useState(0);
289992
+ const [cwd, setCwd] = import_react89.useState(process.cwd());
289993
+ const [ctrlCPressTime, setCtrlCPressTime] = import_react89.useState(null);
289994
+ const [showExitWarning, setShowExitWarning] = import_react89.useState(false);
289995
+ const [inputKey, setInputKey] = import_react89.useState(0);
289996
+ const [showSessionsDialog, setShowSessionsDialog] = import_react89.useState(false);
289997
+ const [showShortcutsDialog, setShowShortcutsDialog] = import_react89.useState(false);
289998
+ const [showThemeDialog, setShowThemeDialog] = import_react89.useState(false);
289999
+ const [showAuthDialog, setShowAuthDialog] = import_react89.useState(false);
290000
+ const [showPentestDialog, setShowPentestDialog] = import_react89.useState(false);
290001
+ const [pendingPentestFlags, setPendingPentestFlags] = import_react89.useState(undefined);
290029
290002
  const navigableItems = ["command-input"];
290030
290003
  return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ConfigProvider, {
290031
290004
  config: appConfig,
@@ -290112,14 +290085,14 @@ function AppContent({
290112
290085
  const { toast } = useToast();
290113
290086
  const { refocusPrompt } = useFocus();
290114
290087
  const { setExternalDialogOpen } = useDialog();
290115
- import_react87.useEffect(() => {
290088
+ import_react89.useEffect(() => {
290116
290089
  checkForUpdate().then(({ updateAvailable, currentVersion, latestVersion }) => {
290117
290090
  if (!updateAvailable)
290118
290091
  return;
290119
290092
  toast(`Update available: v${currentVersion} → v${latestVersion}. Run: pensar upgrade`, "warn", 8000);
290120
290093
  });
290121
290094
  }, []);
290122
- import_react87.useEffect(() => {
290095
+ import_react89.useEffect(() => {
290123
290096
  if (route.data.type !== "base")
290124
290097
  return;
290125
290098
  if (!config3.data.responsibleUseAccepted && route.data.path !== "disclosure") {
@@ -290128,12 +290101,12 @@ function AppContent({
290128
290101
  route.navigate({ type: "base", path: "providers" });
290129
290102
  }
290130
290103
  }, [config3.data.responsibleUseAccepted, route.data]);
290131
- import_react87.useEffect(() => {
290104
+ import_react89.useEffect(() => {
290132
290105
  if (showThemeDialog || showAuthDialog || showPentestDialog) {
290133
290106
  setExternalDialogOpen(true);
290134
290107
  }
290135
290108
  }, [showThemeDialog, showAuthDialog, showPentestDialog]);
290136
- import_react87.useEffect(() => {
290109
+ import_react89.useEffect(() => {
290137
290110
  if (showExitWarning) {
290138
290111
  const timer = setTimeout(() => {
290139
290112
  setShowExitWarning(false);
@@ -290387,18 +290360,16 @@ async function main2() {
290387
290360
  initialMode: mode,
290388
290361
  children: [
290389
290362
  /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ConsoleThemeSync, {}, undefined, false, undefined, this),
290390
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(TerminalDimensionsProvider, {
290391
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToastProvider, {
290392
- children: [
290393
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ErrorBoundary2, {
290394
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(App, {
290395
- appConfig
290396
- }, undefined, false, undefined, this)
290397
- }, undefined, false, undefined, this),
290398
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToastContainer, {}, undefined, false, undefined, this)
290399
- ]
290400
- }, undefined, true, undefined, this)
290401
- }, undefined, false, undefined, this)
290363
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToastProvider, {
290364
+ children: [
290365
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ErrorBoundary2, {
290366
+ children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(App, {
290367
+ appConfig
290368
+ }, undefined, false, undefined, this)
290369
+ }, undefined, false, undefined, this),
290370
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToastContainer, {}, undefined, false, undefined, this)
290371
+ ]
290372
+ }, undefined, true, undefined, this)
290402
290373
  ]
290403
290374
  }, undefined, true, undefined, this));
290404
290375
  }