@agentforge/tools 0.10.7 → 0.11.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 +39 -39
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,23 +44,23 @@ All tools feature:
|
|
|
44
44
|
import { httpGet, jsonParser, fileReader, calculator } from '@agentforge/tools';
|
|
45
45
|
|
|
46
46
|
// Make an HTTP GET request
|
|
47
|
-
const response = await httpGet.
|
|
47
|
+
const response = await httpGet.invoke({
|
|
48
48
|
url: 'https://api.example.com/data'
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
// Parse JSON
|
|
52
|
-
const parsed = await jsonParser.
|
|
52
|
+
const parsed = await jsonParser.invoke({
|
|
53
53
|
json: '{"name": "John", "age": 30}'
|
|
54
54
|
});
|
|
55
55
|
|
|
56
56
|
// Read a file
|
|
57
|
-
const file = await fileReader.
|
|
57
|
+
const file = await fileReader.invoke({
|
|
58
58
|
path: './data.txt',
|
|
59
59
|
encoding: 'utf8'
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
// Perform calculations
|
|
63
|
-
const result = await calculator.
|
|
63
|
+
const result = await calculator.invoke({
|
|
64
64
|
operation: 'add',
|
|
65
65
|
a: 10,
|
|
66
66
|
b: 20
|
|
@@ -213,7 +213,7 @@ General utility tools for common operations.
|
|
|
213
213
|
import { webSearch } from '@agentforge/tools';
|
|
214
214
|
|
|
215
215
|
// Basic search (no API key needed - uses DuckDuckGo)
|
|
216
|
-
const result = await webSearch.
|
|
216
|
+
const result = await webSearch.invoke({
|
|
217
217
|
query: 'TypeScript programming language',
|
|
218
218
|
maxResults: 10
|
|
219
219
|
});
|
|
@@ -226,7 +226,7 @@ result.results.forEach(r => {
|
|
|
226
226
|
|
|
227
227
|
// Premium search with Serper API (requires SERPER_API_KEY env var)
|
|
228
228
|
// Get your API key at: https://serper.dev
|
|
229
|
-
const premiumResult = await webSearch.
|
|
229
|
+
const premiumResult = await webSearch.invoke({
|
|
230
230
|
query: 'Latest AI developments 2026',
|
|
231
231
|
maxResults: 5,
|
|
232
232
|
preferSerper: true // Use Serper for Google search results
|
|
@@ -291,7 +291,7 @@ SERPER_API_KEY=your-serper-api-key-here
|
|
|
291
291
|
```typescript
|
|
292
292
|
import { webScraper } from '@agentforge/tools';
|
|
293
293
|
|
|
294
|
-
const result = await webScraper.
|
|
294
|
+
const result = await webScraper.invoke({
|
|
295
295
|
url: 'https://example.com',
|
|
296
296
|
selector: 'article h1',
|
|
297
297
|
extractText: true,
|
|
@@ -316,26 +316,26 @@ import {
|
|
|
316
316
|
} from '@agentforge/tools';
|
|
317
317
|
|
|
318
318
|
// Send a simple message
|
|
319
|
-
const message = await sendSlackMessage.
|
|
319
|
+
const message = await sendSlackMessage.invoke({
|
|
320
320
|
channel: 'general',
|
|
321
321
|
message: 'Hello from AgentForge!'
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
// Send a notification with mentions
|
|
325
|
-
const notification = await notifySlack.
|
|
325
|
+
const notification = await notifySlack.invoke({
|
|
326
326
|
channel: 'alerts',
|
|
327
327
|
message: 'System alert: High CPU usage detected',
|
|
328
328
|
mentions: ['john', 'jane'] // Will send as: @john @jane System alert...
|
|
329
329
|
});
|
|
330
330
|
|
|
331
331
|
// List available channels
|
|
332
|
-
const channels = await getSlackChannels.
|
|
332
|
+
const channels = await getSlackChannels.invoke({
|
|
333
333
|
include_private: false // Only public channels
|
|
334
334
|
});
|
|
335
335
|
console.log(channels.data?.channels);
|
|
336
336
|
|
|
337
337
|
// Read message history
|
|
338
|
-
const history = await getSlackMessages.
|
|
338
|
+
const history = await getSlackMessages.invoke({
|
|
339
339
|
channel: 'general',
|
|
340
340
|
limit: 50
|
|
341
341
|
});
|
|
@@ -348,7 +348,7 @@ const customTools = createSlackTools({
|
|
|
348
348
|
botIcon: ':rocket:'
|
|
349
349
|
});
|
|
350
350
|
|
|
351
|
-
await customTools.sendMessage.
|
|
351
|
+
await customTools.sendMessage.invoke({
|
|
352
352
|
channel: 'general',
|
|
353
353
|
message: 'Message from custom bot!'
|
|
354
354
|
});
|
|
@@ -384,34 +384,34 @@ import {
|
|
|
384
384
|
} from '@agentforge/tools';
|
|
385
385
|
|
|
386
386
|
// Search for pages
|
|
387
|
-
const searchResults = await searchConfluence.
|
|
387
|
+
const searchResults = await searchConfluence.invoke({
|
|
388
388
|
cql: 'type=page AND space=DOCS',
|
|
389
389
|
limit: 10
|
|
390
390
|
});
|
|
391
391
|
console.log(`Found ${searchResults.results.length} pages`);
|
|
392
392
|
|
|
393
393
|
// Get a specific page
|
|
394
|
-
const page = await getConfluencePage.
|
|
394
|
+
const page = await getConfluencePage.invoke({
|
|
395
395
|
page_id: '123456'
|
|
396
396
|
});
|
|
397
397
|
console.log(`Page title: ${page.page.title}`);
|
|
398
398
|
console.log(`Content: ${page.page.content}`);
|
|
399
399
|
|
|
400
400
|
// List all spaces
|
|
401
|
-
const spaces = await listConfluenceSpaces.
|
|
401
|
+
const spaces = await listConfluenceSpaces.invoke({
|
|
402
402
|
limit: 50
|
|
403
403
|
});
|
|
404
404
|
console.log(`Found ${spaces.spaces.length} spaces`);
|
|
405
405
|
|
|
406
406
|
// Get pages from a space
|
|
407
|
-
const spacePages = await getSpacePages.
|
|
407
|
+
const spacePages = await getSpacePages.invoke({
|
|
408
408
|
space_key: 'DOCS',
|
|
409
409
|
limit: 25
|
|
410
410
|
});
|
|
411
411
|
console.log(`Found ${spacePages.pages.length} pages in DOCS space`);
|
|
412
412
|
|
|
413
413
|
// Create a new page
|
|
414
|
-
const newPage = await createConfluencePage.
|
|
414
|
+
const newPage = await createConfluencePage.invoke({
|
|
415
415
|
space_key: 'DOCS',
|
|
416
416
|
title: 'My New Page',
|
|
417
417
|
content: '<p>This is the page content in HTML format</p>',
|
|
@@ -420,7 +420,7 @@ const newPage = await createConfluencePage.execute({
|
|
|
420
420
|
console.log(`Created page with ID: ${newPage.page.id}`);
|
|
421
421
|
|
|
422
422
|
// Update an existing page
|
|
423
|
-
const updated = await updateConfluencePage.
|
|
423
|
+
const updated = await updateConfluencePage.invoke({
|
|
424
424
|
page_id: newPage.page.id,
|
|
425
425
|
title: 'Updated Page Title',
|
|
426
426
|
content: '<p>Updated content</p>'
|
|
@@ -428,7 +428,7 @@ const updated = await updateConfluencePage.execute({
|
|
|
428
428
|
console.log(`Updated to version ${updated.page.version}`);
|
|
429
429
|
|
|
430
430
|
// Archive a page
|
|
431
|
-
const archived = await archiveConfluencePage.
|
|
431
|
+
const archived = await archiveConfluencePage.invoke({
|
|
432
432
|
page_id: newPage.page.id,
|
|
433
433
|
reason: 'No longer needed'
|
|
434
434
|
});
|
|
@@ -441,7 +441,7 @@ const customTools = createConfluenceTools({
|
|
|
441
441
|
siteUrl: 'https://your-domain.atlassian.net'
|
|
442
442
|
});
|
|
443
443
|
|
|
444
|
-
await customTools.searchConfluence.
|
|
444
|
+
await customTools.searchConfluence.invoke({
|
|
445
445
|
cql: 'type=page',
|
|
446
446
|
limit: 5
|
|
447
447
|
});
|
|
@@ -468,13 +468,13 @@ ATLASSIAN_SITE_URL=https://your-domain.atlassian.net
|
|
|
468
468
|
import { csvParser, arrayFilter, arraySort } from '@agentforge/tools';
|
|
469
469
|
|
|
470
470
|
// Parse CSV data
|
|
471
|
-
const parsed = await csvParser.
|
|
471
|
+
const parsed = await csvParser.invoke({
|
|
472
472
|
csv: 'name,age,city\nJohn,30,NYC\nJane,25,LA',
|
|
473
473
|
hasHeaders: true
|
|
474
474
|
});
|
|
475
475
|
|
|
476
476
|
// Filter the data
|
|
477
|
-
const filtered = await arrayFilter.
|
|
477
|
+
const filtered = await arrayFilter.invoke({
|
|
478
478
|
array: parsed.data,
|
|
479
479
|
property: 'age',
|
|
480
480
|
operator: 'greater-than',
|
|
@@ -482,7 +482,7 @@ const filtered = await arrayFilter.execute({
|
|
|
482
482
|
});
|
|
483
483
|
|
|
484
484
|
// Sort the results
|
|
485
|
-
const sorted = await arraySort.
|
|
485
|
+
const sorted = await arraySort.invoke({
|
|
486
486
|
array: filtered.filtered,
|
|
487
487
|
property: 'age',
|
|
488
488
|
order: 'desc'
|
|
@@ -497,7 +497,7 @@ console.log(sorted.sorted);
|
|
|
497
497
|
import { fileReader, fileWriter, directoryList } from '@agentforge/tools';
|
|
498
498
|
|
|
499
499
|
// Read a file
|
|
500
|
-
const content = await fileReader.
|
|
500
|
+
const content = await fileReader.invoke({
|
|
501
501
|
path: './data.json',
|
|
502
502
|
encoding: 'utf8'
|
|
503
503
|
});
|
|
@@ -506,14 +506,14 @@ const content = await fileReader.execute({
|
|
|
506
506
|
const processed = JSON.parse(content.content);
|
|
507
507
|
processed.updated = new Date().toISOString();
|
|
508
508
|
|
|
509
|
-
await fileWriter.
|
|
509
|
+
await fileWriter.invoke({
|
|
510
510
|
path: './data-updated.json',
|
|
511
511
|
content: JSON.stringify(processed, null, 2),
|
|
512
512
|
createDirs: true
|
|
513
513
|
});
|
|
514
514
|
|
|
515
515
|
// List directory
|
|
516
|
-
const files = await directoryList.
|
|
516
|
+
const files = await directoryList.invoke({
|
|
517
517
|
path: './',
|
|
518
518
|
recursive: false,
|
|
519
519
|
includeDetails: true
|
|
@@ -528,13 +528,13 @@ console.log(files.files);
|
|
|
528
528
|
import { currentDateTime, dateArithmetic, dateDifference } from '@agentforge/tools';
|
|
529
529
|
|
|
530
530
|
// Get current date
|
|
531
|
-
const now = await currentDateTime.
|
|
531
|
+
const now = await currentDateTime.invoke({
|
|
532
532
|
format: 'custom',
|
|
533
533
|
customFormat: 'yyyy-MM-dd HH:mm:ss'
|
|
534
534
|
});
|
|
535
535
|
|
|
536
536
|
// Add 7 days
|
|
537
|
-
const future = await dateArithmetic.
|
|
537
|
+
const future = await dateArithmetic.invoke({
|
|
538
538
|
date: now.iso,
|
|
539
539
|
operation: 'add',
|
|
540
540
|
amount: 7,
|
|
@@ -542,7 +542,7 @@ const future = await dateArithmetic.execute({
|
|
|
542
542
|
});
|
|
543
543
|
|
|
544
544
|
// Calculate difference
|
|
545
|
-
const diff = await dateDifference.
|
|
545
|
+
const diff = await dateDifference.invoke({
|
|
546
546
|
startDate: now.iso,
|
|
547
547
|
endDate: future.result,
|
|
548
548
|
unit: 'hours'
|
|
@@ -557,20 +557,20 @@ console.log(`${diff.difference} hours until ${future.result}`);
|
|
|
557
557
|
import { stringCaseConverter, stringReplace, stringSplit } from '@agentforge/tools';
|
|
558
558
|
|
|
559
559
|
// Convert to different cases
|
|
560
|
-
const camel = await stringCaseConverter.
|
|
560
|
+
const camel = await stringCaseConverter.invoke({
|
|
561
561
|
text: 'hello world example',
|
|
562
562
|
targetCase: 'camel'
|
|
563
563
|
});
|
|
564
564
|
// Result: "helloWorldExample"
|
|
565
565
|
|
|
566
|
-
const kebab = await stringCaseConverter.
|
|
566
|
+
const kebab = await stringCaseConverter.invoke({
|
|
567
567
|
text: 'HelloWorldExample',
|
|
568
568
|
targetCase: 'kebab'
|
|
569
569
|
});
|
|
570
570
|
// Result: "hello-world-example"
|
|
571
571
|
|
|
572
572
|
// Replace text
|
|
573
|
-
const replaced = await stringReplace.
|
|
573
|
+
const replaced = await stringReplace.invoke({
|
|
574
574
|
text: 'Hello World, Hello Universe',
|
|
575
575
|
search: 'Hello',
|
|
576
576
|
replace: 'Hi',
|
|
@@ -579,7 +579,7 @@ const replaced = await stringReplace.execute({
|
|
|
579
579
|
// Result: "Hi World, Hi Universe"
|
|
580
580
|
|
|
581
581
|
// Split string
|
|
582
|
-
const parts = await stringSplit.
|
|
582
|
+
const parts = await stringSplit.invoke({
|
|
583
583
|
text: 'apple,banana,orange',
|
|
584
584
|
delimiter: ','
|
|
585
585
|
});
|
|
@@ -592,19 +592,19 @@ const parts = await stringSplit.execute({
|
|
|
592
592
|
import { emailValidator, urlValidatorSimple, creditCardValidator } from '@agentforge/tools';
|
|
593
593
|
|
|
594
594
|
// Validate email
|
|
595
|
-
const email = await emailValidator.
|
|
595
|
+
const email = await emailValidator.invoke({
|
|
596
596
|
email: 'user@example.com'
|
|
597
597
|
});
|
|
598
598
|
console.log(email.valid); // true
|
|
599
599
|
|
|
600
600
|
// Validate URL
|
|
601
|
-
const url = await urlValidatorSimple.
|
|
601
|
+
const url = await urlValidatorSimple.invoke({
|
|
602
602
|
url: 'https://example.com/path'
|
|
603
603
|
});
|
|
604
604
|
console.log(url.valid); // true
|
|
605
605
|
|
|
606
606
|
// Validate credit card
|
|
607
|
-
const card = await creditCardValidator.
|
|
607
|
+
const card = await creditCardValidator.invoke({
|
|
608
608
|
cardNumber: '4532-1488-0343-6467'
|
|
609
609
|
});
|
|
610
610
|
console.log(card.valid); // true (passes Luhn check)
|
|
@@ -650,7 +650,7 @@ interface Tool<TInput, TOutput> {
|
|
|
650
650
|
Most tools return a result object with a `success` field:
|
|
651
651
|
|
|
652
652
|
```typescript
|
|
653
|
-
const result = await someTool.
|
|
653
|
+
const result = await someTool.invoke({ ... });
|
|
654
654
|
|
|
655
655
|
if (result.success) {
|
|
656
656
|
console.log(result.data);
|
|
@@ -667,7 +667,7 @@ All tools are fully typed with TypeScript:
|
|
|
667
667
|
import { httpGet } from '@agentforge/tools';
|
|
668
668
|
|
|
669
669
|
// TypeScript knows the input type
|
|
670
|
-
const result = await httpGet.
|
|
670
|
+
const result = await httpGet.invoke({
|
|
671
671
|
url: 'https://api.example.com',
|
|
672
672
|
headers: { 'Authorization': 'Bearer token' }
|
|
673
673
|
});
|
|
@@ -733,7 +733,7 @@ const customTools = createSlackTools({
|
|
|
733
733
|
});
|
|
734
734
|
|
|
735
735
|
// Use custom tools
|
|
736
|
-
await customTools.sendMessage.
|
|
736
|
+
await customTools.sendMessage.invoke({
|
|
737
737
|
channel: 'general',
|
|
738
738
|
message: 'Hello from custom bot!'
|
|
739
739
|
});
|