@iinm/plain-agent 1.10.10 → 1.10.11
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/package.json +1 -1
- package/src/tools/webSearch.mjs +11 -0
package/package.json
CHANGED
package/src/tools/webSearch.mjs
CHANGED
|
@@ -47,6 +47,7 @@ import { noThrow } from "../utils/noThrow.mjs";
|
|
|
47
47
|
* @property {CallModel} modelCaller
|
|
48
48
|
* @property {number=} maxLengthPerSearch Truncate each search's output to this many characters (default 50000).
|
|
49
49
|
* @property {number=} maxTotalLength Truncate the combined output across searches to this many characters (default 200000).
|
|
50
|
+
* @property {number=} delayBetweenRequestsMs Delay between each search request in milliseconds (default 1000).
|
|
50
51
|
*/
|
|
51
52
|
|
|
52
53
|
/**
|
|
@@ -69,6 +70,9 @@ const DEFAULT_MAX_TOTAL_LENGTH = 200_000;
|
|
|
69
70
|
/** @type {number} */
|
|
70
71
|
const DEFAULT_SEARCH_TIMEOUT_MS = 30_000;
|
|
71
72
|
|
|
73
|
+
/** @type {number} */
|
|
74
|
+
const DEFAULT_DELAY_BETWEEN_REQUESTS_MS = 1_000;
|
|
75
|
+
|
|
72
76
|
/** @type {number} */
|
|
73
77
|
const SEARCH_MAX_BUFFER_BYTES = 16 * 1024 * 1024;
|
|
74
78
|
|
|
@@ -200,10 +204,17 @@ async function webSearchViaCommand(config, input) {
|
|
|
200
204
|
const maxLengthPerSearch =
|
|
201
205
|
config.maxLengthPerSearch ?? DEFAULT_MAX_LENGTH_PER_SEARCH;
|
|
202
206
|
const maxTotalLength = config.maxTotalLength ?? DEFAULT_MAX_TOTAL_LENGTH;
|
|
207
|
+
const delayBetweenRequestsMs =
|
|
208
|
+
config.delayBetweenRequestsMs ?? DEFAULT_DELAY_BETWEEN_REQUESTS_MS;
|
|
203
209
|
|
|
204
210
|
/** @type {{ keywords: string[], text: string, truncated: boolean, originalLength: number, error?: string }[]} */
|
|
205
211
|
const results = [];
|
|
206
212
|
for (const search of input.searches) {
|
|
213
|
+
if (delayBetweenRequestsMs > 0 && results.length > 0) {
|
|
214
|
+
await new Promise((resolve) =>
|
|
215
|
+
setTimeout(resolve, delayBetweenRequestsMs),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
207
218
|
try {
|
|
208
219
|
const raw = await runSearchCommand(config, search.keywords);
|
|
209
220
|
const { text, truncated, originalLength } = truncateText(
|