pentesting 0.73.4 → 0.73.6

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.
@@ -0,0 +1,1144 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/shared/constants/system/process.ts
9
+ var EXIT_CODES = {
10
+ /** Successful execution */
11
+ SUCCESS: 0,
12
+ /** General error */
13
+ GENERAL_ERROR: 1,
14
+ /** Command not found */
15
+ COMMAND_NOT_FOUND: 127,
16
+ /** Process killed by SIGALRM (timeout) */
17
+ TIMEOUT: 124,
18
+ /** Process killed by SIGINT (Ctrl+C) */
19
+ SIGINT: 130,
20
+ /** Process killed by SIGTERM */
21
+ SIGTERM: 143,
22
+ /** Process killed by SIGKILL */
23
+ SIGKILL: 137,
24
+ /** Invalid or missing configuration (Unix EX_CONFIG convention = 78) */
25
+ CONFIG_ERROR: 78
26
+ };
27
+ var PROCESS_ACTIONS = {
28
+ LIST: "list",
29
+ STATUS: "status",
30
+ INTERACT: "interact",
31
+ PROMOTE: "promote",
32
+ STOP: "stop",
33
+ STOP_ALL: "stop_all"
34
+ };
35
+ var PROCESS_ROLES = {
36
+ LISTENER: "listener",
37
+ ACTIVE_SHELL: "active_shell",
38
+ SERVER: "server",
39
+ SNIFFER: "sniffer",
40
+ SPOOFER: "spoofer",
41
+ CALLBACK: "callback",
42
+ PROXY: "proxy",
43
+ BACKGROUND: "background"
44
+ };
45
+ var PROCESS_ICONS = {
46
+ [PROCESS_ROLES.LISTENER]: "[LISTENER]",
47
+ [PROCESS_ROLES.ACTIVE_SHELL]: "[SHELL]",
48
+ [PROCESS_ROLES.SERVER]: "[SERVER]",
49
+ [PROCESS_ROLES.SNIFFER]: "[SNIFFER]",
50
+ [PROCESS_ROLES.SPOOFER]: "[SPOOFER]",
51
+ [PROCESS_ROLES.CALLBACK]: "[CALLBACK]",
52
+ [PROCESS_ROLES.PROXY]: "[PROXY]",
53
+ [PROCESS_ROLES.BACKGROUND]: "[BG]"
54
+ };
55
+ var STATUS_MARKERS = {
56
+ RUNNING: "[RUNNING]",
57
+ STOPPED: "[STOPPED]",
58
+ WARNING: "[WARNING]",
59
+ INFO: "[INFO]",
60
+ INTERACTIVE: "[INTERACTIVE]",
61
+ EXITED: "[EXITED]"
62
+ };
63
+ var PROCESS_EVENTS = {
64
+ STARTED: "started",
65
+ CONNECTION_DETECTED: "connection_detected",
66
+ ROLE_CHANGED: "role_changed",
67
+ COMMAND_SENT: "command_sent",
68
+ SHELL_STABILITY_CHECKED: "shell_stability_checked",
69
+ SHELL_STABILITY_INCOMPLETE: "shell_stability_incomplete",
70
+ SHELL_UPGRADE_ATTEMPTED: "shell_upgrade_attempted",
71
+ SHELL_STABILIZED: "shell_stabilized",
72
+ POST_EXPLOITATION_ACTIVITY: "post_exploitation_activity",
73
+ STOPPED: "stopped",
74
+ DIED: "died",
75
+ ZOMBIE_CLEANED: "zombie_cleaned"
76
+ };
77
+ var PROCESS_LIMITS = {
78
+ GRACEFUL_SHUTDOWN_WAIT_MS: 200,
79
+ OUTPUT_TRUNCATION_LIMIT: 1e4
80
+ // characters
81
+ };
82
+
83
+ // src/agents/runtime-config/llm-runtime.ts
84
+ function defineRuntimeNode(node) {
85
+ return node;
86
+ }
87
+ var RUNTIME_CONFIG_LLM_NODES = {
88
+ input_processor: {
89
+ role: "\uC785\uB825 \uC804\uCC98\uB9AC \u2014 direct response / main forward / policy merge",
90
+ system_prompt_file: "src/agents/prompts/llm/input-processor-system.md",
91
+ reads: [
92
+ "user_input.raw",
93
+ ".pentesting/memory/policy.md"
94
+ ],
95
+ writes: [
96
+ "memory.input_processing"
97
+ ]
98
+ },
99
+ strategist: {
100
+ role: "\uC804\uC220 \uC9C0\uC2DC \uC0DD\uC131 \u2014 \uB9E4 pre-step, \uCFE8\uB2E4\uC6B4 \uC815\uCC45\uC73C\uB85C \uCE90\uC2DC",
101
+ system_prompt_file: "src/agents/prompts/strategist-system.md",
102
+ fallback_system_prompt_file: "src/agents/prompts/llm/strategist-fallback.md",
103
+ reads: [
104
+ "state.phase",
105
+ "state.targets",
106
+ "state.findings",
107
+ "state.workingMemory",
108
+ "state.attackGraph"
109
+ ],
110
+ writes: [
111
+ "prompt_fragment.strategist_directive"
112
+ ],
113
+ cooldown_policy: {
114
+ cache_ttl_ms: 18e4,
115
+ stall_turns_threshold: 2,
116
+ triggers: [
117
+ "no_cached_directive",
118
+ "phase_changed",
119
+ "stall_detected",
120
+ "cache_ttl_expired"
121
+ ],
122
+ on_cache_hit: "reuse_previous"
123
+ }
124
+ },
125
+ main_llm: {
126
+ role: "\uCD94\uB860 + \uB3C4\uAD6C \uC0AC\uC6A9 \u2014 CoreAgent.step \uB9E4 iteration",
127
+ system_prompt: "prompt_builder",
128
+ model_role: "orchestrator",
129
+ reads: [
130
+ "messages[]",
131
+ "system_prompt"
132
+ ],
133
+ writes: [
134
+ "messages[] (append)",
135
+ "tool_calls",
136
+ ".pentesting/workspace/tools/"
137
+ ],
138
+ limits: {
139
+ max_tokens: 128e3,
140
+ max_prompt_chars: 4e5
141
+ }
142
+ },
143
+ analyst: {
144
+ role: "\uB3C4\uAD6C \uCD9C\uB825 \uC18C\uD654 \u2014 \uB3C4\uAD6C \uC2E4\uD589 \uC9C1\uD6C4 \uC778\uB77C\uC778 \uD638\uCD9C",
145
+ trigger: "per_tool_call",
146
+ system_prompt_file: "src/agents/prompts/llm/analyst-system.md",
147
+ reads: [
148
+ "tool.raw_output",
149
+ "tool.name",
150
+ "state.phase"
151
+ ],
152
+ writes: [
153
+ "tool_journal[].analystSummary (in-memory, append)"
154
+ ],
155
+ on_failure: "empty_summary"
156
+ },
157
+ context_extractor: {
158
+ role: "\uB300\uD654 \uC555\uCD95 \u2014 \uB9E4 post-step, messages[] \uAD50\uCCB4",
159
+ trigger: "post_step",
160
+ input_formatter: "format_for_extraction",
161
+ system_prompt_file: "src/agents/prompts/llm/context-extractor-system.md",
162
+ reads: [
163
+ "messages"
164
+ ],
165
+ writes: {
166
+ memory: "extracted_context"
167
+ },
168
+ output_handling: {
169
+ wrap: "<session-context>\n{value}\n</session-context>",
170
+ write_target: "messages[]",
171
+ write_mode: "replace_all",
172
+ on_failure: "keep_existing"
173
+ }
174
+ },
175
+ reflector: {
176
+ role: "\uD134 \uC790\uAE30\uD3C9\uAC00 \u2014 \uB9E4 post-step, state.lastReflection\uC5D0 \uC800\uC7A5",
177
+ trigger: "post_step",
178
+ input_formatter: "format_reflection_input",
179
+ system_prompt_file: "src/agents/prompts/llm/reflector-system.md",
180
+ reads: [
181
+ "tools",
182
+ "memo",
183
+ "phase"
184
+ ],
185
+ writes: {
186
+ memory: "reflection"
187
+ },
188
+ output_handling: {
189
+ extract_field: "reflection",
190
+ write_target: "state.lastReflection",
191
+ write_mode: "overwrite",
192
+ inject_as: "<last-turn-review>\n{value}\n</last-turn-review>",
193
+ on_failure: "empty_string"
194
+ }
195
+ },
196
+ memory_synth: {
197
+ role: "\uD134 \uBA54\uBAA8\uB9AC \uC791\uC131 \u2014 \uB9E4 \uD134 turn-recorder\uC5D0\uC11C \uD638\uCD9C",
198
+ trigger: "after_turn_recorded",
199
+ input_format: 'Previous insight:\\n{existing_summary}\\n\\nCurrent turn:\\n{turn_data}\n# \uCCAB \uD134: "First turn data:\\n{turn_data}"\n',
200
+ system_prompt_file: "src/agents/prompts/llm/memory-synth-system.md",
201
+ reads: [
202
+ "previous_insight",
203
+ "current_turn_data"
204
+ ],
205
+ writes: {
206
+ disk: {
207
+ path: ".pentesting/turns/{N}-memory.md",
208
+ write_mode: "overwrite"
209
+ }
210
+ },
211
+ on_failure: "fallback_concat"
212
+ },
213
+ playbook_synthesizer: {
214
+ role: "\uACF5\uACA9 \uD328\uD134 \uCD94\uCD9C \u2014 SUCCEEDED \uB178\uB4DC >= N \uC2DC \uC870\uAC74\uBD80 \uC2E4\uD589",
215
+ trigger: "conditional",
216
+ condition: "has_exploit_chain",
217
+ min_succeeded_nodes: 2,
218
+ system_prompt_file: "src/agents/prompts/llm/playbook-synthesizer-system.md",
219
+ input_format: "SERVICE PROFILE: {service_profile}\n\nSUCCEEDED ATTACK NODES:\n{node_lines}\n\nATTACK ACTIONS (edges):\n{edge_actions} (max 8 items)\n\nEXISTING SUMMARY (regex-based, for reference): {existing_chain_summary}\n",
220
+ reads: [
221
+ "attack_graph.succeeded_nodes",
222
+ "attack_graph.succeeded_edges",
223
+ "attack_graph.service_profile",
224
+ "attack_graph.existing_chain_summary"
225
+ ],
226
+ output_parsing: {
227
+ skip_if: "SKIP",
228
+ max_chars: 120
229
+ },
230
+ writes: {
231
+ disk: {
232
+ path: ".pentesting/memory/persistent-knowledge.json",
233
+ write_mode: "merge"
234
+ }
235
+ },
236
+ on_failure: "skip"
237
+ },
238
+ report_generator: {
239
+ role: "\uBCF4\uACE0\uC11C \uC0DD\uC131 \u2014 \uC0AC\uC6A9\uC790 \uC694\uCCAD \uC2DC on-demand",
240
+ trigger: "on_demand",
241
+ system_prompt_file: "src/agents/prompts/llm/report-generator-system.md",
242
+ input_format: "Mission Summary:\\n{mission_summary}\\n\\nFindings (Sorted by Severity):\\n{json_findings}\n",
243
+ input_sorting: "severity_descending",
244
+ reads: [
245
+ "state.findings",
246
+ "state.currentObjective"
247
+ ],
248
+ writes: {
249
+ disk: {
250
+ path: ".pentesting/reports/{timestamp}-report.md",
251
+ write_mode: "overwrite"
252
+ }
253
+ },
254
+ on_failure: {
255
+ fallback_content: "# Fallback Report\nFailed to generate full report. Review raw findings in the workspace.\n"
256
+ }
257
+ },
258
+ triager: {
259
+ role: "\uD134 \uACB0\uACFC \uC6B0\uC120\uC21C\uC704 \uBD84\uB958 \u2014 \uB3C4\uAD6C \uC2E4\uD589 \uC9C1\uD6C4, Reflector \uC804 \uD638\uCD9C",
260
+ trigger: "post_tool_execution",
261
+ system_prompt_file: "src/agents/prompts/llm/triage-system.md",
262
+ reads: [
263
+ "tools",
264
+ "phase",
265
+ "state.lastTriageMemo"
266
+ ],
267
+ writes: {
268
+ memory: "triage_result"
269
+ },
270
+ output_handling: {
271
+ extract_field: "triage",
272
+ write_target: "state.lastTriageMemo",
273
+ write_mode: "overwrite",
274
+ inject_as: "<triage-memo>\n{value}\n</triage-memo>",
275
+ on_failure: "empty_string"
276
+ }
277
+ }
278
+ };
279
+ var RUNTIME_CONFIG_TURN_CYCLE = {
280
+ serial: [
281
+ "process_user_input",
282
+ {
283
+ when: {
284
+ condition: "should_forward_to_main"
285
+ },
286
+ then: {
287
+ serial: [
288
+ "strategist",
289
+ "build_system_prompt",
290
+ "core_inference",
291
+ {
292
+ when: {
293
+ condition: "has_tool_calls"
294
+ },
295
+ then: "core_tool_execution"
296
+ }
297
+ ]
298
+ }
299
+ },
300
+ {
301
+ when: {
302
+ condition: "has_tool_calls"
303
+ },
304
+ then: "triager"
305
+ },
306
+ {
307
+ when: {
308
+ condition: "has_tool_calls"
309
+ },
310
+ then: "save_triage"
311
+ },
312
+ "verify_turn",
313
+ "reflector",
314
+ "context_extractor",
315
+ {
316
+ parallel: [
317
+ "save_reflection",
318
+ "finalize_context"
319
+ ]
320
+ },
321
+ {
322
+ when: {
323
+ condition: "has_exploit_chain",
324
+ min_succeeded: 2
325
+ },
326
+ then: "playbook_synthesizer"
327
+ },
328
+ "write_insight",
329
+ "rotate_turns",
330
+ "save_session"
331
+ ]
332
+ };
333
+ var RUNTIME_CONFIG_NODES = {
334
+ process_user_input: defineRuntimeNode({
335
+ type: "action",
336
+ handler: "process_user_input",
337
+ log_as: "\u24EAInputProcessor \u2192 forward/policy/direct-response"
338
+ }),
339
+ build_system_prompt: defineRuntimeNode({
340
+ type: "action",
341
+ handler: "build_system_prompt",
342
+ log_as: "\u2460PromptBuilder \u2192 messages"
343
+ }),
344
+ core_inference: defineRuntimeNode({
345
+ type: "action",
346
+ handler: "core_inference",
347
+ log_as: "\u2461MainLLM \u2192 tool_calls"
348
+ }),
349
+ core_tool_execution: defineRuntimeNode({
350
+ type: "action",
351
+ handler: "core_tool_execution",
352
+ log_as: "\u2462ToolExecutor \u2192 output"
353
+ }),
354
+ context_extractor: defineRuntimeNode({
355
+ type: "llm",
356
+ class: "context_extractor",
357
+ input_formatter: "format_for_extraction",
358
+ reads: [
359
+ "messages"
360
+ ],
361
+ writes: {
362
+ memory: "extracted_context"
363
+ }
364
+ }),
365
+ reflector: defineRuntimeNode({
366
+ type: "llm",
367
+ class: "reflector",
368
+ input_formatter: "format_reflection_input",
369
+ reads: [
370
+ "tools",
371
+ "memo",
372
+ "phase",
373
+ "triageMemo"
374
+ ],
375
+ writes: {
376
+ memory: "reflection"
377
+ }
378
+ }),
379
+ strategist: defineRuntimeNode({
380
+ type: "llm",
381
+ class: "strategist",
382
+ reads: [
383
+ "state"
384
+ ],
385
+ writes: {
386
+ memory: "strategist_directive"
387
+ },
388
+ log_as: "\u2460Strategist \u2192 ctx.memory.strategist_directive"
389
+ }),
390
+ triager: defineRuntimeNode({
391
+ type: "llm",
392
+ class: "triager",
393
+ input_formatter: "format_triage_input",
394
+ reads: [
395
+ "tools",
396
+ "phase",
397
+ "previousTriage"
398
+ ],
399
+ writes: {
400
+ memory: "triage_result"
401
+ },
402
+ log_as: "\u2467Triager \u2192 ctx.memory.triage_result"
403
+ }),
404
+ save_triage: defineRuntimeNode({
405
+ type: "action",
406
+ handler: "write_field_to_state",
407
+ config: {
408
+ from: "memory.triage_result",
409
+ field: "triage",
410
+ target: "state.lastTriageMemo",
411
+ write_mode: "overwrite"
412
+ },
413
+ log_as: "\u2467Triager \u2192 state.lastTriageMemo"
414
+ }),
415
+ verify_turn: defineRuntimeNode({
416
+ type: "action",
417
+ handler: "verify_turn",
418
+ log_as: "Verifier \u2192 ctx.memory.turn_verifier_report"
419
+ }),
420
+ save_reflection: defineRuntimeNode({
421
+ type: "action",
422
+ handler: "write_field_to_state",
423
+ config: {
424
+ from: "memory.reflection",
425
+ field: "reflection",
426
+ target: "state.lastReflection",
427
+ write_mode: "overwrite"
428
+ },
429
+ log_as: "\u2464Reflector \u2192 state.lastReflection"
430
+ }),
431
+ finalize_context: defineRuntimeNode({
432
+ type: "action",
433
+ handler: "replace_messages_from_memory",
434
+ config: {
435
+ from: "memory.extracted_context",
436
+ field: "extractedContext",
437
+ wrap: "<session-context>\n{value}\n</session-context>",
438
+ write_mode: "replace_all"
439
+ },
440
+ log_as: "\u2463ContextExtractor \u2192 messages REPLACED"
441
+ }),
442
+ playbook_synthesizer: defineRuntimeNode({
443
+ type: "action",
444
+ handler: "synthesize_playbook",
445
+ config: {
446
+ min_succeeded_nodes: 2
447
+ },
448
+ reads: [
449
+ "attack_graph.succeeded"
450
+ ],
451
+ writes: {
452
+ disk: {
453
+ path: ".pentesting/memory/persistent-knowledge.json",
454
+ write_mode: "merge"
455
+ }
456
+ },
457
+ log_as: "\u2466PlaybookSynth \u2192 .pentesting/memory/persistent-knowledge.json"
458
+ }),
459
+ write_insight: defineRuntimeNode({
460
+ type: "action",
461
+ handler: "write_insight"
462
+ }),
463
+ rotate_turns: defineRuntimeNode({
464
+ type: "action",
465
+ handler: "rotate_turns"
466
+ }),
467
+ save_session: defineRuntimeNode({
468
+ type: "action",
469
+ handler: "save_session"
470
+ })
471
+ };
472
+ var RUNTIME_CONFIG_USER_INPUT_QUEUE = {
473
+ format: "tagged",
474
+ tag: "user-input",
475
+ inject_position: "messages_end"
476
+ };
477
+
478
+ // src/agents/runtime-config/prompt-runtime.ts
479
+ function definePromptLayer(layer) {
480
+ return layer;
481
+ }
482
+ var RUNTIME_CONFIG_PROMPT_BUILDER = {
483
+ max_chars: 4e5,
484
+ truncation: "back",
485
+ preserved_last: "user_context",
486
+ layers: [
487
+ definePromptLayer({
488
+ id: 1,
489
+ type: "file",
490
+ source: "src/agents/prompts/base.md",
491
+ label: "core_identity"
492
+ }),
493
+ definePromptLayer({
494
+ id: 1.5,
495
+ type: "file",
496
+ source: "src/agents/prompts/main-agent.md",
497
+ label: "delegation_and_tactics"
498
+ }),
499
+ definePromptLayer({
500
+ id: 2,
501
+ type: "file",
502
+ source: "src/agents/prompts/offensive-playbook.md",
503
+ label: "offensive_playbook"
504
+ }),
505
+ definePromptLayer({
506
+ id: 3,
507
+ type: "file_phase_mapped",
508
+ mapping: "prompt_sources.phase_prompts",
509
+ label: "phase_specialist"
510
+ }),
511
+ definePromptLayer({
512
+ id: 4,
513
+ type: "state",
514
+ source: "state.scope",
515
+ label: "scope_constraints",
516
+ format: "<scope>\n allowed-cidrs: {cidrs}\n allowed-domains: {domains}\n exclusions: {exclusions}\n flags: DOS={is_dos_allowed} | Social={is_social_allowed}\n</scope>\n",
517
+ on_empty: "No scope defined \u2014 treat all discovered hosts as in-scope."
518
+ }),
519
+ definePromptLayer({
520
+ id: 5,
521
+ type: "state",
522
+ source: "state.todo",
523
+ label: "todo_list",
524
+ filter: "status != DONE",
525
+ format_item: "[{status_symbol}] {content} ({priority})"
526
+ }),
527
+ definePromptLayer({
528
+ id: 6,
529
+ type: "state",
530
+ source: "state.time",
531
+ label: "time_status",
532
+ format: '<time-status>{time_status}</time-status>\n<time-strategy phase="{phase}" urgency="{urgency}">{directive}</time-strategy>\n'
533
+ }),
534
+ definePromptLayer({
535
+ id: 7,
536
+ type: "memory",
537
+ source: "memory.strategist_directive",
538
+ label: "strategist_directive",
539
+ on_empty: "skip"
540
+ }),
541
+ definePromptLayer({
542
+ id: 7.5,
543
+ type: "file_read",
544
+ source: ".pentesting/memory/policy.md",
545
+ label: "policy_memory",
546
+ wrap: "<policy-memory>\n{content}\n</policy-memory>",
547
+ on_missing: "skip"
548
+ }),
549
+ definePromptLayer({
550
+ id: 8,
551
+ type: "file_read",
552
+ source: ".pentesting/turns/{N-1}-memory.md",
553
+ label: "session_journal",
554
+ format: "<session-journal>\n{content}\n</session-journal>",
555
+ on_missing: "skip"
556
+ }),
557
+ definePromptLayer({
558
+ id: 9,
559
+ type: "state",
560
+ source: "state.serialized",
561
+ label: "current_state",
562
+ format: "<current-state>\n{content}\n</current-state>"
563
+ }),
564
+ definePromptLayer({
565
+ id: 10,
566
+ type: "state",
567
+ source: "state.workingMemory",
568
+ label: "working_memory"
569
+ }),
570
+ definePromptLayer({
571
+ id: 11,
572
+ type: "state",
573
+ source: "state.challengeAnalysis",
574
+ label: "challenge_analysis",
575
+ on_empty: "skip"
576
+ }),
577
+ definePromptLayer({
578
+ id: 12,
579
+ type: "state",
580
+ source: "state.attackGraph",
581
+ label: "attack_graph"
582
+ }),
583
+ definePromptLayer({
584
+ id: 13,
585
+ type: "static",
586
+ label: "blind_spots_guidelines",
587
+ content: "<blind-spots-guidelines>\nWhen writing your mandatory <critical-reflection> before acting, ensure you evaluate:\n\na) Are there services/ports discovered but NOT yet tested?\nb) Have credentials/tokens been found but NOT sprayed on other services?\nc) Is there a SIMPLER explanation? (misconfiguration vs complex vuln)\nd) Are you drilling too deep while ignoring other viable attack surfaces?\ne) Could a custom script (Python/bash) accomplish what tool attempts have failed to do?\nf) Are there findings from PREVIOUS turns noted but not followed up on?\ng) What would an experienced human tester try RIGHT now?\n\nCRITICAL: You MUST explicitly acknowledge and accept any warnings or Pivot directions.\n</blind-spots-guidelines>\n"
588
+ }),
589
+ definePromptLayer({
590
+ id: 14,
591
+ type: "state",
592
+ source: "state.lastReflection",
593
+ label: "last_turn_review",
594
+ format: "<last-turn-review>\n{value}\n</last-turn-review>",
595
+ written_by: "reflector",
596
+ on_empty: "skip"
597
+ }),
598
+ definePromptLayer({
599
+ id: "14_triage",
600
+ type: "state",
601
+ source: "state.lastTriageMemo",
602
+ label: "triage_memo",
603
+ format: "<triage-memo>\n{value}\n</triage-memo>",
604
+ written_by: "triager",
605
+ on_empty: "skip"
606
+ }),
607
+ definePromptLayer({
608
+ id: 15,
609
+ type: "state",
610
+ source: "state.episodicMemory",
611
+ label: "episodic_memory"
612
+ }),
613
+ definePromptLayer({
614
+ id: 16,
615
+ type: "state",
616
+ source: "state.dynamicTechniques",
617
+ label: "dynamic_techniques",
618
+ pruning: "confidence < 10"
619
+ }),
620
+ definePromptLayer({
621
+ id: 16.5,
622
+ type: "state",
623
+ source: "state.persistentMemory",
624
+ label: "persistent_memory",
625
+ on_empty: "skip"
626
+ }),
627
+ definePromptLayer({
628
+ id: 17,
629
+ type: "files",
630
+ sources: "prompt_sources.core_knowledge",
631
+ label: "core_knowledge",
632
+ exclude_current_phase_file: true,
633
+ wrap: '<reference-knowledge area="{label}">\n{content}\n</reference-knowledge>'
634
+ }),
635
+ definePromptLayer({
636
+ id: 18,
637
+ type: "files_phase_mapped",
638
+ mapping: "prompt_sources.phase_techniques",
639
+ label: "phase_techniques",
640
+ base_dir: "src/agents/prompts/techniques/",
641
+ wrap: '<technique-reference category="{name}">\n{content}\n</technique-reference>'
642
+ }),
643
+ definePromptLayer({
644
+ id: 19,
645
+ type: "state",
646
+ source: "state.targets_ports",
647
+ label: "attack_intelligence",
648
+ format: "<service-inventory>\nDiscovered services \u2014 use get_owasp_knowledge, web_search, or get_web_attack_surface for attack ideas:\n{lines}\n</service-inventory>\n"
649
+ }),
650
+ definePromptLayer({
651
+ id: 20,
652
+ type: "user_input",
653
+ label: "user_context",
654
+ always_included: true
655
+ })
656
+ ]
657
+ };
658
+ var RUNTIME_CONFIG_PROMPT_SOURCES = {
659
+ base_dir: "src/agents/prompts/",
660
+ always: [
661
+ "base.md",
662
+ "offensive-playbook.md"
663
+ ],
664
+ phase_prompts: {
665
+ recon: "recon.md",
666
+ vulnerability_analysis: "vuln.md",
667
+ exploit: "exploit.md",
668
+ web: "web.md",
669
+ post_exploitation: "post.md",
670
+ privilege_escalation: "post.md",
671
+ lateral_movement: "post.md",
672
+ persistence: "post.md",
673
+ exfiltration: "post.md",
674
+ report: "report.md",
675
+ pwn: "ctf-pwn.md",
676
+ crypto: "ctf-crypto.md",
677
+ forensics: "ctf-forensics.md"
678
+ },
679
+ core_knowledge: [
680
+ "strategy.md",
681
+ "evasion.md",
682
+ "zero-day.md",
683
+ "payload-craft.md",
684
+ "infra.md"
685
+ ],
686
+ techniques_dir: "src/agents/prompts/techniques/",
687
+ phase_techniques: {
688
+ recon: [
689
+ "network-svc.md",
690
+ "shells.md",
691
+ "crypto.md",
692
+ "auth-access.md"
693
+ ],
694
+ vulnerability_analysis: [
695
+ "injection.md",
696
+ "network-svc.md",
697
+ "auth-access.md",
698
+ "file-attacks.md",
699
+ "crypto.md",
700
+ "reversing.md"
701
+ ],
702
+ exploit: [
703
+ "injection.md",
704
+ "auth-access.md",
705
+ "shells.md",
706
+ "file-attacks.md",
707
+ "network-svc.md",
708
+ "pwn.md",
709
+ "container-escape.md",
710
+ "sandbox-escape.md",
711
+ "reversing.md"
712
+ ],
713
+ post_exploitation: [
714
+ "privesc.md",
715
+ "lateral.md",
716
+ "auth-access.md",
717
+ "shells.md",
718
+ "container-escape.md",
719
+ "sandbox-escape.md",
720
+ "forensics.md",
721
+ "pivoting.md",
722
+ "enterprise-pentest.md"
723
+ ],
724
+ privilege_escalation: [
725
+ "privesc.md",
726
+ "auth-access.md",
727
+ "shells.md",
728
+ "pwn.md",
729
+ "container-escape.md",
730
+ "sandbox-escape.md"
731
+ ],
732
+ lateral_movement: [
733
+ "lateral.md",
734
+ "ad-attack.md",
735
+ "auth-access.md",
736
+ "container-escape.md",
737
+ "network-svc.md",
738
+ "pivoting.md",
739
+ "enterprise-pentest.md"
740
+ ],
741
+ persistence: [
742
+ "shells.md",
743
+ "privesc.md",
744
+ "lateral.md",
745
+ "enterprise-pentest.md"
746
+ ],
747
+ exfiltration: [
748
+ "lateral.md",
749
+ "network-svc.md",
750
+ "forensics.md"
751
+ ],
752
+ web: [
753
+ "injection.md",
754
+ "file-attacks.md",
755
+ "auth-access.md",
756
+ "crypto.md",
757
+ "shells.md",
758
+ "network-svc.md"
759
+ ],
760
+ report: [],
761
+ pwn: [
762
+ "pwn.md",
763
+ "reversing.md",
764
+ "shells.md"
765
+ ],
766
+ crypto: [
767
+ "crypto.md",
768
+ "reversing.md"
769
+ ],
770
+ forensics: [
771
+ "forensics.md",
772
+ "reversing.md",
773
+ "network-svc.md"
774
+ ]
775
+ },
776
+ strategist_system: "src/agents/prompts/strategist-system.md"
777
+ };
778
+
779
+ // src/agents/runtime-config/ops-runtime.ts
780
+ var RUNTIME_CONFIG_LIMITS = {
781
+ archive: {
782
+ max_turn_entries: 50,
783
+ eviction: "delete_oldest_first"
784
+ },
785
+ messages: {
786
+ context_extractor_per_msg_limit: 3e4,
787
+ truncation_direction: "back"
788
+ },
789
+ prompt: {
790
+ max_chars: 4e5,
791
+ truncation_direction: "back",
792
+ preserved_last: "user_context"
793
+ },
794
+ tool_output: {
795
+ max_chars: 2e5
796
+ },
797
+ agent_loop: {
798
+ max_iterations: 500,
799
+ max_consecutive_idle: 3,
800
+ max_consecutive_llm_errors: "infinity",
801
+ max_retries: 3,
802
+ periodic_report_every_n_turns: 10,
803
+ max_session_files: 10
804
+ },
805
+ state: {
806
+ max_findings: 500,
807
+ max_loot: 200,
808
+ max_action_log: 200,
809
+ max_attack_nodes: 300,
810
+ max_attack_edges: 1e3,
811
+ max_failed_paths: 100,
812
+ working_memory_max: 20,
813
+ episodic_memory_max: 100,
814
+ dynamic_techniques_max: 50,
815
+ technique_failure_decay: 30,
816
+ technique_prune_threshold: 10,
817
+ consecutive_fail_threshold: 3
818
+ }
819
+ };
820
+ var RUNTIME_CONFIG_COMPRESSION = {
821
+ messages: {
822
+ strategy: "llm_compress",
823
+ trigger: "every_turn",
824
+ agent: "context_extractor",
825
+ per_msg_max_chars: 3e4,
826
+ output_format: "<session-context>\n{value}\n</session-context>",
827
+ write_mode: "replace_all",
828
+ on_failure: "keep_existing"
829
+ },
830
+ session_summary: {
831
+ strategy: "llm_progressive",
832
+ trigger: "every_turn",
833
+ agent: "memory_synth",
834
+ input: [
835
+ "previous_insight",
836
+ "current_turn_data"
837
+ ],
838
+ output_path: ".pentesting/turns/{N}-memory.md",
839
+ write_mode: "overwrite",
840
+ on_failure: "fallback_concat"
841
+ },
842
+ deterministic_summary_buckets: [
843
+ "techniques_tried",
844
+ "suspicious_signals",
845
+ "key_findings",
846
+ "credentials",
847
+ "successful_vectors",
848
+ "failure_causes",
849
+ "next_recommendations"
850
+ ],
851
+ archive: {
852
+ strategy: "count_based_rotation",
853
+ max_turns: 50,
854
+ eviction: "delete_oldest_first",
855
+ trigger: "after_each_turn"
856
+ },
857
+ debug_log: {
858
+ strategy: "size_based_rotation",
859
+ rotate_at_mb: 5,
860
+ rotate_mode: "keep_latest_half",
861
+ wipe_at_mb: 20,
862
+ wipe_mode: "truncate_all"
863
+ },
864
+ dynamic_techniques: {
865
+ strategy: "confidence_based_pruning",
866
+ max_entries: 50,
867
+ prune_threshold: 10,
868
+ failure_decay: 30
869
+ }
870
+ };
871
+ var RUNTIME_CONFIG_WORKSPACE = {
872
+ root: ".pentesting/",
873
+ directories: {
874
+ turns: ".pentesting/turns/",
875
+ workspace: ".pentesting/workspace/",
876
+ sessions: ".pentesting/sessions/",
877
+ memory: ".pentesting/memory/",
878
+ reports: ".pentesting/reports/",
879
+ loot: ".pentesting/loot/",
880
+ debug: ".pentesting/debug/"
881
+ },
882
+ turn_structure: {
883
+ insight: {
884
+ file: "{N}-memory.md",
885
+ write_mode: "overwrite",
886
+ written_by: "memory_synth",
887
+ content: "core_insights_only",
888
+ metadata: {
889
+ file_kind: "turn_memory",
890
+ includes: [
891
+ "written_by",
892
+ "input_sources",
893
+ "notes_included",
894
+ "generated_at"
895
+ ]
896
+ }
897
+ }
898
+ },
899
+ persistent_files: {
900
+ session: {
901
+ path: ".pentesting/sessions/latest.json",
902
+ write_mode: "overwrite",
903
+ rotation: {
904
+ strategy: "keep_latest_N",
905
+ max_files: 10
906
+ }
907
+ },
908
+ knowledge: {
909
+ path: ".pentesting/memory/persistent-knowledge.json",
910
+ write_mode: "merge",
911
+ written_by: "playbook_synthesizer"
912
+ },
913
+ debug_log: {
914
+ path: ".pentesting/debug/debug.log",
915
+ write_mode: "append",
916
+ rotation: {
917
+ strategy: "size_based",
918
+ rotate_at_mb: 5,
919
+ wipe_at_mb: 20
920
+ }
921
+ }
922
+ }
923
+ };
924
+ var RUNTIME_CONFIG_TUI = {
925
+ transcript: {
926
+ max_visible_turns: 6
927
+ }
928
+ };
929
+
930
+ // src/agents/runtime-config.ts
931
+ var RUNTIME_CONFIG = {
932
+ version: "3.2",
933
+ llm_nodes: RUNTIME_CONFIG_LLM_NODES,
934
+ turn_cycle: RUNTIME_CONFIG_TURN_CYCLE,
935
+ prompt_builder: RUNTIME_CONFIG_PROMPT_BUILDER,
936
+ prompt_sources: RUNTIME_CONFIG_PROMPT_SOURCES,
937
+ limits: RUNTIME_CONFIG_LIMITS,
938
+ compression: RUNTIME_CONFIG_COMPRESSION,
939
+ workspace: RUNTIME_CONFIG_WORKSPACE,
940
+ tui: RUNTIME_CONFIG_TUI,
941
+ nodes: RUNTIME_CONFIG_NODES,
942
+ user_input_queue: RUNTIME_CONFIG_USER_INPUT_QUEUE
943
+ };
944
+
945
+ // src/agents/pipeline-config.ts
946
+ var _config = null;
947
+ function getPipelineConfig() {
948
+ if (_config) return _config;
949
+ _config = RUNTIME_CONFIG;
950
+ return _config;
951
+ }
952
+
953
+ // src/agents/runtime-config-sections.ts
954
+ var RUNTIME_CONFIG_SOURCE_PATH = "src/agents/runtime-config.ts";
955
+ function buildMissingSectionError(sectionName) {
956
+ return new Error(
957
+ `[runtime-config] ${String(sectionName)} section is required but not found. Add it to ${RUNTIME_CONFIG_SOURCE_PATH}.`
958
+ );
959
+ }
960
+ function getOptionalRuntimeSection(sectionName) {
961
+ return getPipelineConfig()[sectionName];
962
+ }
963
+ function getRequiredRuntimeSection(sectionName) {
964
+ const section = getOptionalRuntimeSection(sectionName);
965
+ if (section === void 0 || section === null) {
966
+ throw buildMissingSectionError(sectionName);
967
+ }
968
+ return section;
969
+ }
970
+ function getRuntimeSectionOr(sectionName, fallback) {
971
+ return getOptionalRuntimeSection(sectionName) ?? fallback;
972
+ }
973
+
974
+ // src/agents/limits-config.ts
975
+ function getLimits() {
976
+ return getRequiredRuntimeSection("limits");
977
+ }
978
+
979
+ // src/shared/constants/system/limits.ts
980
+ var _msgLimits = getLimits().messages ?? {};
981
+ var SYSTEM_LIMITS = {
982
+ /** Maximum wait time for interactive shell responses (10 seconds) */
983
+ MAX_WAIT_MS_INTERACT: 1e4,
984
+ /** Default wait time for interactive shell responses (2 seconds) */
985
+ DEFAULT_WAIT_MS_INTERACT: 2e3,
986
+ /** Maximum characters for process description */
987
+ MAX_DESCRIPTION_LENGTH: 80,
988
+ /** Maximum characters for stored command string */
989
+ MAX_COMMAND_LENGTH: 200,
990
+ /** Maximum characters to show from stdout
991
+ * WHY 50K: background processes (linpeas, scans, shells) produce large
992
+ * output with findings scattered throughout. Let the LLM see it all. */
993
+ MAX_STDOUT_SLICE: 5e4,
994
+ /** Maximum characters to show from stderr */
995
+ MAX_STDERR_SLICE: 5e3,
996
+ /** Maximum characters for error detail messages */
997
+ MAX_ERROR_DETAIL_SLICE: 2e3,
998
+ /** Maximum characters for input prompt previews */
999
+ MAX_PROMPT_PREVIEW: 50,
1000
+ /** Maximum characters for input snippets in logs */
1001
+ MAX_INPUT_SLICE: 100,
1002
+ /** Maximum events to keep in process event log */
1003
+ MAX_EVENT_LOG: 30,
1004
+ /** Wait time for child PID discovery via pgrep */
1005
+ CHILD_PID_DISCOVERY_MS: 500,
1006
+ /** Wait time between SIGTERM and SIGKILL during graceful shutdown */
1007
+ SHUTDOWN_WAIT_MS: 500,
1008
+ /** Wait time between process cleanup batches */
1009
+ CLEANUP_BATCH_WAIT_MS: 300,
1010
+ /** Timeout for pgrep and pkill operations */
1011
+ PROCESS_OP_TIMEOUT_MS: 2e3,
1012
+ /** Port range for web services (development servers) */
1013
+ WEB_PORT_RANGE: { MIN: 8e3, MAX: 9e3 },
1014
+ /** Port range for API services */
1015
+ API_PORT_RANGE: { MIN: 3e3, MAX: 3500 },
1016
+ /** Number of recent events to fetch for resource summary */
1017
+ RECENT_EVENTS_IN_SUMMARY: 10,
1018
+ /** Number of events to display in resource summary */
1019
+ RECENT_EVENTS_DISPLAY: 5,
1020
+ /** Number of recent output lines to show per process */
1021
+ RECENT_OUTPUT_LINES: 3,
1022
+ /** Maximum characters per message for context extraction.
1023
+ * runtime config: limits.messages.context_extractor_per_msg_limit */
1024
+ CONTEXT_EXTRACTOR_LIMIT: _msgLimits.context_extractor_per_msg_limit
1025
+ };
1026
+
1027
+ // src/shared/constants/system/detection.ts
1028
+ var DETECTION_PATTERNS = {
1029
+ LISTENER: /-(?:lvnp|nlvp|lp|p)\s+(\d+)/,
1030
+ HTTP_SERVER: /(?:http\.server|SimpleHTTPServer)\s+(\d+)/,
1031
+ GENERIC_PORT: /-(?:p|port|S)\s+(?:\S+:)?(\d+)/,
1032
+ CONNECTION: [
1033
+ /connection\s+from/i,
1034
+ /connect\s+to/i,
1035
+ /\$\s*$/m,
1036
+ /#\s*$/m,
1037
+ /bash-\d/i,
1038
+ /sh-\d/i,
1039
+ /www-data/i
1040
+ ]
1041
+ };
1042
+ var ORPHAN_PROCESS_NAMES = [
1043
+ "arpspoof",
1044
+ "ettercap",
1045
+ "mitmdump",
1046
+ "mitmproxy",
1047
+ "dnsspoof",
1048
+ "tcpdump",
1049
+ "tshark",
1050
+ "socat"
1051
+ ];
1052
+
1053
+ // src/shared/constants/system/health.ts
1054
+ var HEALTH_CONFIG = {
1055
+ LONG_RUNNING_THRESHOLD_MS: 3e5,
1056
+ // 5 minutes
1057
+ VERY_LONG_RUNNING_THRESHOLD_MS: 9e5,
1058
+ // 15 minutes
1059
+ MAX_RECOMMENDATIONS_FOR_HEALTHY: 2
1060
+ };
1061
+
1062
+ // src/engine/process/process-registry.ts
1063
+ var backgroundProcesses = /* @__PURE__ */ new Map();
1064
+ var processEventLog = [];
1065
+ function logEvent(processId, event, detail) {
1066
+ processEventLog.push({ timestamp: Date.now(), processId, event, detail });
1067
+ if (processEventLog.length > SYSTEM_LIMITS.MAX_EVENT_LOG) {
1068
+ processEventLog.splice(0, processEventLog.length - SYSTEM_LIMITS.MAX_EVENT_LOG);
1069
+ }
1070
+ }
1071
+ function getProcess(processId) {
1072
+ return backgroundProcesses.get(processId);
1073
+ }
1074
+ function setProcess(processId, process) {
1075
+ backgroundProcesses.set(processId, process);
1076
+ }
1077
+ function deleteProcess(processId) {
1078
+ return backgroundProcesses.delete(processId);
1079
+ }
1080
+ function hasProcess(processId) {
1081
+ return backgroundProcesses.has(processId);
1082
+ }
1083
+ function getAllProcessIds() {
1084
+ return Array.from(backgroundProcesses.keys());
1085
+ }
1086
+ function getAllProcesses() {
1087
+ return backgroundProcesses.values();
1088
+ }
1089
+ function getProcessEntries() {
1090
+ return backgroundProcesses.entries();
1091
+ }
1092
+ function getProcessCount() {
1093
+ return backgroundProcesses.size;
1094
+ }
1095
+ function clearAllProcesses() {
1096
+ backgroundProcesses.clear();
1097
+ }
1098
+ function getProcessEventLog() {
1099
+ return [...processEventLog];
1100
+ }
1101
+ function getBackgroundProcessesMap() {
1102
+ return backgroundProcesses;
1103
+ }
1104
+ function getActiveProcessSummary() {
1105
+ const processes = Array.from(getAllProcesses());
1106
+ if (!processes.length) return "";
1107
+ return processes.filter((p) => !p.hasExited).map((p) => {
1108
+ const port = p.listeningPort ? ` port=${p.listeningPort}` : "";
1109
+ const interactive = p.isInteractive ? " interactive=true" : "";
1110
+ return `${p.id}: ${p.command} | role=${p.role}${port}${interactive}`;
1111
+ }).join("\n");
1112
+ }
1113
+
1114
+ export {
1115
+ __require,
1116
+ EXIT_CODES,
1117
+ PROCESS_ACTIONS,
1118
+ PROCESS_ROLES,
1119
+ PROCESS_ICONS,
1120
+ STATUS_MARKERS,
1121
+ PROCESS_EVENTS,
1122
+ PROCESS_LIMITS,
1123
+ getOptionalRuntimeSection,
1124
+ getRequiredRuntimeSection,
1125
+ getRuntimeSectionOr,
1126
+ getLimits,
1127
+ SYSTEM_LIMITS,
1128
+ DETECTION_PATTERNS,
1129
+ ORPHAN_PROCESS_NAMES,
1130
+ HEALTH_CONFIG,
1131
+ logEvent,
1132
+ getProcess,
1133
+ setProcess,
1134
+ deleteProcess,
1135
+ hasProcess,
1136
+ getAllProcessIds,
1137
+ getAllProcesses,
1138
+ getProcessEntries,
1139
+ getProcessCount,
1140
+ clearAllProcesses,
1141
+ getProcessEventLog,
1142
+ getBackgroundProcessesMap,
1143
+ getActiveProcessSummary
1144
+ };