pwn 0.5.761 → 0.5.763
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.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +5 -5
- data/documentation/Banner.md +18 -0
- data/documentation/Swarm.md +113 -0
- data/documentation/pwn-ai-Agent.md +1 -1
- data/etc/default_skills/pwn/ai/agent/solve/SKILL.md +46 -0
- data/etc/default_skills/pwn/ai/agent/swarm/SKILL.md +1 -0
- data/lib/pwn/ai/agent/dispatch.rb +3 -0
- data/lib/pwn/ai/agent/loop.rb +18 -4
- data/lib/pwn/ai/agent/solve.rb +342 -0
- data/lib/pwn/ai/agent/swarm.rb +41 -1
- data/lib/pwn/ai/agent.rb +1 -0
- data/lib/pwn/ai/anthropic.rb +1 -0
- data/lib/pwn/ai/grok.rb +1 -0
- data/lib/pwn/ai/open_ai.rb +1 -0
- data/lib/pwn/plugins/repl/ai.rb +6 -1
- data/lib/pwn/plugins/repl/ai_console.rb +136 -10
- data/lib/pwn/plugins/repl/ai_console_commands.rb +5 -4
- data/lib/pwn/plugins/repl/ai_swarm.rb +44 -11
- data/lib/pwn/version.rb +1 -1
- data/spec/lib/pwn/ai/agent/loop_spec.rb +2 -1
- data/spec/lib/pwn/ai/agent/solve_spec.rb +290 -0
- data/spec/lib/pwn/plugins/repl/ai_console_commands_spec.rb +37 -1
- data/spec/lib/pwn/plugins/repl/ai_console_spec.rb +204 -27
- data/spec/lib/pwn/plugins/repl/ai_swarm_spec.rb +67 -7
- data/third_party/pwn_rdoc.jsonl +19 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fec3b367c44874a819aa4892a5b3c507cf858ed4649eb31d295b0509e8747c83
|
|
4
|
+
data.tar.gz: d8a004b8eee5f7bd996ae8c9208f895d93354b09f9149050cb3e93d8632fda8c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7490168d3e50c940ff771fe6788f7373e89b15f96541a8d0cec29bd13b1cccdce7c377799a415628fcd899a0e912928bf3aeb5fef68c0cf0fda2217871f60d95
|
|
7
|
+
data.tar.gz: eb50e5646ee60e9394f92139b61c38901303fc6167b06f95cf559a413d88a09dbfa21eadeb1e46e8e9418295d348e53f81a62d4d4f25956ebb0284f7e9c2e572
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -278,12 +278,12 @@ If this project helped you and you want to support the work, keep us caffeinated
|
|
|
278
278
|
|
|
279
279
|
### [**0x004D65726368**](https://0day.myspreadshop.com/) ###
|
|
280
280
|
|
|
281
|
-
[](https://0day.myspreadshop.com/home+%26+living+stickers+%26+magnets)
|
|
282
282
|
|
|
283
|
-
[](https://0day.myspreadshop.com/home+%26+living+mugs+%26+drinkwear)
|
|
284
284
|
|
|
285
|
-
[](https://0day.myspreadshop.com/home+%26+living+other)
|
|
286
286
|
|
|
287
|
-
[](https://0day.myspreadshop.com/0dayinc-A5c3e498cf937643162a01b5f?productType=803&sellable=1naaRYxY1zhOoQlv7Mdg-803-34&appearance=2&size=29)
|
|
288
288
|
|
|
289
|
-
[](https://0day.myspreadshop.com/blackfingerprint-A5c3e49db1cbf3a0b9596b4d0?productType=111&sellable=ekXXmGonOyclynglNE87-111-22&appearance=5)
|
data/documentation/Banner.md
CHANGED
|
@@ -14,4 +14,22 @@ welcome-banner # REPL command: redraw a random one
|
|
|
14
14
|
|
|
15
15
|
Add your own: drop a module in `lib/pwn/banner/` implementing `self.get`.
|
|
16
16
|
|
|
17
|
+
## pwn-ai startup pane
|
|
18
|
+
|
|
19
|
+
The curses console starts with a white miniature derived directly from
|
|
20
|
+
`PWN::Banner::WhiteRabbit.get`, without its dedication or wordmark. The full
|
|
21
|
+
banner remains unchanged. The rabbit is centered and aspect-contained in the
|
|
22
|
+
current pane: small panes use area-filtered 3×6 character strokes packed into
|
|
23
|
+
ordinary 2×4 Braille text dots; when the original ASCII fits, it is displayed
|
|
24
|
+
verbatim, centered without enlargement. This assumes typical 1:2 terminal cells.
|
|
25
|
+
Small panes lose punctuation detail, and Braille dot spacing depends on the font;
|
|
26
|
+
physically tiny panes cannot retain a recognizable rabbit. No image protocol,
|
|
27
|
+
image file, graphics probe or runtime image library is used.
|
|
28
|
+
|
|
29
|
+
No games or replays are computed until the animation pane first receives focus
|
|
30
|
+
via Ctrl+T/Ctrl+X. That enables games for the console lifetime. Ctrl+G cycles
|
|
31
|
+
games while focused; leaving the pane keeps the existing automatic animation,
|
|
32
|
+
not the startup rabbit. Resizing, modal input priority and the mission draft
|
|
33
|
+
retain their existing behavior. Monochrome terminals keep the same geometry.
|
|
34
|
+
|
|
17
35
|
[← Home](Home.md)
|
data/documentation/Swarm.md
CHANGED
|
@@ -18,6 +18,119 @@ self-improvement loop covers the whole swarm.
|
|
|
18
18
|
No daemon. Cross-session / cross-process communication == another `pwn-ai` (or
|
|
19
19
|
a `PWN::Cron` job) calling `Swarm.ask` with the same `swarm_id`.
|
|
20
20
|
|
|
21
|
+
## Run one mission with a built-in team
|
|
22
|
+
|
|
23
|
+
```text
|
|
24
|
+
/swarm mission Write and test a Ruby function that validates the supplied data format
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
No persona setup is required. The exact text after `/swarm mission ` remains the
|
|
28
|
+
user request for **every** role; role instructions and JSON handoffs go in system
|
|
29
|
+
context, not a replacement task. Empty requests fail before dispatch. Existing
|
|
30
|
+
`dm`, `broadcast`, and `debate` retain their messaging semantics. `/swarm agents`
|
|
31
|
+
lists available personas; `/swarm dm NAME REQUEST` messages one persona.
|
|
32
|
+
The renamed slash commands replace the previous spellings without compatibility
|
|
33
|
+
aliases. Ruby APIs `Swarm.solve`, `Swarm.ask`, and the `Solve` coordinator are unchanged.
|
|
34
|
+
|
|
35
|
+
`/menu` and Tab use case-insensitive alphabetical ordering at every depth:
|
|
36
|
+
root commands, command actions, and live parameter lists (including agents,
|
|
37
|
+
jobs, MCP tools, sessions, skills, memory keys, and cron jobs). Exact spelling
|
|
38
|
+
breaks case-insensitive ties; selections keep their original command payloads.
|
|
39
|
+
|
|
40
|
+
1. **Antagonist** independently enumerates requirements and risks before seeing
|
|
41
|
+
a candidate. `R0` always contains the entire unchanged original request.
|
|
42
|
+
2. **Protagonist** builds the candidate using the ordinary nested tool-calling
|
|
43
|
+
`Loop.run` through `Swarm.ask`, then declares relative artifact paths.
|
|
44
|
+
3. **Antagonist** critiques the candidate and returns unresolved objections.
|
|
45
|
+
4. **Verifier** proposes requirement-indexed commands and exact expected stdout.
|
|
46
|
+
The coordinator executes them via the registered `shell` tool and `Dispatch`,
|
|
47
|
+
capturing actual stdout, stderr, and exit status. Model-supplied observations
|
|
48
|
+
are never accepted as execution evidence.
|
|
49
|
+
5. **Integrator** reviews those observations and either accepts or sends a
|
|
50
|
+
targeted repair to the protagonist. Repairs always repeat critique and tests.
|
|
51
|
+
|
|
52
|
+
Acceptance additionally requires every requirement ID to have passing executed
|
|
53
|
+
evidence, no open objections, every check to exit zero with its expected output,
|
|
54
|
+
and unchanged artifact hashes and steering revision. A model's `accept` alone
|
|
55
|
+
cannot complete the job. Candidate and handoff revisions are SHA-256-bound;
|
|
56
|
+
changed files, stale handoffs, failed checks, uncovered requirements, malformed
|
|
57
|
+
JSON, provider failures and limits return **INCOMPLETE**, never success. Structured
|
|
58
|
+
records and raw execution observations are saved with owner-only permissions in
|
|
59
|
+
`~/.pwn/swarm/<solve-id>/solve.json`. Every solve gets fresh role sessions, so an
|
|
60
|
+
earlier candidate cannot contaminate the independent initial assessment.
|
|
61
|
+
|
|
62
|
+
### Console and controls
|
|
63
|
+
|
|
64
|
+
Open the swarm workspace with **Ctrl+S / Ctrl+G**, keep a mission in the composer,
|
|
65
|
+
then press **v — Mission with team**. Enter confirms the exact draft and built-in
|
|
66
|
+
roles; Esc aborts without changing the draft or cursor. The jobs detail view
|
|
67
|
+
shows actual role phases, original requirements, provider/model routes, artifact
|
|
68
|
+
hashes, and open objections. There is one integrated final result. Provider usage
|
|
69
|
+
continues through the console's existing usage observer (no invented estimates).
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
/swarm status JOB
|
|
73
|
+
/swarm steer JOB Add this verification constraint
|
|
74
|
+
/swarm pause JOB
|
|
75
|
+
/swarm resume JOB
|
|
76
|
+
/swarm cancel JOB
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The same slash routes work in the legacy line console. Steering belongs to the
|
|
80
|
+
coordinator and is propagated to later roles; it invalidates previously accepted
|
|
81
|
+
candidate evidence without replacing the original goal. Pause stops future
|
|
82
|
+
dispatch at safe boundaries. Cancel interrupts the owned model wait; an already
|
|
83
|
+
running tool finishes first, and its changes are not undone. Another job cannot
|
|
84
|
+
start in the same controller while solve owns the workspace. A workspace file
|
|
85
|
+
lock also excludes overlapping solve coordinators across processes.
|
|
86
|
+
|
|
87
|
+
### Role configuration and limits
|
|
88
|
+
|
|
89
|
+
All roles inherit the already selected provider and that provider's configured
|
|
90
|
+
default model. Optional overrides use **existing** persona fields; no new vault
|
|
91
|
+
configuration keys or schema migration is needed:
|
|
92
|
+
|
|
93
|
+
```text
|
|
94
|
+
/swarm spawn solve_antagonist Review correctness --engine ollama --model YOUR_INSTALLED_MODEL
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The other names are `solve_protagonist`, `solve_verifier`, and `solve_integrator`.
|
|
98
|
+
They can also be defined in `agents.yml`. Engine/model overrides are request-local;
|
|
99
|
+
there is no superiority ranking, automatic diversity, or fallback to a different
|
|
100
|
+
provider. Remote credentials must already be configured. Solve never initiates
|
|
101
|
+
OAuth login or prompts for API keys; configured OAuth refresh remains the provider's
|
|
102
|
+
normal noninteractive operation. Implicit local-agent escalation is disabled for
|
|
103
|
+
solve. A missing provider fails visibly rather than silently switching.
|
|
104
|
+
|
|
105
|
+
Ruby API: `Swarm.solve(request:, workspace: Dir.pwd, rounds: 3, swarm_id: nil,
|
|
106
|
+
steering: nil, on_state: nil, on_tool: nil, usage_observer: nil)`. `swarm_id` supplies
|
|
107
|
+
role overrides; the returned solve ID identifies the independent records. The
|
|
108
|
+
default round limit is 3 (API range 1–10), each role turn is limited to 25 model
|
|
109
|
+
calls, and each of at most 32 checks per round has a 60-second tool timeout.
|
|
110
|
+
|
|
111
|
+
### Boundaries, not a security sandbox
|
|
112
|
+
|
|
113
|
+
The protagonist is the only model role with write-capable tools (`shell` and
|
|
114
|
+
`pwn_eval`). Review roles have no tools; Dispatch denies invented tool calls even
|
|
115
|
+
if a provider ignores its empty tool schema. Integrator repairs are dispatched
|
|
116
|
+
back to that one writer. This is role capability enforcement, **not** confinement
|
|
117
|
+
of arbitrary protagonist Ruby or shell code or other processes on the host.
|
|
118
|
+
|
|
119
|
+
Verification runs in fresh disposable copies of declared regular-file artifacts;
|
|
120
|
+
all test dependencies must be declared. Symlinks/out-of-workspace artifacts are
|
|
121
|
+
rejected, and input copies must retain their candidate hashes after a check.
|
|
122
|
+
Files over 128 KiB cannot currently be passed to full-content review and produce
|
|
123
|
+
an explicit incomplete result. A disposable directory is **not an OS sandbox**:
|
|
124
|
+
test code can use absolute paths, network, installed dependencies and host resources.
|
|
125
|
+
Existing Dispatch confirmation and `ai_sandbox` policies still apply. Use only
|
|
126
|
+
trusted test commands or supply external OS isolation when executing untrusted code.
|
|
127
|
+
|
|
128
|
+
Requirement extraction and test relevance still require model judgment. Executed
|
|
129
|
+
checks are evidence for their stated assertions, not mathematical proof of an
|
|
130
|
+
arbitrary natural-language goal; the saved commands, outputs, requirements and
|
|
131
|
+
revisions make that judgment inspectable. No live-provider reliability or automatic
|
|
132
|
+
security isolation is implied by the deterministic offline integration tests.
|
|
133
|
+
|
|
21
134
|
## Define personas
|
|
22
135
|
|
|
23
136
|
Each persona accepts optional `engine` and `model` keys. `model` is the exact
|
|
@@ -300,7 +300,7 @@ and Ctrl+D still work. A running tool finishes cooperatively: neither rollback
|
|
|
300
300
|
nor remote provider billing cancellation is promised. Swarm jobs should use
|
|
301
301
|
noninteractive tools; their individual stdin prompts are not multiplexed.
|
|
302
302
|
|
|
303
|
-
Typed `/swarm
|
|
303
|
+
Typed `/swarm agents|mission|status|create|use|spawn|retire|dm|broadcast|debate|tail|steer|pause|resume|cancel`
|
|
304
304
|
commands remain available, including parameter completion. These are direct
|
|
305
305
|
operator commands and do not add the workspace's extra confirmation step.
|
|
306
306
|
`/swarm status JOB` includes retained outcomes. Jobs shown here belong to this
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pwn-ai-agent-solve
|
|
3
|
+
description: Drive PWN::AI::Agent::Solve from pwn_eval.
|
|
4
|
+
license: MIT
|
|
5
|
+
allowed-tools: [pwn, pwn_eval]
|
|
6
|
+
metadata:
|
|
7
|
+
bundled: true
|
|
8
|
+
generated: true
|
|
9
|
+
module: PWN::AI::Agent::Solve
|
|
10
|
+
source: pwn/ai/agent/solve.rb
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# PWN::AI::Agent::Solve
|
|
14
|
+
|
|
15
|
+
Revision-bound, single-writer team coordinator. Role replies are proposals, never observations. Only host-executed checks can become evidence.
|
|
16
|
+
|
|
17
|
+
## When to use
|
|
18
|
+
|
|
19
|
+
Call `PWN::AI::Agent::Solve` from `pwn_eval` when the task needs this module.
|
|
20
|
+
Do not reimplement it in shell.
|
|
21
|
+
|
|
22
|
+
## Methodologies
|
|
23
|
+
|
|
24
|
+
Generated from `pwn/ai/agent/solve.rb`. Prefer the public class methods below.
|
|
25
|
+
Class methods take `(opts = {})` and read `opts`.
|
|
26
|
+
|
|
27
|
+
## How to call
|
|
28
|
+
|
|
29
|
+
```ruby
|
|
30
|
+
PWN::AI::Agent::Solve.help
|
|
31
|
+
PWN::AI::Agent::Solve.help(opts)
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Public methods
|
|
35
|
+
|
|
36
|
+
- `authors`
|
|
37
|
+
- `help`
|
|
38
|
+
|
|
39
|
+
## Source
|
|
40
|
+
|
|
41
|
+
`pwn/ai/agent/solve.rb`
|
|
42
|
+
|
|
43
|
+
## Verification
|
|
44
|
+
|
|
45
|
+
`PWN::AI::Agent::Solve.respond_to?(:authors)` after the
|
|
46
|
+
module is loaded. Read the source for parameter names.
|
|
@@ -51,6 +51,9 @@ module PWN
|
|
|
51
51
|
entry = Registry.lookup(name: name) || Registry.lookup(name: repair_name(name: name))
|
|
52
52
|
return JSON.generate(error: "unknown tool: #{name}") unless entry
|
|
53
53
|
|
|
54
|
+
solve_tools = Thread.current[:pwn_solve_tools]
|
|
55
|
+
return JSON.generate(success: false, error: 'Tool denied by solve role capability boundary') if solve_tools && !solve_tools.include?(entry.name.to_s)
|
|
56
|
+
|
|
54
57
|
args = parse_args(raw: raw, entry: entry)
|
|
55
58
|
args = alias_known_keys(args: args, entry: entry)
|
|
56
59
|
schema = entry.schema[:parameters] || entry.schema['parameters'] || { type: 'object' }
|
data/lib/pwn/ai/agent/loop.rb
CHANGED
|
@@ -1704,6 +1704,8 @@ module PWN
|
|
|
1704
1704
|
# export_finetune can later teach the LoRA to NOT need it.
|
|
1705
1705
|
@escalate_warned = false
|
|
1706
1706
|
private_class_method def self.escalate(opts = {})
|
|
1707
|
+
return if Thread.current[:pwn_solve_tools]
|
|
1708
|
+
|
|
1707
1709
|
request = opts[:request]
|
|
1708
1710
|
turn_fails = opts[:turn_fails]
|
|
1709
1711
|
persona = agent_flag(key: :escalation_persona)
|
|
@@ -2058,7 +2060,7 @@ module PWN
|
|
|
2058
2060
|
)
|
|
2059
2061
|
|
|
2060
2062
|
runtime = Thread.current[:pwn_request_runtime]
|
|
2061
|
-
if runtime.respond_to?(:call)
|
|
2063
|
+
if runtime.respond_to?(:call) && !Thread.current[:pwn_solve_tools]
|
|
2062
2064
|
return runtime.call(messages: messages, tools: tools) do |prepared, route|
|
|
2063
2065
|
invoke_provider_chat(engine: (route || {})[:provider] || active_engine, messages: prepared, tools: tools, model: (route || {})[:model], temp: (route || {})[:temperature])
|
|
2064
2066
|
end
|
|
@@ -3160,6 +3162,16 @@ module PWN
|
|
|
3160
3162
|
end
|
|
3161
3163
|
|
|
3162
3164
|
# Commit the returned tool before unwinding, without stale recovery work.
|
|
3165
|
+
# Child handoffs are proposals, never a user completion. Solve owns
|
|
3166
|
+
# the original objective and the final artifact/evidence gate.
|
|
3167
|
+
private_class_method def self.solve_handoff?(opts = {})
|
|
3168
|
+
return false unless opts[:solve_handoff] && Thread.current[:pwn_solve_tools] && Array(opts[:calls]).empty?
|
|
3169
|
+
|
|
3170
|
+
JSON.parse(opts[:text]).is_a?(Hash)
|
|
3171
|
+
rescue JSON::ParserError
|
|
3172
|
+
false
|
|
3173
|
+
end
|
|
3174
|
+
|
|
3163
3175
|
private_class_method def self.steering_tool_checkpoint!(opts = {})
|
|
3164
3176
|
opts[:steering]&.checkpoint(messages: opts[:messages], phase: :tool) do
|
|
3165
3177
|
tc = opts[:tool_call]
|
|
@@ -3348,7 +3360,7 @@ module PWN
|
|
|
3348
3360
|
trivia = world_knowledge?(request: request)
|
|
3349
3361
|
catalog = catalog_lookup?(request: request)
|
|
3350
3362
|
browse = request_need(request: request) == :browse
|
|
3351
|
-
skip_compass = trivia || catalog || no_tools || browse
|
|
3363
|
+
skip_compass = trivia || catalog || no_tools || browse || opts[:solve_handoff]
|
|
3352
3364
|
# Trivia / catalog / browse do not get an implement-shaped
|
|
3353
3365
|
# English compass. Inventing "apply code/host changes" there
|
|
3354
3366
|
# keeps the model on a Navigate task after the page already loaded.
|
|
@@ -3372,7 +3384,7 @@ module PWN
|
|
|
3372
3384
|
Thread.current[:pwn_plan_predicted] = nil
|
|
3373
3385
|
cal_state = calibration_state
|
|
3374
3386
|
force_plan = cal_state[:force_plan]
|
|
3375
|
-
skip_plan = %i[howto recall greeting].include?(intent) ||
|
|
3387
|
+
skip_plan = %i[howto recall greeting].include?(intent) || skip_compass
|
|
3376
3388
|
did_plan = false
|
|
3377
3389
|
if !skip_plan && (force_plan || agent_flag(key: :plan_first, default: local) || budget_exhaustion_hot?) && !Array(tools).empty?
|
|
3378
3390
|
predicted = plan_first(messages: messages, request: request, ts_state: ts_state)
|
|
@@ -3523,6 +3535,8 @@ module PWN
|
|
|
3523
3535
|
|
|
3524
3536
|
messages << msg
|
|
3525
3537
|
|
|
3538
|
+
return text if solve_handoff?(opts.merge(text: text, calls: calls))
|
|
3539
|
+
|
|
3526
3540
|
if calls.empty?
|
|
3527
3541
|
# P28 — refuse polite mid-goal handoffs so multi-step tasks stay autonomous.
|
|
3528
3542
|
if incomplete_final?(text: text, last_iter: false)
|
|
@@ -3650,7 +3664,7 @@ module PWN
|
|
|
3650
3664
|
# P17 — never fork counterfactual when budget fingerprints dominate:
|
|
3651
3665
|
# CF is another mini agent loop and is the #1 amplifier of
|
|
3652
3666
|
# iteration-budget exhaustion on this host.
|
|
3653
|
-
if count >= thresh && !retryable_execution_failure?(raw: raw) && !escalated && defined?(Curriculum) && !budget_exhaustion_hot?
|
|
3667
|
+
if count >= thresh && !retryable_execution_failure?(raw: raw) && !escalated && defined?(Curriculum) && !budget_exhaustion_hot? && !opts[:solve_handoff]
|
|
3654
3668
|
cf = (turn_fails["cf:#{fkey}"] += 1) == 1 ? Curriculum.counterfactual(request: request, name: name, args: args, error: tele[:err] || raw[0, 200], hint: hint) : nil
|
|
3655
3669
|
hint = "#{hint}\n[pwn-ai/counterfactual] branch #{cf[:branch]} (score=#{cf[:score].round(2)}): #{cf[:content]}" if cf
|
|
3656
3670
|
end
|