@agentforge/core 0.16.50 → 0.16.51

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/dist/index.d.cts CHANGED
@@ -1906,119 +1906,6 @@ declare function chain<State>(): MiddlewareChain<State>;
1906
1906
  */
1907
1907
  declare function createMiddlewareContext(): MiddlewareContext;
1908
1908
 
1909
- /**
1910
- * Retry pattern for LangGraph nodes
1911
- *
1912
- * Wraps a node function with retry logic.
1913
- */
1914
- /**
1915
- * Backoff strategy for retries
1916
- */
1917
- type BackoffStrategy = 'constant' | 'linear' | 'exponential';
1918
- /**
1919
- * Options for retry behavior
1920
- */
1921
- interface RetryOptions {
1922
- /**
1923
- * Maximum number of retry attempts
1924
- * @default 3
1925
- */
1926
- maxAttempts?: number;
1927
- /**
1928
- * Backoff strategy between retries
1929
- * @default 'exponential'
1930
- */
1931
- backoff?: BackoffStrategy;
1932
- /**
1933
- * Initial delay in milliseconds
1934
- * @default 1000
1935
- */
1936
- initialDelay?: number;
1937
- /**
1938
- * Maximum delay in milliseconds
1939
- * @default 30000
1940
- */
1941
- maxDelay?: number;
1942
- /**
1943
- * Optional callback when a retry occurs
1944
- */
1945
- onRetry?: (error: Error, attempt: number) => void;
1946
- /**
1947
- * Optional predicate to determine if error should be retried
1948
- * @default () => true (retry all errors)
1949
- */
1950
- shouldRetry?: (error: Error) => boolean;
1951
- }
1952
- /**
1953
- * Wraps a node function with retry logic.
1954
- *
1955
- * @example
1956
- * ```typescript
1957
- * const robustNode = withRetry(myNode, {
1958
- * maxAttempts: 3,
1959
- * backoff: 'exponential',
1960
- * initialDelay: 1000,
1961
- * onRetry: (error, attempt) => {
1962
- * console.log(`Retry attempt ${attempt}: ${error.message}`);
1963
- * },
1964
- * });
1965
- *
1966
- * graph.addNode('robust', robustNode);
1967
- * ```
1968
- *
1969
- * @param node - The node function to wrap
1970
- * @param options - Retry configuration options
1971
- * @returns A wrapped node function with retry logic
1972
- */
1973
- declare function withRetry<State>(node: (state: State) => State | Promise<State> | Partial<State> | Promise<Partial<State>>, options?: RetryOptions): (state: State) => Promise<State | Partial<State>>;
1974
-
1975
- /**
1976
- * Error handler pattern for LangGraph nodes
1977
- *
1978
- * Wraps a node function with error handling logic.
1979
- */
1980
- /**
1981
- * Options for error handling behavior
1982
- */
1983
- interface ErrorHandlerOptions<State> {
1984
- /**
1985
- * Callback function to handle errors
1986
- * Should return a state update to apply when an error occurs
1987
- */
1988
- onError: (error: Error, state: State) => State | Partial<State> | Promise<State | Partial<State>>;
1989
- /**
1990
- * Optional callback for logging errors
1991
- */
1992
- logError?: (error: Error, state: State) => void;
1993
- /**
1994
- * Whether to rethrow the error after handling
1995
- * @default false
1996
- */
1997
- rethrow?: boolean;
1998
- }
1999
- /**
2000
- * Wraps a node function with error handling logic.
2001
- *
2002
- * @example
2003
- * ```typescript
2004
- * const safeNode = withErrorHandler(myNode, {
2005
- * onError: (error, state) => {
2006
- * return { ...state, error: error.message, failed: true };
2007
- * },
2008
- * logError: (error) => {
2009
- * console.error('Node failed:', error);
2010
- * },
2011
- * });
2012
- *
2013
- * graph.addNode('safe', safeNode);
2014
- * ```
2015
- *
2016
- * @param node - The node function to wrap
2017
- * @param options - Error handling configuration options
2018
- * @returns A wrapped node function with error handling
2019
- */
2020
- declare function withErrorHandler<State>(node: (state: State) => State | Promise<State> | Partial<State> | Promise<Partial<State>>, options: ErrorHandlerOptions<State>): (state: State) => Promise<State | Partial<State>>;
2021
-
2022
1909
  /**
2023
1910
  * Structured Logging Utilities
2024
1911
  *
@@ -2143,158 +2030,159 @@ interface Logger {
2143
2030
  declare function createLogger(name: string, options?: LoggerOptions): Logger;
2144
2031
 
2145
2032
  /**
2146
- * Middleware Presets
2147
- *
2148
- * Pre-configured middleware combinations for common use cases.
2033
+ * Error handler pattern for LangGraph nodes
2149
2034
  *
2150
- * @module langgraph/middleware/presets
2035
+ * Wraps a node function with error handling logic.
2151
2036
  */
