reagentbuilder
Version:
An enterprise-grade AI agent framework based on LangChain and LangGraph, featuring dynamic tools, interceptors, breakpoints, and performance monitoring.
35 lines • 1.1 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.NODES = exports.AgentState = void 0;
exports.isAgentState = isAgentState;
const langgraph_1 = require("@langchain/langgraph");
// ============ 状态定义 ============
exports.AgentState = langgraph_1.Annotation.Root({
messages: (0, langgraph_1.Annotation)({
reducer: (x, y) => x.concat(y),
default: () => [],
}),
// ReAct模式状态跟踪
reactIteration: (0, langgraph_1.Annotation)({
reducer: (x, y) => y ?? x,
default: () => 0,
}),
reactMaxIterations: (0, langgraph_1.Annotation)({
reducer: (x, y) => y ?? x,
default: () => 10,
}),
});
exports.NODES = {
AGENT: "agent",
TOOLS: "tools"
};
// ============ 类型保护函数 ============
function isAgentState(obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
const state = obj;
return (Array.isArray(state.messages) &&
state.messages.every((msg) => msg && typeof msg === 'object' && 'getType' in msg));
}
//# sourceMappingURL=agent.js.map
;