agentool 1.0.0 → 1.1.1
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 +132 -21
- package/dist/ask-user/index.cjs +5 -2
- package/dist/ask-user/index.d.cts +10 -1
- package/dist/ask-user/index.d.ts +10 -1
- package/dist/ask-user/index.js +5 -2
- package/dist/bash/index.cjs +5 -2
- package/dist/bash/index.d.cts +14 -1
- package/dist/bash/index.d.ts +14 -1
- package/dist/bash/index.js +5 -2
- package/dist/chunk-2JBLVFB7.cjs +74 -0
- package/dist/{chunk-K77GC2QI.js → chunk-2JF3ZF2J.js} +32 -2
- package/dist/{chunk-XKG2A3EW.js → chunk-2WSZCOJP.js} +54 -18
- package/dist/chunk-3FT4ZPB2.cjs +65 -0
- package/dist/{chunk-VLNDEVKS.js → chunk-3LGXZLBH.js} +46 -8
- package/dist/{chunk-G3ITTPGX.js → chunk-4MXDQEPA.js} +12 -1
- package/dist/{chunk-CGTPF6IS.js → chunk-4UUSERSH.js} +31 -7
- package/dist/{chunk-I6KFFQPV.cjs → chunk-5T3SQYI4.cjs} +34 -4
- package/dist/chunk-6ULQG2W2.cjs +99 -0
- package/dist/chunk-ABXTBB2N.cjs +67 -0
- package/dist/{chunk-CAEVLIQB.cjs → chunk-BIAODQ2P.cjs} +17 -1
- package/dist/chunk-CJA76MKM.js +59 -0
- package/dist/chunk-CM3VRCNX.cjs +59 -0
- package/dist/{chunk-SUSAPI5W.cjs → chunk-CXBWF5ON.cjs} +51 -4
- package/dist/{chunk-U2YMJM25.cjs → chunk-G6ZVJA4V.cjs} +31 -8
- package/dist/chunk-GPHCXS2S.js +99 -0
- package/dist/chunk-HG5T47NA.cjs +77 -0
- package/dist/chunk-HO4NIRU5.js +65 -0
- package/dist/{chunk-HZAQRHBT.js → chunk-IBC4QCGR.js} +27 -2
- package/dist/chunk-JYTOARJV.cjs +69 -0
- package/dist/chunk-KONXT2SF.cjs +8 -0
- package/dist/chunk-KUFZFNPT.cjs +61 -0
- package/dist/chunk-L7R4UZSK.js +61 -0
- package/dist/{chunk-FV2R5FFQ.cjs → chunk-LNAR3NJQ.cjs} +47 -9
- package/dist/chunk-M74OQYNK.js +69 -0
- package/dist/{chunk-IMZQ7ELK.cjs → chunk-NQIV6LBH.cjs} +51 -14
- package/dist/chunk-NTGDU5X3.js +67 -0
- package/dist/{chunk-ONBH74ZV.cjs → chunk-OYLTQJXT.cjs} +32 -8
- package/dist/{chunk-6PQLFDGT.js → chunk-PWBVB6MN.js} +17 -1
- package/dist/{chunk-QEJV2KZ4.cjs → chunk-RIGL3JTS.cjs} +55 -19
- package/dist/chunk-SFDZRLSX.cjs +91 -0
- package/dist/chunk-T6STO7PS.cjs +126 -0
- package/dist/{chunk-LPV5CN2K.js → chunk-TI4ZZ3IJ.js} +32 -2
- package/dist/chunk-TM5L4HA5.js +126 -0
- package/dist/{chunk-4YI2H55A.js → chunk-TXZ3BMMR.js} +49 -2
- package/dist/chunk-UCA6LURO.js +74 -0
- package/dist/{chunk-EA3YV7ZG.js → chunk-VE4U27HI.js} +35 -15
- package/dist/chunk-VHLY7LQE.js +53 -0
- package/dist/{chunk-FW3UJ622.cjs → chunk-VPRUYL4T.cjs} +34 -4
- package/dist/{chunk-3VO6NETR.cjs → chunk-VPV6WG5V.cjs} +41 -21
- package/dist/chunk-VQSWMGG7.cjs +53 -0
- package/dist/{chunk-Y7KOKDFP.js → chunk-VZRXTFS4.js} +29 -6
- package/dist/chunk-WCR62UZ3.js +67 -0
- package/dist/chunk-X6ZY2KFU.js +8 -0
- package/dist/chunk-XGDE7S2D.cjs +67 -0
- package/dist/chunk-XPTW45XY.js +77 -0
- package/dist/{chunk-YPPPGGLA.cjs → chunk-YCWJVQYO.cjs} +28 -3
- package/dist/chunk-YGXLT6SS.js +91 -0
- package/dist/{chunk-5NW4OGRI.cjs → chunk-YTPZHJDC.cjs} +12 -1
- package/dist/{chunk-6MDPYALY.js → chunk-ZHVRP3EH.js} +49 -12
- package/dist/context-compaction/index.cjs +5 -2
- package/dist/context-compaction/index.d.cts +11 -1
- package/dist/context-compaction/index.d.ts +11 -1
- package/dist/context-compaction/index.js +5 -2
- package/dist/diff/index.cjs +6 -2
- package/dist/diff/index.d.cts +12 -2
- package/dist/diff/index.d.ts +12 -2
- package/dist/diff/index.js +7 -3
- package/dist/edit/index.cjs +7 -3
- package/dist/edit/index.d.cts +15 -5
- package/dist/edit/index.d.ts +15 -5
- package/dist/edit/index.js +8 -4
- package/dist/glob/index.cjs +5 -2
- package/dist/glob/index.d.cts +13 -3
- package/dist/glob/index.d.ts +13 -3
- package/dist/glob/index.js +5 -2
- package/dist/grep/index.cjs +6 -2
- package/dist/grep/index.d.cts +13 -3
- package/dist/grep/index.d.ts +13 -3
- package/dist/grep/index.js +6 -2
- package/dist/http-request/index.cjs +5 -2
- package/dist/http-request/index.d.cts +11 -1
- package/dist/http-request/index.d.ts +11 -1
- package/dist/http-request/index.js +5 -2
- package/dist/index.cjs +93 -19
- package/dist/index.d.cts +21 -16
- package/dist/index.d.ts +21 -16
- package/dist/index.js +113 -39
- package/dist/lsp/index.cjs +6 -2
- package/dist/lsp/index.d.cts +16 -10
- package/dist/lsp/index.d.ts +16 -10
- package/dist/lsp/index.js +6 -2
- package/dist/memory/index.cjs +6 -2
- package/dist/memory/index.d.cts +10 -1
- package/dist/memory/index.d.ts +10 -1
- package/dist/memory/index.js +6 -2
- package/dist/multi-edit/index.cjs +7 -4
- package/dist/multi-edit/index.d.cts +12 -2
- package/dist/multi-edit/index.d.ts +12 -2
- package/dist/multi-edit/index.js +7 -4
- package/dist/read/index.cjs +6 -3
- package/dist/read/index.d.cts +11 -1
- package/dist/read/index.d.ts +11 -1
- package/dist/read/index.js +6 -3
- package/dist/sleep/index.cjs +5 -2
- package/dist/sleep/index.d.cts +11 -1
- package/dist/sleep/index.d.ts +11 -1
- package/dist/sleep/index.js +5 -2
- package/dist/task-create/index.cjs +13 -0
- package/dist/task-create/index.d.cts +28 -0
- package/dist/task-create/index.d.ts +28 -0
- package/dist/task-create/index.js +13 -0
- package/dist/task-get/index.cjs +13 -0
- package/dist/task-get/index.d.cts +24 -0
- package/dist/task-get/index.d.ts +24 -0
- package/dist/task-get/index.js +13 -0
- package/dist/task-list/index.cjs +13 -0
- package/dist/task-list/index.d.cts +20 -0
- package/dist/task-list/index.d.ts +20 -0
- package/dist/task-list/index.js +13 -0
- package/dist/task-update/index.cjs +13 -0
- package/dist/task-update/index.d.cts +40 -0
- package/dist/task-update/index.d.ts +40 -0
- package/dist/task-update/index.js +13 -0
- package/dist/tool-search/index.cjs +11 -0
- package/dist/tool-search/index.d.cts +27 -0
- package/dist/tool-search/index.d.ts +27 -0
- package/dist/tool-search/index.js +11 -0
- package/dist/web-fetch/index.cjs +5 -2
- package/dist/web-fetch/index.d.cts +11 -3
- package/dist/web-fetch/index.d.ts +11 -3
- package/dist/web-fetch/index.js +5 -2
- package/dist/web-search/index.cjs +11 -0
- package/dist/web-search/index.d.cts +30 -0
- package/dist/web-search/index.d.ts +30 -0
- package/dist/web-search/index.js +11 -0
- package/dist/write/index.cjs +6 -3
- package/dist/write/index.d.cts +13 -3
- package/dist/write/index.d.ts +13 -3
- package/dist/write/index.js +6 -3
- package/package.json +31 -6
- package/dist/chunk-3EPGFWZV.cjs +0 -30
- package/dist/chunk-7QL4BQCH.js +0 -40
- package/dist/chunk-FAEGCFTO.js +0 -136
- package/dist/chunk-HDKXSKMO.js +0 -30
- package/dist/chunk-JCTBB7H2.cjs +0 -40
- package/dist/chunk-MF7CJVIZ.js +0 -40
- package/dist/chunk-MXFW3XY6.cjs +0 -73
- package/dist/chunk-OXLQ7QVL.cjs +0 -40
- package/dist/chunk-S6QEY7UY.js +0 -73
- package/dist/chunk-TBVHHF3H.cjs +0 -47
- package/dist/chunk-XLD2Y3SS.cjs +0 -136
- package/dist/chunk-ZHCMEQJJ.js +0 -47
- package/dist/task/index.cjs +0 -8
- package/dist/task/index.d.cts +0 -67
- package/dist/task/index.d.ts +0 -67
- package/dist/task/index.js +0 -8
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# agentool
|
|
4
4
|
|
|
5
|
-
**
|
|
5
|
+
**22 AI agent tools as standalone [Vercel AI SDK](https://sdk.vercel.ai/) modules.**
|
|
6
6
|
|
|
7
7
|
<p>
|
|
8
8
|
<a href="https://www.npmjs.com/package/agentool"><img src="https://img.shields.io/npm/v/agentool?style=flat-square&color=cb3837&logo=npm" alt="npm version" /></a>
|
|
@@ -27,13 +27,13 @@ File operations, shell execution, code search, web fetching, and more -- everyth
|
|
|
27
27
|
|
|
28
28
|
## Features
|
|
29
29
|
|
|
30
|
-
- **
|
|
30
|
+
- **22 production-ready tools** -- bash, grep, glob, read, edit, write, web-fetch, web-search, tool-search, memory, multi-edit, diff, task-create, task-get, task-update, task-list, lsp, http-request, context-compaction, ask-user, sleep
|
|
31
31
|
- **Vercel AI SDK compatible** -- works with `generateText()`, `streamText()`, and any AI SDK provider (OpenAI, Anthropic, Google, etc.)
|
|
32
32
|
- **Factory + default pattern** -- `createBash({ cwd: '/my/project' })` for custom config, or just use `bash` with zero config
|
|
33
33
|
- **Dual ESM/CJS** -- works everywhere with proper `exports` map
|
|
34
34
|
- **TypeScript-first** -- full type declarations, strict mode, no `any`
|
|
35
35
|
- **Never throws** -- every `execute()` returns a descriptive error string instead of throwing
|
|
36
|
-
- **Tree-shakeable** --
|
|
36
|
+
- **Tree-shakeable** -- 22 subpath exports, only import what you need
|
|
37
37
|
|
|
38
38
|
## Installation
|
|
39
39
|
|
|
@@ -326,7 +326,58 @@ const result = await webFetch.execute(
|
|
|
326
326
|
// Returns markdown content (HTML converted via Turndown, truncated at 100K chars)
|
|
327
327
|
```
|
|
328
328
|
|
|
329
|
-
**Parameters:** `url` (string
|
|
329
|
+
**Parameters:** `url` (string, must be valid URL)
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### web-search
|
|
334
|
+
|
|
335
|
+
Search the web with a callback-based implementation (bring your own search provider).
|
|
336
|
+
|
|
337
|
+
```typescript
|
|
338
|
+
import { createWebSearch } from 'agentool/web-search';
|
|
339
|
+
|
|
340
|
+
const webSearch = createWebSearch({
|
|
341
|
+
onSearch: async (query, { allowed_domains, blocked_domains }) => {
|
|
342
|
+
// Use Tavily, SerpAPI, Google, or any search provider
|
|
343
|
+
const results = await mySearchProvider.search(query, { allowed_domains, blocked_domains });
|
|
344
|
+
return results.map(r => `${r.title}: ${r.url}\n${r.snippet}`).join('\n\n');
|
|
345
|
+
},
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
const result = await webSearch.execute(
|
|
349
|
+
{ query: 'TypeScript best practices 2024', allowed_domains: ['typescript-eslint.io'] },
|
|
350
|
+
{ toolCallId: 'id', messages: [] },
|
|
351
|
+
);
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
**Parameters:** `query` (string, min 2 chars), `allowed_domains?` (string[]), `blocked_domains?` (string[])
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### tool-search
|
|
359
|
+
|
|
360
|
+
Search through a registry of available tools by name or keyword.
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
import { createToolSearch } from 'agentool/tool-search';
|
|
364
|
+
|
|
365
|
+
const toolSearch = createToolSearch({
|
|
366
|
+
tools: {
|
|
367
|
+
bash: { description: 'Execute shell commands' },
|
|
368
|
+
grep: { description: 'Search file contents with regex' },
|
|
369
|
+
read: { description: 'Read file contents' },
|
|
370
|
+
},
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const result = await toolSearch.execute(
|
|
374
|
+
{ query: 'file', max_results: 3 },
|
|
375
|
+
{ toolCallId: 'id', messages: [] },
|
|
376
|
+
);
|
|
377
|
+
// Returns matching tools sorted by relevance
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Parameters:** `query` (string), `max_results?` (number, default 5)
|
|
330
381
|
|
|
331
382
|
---
|
|
332
383
|
|
|
@@ -390,33 +441,78 @@ await memory.execute(
|
|
|
390
441
|
|
|
391
442
|
---
|
|
392
443
|
|
|
393
|
-
### task
|
|
444
|
+
### task-create
|
|
394
445
|
|
|
395
|
-
|
|
446
|
+
Create a new task with subject, description, and optional metadata.
|
|
396
447
|
|
|
397
448
|
```typescript
|
|
398
|
-
import {
|
|
449
|
+
import { taskCreate } from 'agentool/task-create';
|
|
399
450
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
{ action: 'create', subject: 'Fix login bug', description: 'Auth fails on refresh' },
|
|
451
|
+
const result = await taskCreate.execute(
|
|
452
|
+
{ subject: 'Fix login bug', description: 'Auth fails on refresh', metadata: { priority: 'high' } },
|
|
403
453
|
{ toolCallId: 'id', messages: [] },
|
|
404
454
|
);
|
|
455
|
+
```
|
|
405
456
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
457
|
+
**Parameters:** `subject` (string), `description` (string), `metadata?` (Record<string, unknown>)
|
|
458
|
+
|
|
459
|
+
---
|
|
460
|
+
|
|
461
|
+
### task-get
|
|
462
|
+
|
|
463
|
+
Retrieve a task by ID to see full details.
|
|
464
|
+
|
|
465
|
+
```typescript
|
|
466
|
+
import { taskGet } from 'agentool/task-get';
|
|
467
|
+
|
|
468
|
+
const result = await taskGet.execute(
|
|
469
|
+
{ taskId: 'abc123' },
|
|
409
470
|
{ toolCallId: 'id', messages: [] },
|
|
410
471
|
);
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
**Parameters:** `taskId` (string)
|
|
475
|
+
|
|
476
|
+
---
|
|
477
|
+
|
|
478
|
+
### task-update
|
|
479
|
+
|
|
480
|
+
Update a task's status, owner, metadata, and dependency relationships.
|
|
481
|
+
|
|
482
|
+
```typescript
|
|
483
|
+
import { taskUpdate } from 'agentool/task-update';
|
|
484
|
+
|
|
485
|
+
// Update status and owner
|
|
486
|
+
await taskUpdate.execute(
|
|
487
|
+
{ taskId: 'abc123', status: 'in_progress', owner: 'agent-1' },
|
|
488
|
+
{ toolCallId: 'id', messages: [] },
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
// Add dependencies and merge metadata (null deletes a key)
|
|
492
|
+
await taskUpdate.execute(
|
|
493
|
+
{ taskId: 'abc123', addBlockedBy: ['def456'], metadata: { priority: null, notes: 'reviewed' } },
|
|
494
|
+
{ toolCallId: 'id', messages: [] },
|
|
495
|
+
);
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
**Parameters:** `taskId` (string), `subject?` (string), `description?` (string), `status?` (`'pending'` | `'in_progress'` | `'completed'` | `'deleted'`), `owner?` (string), `activeForm?` (string), `addBlocks?` (string[]), `addBlockedBy?` (string[]), `metadata?` (Record<string, unknown>)
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
### task-list
|
|
503
|
+
|
|
504
|
+
List all non-deleted tasks with status and dependencies.
|
|
505
|
+
|
|
506
|
+
```typescript
|
|
507
|
+
import { taskList } from 'agentool/task-list';
|
|
411
508
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
{ action: 'update', id: 'abc123', status: 'completed' },
|
|
509
|
+
const result = await taskList.execute(
|
|
510
|
+
{},
|
|
415
511
|
{ toolCallId: 'id', messages: [] },
|
|
416
512
|
);
|
|
417
513
|
```
|
|
418
514
|
|
|
419
|
-
**Parameters:**
|
|
515
|
+
**Parameters:** none
|
|
420
516
|
|
|
421
517
|
---
|
|
422
518
|
|
|
@@ -440,7 +536,7 @@ const result = await lsp.execute(
|
|
|
440
536
|
);
|
|
441
537
|
```
|
|
442
538
|
|
|
443
|
-
**Parameters:** `operation` (`'goToDefinition'` | `'findReferences'` | `'hover'` | `'documentSymbol'` | `'workspaceSymbol'` | `'goToImplementation'` | `'incomingCalls'` | `'outgoingCalls'`), `filePath` (string), `line
|
|
539
|
+
**Parameters:** `operation` (`'goToDefinition'` | `'findReferences'` | `'hover'` | `'documentSymbol'` | `'workspaceSymbol'` | `'goToImplementation'` | `'prepareCallHierarchy'` | `'incomingCalls'` | `'outgoingCalls'`), `filePath` (string), `line` (number, 1-based), `character` (number, 1-based)
|
|
444
540
|
|
|
445
541
|
---
|
|
446
542
|
|
|
@@ -552,7 +648,12 @@ Tools that support timeouts extend `TimeoutConfig`:
|
|
|
552
648
|
| `bash` | `shell?: string` -- shell binary path |
|
|
553
649
|
| `read` | `maxLines?: number` -- max lines to return (default: 2000) |
|
|
554
650
|
| `memory` | `memoryDir?: string` -- storage directory |
|
|
555
|
-
| `task` | `tasksFile?: string` -- JSON file path |
|
|
651
|
+
| `task-create` | `tasksFile?: string` -- JSON file path |
|
|
652
|
+
| `task-get` | `tasksFile?: string` -- JSON file path |
|
|
653
|
+
| `task-update` | `tasksFile?: string` -- JSON file path |
|
|
654
|
+
| `task-list` | `tasksFile?: string` -- JSON file path |
|
|
655
|
+
| `web-search` | `onSearch?: (query, opts) => Promise<string>` -- search callback |
|
|
656
|
+
| `tool-search` | `tools?: Record<string, { description }>` -- tool registry |
|
|
556
657
|
| `lsp` | `servers?: Record<string, LspServerConfig>` -- LSP servers by file extension |
|
|
557
658
|
| `http-request` | `defaultHeaders?: Record<string, string>` -- headers merged into every request |
|
|
558
659
|
| `web-fetch` | `maxContentLength?: number`, `userAgent?: string` |
|
|
@@ -587,11 +688,16 @@ import {
|
|
|
587
688
|
grep, createGrep,
|
|
588
689
|
glob, createGlob,
|
|
589
690
|
webFetch, createWebFetch,
|
|
691
|
+
webSearch, createWebSearch,
|
|
692
|
+
toolSearch, createToolSearch,
|
|
590
693
|
httpRequest, createHttpRequest,
|
|
591
694
|
memory, createMemory,
|
|
592
695
|
multiEdit, createMultiEdit,
|
|
593
696
|
diff, createDiff,
|
|
594
|
-
|
|
697
|
+
taskCreate, createTaskCreate,
|
|
698
|
+
taskGet, createTaskGet,
|
|
699
|
+
taskUpdate, createTaskUpdate,
|
|
700
|
+
taskList, createTaskList,
|
|
595
701
|
lsp, createLsp,
|
|
596
702
|
contextCompaction, createContextCompaction,
|
|
597
703
|
askUser, createAskUser,
|
|
@@ -613,7 +719,12 @@ import { httpRequest } from 'agentool/http-request';
|
|
|
613
719
|
import { memory } from 'agentool/memory';
|
|
614
720
|
import { multiEdit } from 'agentool/multi-edit';
|
|
615
721
|
import { diff } from 'agentool/diff';
|
|
616
|
-
import {
|
|
722
|
+
import { taskCreate } from 'agentool/task-create';
|
|
723
|
+
import { taskGet } from 'agentool/task-get';
|
|
724
|
+
import { taskUpdate } from 'agentool/task-update';
|
|
725
|
+
import { taskList } from 'agentool/task-list';
|
|
726
|
+
import { webSearch } from 'agentool/web-search';
|
|
727
|
+
import { toolSearch } from 'agentool/tool-search';
|
|
617
728
|
import { lsp } from 'agentool/lsp';
|
|
618
729
|
import { contextCompaction } from 'agentool/context-compaction';
|
|
619
730
|
import { askUser } from 'agentool/ask-user';
|
package/dist/ask-user/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunk3EPGFWZVcjs = require('../chunk-3EPGFWZV.cjs');
|
|
5
4
|
|
|
5
|
+
var _chunkKUFZFNPTcjs = require('../chunk-KUFZFNPT.cjs');
|
|
6
|
+
require('../chunk-KONXT2SF.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.askUser = _chunkKUFZFNPTcjs.askUser; exports.askUserPrompt = _chunkKUFZFNPTcjs.getPrompt; exports.createAskUser = _chunkKUFZFNPTcjs.createAskUser;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { B as BaseToolConfig } from '../types-3QPDuCXN.cjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the ask-user tool.
|
|
6
|
+
*
|
|
7
|
+
* @returns The full description string for the ask-user tool.
|
|
8
|
+
*/
|
|
9
|
+
declare function getPrompt(): string;
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Configuration for the ask-user tool.
|
|
6
13
|
* Extends {@link BaseToolConfig} with an optional callback for receiving user input.
|
|
@@ -23,6 +30,8 @@ interface AskUserConfig extends BaseToolConfig {
|
|
|
23
30
|
* @returns The user's response string
|
|
24
31
|
*/
|
|
25
32
|
onQuestion?: (question: string, options?: string[]) => Promise<string>;
|
|
33
|
+
/** Override the default tool description. */
|
|
34
|
+
description?: string;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Creates an ask-user tool instance with the given configuration.
|
|
@@ -65,4 +74,4 @@ declare const askUser: ai.Tool<{
|
|
|
65
74
|
options?: string[] | undefined;
|
|
66
75
|
}, string>;
|
|
67
76
|
|
|
68
|
-
export { type AskUserConfig, askUser, createAskUser };
|
|
77
|
+
export { type AskUserConfig, askUser, getPrompt as askUserPrompt, createAskUser };
|
package/dist/ask-user/index.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { B as BaseToolConfig } from '../types-3QPDuCXN.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the ask-user tool.
|
|
6
|
+
*
|
|
7
|
+
* @returns The full description string for the ask-user tool.
|
|
8
|
+
*/
|
|
9
|
+
declare function getPrompt(): string;
|
|
10
|
+
|
|
4
11
|
/**
|
|
5
12
|
* Configuration for the ask-user tool.
|
|
6
13
|
* Extends {@link BaseToolConfig} with an optional callback for receiving user input.
|
|
@@ -23,6 +30,8 @@ interface AskUserConfig extends BaseToolConfig {
|
|
|
23
30
|
* @returns The user's response string
|
|
24
31
|
*/
|
|
25
32
|
onQuestion?: (question: string, options?: string[]) => Promise<string>;
|
|
33
|
+
/** Override the default tool description. */
|
|
34
|
+
description?: string;
|
|
26
35
|
}
|
|
27
36
|
/**
|
|
28
37
|
* Creates an ask-user tool instance with the given configuration.
|
|
@@ -65,4 +74,4 @@ declare const askUser: ai.Tool<{
|
|
|
65
74
|
options?: string[] | undefined;
|
|
66
75
|
}, string>;
|
|
67
76
|
|
|
68
|
-
export { type AskUserConfig, askUser, createAskUser };
|
|
77
|
+
export { type AskUserConfig, askUser, getPrompt as askUserPrompt, createAskUser };
|
package/dist/ask-user/index.js
CHANGED
package/dist/bash/index.cjs
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var _chunkSUSAPI5Wcjs = require('../chunk-SUSAPI5W.cjs');
|
|
5
4
|
|
|
5
|
+
var _chunkCXBWF5ONcjs = require('../chunk-CXBWF5ON.cjs');
|
|
6
|
+
require('../chunk-KONXT2SF.cjs');
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
exports.bash = _chunkCXBWF5ONcjs.bash; exports.bashPrompt = _chunkCXBWF5ONcjs.getPrompt; exports.createBash = _chunkCXBWF5ONcjs.createBash;
|
package/dist/bash/index.d.cts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { T as TimeoutConfig } from '../types-3QPDuCXN.cjs';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the bash tool based on its configuration.
|
|
6
|
+
*
|
|
7
|
+
* The returned string is used as the tool's `description` field in the
|
|
8
|
+
* Vercel AI SDK tool definition, providing the model with behavioral guidance.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The same config passed to {@link createBash}.
|
|
11
|
+
* @returns The full description string for the bash tool.
|
|
12
|
+
*/
|
|
13
|
+
declare function getPrompt(config?: Pick<BashConfig, 'timeout' | 'shell'>): string;
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
16
|
* Configuration for the bash tool.
|
|
6
17
|
* Extends {@link TimeoutConfig} with an optional shell binary path.
|
|
@@ -14,6 +25,8 @@ import { T as TimeoutConfig } from '../types-3QPDuCXN.cjs';
|
|
|
14
25
|
interface BashConfig extends TimeoutConfig {
|
|
15
26
|
/** Shell binary to use. Defaults to `$SHELL` or `/bin/bash`. */
|
|
16
27
|
shell?: string;
|
|
28
|
+
/** Override the default tool description. */
|
|
29
|
+
description?: string;
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Creates a bash tool that executes shell commands via {@link executeShell}.
|
|
@@ -60,4 +73,4 @@ declare const bash: ai.Tool<{
|
|
|
60
73
|
description?: string | undefined;
|
|
61
74
|
}, string>;
|
|
62
75
|
|
|
63
|
-
export { type BashConfig, bash, createBash };
|
|
76
|
+
export { type BashConfig, bash, getPrompt as bashPrompt, createBash };
|
package/dist/bash/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { T as TimeoutConfig } from '../types-3QPDuCXN.js';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Generate the description prompt for the bash tool based on its configuration.
|
|
6
|
+
*
|
|
7
|
+
* The returned string is used as the tool's `description` field in the
|
|
8
|
+
* Vercel AI SDK tool definition, providing the model with behavioral guidance.
|
|
9
|
+
*
|
|
10
|
+
* @param config - The same config passed to {@link createBash}.
|
|
11
|
+
* @returns The full description string for the bash tool.
|
|
12
|
+
*/
|
|
13
|
+
declare function getPrompt(config?: Pick<BashConfig, 'timeout' | 'shell'>): string;
|
|
14
|
+
|
|
4
15
|
/**
|
|
5
16
|
* Configuration for the bash tool.
|
|
6
17
|
* Extends {@link TimeoutConfig} with an optional shell binary path.
|
|
@@ -14,6 +25,8 @@ import { T as TimeoutConfig } from '../types-3QPDuCXN.js';
|
|
|
14
25
|
interface BashConfig extends TimeoutConfig {
|
|
15
26
|
/** Shell binary to use. Defaults to `$SHELL` or `/bin/bash`. */
|
|
16
27
|
shell?: string;
|
|
28
|
+
/** Override the default tool description. */
|
|
29
|
+
description?: string;
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
32
|
* Creates a bash tool that executes shell commands via {@link executeShell}.
|
|
@@ -60,4 +73,4 @@ declare const bash: ai.Tool<{
|
|
|
60
73
|
description?: string | undefined;
|
|
61
74
|
}, string>;
|
|
62
75
|
|
|
63
|
-
export { type BashConfig, bash, createBash };
|
|
76
|
+
export { type BashConfig, bash, getPrompt as bashPrompt, createBash };
|
package/dist/bash/index.js
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
+
|
|
3
|
+
var _chunkKONXT2SFcjs = require('./chunk-KONXT2SF.cjs');
|
|
4
|
+
|
|
5
|
+
// src/tool-search/index.ts
|
|
6
|
+
var _ai = require('ai');
|
|
7
|
+
var _zod = require('zod');
|
|
8
|
+
|
|
9
|
+
// src/tool-search/prompt.ts
|
|
10
|
+
function getPrompt() {
|
|
11
|
+
return `Search for available tools by name or keyword. Returns matching tool names and their descriptions.
|
|
12
|
+
|
|
13
|
+
Uses fuzzy matching \u2014 scores results by name and description relevance.
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
- To discover what tools are available when you're unsure which tool to use
|
|
17
|
+
- To find the right tool for a specific task by searching with keywords
|
|
18
|
+
|
|
19
|
+
## When NOT to Use
|
|
20
|
+
- When you already know the tool name \u2014 just use it directly
|
|
21
|
+
|
|
22
|
+
## Usage Guidelines
|
|
23
|
+
- Requires a tools registry to be configured via createToolSearch({ tools: { ... } })
|
|
24
|
+
- Returns up to \`max_results\` matches (default: 5), sorted by relevance
|
|
25
|
+
- Matches against both tool names and descriptions`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/tool-search/index.ts
|
|
29
|
+
function createToolSearch(config = {}) {
|
|
30
|
+
return _ai.tool.call(void 0, {
|
|
31
|
+
description: _nullishCoalesce(config.description, () => ( getPrompt())),
|
|
32
|
+
inputSchema: _zod.z.object({
|
|
33
|
+
query: _zod.z.string().describe("Query to find tools by name or keyword"),
|
|
34
|
+
max_results: _zod.z.number().optional().default(5).describe("Max results to return")
|
|
35
|
+
}),
|
|
36
|
+
execute: async ({ query, max_results }) => {
|
|
37
|
+
try {
|
|
38
|
+
const registry = _nullishCoalesce(config.tools, () => ( {}));
|
|
39
|
+
const entries = Object.entries(registry);
|
|
40
|
+
if (entries.length === 0) {
|
|
41
|
+
return "No tools registered. Provide a tools registry via createToolSearch({ tools: { ... } })";
|
|
42
|
+
}
|
|
43
|
+
const lower = query.toLowerCase();
|
|
44
|
+
const scored = entries.map(([name, { description }]) => {
|
|
45
|
+
let score = 0;
|
|
46
|
+
const nameLower = name.toLowerCase();
|
|
47
|
+
const descLower = description.toLowerCase();
|
|
48
|
+
if (nameLower === lower) score += 10;
|
|
49
|
+
else if (nameLower.includes(lower)) score += 5;
|
|
50
|
+
if (descLower.includes(lower)) score += 3;
|
|
51
|
+
for (const word of lower.split(/\s+/)) {
|
|
52
|
+
if (nameLower.includes(word)) score += 2;
|
|
53
|
+
if (descLower.includes(word)) score += 1;
|
|
54
|
+
}
|
|
55
|
+
return { name, description, score };
|
|
56
|
+
}).filter((e) => e.score > 0).sort((a, b) => b.score - a.score).slice(0, max_results);
|
|
57
|
+
if (scored.length === 0) {
|
|
58
|
+
return `No tools matched query "${query}".`;
|
|
59
|
+
}
|
|
60
|
+
return scored.map((e) => `${e.name}: ${e.description}`).join("\n");
|
|
61
|
+
} catch (error) {
|
|
62
|
+
const msg = _chunkKONXT2SFcjs.extractErrorMessage.call(void 0, error);
|
|
63
|
+
return `Error [tool-search]: ${msg}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
var toolSearch = createToolSearch();
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
exports.getPrompt = getPrompt; exports.createToolSearch = createToolSearch; exports.toolSearch = toolSearch;
|
|
@@ -1,6 +1,35 @@
|
|
|
1
|
+
import {
|
|
2
|
+
extractErrorMessage
|
|
3
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
4
|
+
|
|
1
5
|
// src/context-compaction/index.ts
|
|
2
6
|
import { tool, zodSchema } from "ai";
|
|
3
7
|
import { z } from "zod";
|
|
8
|
+
|
|
9
|
+
// src/context-compaction/prompt.ts
|
|
10
|
+
function getPrompt(config = {}) {
|
|
11
|
+
const maxTokens = config.maxTokens ?? 4096;
|
|
12
|
+
return `Compact conversation history by summarizing older messages to reduce context size. Target budget: ${maxTokens} tokens.
|
|
13
|
+
|
|
14
|
+
Requires a summarize callback to be configured \u2014 the application provides the summarization implementation.
|
|
15
|
+
|
|
16
|
+
## When to Use
|
|
17
|
+
- When the conversation is getting long and approaching context limits
|
|
18
|
+
- When earlier messages contain details no longer relevant to the current task
|
|
19
|
+
- To free up context space for new work without losing important context
|
|
20
|
+
|
|
21
|
+
## When NOT to Use
|
|
22
|
+
- When the conversation is still within budget \u2014 the tool returns early if already compact
|
|
23
|
+
- When every message contains critical details that shouldn't be summarized
|
|
24
|
+
- For persisting information long-term \u2014 use the memory tool instead
|
|
25
|
+
|
|
26
|
+
## Usage Guidelines
|
|
27
|
+
- Messages already within the token budget (${maxTokens} tokens, ~${maxTokens * 4} characters) are returned unchanged
|
|
28
|
+
- The summarize callback receives all messages and should return a condensed summary
|
|
29
|
+
- The result replaces the original messages with a single system message containing the summary`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/context-compaction/index.ts
|
|
4
33
|
var parametersSchema = z.object({
|
|
5
34
|
messages: z.array(
|
|
6
35
|
z.object({
|
|
@@ -14,7 +43,7 @@ var parametersSchema = z.object({
|
|
|
14
43
|
});
|
|
15
44
|
function createContextCompaction(config = {}) {
|
|
16
45
|
return tool({
|
|
17
|
-
description:
|
|
46
|
+
description: config.description ?? getPrompt(config),
|
|
18
47
|
inputSchema: zodSchema(parametersSchema),
|
|
19
48
|
execute: async ({
|
|
20
49
|
messages,
|
|
@@ -45,7 +74,7 @@ function createContextCompaction(config = {}) {
|
|
|
45
74
|
originalCount: messages.length
|
|
46
75
|
});
|
|
47
76
|
} catch (error) {
|
|
48
|
-
const msg =
|
|
77
|
+
const msg = extractErrorMessage(error);
|
|
49
78
|
return `Error [context-compaction]: Summarization failed: ${msg}`;
|
|
50
79
|
}
|
|
51
80
|
}
|
|
@@ -54,6 +83,7 @@ function createContextCompaction(config = {}) {
|
|
|
54
83
|
var contextCompaction = createContextCompaction();
|
|
55
84
|
|
|
56
85
|
export {
|
|
86
|
+
getPrompt,
|
|
57
87
|
createContextCompaction,
|
|
58
88
|
contextCompaction
|
|
59
89
|
};
|
|
@@ -1,15 +1,50 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeRipgrep
|
|
3
3
|
} from "./chunk-MJCAXASI.js";
|
|
4
|
+
import {
|
|
5
|
+
getFileStats
|
|
6
|
+
} from "./chunk-PWBVB6MN.js";
|
|
4
7
|
import {
|
|
5
8
|
expandPath,
|
|
6
9
|
toRelativePath
|
|
7
10
|
} from "./chunk-I3ONDY7P.js";
|
|
11
|
+
import {
|
|
12
|
+
extractErrorMessage
|
|
13
|
+
} from "./chunk-X6ZY2KFU.js";
|
|
8
14
|
|
|
9
15
|
// src/grep/index.ts
|
|
10
|
-
import { stat } from "fs/promises";
|
|
11
16
|
import { tool } from "ai";
|
|
12
17
|
import { z } from "zod";
|
|
18
|
+
|
|
19
|
+
// src/grep/prompt.ts
|
|
20
|
+
function getPrompt() {
|
|
21
|
+
return `Search file contents using ripgrep. Supports regex patterns, context lines, and multiple output modes.
|
|
22
|
+
|
|
23
|
+
## When to Use
|
|
24
|
+
- To find where a function, variable, string, or pattern is used across files
|
|
25
|
+
- To search for specific code patterns, error messages, or configuration values
|
|
26
|
+
- To count occurrences of a pattern across a codebase
|
|
27
|
+
|
|
28
|
+
## When NOT to Use
|
|
29
|
+
- To find files by name/extension \u2014 use the dedicated file search tool instead
|
|
30
|
+
- To read a specific file \u2014 use the file reading tool instead
|
|
31
|
+
- Don't use shell commands (grep, rg) for content search when this tool is available
|
|
32
|
+
|
|
33
|
+
## Output Modes
|
|
34
|
+
- \`files_with_matches\` (default): Returns file paths containing matches, sorted by modification time. Best for discovering which files contain a pattern.
|
|
35
|
+
- \`content\`: Returns matching lines with optional context. Supports \`-A\` (after), \`-B\` (before), \`-C\` (context) for surrounding lines and \`-n\` for line numbers (default: true).
|
|
36
|
+
- \`count\`: Returns match counts per file with totals.
|
|
37
|
+
|
|
38
|
+
## Usage Guidelines
|
|
39
|
+
- Uses ripgrep regex syntax (not grep). Literal braces need escaping: use \`interface\\{\\}\` to find \`interface{}\`
|
|
40
|
+
- Filter files with the \`glob\` parameter (e.g., "*.js", "*.{ts,tsx}") or \`type\` parameter (e.g., "js", "py")
|
|
41
|
+
- Default head_limit is 250 entries. Pass \`head_limit: 0\` for unlimited (use sparingly \u2014 large results waste context)
|
|
42
|
+
- Use \`offset\` to paginate through large result sets
|
|
43
|
+
- Enable \`multiline: true\` for patterns that span lines (e.g., \`struct \\{[\\s\\S]*?field\`)
|
|
44
|
+
- Use \`-i: true\` for case-insensitive search`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/grep/index.ts
|
|
13
48
|
var VCS_DIRS = [".git", ".svn", ".hg", ".bzr", ".jj", ".sl"];
|
|
14
49
|
var DEFAULT_HEAD_LIMIT = 250;
|
|
15
50
|
function applyHeadLimit(items, limit, offset = 0) {
|
|
@@ -48,22 +83,22 @@ function parseGlobPatterns(globFilter) {
|
|
|
48
83
|
function createGrep(config = {}) {
|
|
49
84
|
const cwd = config.cwd ?? process.cwd();
|
|
50
85
|
return tool({
|
|
51
|
-
description:
|
|
86
|
+
description: config.description ?? getPrompt(),
|
|
52
87
|
inputSchema: z.object({
|
|
53
|
-
pattern: z.string().describe("
|
|
54
|
-
path: z.string().optional().describe("File or directory to search in"),
|
|
55
|
-
glob: z.string().optional().describe('Glob pattern to filter files (e.g. "*.js")'),
|
|
56
|
-
output_mode: z.enum(["content", "files_with_matches", "count"]).optional().describe('Output mode. Defaults to "files_with_matches".'),
|
|
57
|
-
"-B": z.number().optional().describe(
|
|
58
|
-
"-A": z.number().optional().describe(
|
|
59
|
-
"-C": z.number().optional().describe("
|
|
60
|
-
context: z.number().optional().describe(
|
|
61
|
-
"-n": z.boolean().optional().describe(
|
|
62
|
-
"-i": z.boolean().optional().describe("Case insensitive search"),
|
|
63
|
-
type: z.string().optional().describe(
|
|
64
|
-
head_limit: z.number().optional().describe("
|
|
65
|
-
offset: z.number().optional().describe(
|
|
66
|
-
multiline: z.boolean().optional().describe("Enable multiline
|
|
88
|
+
pattern: z.string().describe("The regular expression pattern to search for in file contents"),
|
|
89
|
+
path: z.string().optional().describe("File or directory to search in (rg PATH). Defaults to current working directory."),
|
|
90
|
+
glob: z.string().optional().describe('Glob pattern to filter files (e.g. "*.js", "*.{ts,tsx}") - maps to rg --glob'),
|
|
91
|
+
output_mode: z.enum(["content", "files_with_matches", "count"]).optional().describe('Output mode: "content" shows matching lines (supports -A/-B/-C context, -n line numbers, head_limit), "files_with_matches" shows file paths (supports head_limit), "count" shows match counts (supports head_limit). Defaults to "files_with_matches".'),
|
|
92
|
+
"-B": z.number().optional().describe('Number of lines to show before each match (rg -B). Requires output_mode: "content", ignored otherwise.'),
|
|
93
|
+
"-A": z.number().optional().describe('Number of lines to show after each match (rg -A). Requires output_mode: "content", ignored otherwise.'),
|
|
94
|
+
"-C": z.number().optional().describe("Alias for context."),
|
|
95
|
+
context: z.number().optional().describe('Number of lines to show before and after each match (rg -C). Requires output_mode: "content", ignored otherwise.'),
|
|
96
|
+
"-n": z.boolean().optional().describe('Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise. Defaults to true.'),
|
|
97
|
+
"-i": z.boolean().optional().describe("Case insensitive search (rg -i)"),
|
|
98
|
+
type: z.string().optional().describe("File type to search (rg --type). Common types: js, py, rust, go, java, etc. More efficient than include for standard file types."),
|
|
99
|
+
head_limit: z.number().optional().describe('Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to 250 when unspecified. Pass 0 for unlimited (use sparingly \u2014 large result sets waste context).'),
|
|
100
|
+
offset: z.number().optional().describe('Skip first N lines/entries before applying head_limit, equivalent to "| tail -n +N | head -N". Works across all output modes. Defaults to 0.'),
|
|
101
|
+
multiline: z.boolean().optional().describe("Enable multiline mode where . matches newlines and patterns can span lines (rg -U --multiline-dotall). Default: false.")
|
|
67
102
|
}),
|
|
68
103
|
execute: async (input) => {
|
|
69
104
|
try {
|
|
@@ -132,7 +167,7 @@ function createGrep(config = {}) {
|
|
|
132
167
|
|
|
133
168
|
Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(appliedLimit2, offset);
|
|
134
169
|
}
|
|
135
|
-
const stats = await Promise.allSettled(results.map((f) =>
|
|
170
|
+
const stats = await Promise.allSettled(results.map((f) => getFileStats(f)));
|
|
136
171
|
const sorted = results.map((fp, i) => {
|
|
137
172
|
const r = stats[i];
|
|
138
173
|
const mt = r.status === "fulfilled" ? r.value.mtimeMs ?? 0 : 0;
|
|
@@ -145,7 +180,7 @@ Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(applied
|
|
|
145
180
|
const relative = items.map((f) => toRelativePath(f, cwd));
|
|
146
181
|
return relative.join("\n") + truncationSuffix(appliedLimit, offset);
|
|
147
182
|
} catch (error) {
|
|
148
|
-
const msg =
|
|
183
|
+
const msg = extractErrorMessage(error);
|
|
149
184
|
return `Error [grep]: Failed to search: ${msg}`;
|
|
150
185
|
}
|
|
151
186
|
}
|
|
@@ -154,6 +189,7 @@ Total: ${totalMatches} matches in ${fileCount} files` + truncationSuffix(applied
|
|
|
154
189
|
var grep = createGrep();
|
|
155
190
|
|
|
156
191
|
export {
|
|
192
|
+
getPrompt,
|
|
157
193
|
createGrep,
|
|
158
194
|
grep
|
|
159
195
|
};
|