langchain 1.0.2 → 1.0.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.
Files changed (132) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/agents/ReactAgent.cjs +21 -41
  3. package/dist/agents/ReactAgent.cjs.map +1 -1
  4. package/dist/agents/ReactAgent.js +21 -41
  5. package/dist/agents/ReactAgent.js.map +1 -1
  6. package/dist/agents/annotation.cjs +7 -4
  7. package/dist/agents/annotation.cjs.map +1 -1
  8. package/dist/agents/annotation.js +8 -5
  9. package/dist/agents/annotation.js.map +1 -1
  10. package/dist/agents/middleware/contextEditing.d.cts.map +1 -1
  11. package/dist/agents/middleware/contextEditing.d.ts.map +1 -1
  12. package/dist/agents/middleware/dynamicSystemPrompt.d.cts.map +1 -1
  13. package/dist/agents/middleware/dynamicSystemPrompt.d.ts.map +1 -1
  14. package/dist/agents/middleware/hitl.cjs +7 -2
  15. package/dist/agents/middleware/hitl.cjs.map +1 -1
  16. package/dist/agents/middleware/hitl.d.cts.map +1 -1
  17. package/dist/agents/middleware/hitl.d.ts.map +1 -1
  18. package/dist/agents/middleware/hitl.js +7 -2
  19. package/dist/agents/middleware/hitl.js.map +1 -1
  20. package/dist/agents/middleware/index.cjs +2 -1
  21. package/dist/agents/middleware/index.js +2 -1
  22. package/dist/agents/middleware/llmToolSelector.d.cts +4 -4
  23. package/dist/agents/middleware/llmToolSelector.d.cts.map +1 -1
  24. package/dist/agents/middleware/{callLimit.cjs → modelCallLimit.cjs} +22 -7
  25. package/dist/agents/middleware/modelCallLimit.cjs.map +1 -0
  26. package/dist/agents/middleware/{callLimit.d.cts → modelCallLimit.d.cts} +12 -3
  27. package/dist/agents/middleware/modelCallLimit.d.cts.map +1 -0
  28. package/dist/agents/middleware/{callLimit.d.ts → modelCallLimit.d.ts} +12 -3
  29. package/dist/agents/middleware/modelCallLimit.d.ts.map +1 -0
  30. package/dist/agents/middleware/{callLimit.js → modelCallLimit.js} +22 -7
  31. package/dist/agents/middleware/modelCallLimit.js.map +1 -0
  32. package/dist/agents/middleware/promptCaching.d.cts.map +1 -1
  33. package/dist/agents/middleware/promptCaching.d.ts.map +1 -1
  34. package/dist/agents/middleware/summarization.cjs +274 -52
  35. package/dist/agents/middleware/summarization.cjs.map +1 -1
  36. package/dist/agents/middleware/summarization.d.cts +326 -30
  37. package/dist/agents/middleware/summarization.d.cts.map +1 -1
  38. package/dist/agents/middleware/summarization.d.ts +325 -29
  39. package/dist/agents/middleware/summarization.d.ts.map +1 -1
  40. package/dist/agents/middleware/summarization.js +276 -54
  41. package/dist/agents/middleware/summarization.js.map +1 -1
  42. package/dist/agents/middleware/todoListMiddleware.d.cts.map +1 -1
  43. package/dist/agents/middleware/todoListMiddleware.d.ts.map +1 -1
  44. package/dist/agents/middleware/toolCallLimit.cjs +215 -93
  45. package/dist/agents/middleware/toolCallLimit.cjs.map +1 -1
  46. package/dist/agents/middleware/toolCallLimit.d.cts +48 -37
  47. package/dist/agents/middleware/toolCallLimit.d.cts.map +1 -1
  48. package/dist/agents/middleware/toolCallLimit.d.ts +48 -37
  49. package/dist/agents/middleware/toolCallLimit.d.ts.map +1 -1
  50. package/dist/agents/middleware/toolCallLimit.js +216 -94
  51. package/dist/agents/middleware/toolCallLimit.js.map +1 -1
  52. package/dist/agents/middleware/toolRetry.cjs +224 -0
  53. package/dist/agents/middleware/toolRetry.cjs.map +1 -0
  54. package/dist/agents/middleware/toolRetry.d.cts +179 -0
  55. package/dist/agents/middleware/toolRetry.d.cts.map +1 -0
  56. package/dist/agents/middleware/toolRetry.d.ts +179 -0
  57. package/dist/agents/middleware/toolRetry.d.ts.map +1 -0
  58. package/dist/agents/middleware/toolRetry.js +223 -0
  59. package/dist/agents/middleware/toolRetry.js.map +1 -0
  60. package/dist/agents/middleware/types.d.cts +21 -19
  61. package/dist/agents/middleware/types.d.cts.map +1 -1
  62. package/dist/agents/middleware/types.d.ts +21 -19
  63. package/dist/agents/middleware/types.d.ts.map +1 -1
  64. package/dist/agents/middleware/utils.cjs +7 -0
  65. package/dist/agents/middleware/utils.cjs.map +1 -1
  66. package/dist/agents/middleware/utils.d.cts.map +1 -1
  67. package/dist/agents/middleware/utils.d.ts.map +1 -1
  68. package/dist/agents/middleware/utils.js +7 -1
  69. package/dist/agents/middleware/utils.js.map +1 -1
  70. package/dist/agents/middleware.cjs.map +1 -1
  71. package/dist/agents/middleware.d.cts +4 -4
  72. package/dist/agents/middleware.d.cts.map +1 -1
  73. package/dist/agents/middleware.d.ts +4 -4
  74. package/dist/agents/middleware.d.ts.map +1 -1
  75. package/dist/agents/middleware.js.map +1 -1
  76. package/dist/agents/nodes/AgentNode.cjs +21 -51
  77. package/dist/agents/nodes/AgentNode.cjs.map +1 -1
  78. package/dist/agents/nodes/AgentNode.js +23 -53
  79. package/dist/agents/nodes/AgentNode.js.map +1 -1
  80. package/dist/agents/nodes/ToolNode.cjs +12 -18
  81. package/dist/agents/nodes/ToolNode.cjs.map +1 -1
  82. package/dist/agents/nodes/ToolNode.js +12 -18
  83. package/dist/agents/nodes/ToolNode.js.map +1 -1
  84. package/dist/agents/nodes/middleware.cjs +9 -7
  85. package/dist/agents/nodes/middleware.cjs.map +1 -1
  86. package/dist/agents/nodes/middleware.js +10 -8
  87. package/dist/agents/nodes/middleware.js.map +1 -1
  88. package/dist/agents/nodes/types.d.cts +1 -1
  89. package/dist/agents/nodes/types.d.cts.map +1 -1
  90. package/dist/agents/nodes/types.d.ts +1 -1
  91. package/dist/agents/nodes/types.d.ts.map +1 -1
  92. package/dist/agents/nodes/utils.cjs +5 -1
  93. package/dist/agents/nodes/utils.cjs.map +1 -1
  94. package/dist/agents/nodes/utils.js +5 -1
  95. package/dist/agents/nodes/utils.js.map +1 -1
  96. package/dist/agents/responses.cjs +0 -1
  97. package/dist/agents/responses.js +1 -1
  98. package/dist/agents/runtime.d.cts +11 -27
  99. package/dist/agents/runtime.d.cts.map +1 -1
  100. package/dist/agents/runtime.d.ts +11 -27
  101. package/dist/agents/runtime.d.ts.map +1 -1
  102. package/dist/agents/state.cjs +45 -0
  103. package/dist/agents/state.cjs.map +1 -0
  104. package/dist/agents/state.js +44 -0
  105. package/dist/agents/state.js.map +1 -0
  106. package/dist/agents/types.d.cts +1 -1
  107. package/dist/agents/types.d.cts.map +1 -1
  108. package/dist/agents/types.d.ts +1 -1
  109. package/dist/agents/types.d.ts.map +1 -1
  110. package/dist/agents/utils.cjs +10 -2
  111. package/dist/agents/utils.cjs.map +1 -1
  112. package/dist/agents/utils.js +10 -2
  113. package/dist/agents/utils.js.map +1 -1
  114. package/dist/chat_models/universal.cjs +2 -2
  115. package/dist/chat_models/universal.cjs.map +1 -1
  116. package/dist/chat_models/universal.js +2 -2
  117. package/dist/chat_models/universal.js.map +1 -1
  118. package/dist/index.cjs +6 -18
  119. package/dist/index.cjs.map +1 -1
  120. package/dist/index.d.cts +4 -4
  121. package/dist/index.d.ts +4 -4
  122. package/dist/index.js +4 -5
  123. package/dist/index.js.map +1 -1
  124. package/package.json +7 -7
  125. package/dist/agents/middleware/callLimit.cjs.map +0 -1
  126. package/dist/agents/middleware/callLimit.d.cts.map +0 -1
  127. package/dist/agents/middleware/callLimit.d.ts.map +0 -1
  128. package/dist/agents/middleware/callLimit.js.map +0 -1
  129. package/dist/agents/tools.d.cts +0 -9
  130. package/dist/agents/tools.d.cts.map +0 -1
  131. package/dist/agents/tools.d.ts +0 -9
  132. package/dist/agents/tools.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","z","privateShape: Record<string, any>","target?: string","END"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,eACvB,KAAI,WAAW,aAAa;EAE1B,MAAM,sFACJ,WAAW,aACX,CAAC,QAAQ,IAAI,WAAW,IAAI,CAC7B;EAGD,MAAM,cAAc,8DAA4B,gBAAgB,MAAM;AAEtE,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;;EAKD,MAAM,iBAAiB,YAAY,MAAM,OACtC,OACC,CAACC,UACC,MAAM,SAAS,kBAAkB,MAAM,YAAY,WACtD,CACA,IACC,CAACA,UAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC,EAAE,EAAE,MAAM,SAAS,CACrE,CACA,KAAK,KAAK;AAEb,QAAM,IAAI,MACR,CAAC,YAAY,EAAE,WAAW,KAAK,uDAAuD,EACjF,eAAe,0aAAI,EAad,YAAY,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,gBAAW,CACxD;CAEZ;AAGH,QAAO;AACR;;;;;;;AAQD,SAAgB,mBACdC,aAC4B;CAC5B,MAAM,qBAAqB;EACzB,UAAUC,SAAE,OAAsB,MAAM,CAAE,EAAC;EAE3C,oBAAoBA,SAAE,KAAK,CAAC,UAAU;CACvC;AAED,KAAI,CAAC,YACH,QAAOA,SAAE,OAAO,mBAAmB;CAGrC,MAAM,EAAE,OAAO,GAAG;CAClB,MAAMC,eAAoC,EAAE,GAAG,mBAAoB;AAGnE,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,MAAM,CAC9C,KAAI,IAAI,WAAW,IAAI,EAErB,aAAa,OAAO,MAAM,UAAU;MAEpC,aAAa,OAAO;AAKxB,QAAOD,SAAE,OAAO,aAAa;AAC9B;AAMD,SAAgB,kBAAkBE,QAAqC;AACrE,KAAI,CAAC,OACH,QAAO;;;;AAMT,KAAI;EAAC;EAAiB;EAASC;CAAI,EAAC,SAAS,OAAO,CAClD,QAAO;AAGT,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,MACb,QAAOA;AAGT,OAAM,IAAI,MACR,CAAC,qBAAqB,EAAE,OAAO,oCAAoC,CAAC;AAEvE;;;;;;;;;AAkBD,SAAgB,kBACd,GAAG,SACU;AACb,QAAO,YAAY,IACjB,QAAQ,OACN,CAAC,gBACC,gBAAgB,QAChB,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
