@agentforge/core 0.6.4 → 0.8.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 CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  ## ✨ Features
14
14
 
15
- ### 🛠️ Tool System (Phase 1)
15
+ ### 🛠️ Tool System
16
16
  - **Rich Metadata** - Categories, tags, examples, and detailed descriptions
17
17
  - **Fluent Builder API** - Easy tool creation with `createTool()`
18
18
  - **Tool Registry** - Centralized management with querying and events
@@ -20,7 +20,7 @@
20
20
  - **Prompt Generation** - Automatic LLM-friendly prompt generation
21
21
  - **113 tests** - Comprehensive test coverage
22
22
 
23
- ### 📊 LangGraph Utilities (Phase 2)
23
+ ### 📊 LangGraph Utilities
24
24
  - **State Management** - Type-safe state annotations with Zod validation
25
25
  - **Workflow Builders** - Sequential, parallel, and conditional patterns
26
26
  - **Error Handling** - Retry, error handling, and timeout utilities
@@ -29,13 +29,13 @@
29
29
  - **Observability** - LangSmith integration, metrics, logging, error reporting
30
30
  - **158 tests** - Full coverage of all utilities
31
31
 
32
- ### � Middleware System (Phase 4)
32
+ ### � Middleware System
33
33
  - **Composable Middleware** - Caching, rate limiting, validation, concurrency control
34
34
  - **Production Presets** - Ready-to-use middleware stacks
35
35
  - **Development Tools** - Logging, debugging, and testing middleware
36
36
  - **94 tests** - Comprehensive middleware testing
37
37
 
38
- ### 🌊 Streaming & Real-time (Phase 5.1)
38
+ ### 🌊 Streaming & Real-time
39
39
  - **Stream Transformers** - Filter, map, batch, debounce, throttle
40
40
  - **Stream Aggregators** - Collect, reduce, window operations
41
41
  - **SSE Support** - Server-Sent Events for real-time updates
@@ -43,25 +43,25 @@
43
43
  - **Progress Tracking** - Monitor long-running operations
44
44
  - **68 tests** - Full streaming coverage
45
45
 
46
- ### 🛠️ Advanced Tools (Phase 5.2)
46
+ ### 🛠️ Advanced Tools
47
47
  - **Async Execution** - Parallel and sequential tool execution
48
48
  - **Lifecycle Management** - Setup, teardown, and cleanup hooks
49
49
  - **Tool Composition** - Combine tools into pipelines
50
50
  - **Testing Utilities** - Mock tools and test helpers
51
51
 
52
- ### 📦 Resource Management (Phase 5.3)
52
+ ### 📦 Resource Management
53
53
  - **Connection Pooling** - Efficient resource reuse
54
54
  - **Memory Management** - Automatic cleanup and limits
55
55
  - **Batch Processing** - Efficient bulk operations
56
56
  - **Circuit Breaker** - Fault tolerance and resilience
57
57
 
58
- ### � Monitoring (Phase 5.4)
58
+ ### � Monitoring
59
59
  - **Health Checks** - System and component health monitoring
60
60
  - **Profiling** - Performance metrics and bottleneck detection
61
61
  - **Alerts** - Configurable alerting system
62
62
  - **Audit Logging** - Comprehensive activity tracking
63
63
 
64
- ### 🚀 Deployment (Phase 5.5)
64
+ ### 🚀 Deployment
65
65
  - **Docker Support** - Production-ready containers
66
66
  - **Kubernetes** - Deployment manifests and guides
67
67
  - **CI/CD Templates** - GitHub Actions, GitLab CI
package/dist/index.cjs CHANGED
@@ -688,13 +688,51 @@ var ToolBuilder = class {
688
688
  }
689
689
  /**
690
690
  * Set the implementation function (required)
691
- *
691
+ *
692
692
  * @param execute - Async function that implements the tool
693
693
  */
694
694
  implement(execute) {
695
695
  this._execute = execute;
696
696
  return this;
697
697
  }
698
+ /**
699
+ * Set the implementation function with automatic error handling
700
+ *
701
+ * Wraps the implementation in a try-catch block and returns a standardized
702
+ * result object with success/error information.
703
+ *
704
+ * @param execute - Async function that implements the tool
705
+ * @returns ToolBuilder with safe result type { success: boolean; data?: T; error?: string }
706
+ *
707
+ * @example
708
+ * ```ts
709
+ * const tool = toolBuilder()
710
+ * .name('read-file')
711
+ * .schema(z.object({ path: z.string() }))
712
+ * .implementSafe(async ({ path }) => {
713
+ * return await fs.readFile(path, 'utf-8');
714
+ * })
715
+ * .build();
716
+ *
717
+ * // Result will be: { success: true, data: "file content" }
718
+ * // Or on error: { success: false, error: "ENOENT: no such file..." }
719
+ * ```
720
+ */
721
+ implementSafe(execute) {
722
+ const safeExecute = async (input) => {
723
+ try {
724
+ const data = await execute(input);
725
+ return { success: true, data };
726
+ } catch (error) {
727
+ return {
728
+ success: false,
729
+ error: error instanceof Error ? error.message : String(error)
730
+ };
731
+ }
732
+ };
733
+ this._execute = safeExecute;
734
+ return this;
735
+ }
698
736
  /**
699
737
  * Build the tool with validation
700
738
  *
package/dist/index.d.cts CHANGED
@@ -1070,6 +1070,34 @@ declare class ToolBuilder<TInput = unknown, TOutput = unknown> {
1070
1070
  * @param execute - Async function that implements the tool
1071
1071
  */
