pentesting 0.8.23 → 0.8.24
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/dist/index.js +29 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5079,24 +5079,41 @@ ${this.currentSpec.systemPrompt}`;
|
|
|
5079
5079
|
systemPrompt = buildAgentSystemPrompt(systemPrompt, this.currentAgent);
|
|
5080
5080
|
}
|
|
5081
5081
|
this.emit(AGENT_EVENT.LLM_START, { model: LLM_MODEL });
|
|
5082
|
-
|
|
5083
|
-
|
|
5082
|
+
let response;
|
|
5083
|
+
try {
|
|
5084
|
+
const stream = this.client.messages.stream({
|
|
5084
5085
|
model: LLM_MODEL,
|
|
5085
5086
|
max_tokens: LLM_MAX_TOKENS,
|
|
5086
5087
|
system: systemPrompt,
|
|
5087
5088
|
tools: this.tools,
|
|
5088
5089
|
messages
|
|
5089
|
-
})
|
|
5090
|
-
{
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
this.think(
|
|
5094
|
-
THOUGHT_TYPE.STUCK,
|
|
5095
|
-
`API retry ${attempt}/3 after ${delay}ms: ${error.message}`
|
|
5096
|
-
);
|
|
5090
|
+
});
|
|
5091
|
+
stream.on("text", (text) => {
|
|
5092
|
+
if (text.trim()) {
|
|
5093
|
+
this.think(THOUGHT_TYPE.OBSERVATION, text.slice(0, 100));
|
|
5097
5094
|
}
|
|
5098
|
-
}
|
|
5099
|
-
|
|
5095
|
+
});
|
|
5096
|
+
response = await stream.finalMessage();
|
|
5097
|
+
} catch (error) {
|
|
5098
|
+
response = await withRetry(
|
|
5099
|
+
() => this.client.messages.create({
|
|
5100
|
+
model: LLM_MODEL,
|
|
5101
|
+
max_tokens: LLM_MAX_TOKENS,
|
|
5102
|
+
system: systemPrompt,
|
|
5103
|
+
tools: this.tools,
|
|
5104
|
+
messages
|
|
5105
|
+
}),
|
|
5106
|
+
{
|
|
5107
|
+
maxRetries: 3,
|
|
5108
|
+
onRetry: (attempt, err, delay) => {
|
|
5109
|
+
this.think(
|
|
5110
|
+
THOUGHT_TYPE.STUCK,
|
|
5111
|
+
`API retry ${attempt}/3 after ${delay}ms: ${err.message}`
|
|
5112
|
+
);
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
);
|
|
5116
|
+
}
|
|
5100
5117
|
this.emit(AGENT_EVENT.LLM_END, { model: LLM_MODEL });
|
|
5101
5118
|
if (response.usage) {
|
|
5102
5119
|
this.tokenUsage.input += response.usage.input_tokens;
|