@pensar/apex 0.0.40-canary.1cc0d976 → 0.0.40-canary.53f737e9

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 +196 -179
  2. package/package.json +1 -1
package/build/index.js CHANGED
@@ -49440,10 +49440,10 @@ function WebWizard({ initialTarget, autoMode = false }) {
49440
49440
  }
49441
49441
 
49442
49442
  // src/tui/components/session-view/index.tsx
49443
- var import_react36 = __toESM(require_react(), 1);
49443
+ var import_react38 = __toESM(require_react(), 1);
49444
49444
 
49445
49445
  // src/tui/components/swarm-dashboard/index.tsx
49446
- var import_react28 = __toESM(require_react(), 1);
49446
+ var import_react30 = __toESM(require_react(), 1);
49447
49447
 
49448
49448
  // src/tui/components/agent-display.tsx
49449
49449
  var import_react26 = __toESM(require_react(), 1);
@@ -51076,6 +51076,129 @@ function ToolDetails({ message }) {
51076
51076
  }, undefined, true, undefined, this);
51077
51077
  }
51078
51078
 
51079
+ // src/tui/components/dialog.tsx
51080
+ var import_react29 = __toESM(require_react(), 1);
51081
+ function Dialog({ size = "medium", onClose, children }) {
51082
+ const dimensions = useTerminalDimensions();
51083
+ const renderer = useRenderer();
51084
+ return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
51085
+ onMouseUp: async () => {
51086
+ if (renderer.getSelection())
51087
+ return;
51088
+ onClose?.();
51089
+ },
51090
+ width: dimensions.width,
51091
+ height: dimensions.height,
51092
+ alignItems: "center",
51093
+ position: "absolute",
51094
+ paddingTop: dimensions.height / 4,
51095
+ left: 0,
51096
+ top: 0,
51097
+ backgroundColor: RGBA.fromInts(0, 0, 0, 150),
51098
+ children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
51099
+ onMouseUp: async (e) => {
51100
+ if (renderer.getSelection())
51101
+ return;
51102
+ e.stopPropagation();
51103
+ },
51104
+ width: size === "large" ? 80 : 60,
51105
+ maxWidth: dimensions.width - 2,
51106
+ backgroundColor: "black",
51107
+ paddingTop: 1,
51108
+ children
51109
+ }, undefined, false, undefined, this)
51110
+ }, undefined, false, undefined, this);
51111
+ }
51112
+ var DialogContext = import_react29.createContext(null);
51113
+ function DialogProvider({ children }) {
51114
+ const [stack, setStack] = import_react29.useState([]);
51115
+ const [size, setSize] = import_react29.useState("medium");
51116
+ const [externalDialogOpen, setExternalDialogOpen] = import_react29.useState(false);
51117
+ const renderer = useRenderer();
51118
+ const focusRef = import_react29.useRef(null);
51119
+ const refocus = import_react29.useCallback(() => {
51120
+ setTimeout(() => {
51121
+ const focus = focusRef.current;
51122
+ if (!focus)
51123
+ return;
51124
+ if (focus.isDestroyed)
51125
+ return;
51126
+ function find(item) {
51127
+ for (const child of item.getChildren()) {
51128
+ if (child === focus)
51129
+ return true;
51130
+ if (find(child))
51131
+ return true;
51132
+ }
51133
+ return false;
51134
+ }
51135
+ const found = find(renderer.root);
51136
+ if (!found)
51137
+ return;
51138
+ focus.focus();
51139
+ }, 1);
51140
+ }, [renderer]);
51141
+ const clear = import_react29.useCallback(() => {
51142
+ for (const item of stack) {
51143
+ if (item.onClose)
51144
+ item.onClose();
51145
+ }
51146
+ setSize("medium");
51147
+ setStack([]);
51148
+ refocus();
51149
+ }, [stack, refocus]);
51150
+ const replace = import_react29.useCallback((element, onClose) => {
51151
+ if (stack.length === 0) {
51152
+ focusRef.current = renderer.currentFocusedRenderable;
51153
+ }
51154
+ for (const item of stack) {
51155
+ if (item.onClose)
51156
+ item.onClose();
51157
+ }
51158
+ setSize("medium");
51159
+ setStack([{ element, onClose }]);
51160
+ }, [stack, renderer]);
51161
+ useKeyboard((evt) => {
51162
+ if (evt.name === "escape" && stack.length > 0) {
51163
+ const current = stack[stack.length - 1];
51164
+ current?.onClose?.();
51165
+ setStack(stack.slice(0, -1));
51166
+ evt.preventDefault();
51167
+ refocus();
51168
+ }
51169
+ });
51170
+ const value = {
51171
+ clear,
51172
+ replace,
51173
+ stack,
51174
+ size,
51175
+ setSize,
51176
+ externalDialogOpen,
51177
+ setExternalDialogOpen
51178
+ };
51179
+ return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(DialogContext.Provider, {
51180
+ value,
51181
+ children: [
51182
+ children,
51183
+ /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
51184
+ position: "absolute",
51185
+ children: stack.length > 0 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(Dialog, {
51186
+ onClose: clear,
51187
+ size,
51188
+ children: stack[stack.length - 1].element
51189
+ }, undefined, false, undefined, this)
51190
+ }, undefined, false, undefined, this)
51191
+ ]
51192
+ }, undefined, true, undefined, this);
51193
+ }
51194
+ function useDialog() {
51195
+ const value = import_react29.useContext(DialogContext);
51196
+ if (!value) {
51197
+ throw new Error("useDialog must be used within a DialogProvider");
51198
+ }
51199
+ return value;
51200
+ }
51201
+
51079
51202
  // src/tui/components/swarm-dashboard/index.tsx
