@pensar/apex 0.0.88 → 0.0.89-canary.578f40bc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.js +242 -58
- 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.
|
|
31974
|
+
version: "0.0.89-canary.578f40bc",
|
|
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",
|
|
@@ -88441,7 +88441,8 @@ async function summarizeConversation(messages, opts, model) {
|
|
|
88441
88441
|
const { text: summary, usage: summaryUsage } = await generateText({
|
|
88442
88442
|
model,
|
|
88443
88443
|
system: `You are a helpful assistant that summarizes conversations to pass to another agent. Review the conversation and system prompt at the end provided by the user.`,
|
|
88444
|
-
messages: summarizedMessages
|
|
88444
|
+
messages: summarizedMessages,
|
|
88445
|
+
abortSignal: opts.abortSignal
|
|
88445
88446
|
});
|
|
88446
88447
|
if (opts.onStepFinish && summaryUsage) {
|
|
88447
88448
|
opts.onStepFinish({
|
|
@@ -88719,7 +88720,8 @@ function streamResponse(opts) {
|
|
|
88719
88720
|
"IMPORTANT: For enum fields like 'severity' or 'riskLevel', use ONLY the exact values from the enum (e.g., 'HIGH', 'CRITICAL', 'MEDIUM', 'LOW').",
|
|
88720
88721
|
"Do not add prefixes, suffixes, or formatting characters like '>', '-', '!', etc."
|
|
88721
88722
|
].join(`
|
|
88722
|
-
`)
|
|
88723
|
+
`),
|
|
88724
|
+
abortSignal
|
|
88723
88725
|
});
|
|
88724
88726
|
if (onStepFinish && repairUsage) {
|
|
88725
88727
|
onStepFinish({
|
|
@@ -88787,6 +88789,7 @@ async function generateObjectResponse(opts) {
|
|
|
88787
88789
|
maxTokens,
|
|
88788
88790
|
temperature,
|
|
88789
88791
|
authConfig,
|
|
88792
|
+
abortSignal,
|
|
88790
88793
|
onTokenUsage
|
|
88791
88794
|
} = opts;
|
|
88792
88795
|
const providerModel = getProviderModel(model, authConfig);
|
|
@@ -88802,7 +88805,8 @@ async function generateObjectResponse(opts) {
|
|
|
88802
88805
|
system,
|
|
88803
88806
|
maxOutputTokens: maxTokens,
|
|
88804
88807
|
temperature,
|
|
88805
|
-
maxRetries: 0
|
|
88808
|
+
maxRetries: 0,
|
|
88809
|
+
abortSignal
|
|
88806
88810
|
});
|
|
88807
88811
|
if (onTokenUsage && usage) {
|
|
88808
88812
|
onTokenUsage(usage.inputTokens ?? 0, usage.outputTokens ?? 0);
|
|
@@ -88849,7 +88853,7 @@ function generateRandomName() {
|
|
|
88849
88853
|
return `${adj}-${noun}`;
|
|
88850
88854
|
}
|
|
88851
88855
|
async function generateSessionName(opts) {
|
|
88852
|
-
const { targets, userMessage, model, authConfig } = opts;
|
|
88856
|
+
const { targets, userMessage, model, authConfig, abortSignal } = opts;
|
|
88853
88857
|
const contextParts = [];
|
|
88854
88858
|
if (targets.length > 0) {
|
|
88855
88859
|
contextParts.push(`Target(s): ${targets.join(", ")}`);
|
|
@@ -88874,7 +88878,8 @@ async function generateSessionName(opts) {
|
|
|
88874
88878
|
prompt,
|
|
88875
88879
|
maxTokens: 50,
|
|
88876
88880
|
temperature: 0.7,
|
|
88877
|
-
authConfig
|
|
88881
|
+
authConfig,
|
|
88882
|
+
abortSignal
|
|
88878
88883
|
});
|
|
88879
88884
|
if (!result?.name)
|
|
88880
88885
|
return null;
|
|
@@ -106937,7 +106942,7 @@ IMPORTANT: Always analyze results and adjust your approach based on findings.`,
|
|
|
106937
106942
|
}
|
|
106938
106943
|
if (ctx4.persistentShell) {
|
|
106939
106944
|
try {
|
|
106940
|
-
const result = await ctx4.persistentShell.execute(command, timeout, ctx4.onCommandOutput);
|
|
106945
|
+
const result = await ctx4.persistentShell.execute(command, timeout, ctx4.onCommandOutput, ctx4.abortSignal);
|
|
106941
106946
|
const { text: stdout, file: outputFile } = maybeSaveFullOutput(result.stdout, ctx4);
|
|
106942
106947
|
return {
|
|
106943
106948
|
success: result.exitCode === 0,
|
|
@@ -107845,14 +107850,15 @@ var init_cvss = __esm(() => {
|
|
|
107845
107850
|
});
|
|
107846
107851
|
|
|
107847
107852
|
// src/core/agents/specialized/cvssScorer/index.ts
|
|
107848
|
-
async function scoreFindingWithCVSS(input, model, authConfig) {
|
|
107853
|
+
async function scoreFindingWithCVSS(input, model, authConfig, abortSignal) {
|
|
107849
107854
|
const prompt = buildScoringPrompt(input);
|
|
107850
107855
|
const assessment = await generateObjectResponse({
|
|
107851
107856
|
model,
|
|
107852
107857
|
schema: CVSSMetricsOutputSchema,
|
|
107853
107858
|
prompt,
|
|
107854
107859
|
system: CVSS_SCORER_SYSTEM_PROMPT,
|
|
107855
|
-
authConfig
|
|
107860
|
+
authConfig,
|
|
107861
|
+
abortSignal
|
|
107856
107862
|
});
|
|
107857
107863
|
const cvssResult = calculateCVSS4Score({
|
|
107858
107864
|
...assessment.metrics
|
|
@@ -108120,7 +108126,7 @@ FINDING STRUCTURE:
|
|
|
108120
108126
|
remediation: input.remediation
|
|
108121
108127
|
},
|
|
108122
108128
|
agentMessages: []
|
|
108123
|
-
}, ctx4.model, ctx4.authConfig);
|
|
108129
|
+
}, ctx4.model, ctx4.authConfig, ctx4.abortSignal);
|
|
108124
108130
|
} catch (cvssError) {
|
|
108125
108131
|
const msg = cvssError instanceof Error ? cvssError.message : String(cvssError);
|
|
108126
108132
|
cvssWarning = `CVSS scoring failed (${msg}), using fallback severity.`;
|
|
@@ -111302,10 +111308,12 @@ class FindingsRegistry {
|
|
|
111302
111308
|
findings = [];
|
|
111303
111309
|
model;
|
|
111304
111310
|
authConfig;
|
|
111311
|
+
abortSignal;
|
|
111305
111312
|
mutex = Promise.resolve();
|
|
111306
111313
|
constructor(opts) {
|
|
111307
111314
|
this.model = opts?.model;
|
|
111308
111315
|
this.authConfig = opts?.authConfig;
|
|
111316
|
+
this.abortSignal = opts?.abortSignal;
|
|
111309
111317
|
}
|
|
111310
111318
|
get size() {
|
|
111311
111319
|
return this.findings.length;
|
|
@@ -111402,7 +111410,8 @@ class FindingsRegistry {
|
|
|
111402
111410
|
schema: SemanticDedupResultSchema,
|
|
111403
111411
|
prompt,
|
|
111404
111412
|
system: SEMANTIC_DEDUP_SYSTEM,
|
|
111405
|
-
authConfig: this.authConfig
|
|
111413
|
+
authConfig: this.authConfig,
|
|
111414
|
+
abortSignal: this.abortSignal
|
|
111406
111415
|
});
|
|
111407
111416
|
if (result.isDuplicate && result.matchedIndex != null) {
|
|
111408
111417
|
const idx = result.matchedIndex - 1;
|
|
@@ -111526,7 +111535,8 @@ Pass every target you want tested — the swarm handles concurrency automaticall
|
|
|
111526
111535
|
}
|
|
111527
111536
|
const findingsRegistry = ctx4.findingsRegistry ?? FindingsRegistry.fromDirectory(ctx4.session.findingsPath, {
|
|
111528
111537
|
model: ctx4.model,
|
|
111529
|
-
authConfig: ctx4.authConfig
|
|
111538
|
+
authConfig: ctx4.authConfig,
|
|
111539
|
+
abortSignal: ctx4.abortSignal
|
|
111530
111540
|
});
|
|
111531
111541
|
const total = targets.length;
|
|
111532
111542
|
console.log(`
|
|
@@ -193567,10 +193577,17 @@ class PersistentShell {
|
|
|
193567
193577
|
this.spawn();
|
|
193568
193578
|
}
|
|
193569
193579
|
}
|
|
193570
|
-
async execute(command, timeoutSeconds, onData) {
|
|
193580
|
+
async execute(command, timeoutSeconds, onData, abortSignal) {
|
|
193571
193581
|
if (this.disposed) {
|
|
193572
193582
|
return { stdout: "", stderr: "Shell has been disposed", exitCode: 1 };
|
|
193573
193583
|
}
|
|
193584
|
+
if (abortSignal?.aborted) {
|
|
193585
|
+
return {
|
|
193586
|
+
stdout: "",
|
|
193587
|
+
stderr: "Command aborted",
|
|
193588
|
+
exitCode: 130
|
|
193589
|
+
};
|
|
193590
|
+
}
|
|
193574
193591
|
this.ensureAlive();
|
|
193575
193592
|
const proc = this.proc;
|
|
193576
193593
|
if (!proc || !proc.stdin || !proc.stdout || !proc.stderr) {
|
|
@@ -193595,11 +193612,38 @@ class PersistentShell {
|
|
|
193595
193612
|
this.pendingStderr = null;
|
|
193596
193613
|
if (timeoutTimer)
|
|
193597
193614
|
clearTimeout(timeoutTimer);
|
|
193615
|
+
if (abortCleanup)
|
|
193616
|
+
abortCleanup();
|
|
193598
193617
|
proc.stdout.removeListener("data", onStdout);
|
|
193599
193618
|
proc.stderr.removeListener("data", onStderr);
|
|
193600
193619
|
resolve4(result);
|
|
193601
193620
|
};
|
|
193602
193621
|
this.pendingCancel = safeResolve;
|
|
193622
|
+
let abortCleanup;
|
|
193623
|
+
if (abortSignal) {
|
|
193624
|
+
const onAbort = () => {
|
|
193625
|
+
if (resolved)
|
|
193626
|
+
return;
|
|
193627
|
+
const pid = proc.pid;
|
|
193628
|
+
if (pid && process.platform !== "win32") {
|
|
193629
|
+
try {
|
|
193630
|
+
spawnSync("pkill", ["-TERM", "-P", pid.toString()], {
|
|
193631
|
+
stdio: "ignore"
|
|
193632
|
+
});
|
|
193633
|
+
} catch {}
|
|
193634
|
+
}
|
|
193635
|
+
setTimeout(() => {
|
|
193636
|
+
safeResolve({
|
|
193637
|
+
stdout: stdout || "(no output)",
|
|
193638
|
+
stderr: stderr ? stderr + `
|
|
193639
|
+
(aborted)` : "(aborted)",
|
|
193640
|
+
exitCode: 130
|
|
193641
|
+
});
|
|
193642
|
+
}, 500);
|
|
193643
|
+
};
|
|
193644
|
+
abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
193645
|
+
abortCleanup = () => abortSignal.removeEventListener("abort", onAbort);
|
|
193646
|
+
}
|
|
193603
193647
|
const onStdout = (data) => {
|
|
193604
193648
|
const chunk = data.toString();
|
|
193605
193649
|
if (onData && !chunk.includes(exitMarkerPrefix)) {
|
|
@@ -194504,6 +194548,35 @@ For \`http_request\`, pass these as the \`headers\` parameter.`, `For \`execute_
|
|
|
194504
194548
|
The following vulnerabilities have already been documented. Do NOT re-test or re-document these — the system will automatically reject duplicates.
|
|
194505
194549
|
${existing}`;
|
|
194506
194550
|
}
|
|
194551
|
+
let knowledgeBaseSection = "";
|
|
194552
|
+
const markerPath = join24(sessionRootPath, "scratchpad", ".knowledge-populated");
|
|
194553
|
+
if (existsSync23(markerPath)) {
|
|
194554
|
+
try {
|
|
194555
|
+
const count = parseInt(readFileSync9(markerPath, "utf-8").trim(), 10) || 0;
|
|
194556
|
+
if (count > 0) {
|
|
194557
|
+
knowledgeBaseSection = `
|
|
194558
|
+
|
|
194559
|
+
## Project Knowledge Available
|
|
194560
|
+
There are ${count} project knowledge entries in the memory system from previous scans, user notes, and resolved issues. Before beginning your testing plan, call \`list_memories\` with tag \`"project-knowledge"\` to check for relevant context. Pay special attention to false positive patterns and technology context that may affect your testing.`;
|
|
194561
|
+
}
|
|
194562
|
+
} catch {}
|
|
194563
|
+
}
|
|
194564
|
+
if (!knowledgeBaseSection) {
|
|
194565
|
+
const knowledgePath = join24(sessionRootPath, "scratchpad", "knowledge-base.md");
|
|
194566
|
+
if (existsSync23(knowledgePath)) {
|
|
194567
|
+
try {
|
|
194568
|
+
const knowledgeContent = readFileSync9(knowledgePath, "utf-8").trim();
|
|
194569
|
+
if (knowledgeContent) {
|
|
194570
|
+
knowledgeBaseSection = `
|
|
194571
|
+
|
|
194572
|
+
## Project Knowledge Base
|
|
194573
|
+
The following is accumulated knowledge about this project from previous scans, user notes, and resolved issues. Use this context to avoid false positives and make better testing decisions.
|
|
194574
|
+
|
|
194575
|
+
${knowledgeContent}`;
|
|
194576
|
+
}
|
|
194577
|
+
} catch {}
|
|
194578
|
+
}
|
|
194579
|
+
}
|
|
194507
194580
|
const outcomeSection = outcomeGuidance ? `
|
|
194508
194581
|
## Outcome Guidance
|
|
194509
194582
|
${outcomeGuidance}
|
|
@@ -194535,6 +194608,7 @@ Do NOT discover or enumerate other endpoints or services. Focus exclusively on t
|
|
|
194535
194608
|
- **URL:** ${target}
|
|
194536
194609
|
${authSection}
|
|
194537
194610
|
${knownFindingsSection}
|
|
194611
|
+
${knowledgeBaseSection}
|
|
194538
194612
|
|
|
194539
194613
|
## Objectives
|
|
194540
194614
|
${objectiveList}
|
|
@@ -194685,7 +194759,9 @@ var init_agent4 = __esm(() => {
|
|
|
194685
194759
|
"email_list_inboxes",
|
|
194686
194760
|
"email_list_messages",
|
|
194687
194761
|
"email_search_messages",
|
|
194688
|
-
"email_get_message"
|
|
194762
|
+
"email_get_message",
|
|
194763
|
+
"list_memories",
|
|
194764
|
+
"get_memory"
|
|
194689
194765
|
],
|
|
194690
194766
|
responseSchema: PentestResponseSchema,
|
|
194691
194767
|
resolveResult: () => {
|
|
@@ -195516,7 +195592,8 @@ async function runPentestWorkflow(input) {
|
|
|
195516
195592
|
}
|
|
195517
195593
|
const findingsRegistry = FindingsRegistry.fromDirectory(session.findingsPath, {
|
|
195518
195594
|
model,
|
|
195519
|
-
authConfig
|
|
195595
|
+
authConfig,
|
|
195596
|
+
abortSignal
|
|
195520
195597
|
});
|
|
195521
195598
|
await runPentestSwarm({
|
|
195522
195599
|
targets: swarmTargets,
|
|
@@ -272247,7 +272324,7 @@ var useTerminalDimensions = () => {
|
|
|
272247
272324
|
};
|
|
272248
272325
|
|
|
272249
272326
|
// src/tui/index.tsx
|
|
272250
|
-
var
|
|
272327
|
+
var import_react88 = __toESM(require_react(), 1);
|
|
272251
272328
|
|
|
272252
272329
|
// src/tui/components/footer.tsx
|
|
272253
272330
|
import os6 from "os";
|
|
@@ -274866,6 +274943,12 @@ function shouldResetHistory(historyIndex, isNavigatingHistory) {
|
|
|
274866
274943
|
}
|
|
274867
274944
|
|
|
274868
274945
|
// src/tui/components/shared/prompt-input.tsx
|
|
274946
|
+
var chatKeyBindings = [
|
|
274947
|
+
{ name: "return", action: "submit" },
|
|
274948
|
+
{ name: "linefeed", action: "newline" },
|
|
274949
|
+
{ name: "return", shift: true, action: "newline" },
|
|
274950
|
+
{ name: "linefeed", shift: true, action: "newline" }
|
|
274951
|
+
];
|
|
274869
274952
|
var PromptInput = import_react29.forwardRef(function PromptInput2({
|
|
274870
274953
|
width,
|
|
274871
274954
|
minHeight = 1,
|
|
@@ -275058,26 +275141,7 @@ var PromptInput = import_react29.forwardRef(function PromptInput2({
|
|
|
275058
275141
|
backgroundColor,
|
|
275059
275142
|
focusedBackgroundColor,
|
|
275060
275143
|
cursorColor: cursorColor ?? colors2.textMuted,
|
|
275061
|
-
keyBindings:
|
|
275062
|
-
{
|
|
275063
|
-
action: "submit",
|
|
275064
|
-
name: "return"
|
|
275065
|
-
},
|
|
275066
|
-
{
|
|
275067
|
-
action: "submit",
|
|
275068
|
-
name: "linefeed"
|
|
275069
|
-
},
|
|
275070
|
-
{
|
|
275071
|
-
action: "newline",
|
|
275072
|
-
shift: true,
|
|
275073
|
-
name: "return"
|
|
275074
|
-
},
|
|
275075
|
-
{
|
|
275076
|
-
action: "newline",
|
|
275077
|
-
shift: true,
|
|
275078
|
-
name: "linefeed"
|
|
275079
|
-
}
|
|
275080
|
-
],
|
|
275144
|
+
keyBindings: chatKeyBindings,
|
|
275081
275145
|
onContentChange: handleContentChange,
|
|
275082
275146
|
onSubmit: handleSubmit
|
|
275083
275147
|
}, undefined, false, undefined, this)
|
|
@@ -289634,15 +289698,125 @@ async function detectTerminalMode(timeoutMs = 1000) {
|
|
|
289634
289698
|
});
|
|
289635
289699
|
}
|
|
289636
289700
|
|
|
289701
|
+
// src/tui/console-theme.ts
|
|
289702
|
+
var import_react85 = __toESM(require_react(), 1);
|
|
289703
|
+
var withAlpha = (rgba, a) => RGBA.fromValues(rgba.r, rgba.g, rgba.b, a);
|
|
289704
|
+
var overlayThemeRef = {
|
|
289705
|
+
current: null
|
|
289706
|
+
};
|
|
289707
|
+
function buildConsoleOptions(themeColors) {
|
|
289708
|
+
return {
|
|
289709
|
+
backgroundColor: withAlpha(themeColors.backgroundPanel, 0.85),
|
|
289710
|
+
titleBarColor: withAlpha(themeColors.backgroundElement, 0.9),
|
|
289711
|
+
titleBarTextColor: themeColors.text,
|
|
289712
|
+
colorDefault: themeColors.textMuted,
|
|
289713
|
+
colorInfo: themeColors.info,
|
|
289714
|
+
colorWarn: themeColors.warning,
|
|
289715
|
+
colorError: themeColors.error,
|
|
289716
|
+
colorDebug: themeColors.textMuted,
|
|
289717
|
+
selectionColor: withAlpha(themeColors.primary, 0.35),
|
|
289718
|
+
cursorColor: themeColors.primary,
|
|
289719
|
+
copyButtonColor: themeColors.primary
|
|
289720
|
+
};
|
|
289721
|
+
}
|
|
289722
|
+
function ConsoleThemeSync() {
|
|
289723
|
+
const { colors: colors2 } = useTheme();
|
|
289724
|
+
const renderer = useRenderer();
|
|
289725
|
+
import_react85.useEffect(() => {
|
|
289726
|
+
overlayThemeRef.current = colors2;
|
|
289727
|
+
const c = renderer.console;
|
|
289728
|
+
c.backgroundColor = withAlpha(colors2.backgroundPanel, 0.85);
|
|
289729
|
+
c._rgbaTitleBar = withAlpha(colors2.backgroundElement, 0.9);
|
|
289730
|
+
c._rgbaTitleBarText = colors2.text;
|
|
289731
|
+
c._rgbaDefault = colors2.textMuted;
|
|
289732
|
+
c._rgbaInfo = colors2.info;
|
|
289733
|
+
c._rgbaWarn = colors2.warning;
|
|
289734
|
+
c._rgbaError = colors2.error;
|
|
289735
|
+
c._rgbaDebug = colors2.textMuted;
|
|
289736
|
+
c._rgbaSelection = withAlpha(colors2.primary, 0.35);
|
|
289737
|
+
c._rgbaCursor = colors2.primary;
|
|
289738
|
+
c._rgbaCopyButton = colors2.primary;
|
|
289739
|
+
c.markNeedsRerender();
|
|
289740
|
+
}, [colors2]);
|
|
289741
|
+
return null;
|
|
289742
|
+
}
|
|
289743
|
+
|
|
289744
|
+
// src/tui/clipboard.ts
|
|
289745
|
+
function createClipboardManager(renderer) {
|
|
289746
|
+
let clipboardNotifExpiry = 0;
|
|
289747
|
+
const copyToClipboard = (text2) => {
|
|
289748
|
+
renderer.copyToClipboardOSC52(text2);
|
|
289749
|
+
try {
|
|
289750
|
+
const proc = Bun.spawn(process.platform === "darwin" ? ["pbcopy"] : ["xclip", "-selection", "clipboard"], { stdin: "pipe" });
|
|
289751
|
+
proc.stdin.write(text2);
|
|
289752
|
+
proc.stdin.end();
|
|
289753
|
+
} catch {}
|
|
289754
|
+
clipboardNotifExpiry = Date.now() + 2000;
|
|
289755
|
+
renderer.requestRender();
|
|
289756
|
+
setTimeout(() => renderer.requestRender(), 2010);
|
|
289757
|
+
};
|
|
289758
|
+
const notifLabel = "Copied to clipboard";
|
|
289759
|
+
const notifPadX = 1;
|
|
289760
|
+
const notifBoxWidth = 1 + notifPadX + notifLabel.length + notifPadX + 1;
|
|
289761
|
+
const notifBoxHeight = 3;
|
|
289762
|
+
const notifMargin = 1;
|
|
289763
|
+
renderer.addPostProcessFn((buffer) => {
|
|
289764
|
+
if (Date.now() < clipboardNotifExpiry && overlayThemeRef.current) {
|
|
289765
|
+
const c = overlayThemeRef.current;
|
|
289766
|
+
const x4 = buffer.width - notifBoxWidth - notifMargin;
|
|
289767
|
+
const y3 = notifMargin;
|
|
289768
|
+
buffer.fillRect(x4, y3, notifBoxWidth, notifBoxHeight, c.backgroundElement);
|
|
289769
|
+
buffer.drawBox({
|
|
289770
|
+
x: x4,
|
|
289771
|
+
y: y3,
|
|
289772
|
+
width: notifBoxWidth,
|
|
289773
|
+
height: notifBoxHeight,
|
|
289774
|
+
border: true,
|
|
289775
|
+
borderColor: c.border,
|
|
289776
|
+
backgroundColor: c.backgroundElement,
|
|
289777
|
+
shouldFill: false
|
|
289778
|
+
});
|
|
289779
|
+
buffer.drawText(notifLabel, x4 + 1 + notifPadX, y3 + 1, c.text, c.backgroundElement);
|
|
289780
|
+
}
|
|
289781
|
+
});
|
|
289782
|
+
renderer.console.onCopySelection = copyToClipboard;
|
|
289783
|
+
return { copyToClipboard };
|
|
289784
|
+
}
|
|
289785
|
+
|
|
289786
|
+
// src/tui/auto-copy.ts
|
|
289787
|
+
function setupAutoCopy(renderer, copyToClipboard) {
|
|
289788
|
+
renderer.console.getCopyButtonLabel = () => "Select to copy";
|
|
289789
|
+
const originalHandleMouse = renderer.console.handleMouse.bind(renderer.console);
|
|
289790
|
+
renderer.console.handleMouse = (event) => {
|
|
289791
|
+
const result = originalHandleMouse(event);
|
|
289792
|
+
if (event.type === "up") {
|
|
289793
|
+
const c = renderer.console;
|
|
289794
|
+
if (typeof c.hasSelection === "function" && c.hasSelection()) {
|
|
289795
|
+
c.triggerCopy();
|
|
289796
|
+
}
|
|
289797
|
+
}
|
|
289798
|
+
return result;
|
|
289799
|
+
};
|
|
289800
|
+
renderer.on("selection", (selection) => {
|
|
289801
|
+
if (selection && !selection.isDragging) {
|
|
289802
|
+
const text2 = selection.getSelectedText();
|
|
289803
|
+
if (text2) {
|
|
289804
|
+
copyToClipboard(text2);
|
|
289805
|
+
}
|
|
289806
|
+
process.nextTick(() => renderer.clearSelection());
|
|
289807
|
+
}
|
|
289808
|
+
});
|
|
289809
|
+
}
|
|
289810
|
+
|
|
289637
289811
|
// src/tui/index.tsx
|
|
289638
289812
|
function App({ appConfig }) {
|
|
289639
|
-
const [focusIndex, setFocusIndex] =
|
|
289640
|
-
const [cwd, setCwd] =
|
|
289641
|
-
const [ctrlCPressTime, setCtrlCPressTime] =
|
|
289642
|
-
const [showExitWarning, setShowExitWarning] =
|
|
289643
|
-
const [inputKey, setInputKey] =
|
|
289644
|
-
const [showSessionsDialog, setShowSessionsDialog] =
|
|
289645
|
-
const [showShortcutsDialog, setShowShortcutsDialog] =
|
|
289813
|
+
const [focusIndex, setFocusIndex] = import_react88.useState(0);
|
|
289814
|
+
const [cwd, setCwd] = import_react88.useState(process.cwd());
|
|
289815
|
+
const [ctrlCPressTime, setCtrlCPressTime] = import_react88.useState(null);
|
|
289816
|
+
const [showExitWarning, setShowExitWarning] = import_react88.useState(false);
|
|
289817
|
+
const [inputKey, setInputKey] = import_react88.useState(0);
|
|
289818
|
+
const [showSessionsDialog, setShowSessionsDialog] = import_react88.useState(false);
|
|
289819
|
+
const [showShortcutsDialog, setShowShortcutsDialog] = import_react88.useState(false);
|
|
289646
289820
|
const navigableItems = ["command-input"];
|
|
289647
289821
|
return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ConfigProvider, {
|
|
289648
289822
|
config: appConfig,
|
|
@@ -289707,14 +289881,14 @@ function AppContent({
|
|
|
289707
289881
|
const { toast } = useToast();
|
|
289708
289882
|
const { refocusPrompt } = useFocus();
|
|
289709
289883
|
const { setExternalDialogOpen } = useDialog();
|
|
289710
|
-
|
|
289884
|
+
import_react88.useEffect(() => {
|
|
289711
289885
|
checkForUpdate().then(({ updateAvailable, currentVersion, latestVersion }) => {
|
|
289712
289886
|
if (!updateAvailable)
|
|
289713
289887
|
return;
|
|
289714
289888
|
toast(`Update available: v${currentVersion} → v${latestVersion}. Run: pensar upgrade`, "warn", 8000);
|
|
289715
289889
|
});
|
|
289716
289890
|
}, []);
|
|
289717
|
-
|
|
289891
|
+
import_react88.useEffect(() => {
|
|
289718
289892
|
if (route.data.type !== "base")
|
|
289719
289893
|
return;
|
|
289720
289894
|
if (!config3.data.responsibleUseAccepted && route.data.path !== "disclosure") {
|
|
@@ -289723,7 +289897,7 @@ function AppContent({
|
|
|
289723
289897
|
route.navigate({ type: "base", path: "providers" });
|
|
289724
289898
|
}
|
|
289725
289899
|
}, [config3.data.responsibleUseAccepted, route.data]);
|
|
289726
|
-
|
|
289900
|
+
import_react88.useEffect(() => {
|
|
289727
289901
|
if (showExitWarning) {
|
|
289728
289902
|
const timer = setTimeout(() => {
|
|
289729
289903
|
setShowExitWarning(false);
|
|
@@ -289912,7 +290086,14 @@ async function main2() {
|
|
|
289912
290086
|
} else {
|
|
289913
290087
|
mode = await detectTerminalMode();
|
|
289914
290088
|
}
|
|
289915
|
-
const
|
|
290089
|
+
const themeColors = resolveThemeColors(getTheme(themeName), mode);
|
|
290090
|
+
overlayThemeRef.current = themeColors;
|
|
290091
|
+
const renderer = await createCliRenderer({
|
|
290092
|
+
exitOnCtrlC: false,
|
|
290093
|
+
consoleOptions: buildConsoleOptions(themeColors)
|
|
290094
|
+
});
|
|
290095
|
+
const { copyToClipboard } = createClipboardManager(renderer);
|
|
290096
|
+
setupAutoCopy(renderer, copyToClipboard);
|
|
289916
290097
|
const cleanup = () => {
|
|
289917
290098
|
renderer.destroy();
|
|
289918
290099
|
process.exit(0);
|
|
@@ -289934,16 +290115,19 @@ async function main2() {
|
|
|
289934
290115
|
createRoot(renderer).render(/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ThemeProvider, {
|
|
289935
290116
|
initialTheme: themeName,
|
|
289936
290117
|
initialMode: mode,
|
|
289937
|
-
children:
|
|
289938
|
-
|
|
289939
|
-
|
|
289940
|
-
|
|
289941
|
-
|
|
289942
|
-
|
|
289943
|
-
|
|
289944
|
-
|
|
289945
|
-
|
|
289946
|
-
|
|
289947
|
-
|
|
290118
|
+
children: [
|
|
290119
|
+
/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ConsoleThemeSync, {}, undefined, false, undefined, this),
|
|
290120
|
+
/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToastProvider, {
|
|
290121
|
+
children: [
|
|
290122
|
+
/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ErrorBoundary2, {
|
|
290123
|
+
children: /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(App, {
|
|
290124
|
+
appConfig
|
|
290125
|
+
}, undefined, false, undefined, this)
|
|
290126
|
+
}, undefined, false, undefined, this),
|
|
290127
|
+
/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV(ToastContainer, {}, undefined, false, undefined, this)
|
|
290128
|
+
]
|
|
290129
|
+
}, undefined, true, undefined, this)
|
|
290130
|
+
]
|
|
290131
|
+
}, undefined, true, undefined, this));
|
|
289948
290132
|
}
|
|
289949
290133
|
main2();
|