pwn 0.5.668 → 0.5.670

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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +15 -0
  3. data/Gemfile +1 -1
  4. data/README.md +8 -6
  5. data/documentation/AI-Integration.md +5 -3
  6. data/documentation/Agent-Tool-Registry.md +18 -14
  7. data/documentation/Configuration.md +6 -0
  8. data/documentation/Contributing.md +13 -0
  9. data/documentation/Diagrams.md +1 -1
  10. data/documentation/Home.md +4 -4
  11. data/documentation/How-PWN-Works.md +6 -6
  12. data/documentation/Persistence.md +17 -0
  13. data/documentation/Reinforcement-Learning.md +39 -39
  14. data/documentation/SDR.md +1 -1
  15. data/documentation/Sessions.md +1 -0
  16. data/documentation/Skills-Memory-Learning.md +2 -0
  17. data/documentation/What-is-PWN.md +3 -3
  18. data/documentation/diagrams/agent-tool-registry.svg +43 -43
  19. data/documentation/diagrams/ai-integration-tool-calling.svg +112 -85
  20. data/documentation/diagrams/dot/agent-tool-registry.dot +4 -4
  21. data/documentation/diagrams/dot/ai-integration-tool-calling.dot +7 -3
  22. data/documentation/diagrams/dot/memory-skills-detailed.dot +2 -2
  23. data/documentation/diagrams/dot/overall-pwn-architecture.dot +6 -4
  24. data/documentation/diagrams/dot/persistence-filesystem.dot +1 -1
  25. data/documentation/diagrams/dot/sdr-radio-flow.dot +1 -1
  26. data/documentation/diagrams/dot/task-summarizer.dot +24 -12
  27. data/documentation/diagrams/memory-skills-detailed.svg +182 -182
  28. data/documentation/diagrams/overall-pwn-architecture.svg +154 -146
  29. data/documentation/diagrams/persistence-filesystem.svg +6 -6
  30. data/documentation/diagrams/sdr-radio-flow.svg +1 -1
  31. data/documentation/diagrams/task-summarizer.svg +178 -126
  32. data/documentation/pwn-ai-Agent.md +53 -15
  33. data/lib/pwn/ai/agent/loop.rb +773 -6
  34. data/lib/pwn/ai/agent/prompt_builder.rb +81 -7
  35. data/lib/pwn/ai/agent/task_summarizer.rb +426 -28
  36. data/lib/pwn/ai/agent/tools/shell.rb +32 -0
  37. data/lib/pwn/config.rb +7 -2
  38. data/lib/pwn/memory.rb +188 -0
  39. data/lib/pwn/memory_index.rb +17 -2
  40. data/lib/pwn/plugins/repl.rb +36 -7
  41. data/lib/pwn/sessions.rb +9 -4
  42. data/lib/pwn/version.rb +1 -1
  43. data/spec/lib/pwn/ai/agent/loop_spec.rb +246 -2
  44. data/spec/lib/pwn/ai/agent/prompt_builder_spec.rb +51 -0
  45. data/spec/lib/pwn/ai/agent/task_summarizer_spec.rb +115 -0
  46. data/spec/lib/pwn/ai/agent/tools/shell_spec.rb +21 -0
  47. data/spec/lib/pwn/memory_spec.rb +62 -0
  48. data/spec/lib/pwn/plugins/repl_pwn_vault_spec.rb +134 -0
  49. data/third_party/pwn_rdoc.jsonl +30 -2
  50. metadata +4 -3
