@ljoukov/llm 2.0.0 → 2.1.0
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/README.md +80 -0
- package/dist/index.cjs +1692 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +202 -1
- package/dist/index.d.ts +202 -1
- package/dist/index.js +1680 -11
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/README.md
CHANGED
|
@@ -392,6 +392,86 @@ const result = await runToolLoop({
|
|
|
392
392
|
console.log(result.text);
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
+
### Built-in `apply_patch` tool
|
|
396
|
+
|
|
397
|
+
The library includes a Codex-style `apply_patch` tool with a pluggable filesystem adapter.
|
|
398
|
+
|
|
399
|
+
```ts
|
|
400
|
+
import {
|
|
401
|
+
createApplyPatchTool,
|
|
402
|
+
createInMemoryAgentFilesystem,
|
|
403
|
+
runToolLoop,
|
|
404
|
+
} from "@ljoukov/llm";
|
|
405
|
+
|
|
406
|
+
const fs = createInMemoryAgentFilesystem({
|
|
407
|
+
"/repo/index.ts": "export const value = 1;\n",
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
const result = await runToolLoop({
|
|
411
|
+
model: "chatgpt-gpt-5.3-codex",
|
|
412
|
+
input: "Use apply_patch to change value from 1 to 2.",
|
|
413
|
+
tools: {
|
|
414
|
+
apply_patch: createApplyPatchTool({
|
|
415
|
+
cwd: "/repo",
|
|
416
|
+
fs,
|
|
417
|
+
checkAccess: ({ path }) => {
|
|
418
|
+
if (!path.startsWith("/repo/")) {
|
|
419
|
+
throw new Error("Writes are allowed only inside /repo");
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
}),
|
|
423
|
+
},
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
console.log(result.text);
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
### `runAgentLoop()` with model-aware filesystem tools
|
|
430
|
+
|
|
431
|
+
Use `runAgentLoop()` when you want a default filesystem toolset chosen by model:
|
|
432
|
+
|
|
433
|
+
- Codex-like models -> `apply_patch`, `read_file`, `list_dir`, `grep_files`
|
|
434
|
+
- Gemini models -> `read_file`, `write_file`, `replace`, `list_directory`, `grep_search`, `glob`
|
|
435
|
+
- Other models -> model-agnostic (Gemini-style) set by default
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
import { createInMemoryAgentFilesystem, runAgentLoop } from "@ljoukov/llm";
|
|
439
|
+
|
|
440
|
+
const fs = createInMemoryAgentFilesystem({
|
|
441
|
+
"/repo/src/a.ts": "export const value = 1;\n",
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const result = await runAgentLoop({
|
|
445
|
+
model: "chatgpt-gpt-5.3-codex",
|
|
446
|
+
input: "Change value from 1 to 2 using filesystem tools.",
|
|
447
|
+
filesystemTool: {
|
|
448
|
+
profile: "auto",
|
|
449
|
+
options: {
|
|
450
|
+
cwd: "/repo",
|
|
451
|
+
fs,
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
console.log(result.text);
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
## Agent benchmark (micro)
|
|
460
|
+
|
|
461
|
+
For small edit-harness experiments with `chatgpt-gpt-5.3-codex`:
|
|
462
|
+
|
|
463
|
+
```bash
|
|
464
|
+
npm run bench:agent
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
Estimate-only:
|
|
468
|
+
|
|
469
|
+
```bash
|
|
470
|
+
npm run bench:agent:estimate
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
See `benchmarks/agent/README.md` for options and output format.
|
|
474
|
+
|
|
395
475
|
## License
|
|
396
476
|
|
|
397
477
|
MIT
|