51080
51203
  var greenBullet2 = RGBA.fromInts(76, 175, 80, 255);
51081
51204
  var creamText2 = RGBA.fromInts(255, 248, 220, 255);
@@ -51090,13 +51213,14 @@ function SwarmDashboard({
51090
51213
  onBack,
51091
51214
  onViewReport
51092
51215
  }) {
51093
- const [currentView, setCurrentView] = import_react28.useState("overview");
51094
- const [selectedAgentId, setSelectedAgentId] = import_react28.useState(null);
51095
- const [focusedIndex, setFocusedIndex] = import_react28.useState(0);
51096
- const [showDiscoveryLogs, setShowDiscoveryLogs] = import_react28.useState(false);
51097
- const discoveryAgent = import_react28.useMemo(() => subagents.find((s) => s.type === "attack-surface") || null, [subagents]);
51098
- const pentestAgents = import_react28.useMemo(() => subagents.filter((s) => s.type === "pentest"), [subagents]);
51099
- const metrics = import_react28.useMemo(() => {
51216
+ const [currentView, setCurrentView] = import_react30.useState("overview");
51217
+ const [selectedAgentId, setSelectedAgentId] = import_react30.useState(null);
51218
+ const [focusedIndex, setFocusedIndex] = import_react30.useState(0);
51219
+ const [showDiscoveryLogs, setShowDiscoveryLogs] = import_react30.useState(false);
51220
+ const { stack, externalDialogOpen } = useDialog();
51221
+ const discoveryAgent = import_react30.useMemo(() => subagents.find((s) => s.type === "attack-surface") || null, [subagents]);
51222
+ const pentestAgents = import_react30.useMemo(() => subagents.filter((s) => s.type === "pentest"), [subagents]);
51223
+ const metrics = import_react30.useMemo(() => {
51100
51224
  const findingsCount = subagents.reduce((sum, s) => {
51101
51225
  return sum + s.messages.filter((m2) => m2.role === "assistant" && typeof m2.content === "string" && (m2.content.includes("finding") || m2.content.includes("vulnerability"))).length;
51102
51226
  }, 0);
@@ -51108,8 +51232,10 @@ function SwarmDashboard({
51108
51232
  duration: startTime ? Math.floor((Date.now() - startTime.getTime()) / 1000) : 0
51109
51233
  };
51110
51234
  }, [subagents, pentestAgents.length, startTime]);
51111
- const selectedAgent = import_react28.useMemo(() => selectedAgentId ? subagents.find((s) => s.id === selectedAgentId) : null, [subagents, selectedAgentId]);
51235
+ const selectedAgent = import_react30.useMemo(() => selectedAgentId ? subagents.find((s) => s.id === selectedAgentId) : null, [subagents, selectedAgentId]);
51112
51236
  useKeyboard((key) => {
51237
+ if (stack.length > 0 || externalDialogOpen)
51238
+ return;
51113
51239
  if (currentView === "overview") {
51114
51240
  if (key.name === "d" || key.name === "D") {
51115
51241
  setShowDiscoveryLogs((prev) => !prev);
@@ -51299,7 +51425,7 @@ function DiscoveryPanel({
51299
51425
  showLogs,
51300
51426
  onToggleLogs
51301
51427
  }) {
51302
- const endpoints = import_react28.useMemo(() => {
51428
+ const endpoints = import_react30.useMemo(() => {
51303
51429
  if (!agent)
51304
51430
  return [];
51305
51431
  const endpointSet = new Set;
@@ -51524,7 +51650,7 @@ function AgentCard({ agent, focused, onSelect }) {
51524
51650
  completed: greenBullet2,
51525
51651
  failed: RGBA.fromInts(244, 67, 54, 255)
51526
51652
  }[agent.status];
51527
- const lastActivity = import_react28.useMemo(() => {
51653
+ const lastActivity = import_react30.useMemo(() => {
51528
51654
  const lastMsg = agent.messages[agent.messages.length - 1];
51529
51655
  if (!lastMsg)
51530
51656
  return "Starting...";
@@ -51541,7 +51667,7 @@ function AgentCard({ agent, focused, onSelect }) {
51541
51667
  }
51542
51668
  return text;
51543
51669
  }, [agent.messages]);
51544
- const stats = import_react28.useMemo(() => {
51670
+ const stats = import_react30.useMemo(() => {
51545
51671
  const toolCalls = agent.messages.filter((m2) => m2.role === "tool").length;
51546
51672
  return { toolCalls };
51547
51673
  }, [agent.messages]);
@@ -51623,7 +51749,7 @@ function AgentCardGrid({
51623
51749
  focusedIndex,
51624
51750
  onSelectAgent
51625
51751
  }) {
51626
- const rows = import_react28.useMemo(() => {
51752
+ const rows = import_react30.useMemo(() => {
51627
51753
  const result = [];
51628
51754
  for (let i = 0;i < agents.length; i += 2) {
51629
51755
  result.push(agents.slice(i, i + 2));
@@ -51666,7 +51792,7 @@ function MetricsBar({
51666
51792
  duration: duration3,
51667
51793
  isExecuting
51668
51794
  }) {
51669
- const formattedDuration = import_react28.useMemo(() => {
51795
+ const formattedDuration = import_react30.useMemo(() => {
51670
51796
  const mins = Math.floor(duration3 / 60);
51671
51797
  const secs = duration3 % 60;
51672
51798
  return `${mins}m ${secs.toString().padStart(2, "0")}s`;
@@ -51901,7 +52027,7 @@ function AgentDetailView({ agent, onBack }) {
51901
52027
  }
51902
52028
 
51903
52029
  // src/tui/components/driver-dashboard/index.tsx
51904
- var import_react34 = __toESM(require_react(), 1);
52030
+ var import_react36 = __toESM(require_react(), 1);
51905
52031
  import { existsSync as existsSync12, readFileSync as readFileSync7 } from "fs";
51906
52032
  import { join as join7 } from "path";
51907
52033
 
@@ -85084,10 +85210,10 @@ function EndpointItem({
85084
85210
  }
85085
85211
 
85086
85212
  // src/tui/components/driver-dashboard/agent-chat-view.tsx
85087
- var import_react32 = __toESM(require_react(), 1);
85213
+ var import_react34 = __toESM(require_react(), 1);
85088
85214
 
85089
85215
  // src/tui/components/driver-dashboard/mention-autocomplete.tsx
85090
- var import_react30 = __toESM(require_react(), 1);
85216
+ var import_react32 = __toESM(require_react(), 1);
85091
85217
  var greenBullet4 = RGBA.fromInts(76, 175, 80, 255);
85092
85218
  var creamText4 = RGBA.fromInts(255, 248, 220, 255);
85093
85219
  var dimText4 = RGBA.fromInts(120, 120, 120, 255);
@@ -85098,14 +85224,14 @@ function MentionAutocomplete({
85098
85224
  onSelect,
85099
85225
  onClose
85100
85226
  }) {
85101
- const [selectedIndex, setSelectedIndex] = import_react30.useState(0);
85102
- const filteredEndpoints = import_react30.useMemo(() => {
85227
+ const [selectedIndex, setSelectedIndex] = import_react32.useState(0);
85228
+ const filteredEndpoints = import_react32.useMemo(() => {
85103
85229
  if (!query)
85104
85230
  return endpoints.slice(0, 5);
85105
85231
  const lowerQuery = query.toLowerCase();
85106
85232
  return endpoints.filter((e) => e.id.toLowerCase().includes(lowerQuery) || e.url.toLowerCase().includes(lowerQuery) || e.suggestedObjective.toLowerCase().includes(lowerQuery)).slice(0, 5);
85107
85233
  }, [endpoints, query]);
85108
- import_react30.useEffect(() => {
85234
+ import_react32.useEffect(() => {
85109
85235
  setSelectedIndex(0);
85110
85236
  }, [filteredEndpoints.length]);
85111
85237
  useKeyboard((key) => {
@@ -85201,9 +85327,9 @@ function AgentChatView({
85201
85327
  onBack,
85202
85328
  onStop
85203
85329
  }) {
85204
- const [inputValue, setInputValue] = import_react32.useState("");
85205
- const [showMentions, setShowMentions] = import_react32.useState(false);
85206
- const [mentionQuery, setMentionQuery] = import_react32.useState("");
85330
+ const [inputValue, setInputValue] = import_react34.useState("");
85331
+ const [showMentions, setShowMentions] = import_react34.useState(false);
85332
+ const [mentionQuery, setMentionQuery] = import_react34.useState("");
85207
85333
  const statusIcon = {
85208
85334
  running: "◐",
85209
85335
  paused: "◑",
@@ -85216,7 +85342,7 @@ function AgentChatView({
85216
85342
  completed: greenBullet5,
85217
85343
  failed: RGBA.fromInts(244, 67, 54, 255)
85218
85344
  }[agent2.status];
85219
- const handleInput = import_react32.useCallback((value) => {
85345
+ const handleInput = import_react34.useCallback((value) => {
85220
85346
  setInputValue(value);
85221
85347
  const lastAtIndex = value.lastIndexOf("@");
85222
85348
  if (lastAtIndex !== -1 && lastAtIndex === value.length - 1) {
@@ -85234,13 +85360,13 @@ function AgentChatView({
85234
85360
  setShowMentions(false);
85235
85361
  }
85236
85362
  }, []);
85237
- const handleMentionSelect = import_react32.useCallback((endpoint) => {
85363
+ const handleMentionSelect = import_react34.useCallback((endpoint) => {
85238
85364
  const lastAtIndex = inputValue.lastIndexOf("@");
85239
85365
  const newValue = inputValue.substring(0, lastAtIndex) + endpoint.url + " ";
85240
85366
  setInputValue(newValue);
85241
85367
  setShowMentions(false);
85242
85368
  }, [inputValue]);
85243
- const handleSend = import_react32.useCallback(() => {
85369
+ const handleSend = import_react34.useCallback(() => {
85244
85370
  if (inputValue.trim()) {
85245
85371
  onSendMessage(inputValue.trim());
85246
85372
  setInputValue("");
@@ -85379,28 +85505,29 @@ var darkBg3 = RGBA.fromInts(10, 10, 10, 255);
85379
85505
  function DriverDashboard({ session }) {
85380
85506
  const route = useRoute();
85381
85507
  const { model } = useAgent();
85382
- const [currentView, setCurrentView] = import_react34.useState("overview");
85383
- const [agents, setAgents] = import_react34.useState([]);
85384
- const [endpoints, setEndpoints] = import_react34.useState([]);
85385
- const [reconStatus, setReconStatus] = import_react34.useState("idle");
85386
- const [reconMessages, setReconMessages] = import_react34.useState([]);
85387
- const [focusedArea, setFocusedArea] = import_react34.useState("agents");
85388
- const [focusedAgentIndex, setFocusedAgentIndex] = import_react34.useState(0);
85389
- const [focusedEndpointIndex, setFocusedEndpointIndex] = import_react34.useState(0);
85390
- const [activeAgentId, setActiveAgentId] = import_react34.useState(null);
85391
- const [showNewAgentInput, setShowNewAgentInput] = import_react34.useState(false);
85392
- const [newAgentInput, setNewAgentInput] = import_react34.useState("");
85393
- const [startTime] = import_react34.useState(() => new Date);
85394
- const [showMentions, setShowMentions] = import_react34.useState(false);
85395
- const [mentionQuery, setMentionQuery] = import_react34.useState("");
85396
- const [loading, setLoading] = import_react34.useState(false);
85397
- const activeAgent = import_react34.useMemo(() => agents.find((a) => a.id === activeAgentId) || null, [agents, activeAgentId]);
85398
- import_react34.useEffect(() => {
85508
+ const { stack, externalDialogOpen } = useDialog();
85509
+ const [currentView, setCurrentView] = import_react36.useState("overview");
85510
+ const [agents, setAgents] = import_react36.useState([]);
85511
+ const [endpoints, setEndpoints] = import_react36.useState([]);
85512
+ const [reconStatus, setReconStatus] = import_react36.useState("idle");
85513
+ const [reconMessages, setReconMessages] = import_react36.useState([]);
85514
+ const [focusedArea, setFocusedArea] = import_react36.useState("agents");
85515
+ const [focusedAgentIndex, setFocusedAgentIndex] = import_react36.useState(0);
85516
+ const [focusedEndpointIndex, setFocusedEndpointIndex] = import_react36.useState(0);
85517
+ const [activeAgentId, setActiveAgentId] = import_react36.useState(null);
85518
+ const [showNewAgentInput, setShowNewAgentInput] = import_react36.useState(false);
85519
+ const [newAgentInput, setNewAgentInput] = import_react36.useState("");
85520
+ const [startTime] = import_react36.useState(() => new Date);
85521
+ const [showMentions, setShowMentions] = import_react36.useState(false);
85522
+ const [mentionQuery, setMentionQuery] = import_react36.useState("");
85523
+ const [loading, setLoading] = import_react36.useState(false);
85524
+ const activeAgent = import_react36.useMemo(() => agents.find((a) => a.id === activeAgentId) || null, [agents, activeAgentId]);
85525
+ import_react36.useEffect(() => {
85399
85526
  if (reconStatus === "idle") {
85400
85527
  startRecon();
85401
85528
  }
85402
85529
  }, []);
85403
- const handleInput = import_react34.useCallback((value) => {
85530
+ const handleInput = import_react36.useCallback((value) => {
85404
85531
  if (loading) {
85405
85532
  return;
85406
85533
  }
@@ -85421,13 +85548,13 @@ function DriverDashboard({ session }) {
85421
85548
  setShowMentions(false);
85422
85549
  }
85423
85550
  }, []);
85424
- const handleMentionSelect = import_react34.useCallback((endpoint) => {
85551
+ const handleMentionSelect = import_react36.useCallback((endpoint) => {
85425
85552
  const lastAtIndex = newAgentInput.lastIndexOf("@");
85426
85553
  const newValue = newAgentInput.substring(0, lastAtIndex) + endpoint.url + " ";
85427
85554
  setNewAgentInput(newValue);
85428
85555
  setShowMentions(false);
85429
85556
  }, [newAgentInput]);
85430
- const startRecon = import_react34.useCallback(async () => {
85557
+ const startRecon = import_react36.useCallback(async () => {
85431
85558
  setReconStatus("running");
85432
85559
  setReconMessages([{
85433
85560
  role: "user",
@@ -85516,7 +85643,7 @@ function DriverDashboard({ session }) {
85516
85643
  setReconStatus("completed");
85517
85644
  }
85518
85645
  }, [session, model.id]);
85519
- const spawnAgent = import_react34.useCallback(async (target) => {
85646
+ const spawnAgent = import_react36.useCallback(async (target) => {
85520
85647
  const agentId = `agent-${Date.now()}`;
85521
85648
  const agentName = `Agent ${agents.length + 1}`;
85522
85649
  const driverAgent = createDriverModeAgent({
@@ -85550,7 +85677,7 @@ function DriverDashboard({ session }) {
85550
85677
  setCurrentView("agent-chat");
85551
85678
  driverAgent.start(target).catch(console.error);
85552
85679
  }, [agents.length, session, model.id]);
85553
- const spawnAgentFromEndpoint = import_react34.useCallback(async (endpoint) => {
85680
+ const spawnAgentFromEndpoint = import_react36.useCallback(async (endpoint) => {
85554
85681
  const target = {
85555
85682
  target: endpoint.url,
85556
85683
  objective: endpoint.suggestedObjective,
@@ -85558,7 +85685,7 @@ function DriverDashboard({ session }) {
85558
85685
  };
85559
85686
  await spawnAgent(target);
85560
85687
  }, [spawnAgent]);
85561
- const handleCreateNewAgent = import_react34.useCallback(async () => {
85688
+ const handleCreateNewAgent = import_react36.useCallback(async () => {
85562
85689
  if (!newAgentInput.trim()) {
85563
85690
  setShowNewAgentInput(false);
85564
85691
  return;
@@ -85582,6 +85709,8 @@ function DriverDashboard({ session }) {
85582
85709
  setLoading(false);
85583
85710
  }, [newAgentInput, endpoints, model.id, spawnAgent]);
85584
85711
  useKeyboard((key) => {
85712
+ if (stack.length > 0 || externalDialogOpen)
85713
+ return;
85585
85714
  if (currentView === "agent-chat") {
85586
85715
  if (key.shift && key.name === "/") {
85587
85716
  setCurrentView("overview");
@@ -85676,7 +85805,7 @@ function DriverDashboard({ session }) {
85676
85805
  }
85677
85806
  }
85678
85807
  });
85679
- const metrics = import_react34.useMemo(() => ({
85808
+ const metrics = import_react36.useMemo(() => ({
85680
85809
  totalAgents: agents.length,
85681
85810
  activeAgents: agents.filter((a) => a.status === "running").length,
85682
85811
  completedAgents: agents.filter((a) => a.status === "completed").length,
@@ -87414,15 +87543,15 @@ function SessionView({
87414
87543
  }) {
87415
87544
  const route = useRoute();
87416
87545
  const { model, setThinking, isExecuting, addTokenUsage, setIsExecuting } = useAgent();
87417
- const [session, setSession] = import_react36.useState(null);
87418
- const [loading, setLoading] = import_react36.useState(true);
87419
- const [error46, setError] = import_react36.useState(null);
87420
- const [subagents, setSubagents] = import_react36.useState([]);
87421
- const [isCompleted, setIsCompleted] = import_react36.useState(false);
87422
- const [abortController, setAbortController] = import_react36.useState(null);
87423
- const [startTime, setStartTime] = import_react36.useState(null);
87424
- const [hasStarted, setHasStarted] = import_react36.useState(false);
87425
- import_react36.useEffect(() => {
87546
+ const [session, setSession] = import_react38.useState(null);
87547
+ const [loading, setLoading] = import_react38.useState(true);
87548
+ const [error46, setError] = import_react38.useState(null);
87549
+ const [subagents, setSubagents] = import_react38.useState([]);
87550
+ const [isCompleted, setIsCompleted] = import_react38.useState(false);
87551
+ const [abortController, setAbortController] = import_react38.useState(null);
87552
+ const [startTime, setStartTime] = import_react38.useState(null);
87553
+ const [hasStarted, setHasStarted] = import_react38.useState(false);
87554
+ import_react38.useEffect(() => {
87426
87555
  async function loadSession() {
87427
87556
  try {
87428
87557
  const loadedSession = await Session.get(sessionId);
@@ -87460,13 +87589,13 @@ function SessionView({
87460
87589
  }
87461
87590
  loadSession();
87462
87591
  }, [sessionId, isResume]);
87463
- import_react36.useEffect(() => {
87592
+ import_react38.useEffect(() => {
87464
87593
  if (session && !hasStarted && !loading && !isResume) {
87465
87594
  setHasStarted(true);
87466
87595
  startPentest(session);
87467
87596
  }
87468
87597
  }, [session, hasStarted, loading, isResume]);
87469
- const startPentest = import_react36.useCallback(async (execSession) => {
87598
+ const startPentest = import_react38.useCallback(async (execSession) => {
87470
87599
  setIsExecuting(true);
87471
87600
  setThinking(true);
87472
87601
  setStartTime(new Date);
@@ -87706,7 +87835,7 @@ function SessionView({
87706
87835
  }
87707
87836
  }
87708
87837
  }, [model.id, addTokenUsage, setThinking, setIsExecuting]);
87709
- const openReport = import_react36.useCallback(() => {
87838
+ const openReport = import_react38.useCallback(() => {
87710
87839
  if (session?.rootPath) {
87711
87840
  const reportPath = `${session.rootPath}/comprehensive-pentest-report.md`;
87712
87841
  if (existsSync17(reportPath)) {
@@ -87716,7 +87845,7 @@ function SessionView({
87716
87845
  }
87717
87846
  }
87718
87847
  }, [session?.rootPath]);
87719
- const handleBack = import_react36.useCallback(() => {
87848
+ const handleBack = import_react38.useCallback(() => {
87720
87849
  route.navigate({ type: "base", path: "home" });
87721
87850
  }, [isExecuting, abortController, route]);
87722
87851
  if (loading) {
@@ -87778,121 +87907,6 @@ function SessionView({
87778
87907
  var import_react39 = __toESM(require_react(), 1);
87779
87908
  import { exec as exec4 } from "child_process";
87780
87909
  import { existsSync as existsSync18 } from "fs";
87781
-
87782
- // src/tui/components/dialog.tsx
87783
- var import_react38 = __toESM(require_react(), 1);
87784
- function Dialog({ size = "medium", onClose, children }) {
87785
- const dimensions = useTerminalDimensions();
87786
- const renderer = useRenderer();
87787
- return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
87788
- onMouseUp: async () => {
87789
- if (renderer.getSelection())
87790
- return;
87791
- onClose?.();
87792
- },
87793
- width: dimensions.width,
87794
- height: dimensions.height,
87795
- alignItems: "center",
87796
- position: "absolute",
87797
- paddingTop: dimensions.height / 4,
87798
- left: 0,
87799
- top: 0,
87800
- backgroundColor: RGBA.fromInts(0, 0, 0, 150),
87801
- children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
87802
- onMouseUp: async (e) => {
87803
- if (renderer.getSelection())
87804
- return;
87805
- e.stopPropagation();
87806
- },
87807
- width: size === "large" ? 80 : 60,
87808
- maxWidth: dimensions.width - 2,
87809
- backgroundColor: "black",
87810
- paddingTop: 1,
87811
- children
87812
- }, undefined, false, undefined, this)
87813
- }, undefined, false, undefined, this);
87814
- }
87815
- var DialogContext = import_react38.createContext(null);
87816
- function DialogProvider({ children }) {
87817
- const [stack, setStack] = import_react38.useState([]);
87818
- const [size, setSize] = import_react38.useState("medium");
87819
- const renderer = useRenderer();
87820
- const focusRef = import_react38.useRef(null);
87821
- const refocus = import_react38.useCallback(() => {
87822
- setTimeout(() => {
87823
- const focus = focusRef.current;
87824
- if (!focus)
87825
- return;
87826
- if (focus.isDestroyed)
87827
- return;
87828
- function find(item) {
87829
- for (const child of item.getChildren()) {
87830
- if (child === focus)
87831
- return true;
87832
- if (find(child))
87833
- return true;
87834
- }
87835
- return false;
87836
- }
87837
- const found = find(renderer.root);
87838
- if (!found)
87839
- return;
87840
- focus.focus();
87841
- }, 1);
87842
- }, [renderer]);
87843
- const clear = import_react38.useCallback(() => {
87844
- for (const item of stack) {
87845
- if (item.onClose)
87846
- item.onClose();
87847
- }
87848
- setSize("medium");
87849
- setStack([]);
87850
- refocus();
87851
- }, [stack, refocus]);
87852
- const replace = import_react38.useCallback((element, onClose) => {
87853
- if (stack.length === 0) {
87854
- focusRef.current = renderer.currentFocusedRenderable;
87855
- }
87856
- for (const item of stack) {
87857
- if (item.onClose)
87858
- item.onClose();
87859
- }
87860
- setSize("medium");
87861
- setStack([{ element, onClose }]);
87862
- }, [stack, renderer]);
87863
- useKeyboard((evt) => {
87864
- if (evt.name === "escape" && stack.length > 0) {
87865
- const current = stack[stack.length - 1];
87866
- current?.onClose?.();
87867
- setStack(stack.slice(0, -1));
87868
- evt.preventDefault();
87869
- refocus();
87870
- }
87871
- });
87872
- const value = {
87873
- clear,
87874
- replace,
87875
- stack,
87876
- size,
87877
- setSize
87878
- };
87879
- return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(DialogContext.Provider, {
87880
- value,
87881
- children: [
87882
- children,
87883
- /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
87884
- position: "absolute",
87885
- children: stack.length > 0 && /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(Dialog, {
87886
- onClose: clear,
87887
- size,
87888
- children: stack[stack.length - 1].element
87889
- }, undefined, false, undefined, this)
87890
- }, undefined, false, undefined, this)
87891
- ]
87892
- }, undefined, true, undefined, this);
87893
- }
87894
-
87895
- // src/tui/components/commands/sessions-display.tsx
87896
87910
  function SessionsDisplay({ onClose }) {
87897
87911
  const { refocusCommandInput } = useFocus();
87898
87912
  const [sessions, setSessions] = import_react39.useState([]);
@@ -89310,6 +89324,7 @@ function AppContent({
89310
89324
  const renderer = useRenderer();
89311
89325
  const { isInputEmpty } = useInput();
89312
89326
  const { refocusCommandInput } = useFocus();
89327
+ const { setExternalDialogOpen } = useDialog();
89313
89328
  const [showCreateSessionDialog, setShowCreateSessionDialog] = import_react53.useState(false);
89314
89329
  const [showSessionsDialog, setShowSessionsDialog] = import_react53.useState(false);
89315
89330
  const [showShortcutsDialog, setShowShortcutsDialog] = import_react53.useState(false);
@@ -89368,6 +89383,7 @@ function AppContent({
89368
89383
  return;
89369
89384
  }
89370
89385
  if (key.sequence === "?" && isInputEmpty) {
89386
+ setExternalDialogOpen(true);
89371
89387
  setShowShortcutsDialog(true);
89372
89388
  return;
89373
89389
  }
@@ -89404,6 +89420,7 @@ function AppContent({
89404
89420
  };
89405
89421
  const handleCloseShortcutsDialog = () => {
89406
89422
  setShowShortcutsDialog(false);
89423
+ setExternalDialogOpen(false);
89407
89424
  setInputKey((prev) => prev + 1);
89408
89425
  refocusCommandInput();
89409
89426
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pensar/apex",
3
- "version": "0.0.40-canary.1cc0d976",
3
+ "version": "0.0.40-canary.53f737e9",
4
4
  "description": "AI-powered penetration testing CLI tool with terminal UI",
5
5
  "module": "src/tui/index.tsx",
6
6
  "main": "build/index.js",