pentesting 0.73.6 → 0.73.7

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.
@@ -5,7 +5,7 @@ import {
5
5
  createContextExtractor,
6
6
  getLLMClient,
7
7
  getShellSupervisorLifecycleSnapshot
8
- } from "./chunk-HSZZHAGX.js";
8
+ } from "./chunk-UIYY4RLA.js";
9
9
  import {
10
10
  AGENT_ROLES,
11
11
  EVENT_TYPES,
@@ -13,7 +13,7 @@ import {
13
13
  TOOL_NAMES,
14
14
  getProcessOutput,
15
15
  listBackgroundProcesses
16
- } from "./chunk-4HG57VDC.js";
16
+ } from "./chunk-FJ7PENUK.js";
17
17
  import {
18
18
  DETECTION_PATTERNS,
19
19
  PROCESS_EVENTS,
@@ -347,7 +347,7 @@ var INPUT_PROMPT_PATTERNS = [
347
347
  ];
348
348
 
349
349
  // src/shared/constants/agent.ts
350
- var APP_VERSION = "0.73.6";
350
+ var APP_VERSION = "0.73.7";
351
351
  var APP_DESCRIPTION = "Autonomous Penetration Testing AI Agent";
352
352
  var LLM_ROLES = {
353
353
  SYSTEM: "system",
@@ -3829,6 +3829,25 @@ var StateSerializer = class {
3829
3829
  }
3830
3830
  }
3831
3831
  static formatDelegatedTasks(state3, lines) {
3832
+ const activeExecution = state3.getActiveDelegatedExecution();
3833
+ if (activeExecution) {
3834
+ const worker = activeExecution.workerType ? ` worker:${activeExecution.workerType}` : "";
3835
+ const resume = activeExecution.resumeTaskId ? ` resume:${activeExecution.resumeTaskId}` : "";
3836
+ lines.push(`Delegated Execution [running]: ${activeExecution.task}${worker}${resume}`);
3837
+ if (activeExecution.target) {
3838
+ lines.push(` target: ${activeExecution.target}`);
3839
+ }
3840
+ if (activeExecution.context) {
3841
+ lines.push(` context: ${activeExecution.context}`);
3842
+ }
3843
+ if (activeExecution.parentTaskId || activeExecution.rootTaskId) {
3844
+ const chainParts = [
3845
+ activeExecution.parentTaskId ? `parent:${activeExecution.parentTaskId}` : "",
3846
+ activeExecution.rootTaskId ? `root:${activeExecution.rootTaskId}` : ""
3847
+ ].filter(Boolean);
3848
+ lines.push(` chain: ${chainParts.join(" ")}`);
3849
+ }
3850
+ }
3832
3851
  const activeTasks = state3.getActiveDelegatedTasks();
3833
3852
  if (activeTasks.length === 0) return;
3834
3853
  lines.push(`Delegated Tasks (${activeTasks.length} active):`);
@@ -3993,6 +4012,7 @@ function saveState(state3) {
3993
4012
  currentPhase: state3.getPhase(),
3994
4013
  missionSummary: state3.getMissionSummary(),
3995
4014
  missionChecklist: state3.getMissionChecklist(),
4015
+ activeDelegatedExecution: state3.getActiveDelegatedExecution(),
3996
4016
  delegatedTasks: state3.getDelegatedTasks()
3997
4017
  };
3998
4018
  const sessionFile = join5(sessionsDir, FILE_PATTERNS.session());
@@ -4064,6 +4084,9 @@ function loadState(state3) {
4064
4084
  if (snapshot.missionChecklist?.length > 0) {
4065
4085
  state3.restoreMissionChecklist(snapshot.missionChecklist);
4066
4086
  }
4087
+ if (snapshot.activeDelegatedExecution) {
4088
+ state3.restoreActiveDelegatedExecution(snapshot.activeDelegatedExecution);
4089
+ }
4067
4090
  if (Array.isArray(snapshot.delegatedTasks)) {
4068
4091
  for (const task of snapshot.delegatedTasks) {
4069
4092
  state3.restoreDelegatedTask(task);
@@ -64,7 +64,7 @@ import {
64
64
  startBackgroundProcess,
65
65
  stopBackgroundProcess,
66
66
  writeFileContent
67
- } from "./chunk-4HG57VDC.js";
67
+ } from "./chunk-FJ7PENUK.js";
68
68
  import {
69
69
  DETECTION_PATTERNS,
70
70
  HEALTH_CONFIG,
@@ -8264,6 +8264,7 @@ var SharedState = class {
8264
8264
  */
8265
8265
  currentObjective = null;
8266
8266
  delegatedTasks = [];
8267
+ activeDelegatedExecution = null;
8267
8268
  constructor() {
8268
8269
  this.targetState = new TargetState(this.attackGraph);
8269
8270
  this.findingState = new FindingState();
@@ -8290,6 +8291,7 @@ var SharedState = class {
8290
8291
  this.artifacts = [];
8291
8292
  this.currentObjective = null;
8292
8293
  this.delegatedTasks = [];
8294
+ this.activeDelegatedExecution = null;
8293
8295
  this.lastReflection = "";
8294
8296
  this.lastTriageMemo = "";
8295
8297
  }
@@ -8407,6 +8409,40 @@ var SharedState = class {
8407
8409
  getTimeStatus() {
8408
8410
  return this.sessionState.getTimeStatus();
8409
8411
  }
8412
+ startDelegatedExecution(execution) {
8413
+ const now = Date.now();
8414
+ const parentTask = execution.resumeTaskId ? this.delegatedTasks.find((existing) => existing.id === execution.resumeTaskId) : void 0;
8415
+ const activeExecution = {
8416
+ id: generatePrefixedId("delegated_exec"),
8417
+ task: execution.task,
8418
+ target: execution.target,
8419
+ context: execution.context,
8420
+ resumeTaskId: execution.resumeTaskId,
8421
+ parentTaskId: execution.resumeTaskId || void 0,
8422
+ rootTaskId: parentTask ? parentTask.rootTaskId || parentTask.id : execution.resumeTaskId || void 0,
8423
+ workerType: execution.workerType,
8424
+ status: "running",
8425
+ startedAt: now,
8426
+ updatedAt: now
8427
+ };
8428
+ this.activeDelegatedExecution = activeExecution;
8429
+ return activeExecution;
8430
+ }
8431
+ restoreActiveDelegatedExecution(execution) {
8432
+ this.activeDelegatedExecution = execution;
8433
+ }
8434
+ clearActiveDelegatedExecution(executionId) {
8435
+ if (!this.activeDelegatedExecution) {
8436
+ return;
8437
+ }
8438
+ if (executionId && this.activeDelegatedExecution.id !== executionId) {
8439
+ return;
8440
+ }
8441
+ this.activeDelegatedExecution = null;
8442
+ }
8443
+ getActiveDelegatedExecution() {
8444
+ return this.activeDelegatedExecution ? { ...this.activeDelegatedExecution } : null;
8445
+ }
8410
8446
  recordDelegatedTask(task) {
8411
8447
  const now = Date.now();
8412
8448
  const parentTask = task.resumeTaskId ? this.delegatedTasks.find((existing) => existing.id === task.resumeTaskId) : void 0;
@@ -11897,42 +11933,91 @@ After completion: record key loot/findings from the sub-agent output to canonica
11897
11933
  workerType: params["worker_type"],
11898
11934
  resumeTaskId: params["resume_task_id"]
11899
11935
  };
11900
- const { AgentTool } = await import("./agent-tool-3Y7YKMCZ.js");
11901
- const executor = new AgentTool(state, events, scopeGuard, approvalGate);
11902
- const result = await executor.execute(input);
11903
- state.recordDelegatedTask({
11936
+ const activeExecution = state.startDelegatedExecution({
11904
11937
  task: input.task,
11905
11938
  target: input.target,
11906
11939
  context: input.context,
11907
- resumeTaskId: input.resumeTaskId,
11908
11940
  workerType: input.workerType,
11909
- status: result.status,
11910
- summary: result.summary,
11911
- tried: result.tried,
11912
- findings: result.findings,
11913
- loot: result.loot,
11914
- sessions: result.sessions,
11915
- assets: result.assets,
11916
- suggestedNext: result.suggestedNext,
11917
- waitingOn: result.waitingOn,
11918
- resumeHint: result.resumeHint,
11919
- nextWorkerType: result.nextWorkerType
11941
+ resumeTaskId: input.resumeTaskId
11942
+ });
11943
+ events.emit({
11944
+ type: EVENT_TYPES.DELEGATE,
11945
+ timestamp: Date.now(),
11946
+ data: {
11947
+ fromAgent: "main",
11948
+ toAgent: input.workerType || "general",
11949
+ task: input.task,
11950
+ dangerLevel: "delegated",
11951
+ reason: input.context,
11952
+ executionId: activeExecution.id,
11953
+ workerType: input.workerType,
11954
+ resumeTaskId: input.resumeTaskId,
11955
+ parentTaskId: activeExecution.parentTaskId,
11956
+ rootTaskId: activeExecution.rootTaskId
11957
+ }
11920
11958
  });
11921
- const lines = [
11922
- `[Status] ${result.status}`,
11923
- `[Summary] ${result.summary}`,
11924
- result.findings.length ? `[Findings] ${result.findings.join(" | ")}` : "",
11925
- result.loot.length ? `[Loot] ${result.loot.join(" | ")}` : "",
11926
- result.sessions.length ? `[Sessions] ${result.sessions.join(", ")}` : "",
11927
- result.assets.length ? `[Assets] ${result.assets.join(" | ")}` : "",
11928
- result.tried.length ? `[Tried] ${result.tried.join(" | ")}` : "",
11929
- input.resumeTaskId ? `[ResumedFrom] ${input.resumeTaskId}` : "",
11930
- result.waitingOn ? `[Waiting] ${result.waitingOn}` : "",
11931
- result.resumeHint ? `[Resume] ${result.resumeHint}` : "",
11932
- result.nextWorkerType ? `[NextWorker] ${result.nextWorkerType}` : "",
11933
- result.suggestedNext ? `[Next] ${result.suggestedNext}` : ""
11934
- ].filter(Boolean);
11935
- return { success: true, output: lines.join("\n") };
11959
+ const { AgentTool } = await import("./agent-tool-EZF2ILH6.js");
11960
+ const executor = new AgentTool(state, events, scopeGuard, approvalGate);
11961
+ try {
11962
+ const result = await executor.execute(input);
11963
+ const record = state.recordDelegatedTask({
11964
+ task: input.task,
11965
+ target: input.target,
11966
+ context: input.context,
11967
+ resumeTaskId: input.resumeTaskId,
11968
+ workerType: input.workerType,
11969
+ status: result.status,
11970
+ summary: result.summary,
11971
+ tried: result.tried,
11972
+ findings: result.findings,
11973
+ loot: result.loot,
11974
+ sessions: result.sessions,
11975
+ assets: result.assets,
11976
+ suggestedNext: result.suggestedNext,
11977
+ waitingOn: result.waitingOn,
11978
+ resumeHint: result.resumeHint,
11979
+ nextWorkerType: result.nextWorkerType
11980
+ });
11981
+ events.emit({
11982
+ type: EVENT_TYPES.DELEGATE_RESULT,
11983
+ timestamp: Date.now(),
11984
+ data: {
11985
+ agent: input.workerType || "general",
11986
+ output: result.summary,
11987
+ findings: result.findings.length,
11988
+ targets: 0,
11989
+ iterations: result.tried.length,
11990
+ isCompleted: result.status !== "waiting" && result.status !== "running",
11991
+ taskId: record.id,
11992
+ parentTaskId: record.parentTaskId,
11993
+ rootTaskId: record.rootTaskId,
11994
+ workerType: record.workerType,
11995
+ status: result.status,
11996
+ summary: result.summary,
11997
+ waitingOn: result.waitingOn,
11998
+ resumeHint: result.resumeHint,
11999
+ nextWorkerType: result.nextWorkerType,
12000
+ executionId: activeExecution.id
12001
+ }
12002
+ });
12003
+ const lines = [
12004
+ `[Status] ${result.status}`,
12005
+ `[Summary] ${result.summary}`,
12006
+ result.findings.length ? `[Findings] ${result.findings.join(" | ")}` : "",
12007
+ result.loot.length ? `[Loot] ${result.loot.join(" | ")}` : "",
12008
+ result.sessions.length ? `[Sessions] ${result.sessions.join(", ")}` : "",
12009
+ result.assets.length ? `[Assets] ${result.assets.join(" | ")}` : "",
12010
+ result.tried.length ? `[Tried] ${result.tried.join(" | ")}` : "",
12011
+ input.resumeTaskId ? `[ResumedFrom] ${input.resumeTaskId}` : "",
12012
+ result.waitingOn ? `[Waiting] ${result.waitingOn}` : "",
12013
+ result.resumeHint ? `[Resume] ${result.resumeHint}` : "",
12014
+ result.nextWorkerType ? `[NextWorker] ${result.nextWorkerType}` : "",
12015
+ result.suggestedNext ? `[Next] ${result.suggestedNext}` : ""
12016
+ ].filter(Boolean);
12017
+ return { success: true, output: lines.join("\n") };
12018
+ } finally {
12019
+ state.clearActiveDelegatedExecution(activeExecution.id);
12020
+ }
11936
12021
  }
11937
12022
  };
11938
12023
  }