langchain 1.0.0-alpha.2 → 1.0.0-alpha.4
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/agents/ReactAgent.cjs +1 -1
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts +3 -3
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts +3 -3
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +2 -2
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/annotation.cjs +122 -2
- package/dist/agents/annotation.cjs.map +1 -1
- package/dist/agents/annotation.d.cts +18 -14
- package/dist/agents/annotation.d.cts.map +1 -1
- package/dist/agents/annotation.d.ts +18 -14
- package/dist/agents/annotation.d.ts.map +1 -1
- package/dist/agents/annotation.js +121 -2
- package/dist/agents/annotation.js.map +1 -1
- package/dist/agents/errors.cjs +1 -1
- package/dist/agents/errors.cjs.map +1 -1
- package/dist/agents/errors.js +1 -1
- package/dist/agents/errors.js.map +1 -1
- package/dist/agents/index.cjs +2 -2
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +15 -15
- package/dist/agents/index.d.cts.map +1 -1
- package/dist/agents/index.d.ts +15 -15
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/nodes/AgentNode.cjs +8 -3
- package/dist/agents/nodes/AgentNode.cjs.map +1 -1
- package/dist/agents/nodes/AgentNode.js +8 -3
- package/dist/agents/nodes/AgentNode.js.map +1 -1
- package/dist/agents/nodes/ToolNode.cjs +2 -2
- package/dist/agents/nodes/ToolNode.cjs.map +1 -1
- package/dist/agents/nodes/ToolNode.d.cts +1 -1
- package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
- package/dist/agents/nodes/ToolNode.d.ts +1 -1
- package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
- package/dist/agents/nodes/ToolNode.js +2 -2
- package/dist/agents/nodes/ToolNode.js.map +1 -1
- package/dist/agents/responses.cjs +2 -3
- package/dist/agents/responses.cjs.map +1 -1
- package/dist/agents/responses.d.cts +6 -1
- package/dist/agents/responses.d.cts.map +1 -1
- package/dist/agents/responses.d.ts +6 -1
- package/dist/agents/responses.d.ts.map +1 -1
- package/dist/agents/responses.js +2 -3
- package/dist/agents/responses.js.map +1 -1
- package/dist/agents/types.d.cts +28 -10
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +28 -10
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/utils.cjs +1 -1
- package/dist/agents/utils.cjs.map +1 -1
- package/dist/agents/utils.js +1 -1
- package/dist/agents/utils.js.map +1 -1
- package/dist/agents/withAgentName.cjs +1 -1
- package/dist/agents/withAgentName.cjs.map +1 -1
- package/dist/agents/withAgentName.js +1 -1
- package/dist/agents/withAgentName.js.map +1 -1
- package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
- package/dist/evaluation/agents/trajectory.d.ts.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
- package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
- package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
- package/dist/index.cjs +52 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +12 -5
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
import { ResponseFormatUndefined } from "./responses.js";
|
|
2
2
|
import { BaseMessage } from "@langchain/core/messages";
|
|
3
|
-
import
|
|
4
|
-
import { AnnotationRoot, Messages } from "@langchain/langgraph";
|
|
3
|
+
import { AnnotationRoot, BinaryOperatorAggregate, LastValue, Messages } from "@langchain/langgraph";
|
|
5
4
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
6
5
|
import { InteropZodToStateDefinition } from "@langchain/langgraph/zod";
|
|
7
6
|
|
|
8
7
|
//#region src/agents/annotation.d.ts
|
|
9
8
|
declare const PreHookAnnotation: AnnotationRoot<{
|
|
10
|
-
llmInputMessages:
|
|
11
|
-
messages:
|
|
9
|
+
llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;
|
|
10
|
+
messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
|
|
12
11
|
}>;
|
|
13
12
|
type PreHookAnnotation = typeof PreHookAnnotation;
|
|
14
13
|
// Base annotation without structuredResponse (for ResponseFormatUndefined)
|
|
15
|
-
declare const
|
|
16
|
-
messages:
|
|
14
|
+
declare const createAgentBaseAnnotation: () => AnnotationRoot<{
|
|
15
|
+
messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
|
|
17
16
|
}>;
|
|
18
17
|
// Full annotation with structuredResponse (for regular cases)
|
|
19
|
-
declare const
|
|
18
|
+
declare const createAgentAnnotation: <
|
|
20
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
20
|
T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
(): _langchain_langgraph0.LastValue<T>;
|
|
25
|
-
(annotation: _langchain_langgraph0.SingleReducer<T, T>): _langchain_langgraph0.BinaryOperatorAggregate<T, T>;
|
|
26
|
-
Root: <S extends _langchain_langgraph0.StateDefinition>(sd: S) => AnnotationRoot<S>;
|
|
27
|
-
};
|
|
21
|
+
structuredResponse: LastValue<T>;
|
|
22
|
+
messages: BinaryOperatorAggregate<BaseMessage[], Messages>;
|
|
28
23
|
}>;
|
|
29
24
|
// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse
|
|
30
25
|
|
|
31
26
|
// Helper type to select the right annotation based on the response format type
|
|
32
|
-
type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof
|
|
27
|
+
type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof createAgentBaseAnnotation> : T extends Record<string, any> ? ReturnType<typeof createAgentAnnotation<T>> : never;
|
|
33
28
|
type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;
|
|
34
29
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
30
|
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
31
|
+
/**
|
|
32
|
+
* Enhances a state schema to ensure proper message handling.
|
|
33
|
+
* If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer
|
|
34
|
+
* and infers appropriate reducers for all other fields.
|
|
35
|
+
*
|
|
36
|
+
* @param stateSchema - The state schema to enhance.
|
|
37
|
+
* @returns The enhanced state schema.
|
|
38
|
+
*/
|
|
39
|
+
|
|
36
40
|
//#endregion
|
|
37
41
|
export { AnyAnnotationRoot, PreHookAnnotation, ReactAgentAnnotation, ToAnnotationRoot };
|
|
38
42
|
//# sourceMappingURL=annotation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.d.ts","names":["BaseMessage","Messages","AnnotationRoot","
|
|
1
|
+
{"version":3,"file":"annotation.d.ts","names":["BaseMessage","Messages","AnnotationRoot","BinaryOperatorAggregate","LastValue","InteropZodToStateDefinition","InteropZodObject","ResponseFormatUndefined","PreHookAnnotation","createAgentBaseAnnotation","createAgentAnnotation","Record","T","createAgentAnnotationConditional","ReactAgentAnnotation","ReturnType","ToAnnotationRoot","AnyAnnotationRoot","A","enhanceStateSchemaWithMessageReducer"],"sources":["../../src/agents/annotation.d.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport { Messages, AnnotationRoot, type BinaryOperatorAggregate, type LastValue } from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport { type InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\nexport declare const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport declare const createAgentBaseAnnotation: () => AnnotationRoot<{\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Full annotation with structuredResponse (for regular cases)\ndeclare const createAgentAnnotation: <\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nT extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{\n structuredResponse: LastValue<T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport declare function createAgentAnnotationConditional<T extends Record<string, any> | ResponseFormatUndefined>(hasStructuredResponse?: boolean): AnnotationRoot<{\n structuredResponse: LastValue<T extends ResponseFormatUndefined ? never : T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>;\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<T extends Record<string, any> | ResponseFormatUndefined> = T extends ResponseFormatUndefined ? ReturnType<typeof createAgentBaseAnnotation> : T extends Record<string, any> ? ReturnType<typeof createAgentAnnotation<T>> : never;\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> = A extends AnyAnnotationRoot ? A : A extends InteropZodObject ? AnnotationRoot<InteropZodToStateDefinition<A>> : never;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n/**\n * Enhances a state schema to ensure proper message handling.\n * If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer\n * and infers appropriate reducers for all other fields.\n *\n * @param stateSchema - The state schema to enhance.\n * @returns The enhanced state schema.\n */\nexport declare function enhanceStateSchemaWithMessageReducer(stateSchema: AnyAnnotationRoot | InteropZodObject): AnnotationRoot<{\n messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;\n}> | AnyAnnotationRoot;\nexport {};\n"],"mappings":";;;;;;;cAKqBQ,mBAAmBN;oBAClBC,wBAAwBH,eAAeC;EADxCO,QAAAA,EAEPL,uBACZ,CADoCH,WACpC,EAAA,EADmDC,QACnD,CAAA;CAAA,CAAA;AAF4CD,KAGlCQ,iBAAAA,GAHkCR,OAGPQ,iBAHOR;;AAAxBG,cAKDM,yBALCN,EAAAA,GAAAA,GAKgCD,cALhCC,CAAAA;EAAuB,QACPH,EAKxBG,uBALwBH,CAKAA,WALAA,EAAAA,EAKeC,QALfD,CAAAA;CAAW,CAAA;;cAQnCU,qBAV0BR,EAAAA;AAAc;AAItD,UAQUS,MAREH,CAAAA,MAAAA,EAAiB,GAAA,CAAA,GAQGG,MAROH,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA,GAAiB,GAQEN,cARF,CAAA;EAEnCO,kBAAAA,EAOGL,SALtB,CAKgCQ,CALhC,CAAA;EAAA,QAAA,EAMYT,uBANZ,CAMoCH,WANpC,EAAA,EAMmDC,QANnD,CAAA;CAAA,CAAA;;;;AAIQU,KAUEG,oBAVFH,CAAAA,UAUiCA,MAVjCA,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GAUuDJ,uBAVvDI,CAAAA,GAUkFC,CAVlFD,SAU4FJ,uBAV5FI,GAUsHI,UAVtHJ,CAAAA,OAUwIF,yBAVxIE,CAAAA,GAUqKC,CAVrKD,SAU+KA,MAV/KA,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GAUqMI,UAVrMJ,CAAAA,OAUuND,qBAVvNC,CAU6OC,CAV7OD,CAAAA,CAAAA,GAAAA,KAAAA;AAAsBA,KAWpBK,gBAXoBL,CAAAA,UAWOM,iBAXPN,GAW2BL,gBAX3BK,CAAAA,GAW+CO,CAX/CP,SAWyDM,iBAXzDN,GAW6EO,CAX7EP,GAWiFO,CAXjFP,SAW2FL,gBAX3FK,GAW8GT,cAX9GS,CAW6HN,2BAX7HM,CAWyJO,CAXzJP,CAAAA,CAAAA,GAAAA,KAAAA;;AACRP,KAYZa,iBAAAA,GAAoBf,cAZRE,CAAAA,GAAAA,CAAAA;;;;;AADgD;AAUxE"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Annotation, messagesStateReducer } from "@langchain/langgraph";
|
|
2
|
+
import { getInteropZodDefaultGetter, getInteropZodObjectShape, isInteropZodSchema } from "@langchain/core/utils/types";
|
|
2
3
|
|
|
3
4
|
//#region src/agents/annotation.ts
|
|
4
5
|
const PreHookAnnotation = Annotation.Root({
|
|
@@ -11,7 +12,7 @@ const PreHookAnnotation = Annotation.Root({
|
|
|
11
12
|
default: () => []
|
|
12
13
|
})
|
|
13
14
|
});
|
|
14
|
-
function
|
|
15
|
+
function createAgentAnnotationConditional(hasStructuredResponse = true) {
|
|
15
16
|
const baseAnnotation = { messages: Annotation({
|
|
16
17
|
reducer: messagesStateReducer,
|
|
17
18
|
default: () => []
|
|
@@ -22,7 +23,125 @@ function createReactAgentAnnotationConditional(hasStructuredResponse = true) {
|
|
|
22
23
|
structuredResponse: Annotation()
|
|
23
24
|
});
|
|
24
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Enhances a state schema to ensure proper message handling.
|
|
28
|
+
* If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer
|
|
29
|
+
* and infers appropriate reducers for all other fields.
|
|
30
|
+
*
|
|
31
|
+
* @param stateSchema - The state schema to enhance.
|
|
32
|
+
* @returns The enhanced state schema.
|
|
33
|
+
*/
|
|
34
|
+
function enhanceStateSchemaWithMessageReducer(stateSchema) {
|
|
35
|
+
/**
|
|
36
|
+
* If it's already an annotation, return as-is
|
|
37
|
+
*/
|
|
38
|
+
if (typeof stateSchema === "object" && "State" in stateSchema) return stateSchema;
|
|
39
|
+
/**
|
|
40
|
+
* If it's a Zod schema, create annotations for all fields
|
|
41
|
+
*/
|
|
42
|
+
if (isInteropZodSchema(stateSchema)) {
|
|
43
|
+
const shape = getInteropZodObjectShape(stateSchema);
|
|
44
|
+
const annotationFields = {};
|
|
45
|
+
/**
|
|
46
|
+
* Process each field in the Zod schema
|
|
47
|
+
*/
|
|
48
|
+
for (const [key, zodType] of Object.entries(shape)) annotationFields[key] = key === "messages" ? Annotation({
|
|
49
|
+
reducer: messagesStateReducer,
|
|
50
|
+
default: () => []
|
|
51
|
+
}) : createAnnotationForZodType(zodType);
|
|
52
|
+
/**
|
|
53
|
+
* Ensure messages field exists even if not in the Zod schema
|
|
54
|
+
*/
|
|
55
|
+
if (!annotationFields.messages) annotationFields.messages = Annotation({
|
|
56
|
+
reducer: messagesStateReducer,
|
|
57
|
+
default: () => []
|
|
58
|
+
});
|
|
59
|
+
return Annotation.Root(annotationFields);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Fallback: create a base annotation with message reducer only
|
|
63
|
+
*/
|
|
64
|
+
return Annotation.Root({ messages: Annotation({
|
|
65
|
+
reducer: messagesStateReducer,
|
|
66
|
+
default: () => []
|
|
67
|
+
}) });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Type configuration for different Zod types
|
|
71
|
+
*/
|
|
72
|
+
const ZOD_TYPE_CONFIGS = {
|
|
73
|
+
ZodString: {
|
|
74
|
+
reducer: (_, update) => update,
|
|
75
|
+
fallbackDefault: ""
|
|
76
|
+
},
|
|
77
|
+
ZodNumber: {
|
|
78
|
+
reducer: (_, update) => update,
|
|
79
|
+
fallbackDefault: 0
|
|
80
|
+
},
|
|
81
|
+
ZodBoolean: {
|
|
82
|
+
reducer: (_, update) => update,
|
|
83
|
+
fallbackDefault: false
|
|
84
|
+
},
|
|
85
|
+
ZodArray: {
|
|
86
|
+
reducer: (_, update) => update,
|
|
87
|
+
fallbackDefault: []
|
|
88
|
+
},
|
|
89
|
+
ZodRecord: {
|
|
90
|
+
reducer: (current, update) => ({
|
|
91
|
+
...current,
|
|
92
|
+
...update
|
|
93
|
+
}),
|
|
94
|
+
fallbackDefault: {}
|
|
95
|
+
},
|
|
96
|
+
ZodObject: {
|
|
97
|
+
reducer: (current, update) => ({
|
|
98
|
+
...current,
|
|
99
|
+
...update
|
|
100
|
+
}),
|
|
101
|
+
fallbackDefault: {}
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Creates an annotation based on type configuration and default value
|
|
106
|
+
*/
|
|
107
|
+
function createAnnotationFromConfig(config, defaultValueFn) {
|
|
108
|
+
return Annotation({
|
|
109
|
+
reducer: config.reducer,
|
|
110
|
+
default: defaultValueFn
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates an appropriate annotation for a given Zod type.
|
|
115
|
+
*/
|
|
116
|
+
function createAnnotationForZodType(zodType) {
|
|
117
|
+
const typeName = zodType._def?.typeName;
|
|
118
|
+
const defaultGetter = getInteropZodDefaultGetter(zodType);
|
|
119
|
+
const isOptional = typeName === "ZodOptional";
|
|
120
|
+
/**
|
|
121
|
+
* Handle Zod wrapper first
|
|
122
|
+
*/
|
|
123
|
+
if (typeName === "ZodDefault" || typeName === "ZodOptional" || typeName === "ZodNullable") {
|
|
124
|
+
const innerTypeName = zodType._def.innerType._def?.typeName;
|
|
125
|
+
const config$1 = ZOD_TYPE_CONFIGS[innerTypeName];
|
|
126
|
+
return config$1 ? createAnnotationFromConfig(config$1, () => defaultGetter?.() || (isOptional ? void 0 : config$1?.fallbackDefault)) : Annotation({
|
|
127
|
+
reducer: (_, update) => update,
|
|
128
|
+
default: () => defaultGetter?.()
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Handle regular types
|
|
133
|
+
*/
|
|
134
|
+
const config = ZOD_TYPE_CONFIGS[typeName];
|
|
135
|
+
if (config) return createAnnotationFromConfig(config, () => defaultGetter?.() || config?.fallbackDefault);
|
|
136
|
+
/**
|
|
137
|
+
* Fallback for unknown types
|
|
138
|
+
*/
|
|
139
|
+
return Annotation({
|
|
140
|
+
reducer: (_, update) => update,
|
|
141
|
+
default: () => defaultGetter?.()
|
|
142
|
+
});
|
|
143
|
+
}
|
|
25
144
|
|
|
26
145
|
//#endregion
|
|
27
|
-
export {
|
|
146
|
+
export { createAgentAnnotationConditional, enhanceStateSchemaWithMessageReducer };
|
|
28
147
|
//# sourceMappingURL=annotation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"annotation.js","names":[],"sources":["../../src/agents/annotation.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport {\n Annotation,\n Messages,\n AnnotationRoot,\n messagesStateReducer,\n} from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport type { InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n\nexport const PreHookAnnotation = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n});\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport const createReactAgentBaseAnnotation = () =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n\n// Full annotation with structuredResponse (for regular cases)\nconst createReactAgentAnnotation = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n>() =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>,\n });\n\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport function createReactAgentAnnotationConditional<\n T extends Record<string, any> | ResponseFormatUndefined\n>(hasStructuredResponse = true) {\n const baseAnnotation = {\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n };\n\n if (!hasStructuredResponse) {\n return Annotation.Root(baseAnnotation);\n }\n\n return Annotation.Root({\n ...baseAnnotation,\n structuredResponse:\n Annotation<T extends ResponseFormatUndefined ? never : T>(),\n });\n}\n\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<\n T extends Record<string, any> | ResponseFormatUndefined\n> = T extends ResponseFormatUndefined\n ? ReturnType<typeof createReactAgentBaseAnnotation>\n : T extends Record<string, any>\n ? ReturnType<typeof createReactAgentAnnotation<T>>\n : never;\n\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n"],"mappings":";;;AAWA,MAAa,oBAAoB,WAAW,KAAK;CAC/C,kBAAkB,WAAoC;EACpD,SAAS,CAAC,GAAG,WAAW,qBAAqB,CAAE,GAAE,OAAO;EACxD,SAAS,MAAM,CAAE;CAClB,EAAC;CACF,UAAU,WAAoC;EAC5C,SAAS;EACT,SAAS,MAAM,CAAE;CAClB,EAAC;AACH,EAAC;AA0BF,SAAgB,sCAEd,wBAAwB,MAAM;CAC9B,MAAM,iBAAiB,EACrB,UAAU,WAAoC;EAC5C,SAAS;EACT,SAAS,MAAM,CAAE;CAClB,EAAC,CACH;AAED,KAAI,CAAC,sBACH,QAAO,WAAW,KAAK,eAAe;AAGxC,QAAO,WAAW,KAAK;EACrB,GAAG;EACH,oBACE,YAA2D;CAC9D,EAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"annotation.js","names":["PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}>","stateSchema: AnyAnnotationRoot | InteropZodObject","annotationFields: Record<string, any>","_: unknown","update: unknown","current: unknown[]","update: unknown[]","config: (typeof ZOD_TYPE_CONFIGS)[keyof typeof ZOD_TYPE_CONFIGS]","defaultValueFn: () => unknown","zodType: any","config"],"sources":["../../src/agents/annotation.ts"],"sourcesContent":["import { BaseMessage } from \"@langchain/core/messages\";\nimport {\n Annotation,\n Messages,\n AnnotationRoot,\n messagesStateReducer,\n type BinaryOperatorAggregate,\n type LastValue,\n} from \"@langchain/langgraph\";\nimport type { InteropZodToStateDefinition } from \"@langchain/langgraph/zod\";\nimport {\n isInteropZodSchema,\n getInteropZodObjectShape,\n getInteropZodDefaultGetter,\n type InteropZodObject,\n} from \"@langchain/core/utils/types\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n\nexport const PreHookAnnotation: AnnotationRoot<{\n llmInputMessages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n});\nexport type PreHookAnnotation = typeof PreHookAnnotation;\n\n// Base annotation without structuredResponse (for ResponseFormatUndefined)\nexport const createAgentBaseAnnotation = () =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n\n// Full annotation with structuredResponse (for regular cases)\nconst createAgentAnnotation = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n>(): AnnotationRoot<{\n structuredResponse: LastValue<T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>(),\n });\n\n// Create annotation conditionally - for ResponseFormatUndefined, don't include structuredResponse\nexport function createAgentAnnotationConditional<\n T extends Record<string, any> | ResponseFormatUndefined\n>(\n hasStructuredResponse = true\n): AnnotationRoot<{\n structuredResponse: LastValue<T extends ResponseFormatUndefined ? never : T>;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n}> {\n const baseAnnotation = {\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n };\n\n if (!hasStructuredResponse) {\n return Annotation.Root(baseAnnotation) as AnnotationRoot<{\n structuredResponse: LastValue<\n T extends ResponseFormatUndefined ? never : T\n >;\n messages: BinaryOperatorAggregate<BaseMessage[], Messages>;\n }>;\n }\n\n return Annotation.Root({\n ...baseAnnotation,\n structuredResponse:\n Annotation<T extends ResponseFormatUndefined ? never : T>(),\n });\n}\n\n// Helper type to select the right annotation based on the response format type\nexport type ReactAgentAnnotation<\n T extends Record<string, any> | ResponseFormatUndefined\n> = T extends ResponseFormatUndefined\n ? ReturnType<typeof createAgentBaseAnnotation>\n : T extends Record<string, any>\n ? ReturnType<typeof createAgentAnnotation<T>>\n : never;\n\nexport type ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyAnnotationRoot = AnnotationRoot<any>;\n\n/**\n * Enhances a state schema to ensure proper message handling.\n * If a Zod schema is provided, it creates an annotation that includes the messagesStateReducer\n * and infers appropriate reducers for all other fields.\n *\n * @param stateSchema - The state schema to enhance.\n * @returns The enhanced state schema.\n */\nexport function enhanceStateSchemaWithMessageReducer(\n stateSchema: AnyAnnotationRoot | InteropZodObject\n) {\n /**\n * If it's already an annotation, return as-is\n */\n if (typeof stateSchema === \"object\" && \"State\" in stateSchema) {\n return stateSchema;\n }\n\n /**\n * If it's a Zod schema, create annotations for all fields\n */\n if (isInteropZodSchema(stateSchema)) {\n const shape = getInteropZodObjectShape(stateSchema);\n const annotationFields: Record<string, any> = {};\n\n /**\n * Process each field in the Zod schema\n */\n for (const [key, zodType] of Object.entries(shape)) {\n annotationFields[key] =\n key === \"messages\"\n ? /**\n * Special handling for messages field - always use messagesStateReducer\n */\n Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n })\n : /**\n * For other fields, create appropriate annotations based on type\n */\n createAnnotationForZodType(zodType);\n }\n\n /**\n * Ensure messages field exists even if not in the Zod schema\n */\n if (!annotationFields.messages) {\n annotationFields.messages = Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n });\n }\n\n return Annotation.Root(annotationFields);\n }\n\n /**\n * Fallback: create a base annotation with message reducer only\n */\n return Annotation.Root({\n messages: Annotation<BaseMessage[]>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n });\n}\n\n/**\n * Type configuration for different Zod types\n */\nconst ZOD_TYPE_CONFIGS = {\n ZodString: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: \"\",\n },\n ZodNumber: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: 0,\n },\n ZodBoolean: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: false,\n },\n ZodArray: {\n reducer: (_: unknown, update: unknown) => update,\n fallbackDefault: [] as unknown[],\n },\n ZodRecord: {\n reducer: (current: unknown[], update: unknown[]) => ({\n ...current,\n ...update,\n }),\n fallbackDefault: {} as Record<string, unknown>,\n },\n ZodObject: {\n reducer: (current: unknown[], update: unknown[]) => ({\n ...current,\n ...update,\n }),\n fallbackDefault: {} as Record<string, unknown>,\n },\n} as const;\n\n/**\n * Creates an annotation based on type configuration and default value\n */\nfunction createAnnotationFromConfig(\n config: (typeof ZOD_TYPE_CONFIGS)[keyof typeof ZOD_TYPE_CONFIGS],\n defaultValueFn: () => unknown\n) {\n return Annotation<any>({\n reducer: config.reducer,\n default: defaultValueFn,\n });\n}\n\n/**\n * Creates an appropriate annotation for a given Zod type.\n */\nfunction createAnnotationForZodType(zodType: any): any {\n const typeName = zodType._def?.typeName;\n const defaultGetter = getInteropZodDefaultGetter(zodType);\n const isOptional = typeName === \"ZodOptional\";\n\n /**\n * Handle Zod wrapper first\n */\n if (\n typeName === \"ZodDefault\" ||\n typeName === \"ZodOptional\" ||\n typeName === \"ZodNullable\"\n ) {\n const innerTypeName = zodType._def.innerType._def?.typeName;\n const config =\n ZOD_TYPE_CONFIGS[innerTypeName as keyof typeof ZOD_TYPE_CONFIGS];\n return config\n ? createAnnotationFromConfig(\n config,\n () =>\n defaultGetter?.() ||\n (isOptional ? undefined : config?.fallbackDefault)\n )\n : Annotation<unknown>({\n reducer: (_: unknown, update: unknown) => update,\n default: () => defaultGetter?.(),\n });\n }\n\n /**\n * Handle regular types\n */\n const config = ZOD_TYPE_CONFIGS[typeName as keyof typeof ZOD_TYPE_CONFIGS];\n if (config) {\n return createAnnotationFromConfig(\n config,\n () => defaultGetter?.() || config?.fallbackDefault\n );\n }\n\n /**\n * Fallback for unknown types\n */\n return Annotation<unknown>({\n reducer: (_: unknown, update: unknown) => update,\n default: () => defaultGetter?.(),\n });\n}\n"],"mappings":";;;;AAkBA,MAAaA,oBAGR,WAAW,KAAK;CACnB,kBAAkB,WAAoC;EACpD,SAAS,CAAC,GAAG,WAAW,qBAAqB,CAAE,GAAE,OAAO;EACxD,SAAS,MAAM,CAAE;CAClB,EAAC;CACF,UAAU,WAAoC;EAC5C,SAAS;EACT,SAAS,MAAM,CAAE;CAClB,EAAC;AACH,EAAC;AA6BF,SAAgB,iCAGd,wBAAwB,MAIvB;CACD,MAAM,iBAAiB,EACrB,UAAU,WAAoC;EAC5C,SAAS;EACT,SAAS,MAAM,CAAE;CAClB,EAAC,CACH;AAED,KAAI,CAAC,sBACH,QAAO,WAAW,KAAK,eAAe;AAQ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B,SAAS,OAAO;EAChB,SAAS;CACV,EAAC;AACH;;;;AAKD,SAAS,2BAA2BC,SAAmB;CACrD,MAAM,WAAW,QAAQ,MAAM;CAC/B,MAAM,gBAAgB,2BAA2B,QAAQ;CACzD,MAAM,aAAa,aAAa;;;;AAKhC,KACE,aAAa,gBACb,aAAa,iBACb,aAAa,eACb;EACA,MAAM,gBAAgB,QAAQ,KAAK,UAAU,MAAM;EACnD,MAAMC,WACJ,iBAAiB;AACnB,SAAOA,WACH,2BACEA,UACA,MACE,iBAAiB,KAChB,aAAa,SAAYA,UAAQ,iBACrC,GACD,WAAoB;GAClB,SAAS,CAACP,GAAYC,WAAoB;GAC1C,SAAS,MAAM,iBAAiB;EACjC,EAAC;CACP;;;;CAKD,MAAM,SAAS,iBAAiB;AAChC,KAAI,OACF,QAAO,2BACL,QACA,MAAM,iBAAiB,IAAI,QAAQ,gBACpC;;;;AAMH,QAAO,WAAoB;EACzB,SAAS,CAACD,GAAYC,WAAoB;EAC1C,SAAS,MAAM,iBAAiB;CACjC,EAAC;AACH"}
|
package/dist/agents/errors.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
//#region src/agents/errors.ts
|
|
3
3
|
var MultipleToolsBoundError = class extends Error {
|
|
4
4
|
constructor() {
|
|
5
|
-
super("The provided LLM already has bound tools. Please provide an LLM without bound tools to
|
|
5
|
+
super("The provided LLM already has bound tools. Please provide an LLM without bound tools to createAgent. The agent will bind the tools provided in the 'tools' parameter.");
|
|
6
6
|
}
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.cjs","names":["toolNames: string[]","toolName: string","errors: string[]","toolError: unknown","toolCall: ToolCall"],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to
|
|
1
|
+
{"version":3,"file":"errors.cjs","names":["toolNames: string[]","toolName: string","errors: string[]","toolError: unknown","toolCall: ToolCall"],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to createAgent. \" +\n \"The agent will bind the tools provided in the 'tools' parameter.\"\n );\n }\n}\n\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport class MultipleStructuredOutputsError extends Error {\n public readonly toolNames: string[];\n\n constructor(toolNames: string[]) {\n super(\n `The model has called multiple tools: ${toolNames.join(\n \", \"\n )} to return a structured output. ` +\n \"This is not supported. Please provide a single structured output.\"\n );\n this.toolNames = toolNames;\n }\n}\n\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport class StructuredOutputParsingError extends Error {\n public readonly toolName: string;\n\n public readonly errors: string[];\n\n constructor(toolName: string, errors: string[]) {\n super(\n `Failed to parse structured output for tool '${toolName}':${errors\n .map((e) => `\\n - ${e}`)\n .join(\"\")}.`\n );\n this.toolName = toolName;\n this.errors = errors;\n }\n}\n\n/**\n * Raised when a tool call is throwing an error.\n */\nexport class ToolInvocationError extends Error {\n public readonly toolCall: ToolCall;\n\n public readonly toolError: Error;\n\n constructor(toolError: unknown, toolCall: ToolCall) {\n const error =\n toolError instanceof Error ? toolError : new Error(String(toolError));\n super(\n `Error invoking tool '${toolCall.name}' with kwargs ${JSON.stringify(\n toolCall.args\n )} ` +\n `with error:\\n ${error.stack}\\n Please fix the error and try again.`\n );\n\n this.toolCall = toolCall;\n this.toolError = error;\n }\n}\n"],"mappings":";;AAGA,IAAa,0BAAb,cAA6C,MAAM;CACjD,cAAc;EACZ,MACE,uKAGD;CACF;AACF;;;;AAKD,IAAa,iCAAb,cAAoD,MAAM;CACxD,AAAgB;CAEhB,YAAYA,WAAqB;EAC/B,MACE,CAAC,qCAAqC,EAAE,UAAU,KAChD,KACD,CAAC,iGAAgC,CACmC,CACtE;EACD,KAAK,YAAY;CAClB;AACF;;;;AAKD,IAAa,+BAAb,cAAkD,MAAM;CACtD,AAAgB;CAEhB,AAAgB;CAEhB,YAAYC,UAAkBC,QAAkB;EAC9C,MACE,CAAC,4CAA4C,EAAE,SAAS,EAAE,EAAE,OACzD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACxB,KAAK,GAAG,CAAC,CAAC,CAAC,CACf;EACD,KAAK,WAAW;EAChB,KAAK,SAAS;CACf;AACF;;;;AAKD,IAAa,sBAAb,cAAyC,MAAM;CAC7C,AAAgB;CAEhB,AAAgB;CAEhB,YAAYC,WAAoBC,UAAoB;EAClD,MAAM,QACJ,qBAAqB,QAAQ,YAAY,IAAI,MAAM,OAAO,UAAU;EACtE,MACE,CAAC,qBAAqB,EAAE,SAAS,KAAK,cAAc,EAAE,KAAK,UACzD,SAAS,KACV,CAAC,eAAC,EACgB,MAAM,MAAM,sCAAsC,CAAC,CACvE;EAED,KAAK,WAAW;EAChB,KAAK,YAAY;CAClB;AACF"}
|
package/dist/agents/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/agents/errors.ts
|
|
2
2
|
var MultipleToolsBoundError = class extends Error {
|
|
3
3
|
constructor() {
|
|
4
|
-
super("The provided LLM already has bound tools. Please provide an LLM without bound tools to
|
|
4
|
+
super("The provided LLM already has bound tools. Please provide an LLM without bound tools to createAgent. The agent will bind the tools provided in the 'tools' parameter.");
|
|
5
5
|
}
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["toolNames: string[]","toolName: string","errors: string[]","toolError: unknown","toolCall: ToolCall"],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to
|
|
1
|
+
{"version":3,"file":"errors.js","names":["toolNames: string[]","toolName: string","errors: string[]","toolError: unknown","toolCall: ToolCall"],"sources":["../../src/agents/errors.ts"],"sourcesContent":["/* eslint-disable no-instanceof/no-instanceof */\nimport type { ToolCall } from \"@langchain/core/messages/tool\";\n\nexport class MultipleToolsBoundError extends Error {\n constructor() {\n super(\n \"The provided LLM already has bound tools. \" +\n \"Please provide an LLM without bound tools to createAgent. \" +\n \"The agent will bind the tools provided in the 'tools' parameter.\"\n );\n }\n}\n\n/**\n * Raised when model returns multiple structured output tool calls when only one is expected.\n */\nexport class MultipleStructuredOutputsError extends Error {\n public readonly toolNames: string[];\n\n constructor(toolNames: string[]) {\n super(\n `The model has called multiple tools: ${toolNames.join(\n \", \"\n )} to return a structured output. ` +\n \"This is not supported. Please provide a single structured output.\"\n );\n this.toolNames = toolNames;\n }\n}\n\n/**\n * Raised when structured output tool call arguments fail to parse according to the schema.\n */\nexport class StructuredOutputParsingError extends Error {\n public readonly toolName: string;\n\n public readonly errors: string[];\n\n constructor(toolName: string, errors: string[]) {\n super(\n `Failed to parse structured output for tool '${toolName}':${errors\n .map((e) => `\\n - ${e}`)\n .join(\"\")}.`\n );\n this.toolName = toolName;\n this.errors = errors;\n }\n}\n\n/**\n * Raised when a tool call is throwing an error.\n */\nexport class ToolInvocationError extends Error {\n public readonly toolCall: ToolCall;\n\n public readonly toolError: Error;\n\n constructor(toolError: unknown, toolCall: ToolCall) {\n const error =\n toolError instanceof Error ? toolError : new Error(String(toolError));\n super(\n `Error invoking tool '${toolCall.name}' with kwargs ${JSON.stringify(\n toolCall.args\n )} ` +\n `with error:\\n ${error.stack}\\n Please fix the error and try again.`\n );\n\n this.toolCall = toolCall;\n this.toolError = error;\n }\n}\n"],"mappings":";AAGA,IAAa,0BAAb,cAA6C,MAAM;CACjD,cAAc;EACZ,MACE,uKAGD;CACF;AACF;;;;AAKD,IAAa,iCAAb,cAAoD,MAAM;CACxD,AAAgB;CAEhB,YAAYA,WAAqB;EAC/B,MACE,CAAC,qCAAqC,EAAE,UAAU,KAChD,KACD,CAAC,iGAAgC,CACmC,CACtE;EACD,KAAK,YAAY;CAClB;AACF;;;;AAKD,IAAa,+BAAb,cAAkD,MAAM;CACtD,AAAgB;CAEhB,AAAgB;CAEhB,YAAYC,UAAkBC,QAAkB;EAC9C,MACE,CAAC,4CAA4C,EAAE,SAAS,EAAE,EAAE,OACzD,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACxB,KAAK,GAAG,CAAC,CAAC,CAAC,CACf;EACD,KAAK,WAAW;EAChB,KAAK,SAAS;CACf;AACF;;;;AAKD,IAAa,sBAAb,cAAyC,MAAM;CAC7C,AAAgB;CAEhB,AAAgB;CAEhB,YAAYC,WAAoBC,UAAoB;EAClD,MAAM,QACJ,qBAAqB,QAAQ,YAAY,IAAI,MAAM,OAAO,UAAU;EACtE,MACE,CAAC,qBAAqB,EAAE,SAAS,KAAK,cAAc,EAAE,KAAK,UACzD,SAAS,KACV,CAAC,eAAC,EACgB,MAAM,MAAM,sCAAsC,CAAC,CACvE;EAED,KAAK,WAAW;EAChB,KAAK,YAAY;CAClB;AACF"}
|
package/dist/agents/index.cjs
CHANGED
|
@@ -7,10 +7,10 @@ require('./interrupt.cjs');
|
|
|
7
7
|
const __langchain_langgraph = require_rolldown_runtime.__toESM(require("@langchain/langgraph"));
|
|
8
8
|
|
|
9
9
|
//#region src/agents/index.ts
|
|
10
|
-
function
|
|
10
|
+
function createAgent(params) {
|
|
11
11
|
return new require_ReactAgent.ReactAgent(params);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
//#endregion
|
|
15
|
-
exports.
|
|
15
|
+
exports.createAgent = createAgent;
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["params:
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >","ReactAgent"],"sources":["../../src/agents/index.ts"],"sourcesContent":["import type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\n\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\n\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type {\n ToolStrategy,\n TypedToolStrategy,\n ProviderStrategy,\n ResponseFormat,\n ResponseFormatUndefined,\n JsonSchemaFormat,\n} from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n\n/**\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n InteropZodType<T>\n > & {\n responseFormat: InteropZodType<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport function createAgent<\n T extends readonly InteropZodType<any>[],\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema,\n T\n > & {\n responseFormat: T;\n }\n): ReactAgent<\n StateSchema,\n ExtractZodArrayTypes<T> extends Record<string, any>\n ? ExtractZodArrayTypes<T>\n : Record<string, any>,\n ContextSchema\n>;\n\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat\n > & {\n responseFormat: JsonSchemaFormat;\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n Record<string, unknown>,\n ContextSchema,\n JsonSchemaFormat | JsonSchemaFormat[]\n > & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n }\n): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n TypedToolStrategy<T>\n > & {\n responseFormat: TypedToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 7: With responseFormat as ProviderStrategy\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n T extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n T,\n ContextSchema,\n ProviderStrategy<T>\n > & {\n responseFormat: ProviderStrategy<T>;\n }\n): ReactAgent<StateSchema, T, ContextSchema>;\n\n// Overload 8: Without responseFormat property at all\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n >\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 9: With responseFormat explicitly undefined\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: Omit<\n CreateAgentParams<\n StateSchema,\n ResponseFormatUndefined,\n ContextSchema,\n never\n >,\n \"responseFormat\"\n > & {\n responseFormat?: undefined;\n }\n): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n\n// Overload 10: For other ResponseFormat values (failsafe)\nexport function createAgent<\n StateSchema extends\n | AnyAnnotationRoot\n | InteropZodObject = typeof MessagesAnnotation,\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n ResponseFormat\n > & {\n responseFormat: ResponseFormat;\n }\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;\n\n// Implementation\nexport function createAgent<\n StateSchema extends AnyAnnotationRoot | InteropZodObject,\n StructuredResponseFormat extends Record<string, any>,\n ContextSchema extends AnyAnnotationRoot | InteropZodObject\n>(\n params: CreateAgentParams<\n StateSchema,\n StructuredResponseFormat,\n ContextSchema,\n any\n >\n): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema> {\n return new ReactAgent(params);\n}\n\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport {\n toolStrategy,\n providerStrategy,\n ToolStrategy,\n ProviderStrategy,\n type ResponseFormat,\n} from \"./responses.js\";\n"],"mappings":";;;;;;;;;AAqQA,SAAgB,YAKdA,QAMkE;AAClE,QAAO,IAAIC,8BAAW;AACvB"}
|
package/dist/agents/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { MultipleStructuredOutputsError, StructuredOutputParsingError } from "./
|
|
|
2
2
|
import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy, providerStrategy, toolStrategy } from "./responses.cjs";
|
|
3
3
|
import { AnyAnnotationRoot } from "./annotation.cjs";
|
|
4
4
|
import { ToolNode } from "./nodes/ToolNode.cjs";
|
|
5
|
-
import { AgentState, ClientTool,
|
|
5
|
+
import { AgentRuntime, AgentState, ClientTool, CreateAgentParams, ExtractZodArrayTypes, N, Prompt, ServerTool } from "./types.cjs";
|
|
6
6
|
import { ReactAgent } from "./ReactAgent.cjs";
|
|
7
7
|
import { ActionRequest, HumanInterrupt, HumanInterruptConfig, HumanResponse } from "./interrupt.cjs";
|
|
8
8
|
import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
|
|
@@ -16,7 +16,7 @@ import { MessagesAnnotation } from "@langchain/langgraph";
|
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
18
18
|
* import { ChatOpenAI } from "@langchain/openai";
|
|
19
|
-
* import {
|
|
19
|
+
* import { createAgent, tool } from "langchain";
|
|
20
20
|
* import { z } from "zod";
|
|
21
21
|
*
|
|
22
22
|
* const model = new ChatOpenAI({
|
|
@@ -37,7 +37,7 @@ import { MessagesAnnotation } from "@langchain/langgraph";
|
|
|
37
37
|
* })
|
|
38
38
|
* })
|
|
39
39
|
*
|
|
40
|
-
* const agent =
|
|
40
|
+
* const agent = createAgent({ llm: model, tools: [getWeather] });
|
|
41
41
|
*
|
|
42
42
|
* const inputs = {
|
|
43
43
|
* messages: [{ role: "user", content: "what is the weather in SF?" }],
|
|
@@ -52,47 +52,47 @@ import { MessagesAnnotation } from "@langchain/langgraph";
|
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
// Overload 1: With responseFormat as single InteropZodType
|
|
55
|
-
declare function
|
|
55
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {
|
|
56
56
|
responseFormat: InteropZodType<T>;
|
|
57
57
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
58
58
|
// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)
|
|
59
|
-
declare function
|
|
59
|
+
declare function createAgent<T extends readonly InteropZodType<any>[], StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {
|
|
60
60
|
responseFormat: T;
|
|
61
61
|
}): ReactAgent<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema>;
|
|
62
62
|
// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)
|
|
63
|
-
declare function
|
|
63
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {
|
|
64
64
|
responseFormat: JsonSchemaFormat;
|
|
65
65
|
}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;
|
|
66
66
|
// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)
|
|
67
|
-
declare function
|
|
67
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {
|
|
68
68
|
responseFormat: JsonSchemaFormat[];
|
|
69
69
|
}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;
|
|
70
70
|
// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]
|
|
71
|
-
declare function
|
|
71
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {
|
|
72
72
|
responseFormat: JsonSchemaFormat | JsonSchemaFormat[];
|
|
73
73
|
}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;
|
|
74
74
|
// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)
|
|
75
|
-
declare function
|
|
75
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, TypedToolStrategy<T>> & {
|
|
76
76
|
responseFormat: TypedToolStrategy<T>;
|
|
77
77
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
78
78
|
// Overload 6: With responseFormat as single ToolStrategy instance
|
|
79
|
-
declare function
|
|
79
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {
|
|
80
80
|
responseFormat: ToolStrategy<T>;
|
|
81
81
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
82
82
|
// Overload 7: With responseFormat as ProviderStrategy
|
|
83
|
-
declare function
|
|
83
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ProviderStrategy<T>> & {
|
|
84
84
|
responseFormat: ProviderStrategy<T>;
|
|
85
85
|
}): ReactAgent<StateSchema, T, ContextSchema>;
|
|
86
86
|
// Overload 8: Without responseFormat property at all
|
|
87
|
-
declare function
|
|
87
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, "responseFormat">): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;
|
|
88
88
|
// Overload 9: With responseFormat explicitly undefined
|
|
89
|
-
declare function
|
|
89
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, "responseFormat"> & {
|
|
90
90
|
responseFormat?: undefined;
|
|
91
91
|
}): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;
|
|
92
92
|
// Overload 10: For other ResponseFormat values (failsafe)
|
|
93
|
-
declare function
|
|
93
|
+
declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema, ResponseFormat> & {
|
|
94
94
|
responseFormat: ResponseFormat;
|
|
95
95
|
}): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;
|
|
96
96
|
//#endregion
|
|
97
|
-
export {
|
|
97
|
+
export { createAgent };
|
|
98
98
|
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["InteropZodObject","InteropZodType","MessagesAnnotation","AnyAnnotationRoot","CreateReactAgentParams","ExtractZodArrayTypes","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormat","ResponseFormatUndefined","JsonSchemaFormat","ReactAgent","createReactAgent","Record","StateSchema","T","ContextSchema","Omit","StructuredResponseFormat","ToolNode","toolStrategy","providerStrategy"],"sources":["../../src/agents/index.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateReactAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type { ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, JsonSchemaFormat } from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n/**\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { createReactAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport declare function createReactAgent<T extends readonly InteropZodType<any>[], StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {\n responseFormat: T;\n}): ReactAgent<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema>;\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 7: With responseFormat as ProviderStrategy\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 8: Without responseFormat property at all\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateReactAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\">): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 9: With responseFormat explicitly undefined\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateReactAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n}): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 10: For other ResponseFormat values (failsafe)\nexport declare function createReactAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateReactAgentParams<StateSchema, StructuredResponseFormat, ContextSchema, ResponseFormat> & {\n responseFormat: ResponseFormat;\n}): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport { toolStrategy, providerStrategy, ToolStrategy, ProviderStrategy, type ResponseFormat, } from \"./responses.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA;;;;;;;;;;;;;;;;;;;;;;AAEc;AAEd;;;;;;;;;;;;;;AAA2VK,iBAJnUQ,gBAImUR,CAAAA,oBAJ9RF,iBAI8RE,GAJ1QL,gBAI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AA;;AAAvC,iBAwBUJ,gBAxBV,CAAA,oBAwB+CV,iBAxB/C,GAwBmEH,gBAxBnE,GAAA,OAwB6FE,kBAxB7F,EAAA,sBAwBuIC,iBAxBvI,GAwB2JH,gBAxB3J,GAwB8KG,iBAxB9K,CAAA,CAAA,MAAA,EAwByMe,IAxBzM,CAwB8Md,sBAxB9M,CAwBqOW,WAxBrO,EAwBkPL,uBAxBlP,EAwB2QO,aAxB3Q,EAAA,KAAA,CAAA,EAAA,gBAAA,CAAA,GAAA;EAEUJ,cAAAA,CAAAA,EAAAA,SAAgB;CAAA,CAAA,EAwBpCD,UAxBoC,CAwBzBG,WAxByB,EAwBZL,uBAxBY,EAwBaO,aAxBb,CAAA;;AAAyCjB,iBA0BzDa,gBA1ByDb,CAAAA,oBA0BpBG,iBA1BoBH,GA0BAA,gBA1BAA,GAAAA,OA0B0BE,kBA1B1BF,EAAAA,iCA0B+Ec,MA1B/Ed,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GA0BqGc,MA1BrGd,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA,sBA0BgJG,iBA1BhJH,GA0BoKA,gBA1BpKA,GA0BuLG,iBA1BvLH,CAAAA,CAAAA,MAAAA,EA0BkNI,sBA1BlNJ,CA0ByOe,WA1BzOf,EA0BsPmB,wBA1BtPnB,EA0BgRiB,aA1BhRjB,EA0B+RS,cA1B/RT,CAAAA,GAAAA;EAAgB,cAAUE,EA2BvFO,cA3BuFP;CAAkB,CAAA,EA4BzHU,UA5BiJT,CA4BtIY,WA5BsIZ,EA4BzHgB,wBA5ByHhB,EA4B/Fc,aA5B+Fd,CAAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["InteropZodObject","InteropZodType","MessagesAnnotation","AnyAnnotationRoot","CreateAgentParams","ExtractZodArrayTypes","ToolStrategy","TypedToolStrategy","ProviderStrategy","ResponseFormat","ResponseFormatUndefined","JsonSchemaFormat","ReactAgent","createAgent","Record","StateSchema","T","ContextSchema","Omit","StructuredResponseFormat","ToolNode","toolStrategy","providerStrategy"],"sources":["../../src/agents/index.d.ts"],"sourcesContent":["import type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport { MessagesAnnotation } from \"@langchain/langgraph\";\nimport { type AnyAnnotationRoot } from \"./annotation.js\";\nimport type { CreateAgentParams, ExtractZodArrayTypes } from \"./types.js\";\nimport type { ToolStrategy, TypedToolStrategy, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, JsonSchemaFormat } from \"./responses.js\";\nimport { ReactAgent } from \"./ReactAgent.js\";\n/**\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { createAgent, tool } from \"langchain\";\n * import { z } from \"zod\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\n// Overload 1: With responseFormat as single InteropZodType\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, InteropZodType<T>> & {\n responseFormat: InteropZodType<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 2: With responseFormat as array of InteropZodTypes (infers union type)\nexport declare function createAgent<T extends readonly InteropZodType<any>[], StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema, T> & {\n responseFormat: T;\n}): ReactAgent<StateSchema, ExtractZodArrayTypes<T> extends Record<string, any> ? ExtractZodArrayTypes<T> : Record<string, any>, ContextSchema>;\n// Overload 3: With responseFormat as JsonSchemaFormat (JSON schema object)\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat> & {\n responseFormat: JsonSchemaFormat;\n}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 4: With responseFormat as array of JsonSchemaFormat (JSON schema objects)\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat[];\n}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 4.5: With responseFormat as union of JsonSchemaFormat | JsonSchemaFormat[]\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, Record<string, unknown>, ContextSchema, JsonSchemaFormat | JsonSchemaFormat[]> & {\n responseFormat: JsonSchemaFormat | JsonSchemaFormat[];\n}): ReactAgent<StateSchema, Record<string, unknown>, ContextSchema>;\n// Overload 5: With responseFormat as TypedToolStrategy (for union types from toolStrategy)\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, TypedToolStrategy<T>> & {\n responseFormat: TypedToolStrategy<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 6: With responseFormat as single ToolStrategy instance\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ToolStrategy<T>> & {\n responseFormat: ToolStrategy<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 7: With responseFormat as ProviderStrategy\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, T extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, T, ContextSchema, ProviderStrategy<T>> & {\n responseFormat: ProviderStrategy<T>;\n}): ReactAgent<StateSchema, T, ContextSchema>;\n// Overload 8: Without responseFormat property at all\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\">): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 9: With responseFormat explicitly undefined\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: Omit<CreateAgentParams<StateSchema, ResponseFormatUndefined, ContextSchema, never>, \"responseFormat\"> & {\n responseFormat?: undefined;\n}): ReactAgent<StateSchema, ResponseFormatUndefined, ContextSchema>;\n// Overload 10: For other ResponseFormat values (failsafe)\nexport declare function createAgent<StateSchema extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation, StructuredResponseFormat extends Record<string, any> = Record<string, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params: CreateAgentParams<StateSchema, StructuredResponseFormat, ContextSchema, ResponseFormat> & {\n responseFormat: ResponseFormat;\n}): ReactAgent<StateSchema, StructuredResponseFormat, ContextSchema>;\nexport * from \"./types.js\";\nexport * from \"./errors.js\";\nexport * from \"./interrupt.js\";\nexport { ToolNode } from \"./nodes/ToolNode.js\";\nexport { toolStrategy, providerStrategy, ToolStrategy, ProviderStrategy, type ResponseFormat, } from \"./responses.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA;;;;;;;;;;;;;;;;;;;;;;AAEc;AAEd;;;;;;;;;;;;;;AAAiVK,iBAJzTQ,WAIyTR,CAAAA,oBAJzRF,iBAIyRE,GAJrQL,gBAIqQK,GAAAA,OAJ3OH,kBAI2OG,EAAAA,UAJ7MS,MAI6MT,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,GAJvLS,MAIuLT,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,EAAAA,sBAJ5IF,iBAI4IE,GAJxHL,gBAIwHK,GAJrGF,iBAIqGE,CAAAA,CAAAA,MAAAA,EAJ1ED,iBAI0EC,CAJxDU,WAIwDV,EAJ3CW,CAI2CX,EAJxCY,aAIwCZ,EAJzBJ,cAIyBI,CAJVW,CAIUX,CAAAA,CAAAA,GAAAA;EAAoB,cAAMS,EAHvVb,cAGuVa,CAHxUE,CAGwUF,CAAAA;CAAM,CAAA,EAF7WF,UAE4XK,CAFjXF,WAEiXE,EAFpWD,CAEoWC,EAFjWA,aAEiWA,CAAAA;;AAApIb,iBAApOS,WAAo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