@agentforge/core 0.16.51 → 0.16.52
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 +9 -1
- package/dist/index.d.cts +15 -72
- package/dist/index.d.ts +15 -72
- package/dist/index.js +9 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2107,8 +2107,10 @@ function createToolSimulator(config) {
|
|
|
2107
2107
|
};
|
|
2108
2108
|
}
|
|
2109
2109
|
|
|
2110
|
-
// src/langgraph/state.ts
|
|
2110
|
+
// src/langgraph/state-annotation.ts
|
|
2111
2111
|
var import_langgraph = require("@langchain/langgraph");
|
|
2112
|
+
|
|
2113
|
+
// src/langgraph/state-shared.ts
|
|
2112
2114
|
function entriesOf(value) {
|
|
2113
2115
|
return Object.entries(value);
|
|
2114
2116
|
}
|
|
@@ -2127,6 +2129,8 @@ function setStateValue(target, key, value) {
|
|
|
2127
2129
|
function setStateDefinitionValue(target, key, value) {
|
|
2128
2130
|
target[key] = value;
|
|
2129
2131
|
}
|
|
2132
|
+
|
|
2133
|
+
// src/langgraph/state-annotation.ts
|
|
2130
2134
|
function createChannel(channelConfig) {
|
|
2131
2135
|
if (channelConfig.reducer) {
|
|
2132
2136
|
return (0, import_langgraph.Annotation)({
|
|
@@ -2153,6 +2157,8 @@ function createStateAnnotation(config) {
|
|
|
2153
2157
|
}
|
|
2154
2158
|
return import_langgraph.Annotation.Root(stateDefinition);
|
|
2155
2159
|
}
|
|
2160
|
+
|
|
2161
|
+
// src/langgraph/state-validation.ts
|
|
2156
2162
|
function validateState(state, config) {
|
|
2157
2163
|
const validated = {};
|
|
2158
2164
|
for (const [key, channelConfig] of entriesOf(config)) {
|
|
@@ -2170,6 +2176,8 @@ function validateState(state, config) {
|
|
|
2170
2176
|
}
|
|
2171
2177
|
return validated;
|
|
2172
2178
|
}
|
|
2179
|
+
|
|
2180
|
+
// src/langgraph/state-merge.ts
|
|
2173
2181
|
function mergeState(currentState, update, config) {
|
|
2174
2182
|
const merged = { ...currentState };
|
|
2175
2183
|
for (const key of keysOf(update)) {
|
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
|
|
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
|
|
package/dist/index.js
CHANGED
|
@@ -1932,8 +1932,10 @@ function createToolSimulator(config) {
|
|
|
1932
1932
|
};
|
|
1933
1933
|
}
|
|
1934
1934
|
|
|
1935
|
-
// src/langgraph/state.ts
|
|
1935
|
+
// src/langgraph/state-annotation.ts
|
|
1936
1936
|
import { Annotation } from "@langchain/langgraph";
|
|
1937
|
+
|
|
1938
|
+
// src/langgraph/state-shared.ts
|
|
1937
1939
|
function entriesOf(value) {
|
|
1938
1940
|
return Object.entries(value);
|
|
1939
1941
|
}
|
|
@@ -1952,6 +1954,8 @@ function setStateValue(target, key, value) {
|
|
|
1952
1954
|
function setStateDefinitionValue(target, key, value) {
|
|
1953
1955
|
target[key] = value;
|
|
1954
1956
|
}
|
|
1957
|
+
|
|
1958
|
+
// src/langgraph/state-annotation.ts
|
|
1955
1959
|
function createChannel(channelConfig) {
|
|
1956
1960
|
if (channelConfig.reducer) {
|
|
1957
1961
|
return Annotation({
|
|
@@ -1978,6 +1982,8 @@ function createStateAnnotation(config) {
|
|
|
1978
1982
|
}
|
|
1979
1983
|
return Annotation.Root(stateDefinition);
|
|
1980
1984
|
}
|
|
1985
|
+
|
|
1986
|
+
// src/langgraph/state-validation.ts
|
|
1981
1987
|
function validateState(state, config) {
|
|
1982
1988
|
const validated = {};
|
|
1983
1989
|
for (const [key, channelConfig] of entriesOf(config)) {
|
|
@@ -1995,6 +2001,8 @@ function validateState(state, config) {
|
|
|
1995
2001
|
}
|
|
1996
2002
|
return validated;
|
|
1997
2003
|
}
|
|
2004
|
+
|
|
2005
|
+
// src/langgraph/state-merge.ts
|
|
1998
2006
|
function mergeState(currentState, update, config) {
|
|
1999
2007
|
const merged = { ...currentState };
|
|
2000
2008
|
for (const key of keysOf(update)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentforge/core",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.52",
|
|
4
4
|
"description": "Production-ready TypeScript agent framework built on LangGraph with orchestration, middleware, and typed abstractions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|