2152
-
2153
2037
  /**
2154
- * Options for the production preset.
2038
+ * Options for error handling behavior
2155
2039
  */
2156
- interface ProductionPresetOptions<State> {
2157
- /**
2158
- * Name of the node (for logging and metrics)
2159
- */
2160
- nodeName: string;
2161
- /**
2162
- * Logger instance
2163
- */
2164
- logger?: Logger;
2165
- /**
2166
- * Enable metrics tracking
2167
- * @default true
2168
- */
2169
- enableMetrics?: boolean;
2170
- /**
2171
- * Enable tracing
2172
- * @default true
2173
- */
2174
- enableTracing?: boolean;
2175
- /**
2176
- * Enable retry logic
2177
- * @default true
2178
- */
2179
- enableRetry?: boolean;
2040
+ interface ErrorHandlerOptions<State> {
2180
2041
  /**
2181
- * Timeout in milliseconds
2182
- * @default 30000 (30 seconds)
2042
+ * Callback function to handle errors
2043
+ * Should return a state update to apply when an error occurs
2183
2044
  */
2184
- timeout?: number;
2045
+ onError: (error: Error, state: State) => State | Partial<State> | Promise<State | Partial<State>>;
2185
2046
  /**
2186
- * Custom retry options
2047
+ * Optional callback for logging errors
2187
2048
  */
2188
- retryOptions?: Partial<RetryOptions>;
2049
+ logError?: (error: Error, state: State) => void;
2189
2050
  /**
2190
- * Custom error handler options
2051
+ * Whether to rethrow the error after handling
2052
+ * @default false
2191
2053
  */
2192
- errorOptions?: Partial<ErrorHandlerOptions<State>>;
2054
+ rethrow?: boolean;
2193
2055
  }
2194
2056
  /**
2195
- * Production preset with comprehensive error handling, metrics, and tracing.
2196
- *
2197
- * Includes:
2198
- * - Error handling with fallback
2199
- * - Retry logic with exponential backoff
2200
- * - Timeout protection
2201
- * - Metrics tracking
2202
- * - Distributed tracing
2057
+ * Wraps a node function with error handling logic.
2203
2058
  *
2204
2059
  * @example
2205
2060
  * ```typescript
2206
- * const productionNode = presets.production(myNode, {
2207
- * nodeName: 'my-node',
2208
- * logger: createLogger({ level: LogLevel.INFO }),
2061
+ * const safeNode = withErrorHandler(myNode, {
2062
+ * onError: (error, state) => {
2063
+ * return { ...state, error: error.message, failed: true };
2064
+ * },
2065
+ * logError: (error) => {
2066
+ * console.error('Node failed:', error);
2067
+ * },
2209
2068
  * });
2069
+ *
2070
+ * graph.addNode('safe', safeNode);
2210
2071
  * ```
2072
+ *
2073
+ * @param node - The node function to wrap
2074
+ * @param options - Error handling configuration options
2075
+ * @returns A wrapped node function with error handling
2211
2076
  */
2212
- declare function production<State>(node: NodeFunction<State>, options: ProductionPresetOptions<State>): NodeFunction<State>;
2077
+ declare function withErrorHandler<State>(node: (state: State) => State | Promise<State> | Partial<State> | Promise<Partial<State>>, options: ErrorHandlerOptions<State>): (state: State) => Promise<State | Partial<State>>;
2078
+
2213
2079
  /**
2214
- * Options for the development preset.
2080
+ * Retry pattern for LangGraph nodes
2081
+ *
2082
+ * Wraps a node function with retry logic.
2215
2083
  */
2216
- interface DevelopmentPresetOptions {
2217
- /**
2218
- * Name of the node
2219
- */
2220
- nodeName: string;
2221
- /**
2222
- * Enable verbose logging
2223
- * @default true
2224
- */
2225
- verbose?: boolean;
2226
- /**
2227
- * Logger instance
2228
- */
2229
- logger?: Logger;
2230
- }
2231
2084
  /**
2232
- * Development preset with verbose logging and debugging.
2233
- *
2234
- * Includes:
2235
- * - Verbose logging
2236
- * - Error details
2237
- * - No retry (fail fast)
2238
- * - Extended timeout
2239
- *
2240
- * @example
2241
- * ```typescript
2242
- * const devNode = presets.development(myNode, {
2243
- * nodeName: 'my-node',
2244
- * verbose: true,
2245
- * });
2246
- * ```
2085
+ * Backoff strategy for retries
2247
2086
  */
2248
- declare function development<State>(node: NodeFunction<State>, options: DevelopmentPresetOptions): NodeFunction<State>;
2087
+ type BackoffStrategy = 'constant' | 'linear' | 'exponential';
2249
2088
  /**
2250
- * Options for the testing preset.
2089
+ * Options for retry behavior
2251
2090
  */
2252
- interface TestingPresetOptions<State> {
2091
+ interface RetryOptions {
2253
2092
  /**
2254
- * Name of the node
2093
+ * Maximum number of retry attempts
2094
+ * @default 3
2255
2095
  */
2256
- nodeName: string;
2096
+ maxAttempts?: number;
2257
2097
  /**
2258
- * Mock responses for testing
2098
+ * Backoff strategy between retries
2099
+ * @default 'exponential'
2259
2100
  */
2260
- mockResponse?: Partial<State>;
2101
+ backoff?: BackoffStrategy;
2102
+ /**
2103
+ * Initial delay in milliseconds
2104
+ * @default 1000
2105
+ */
2106
+ initialDelay?: number;
2261
2107
  /**
2262
- * Simulate errors for testing
2108
+ * Maximum delay in milliseconds
2109
+ * @default 30000
2263
2110
  */
2264
- simulateError?: Error;
2111
+ maxDelay?: number;
2265
2112
  /**
2266
- * Delay in milliseconds for testing async behavior
2113
+ * Optional callback when a retry occurs
2267
2114
  */
2268
- delay?: number;
2115
+ onRetry?: (error: Error, attempt: number) => void;
2269
2116
  /**
2270
- * Track invocations for assertions
2117
+ * Optional predicate to determine if error should be retried
2118
+ * @default () => true (retry all errors)
2271
2119
  */
2272
- trackInvocations?: boolean;
2120
+ shouldRetry?: (error: Error) => boolean;
2273
2121
  }
2274
2122
  /**
2275
- * Testing preset for unit and integration tests.
2276
- *
2277
- * Includes:
2278
- * - Mock responses
2279
- * - Error simulation
2280
- * - Invocation tracking
2281
- * - Configurable delays
2123
+ * Wraps a node function with retry logic.
2282
2124
  *
2283
2125
  * @example
2284
2126
  * ```typescript
2285
- * const testNode = presets.testing(myNode, {
2286
- * nodeName: 'my-node',
2287
- * mockResponse: { result: 'mocked' },
2288
- * trackInvocations: true,
2127
+ * const robustNode = withRetry(myNode, {
2128
+ * maxAttempts: 3,
2129
+ * backoff: 'exponential',
2130
+ * initialDelay: 1000,
2131
+ * onRetry: (error, attempt) => {
2132
+ * console.log(`Retry attempt ${attempt}: ${error.message}`);
2133
+ * },
2289
2134
  * });
2135
+ *
2136
+ * graph.addNode('robust', robustNode);
2290
2137
  * ```
2138
+ *
2139
+ * @param node - The node function to wrap
2140
+ * @param options - Retry configuration options
2141
+ * @returns A wrapped node function with retry logic
2291
2142
  */
2292
- declare function testing<State>(node: NodeFunction<State>, options: TestingPresetOptions<State>): NodeFunction<State> & {
2143
+ declare function withRetry<State>(node: (state: State) => State | Promise<State> | Partial<State> | Promise<Partial<State>>, options?: RetryOptions): (state: State) => Promise<State | Partial<State>>;
2144
+
2145
+ interface ProductionPresetOptions<State> {
2146
+ nodeName: string;
2147
+ logger?: Logger;
2148
+ enableMetrics?: boolean;
2149
+ enableTracing?: boolean;
2150
+ enableRetry?: boolean;
2151
+ timeout?: number;
2152
+ retryOptions?: Partial<RetryOptions>;
2153
+ errorOptions?: Partial<ErrorHandlerOptions<State>>;
2154
+ }
2155
+ interface DevelopmentPresetOptions {
2156
+ nodeName: string;
2157
+ verbose?: boolean;
2158
+ logger?: Logger;
2159
+ }
2160
+ interface TestingPresetOptions<State> {
2161
+ nodeName: string;
2162
+ mockResponse?: Partial<State>;
2163
+ simulateError?: Error;
2164
+ delay?: number;
2165
+ trackInvocations?: boolean;
2166
+ }
2167
+ type TestingPresetNode<State> = NodeFunction<State> & {
2293
2168
  invocations: State[];
2294
2169
  };
2170
+
2295
2171
  /**
2296
- * Preset collection for easy access.
2172
+ * Production preset with comprehensive error handling, metrics, and tracing.
2297
2173
  */
2174
+ declare function production<State>(node: NodeFunction<State>, options: ProductionPresetOptions<State>): NodeFunction<State>;
2175
+
2176
+ /**
2177
+ * Development preset with verbose logging and debugging.
2178
+ */
2179
+ declare function development<State>(node: NodeFunction<State>, options: DevelopmentPresetOptions): NodeFunction<State>;
2180
+
2181
+ /**
2182
+ * Testing preset for unit and integration tests.
2183
+ */
2184
+ declare function testing<State>(node: NodeFunction<State>, options: TestingPresetOptions<State>): TestingPresetNode<State>;
2185
+
2298
2186
  declare const presets: {
2299
2187
  production: typeof production;
2300
2188
  development: typeof development;