pentesting 0.8.23 → 0.8.25

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 (2) hide show
  1. package/dist/index.js +37 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5079,24 +5079,49 @@ ${this.currentSpec.systemPrompt}`;
5079
5079
  systemPrompt = buildAgentSystemPrompt(systemPrompt, this.currentAgent);
5080
5080
  }
5081
5081
  this.emit(AGENT_EVENT.LLM_START, { model: LLM_MODEL });
5082
- const response = await withRetry(
5083
- () => this.client.messages.create({
5082
+ let response;
5083
+ let streamBuffer = "";
5084
+ try {
5085
+ const stream = this.client.messages.stream({
5084
5086
  model: LLM_MODEL,
5085
5087
  max_tokens: LLM_MAX_TOKENS,
5086
5088
  system: systemPrompt,
5087
5089
  tools: this.tools,
5088
5090
  messages
5089
- }),
5090
- {
5091
- maxRetries: 3,
5092
- onRetry: (attempt, error, delay) => {
5093
- this.think(
5094
- THOUGHT_TYPE.STUCK,
5095
- `API retry ${attempt}/3 after ${delay}ms: ${error.message}`
5096
- );
5091
+ });
5092
+ stream.on("text", (text) => {
5093
+ streamBuffer += text;
5094
+ this.emit(AGENT_EVENT.THOUGHT, { type: "thinking", content: text });
5095
+ });
5096
+ stream.on("contentBlock", (block) => {
5097
+ if (block.type === "tool_use") {
5098
+ this.emit(AGENT_EVENT.THOUGHT, {
5099
+ type: "action",
5100
+ content: `Calling: ${block.name}`
5101
+ });
5097
5102
  }
5098
- }
5099
- );
5103
+ });
5104
+ response = await stream.finalMessage();
5105
+ } catch (error) {
5106
+ response = await withRetry(
5107
+ () => this.client.messages.create({
5108
+ model: LLM_MODEL,
5109
+ max_tokens: LLM_MAX_TOKENS,
5110
+ system: systemPrompt,
5111
+ tools: this.tools,
5112
+ messages
5113
+ }),
5114
+ {
5115
+ maxRetries: 3,
5116
+ onRetry: (attempt, err, delay) => {
5117
+ this.think(
5118
+ THOUGHT_TYPE.STUCK,
5119
+ `API retry ${attempt}/3 after ${delay}ms: ${err.message}`
5120
+ );
5121
+ }
5122
+ }
5123
+ );
5124
+ }
5100
5125
  this.emit(AGENT_EVENT.LLM_END, { model: LLM_MODEL });
5101
5126
  if (response.usage) {
5102
5127
  this.tokenUsage.input += response.usage.input_tokens;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentesting",
3
- "version": "0.8.23",
3
+ "version": "0.8.25",
4
4
  "description": "Autonomous Penetration Testing AI Agent",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",