@iinm/plain-agent 1.10.9 → 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/patchFile.mjs +4 -4
- package/src/tools/webSearch.mjs +11 -0
package/package.json
CHANGED
package/src/tools/patchFile.mjs
CHANGED
|
@@ -31,14 +31,14 @@ When editing multiple locations in the same file, include all blocks in a single
|
|
|
31
31
|
Format — a single patch string may contain multiple blocks:
|
|
32
32
|
@@@ ${nonce} {start}:{startHash}-{end}:{endHash}
|
|
33
33
|
replacement for lines {start}-{end}
|
|
34
|
+
@@@ ${nonce} {N}:{hash}
|
|
35
|
+
replace just that one line
|
|
36
|
+
@@@ ${nonce} {start}:{startHash}-{end}:{endHash}
|
|
37
|
+
(empty body deletes the range)
|
|
34
38
|
@@@ ${nonce} {N}:{afterHash}+
|
|
35
39
|
appended content after line N
|
|
36
40
|
@@@ ${nonce} 0+
|
|
37
41
|
prepended content at beginning of file
|
|
38
|
-
@@@ ${nonce} {N}:{hash}
|
|
39
|
-
replace just that one line
|
|
40
|
-
@@@ ${nonce} 10:ab-15:cd
|
|
41
|
-
(empty body deletes the range)
|
|
42
42
|
|
|
43
43
|
- Each block's content starts right after its @@@ header line and ends at the next @@@ or the end of the string. Any blank lines between the header and the content become part of the replacement.
|
|
44
44
|
- The nonce "${nonce}" is constant; always use the exact value shown above.
|
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(
|