1
+ {"version":3,"file":"utils.cjs","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","z","privateShape: Record<string, any>","target?: string","END"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n /**\n * skip middleware if it doesn't have a state schema\n */\n if (!middleware.stateSchema) {\n continue;\n }\n\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map((issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`)\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,g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WAAW,QACb,QAAO;AAET,KAAI,WAAW,MACb,QAAOA;AAGT,OAAM,IAAI,MACR,CAAC,qBAAqB,EAAE,OAAO,oCAAoC,CAAC;AAEvE;;;;;;;;;AAkBD,SAAgB,kBACd,GAAG,SACU;AACb,QAAO,YAAY,IACjB,QAAQ,OACN,CAAC,gBACC,gBAAgB,QAChB,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
@@ -12,7 +12,11 @@ import { interopSafeParseAsync, interopZodObjectMakeFieldsOptional } from "@lang
12
12
  */
13
13
  async function initializeMiddlewareStates(middlewareList, state) {
14
14
  const middlewareStates = {};
15
- for (const middleware of middlewareList) if (middleware.stateSchema) {
15
+ for (const middleware of middlewareList) {
16
+ /**
17
+ * skip middleware if it doesn't have a state schema
18
+ */
19
+ if (!middleware.stateSchema) continue;
16
20
  const modifiedSchema = interopZodObjectMakeFieldsOptional(middleware.stateSchema, (key) => key.startsWith("_"));
17
21
  const parseResult = await interopSafeParseAsync(modifiedSchema, state);
18
22
  if (parseResult.success) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","target?: string"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n if (middleware.stateSchema) {\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map(\n (issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`\n )\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACA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OAAO,CAClD,QAAO;AAGT,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,QACb,QAAO;AAET,KAAI,WAAW,MACb,QAAO;AAGT,OAAM,IAAI,MACR,CAAC,qBAAqB,EAAE,OAAO,oCAAoC,CAAC;AAEvE;;;;;;;;;AAkBD,SAAgB,kBACd,GAAG,SACU;AACb,QAAO,YAAY,IACjB,QAAQ,OACN,CAAC,gBACC,gBAAgB,QAChB,gBAAgB,UAChB,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
1
+ {"version":3,"file":"utils.js","names":["middlewareList: readonly AgentMiddleware[]","state: unknown","middlewareStates: Record<string, any>","issue: ZodIssue","stateSchema?: z.ZodObject<z.ZodRawShape>","privateShape: Record<string, any>","target?: string"],"sources":["../../../src/agents/nodes/utils.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { z } from \"zod/v3\";\nimport { type BaseMessage } from \"@langchain/core/messages\";\nimport {\n interopSafeParseAsync,\n interopZodObjectMakeFieldsOptional,\n} from \"@langchain/core/utils/types\";\nimport { type ZodIssue } from \"zod/v3\";\nimport { END } from \"@langchain/langgraph\";\n\nimport type { JumpTo } from \"../types.js\";\nimport type { AgentMiddleware } from \"../middleware/types.js\";\n\n/**\n * Helper function to initialize middleware state defaults.\n * This is used to ensure all middleware state properties are initialized.\n *\n * Private properties (starting with _) are automatically made optional since\n * users cannot provide them when invoking the agent.\n */\nexport async function initializeMiddlewareStates(\n middlewareList: readonly AgentMiddleware[],\n state: unknown\n): Promise<Record<string, any>> {\n const middlewareStates: Record<string, any> = {};\n\n for (const middleware of middlewareList) {\n /**\n * skip middleware if it doesn't have a state schema\n */\n if (!middleware.stateSchema) {\n continue;\n }\n\n // Create a modified schema where private properties are optional\n const modifiedSchema = interopZodObjectMakeFieldsOptional(\n middleware.stateSchema,\n (key) => key.startsWith(\"_\")\n );\n\n // Use safeParse with the modified schema\n const parseResult = await interopSafeParseAsync(modifiedSchema, state);\n if (parseResult.success) {\n Object.assign(middlewareStates, parseResult.data);\n continue;\n }\n\n /**\n * If safeParse fails, there are required public fields missing\n */\n const requiredFields = parseResult.error.issues\n .filter(\n (issue: ZodIssue) =>\n issue.code === \"invalid_type\" && issue.message === \"Required\"\n )\n .map((issue: ZodIssue) => ` - ${issue.path.join(\".\")}: ${issue.message}`)\n .join(\"\\n\");\n\n throw new Error(\n `Middleware \"${middleware.name}\" has required state fields that must be initialized:\\n` +\n `${requiredFields}\\n\\n` +\n `To fix this, either:\\n` +\n `1. Provide default values in your middleware's state schema using .default():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().default(\"default value\")\\n` +\n ` })\\n\\n` +\n `2. Or make the fields optional using .optional():\\n` +\n ` stateSchema: z.object({\\n` +\n ` myField: z.string().optional()\\n` +\n ` })\\n\\n` +\n `3. Or ensure you pass these values when invoking the agent:\\n` +\n ` agent.invoke({\\n` +\n ` messages: [...],\\n` +\n ` ${parseResult.error.issues[0]?.path.join(\".\")}: \"value\"\\n` +\n ` })`\n );\n }\n\n return middlewareStates;\n}\n\n/**\n * Users can define private and public state for a middleware. Private state properties start with an underscore.\n * This function will return the private state properties from the state schema, making all of them optional.\n * @param stateSchema - The middleware state schema\n * @returns A new schema containing only the private properties (underscore-prefixed), all made optional\n */\nexport function derivePrivateState(\n stateSchema?: z.ZodObject<z.ZodRawShape>\n): z.ZodObject<z.ZodRawShape> {\n const builtInStateSchema = {\n messages: z.custom<BaseMessage[]>(() => []),\n // Include optional structuredResponse so after_agent hooks can access/modify it\n structuredResponse: z.any().optional(),\n };\n\n if (!stateSchema) {\n return z.object(builtInStateSchema);\n }\n\n const { shape } = stateSchema;\n const privateShape: Record<string, any> = { ...builtInStateSchema };\n\n // Filter properties that start with underscore and make them optional\n for (const [key, value] of Object.entries(shape)) {\n if (key.startsWith(\"_\")) {\n // Make the private property optional\n privateShape[key] = value.optional();\n } else {\n privateShape[key] = value;\n }\n }\n\n // Return a new schema with only private properties (all optional)\n return z.object(privateShape);\n}\n\n/**\n * Parse `jumpTo` target from user facing labels to a LangGraph node names\n */\nexport function parseJumpToTarget(target: string): JumpTo;\nexport function parseJumpToTarget(target?: string): JumpTo | undefined {\n if (!target) {\n return undefined;\n }\n\n /**\n * if target is already a valid jump target, return it\n */\n if ([\"model_request\", \"tools\", END].includes(target)) {\n return target as JumpTo;\n }\n\n if (target === \"model\") {\n return \"model_request\";\n }\n if (target === \"tools\") {\n return \"tools\";\n }\n if (target === \"end\") {\n return END;\n }\n\n throw new Error(\n `Invalid jump target: ${target}, must be \"model\", \"tools\" or \"end\".`\n );\n}\n\n/**\n * TypeScript currently doesn't support types for `AbortSignal.any`\n * @see https://github.com/microsoft/TypeScript/issues/60695\n */\ndeclare const AbortSignal: {\n any(signals: AbortSignal[]): AbortSignal;\n};\n\n/**\n * `config` always contains a signal from LangGraphs Pregel class.\n * To ensure we acknowledge the abort signal from the user, we merge it\n * with the signal from the ToolNode.\n *\n * @param signals - The signals to merge.\n * @returns The merged signal.\n */\nexport function mergeAbortSignals(\n ...signals: (AbortSignal | undefined)[]\n): AbortSignal {\n return AbortSignal.any(\n signals.filter(\n (maybeSignal): maybeSignal is AbortSignal =>\n maybeSignal !== null &&\n maybeSignal !== undefined &&\n typeof maybeSignal === \"object\" &&\n \"aborted\" in maybeSignal &&\n typeof maybeSignal.aborted === \"boolean\"\n )\n );\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,eAAsB,2BACpBA,gBACAC,OAC8B;CAC9B,MAAMC,mBAAwC,CAAE;AAEhD,MAAK,MAAM,cAAc,gBAAgB;;;;AAIvC,MAAI,CAAC,WAAW,YACd;EAIF,MAAM,iBAAiB,mCACrB,WAAW,aACX,CAAC,QAAQ,IAAI,WAAW,IAAI,CAC7B;EAGD,MAAM,cAAc,MAAM,sBAAsB,gBAAgB,MAAM;AACtE,MAAI,YAAY,SAAS;GACvB,OAAO,OAAO,kBAAkB,YAAY,KAAK;AACjD;EACD;;;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,OAAO,gBAAgB,YACvB,aAAa,eACb,OAAO,YAAY,YAAY,UAClC,CACF;AACF"}
@@ -201,7 +201,6 @@ function hasSupportForJsonSchemaOutput(model) {
201
201
  //#endregion
202
202
  exports.ProviderStrategy = ProviderStrategy;
203
203
  exports.ToolStrategy = ToolStrategy;
204
- exports.hasSupportForJsonSchemaOutput = hasSupportForJsonSchemaOutput;
205
204
  exports.providerStrategy = providerStrategy;
206
205
  exports.toolStrategy = toolStrategy;
207
206
  exports.transformResponseFormat = transformResponseFormat;
@@ -198,5 +198,5 @@ function hasSupportForJsonSchemaOutput(model) {
198
198
  }
199
199
 
200
200
  //#endregion
201
- export { ProviderStrategy, ToolStrategy, hasSupportForJsonSchemaOutput, providerStrategy, toolStrategy, transformResponseFormat };
201
+ export { ProviderStrategy, ToolStrategy, providerStrategy, toolStrategy, transformResponseFormat };
202
202
  //# sourceMappingURL=responses.js.map
@@ -1,4 +1,5 @@
1
1
  import { BaseMessage } from "@langchain/core/messages";
2
+ import { BaseCallbackConfig } from "@langchain/core/callbacks/manager";
2
3
  import { InteropZodDefault, InteropZodOptional } from "@langchain/core/utils/types";
3
4
  import { PregelOptions, Runtime } from "@langchain/langgraph";
4
5
 
@@ -52,33 +53,12 @@ type WithMaybeContext<TContext> = undefined extends TContext ? {
52
53
  /**
53
54
  * Runtime information available to middleware (readonly).
54
55
  */
55
- type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & PrivateState & {
56
+ type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & {
56
57
  configurable?: {
57
58
  thread_id?: string;
58
59
  [key: string]: unknown;
59
60
  };
60
61
  };
61
- interface RunLevelPrivateState {
62
- /**
63
- * The number of times the model has been called at the run level.
64
- * This includes multiple agent invocations.
65
- */
66
- runModelCallCount: number;
67
- }
68
- interface ThreadLevelPrivateState {
69
- /**
70
- * The number of times the model has been called at the thread level.
71
- * This includes multiple agent invocations within different environments
72
- * using the same thread.
73
- */
74
- threadLevelCallCount: number;
75
- }
76
- /**
77
- * As private state we consider all information we want to track within
78
- * the lifecycle of the agent, without exposing it to the user. These informations
79
- * are propagated to the user as _readonly_ runtime properties.
80
- */
81
- interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {}
82
62
  /**
83
63
  * Helper type to check if a type is optional (includes undefined)
84
64
  */
@@ -97,6 +77,10 @@ undefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonU
97
77
  * Pregel options that are propagated to the agent
98
78
  */
99
79
  type CreateAgentPregelOptions = "configurable" | "durability" | "store" | "cache" | "signal" | "recursionLimit" | "maxConcurrency" | "timeout";
80
+ /**
81
+ * Pregel stream options that are propagated to the agent
82
+ */
83
+ type CreateAgentPregelStreamOptions = "encoding" | "streamMode";
100
84
  /**
101
85
  * Decide whether provided configuration requires a context
102
86
  */
@@ -104,20 +88,20 @@ type InvokeConfiguration<ContextSchema extends Record<string, any>> =
104
88
  /**
105
89
  * If the context schema is a default object, `context` can be optional
106
90
  */
107
- ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
91
+ ContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
108
92
  context?: Partial<ContextSchema>;
109
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
93
+ } : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
110
94
  context?: Partial<ContextSchema>;
111
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
95
+ } : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
112
96
  type StreamConfiguration<ContextSchema extends Record<string, any>> =
113
97
  /**
114
98
  * If the context schema is a default object, `context` can be optional
115
99
  */
116
100
  ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
117
101
  context?: Partial<ContextSchema>;
118
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & {
102
+ } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {
119
103
  context?: Partial<ContextSchema>;
120
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & WithMaybeContext<ContextSchema>;
104
+ } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;
121
105
  //#endregion
122
106
  export { AgentBuiltInState, InvokeConfiguration, Runtime$1 as Runtime, StreamConfiguration };
123
107
  //# sourceMappingURL=runtime.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.cts","names":["InteropZodOptional","InteropZodDefault","Runtime","LangGraphRuntime","PregelOptions","BaseMessage","ResponseFormatUndefined","AgentBuiltInState","Record","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","PrivateState","RunLevelPrivateState","ThreadLevelPrivateState","InternalAgentState","StructuredResponseType","IsOptionalType","ExtractNonUndefined","IsAllOptional","CreateAgentPregelOptions","InvokeConfiguration","ContextSchema","Pick","StreamConfiguration"],"sources":["../../src/agents/runtime.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodOptional } from \"@langchain/core/utils/types\";\nimport type { InteropZodDefault } from \"@langchain/core/utils/types\";\nimport type { Runtime as LangGraphRuntime, PregelOptions } from \"@langchain/langgraph\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n /**\n * Array of messages representing the conversation history.\n *\n * This includes all messages exchanged during the agent's execution:\n * - Human messages: Input from the user\n * - AI messages: Responses from the language model\n * - Tool messages: Results from tool executions\n * - System messages: System-level instructions or information\n *\n * Messages are accumulated throughout the agent's lifecycle and can be\n * accessed or modified by middleware hooks during execution.\n */\n messages: BaseMessage[];\n /**\n * Structured response data returned by the agent when a `responseFormat` is configured.\n *\n * This property is only populated when you provide a `responseFormat` schema\n * (as Zod or JSON schema) to the agent configuration. The agent will format\n * its final output to match the specified schema and store it in this property.\n *\n * Note: The type is specified as `Record<string, unknown>` because TypeScript cannot\n * infer the actual response format type in contexts like middleware, where the agent's\n * generic type parameters are not accessible. You may need to cast this to your specific\n * response type when accessing it.\n */\n structuredResponse?: Record<string, unknown>;\n};\n/**\n * Type helper to check if TContext is an optional Zod schema\n */\ntype IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;\ntype IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;\nexport type WithMaybeContext<TContext> = undefined extends TContext ? {\n readonly context?: TContext;\n} : IsOptionalZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : IsDefaultZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : {\n readonly context: TContext;\n};\n/**\n * Runtime information available to middleware (readonly).\n */\nexport type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & WithMaybeContext<TContext> & PrivateState & {\n configurable?: {\n thread_id?: string;\n [key: string]: unknown;\n };\n};\nexport interface RunLevelPrivateState {\n /**\n * The number of times the model has been called at the run level.\n * This includes multiple agent invocations.\n */\n runModelCallCount: number;\n}\nexport interface ThreadLevelPrivateState {\n /**\n * The number of times the model has been called at the thread level.\n * This includes multiple agent invocations within different environments\n * using the same thread.\n */\n threadLevelCallCount: number;\n}\n/**\n * As private state we consider all information we want to track within\n * the lifecycle of the agent, without exposing it to the user. These informations\n * are propagated to the user as _readonly_ runtime properties.\n */\nexport interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {\n}\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n _privateState?: PrivateState;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\n/**\n * Helper type to check if a type is optional (includes undefined)\n */\ntype IsOptionalType<T> = undefined extends T ? true : false;\n/**\n * Extract non-undefined part of a union that includes undefined\n */\ntype ExtractNonUndefined<T> = T extends undefined ? never : T;\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = \n// If T includes undefined, then it's optional (can be omitted entirely)\nundefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;\n/**\n * Pregel options that are propagated to the agent\n */\ntype CreateAgentPregelOptions = \"configurable\" | \"durability\" | \"store\" | \"cache\" | \"signal\" | \"recursionLimit\" | \"maxConcurrency\" | \"timeout\";\n/**\n * Decide whether provided configuration requires a context\n */\nexport type InvokeConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;\nexport type StreamConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | \"streamMode\">> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | \"streamMode\">> & WithMaybeContext<ContextSchema>;\nexport {};\n"],"mappings":";;;;;;;;;AAmC+B,KA1BnBO,iBAAAA,GA0BmB;EAK1BE;;;;AAAqD;AAAA;;;;AACF;AACxD;;EAA4B,QAA+BI,EApB7CR,WAoB6CQ,EAAAA;EAAQ;;;;;;;;AAOrC;AAK9B;;;EAAgF,kBAAzBV,CAAAA,EAnB9BK,MAmB8BL,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;CAAgB;;;;KAdlEM,mBAc0IO,CAAAA,CAAAA,CAAAA,GAdjHN,CAciHM,SAdvGhB,kBAcuGgB,CAAAA,GAAAA,CAAAA,GAAAA,IAAAA,GAAAA,KAAAA;AAAY,KAbtJL,kBAasJ,CAAA,CAAA,CAAA,GAb9HD,CAa8H,SAbpHT,iBAaoH,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAM1IgB,KAlBLL,gBAkByB,CAAA,QAAA,CAAA,GAAA,SAAA,SAlBsBC,QAkBtB,GAAA;EAOpBK,SAAAA,OAAAA,CAAAA,EAxBML,QAwBiB;AAaxC,CAAA,GApCIJ,mBAoCyB,CApCLI,QAoCK,CAAA,SAAA,IAAA,GAAA;EAAA,SAAA,OAAA,CAAA,EAnCNA,QAmCM;CAAA,GAlCzBF,kBAkCkCO,CAlCfL,QAkCeK,CAAAA,SAAAA,IAAAA,GAAAA;EAAuB,SAAED,OAAAA,CAAAA,EAjCxCJ,QAiCwCI;AAAoB,CAAA,GAAA;EAW9EI,SAAAA,OAAAA,EA1CiBR,QA0CH;AAAyB,CAAA;;;;AAIiB,KAzCjDX,SAyCiD,CAAA,WAAA,OAAA,CAAA,GAzCnBa,OAyCmB,CAzCXD,IAyCW,CAzCNX,OAyCM,CAzCWU,QAyCX,CA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AAA,SAAAA;;;;AAC6ES,KAf/EC,mBAe+ED,CAAAA,sBAfrChB,MAeqCgB,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA;;;;AAX3FE,aAYcX,SAZQd,iBAYRc,CAAAA,GAAAA,CAAAA,GAZiCA,OAYjCA,CAZyCY,IAYzCZ,CAZ8CX,aAY9CW,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAZ4ES,wBAY5ET,CAAAA,CAAAA,GAAAA;EAAO,OACJX,CAAAA,EAZHW,OAYGX,CAZKsB,aAYLtB,CAAAA;CAAa,GAX1BmB,aAW2CC,CAX7BE,aAW6BF,CAAAA,SAAAA,IAAAA,GAXCT,OAWDS,CAXSG,IAWTH,CAXcpB,aAWdoB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAX4CA,wBAW5CA,CAAAA,CAAAA,GAAAA;EAAwB,OAA3DG,CAAAA,EAVEZ,OAUFY,CAVUD,aAUVC,CAAAA;CAAI,GATZZ,OASAA,CATQY,IASRZ,CATaX,aASbW,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAT2CS,wBAS3CT,CAAAA,CAAAA,GATwEH,gBASxEG,CATyFW,aASzFX,CAAAA;AAAwGW,KARhGE,mBAQgGF,CAAAA,sBARtDlB,MAQsDkB,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA;;AAAD;;AAJ3GA,sBAAsBzB,yBAAyBc,QAAQY,KAAKvB,8BAA8BoB;YAC5ET,QAAQW;IAClBH,cAAcG,8BAA8BX,QAAQY,KAAKvB,8BAA8BoB;YAC7ET,QAAQW;IAClBX,QAAQY,KAAKvB,8BAA8BoB,4CAA4CZ,iBAAiBc"}
1
+ {"version":3,"file":"runtime.d.cts","names":["InteropZodOptional","InteropZodDefault","Runtime","LangGraphRuntime","PregelOptions","BaseMessage","BaseCallbackConfig","ResponseFormatUndefined","AgentBuiltInState","Record","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","InternalAgentState","StructuredResponseType","IsOptionalType","ExtractNonUndefined","IsAllOptional","CreateAgentPregelOptions","CreateAgentPregelStreamOptions","InvokeConfiguration","ContextSchema","Pick","StreamConfiguration"],"sources":["../../src/agents/runtime.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodOptional } from \"@langchain/core/utils/types\";\nimport type { InteropZodDefault } from \"@langchain/core/utils/types\";\nimport type { Runtime as LangGraphRuntime, PregelOptions } from \"@langchain/langgraph\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseCallbackConfig } from \"@langchain/core/callbacks/manager\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n /**\n * Array of messages representing the conversation history.\n *\n * This includes all messages exchanged during the agent's execution:\n * - Human messages: Input from the user\n * - AI messages: Responses from the language model\n * - Tool messages: Results from tool executions\n * - System messages: System-level instructions or information\n *\n * Messages are accumulated throughout the agent's lifecycle and can be\n * accessed or modified by middleware hooks during execution.\n */\n messages: BaseMessage[];\n /**\n * Structured response data returned by the agent when a `responseFormat` is configured.\n *\n * This property is only populated when you provide a `responseFormat` schema\n * (as Zod or JSON schema) to the agent configuration. The agent will format\n * its final output to match the specified schema and store it in this property.\n *\n * Note: The type is specified as `Record<string, unknown>` because TypeScript cannot\n * infer the actual response format type in contexts like middleware, where the agent's\n * generic type parameters are not accessible. You may need to cast this to your specific\n * response type when accessing it.\n */\n structuredResponse?: Record<string, unknown>;\n};\n/**\n * Type helper to check if TContext is an optional Zod schema\n */\ntype IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;\ntype IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;\nexport type WithMaybeContext<TContext> = undefined extends TContext ? {\n readonly context?: TContext;\n} : IsOptionalZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : IsDefaultZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : {\n readonly context: TContext;\n};\n/**\n * Runtime information available to middleware (readonly).\n */\nexport type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & WithMaybeContext<TContext> & {\n configurable?: {\n thread_id?: string;\n [key: string]: unknown;\n };\n};\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\n/**\n * Helper type to check if a type is optional (includes undefined)\n */\ntype IsOptionalType<T> = undefined extends T ? true : false;\n/**\n * Extract non-undefined part of a union that includes undefined\n */\ntype ExtractNonUndefined<T> = T extends undefined ? never : T;\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = \n// If T includes undefined, then it's optional (can be omitted entirely)\nundefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;\n/**\n * Pregel options that are propagated to the agent\n */\ntype CreateAgentPregelOptions = \"configurable\" | \"durability\" | \"store\" | \"cache\" | \"signal\" | \"recursionLimit\" | \"maxConcurrency\" | \"timeout\";\n/**\n * Pregel stream options that are propagated to the agent\n */\ntype CreateAgentPregelStreamOptions = \"encoding\" | \"streamMode\";\n/**\n * Decide whether provided configuration requires a context\n */\nexport type InvokeConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;\nexport type StreamConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;\nexport {};\n"],"mappings":";;;;;;;;;;AAoC+B,KA1BnBQ,iBAAAA,GA0BmB;EAK1BE;;;;AAAqD;AAAA;;;;AACF;AACxD;;EAA4B,QAA+BI,EApB7CT,WAoB6CS,EAAAA;EAAQ;;;;;;;;AAOrC;AAK9B;;;EAAgF,kBAAzBX,CAAAA,EAnB9BM,MAmB8BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;CAAgB;;;;AAA2D,KAd7HO,mBAc6H,CAAA,CAAA,CAAA,GAdpGC,CAcoG,SAd1FX,kBAc0F,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAU/H,KAvBEY,kBA2Bc,CAAA,CAAA,CAAA,GA3BUD,CA2BV,SA3BoBV,iBA2BK,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAIvCmB,KA9BOP,gBA8BY,CAAA,QAAA,CAAA,GAAA,SAAA,SA9BmCC,QA8BnC,GAAA;EAAA,SAAA,OAAA,CAAA,EA7BDA,QA6BC;CAAA,GA5BpBJ,mBA4B0BC,CA5BNG,QA4BMH,CAAAA,SAAAA,IAAAA,GAAAA;EAAC,SAA6BA,OAAAA,CAAAA,EA3BrCG,QA2BqCH;AAAC,CAAA,GA1BzDC,kBA0ByD,CA1BtCE,QA0BsC,CAAA,SAAA,IA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;EAAa,OAA4CjB,CAAAA,EAD/CY,OAC+CZ,CADvCqB,aACuCrB,CAAAA;CAAa,GAAtEiB,aAAuFC,CAAzEG,aAAyEH,CAAAA,SAAAA,IAAAA,GAA3CN,OAA2CM,CAAnCI,IAAmCJ,CAA9BlB,aAA8BkB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAAAA,wBAAAA,GAA2BC,8BAA3BD,CAAAA,CAAAA,GAAAA;EAAwB,OAAGC,CAAAA,EACxGP,OADwGO,CAChGE,aADgGF,CAAAA;CAA8B,GAEhJP,OAFoDU,CAE5CA,IAF4CA,CAEvCtB,aAFuCsB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAETJ,wBAFSI,GAEkBH,8BAFlBG,CAAAA,CAAAA,GAEqDb,gBAFrDa,CAEsED,aAFtEC,CAAAA"}
@@ -1,6 +1,7 @@
1
1
  import { BaseMessage } from "@langchain/core/messages";
2
2
  import { PregelOptions, Runtime } from "@langchain/langgraph";
3
3
  import { InteropZodDefault, InteropZodOptional } from "@langchain/core/utils/types";
4
+ import { BaseCallbackConfig } from "@langchain/core/callbacks/manager";
4
5
 
5
6
  //#region src/agents/runtime.d.ts
6
7
 
@@ -52,33 +53,12 @@ type WithMaybeContext<TContext> = undefined extends TContext ? {
52
53
  /**
53
54
  * Runtime information available to middleware (readonly).
54
55
  */
55
- type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & PrivateState & {
56
+ type Runtime$1<TContext = unknown> = Partial<Omit<Runtime<TContext>, "context" | "configurable">> & WithMaybeContext<TContext> & {
56
57
  configurable?: {
57
58
  thread_id?: string;
58
59
  [key: string]: unknown;
59
60
  };
60
61
  };
61
- interface RunLevelPrivateState {
62
- /**
63
- * The number of times the model has been called at the run level.
64
- * This includes multiple agent invocations.
65
- */
66
- runModelCallCount: number;
67
- }
68
- interface ThreadLevelPrivateState {
69
- /**
70
- * The number of times the model has been called at the thread level.
71
- * This includes multiple agent invocations within different environments
72
- * using the same thread.
73
- */
74
- threadLevelCallCount: number;
75
- }
76
- /**
77
- * As private state we consider all information we want to track within
78
- * the lifecycle of the agent, without exposing it to the user. These informations
79
- * are propagated to the user as _readonly_ runtime properties.
80
- */
81
- interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {}
82
62
  /**
83
63
  * Helper type to check if a type is optional (includes undefined)
84
64
  */
@@ -97,6 +77,10 @@ undefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonU
97
77
  * Pregel options that are propagated to the agent
98
78
  */
99
79
  type CreateAgentPregelOptions = "configurable" | "durability" | "store" | "cache" | "signal" | "recursionLimit" | "maxConcurrency" | "timeout";
80
+ /**
81
+ * Pregel stream options that are propagated to the agent
82
+ */
83
+ type CreateAgentPregelStreamOptions = "encoding" | "streamMode";
100
84
  /**
101
85
  * Decide whether provided configuration requires a context
102
86
  */
@@ -104,20 +88,20 @@ type InvokeConfiguration<ContextSchema extends Record<string, any>> =
104
88
  /**
105
89
  * If the context schema is a default object, `context` can be optional
106
90
  */
107
- ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
91
+ ContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
108
92
  context?: Partial<ContextSchema>;
109
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
93
+ } : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
110
94
  context?: Partial<ContextSchema>;
111
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
95
+ } : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;
112
96
  type StreamConfiguration<ContextSchema extends Record<string, any>> =
113
97
  /**
114
98
  * If the context schema is a default object, `context` can be optional
115
99
  */
116
100
  ContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {
117
101
  context?: Partial<ContextSchema>;
118
- } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & {
102
+ } : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {
119
103
  context?: Partial<ContextSchema>;
120
- } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | "streamMode">> & WithMaybeContext<ContextSchema>;
104
+ } : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;
121
105
  //#endregion
122
106
  export { AgentBuiltInState, InvokeConfiguration, Runtime$1 as Runtime, StreamConfiguration };
123
107
  //# sourceMappingURL=runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","names":["InteropZodOptional","InteropZodDefault","Runtime","LangGraphRuntime","PregelOptions","BaseMessage","ResponseFormatUndefined","AgentBuiltInState","Record","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","PrivateState","RunLevelPrivateState","ThreadLevelPrivateState","InternalAgentState","StructuredResponseType","IsOptionalType","ExtractNonUndefined","IsAllOptional","CreateAgentPregelOptions","InvokeConfiguration","ContextSchema","Pick","StreamConfiguration"],"sources":["../../src/agents/runtime.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodOptional } from \"@langchain/core/utils/types\";\nimport type { InteropZodDefault } from \"@langchain/core/utils/types\";\nimport type { Runtime as LangGraphRuntime, PregelOptions } from \"@langchain/langgraph\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n /**\n * Array of messages representing the conversation history.\n *\n * This includes all messages exchanged during the agent's execution:\n * - Human messages: Input from the user\n * - AI messages: Responses from the language model\n * - Tool messages: Results from tool executions\n * - System messages: System-level instructions or information\n *\n * Messages are accumulated throughout the agent's lifecycle and can be\n * accessed or modified by middleware hooks during execution.\n */\n messages: BaseMessage[];\n /**\n * Structured response data returned by the agent when a `responseFormat` is configured.\n *\n * This property is only populated when you provide a `responseFormat` schema\n * (as Zod or JSON schema) to the agent configuration. The agent will format\n * its final output to match the specified schema and store it in this property.\n *\n * Note: The type is specified as `Record<string, unknown>` because TypeScript cannot\n * infer the actual response format type in contexts like middleware, where the agent's\n * generic type parameters are not accessible. You may need to cast this to your specific\n * response type when accessing it.\n */\n structuredResponse?: Record<string, unknown>;\n};\n/**\n * Type helper to check if TContext is an optional Zod schema\n */\ntype IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;\ntype IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;\nexport type WithMaybeContext<TContext> = undefined extends TContext ? {\n readonly context?: TContext;\n} : IsOptionalZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : IsDefaultZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : {\n readonly context: TContext;\n};\n/**\n * Runtime information available to middleware (readonly).\n */\nexport type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & WithMaybeContext<TContext> & PrivateState & {\n configurable?: {\n thread_id?: string;\n [key: string]: unknown;\n };\n};\nexport interface RunLevelPrivateState {\n /**\n * The number of times the model has been called at the run level.\n * This includes multiple agent invocations.\n */\n runModelCallCount: number;\n}\nexport interface ThreadLevelPrivateState {\n /**\n * The number of times the model has been called at the thread level.\n * This includes multiple agent invocations within different environments\n * using the same thread.\n */\n threadLevelCallCount: number;\n}\n/**\n * As private state we consider all information we want to track within\n * the lifecycle of the agent, without exposing it to the user. These informations\n * are propagated to the user as _readonly_ runtime properties.\n */\nexport interface PrivateState extends ThreadLevelPrivateState, RunLevelPrivateState {\n}\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n _privateState?: PrivateState;\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\n/**\n * Helper type to check if a type is optional (includes undefined)\n */\ntype IsOptionalType<T> = undefined extends T ? true : false;\n/**\n * Extract non-undefined part of a union that includes undefined\n */\ntype ExtractNonUndefined<T> = T extends undefined ? never : T;\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = \n// If T includes undefined, then it's optional (can be omitted entirely)\nundefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;\n/**\n * Pregel options that are propagated to the agent\n */\ntype CreateAgentPregelOptions = \"configurable\" | \"durability\" | \"store\" | \"cache\" | \"signal\" | \"recursionLimit\" | \"maxConcurrency\" | \"timeout\";\n/**\n * Decide whether provided configuration requires a context\n */\nexport type InvokeConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;\nexport type StreamConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | \"streamMode\">> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | \"streamMode\">> & WithMaybeContext<ContextSchema>;\nexport {};\n"],"mappings":";;;;;;;;;AAmC+B,KA1BnBO,iBAAAA,GA0BmB;EAK1BE;;;;AAAqD;AAAA;;;;AACF;AACxD;;EAA4B,QAA+BI,EApB7CR,WAoB6CQ,EAAAA;EAAQ;;;;;;;;AAOrC;AAK9B;;;EAAgF,kBAAzBV,CAAAA,EAnB9BK,MAmB8BL,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;CAAgB;;;;KAdlEM,mBAc0IO,CAAAA,CAAAA,CAAAA,GAdjHN,CAciHM,SAdvGhB,kBAcuGgB,CAAAA,GAAAA,CAAAA,GAAAA,IAAAA,GAAAA,KAAAA;AAAY,KAbtJL,kBAasJ,CAAA,CAAA,CAAA,GAb9HD,CAa8H,SAbpHT,iBAaoH,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAM1IgB,KAlBLL,gBAkByB,CAAA,QAAA,CAAA,GAAA,SAAA,SAlBsBC,QAkBtB,GAAA;EAOpBK,SAAAA,OAAAA,CAAAA,EAxBML,QAwBiB;AAaxC,CAAA,GApCIJ,mBAoCyB,CApCLI,QAoCK,CAAA,SAAA,IAAA,GAAA;EAAA,SAAA,OAAA,CAAA,EAnCNA,QAmCM;CAAA,GAlCzBF,kBAkCkCO,CAlCfL,QAkCeK,CAAAA,SAAAA,IAAAA,GAAAA;EAAuB,SAAED,OAAAA,CAAAA,EAjCxCJ,QAiCwCI;AAAoB,CAAA,GAAA;EAW9EI,SAAAA,OAAAA,EA1CiBR,QA0CH;AAAyB,CAAA;;;;AAIiB,KAzCjDX,SAyCiD,CAAA,WAAA,OAAA,CAAA,GAzCnBa,OAyCmB,CAzCXD,IAyCW,CAzCNX,OAyC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A,GAAAA,gBAAAA,GAAAA,SAAAA;;;;AAC6ES,KAf/EC,mBAe+ED,CAAAA,sBAfrChB,MAeqCgB,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA;;;;AAX3FE,aAYcX,SAZQd,iBAYRc,CAAAA,GAAAA,CAAAA,GAZiCA,OAYjCA,CAZyCY,IAYzCZ,CAZ8CX,aAY9CW,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAZ4ES,wBAY5ET,CAAAA,CAAAA,GAAAA;EAAO,OACJX,CAAAA,EAZHW,OAYGX,CAZKsB,aAYLtB,CAAAA;CAAa,GAX1BmB,aAW2CC,CAX7BE,aAW6BF,CAAAA,SAAAA,IAAAA,GAXCT,OAWDS,CAXSG,IAWTH,CAXcpB,aAWdoB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAX4CA,wBAW5CA,CAAAA,CAAAA,GAAAA;EAAwB,OAA3DG,CAAAA,EAVEZ,OAUFY,CAVUD,aAUVC,CAAAA;CAAI,GATZZ,OASAA,CATQY,IASRZ,CATaX,aASbW,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAT2CS,wBAS3CT,CAAAA,CAAAA,GATwEH,gBASxEG,CATyFW,aASzFX,CAAAA;AAAwGW,KARhGE,mBAQgGF,CAAAA,sBARtDlB,MAQsDkB,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA,CAAAA;;AAAD;;AAJ3GA,sBAAsBzB,yBAAyBc,QAAQY,KAAKvB,8BAA8BoB;YAC5ET,QAAQW;IAClBH,cAAcG,8BAA8BX,QAAQY,KAAKvB,8BAA8BoB;YAC7ET,QAAQW;IAClBX,QAAQY,KAAKvB,8BAA8BoB,4CAA4CZ,iBAAiBc"}
1
+ {"version":3,"file":"runtime.d.ts","names":["InteropZodOptional","InteropZodDefault","Runtime","LangGraphRuntime","PregelOptions","BaseMessage","BaseCallbackConfig","ResponseFormatUndefined","AgentBuiltInState","Record","IsOptionalZodObject","T","IsDefaultZodObject","WithMaybeContext","TContext","Omit","Partial","InternalAgentState","StructuredResponseType","IsOptionalType","ExtractNonUndefined","IsAllOptional","CreateAgentPregelOptions","CreateAgentPregelStreamOptions","InvokeConfiguration","ContextSchema","Pick","StreamConfiguration"],"sources":["../../src/agents/runtime.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodOptional } from \"@langchain/core/utils/types\";\nimport type { InteropZodDefault } from \"@langchain/core/utils/types\";\nimport type { Runtime as LangGraphRuntime, PregelOptions } from \"@langchain/langgraph\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseCallbackConfig } from \"@langchain/core/callbacks/manager\";\nimport type { ResponseFormatUndefined } from \"./responses.js\";\n/**\n * Type for the agent's built-in state properties.\n */\nexport type AgentBuiltInState = {\n /**\n * Array of messages representing the conversation history.\n *\n * This includes all messages exchanged during the agent's execution:\n * - Human messages: Input from the user\n * - AI messages: Responses from the language model\n * - Tool messages: Results from tool executions\n * - System messages: System-level instructions or information\n *\n * Messages are accumulated throughout the agent's lifecycle and can be\n * accessed or modified by middleware hooks during execution.\n */\n messages: BaseMessage[];\n /**\n * Structured response data returned by the agent when a `responseFormat` is configured.\n *\n * This property is only populated when you provide a `responseFormat` schema\n * (as Zod or JSON schema) to the agent configuration. The agent will format\n * its final output to match the specified schema and store it in this property.\n *\n * Note: The type is specified as `Record<string, unknown>` because TypeScript cannot\n * infer the actual response format type in contexts like middleware, where the agent's\n * generic type parameters are not accessible. You may need to cast this to your specific\n * response type when accessing it.\n */\n structuredResponse?: Record<string, unknown>;\n};\n/**\n * Type helper to check if TContext is an optional Zod schema\n */\ntype IsOptionalZodObject<T> = T extends InteropZodOptional<any> ? true : false;\ntype IsDefaultZodObject<T> = T extends InteropZodDefault<any> ? true : false;\nexport type WithMaybeContext<TContext> = undefined extends TContext ? {\n readonly context?: TContext;\n} : IsOptionalZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : IsDefaultZodObject<TContext> extends true ? {\n readonly context?: TContext;\n} : {\n readonly context: TContext;\n};\n/**\n * Runtime information available to middleware (readonly).\n */\nexport type Runtime<TContext = unknown> = Partial<Omit<LangGraphRuntime<TContext>, \"context\" | \"configurable\">> & WithMaybeContext<TContext> & {\n configurable?: {\n thread_id?: string;\n [key: string]: unknown;\n };\n};\nexport type InternalAgentState<StructuredResponseType extends Record<string, unknown> | undefined = Record<string, unknown>> = {\n messages: BaseMessage[];\n} & (StructuredResponseType extends ResponseFormatUndefined ? Record<string, never> : {\n structuredResponse: StructuredResponseType;\n});\n/**\n * Helper type to check if a type is optional (includes undefined)\n */\ntype IsOptionalType<T> = undefined extends T ? true : false;\n/**\n * Extract non-undefined part of a union that includes undefined\n */\ntype ExtractNonUndefined<T> = T extends undefined ? never : T;\n/**\n * Helper type to check if all properties of a type are optional\n */\nexport type IsAllOptional<T> = \n// If T includes undefined, then it's optional (can be omitted entirely)\nundefined extends T ? true : IsOptionalType<T> extends true ? true : ExtractNonUndefined<T> extends Record<string, any> ? {} extends ExtractNonUndefined<T> ? true : false : IsOptionalType<T>;\n/**\n * Pregel options that are propagated to the agent\n */\ntype CreateAgentPregelOptions = \"configurable\" | \"durability\" | \"store\" | \"cache\" | \"signal\" | \"recursionLimit\" | \"maxConcurrency\" | \"timeout\";\n/**\n * Pregel stream options that are propagated to the agent\n */\ntype CreateAgentPregelStreamOptions = \"encoding\" | \"streamMode\";\n/**\n * Decide whether provided configuration requires a context\n */\nexport type InvokeConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : BaseCallbackConfig & Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & WithMaybeContext<ContextSchema>;\nexport type StreamConfiguration<ContextSchema extends Record<string, any>> = \n/**\n * If the context schema is a default object, `context` can be optional\n */\nContextSchema extends InteropZodDefault<any> ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions>> & {\n context?: Partial<ContextSchema>;\n} : IsAllOptional<ContextSchema> extends true ? Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & {\n context?: Partial<ContextSchema>;\n} : Partial<Pick<PregelOptions<any, any, any>, CreateAgentPregelOptions | CreateAgentPregelStreamOptions>> & WithMaybeContext<ContextSchema>;\nexport {};\n"],"mappings":";;;;;;;;;;AAoC+B,KA1BnBQ,iBAAAA,GA0BmB;EAK1BE;;;;AAAqD;AAAA;;;;AACF;AACxD;;EAA4B,QAA+BI,EApB7CT,WAoB6CS,EAAAA;EAAQ;;;;;;;;AAOrC;AAK9B;;;EAAgF,kBAAzBX,CAAAA,EAnB9BM,MAmB8BN,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;CAAgB;;;;AAA2D,KAd7HO,mBAc6H,CAAA,CAAA,CAAA,GAdpGC,CAcoG,SAd1FX,kBAc0F,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAU/H,KAvBEY,kBA2Bc,CAAA,CAAA,CAAA,GA3BUD,CA2BV,SA3BoBV,iBA2BK,CAAA,GAAA,CAAA,GAAA,IAAA,GAAA,KAAA;AAIvCmB,KA9BOP,gBA8BY,CAAA,QAAA,CAAA,GAAA,SAAA,SA9BmCC,QA8BnC,GAAA;EAAA,SAAA,OAAA,CAAA,EA7BDA,QA6BC;CAAA,GA5BpBJ,mBA4B0BC,CA5BNG,QA4BMH,CAAAA,SAAAA,IAAAA,GAAAA;EAAC,SAA6BA,OAAAA,CAAAA,EA3BrCG,QA2BqCH;AAAC,CAAA,GA1BzDC,kBA0ByD,CA1BtCE,QA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CAAAA,CAAAA,GAAAA;EAAa,OAA4CjB,CAAAA,EAD/CY,OAC+CZ,CADvCqB,aACuCrB,CAAAA;CAAa,GAAtEiB,aAAuFC,CAAzEG,aAAyEH,CAAAA,SAAAA,IAAAA,GAA3CN,OAA2CM,CAAnCI,IAAmCJ,CAA9BlB,aAA8BkB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAAAA,wBAAAA,GAA2BC,8BAA3BD,CAAAA,CAAAA,GAAAA;EAAwB,OAAGC,CAAAA,EACxGP,OADwGO,CAChGE,aADgGF,CAAAA;CAA8B,GAEhJP,OAFoDU,CAE5CA,IAF4CA,CAEvCtB,aAFuCsB,CAAAA,GAAAA,EAAAA,GAAAA,EAAAA,GAAAA,CAAAA,EAETJ,wBAFSI,GAEkBH,8BAFlBG,CAAAA,CAAAA,GAEqDb,gBAFrDa,CAEsED,aAFtEC,CAAAA"}
@@ -0,0 +1,45 @@
1
+
2
+ //#region src/agents/state.ts
3
+ /**
4
+ * The StateManager is responsible for managing the state of the agent.
5
+ * The `createAgent` maintains different nodes with their own state. For the user
6
+ * however, they only see the combined state of all nodes. This class is helps
7
+ * to share the state between different nodes.
8
+ *
9
+ * @internal
10
+ */
11
+ var StateManager = class {
12
+ #nodes = /* @__PURE__ */ new Map();
13
+ /**
14
+ * Add node to middleware group.
15
+ * @param name - The name of the middleware group.
16
+ * @param node - The node to add.
17
+ */
18
+ addNode(middleware, node) {
19
+ this.#nodes.set(middleware.name, [...this.#nodes.get(middleware.name) ?? [], node]);
20
+ }
21
+ /**
22
+ * Get the state of a middleware group.
23
+ * @param name - The name of the middleware group.
24
+ * @returns The state of the middleware group.
25
+ */
26
+ getState(name) {
27
+ const middlewareNodes = this.#nodes.get(name) ?? [];
28
+ const state = middlewareNodes.reduce((prev, node) => {
29
+ return {
30
+ ...prev,
31
+ ...node.getState() ?? {}
32
+ };
33
+ }, {});
34
+ /**
35
+ * we internally reset the jumpTo property and shouldn't propagate this value
36
+ * to the middleware hooks.
37
+ */
38
+ delete state.jumpTo;
39
+ return state;
40
+ }
41
+ };
42
+
43
+ //#endregion
44
+ exports.StateManager = StateManager;
45
+ //# sourceMappingURL=state.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.cjs","names":["middleware: AgentMiddleware<InteropZodObject | undefined>","node: AgentNode","#nodes","name: string"],"sources":["../../src/agents/state.ts"],"sourcesContent":["import type { InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { RunnableCallable } from \"./RunnableCallable.js\";\nimport type { AgentMiddleware } from \"./middleware/types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AgentNode = RunnableCallable<any, any>;\n\n/**\n * The StateManager is responsible for managing the state of the agent.\n * The `createAgent` maintains different nodes with their own state. For the user\n * however, they only see the combined state of all nodes. This class is helps\n * to share the state between different nodes.\n *\n * @internal\n */\nexport class StateManager {\n #nodes = new Map<string, AgentNode[]>();\n\n /**\n * Add node to middleware group.\n * @param name - The name of the middleware group.\n * @param node - The node to add.\n */\n addNode(\n middleware: AgentMiddleware<InteropZodObject | undefined>,\n node: AgentNode\n ) {\n this.#nodes.set(middleware.name, [\n ...(this.#nodes.get(middleware.name) ?? []),\n node,\n ]);\n }\n\n /**\n * Get the state of a middleware group.\n * @param name - The name of the middleware group.\n * @returns The state of the middleware group.\n */\n getState(name: string) {\n const middlewareNodes = this.#nodes.get(name) ?? [];\n const state = middlewareNodes.reduce((prev, node) => {\n return {\n ...prev,\n ...((node.getState() as Record<string, unknown>) ?? {}),\n };\n }, {} as Record<string, unknown>);\n\n /**\n * we internally reset the jumpTo property and shouldn't propagate this value\n * to the middleware hooks.\n */\n delete state.jumpTo;\n\n return state;\n }\n}\n"],"mappings":";;;;;;;;;;AAeA,IAAa,eAAb,MAA0B;CACxB,yBAAS,IAAI;;;;;;CAOb,QACEA,YACAC,MACA;EACA,KAAKC,OAAO,IAAI,WAAW,MAAM,CAC/B,GAAI,KAAKA,OAAO,IAAI,WAAW,KAAK,IAAI,CAAE,GAC1C,IACD,EAAC;CACH;;;;;;CAOD,SAASC,MAAc;EACrB,MAAM,kBAAkB,KAAKD,OAAO,IAAI,KAAK,IAAI,CAAE;EACnD,MAAM,QAAQ,gBAAgB,OAAO,CAAC,MAAM,SAAS;AACnD,UAAO;IACL,GAAG;IACH,GAAK,KAAK,UAAU,IAAgC,CAAE;GACvD;EACF,GAAE,CAAE,EAA4B;;;;;EAMjC,OAAO,MAAM;AAEb,SAAO;CACR;AACF"}
@@ -0,0 +1,44 @@
1
+ //#region src/agents/state.ts
2
+ /**
3
+ * The StateManager is responsible for managing the state of the agent.
4
+ * The `createAgent` maintains different nodes with their own state. For the user
5
+ * however, they only see the combined state of all nodes. This class is helps
6
+ * to share the state between different nodes.
7
+ *
8
+ * @internal
9
+ */
10
+ var StateManager = class {
11
+ #nodes = /* @__PURE__ */ new Map();
12
+ /**
13
+ * Add node to middleware group.
14
+ * @param name - The name of the middleware group.
15
+ * @param node - The node to add.
16
+ */
17
+ addNode(middleware, node) {
18
+ this.#nodes.set(middleware.name, [...this.#nodes.get(middleware.name) ?? [], node]);
19
+ }
20
+ /**
21
+ * Get the state of a middleware group.
22
+ * @param name - The name of the middleware group.
23
+ * @returns The state of the middleware group.
24
+ */
25
+ getState(name) {
26
+ const middlewareNodes = this.#nodes.get(name) ?? [];
27
+ const state = middlewareNodes.reduce((prev, node) => {
28
+ return {
29
+ ...prev,
30
+ ...node.getState() ?? {}
31
+ };
32
+ }, {});
33
+ /**
34
+ * we internally reset the jumpTo property and shouldn't propagate this value
35
+ * to the middleware hooks.
36
+ */
37
+ delete state.jumpTo;
38
+ return state;
39
+ }
40
+ };
41
+
42
+ //#endregion
43
+ export { StateManager };
44
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","names":["middleware: AgentMiddleware<InteropZodObject | undefined>","node: AgentNode","#nodes","name: string"],"sources":["../../src/agents/state.ts"],"sourcesContent":["import type { InteropZodObject } from \"@langchain/core/utils/types\";\nimport type { RunnableCallable } from \"./RunnableCallable.js\";\nimport type { AgentMiddleware } from \"./middleware/types.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AgentNode = RunnableCallable<any, any>;\n\n/**\n * The StateManager is responsible for managing the state of the agent.\n * The `createAgent` maintains different nodes with their own state. For the user\n * however, they only see the combined state of all nodes. This class is helps\n * to share the state between different nodes.\n *\n * @internal\n */\nexport class StateManager {\n #nodes = new Map<string, AgentNode[]>();\n\n /**\n * Add node to middleware group.\n * @param name - The name of the middleware group.\n * @param node - The node to add.\n */\n addNode(\n middleware: AgentMiddleware<InteropZodObject | undefined>,\n node: AgentNode\n ) {\n this.#nodes.set(middleware.name, [\n ...(this.#nodes.get(middleware.name) ?? []),\n node,\n ]);\n }\n\n /**\n * Get the state of a middleware group.\n * @param name - The name of the middleware group.\n * @returns The state of the middleware group.\n */\n getState(name: string) {\n const middlewareNodes = this.#nodes.get(name) ?? [];\n const state = middlewareNodes.reduce((prev, node) => {\n return {\n ...prev,\n ...((node.getState() as Record<string, unknown>) ?? {}),\n };\n }, {} as Record<string, unknown>);\n\n /**\n * we internally reset the jumpTo property and shouldn't propagate this value\n * to the middleware hooks.\n */\n delete state.jumpTo;\n\n return state;\n }\n}\n"],"mappings":";;;;;;;;;AAeA,IAAa,eAAb,MAA0B;CACxB,yBAAS,IAAI;;;;;;CAOb,QACEA,YACAC,MACA;EACA,KAAKC,OAAO,IAAI,WAAW,MAAM,CAC/B,GAAI,KAAKA,OAAO,IAAI,WAAW,KAAK,IAAI,CAAE,GAC1C,IACD,EAAC;CACH;;;;;;CAOD,SAASC,MAAc;EACrB,MAAM,kBAAkB,KAAKD,OAAO,IAAI,KAAK,IAAI,CAAE;EACnD,MAAM,QAAQ,gBAAgB,OAAO,CAAC,MAAM,SAAS;AACnD,UAAO;IACL,GAAG;IACH,GAAK,KAAK,UAAU,IAAgC,CAAE;GACvD;EACF,GAAE,CAAE,EAA4B;;;;;EAMjC,OAAO,MAAM;AAEb,SAAO;CACR;AACF"}
@@ -1,9 +1,9 @@
1
1
  import { JsonSchemaFormat, ProviderStrategy, ResponseFormat, ResponseFormatUndefined, ToolStrategy, TypedToolStrategy } from "./responses.cjs";
2
2
  import { JumpToTarget } from "./constants.cjs";
3
- import { ClientTool, ServerTool } from "./tools.cjs";
4
3
  import { AgentMiddleware, AnyAnnotationRoot, InferSchemaInput } from "./middleware/types.cjs";
5
4
  import { LanguageModelLike } from "@langchain/core/language_models/base";
6
5
  import { BaseMessage } from "@langchain/core/messages";
6
+ import { ClientTool, ServerTool } from "@langchain/core/tools";
7
7
  import { InteropZodObject, InteropZodType } from "@langchain/core/utils/types";
8
8
  import { END, START, StateGraph } from "@langchain/langgraph";
9
9
  import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":["InteropZodObject","InteropZodType","START","END","StateGraph","LanguageModelLike","BaseMessage","BaseCheckpointSaver","BaseStore","Messages","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","JsonSchemaFormat","ResponseFormatUndefined","AgentMiddleware","AnyAnnotationRoot","InferSchemaInput","ServerTool","ClientTool","JumpToTarget","N","Interrupt","TValue","BuiltInState","UserInput","TStateSchema","ToolCall","Record","ToolResult","JumpTo","ExecutedToolCall","CreateAgentParams","StructuredResponseType","StateSchema","ContextSchema","ResponseFormatType","AbortSignal","ExtractZodArrayTypes","T","Rest","A","WithStateGraphNodes","Graph","SD","S","U","K","I","O","C"],"sources":["../../src/agents/types.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport type { START, END, StateGraph } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Messages } from \"@langchain/langgraph/\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, JsonSchemaFormat, ResponseFormatUndefined } from \"./responses.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot, InferSchemaInput } from \"./middleware/types.js\";\nimport type { ServerTool, ClientTool } from \"./tools.js\";\nimport type { JumpToTarget } from \"./constants.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\n/**\n * Represents information about an interrupt.\n */\nexport interface Interrupt<TValue = unknown> {\n /**\n * The ID of the interrupt.\n */\n id: string;\n /**\n * The requests for human input.\n */\n value: TValue;\n}\nexport interface BuiltInState {\n messages: BaseMessage[];\n __interrupt__?: Interrupt[];\n /**\n * Optional property to control routing after afterModel middleware execution.\n * When set by middleware, the agent will jump to the specified node instead of\n * following normal routing logic. The property is automatically cleared after use.\n *\n * - \"model_request\": Jump back to the model for another LLM call\n * - \"tools\": Jump to tool execution (requires tools to be available)\n */\n jumpTo?: JumpToTarget;\n}\n/**\n * Base input type for `.invoke` and `.stream` methods.\n */\nexport type UserInput<TStateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined> = InferSchemaInput<TStateSchema> & {\n messages: Messages;\n};\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n /**\n * The result of the tool call.\n */\n result?: unknown;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * jump targets (internal)\n */\nexport type JumpTo = \"model_request\" | \"tools\" | typeof END;\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, StateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /**\n * Defines a model to use for the agent. You can either pass in an instance of a LangChain chat model\n * or a string. If a string is provided the agent initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * const agent = createAgent({\n * model: new ChatOpenAI({ model: \"gpt-4o\" }),\n * // ...\n * });\n * ```\n */\n model: string | LanguageModelLike;\n /**\n * A list of tools or a ToolNode.\n *\n * @example\n * ```ts\n * import { tool } from \"langchain\";\n *\n * const weatherTool = tool(() => \"Sunny!\", {\n * name: \"get_weather\",\n * description: \"Get the weather for a location\",\n * schema: z.object({\n * location: z.string().describe(\"The location to get weather for\"),\n * }),\n * });\n *\n * const agent = createAgent({\n * tools: [weatherTool],\n * // ...\n * });\n * ```\n */\n tools?: (ServerTool | ClientTool)[];\n /**\n * An optional system message for the model.\n */\n systemPrompt?: string;\n /**\n * An optional schema for the agent state. It allows you to define custom state properties that persist\n * across agent invocations and can be accessed in hooks, middleware, and throughout the agent's execution.\n * The state is persisted when using a checkpointer and can be updated by middleware or during execution.\n *\n * As opposed to the context (defined in `contextSchema`), the state is persisted between agent invocations\n * when using a checkpointer, making it suitable for maintaining conversation history, user preferences,\n * or any other data that should persist across multiple interactions.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { createAgent } from \"@langchain/langgraph\";\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getWeather],\n * stateSchema: z.object({\n * userPreferences: z.object({\n * temperatureUnit: z.enum([\"celsius\", \"fahrenheit\"]).default(\"celsius\"),\n * location: z.string().optional(),\n * }).optional(),\n * conversationCount: z.number().default(0),\n * }),\n * prompt: (state, config) => {\n * const unit = state.userPreferences?.temperatureUnit || \"celsius\";\n * return [\n * new SystemMessage(`You are a helpful assistant. Use ${unit} for temperature.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new HumanMessage(\"What's the weather like?\"),\n * ],\n * userPreferences: {\n * temperatureUnit: \"fahrenheit\",\n * location: \"New York\",\n * },\n * conversationCount: 1,\n * });\n * ```\n */\n stateSchema?: StateSchema;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /**\n * An optional checkpoint saver to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/persistence | Checkpointing}\n */\n checkpointer?: BaseCheckpointSaver | boolean;\n /**\n * An optional store to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/memory#memory-storage | Long-term memory}\n */\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n *\n * @see {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Type helper to extract union type from an array of Zod schemas\n */\nexport type ExtractZodArrayTypes<T extends readonly InteropZodType<any>[]> = T extends readonly [InteropZodType<infer A>, ...infer Rest] ? Rest extends readonly InteropZodType<any>[] ? A | ExtractZodArrayTypes<Rest> : A : never;\nexport type WithStateGraphNodes<K extends string, Graph> = Graph extends StateGraph<infer SD, infer S, infer U, infer N, infer I, infer O, infer C> ? StateGraph<SD, S, U, N | K, I, O, C> : never;\n"],"mappings":";;;;;;;;;;;;KAWYsB,CAAAA,UAAWpB;AAAvB;AAIA;AAUA;AAA6B,UAVZqB,SAUY,CAAA,SAAA,OAAA,CAAA,CAAA;EAAA;;;EAWJ,EAAA,EAAA,MAAA;EAKbG;;;EAAgD,KAAG1B,EAlBpDwB,MAkBoDxB;;AAA4CkB,UAhB1FO,YAAAA,CAgB0FP;EAAgB,QAC7GT,EAhBAH,WAgBAG,EAAAA;EAAQ,aAAA,CAAA,EAfFc,SAeE,EAAA;EAKLK;AAyBjB;AAiBA;AAIA;AAkBA;;;;EAAyF,MAAmCX,CAAAA,EA3E/GI,YA2E+GJ;;;;;AAAkLiB,KAtElSR,SAsEkSQ,CAAAA,qBAtEnQjB,iBAsEmQiB,GAtE/OlC,gBAsE+OkC,GAAAA,SAAAA,GAAAA,SAAAA,CAAAA,GAtEnMhB,gBAsEmMgB,CAtElLP,YAsEkLO,CAAAA,GAAAA;EAAsB,QAArCjC,EArEjRQ,QAqEiRR;CAAc;;;;AAAkIiC,UAhE9ZN,UAAAA,CAgE8Z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qBAAqBE,QAAQC;KAC9MC,+CAA+CC,cAAcxC,6EAA6EA,WAAWyC,IAAIC,GAAGC,GAAGzB,IAAI0B,GAAGC,GAAGC,GAAGC"}
