@agentforge/core 0.16.51 → 0.16.53
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.cjs +360 -211
- package/dist/index.d.cts +21 -87
- package/dist/index.d.ts +21 -87
- package/dist/index.js +360 -211
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { z, ZodTypeAny, output, ZodType, ZodTypeDef } from 'zod';
|
|
|
2
2
|
import * as _langchain_core_tools from '@langchain/core/tools';
|
|
3
3
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
4
4
|
import * as _langchain_langgraph from '@langchain/langgraph';
|
|
5
|
-
import {
|
|
5
|
+
import { BaseChannel, AnnotationRoot, StateDefinition, UpdateType, StateGraph, END, MemorySaver, BaseCheckpointSaver, CheckpointTuple } from '@langchain/langgraph';
|
|
6
6
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1093,15 +1093,6 @@ declare function getToolJsonSchema<TInput, TOutput>(tool: Tool<TInput, TOutput>)
|
|
|
1093
1093
|
*/
|
|
1094
1094
|
declare function getToolDescription<TInput, TOutput>(tool: Tool<TInput, TOutput>): string;
|
|
1095
1095
|
|
|
1096
|
-
/**
|
|
1097
|
-
* LangGraph State Utilities
|
|
1098
|
-
*
|
|
1099
|
-
* Type-safe helpers for working with LangGraph state management.
|
|
1100
|
-
* These utilities wrap LangGraph's Annotation API to provide better TypeScript ergonomics.
|
|
1101
|
-
*
|
|
1102
|
-
* @module langgraph/state
|
|
1103
|
-
*/
|
|
1104
|
-
|
|
1105
1096
|
/**
|
|
1106
1097
|
* State channel configuration with optional Zod schema validation
|
|
1107
1098
|
*/
|
|
@@ -1150,6 +1141,16 @@ type ReducerUpdate<TChannel extends StateChannelConfigLike> = TChannel extends {
|
|
|
1150
1141
|
} ? TUpdate : never;
|
|
1151
1142
|
type ChannelValue<TChannel extends StateChannelConfigLike> = HasReducer<TChannel> extends true ? ReducerValue<TChannel> : [SchemaValue<TChannel>] extends [never] ? [DefaultValue<TChannel>] extends [never] ? unknown : DefaultValue<TChannel> : SchemaValue<TChannel>;
|
|
1152
1143
|
type ChannelUpdate<TChannel extends StateChannelConfigLike> = HasReducer<TChannel> extends true ? ReducerUpdate<TChannel> : ChannelValue<TChannel>;
|
|
1144
|
+
type SchemaMatchesValue<TChannel extends StateChannelConfigLike> = [
|
|
1145
|
+
SchemaValue<TChannel>
|
|
1146
|
+
] extends [never] ? true : [ChannelValue<TChannel>] extends [SchemaValue<TChannel>] ? true : false;
|
|
1147
|
+
type DefaultMatchesValue<TChannel extends StateChannelConfigLike> = [
|
|
1148
|
+
DefaultValue<TChannel>
|
|
1149
|
+
] extends [never] ? true : [DefaultValue<TChannel>] extends [ChannelValue<TChannel>] ? true : false;
|
|
1150
|
+
type ValidStateChannel<TChannel extends StateChannelConfigLike> = HasReducer<TChannel> extends true ? [ChannelValue<TChannel>] extends [never] ? never : SchemaMatchesValue<TChannel> extends true ? DefaultMatchesValue<TChannel> extends true ? TChannel : never : never : TChannel;
|
|
1151
|
+
type ValidStateConfig<TConfig extends StateConfigMap> = {
|
|
1152
|
+
[K in keyof TConfig]: ValidStateChannel<TConfig[K]>;
|
|
1153
|
+
};
|
|
1153
1154
|
type StateShape<TConfig extends StateConfigMap> = {
|
|
1154
1155
|
[K in keyof TConfig]: ChannelValue<TConfig[K]>;
|
|
1155
1156
|
};
|
|
@@ -1169,6 +1170,7 @@ type InputStateKeys<TConfig extends StateConfigMap, TState> = Extract<keyof TCon
|
|
|
1169
1170
|
type ValidatedState<TConfig extends StateConfigMap, TState extends Partial<Record<keyof TConfig, unknown>>> = {
|
|
1170
1171
|
[K in InputStateKeys<TConfig, TState> | DefaultedKeys<TConfig>]: ChannelValue<TConfig[K]>;
|
|
1171
1172
|
};
|
|
1173
|
+
|
|
1172
1174
|
/**
|
|
1173
1175
|
* Create a type-safe state annotation with optional Zod validation
|
|
1174
1176
|
*
|
|
@@ -1176,75 +1178,16 @@ type ValidatedState<TConfig extends StateConfigMap, TState extends Partial<Recor
|
|
|
1176
1178
|
* - Zod schema validation support
|
|
1177
1179
|
* - Better TypeScript inference
|
|
1178
1180
|
* - Documentation/description support
|
|
1179
|
-
*
|
|
1180
|
-
* @example
|
|
1181
|
-
* ```typescript
|
|
1182
|
-
* import { createStateAnnotation } from '@agentforge/core';
|
|
1183
|
-
* import { z } from 'zod';
|
|
1184
|
-
*
|
|
1185
|
-
* const AgentState = createStateAnnotation({
|
|
1186
|
-
* messages: {
|
|
1187
|
-
* schema: z.array(z.string()),
|
|
1188
|
-
* reducer: (left, right) => [...left, ...right],
|
|
1189
|
-
* default: () => [],
|
|
1190
|
-
* description: 'Chat messages'
|
|
1191
|
-
* },
|
|
1192
|
-
* context: {
|
|
1193
|
-
* schema: z.record(z.any()),
|
|
1194
|
-
* default: () => ({}),
|
|
1195
|
-
* description: 'Agent context'
|
|
1196
|
-
* }
|
|
1197
|
-
* });
|
|
1198
|
-
*
|
|
1199
|
-
* type State = typeof AgentState.State;
|
|
1200
|
-
* ```
|
|
1201
1181
|
*/
|
|
1202
|
-
declare function createStateAnnotation<TConfig extends StateConfigMap>(config: TConfig): AnnotationRoot<StateAnnotationDefinition<TConfig>>;
|
|
1182
|
+
declare function createStateAnnotation<TConfig extends StateConfigMap>(config: ValidStateConfig<TConfig>): AnnotationRoot<StateAnnotationDefinition<TConfig>>;
|
|
1183
|
+
|
|
1203
1184
|
/**
|
|
1204
1185
|
* Validate state against Zod schemas
|
|
1205
|
-
*
|
|
1206
|
-
* @param state - The state object to validate
|
|
1207
|
-
* @param config - The state channel configuration with schemas
|
|
1208
|
-
* @returns Validated state
|
|
1209
|
-
* @throws {z.ZodError} If validation fails
|
|
1210
|
-
*
|
|
1211
|
-
* @example
|
|
1212
|
-
* ```typescript
|
|
1213
|
-
* const config = {
|
|
1214
|
-
* messages: { schema: z.array(z.string()) },
|
|
1215
|
-
* count: { schema: z.number() }
|
|
1216
|
-
* };
|
|
1217
|
-
*
|
|
1218
|
-
* const validatedState = validateState(
|
|
1219
|
-
* { messages: ['hello'], count: 42 },
|
|
1220
|
-
* config
|
|
1221
|
-
* );
|
|
1222
|
-
* ```
|
|
1223
1186
|
*/
|
|
1224
1187
|
declare function validateState<TConfig extends StateConfigMap, TState extends Partial<Record<keyof TConfig, unknown>>>(state: TState, config: TConfig): ValidatedState<TConfig, TState>;
|
|
1188
|
+
|
|
1225
1189
|
/**
|
|
1226
1190
|
* Merge state updates using configured reducers
|
|
1227
|
-
*
|
|
1228
|
-
* @param currentState - Current state
|
|
1229
|
-
* @param update - State update
|
|
1230
|
-
* @param config - State channel configuration
|
|
1231
|
-
* @returns Merged state
|
|
1232
|
-
*
|
|
1233
|
-
* @example
|
|
1234
|
-
* ```typescript
|
|
1235
|
-
* const config = {
|
|
1236
|
-
* messages: {
|
|
1237
|
-
* reducer: (left, right) => [...left, ...right]
|
|
1238
|
-
* }
|
|
1239
|
-
* };
|
|
1240
|
-
*
|
|
1241
|
-
* const merged = mergeState(
|
|
1242
|
-
* { messages: ['a', 'b'] },
|
|
1243
|
-
* { messages: ['c'] },
|
|
1244
|
-
* config
|
|
1245
|
-
* );
|
|
1246
|
-
* // Result: { messages: ['a', 'b', 'c'] }
|
|
1247
|
-
* ```
|
|
1248
1191
|
*/
|
|
1249
1192
|
declare function mergeState<TConfig extends StateConfigMap>(currentState: Partial<StateShape<TConfig>>, update: StateUpdateShape<TConfig>, config: TConfig): Partial<StateShape<TConfig>>;
|
|
1250
1193
|
|
|
@@ -4115,9 +4058,6 @@ declare function broadcast<TData = unknown, TSocket extends WebSocketSendTarget
|
|
|
4115
4058
|
*/
|
|
4116
4059
|
declare function createMessage<TData = unknown>(type: string, data?: TData, error?: string): WebSocketMessage<TData>;
|
|
4117
4060
|
|
|
4118
|
-
/**
|
|
4119
|
-
* Connection pooling for database and HTTP clients
|
|
4120
|
-
*/
|
|
4121
4061
|
interface PoolConfig {
|
|
4122
4062
|
min?: number;
|
|
4123
4063
|
max?: number;
|
|
@@ -4152,22 +4092,16 @@ interface PoolStats {
|
|
|
4152
4092
|
healthChecksPassed: number;
|
|
4153
4093
|
healthChecksFailed: number;
|
|
4154
4094
|
}
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* Connection pooling for database and HTTP clients
|
|
4098
|
+
*/
|
|
4099
|
+
|
|
4155
4100
|
declare class ConnectionPool<T> {
|
|
4156
|
-
private
|
|
4157
|
-
private connections;
|
|
4158
|
-
private pending;
|
|
4159
|
-
private stats;
|
|
4160
|
-
private evictionTimer?;
|
|
4161
|
-
private healthCheckTimer?;
|
|
4162
|
-
private draining;
|
|
4101
|
+
private readonly runtime;
|
|
4163
4102
|
constructor(options: ConnectionPoolOptions<T>);
|
|
4164
|
-
private initialize;
|
|
4165
|
-
private createConnection;
|
|
4166
|
-
private destroyConnection;
|
|
4167
4103
|
acquire(): Promise<T>;
|
|
4168
4104
|
release(connection: T): Promise<void>;
|
|
4169
|
-
private evictIdleConnections;
|
|
4170
|
-
private performHealthChecks;
|
|
4171
4105
|
drain(): Promise<void>;
|
|
4172
4106
|
clear(): Promise<void>;
|
|
4173
4107
|
getStats(): PoolStats;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { z, ZodTypeAny, output, ZodType, ZodTypeDef } from 'zod';
|
|
|
2
2
|
import * as _langchain_core_tools from '@langchain/core/tools';
|
|
3
3
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
4
4
|
import * as _langchain_langgraph from '@langchain/langgraph';
|
|
5
|
-
import {
|
|
5
|
+
import { BaseChannel, AnnotationRoot, StateDefinition, UpdateType, StateGraph, END, MemorySaver, BaseCheckpointSaver, CheckpointTuple } from '@langchain/langgraph';
|
|
6
6
|
import { RunnableConfig } from '@langchain/core/runnables';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1093,15 +1093,6 @@ declare function getToolJsonSchema<TInput, TOutput>(tool: Tool<TInput, TOutput>)
|
|
|
1093
1093
|
*/
|
|
1094
1094
|
declare function getToolDescription<TInput, TOutput>(tool: Tool<TInput, TOutput>): string;
|
|
1095
1095
|
|
|
1096
|
-
/**
|
|
1097
|
-
* LangGraph State Utilities
|
|
1098
|
-
*
|
|
1099
|
-
* Type-safe helpers for working with LangGraph state management.
|
|
1100
|
-
* These utilities wrap LangGraph's Annotation API to provide better TypeScript ergonomics.
|
|
1101
|
-
*
|
|
1102
|
-
* @module langgraph/state
|
|
1103
|
-
*/
|
|
1104
|
-
|
|
1105
1096
|
/**
|
|
1106
1097
|
* State channel configuration with optional Zod schema validation
|
|
1107
1098
|
*/
|
|
@@ -1150,6 +1141,16 @@ type ReducerUpdate<TChannel extends StateChannelConfigLike> = TChannel extends {
|
|
|
1150
1141
|
} ? TUpdate : never;
|
|
1151
1142
|
type ChannelValue<TChannel extends StateChannelConfigLike> = HasReducer<TChannel> extends true ? ReducerValue<TChannel> : [SchemaValue<TChannel>] extends [never] ? [DefaultValue<TChannel>] extends [never] ? unknown : DefaultValue<TChannel> : SchemaValue<TChannel>;
|
|
1152
1143
|
type ChannelUpdate<TChannel extends StateChannelConfigLike> = HasReducer<TChannel> extends true ? ReducerUpdate<TChannel> : ChannelValue<TChannel>;
|
|
1144
|
+
type SchemaMatchesValue<TChannel extends StateChannelConfigLike> = [
|
|
1145
|
+
SchemaValue<TChannel>
|
|
1146
|
+
] extends [never] ? true : [ChannelValue<TChannel>] extends [SchemaValue<TChannel>] ? true : false;
|
|
1147
|
+
type DefaultMatchesValue<TChannel extends StateChannelConfigLike> = [
|
|
1148
|
+
DefaultValue<TChannel>
|
|
1149
|
+
] extends [never] ? true : [DefaultValue<TChannel>] extends [ChannelValue<TChannel>] ? true : false;
|
|
1150
|
+
type ValidStateChannel<TChannel extends StateChannelConfigLike> = HasReducer<TChannel> extends true ? [ChannelValue<TChannel>] extends [never] ? never : SchemaMatchesValue<TChannel> extends true ? DefaultMatchesValue<TChannel> extends true ? TChannel : never : never : TChannel;
|
|
1151
|
+
type ValidStateConfig<TConfig extends StateConfigMap> = {
|
|
1152
|
+
[K in keyof TConfig]: ValidStateChannel<TConfig[K]>;
|
|
1153
|
+
};
|
|
1153
1154
|
type StateShape<TConfig extends StateConfigMap> = {
|
|
1154
1155
|
[K in keyof TConfig]: ChannelValue<TConfig[K]>;
|
|
1155
1156
|
};
|
|
@@ -1169,6 +1170,7 @@ type InputStateKeys<TConfig extends StateConfigMap, TState> = Extract<keyof TCon
|
|
|
1169
1170
|
type ValidatedState<TConfig extends StateConfigMap, TState extends Partial<Record<keyof TConfig, unknown>>> = {
|
|
1170
1171
|
[K in InputStateKeys<TConfig, TState> | DefaultedKeys<TConfig>]: ChannelValue<TConfig[K]>;
|
|
1171
1172
|
};
|
|
1173
|
+
|
|
1172
1174
|
/**
|
|
1173
1175
|
* Create a type-safe state annotation with optional Zod validation
|
|
1174
1176
|
*
|
|
@@ -1176,75 +1178,16 @@ type ValidatedState<TConfig extends StateConfigMap, TState extends Partial<Recor
|
|
|
1176
1178
|
* - Zod schema validation support
|
|
1177
1179
|
* - Better TypeScript inference
|
|
1178
1180
|
* - Documentation/description support
|
|
1179
|
-
*
|
|
1180
|
-
* @example
|
|
1181
|
-
* ```typescript
|
|
1182
|
-
* import { createStateAnnotation } from '@agentforge/core';
|
|
1183
|
-
* import { z } from 'zod';
|
|
1184
|
-
*
|
|
1185
|
-
* const AgentState = createStateAnnotation({
|
|
1186
|
-
* messages: {
|
|
1187
|
-
* schema: z.array(z.string()),
|
|
1188
|
-
* reducer: (left, right) => [...left, ...right],
|
|
1189
|
-
* default: () => [],
|
|
1190
|
-
* description: 'Chat messages'
|
|
1191
|
-
* },
|
|
1192
|
-
* context: {
|
|
1193
|
-
* schema: z.record(z.any()),
|
|
1194
|
-
* default: () => ({}),
|
|
1195
|
-
* description: 'Agent context'
|
|
1196
|
-
* }
|
|
1197
|
-
* });
|
|
1198
|
-
*
|
|
1199
|
-
* type State = typeof AgentState.State;
|
|
1200
|
-
* ```
|
|
1201
1181
|
*/
|
|
1202
|
-
declare function createStateAnnotation<TConfig extends StateConfigMap>(config: TConfig): AnnotationRoot<StateAnnotationDefinition<TConfig>>;
|
|
1182
|
+
declare function createStateAnnotation<TConfig extends StateConfigMap>(config: ValidStateConfig<TConfig>): AnnotationRoot<StateAnnotationDefinition<TConfig>>;
|
|
1183
|
+
|
|
1203
1184
|
/**
|
|
1204
1185
|
* Validate state against Zod schemas
|
|
1205
|
-
*
|
|
1206
|
-
* @param state - The state object to validate
|
|
1207
|
-
* @param config - The state channel configuration with schemas
|
|
1208
|
-
* @returns Validated state
|
|
1209
|
-
* @throws {z.ZodError} If validation fails
|
|
1210
|
-
*
|
|
1211
|
-
* @example
|
|
1212
|
-
* ```typescript
|
|
1213
|
-
* const config = {
|
|
1214
|
-
* messages: { schema: z.array(z.string()) },
|
|
1215
|
-
* count: { schema: z.number() }
|
|
1216
|
-
* };
|
|
1217
|
-
*
|
|
1218
|
-
* const validatedState = validateState(
|
|
1219
|
-
* { messages: ['hello'], count: 42 },
|
|
1220
|
-
* config
|
|
1221
|
-
* );
|
|
1222
|
-
* ```
|
|
1223
1186
|
*/
|
|
1224
1187
|
declare function validateState<TConfig extends StateConfigMap, TState extends Partial<Record<keyof TConfig, unknown>>>(state: TState, config: TConfig): ValidatedState<TConfig, TState>;
|
|
1188
|
+
|
|
1225
1189
|
/**
|
|
1226
1190
|
* Merge state updates using configured reducers
|
|
1227
|
-
*
|
|
1228
|
-
* @param currentState - Current state
|
|
1229
|
-
* @param update - State update
|
|
1230
|
-
* @param config - State channel configuration
|
|
1231
|
-
* @returns Merged state
|
|
1232
|
-
*
|
|
1233
|
-
* @example
|
|
1234
|
-
* ```typescript
|
|
1235
|
-
* const config = {
|
|
1236
|
-
* messages: {
|
|
1237
|
-
* reducer: (left, right) => [...left, ...right]
|
|
1238
|
-
* }
|
|
1239
|
-
* };
|
|
1240
|
-
*
|
|
1241
|
-
* const merged = mergeState(
|
|
1242
|
-
* { messages: ['a', 'b'] },
|
|
1243
|
-
* { messages: ['c'] },
|
|
1244
|
-
* config
|
|
1245
|
-
* );
|
|
1246
|
-
* // Result: { messages: ['a', 'b', 'c'] }
|
|
1247
|
-
* ```
|
|
1248
1191
|
*/
|
|
1249
1192
|
declare function mergeState<TConfig extends StateConfigMap>(currentState: Partial<StateShape<TConfig>>, update: StateUpdateShape<TConfig>, config: TConfig): Partial<StateShape<TConfig>>;
|
|
1250
1193
|
|
|
@@ -4115,9 +4058,6 @@ declare function broadcast<TData = unknown, TSocket extends WebSocketSendTarget
|
|
|
4115
4058
|
*/
|
|
4116
4059
|
declare function createMessage<TData = unknown>(type: string, data?: TData, error?: string): WebSocketMessage<TData>;
|
|
4117
4060
|
|
|
4118
|
-
/**
|
|
4119
|
-
* Connection pooling for database and HTTP clients
|
|
4120
|
-
*/
|
|
4121
4061
|
interface PoolConfig {
|
|
4122
4062
|
min?: number;
|
|
4123
4063
|
max?: number;
|
|
@@ -4152,22 +4092,16 @@ interface PoolStats {
|
|
|
4152
4092
|
healthChecksPassed: number;
|
|
4153
4093
|
healthChecksFailed: number;
|
|
4154
4094
|
}
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* Connection pooling for database and HTTP clients
|
|
4098
|
+
*/
|
|
4099
|
+
|
|
4155
4100
|
declare class ConnectionPool<T> {
|
|
4156
|
-
private
|
|
4157
|
-
private connections;
|
|
4158
|
-
private pending;
|
|
4159
|
-
private stats;
|
|
4160
|
-
private evictionTimer?;
|
|
4161
|
-
private healthCheckTimer?;
|
|
4162
|
-
private draining;
|
|
4101
|
+
private readonly runtime;
|
|
4163
4102
|
constructor(options: ConnectionPoolOptions<T>);
|
|
4164
|
-
private initialize;
|
|
4165
|
-
private createConnection;
|
|
4166
|
-
private destroyConnection;
|
|
4167
4103
|
acquire(): Promise<T>;
|
|
4168
4104
|
release(connection: T): Promise<void>;
|
|
4169
|
-
private evictIdleConnections;
|
|
4170
|
-
private performHealthChecks;
|
|
4171
4105
|
drain(): Promise<void>;
|
|
4172
4106
|
clear(): Promise<void>;
|
|
4173
4107
|
getStats(): PoolStats;
|