pentesting 0.8.34 → 0.8.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +167 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6959,6 +6959,142 @@ function getKeyboardListener() {
|
|
|
6959
6959
|
return keyboardListenerInstance;
|
|
6960
6960
|
}
|
|
6961
6961
|
|
|
6962
|
+
// src/utils/input-queue.ts
|
|
6963
|
+
import { EventEmitter as EventEmitter8 } from "events";
|
|
6964
|
+
var INPUT_QUEUE_EVENT = {
|
|
6965
|
+
QUEUED: "queued",
|
|
6966
|
+
// Message added to queue
|
|
6967
|
+
DEQUEUED: "dequeued",
|
|
6968
|
+
// Message removed from queue
|
|
6969
|
+
PROCESSING: "processing",
|
|
6970
|
+
// Message being processed
|
|
6971
|
+
CLEARED: "cleared",
|
|
6972
|
+
// Queue cleared
|
|
6973
|
+
SHUTDOWN: "shutdown"
|
|
6974
|
+
// Queue shutdown
|
|
6975
|
+
};
|
|
6976
|
+
var InputQueue = class extends EventEmitter8 {
|
|
6977
|
+
queue = [];
|
|
6978
|
+
isShutdown = false;
|
|
6979
|
+
isPaused = false;
|
|
6980
|
+
nextId = 1;
|
|
6981
|
+
constructor() {
|
|
6982
|
+
super();
|
|
6983
|
+
}
|
|
6984
|
+
/**
|
|
6985
|
+
* Add input to the queue
|
|
6986
|
+
* Returns immediately, input will be processed when agent is ready
|
|
6987
|
+
*/
|
|
6988
|
+
enqueue(content, options = {}) {
|
|
6989
|
+
if (this.isShutdown) {
|
|
6990
|
+
throw new Error("Queue is shutdown");
|
|
6991
|
+
}
|
|
6992
|
+
const input = {
|
|
6993
|
+
id: `input_${this.nextId++}`,
|
|
6994
|
+
content,
|
|
6995
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
6996
|
+
priority: options.priority || "normal",
|
|
6997
|
+
metadata: options.metadata
|
|
6998
|
+
};
|
|
6999
|
+
if (input.priority === "interrupt") {
|
|
7000
|
+
this.queue.unshift(input);
|
|
7001
|
+
} else if (input.priority === "high") {
|
|
7002
|
+
const firstNormal = this.queue.findIndex((q) => q.priority === "normal");
|
|
7003
|
+
if (firstNormal === -1) {
|
|
7004
|
+
this.queue.push(input);
|
|
7005
|
+
} else {
|
|
7006
|
+
this.queue.splice(firstNormal, 0, input);
|
|
7007
|
+
}
|
|
7008
|
+
} else {
|
|
7009
|
+
this.queue.push(input);
|
|
7010
|
+
}
|
|
7011
|
+
this.emit(INPUT_QUEUE_EVENT.QUEUED, input);
|
|
7012
|
+
return input;
|
|
7013
|
+
}
|
|
7014
|
+
/**
|
|
7015
|
+
* Get next input from queue
|
|
7016
|
+
* Returns null if queue is empty or paused
|
|
7017
|
+
*/
|
|
7018
|
+
dequeue() {
|
|
7019
|
+
if (this.isShutdown || this.isPaused || this.queue.length === 0) {
|
|
7020
|
+
return null;
|
|
7021
|
+
}
|
|
7022
|
+
const input = this.queue.shift();
|
|
7023
|
+
this.emit(INPUT_QUEUE_EVENT.DEQUEUED, input);
|
|
7024
|
+
return input;
|
|
7025
|
+
}
|
|
7026
|
+
/**
|
|
7027
|
+
* Peek at next input without removing it
|
|
7028
|
+
*/
|
|
7029
|
+
peek() {
|
|
7030
|
+
return this.queue[0] || null;
|
|
7031
|
+
}
|
|
7032
|
+
/**
|
|
7033
|
+
* Check if there are pending inputs
|
|
7034
|
+
*/
|
|
7035
|
+
hasPending() {
|
|
7036
|
+
return this.queue.length > 0 && !this.isPaused && !this.isShutdown;
|
|
7037
|
+
}
|
|
7038
|
+
/**
|
|
7039
|
+
* Get number of pending inputs
|
|
7040
|
+
*/
|
|
7041
|
+
get length() {
|
|
7042
|
+
return this.queue.length;
|
|
7043
|
+
}
|
|
7044
|
+
/**
|
|
7045
|
+
* Get all pending inputs (for display)
|
|
7046
|
+
*/
|
|
7047
|
+
getPending() {
|
|
7048
|
+
return [...this.queue];
|
|
7049
|
+
}
|
|
7050
|
+
/**
|
|
7051
|
+
* Pause queue processing (inputs can still be added)
|
|
7052
|
+
*/
|
|
7053
|
+
pause() {
|
|
7054
|
+
this.isPaused = true;
|
|
7055
|
+
}
|
|
7056
|
+
/**
|
|
7057
|
+
* Resume queue processing
|
|
7058
|
+
*/
|
|
7059
|
+
resume() {
|
|
7060
|
+
this.isPaused = false;
|
|
7061
|
+
}
|
|
7062
|
+
/**
|
|
7063
|
+
* Clear all pending inputs
|
|
7064
|
+
*/
|
|
7065
|
+
clear() {
|
|
7066
|
+
this.queue = [];
|
|
7067
|
+
this.emit(INPUT_QUEUE_EVENT.CLEARED);
|
|
7068
|
+
}
|
|
7069
|
+
/**
|
|
7070
|
+
* Shutdown queue (no more inputs accepted)
|
|
7071
|
+
*/
|
|
7072
|
+
shutdown() {
|
|
7073
|
+
this.isShutdown = true;
|
|
7074
|
+
this.queue = [];
|
|
7075
|
+
this.emit(INPUT_QUEUE_EVENT.SHUTDOWN);
|
|
7076
|
+
}
|
|
7077
|
+
/**
|
|
7078
|
+
* Check if queue is shutdown
|
|
7079
|
+
*/
|
|
7080
|
+
get isTerminated() {
|
|
7081
|
+
return this.isShutdown;
|
|
7082
|
+
}
|
|
7083
|
+
/**
|
|
7084
|
+
* Check if queue is paused
|
|
7085
|
+
*/
|
|
7086
|
+
get isHeld() {
|
|
7087
|
+
return this.isPaused;
|
|
7088
|
+
}
|
|
7089
|
+
};
|
|
7090
|
+
var inputQueueInstance = null;
|
|
7091
|
+
function getInputQueue() {
|
|
7092
|
+
if (!inputQueueInstance) {
|
|
7093
|
+
inputQueueInstance = new InputQueue();
|
|
7094
|
+
}
|
|
7095
|
+
return inputQueueInstance;
|
|
7096
|
+
}
|
|
7097
|
+
|
|
6962
7098
|
// src/cli/app.tsx
|
|
6963
7099
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
6964
7100
|
var App = ({ autoApprove = false, target }) => {
|
|
@@ -6977,6 +7113,7 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
6977
7113
|
const [preInputBuffer, setPreInputBuffer] = useState("");
|
|
6978
7114
|
const [wasInterrupted, setWasInterrupted] = useState(false);
|
|
6979
7115
|
const [spinnerHue, setSpinnerHue] = useState(0);
|
|
7116
|
+
const [queuedCount, setQueuedCount] = useState(0);
|
|
6980
7117
|
const [, forceUpdate] = useState(0);
|
|
6981
7118
|
const spinnerColor = THEME.spinner;
|
|
6982
7119
|
const [agent] = useState(() => new AutonomousHackingAgent(void 0, { autoApprove }));
|
|
@@ -7220,6 +7357,24 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
7220
7357
|
addMessage(MESSAGE_TYPE.SYSTEM, `\u2713 Complete (${duration}s)`);
|
|
7221
7358
|
setIsProcessing(false);
|
|
7222
7359
|
setCurrentStatus("");
|
|
7360
|
+
const inputQueue = getInputQueue();
|
|
7361
|
+
if (inputQueue.hasPending()) {
|
|
7362
|
+
const next = inputQueue.dequeue();
|
|
7363
|
+
if (next) {
|
|
7364
|
+
setQueuedCount(inputQueue.length);
|
|
7365
|
+
addMessage(MESSAGE_TYPE.SYSTEM, ` \u{1F4E4} Processing queued: ${next.content.slice(0, 50)}...`);
|
|
7366
|
+
addMessage(MESSAGE_TYPE.USER, next.content);
|
|
7367
|
+
setIsProcessing(true);
|
|
7368
|
+
setTimeout(async () => {
|
|
7369
|
+
try {
|
|
7370
|
+
await agent.chat(next.content);
|
|
7371
|
+
} catch (err) {
|
|
7372
|
+
addMessage(MESSAGE_TYPE.ERROR, err instanceof Error ? err.message : String(err));
|
|
7373
|
+
setIsProcessing(false);
|
|
7374
|
+
}
|
|
7375
|
+
}, 100);
|
|
7376
|
+
}
|
|
7377
|
+
}
|
|
7223
7378
|
});
|
|
7224
7379
|
agent.on(AGENT_EVENT.ERROR, (error) => {
|
|
7225
7380
|
stopTimer();
|
|
@@ -7275,7 +7430,14 @@ var App = ({ autoApprove = false, target }) => {
|
|
|
7275
7430
|
exit();
|
|
7276
7431
|
return;
|
|
7277
7432
|
}
|
|
7278
|
-
if (isProcessing && !trimmed.startsWith("/"))
|
|
7433
|
+
if (isProcessing && !trimmed.startsWith("/")) {
|
|
7434
|
+
const inputQueue = getInputQueue();
|
|
7435
|
+
inputQueue.enqueue(trimmed);
|
|
7436
|
+
setQueuedCount(inputQueue.length);
|
|
7437
|
+
setInput("");
|
|
7438
|
+
addMessage(MESSAGE_TYPE.SYSTEM, ` \u{1F4E5} Queued (${inputQueue.length} pending): ${trimmed.slice(0, 50)}...`);
|
|
7439
|
+
return;
|
|
7440
|
+
}
|
|
7279
7441
|
setInput("");
|
|
7280
7442
|
addMessage(MESSAGE_TYPE.USER, trimmed);
|
|
7281
7443
|
if (trimmed.startsWith("/")) {
|
|
@@ -7926,7 +8088,10 @@ ${list}`);
|
|
|
7926
8088
|
/* @__PURE__ */ jsx2(Text2, { color: THEME.text.accent, children: preInputBuffer }),
|
|
7927
8089
|
/* @__PURE__ */ jsx2(Text2, { color: THEME.text.muted, children: "\u258C" })
|
|
7928
8090
|
] }),
|
|
7929
|
-
/* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */
|
|
8091
|
+
/* @__PURE__ */ jsx2(Box2, { marginTop: 1, children: /* @__PURE__ */ jsxs2(Text2, { dimColor: true, children: [
|
|
8092
|
+
"ESC to interrupt \u2502 Type ahead to queue input",
|
|
8093
|
+
queuedCount > 0 ? ` \u2502 \u{1F4E5} ${queuedCount} queued` : ""
|
|
8094
|
+
] }) })
|
|
7930
8095
|
] }) : /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", children: [
|
|
7931
8096
|
showCommandHints && input.startsWith("/") && /* @__PURE__ */ jsx2(Box2, { flexDirection: "column", marginBottom: 1, children: /* @__PURE__ */ jsx2(Text2, { dimColor: true, children: [
|
|
7932
8097
|
"/target <ip>",
|