1
+ {"version":3,"file":"types.d.cts","names":["InteropZodObject","InteropZodType","START","END","StateGraph","LanguageModelLike","BaseMessage","BaseCheckpointSaver","BaseStore","Messages","ClientTool","ServerTool","ResponseFormat","ToolStrategy","TypedToolStrategy","ProviderStrategy","JsonSchemaFormat","ResponseFormatUndefined","AgentMiddleware","AnyAnnotationRoot","InferSchemaInput","JumpToTarget","N","Interrupt","TValue","BuiltInState","UserInput","TStateSchema","ToolCall","Record","ToolResult","JumpTo","ExecutedToolCall","CreateAgentParams","StructuredResponseType","StateSchema","ContextSchema","ResponseFormatType","AbortSignal","ExtractZodArrayTypes","T","Rest","A","WithStateGraphNodes","Graph","SD","S","U","K","I","O","C"],"sources":["../../src/agents/types.d.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { InteropZodObject, InteropZodType } from \"@langchain/core/utils/types\";\nimport type { START, END, StateGraph } from \"@langchain/langgraph\";\nimport type { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport type { BaseMessage } from \"@langchain/core/messages\";\nimport type { BaseCheckpointSaver, BaseStore } from \"@langchain/langgraph-checkpoint\";\nimport type { Messages } from \"@langchain/langgraph/\";\nimport type { ClientTool, ServerTool } from \"@langchain/core/tools\";\nimport type { ResponseFormat, ToolStrategy, TypedToolStrategy, ProviderStrategy, JsonSchemaFormat, ResponseFormatUndefined } from \"./responses.js\";\nimport type { AgentMiddleware, AnyAnnotationRoot, InferSchemaInput } from \"./middleware/types.js\";\nimport type { JumpToTarget } from \"./constants.js\";\nexport type N = typeof START | \"model_request\" | \"tools\";\n/**\n * Represents information about an interrupt.\n */\nexport interface Interrupt<TValue = unknown> {\n /**\n * The ID of the interrupt.\n */\n id: string;\n /**\n * The requests for human input.\n */\n value: TValue;\n}\nexport interface BuiltInState {\n messages: BaseMessage[];\n __interrupt__?: Interrupt[];\n /**\n * Optional property to control routing after afterModel middleware execution.\n * When set by middleware, the agent will jump to the specified node instead of\n * following normal routing logic. The property is automatically cleared after use.\n *\n * - \"model_request\": Jump back to the model for another LLM call\n * - \"tools\": Jump to tool execution (requires tools to be available)\n */\n jumpTo?: JumpToTarget;\n}\n/**\n * Base input type for `.invoke` and `.stream` methods.\n */\nexport type UserInput<TStateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined> = InferSchemaInput<TStateSchema> & {\n messages: Messages;\n};\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ToolCall {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, any>;\n /**\n * The result of the tool call.\n */\n result?: unknown;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * Information about a tool result from a tool execution.\n */\nexport interface ToolResult {\n /**\n * The ID of the tool call.\n */\n id: string;\n /**\n * The result of the tool call.\n */\n result: any;\n /**\n * An optional error message if the tool call failed.\n */\n error?: string;\n}\n/**\n * jump targets (internal)\n */\nexport type JumpTo = \"model_request\" | \"tools\" | typeof END;\n/**\n * Information about a tool call that has been executed.\n */\nexport interface ExecutedToolCall {\n /**\n * The name of the tool that was called.\n */\n name: string;\n /**\n * The arguments that were passed to the tool.\n */\n args: Record<string, unknown>;\n /**\n * The ID of the tool call.\n */\n tool_id: string;\n /**\n * The result of the tool call (if available).\n */\n result?: unknown;\n}\nexport type CreateAgentParams<StructuredResponseType extends Record<string, any> = Record<string, any>, StateSchema extends AnyAnnotationRoot | InteropZodObject | undefined = undefined, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot, ResponseFormatType = InteropZodType<StructuredResponseType> | InteropZodType<unknown>[] | JsonSchemaFormat | JsonSchemaFormat[] | ResponseFormat | TypedToolStrategy<StructuredResponseType> | ToolStrategy<StructuredResponseType> | ProviderStrategy<StructuredResponseType> | ResponseFormatUndefined> = {\n /**\n * Defines a model to use for the agent. You can either pass in an instance of a LangChain chat model\n * or a string. If a string is provided the agent initializes a ChatModel based on the provided model name and provider.\n * It supports various model providers and allows for runtime configuration of model parameters.\n *\n * @uses {@link initChatModel}\n * @example\n * ```ts\n * const agent = createAgent({\n * model: \"anthropic:claude-3-7-sonnet-latest\",\n * // ...\n * });\n * ```\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * const agent = createAgent({\n * model: new ChatOpenAI({ model: \"gpt-4o\" }),\n * // ...\n * });\n * ```\n */\n model: string | LanguageModelLike;\n /**\n * A list of tools or a ToolNode.\n *\n * @example\n * ```ts\n * import { tool } from \"langchain\";\n *\n * const weatherTool = tool(() => \"Sunny!\", {\n * name: \"get_weather\",\n * description: \"Get the weather for a location\",\n * schema: z.object({\n * location: z.string().describe(\"The location to get weather for\"),\n * }),\n * });\n *\n * const agent = createAgent({\n * tools: [weatherTool],\n * // ...\n * });\n * ```\n */\n tools?: (ServerTool | ClientTool)[];\n /**\n * An optional system message for the model.\n */\n systemPrompt?: string;\n /**\n * An optional schema for the agent state. It allows you to define custom state properties that persist\n * across agent invocations and can be accessed in hooks, middleware, and throughout the agent's execution.\n * The state is persisted when using a checkpointer and can be updated by middleware or during execution.\n *\n * As opposed to the context (defined in `contextSchema`), the state is persisted between agent invocations\n * when using a checkpointer, making it suitable for maintaining conversation history, user preferences,\n * or any other data that should persist across multiple interactions.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { createAgent } from \"@langchain/langgraph\";\n *\n * const agent = createAgent({\n * model: \"openai:gpt-4o\",\n * tools: [getWeather],\n * stateSchema: z.object({\n * userPreferences: z.object({\n * temperatureUnit: z.enum([\"celsius\", \"fahrenheit\"]).default(\"celsius\"),\n * location: z.string().optional(),\n * }).optional(),\n * conversationCount: z.number().default(0),\n * }),\n * prompt: (state, config) => {\n * const unit = state.userPreferences?.temperatureUnit || \"celsius\";\n * return [\n * new SystemMessage(`You are a helpful assistant. Use ${unit} for temperature.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new HumanMessage(\"What's the weather like?\"),\n * ],\n * userPreferences: {\n * temperatureUnit: \"fahrenheit\",\n * location: \"New York\",\n * },\n * conversationCount: 1,\n * });\n * ```\n */\n stateSchema?: StateSchema;\n /**\n * An optional schema for the context. It allows to pass in a typed context object into the agent\n * invocation and allows to access it in hooks such as `prompt` and middleware.\n * As opposed to the agent state, defined in `stateSchema`, the context is not persisted between\n * agent invocations.\n *\n * @example\n * ```ts\n * const agent = createAgent({\n * llm: model,\n * tools: [getWeather],\n * contextSchema: z.object({\n * capital: z.string(),\n * }),\n * prompt: (state, config) => {\n * return [\n * new SystemMessage(`You are a helpful assistant. The capital of France is ${config.context.capital}.`),\n * ];\n * },\n * });\n *\n * const result = await agent.invoke({\n * messages: [\n * new SystemMessage(\"You are a helpful assistant.\"),\n * new HumanMessage(\"What is the capital of France?\"),\n * ],\n * }, {\n * context: {\n * capital: \"Paris\",\n * },\n * });\n * ```\n */\n contextSchema?: ContextSchema;\n /**\n * An optional checkpoint saver to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/persistence | Checkpointing}\n */\n checkpointer?: BaseCheckpointSaver | boolean;\n /**\n * An optional store to persist the agent's state.\n * @see {@link https://docs.langchain.com/oss/javascript/langgraph/memory#memory-storage | Long-term memory}\n */\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: z.object({\n * capital: z.string(),\n * }),\n * // ...\n * });\n * ```\n * - JSON schema\n * ```ts\n * const agent = createAgent({\n * responseFormat: {\n * type: \"json_schema\",\n * schema: {\n * type: \"object\",\n * properties: {\n * capital: { type: \"string\" },\n * },\n * required: [\"capital\"],\n * },\n * },\n * // ...\n * });\n * ```\n * - Create React Agent ResponseFormat\n * ```ts\n * import { providerStrategy, toolStrategy } from \"langchain\";\n * const agent = createAgent({\n * responseFormat: providerStrategy(\n * z.object({\n * capital: z.string(),\n * })\n * ),\n * // or\n * responseFormat: [\n * toolStrategy({ ... }),\n * toolStrategy({ ... }),\n * ]\n * // ...\n * });\n * ```\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?: ResponseFormatType;\n /**\n * Middleware instances to run during agent execution.\n * Each middleware can define its own state schema and hook into the agent lifecycle.\n *\n * @see {@link https://docs.langchain.com/oss/javascript/langchain/middleware | Middleware}\n */\n middleware?: readonly AgentMiddleware<any, any, any>[];\n /**\n * An optional name for the agent.\n */\n name?: string;\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string;\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n * - `undefined`: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n * - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n * Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n /**\n * An optional abort signal that indicates that the overall operation should be aborted.\n */\n signal?: AbortSignal;\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v2\"`\n */\n version?: \"v1\" | \"v2\";\n};\n/**\n * Type helper to extract union type from an array of Zod schemas\n */\nexport type ExtractZodArrayTypes<T extends readonly InteropZodType<any>[]> = T extends readonly [InteropZodType<infer A>, ...infer Rest] ? Rest extends readonly InteropZodType<any>[] ? A | ExtractZodArrayTypes<Rest> : A : never;\nexport type WithStateGraphNodes<K extends string, Graph> = Graph extends StateGraph<infer SD, infer S, infer U, infer N, infer I, infer O, infer C> ? StateGraph<SD, S, U, N | K, I, O, C> : never;\n"],"mappings":";;;;;;;;;;;;KAWYsB,CAAAA,UAAWpB;AAAvB;AAIA;AAUA;AAA6B,UAVZqB,SAUY,CAAA,SAAA,OAAA,CAAA,CAAA;EAAA;;;EAWJ,EAAA,EAAA,MAAA;EAKbG;;;EAAgD,KAAG1B,EAlBpDwB,MAkBoDxB;;AAA4CoB,UAhB1FK,YAAAA,CAgB0FL;EAAgB,QAC7GX,EAhBAH,WAgBAG,EAAAA;EAAQ,aAAA,CAAA,EAfFc,SAeE,EAAA;EAKLK;AAyBjB;AAiBA;AAIA;AAkBA;;;;EAAyF,MAAmCT,CAAAA,EA3E/GE,YA2E+GF;;;;;AAAkLe,KAtElSR,SAsEkSQ,CAAAA,qBAtEnQf,iBAsEmQe,GAtE/OlC,gBAsE+OkC,GAAAA,SAAAA,GAAAA,SAAAA,CAAAA,GAtEnMd,gBAsEmMc,CAtElLP,YAsEkLO,CAAAA,GAAAA;EAAsB,QAArCjC,EArEjRQ,QAqEiRR;CAAc;;;;AAAkIiC,UAhE9ZN,UAAAA,CAgE8ZM;EAAsB;;;EAAgB,EAAA,EAA4CA,MAAAA;EAAsB;;;EAwBlf,IAsBxBvB,EAAAA,MAAAA;EAAU;;;EAmFU,IAKdJ,EA1LTsB,MA0LStB,CAAAA,MAAAA,EAAAA,GAAAA,CAAAA;EAAmB;;;EAkEG,MAoB5B+B,CAAAA,EAAAA,OAAAA;EAAW;AAiBxB;;EAAgC,KAAoBrC,CAAAA,EAAAA,MAAAA;;;;;AAAqIyC,UApRxKZ,UAAAA,CAoRwKY;EAAC;;;EAAiC,EAAA,EAAA,MAAA;EAC/MC;;;EAAoD,MAASvC,EAAAA,GAAAA;EAAU;;;EAAsF,KAAEkB,CAAAA,EAAA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