1072
1072
  implement<T>(execute: (input: TInput) => Promise<T>): ToolBuilder<TInput, T>;
1073
+ /**
1074
+ * Set the implementation function with automatic error handling
1075
+ *
1076
+ * Wraps the implementation in a try-catch block and returns a standardized
1077
+ * result object with success/error information.
1078
+ *
1079
+ * @param execute - Async function that implements the tool
1080
+ * @returns ToolBuilder with safe result type { success: boolean; data?: T; error?: string }
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * const tool = toolBuilder()
1085
+ * .name('read-file')
1086
+ * .schema(z.object({ path: z.string() }))
1087
+ * .implementSafe(async ({ path }) => {
1088
+ * return await fs.readFile(path, 'utf-8');
1089
+ * })
1090
+ * .build();
1091
+ *
1092
+ * // Result will be: { success: true, data: "file content" }
1093
+ * // Or on error: { success: false, error: "ENOENT: no such file..." }
1094
+ * ```
1095
+ */
1096
+ implementSafe<T>(execute: (input: TInput) => Promise<T>): ToolBuilder<TInput, {
1097
+ success: boolean;
1098
+ data?: T;
1099
+ error?: string;
1100
+ }>;
1073
1101
  /**
1074
1102
  * Build the tool with validation
1075
1103
  *
package/dist/index.d.ts CHANGED
@@ -1070,6 +1070,34 @@ declare class ToolBuilder<TInput = unknown, TOutput = unknown> {
1070
1070
  * @param execute - Async function that implements the tool
1071
1071
  */
1072
1072
  implement<T>(execute: (input: TInput) => Promise<T>): ToolBuilder<TInput, T>;
1073
+ /**
1074
+ * Set the implementation function with automatic error handling
1075
+ *
1076
+ * Wraps the implementation in a try-catch block and returns a standardized
1077
+ * result object with success/error information.
1078
+ *
1079
+ * @param execute - Async function that implements the tool
1080
+ * @returns ToolBuilder with safe result type { success: boolean; data?: T; error?: string }
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * const tool = toolBuilder()
1085
+ * .name('read-file')
1086
+ * .schema(z.object({ path: z.string() }))
1087
+ * .implementSafe(async ({ path }) => {
1088
+ * return await fs.readFile(path, 'utf-8');
1089
+ * })
1090
+ * .build();
1091
+ *
1092
+ * // Result will be: { success: true, data: "file content" }
1093
+ * // Or on error: { success: false, error: "ENOENT: no such file..." }
1094
+ * ```
1095
+ */
1096
+ implementSafe<T>(execute: (input: TInput) => Promise<T>): ToolBuilder<TInput, {
1097
+ success: boolean;
1098
+ data?: T;
1099
+ error?: string;
1100
+ }>;
1073
1101
  /**
1074
1102
  * Build the tool with validation
1075
1103
  *
package/dist/index.js CHANGED
@@ -532,13 +532,51 @@ var ToolBuilder = class {
532
532
  }
533
533
  /**
534
534
  * Set the implementation function (required)
535
- *
535
+ *
536
536
  * @param execute - Async function that implements the tool
537
537
  */
538
538
  implement(execute) {
539
539
  this._execute = execute;
540
540
  return this;
541
541
  }
542
+ /**
543
+ * Set the implementation function with automatic error handling
544
+ *
545
+ * Wraps the implementation in a try-catch block and returns a standardized
546
+ * result object with success/error information.
547
+ *
548
+ * @param execute - Async function that implements the tool
549
+ * @returns ToolBuilder with safe result type { success: boolean; data?: T; error?: string }
550
+ *
551
+ * @example
552
+ * ```ts
553
+ * const tool = toolBuilder()
554
+ * .name('read-file')
555
+ * .schema(z.object({ path: z.string() }))
556
+ * .implementSafe(async ({ path }) => {
557
+ * return await fs.readFile(path, 'utf-8');
558
+ * })
559
+ * .build();
560
+ *
561
+ * // Result will be: { success: true, data: "file content" }
562
+ * // Or on error: { success: false, error: "ENOENT: no such file..." }
563
+ * ```
564
+ */
565
+ implementSafe(execute) {
566
+ const safeExecute = async (input) => {
567
+ try {
568
+ const data = await execute(input);
569
+ return { success: true, data };
570
+ } catch (error) {
571
+ return {
572
+ success: false,
573
+ error: error instanceof Error ? error.message : String(error)
574
+ };
575
+ }
576
+ };
577
+ this._execute = safeExecute;
578
+ return this;
579
+ }
542
580
  /**
543
581
  * Build the tool with validation
544
582
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentforge/core",
3
- "version": "0.6.4",
3
+ "version": "0.8.0",
4
4
  "description": "Core abstractions for AgentForge - production-ready deep agents framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",