pentesting 0.73.6 → 0.73.8

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/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  <div align="center">
2
2
 
3
- <img src="https://api.iconify.design/game-icons:fizzing-flask.svg?color=%232496ED" width="80" height="80" alt="Pentesting Agent" />
3
+ <a href="https://agnusdei1207.github.io/brainscience/pentesting/">
4
+ <img src="https://api.iconify.design/game-icons:fizzing-flask.svg?color=%232496ED" width="80" height="80" alt="Pentesting Agent" />
5
+ </a>
4
6
 
5
7
  # pentesting
6
8
  > **Autonomous Offensive Security AI Agent**
7
9
 
8
- [![npm](https://img.shields.io/badge/npm-pentesting-2496ED)](https://www.npmjs.org/package/pentesting)
9
- [![docker](https://img.shields.io/badge/docker-pentesting-2496ED)](https://hub.docker.com/r/agnusdei1207/pentesting)
10
+ [![npm](https://img.shields.io/badge/npm-pentesting-CB3837?style=flat-square&logo=npm&logoColor=white)](https://www.npmjs.com/package/pentesting)
11
+ [![docker](https://img.shields.io/badge/docker-pentesting-2496ED?style=flat-square&logo=docker&logoColor=white)](https://hub.docker.com/r/agnusdei1207/pentesting)
12
+ [![docs](https://img.shields.io/badge/docs-brainscience-10B981?style=flat-square&logo=readthedocs&logoColor=white)](https://agnusdei1207.github.io/brainscience/pentesting/)
10
13
 
11
14
  </div>
12
15
 
@@ -30,48 +33,26 @@
30
33
 
31
34
  ## Purpose
32
35
 
33
- Pentesting support tool. Can autonomously execute network penetration tests or assist with generic Capture The Flag (CTF) challenges (such as Reverse Engineering, Cryptography, and binary analysis) without requiring a specific network target.
36
+ Autonomous network penetration testing and CTF assistant. Supports offensive security workflows including recon, exploit, and post-exploitation.
34
37
 
35
38
  ## Quick Start
36
39
 
37
- ### z.ai GLM Coding Plan Max (Recommended)
38
-
39
- Web search is included in the subscription — **no separate Search API key required**.
40
-
41
- If you want the repository default start path, export your env vars locally and run:
42
-
43
- ```bash
44
- export PENTEST_API_KEY="your_z_ai_key"
45
- export PENTEST_BASE_URL="https://api.z.ai/api/anthropic"
46
- export PENTEST_MODEL="glm-4.7"
47
- npm run start
48
- ```
49
-
50
- `npm run start -- -t 10.10.10.5` passes CLI arguments through to the container entrypoint.
51
- Use `npm run start:local` only if you explicitly want the non-container Node runtime.
40
+ ### 🐳 Docker (Recommended)
52
41
 
53
42
  ```bash
54
43
  docker run -it --rm \
55
- -e PENTEST_API_KEY="your_z_ai_key" \
44
+ -e PENTEST_API_KEY="your_key" \
56
45
  -e PENTEST_BASE_URL="https://api.z.ai/api/anthropic" \
57
46
  -e PENTEST_MODEL="glm-4.7" \
58
47
  agnusdei1207/pentesting
59
48
  ```
60
49
 
61
- Enable container Tor mode by adding `-e PENTEST_TOR=true` to the same `docker run` command.
62
-
63
- ### External Search API (Optional)
64
-
65
- For providers other than z.ai, or to use a dedicated search backend.
50
+ ### 🐉 Kali Linux (Native)
66
51
 
67
52
  ```bash
68
- docker run -it --rm \
69
- -e PENTEST_API_KEY="your_api_key" \
70
- -e PENTEST_BASE_URL="https://open.bigmodel.cn/api/paas/v4" \
71
- -e PENTEST_MODEL="glm-4-plus" \
72
- -e SEARCH_API_KEY="your_brave_api_key" \
73
- -e SEARCH_API_URL="https://api.search.brave.com/res/v1/web/search" \
74
- agnusdei1207/pentesting
53
+ npm install -g pentesting
54
+ export PENTEST_API_KEY="your_key"
55
+ pentesting
75
56
  ```
76
57
 
77
58
  ### Environment Variables
@@ -79,38 +60,10 @@ docker run -it --rm \
79
60
  | Variable | Required | Description |
80
61
  |----------|----------|-------------|
81
62
  | `PENTEST_API_KEY` | ✅ | LLM API key |
82
- | `PENTEST_BASE_URL` | ❌ | Custom API endpoint (web search auto-enabled when URL contains `z.ai`) |
83
- | `PENTEST_MODEL` | ❌ | Model override (defaults depend on provider/runtime; examples use `glm-4.7`) |
84
- | `SEARCH_API_KEY` | ❌ | External search API key (not needed with z.ai) |
85
- | `SEARCH_API_URL` | ❌ | External search API URL (not needed with z.ai) |
86
- | `PENTEST_SCOPE_MODE` | ❌ | Scope mode override: `advisory` or `enforce` |
87
- | `PENTEST_APPROVAL_MODE` | ❌ | Approval mode override: `advisory` or `require_auto_approve` |
88
- | `PENTEST_TOR` | ❌ | Container-only Tor mode. When `true`, the Docker entrypoint starts Tor and launches the agent through `proxychains4` |
89
-
90
- Safety defaults:
91
-
92
- - Containerized runtime defaults to `PENTEST_SCOPE_MODE=advisory` and `PENTEST_APPROVAL_MODE=advisory`.
93
- - Non-container runtime defaults to `PENTEST_SCOPE_MODE=enforce` and `PENTEST_APPROVAL_MODE=require_auto_approve`.
94
- - Explicit env vars override those defaults.
95
-
96
- Tor notes:
97
-
98
- - Tor is supported only in the containerized runtime.
99
- - There is no in-app `/tor` toggle. Enable it at container startup with `-e PENTEST_TOR=true`.
100
- - Non-container runs ignore `PENTEST_TOR`, so local host execution stays on direct networking.
101
-
102
- ### Developer Verification
103
-
104
- ```bash
105
- npm run verify
106
- npm run verify:docker
107
- ```
108
-
109
- - `npm run verify` now runs typecheck, tests, and build.
110
- - `npm run verify:docker` builds the image and launches the Docker TUI path through `test.sh`.
111
- - `npm run check` prunes Docker state, runs tests and build, rebuilds the local image, and then launches the Docker TUI path.
112
- - `npm run check:clean` runs `npm run check:ci` after an explicit `docker system prune -af --volumes`.
113
-
63
+ | `PENTEST_BASE_URL` | ❌ | API endpoint (z.ai auto-enables web search) |
64
+ | `PENTEST_MODEL` | ❌ | Model (default: `glm-4.7`) |
65
+ | `SEARCH_API_KEY` | ❌ | External search key (not needed for z.ai) |
66
+ | `PENTEST_TOR` | ❌ | Enable Tor (`true`, Docker only) |
114
67
  ---
115
68
 
116
69
  ## Issue
@@ -134,124 +87,3 @@ we don't stop until the flag is captured.
134
87
  <br/>
135
88
 
136
89
  </div>
137
-
138
- ---
139
-
140
- ## Research References
141
-
142
- This section collects representative papers matched to the design themes reflected in `pentesting`.
143
-
144
- It is an inference-based reconstruction from topic overlap, not a verbatim personal reading log.
145
-
146
- ### Mapping
147
-
148
- - Offensive security agent papers inform the autonomous pentest workflow.
149
- - Planner-executor and heterogeneous collaboration papers inform task decomposition and coordination.
150
- - Multi-agent orchestration papers inform role separation, delegation, and control topology.
151
- - Benchmark and evaluation papers inform capability framing and validation strategy.
152
-
153
- ### Offensive Security Agents
154
-
155
- 1. [PentestGPT: Evaluating and Harnessing Large Language Models for Automated Penetration Testing](https://www.usenix.org/conference/usenixsecurity24/presentation/deng)
156
- USENIX Security 2024
157
- Relevance: autonomous pentest loop and operator-assist workflow.
158
-
159
- 2. [D-CIPHER: Dynamic Collaborative Intelligent Agents with Planning and Heterogeneous Execution for Enhanced Reasoning in Offensive Security](https://arxiv.org/abs/2502.10931)
160
- arXiv 2025
161
- Relevance: collaborative offensive agents, planning, and heterogeneous execution roles.
162
-
163
- 3. [Towards Automated Software Security Testing: Augmenting Penetration Testing through LLMs](https://conf.researchr.org/room/ssbse-2023/fse-2023-venue-golden-gate-c1)
164
- ESEC/FSE 2023
165
- Relevance: LLM-augmented penetration testing as a software engineering workflow.
166
-
167
- 4. [LLMs as Hackers: Autonomous Linux Privilege Escalation Attacks](https://arxiv.org/abs/2310.11409)
168
- arXiv 2023
169
- Relevance: offensive autonomy in post-exploitation and privilege escalation.
170
-
171
- 5. [Can LLMs Hack Enterprise Networks? Autonomous Assumed Breach Penetration-Testing Active Directory Networks](https://arxiv.org/abs/2502.04227)
172
- arXiv 2025
173
- Relevance: enterprise network movement and AD-focused agent behavior.
174
-
175
- 6. [LLM Agents can Autonomously Hack Websites](https://arxiv.org/abs/2402.06664)
176
- arXiv 2024
177
- Relevance: web exploitation agents and end-to-end task execution.
178
-
179
- 7. [LLM Agents can Autonomously Exploit One-day Vulnerabilities](https://arxiv.org/abs/2404.08144)
180
- arXiv 2024
181
- Relevance: exploit execution against known-vulnerability targets.
182
-
183
- 8. [Teams of LLM Agents can Exploit Zero-Day Vulnerabilities](https://arxiv.org/abs/2406.01637)
184
- arXiv 2024
185
- Relevance: multi-agent offensive workflows for harder vulnerability exploitation.
186
-
187
- 9. [AutoPentester: An LLM Agent-based Framework for Automated Pentesting](https://arxiv.org/abs/2510.05605)
188
- arXiv 2025
189
- Relevance: explicit automated pentesting framework alignment.
190
-
191
- ### Benchmarks and Cyber Evaluation
192
-
193
- 10. [AutoPenBench: A Vulnerability Testing Benchmark for Generative Agents](https://aclanthology.org/2025.emnlp-industry.114/)
194
- EMNLP Industry 2025
195
- Relevance: benchmark framing for generative vulnerability-testing agents.
196
-
197
- 11. [Training Language Model Agents to Find Vulnerabilities with CTF-Dojo](https://arxiv.org/abs/2508.18370)
198
- arXiv 2025
199
- Relevance: CTF-grounded vulnerability discovery and training/eval setup.
200
-
201
- 12. [Cybench: A Framework for Evaluating Cybersecurity Capabilities and Risks of Language Models](https://arxiv.org/abs/2408.08926)
202
- arXiv 2024
203
- Relevance: evaluation of cybersecurity capability and misuse risk.
204
-
205
- 13. [CyberGym: Evaluating AI Agents' Cybersecurity Capabilities with Real-World Vulnerabilities at Scale](https://arxiv.org/abs/2506.02548)
206
- arXiv 2025
207
- Relevance: large-scale realistic vulnerability evaluation.
208
-
209
- 14. [CyberSecEval 2: A Wide-Ranging Cybersecurity Evaluation Suite for Large Language Models](https://arxiv.org/abs/2404.13161)
210
- arXiv 2024
211
- Relevance: broad cyber eval framing and safety measurement.
212
-
213
- 15. [When LLMs Meet Cybersecurity: A Systematic Literature Review](https://arxiv.org/abs/2405.03644)
214
- arXiv 2024
215
- Relevance: survey grounding across offensive and defensive use cases.
216
-
217
- 16. [Large Language Models in Cybersecurity: State-of-the-Art](https://arxiv.org/abs/2402.00891)
218
- arXiv 2024
219
- Relevance: landscape overview for positioning the project.
220
-
221
- ### Multi-Agent Collaboration and Orchestration
222
-
223
- 17. [A Survey on Large Language Model based Autonomous Agents](https://arxiv.org/abs/2308.11432)
224
- arXiv 2023
225
- Relevance: agent architecture baseline and terminology.
226
-
227
- 18. [Large Language Model based Multi-Agents: A Survey of Progress and Challenges](https://arxiv.org/abs/2402.01680)
228
- arXiv 2024
229
- Relevance: multi-agent coordination patterns and failure modes.
230
-
231
- 19. [AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation](https://arxiv.org/abs/2308.08155)
232
- arXiv 2023
233
- Relevance: role-based dialogue and tool-using multi-agent orchestration.
234
-
235
- 20. [MetaGPT: Meta Programming for A Multi-Agent Collaborative Framework](https://arxiv.org/abs/2308.00352)
236
- arXiv 2023
237
- Relevance: structured role decomposition and pipeline-style collaboration.
238
-
239
- 21. [ChatDev: Communicative Agents for Software Development](https://aclanthology.org/2024.acl-long.810/)
240
- ACL 2024
241
- Relevance: communication protocol and software-task role separation.
242
-
243
- 22. [CAMEL: Communicative Agents for "Mind" Exploration of Large Language Model Society](https://arxiv.org/abs/2303.17760)
244
- arXiv 2023
245
- Relevance: agent role prompting and cooperative interaction patterns.
246
-
247
- 23. [AgentVerse: Facilitating Multi-Agent Collaboration and Exploring Emergent Behaviors](https://arxiv.org/abs/2308.10848)
248
- arXiv 2023
249
- Relevance: multi-agent environment framing and emergent collaboration.
250
-
251
- 24. [Scaling Large-Language-Model-based Multi-Agent Collaboration](https://arxiv.org/abs/2406.07155)
252
- arXiv 2024
253
- Relevance: scale behavior and coordination bottlenecks.
254
-
255
- 25. [Multi-Agent Collaboration via Evolving Orchestration](https://arxiv.org/abs/2505.19591)
256
- arXiv 2025
257
- Relevance: orchestration policy evolution and adaptive coordination.
@@ -5,7 +5,7 @@ import {
5
5
  createContextExtractor,
6
6
  getLLMClient,
7
7
  getShellSupervisorLifecycleSnapshot
8
- } from "./chunk-HSZZHAGX.js";
8
+ } from "./chunk-DN7INJ7C.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-26G2YIOA.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.8";
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-26G2YIOA.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-Y6CG5KRL.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
  }