@@ -1,6 +1,6 @@
1
1
  digraph "PWN_AI_Integration" {
2
2
  graph [
3
- label=<<B>PWN::AI - Multi-Provider LLM Integration</B><BR/><FONT POINT-SIZE="11" COLOR="#94a3b8">one Agent Loop · five interchangeable engines</FONT>>,
3
+ label=<<B>PWN::AI - Multi-Provider LLM Integration</B><BR/><FONT POINT-SIZE="11" COLOR="#94a3b8">one Agent Loop · six interchangeable engines</FONT>>,
4
4
  labelloc=t, fontsize=20, fontname="Helvetica",
5
5
  rankdir=LR, splines=spline, nodesep=0.45, ranksep=1.3,
6
6
  bgcolor="#0f172a", fontcolor="#e2e8f0", pad=0.6, newrank=true
@@ -20,8 +20,9 @@ digraph "PWN_AI_Integration" {
20
20
  Grok [label="Grok\nOAuth device flow", fillcolor="#c4b5fd"];
21
21
  Gemini [label="Gemini", fillcolor="#c4b5fd"];
22
22
  Ollama [label="Ollama (local)\n/api/chat num_ctx · keep_alive\n/api/embed → MemoryIndex", fillcolor="#c4b5fd"];
23
+ OpenWebUI [label="Open WebUI\ngateway JWT\n/api/v1/chat + /ollama", fillcolor="#c4b5fd"];
23
24
  }
24
- {rank=same; OpenAI; Anthropic; Grok; Gemini; Ollama}
25
+ {rank=same; OpenAI; Anthropic; Grok; Gemini; Ollama; OpenWebUI}
25
26
 
26
27
  subgraph cluster_api {
27
28
  label="Provider APIs"; fontcolor="#fecaca"; style="rounded,dashed";
@@ -31,8 +32,9 @@ digraph "PWN_AI_Integration" {
31
32
  A3 [label="api.x.ai\nauth.x.ai", fillcolor="#fda4af"];
32
33
  A4 [label="generativelanguage\n.googleapis.com", fillcolor="#fda4af"];
33
34
  A5 [label="localhost:11434", fillcolor="#fda4af"];
35
+ A6 [label="Open WebUI host\n/api/v1 + /ollama", fillcolor="#fda4af"];
34
36
  }
35
- {rank=same; A1; A2; A3; A4; A5}
37
+ {rank=same; A1; A2; A3; A4; A5; A6}
36
38
 
37
39
  Cfg [label="PWN::Config\n~/.pwn/pwn.yaml\nactive · key · oauth\nprompt_budget · reflect_engine\nplan_first · tool_router · escalation", shape=cylinder, fillcolor="#fcd34d"];
38
40
 
@@ -41,11 +43,13 @@ digraph "PWN_AI_Integration" {
41
43
  Loop -> Grok [color="#a78bfa"];
42
44
  Loop -> Gemini [color="#a78bfa"];
43
45
  Loop -> Ollama [color="#a78bfa"];
46
+ Loop -> OpenWebUI [color="#a78bfa"];
44
47
  OpenAI -> A1 [color="#fb7185"];
45
48
  Anthropic -> A2 [color="#fb7185"];
46
49
  Grok -> A3 [color="#fb7185"];
47
50
  Gemini -> A4 [color="#fb7185"];
48
51
  Ollama -> A5 [color="#fb7185"];
52
+ OpenWebUI -> A6 [color="#fb7185"];
49
53
  Cfg -> Loop [label="active engine", style=dashed, color="#fbbf24", constraint=false];
50
54
  Loop -> Anthropic [label="reflect_engine\n(teacher-student)", style=dashed, color="#fbbf24", constraint=false];
51
55
  }
@@ -13,7 +13,7 @@ digraph "PWN_MemorySkills" {
13
13
  subgraph cluster_write {
14
14
  label="Write-Side Tools"; fontcolor="#a7f3d0"; style=rounded;
15
15
  color="#047857"; bgcolor="#022c22";
16
- Rem [label="memory_remember\nkey · value · category", fillcolor="#6ee7b7"];
16
+ Rem [label="memory_remember · lean\nkey · value · category", fillcolor="#6ee7b7"];
17
17
  Skc [label="skill_create\nskill_add_reference", fillcolor="#6ee7b7"];
18
18
  Note [label="learning_note_outcome\nlearning_reflect", fillcolor="#6ee7b7"];
19
19
  Dist [label="learning_distill_skill\n(session → skill)", fillcolor="#6ee7b7"];
@@ -30,7 +30,7 @@ digraph "PWN_MemorySkills" {
30
30
  Fidx [label="memory.idx\nembedding index\n(sha → vec)", shape=cylinder, fillcolor="#fcd34d"];
31
31
  Fskl [label="skills/<n>/SKILL.md\nYAML front-matter refs", shape=cylinder, fillcolor="#fcd34d"];
32
32
  Flrn [label="learning.jsonl\noutcome log", shape=cylinder, fillcolor="#fcd34d"];
33
- Fses [label="sessions/*.jsonl\ntranscripts", shape=cylinder, fillcolor="#fcd34d"];
33
+ Fses [label="sessions/*.jsonl\ntranscripts (+ lean)", shape=cylinder, fillcolor="#fcd34d"];
34
34
  Fmis [label="mistakes.json\nsig → count · fix · regressed", shape=cylinder, fillcolor="#fcd34d"];
35
35
  Fext [label="extrospection.json\nsnapshot · rf · web · obs", shape=cylinder, fillcolor="#fcd34d"];
36
36
  Fftn [label="finetune/*.jsonl\nShareGPT / OpenAI / DPO", shape=cylinder, fillcolor="#fcd34d"];
@@ -16,7 +16,7 @@ digraph "PWN_Overall_Architecture" {
16
16
  color="#334155"; bgcolor="#1e293b";
17
17
  User [label="👤 Researcher\nRed Team · Bug Hunter", fillcolor="#7dd3fc"];
18
18
  CI [label="⚙️ CI / CD\nHeadless pipelines", fillcolor="#7dd3fc"];
19
- LLM [label="🤖 LLM Providers\nOpenAI · Anthropic\nGrok · Gemini · Ollama", fillcolor="#c4b5fd"];
19
+ LLM [label="🤖 LLM Providers\nOpenAI · Anthropic · Grok\nGemini · Ollama · Open WebUI", fillcolor="#c4b5fd"];
20
20
  Target [label="🎯 Attack Surface\nHosts · Web · Cloud\nRadio · Hardware", fillcolor="#fda4af"];
21
21
  }
22
22
  {rank=same; User; CI; LLM; Target}
@@ -37,7 +37,7 @@ digraph "PWN_Overall_Architecture" {
37
37
  label="PWN::AI::Agent"; fontcolor="#ddd6fe";
38
38
  style=rounded; color="#6d28d9"; bgcolor="#2e1065"; penwidth=2;
39
39
  Loop [label="Loop\nTaskSummarizer briefs\nplan_first → dispatch\n→ observe → escalate\nbudget-pressure caps", fillcolor="#c4b5fd"];
40
- Registry [label="Registry\n12 toolsets · 78 tools\ntool_router (CORE+topK)", fillcolor="#c4b5fd"];
40
+ Registry [label="Registry\n12 toolsets · 82 tools\ntool_router (CORE+topK)", fillcolor="#c4b5fd"];
41
41
  Swarm [label="Swarm\npersonas · debate · bus", fillcolor="#c4b5fd"];
42
42
  Prompt [label="PromptBuilder\nengine-budgeted blocks\nMemoryIndex → relevance-ranked",fillcolor="#c4b5fd"];
43
43
  }
@@ -51,7 +51,7 @@ digraph "PWN_Overall_Architecture" {
51
51
  SAST [label="SAST\n48 rules", fillcolor="#6ee7b7"];
52
52
  WWW [label="WWW\n21 site drivers", fillcolor="#6ee7b7"];
53
53
  AWS [label="AWS\n90 services", fillcolor="#6ee7b7"];
54
- SDR [label="SDR\nGQRX · Flipper · RFID\nDecoder::* (20)", fillcolor="#6ee7b7"];
54
+ SDR [label="SDR\nGQRX · Flipper · RFID\nDecoder::* (20+Base/DSP)", fillcolor="#6ee7b7"];
55
55
  Chain [label="Blockchain\nBTC · ETH", fillcolor="#6ee7b7"];
56
56
  Bounty [label="Bounty\nlifecycle replay", fillcolor="#6ee7b7"];
57
57
  Reports [label="Reports\nHTML · JSON", fillcolor="#6ee7b7"];
@@ -73,8 +73,9 @@ digraph "PWN_Overall_Architecture" {
73
73
  SwarmB [label="swarm/*/bus.jsonl", shape=cylinder, fillcolor="#fcd34d"];
74
74
  CronF [label="cron/jobs.yml", shape=cylinder, fillcolor="#fcd34d"];
75
75
  Finetune [label="finetune/*.jsonl", shape=cylinder, fillcolor="#fcd34d"];
76
+ Prefs [label="preferences.jsonl", shape=cylinder, fillcolor="#fcd34d"];
76
77
  }
77
- {rank=same; Memory; MemIdx; Skills; Learn; Metrics; MistF; Extro; Sessions; SwarmB; CronF; Finetune}
78
+ {rank=same; Memory; MemIdx; Skills; Learn; Metrics; MistF; Extro; Sessions; SwarmB; CronF; Finetune; Prefs}
78
79
 
79
80
  /* ── L0 → L1 ── */
80
81
  User -> REPL [color="#38bdf8"];
@@ -110,6 +111,7 @@ digraph "PWN_Overall_Architecture" {
110
111
  Chain -> Sessions [color="#f59e0b"];
111
112
  Bounty -> SwarmB [color="#f59e0b"];
112
113
  Reports -> CronF [color="#f59e0b"];
114
+ Reports -> Prefs [style=invis];
113
115
 
114
116
  /* ── side flows (few, non-constraining) ── */
115
117
  Loop -> LLM [label="tool-use API", color="#c4b5fd", constraint=false, penwidth=2];
@@ -28,7 +28,7 @@ digraph "PWN_Persistence" {
28
28
  crn [label="cron/jobs.yml + log/\nseeded: curriculum_practice_nightly\ncurriculum_train_weekly"];
29
29
  agt [label="agents.yml\npersona registry"];
30
30
  swm [label="swarm/<id>/bus.jsonl\nmulti-agent chat"];
31
- cur [label="curriculum/\nself-play reproducers · A/B eval"];
31
+ cur [label="curriculum/ + curriculum_kpi.jsonl\nself-play · A/B eval · KPI trend"];
32
32
  ftn [label="finetune/*.jsonl\nShareGPT / OpenAI SFT + DPO"];
33
33
  bkp [label="backup/<ts>/ · quarantine/\nMigrate autofix snapshots"];
34
34
  hist [label="~/.pwn_history\nREPL history"];
@@ -1,6 +1,6 @@
1
1
  digraph "PWN_SDR" {
2
2
  graph [
3
- label=<<B>PWN::SDR - Software-Defined Radio &amp; RF Hacking</B><BR/><FONT POINT-SIZE="11" COLOR="#94a3b8">GQRX · FlipperZero · RFIDler · FrequencyAllocation · Decoder::* (20) · Base.run_iq (true-air) · FFI::{Volk,Liquid,FFTW,RTLSdr,HackRF,AdalmPluto,SoapySDR}</FONT>>,
3
+ label=<<B>PWN::SDR - Software-Defined Radio &amp; RF Hacking</B><BR/><FONT POINT-SIZE="11" COLOR="#94a3b8">GQRX · FlipperZero · RFIDler · FrequencyAllocation · Decoder::* (20+Base/DSP) · Base.run_iq (true-air) · FFI::{Volk,Liquid,FFTW,RTLSdr,HackRF,AdalmPluto,SoapySDR}</FONT>>,
4
4
  labelloc=t, fontsize=20, fontname="Helvetica",
5
5
  rankdir=LR, splines=spline, nodesep=0.45, ranksep=1.1,
6
6
  bgcolor="#0f172a", fontcolor="#e2e8f0", pad=0.6, newrank=true
@@ -1,6 +1,6 @@
1
1
  digraph "PWN_TaskSummarizer" {
2
2
  graph [
3
- label=<<B>PWN::AI::Agent::TaskSummarizer - Executive task briefs</B><BR/><FONT POINT-SIZE="11" COLOR="#94a3b8">emit_plan! (full goal once) → about_to (per batch, deduped) → tools on their own lines · Loop single emitter</FONT>>,
3
+ label=<<B>PWN::AI::Agent::TaskSummarizer - Request kind + executive briefs</B><BR/><FONT POINT-SIZE="11" COLOR="#94a3b8">request_kind → (statement|question: no plan) · (autonomous_goal: emit_plan! → about_to → tools)</FONT>>,
4
4
  labelloc=t, fontsize=20, fontname="Helvetica",
5
5
  rankdir=TB, splines=spline, nodesep=0.55, ranksep=0.9,
6
6
  bgcolor="#0f172a", fontcolor="#e2e8f0", pad=0.6, newrank=true, compound=true
@@ -10,25 +10,34 @@ digraph "PWN_TaskSummarizer" {
10
10
  edge [fontname="Helvetica", fontsize=9, color="#94a3b8",
11
11
  fontcolor="#cbd5e1", penwidth=1.3, arrowsize=0.8];
12
12
 
13
- User [label="👤 User goal", fillcolor="#7dd3fc"];
14
- Loop [label="Loop.run\nts_state = TaskSummarizer.fresh", fillcolor="#c4b5fd"];
15
- {rank=same; User; Loop}
13
+ User [label="User request", fillcolor="#7dd3fc"];
14
+ Loop [label="Loop.run\nts_state = TaskSummarizer.fresh\nrequest_kind + request_intent", fillcolor="#c4b5fd"];
15
+ Kind [label="request_kind (LLM + heuristic)\nstatement | question | autonomous_goal\nhost-evidence Qs → goal", fillcolor="#fcd34d", penwidth=2];
16
+ {rank=same; User; Loop; Kind}
17
+
18
+ subgraph cluster_nogoal {
19
+ label="No multi-step breakdown"; fontcolor="#fda4af";
20
+ style=rounded; color="#be123c"; bgcolor="#4c0519"; penwidth=2;
21
+ Stmt [label="statement\nanswer_statement / greeting ack", fillcolor="#fda4af"];
22
+ Ques [label="question (knowledge/howto/recall)\nanswer_question / howto / recall\nno tools / no plan", fillcolor="#fda4af"];
23
+ }
24
+ {rank=same; Stmt; Ques}
16
25
 
17
26
  subgraph cluster_plan {
18
- label="Plan layer (once per turn)"; fontcolor="#ddd6fe";
27
+ label="Autonomous goal plan (once per turn)"; fontcolor="#ddd6fe";
19
28
  style=rounded; color="#6d28d9"; bgcolor="#2e1065"; penwidth=2;
20
- Plan [label="plan(request)\nenumerated steps or heuristic_decompose", fillcolor="#c4b5fd"];
21
- EmitP [label="emit_plan!\nGoal: …\nTangible tasks (N):\n 1. … 2. …", fillcolor="#c4b5fd", penwidth=2];
29
+ Plan [label="plan(request)\nenumerated · LLM · fallback\nordered work units", fillcolor="#c4b5fd"];
30
+ EmitP [label="emit_plan!\nKind: autonomous_goal\nGoal: ...\nTangible tasks (N):\n each may use 1+ tools", fillcolor="#c4b5fd", penwidth=2];
22
31
  }
23
32
  {rank=same; Plan; EmitP}
24
33
 
25
34
  subgraph cluster_batch {
26
35
  label="Batch layer (each tool collection)"; fontcolor="#a7f3d0";
27
36
  style=rounded; color="#047857"; bgcolor="#022c22"; penwidth=2;
28
- About [label="about_to(tools:)\ncapability_label\ntool_counts_phrase\nintent_phrase", fillcolor="#6ee7b7"];
37
+ About [label="about_to(tools:)\ntask k/n English primary\nvia tools (intent)", fillcolor="#6ee7b7"];
29
38
  FP [label="brief_fingerprint\nlast_brief_fp", fillcolor="#6ee7b7"];
30
39
  Dup [label="duplicate_brief?", shape=diamond, fillcolor="#fcd34d"];
31
- EmitB [label="emit task line\nNext: shell×2 (search)\n[task k/N: …]", fillcolor="#6ee7b7", penwidth=2];
40
+ EmitB [label="emit task line\ntask k/N: ...\nvia shell×2 (search)", fillcolor="#6ee7b7", penwidth=2];
32
41
  Skip [label="return nil\n(suppress duplicate)", fillcolor="#fda4af"];
33
42
  }
34
43
  {rank=same; About; FP; Dup; EmitB; Skip}
@@ -36,7 +45,7 @@ digraph "PWN_TaskSummarizer" {
36
45
  subgraph cluster_exec {
37
46
  label="Execution (not on task row)"; fontcolor="#fde68a";
38
47
  style=rounded; color="#a16207"; bgcolor="#422006"; penwidth=2;
39
- Tools [label="Dispatch tools\nshell · pwn_eval · …\nown REPL lines", fillcolor="#fcd34d"];
48
+ Tools [label="Dispatch tools\nshell · pwn_eval · ...\nown REPL lines", fillcolor="#fcd34d"];
40
49
  Rec [label="record!\nadvance plan_idx\n(silent unless verbose)", fillcolor="#fcd34d"];
41
50
  Flush [label="flush! / emit!\noptional closing brief", fillcolor="#fcd34d"];
42
51
  }
@@ -45,10 +54,13 @@ digraph "PWN_TaskSummarizer" {
45
54
  UI [label="REPL on_tool\nname='task', full text, result=''\n(no truncation)", fillcolor="#7dd3fc"];
46
55
 
47
56
  User -> Loop [color="#38bdf8", penwidth=2];
48
- Loop -> Plan [color="#a78bfa"];
57
+ Loop -> Kind [color="#fbbf24", penwidth=2];
58
+ Kind -> Stmt [label="statement", color="#fb7185"];
59
+ Kind -> Ques [label="question", color="#fb7185"];
60
+ Kind -> Plan [label="autonomous_goal", color="#a78bfa", penwidth=2];
49
61
  Plan -> EmitP [color="#a78bfa"];
50
62
  EmitP -> UI [label="full goal once", color="#38bdf8", penwidth=2];
51
- Loop -> About [label="before each\ntool batch", color="#a78bfa"];
63
+ Loop -> About [label="before each\ntool batch\n(goals only)", color="#a78bfa"];
52
64
  About -> FP [color="#34d399"];
53
65
  FP -> Dup [color="#34d399"];
54
66
  Dup -> EmitB [label="new", color="#34d399"];