@librechat/agents 3.4.7 → 3.5.1

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 (924) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +0 -356
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/agents/projection.cjs +0 -9
  4. package/dist/cjs/agents/projection.cjs.map +1 -1
  5. package/dist/cjs/common/constants.cjs +0 -26
  6. package/dist/cjs/common/constants.cjs.map +1 -1
  7. package/dist/cjs/common/enum.cjs +0 -85
  8. package/dist/cjs/common/enum.cjs.map +1 -1
  9. package/dist/cjs/events.cjs +0 -14
  10. package/dist/cjs/events.cjs.map +1 -1
  11. package/dist/cjs/graphs/Graph.cjs +1 -909
  12. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  13. package/dist/cjs/graphs/MultiAgentGraph.cjs +7 -272
  14. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  15. package/dist/cjs/graphs/applyGraphRuntimeConfig.cjs.map +1 -1
  16. package/dist/cjs/graphs/createGraph.cjs.map +1 -1
  17. package/dist/cjs/hitl/askUserQuestion.cjs +0 -53
  18. package/dist/cjs/hitl/askUserQuestion.cjs.map +1 -1
  19. package/dist/cjs/hitl/askUserQuestions.cjs +0 -20
  20. package/dist/cjs/hitl/askUserQuestions.cjs.map +1 -1
  21. package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs +0 -6
  22. package/dist/cjs/hitl/askUserQuestionsInterrupt.cjs.map +1 -1
  23. package/dist/cjs/hooks/HookRegistry.cjs +0 -127
  24. package/dist/cjs/hooks/HookRegistry.cjs.map +1 -1
  25. package/dist/cjs/hooks/createToolPolicyHook.cjs +0 -38
  26. package/dist/cjs/hooks/createToolPolicyHook.cjs.map +1 -1
  27. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs +0 -77
  28. package/dist/cjs/hooks/createWorkspacePolicyHook.cjs.map +1 -1
  29. package/dist/cjs/hooks/executeHooks.cjs +0 -79
  30. package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
  31. package/dist/cjs/hooks/index.cjs +0 -16
  32. package/dist/cjs/hooks/index.cjs.map +1 -1
  33. package/dist/cjs/hooks/matchers.cjs +0 -104
  34. package/dist/cjs/hooks/matchers.cjs.map +1 -1
  35. package/dist/cjs/hooks/types.cjs +0 -8
  36. package/dist/cjs/hooks/types.cjs.map +1 -1
  37. package/dist/cjs/instrumentation.cjs +0 -14
  38. package/dist/cjs/instrumentation.cjs.map +1 -1
  39. package/dist/cjs/langfuse.cjs +0 -75
  40. package/dist/cjs/langfuse.cjs.map +1 -1
  41. package/dist/cjs/langfuseConfig.cjs.map +1 -1
  42. package/dist/cjs/langfuseRuntimeContext.cjs +0 -13
  43. package/dist/cjs/langfuseRuntimeContext.cjs.map +1 -1
  44. package/dist/cjs/langfuseRuntimeScope.cjs +0 -4
  45. package/dist/cjs/langfuseRuntimeScope.cjs.map +1 -1
  46. package/dist/cjs/langfuseSpanRegistry.cjs +0 -28
  47. package/dist/cjs/langfuseSpanRegistry.cjs.map +1 -1
  48. package/dist/cjs/langfuseToolOutputTracing.cjs +0 -3
  49. package/dist/cjs/langfuseToolOutputTracing.cjs.map +1 -1
  50. package/dist/cjs/langfuseTraceShaping.cjs +0 -74
  51. package/dist/cjs/langfuseTraceShaping.cjs.map +1 -1
  52. package/dist/cjs/llm/anthropic/index.cjs +0 -3
  53. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  54. package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
  55. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +1 -111
  56. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  57. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +0 -1
  58. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  59. package/dist/cjs/llm/anthropic/utils/stream_events.cjs +0 -8
  60. package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
  61. package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -1
  62. package/dist/cjs/llm/bedrock/cachePoints.cjs.map +1 -1
  63. package/dist/cjs/llm/bedrock/index.cjs +1 -95
  64. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  65. package/dist/cjs/llm/bedrock/toolCache.cjs.map +1 -1
  66. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +0 -78
  67. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
  68. package/dist/cjs/llm/bedrock/utils/message_outputs.cjs +0 -24
  69. package/dist/cjs/llm/bedrock/utils/message_outputs.cjs.map +1 -1
  70. package/dist/cjs/llm/contextOverflowRecovery.cjs +0 -62
  71. package/dist/cjs/llm/contextOverflowRecovery.cjs.map +1 -1
  72. package/dist/cjs/llm/fake.cjs.map +1 -1
  73. package/dist/cjs/llm/google/index.cjs +2 -21
  74. package/dist/cjs/llm/google/index.cjs.map +1 -1
  75. package/dist/cjs/llm/google/utils/common.cjs +0 -35
  76. package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
  77. package/dist/cjs/llm/init.cjs +0 -9
  78. package/dist/cjs/llm/init.cjs.map +1 -1
  79. package/dist/cjs/llm/invoke.cjs +1 -270
  80. package/dist/cjs/llm/invoke.cjs.map +1 -1
  81. package/dist/cjs/llm/mistral/index.cjs.map +1 -1
  82. package/dist/cjs/llm/openai/index.cjs +0 -99
  83. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  84. package/dist/cjs/llm/openai/streamMetadata.cjs +0 -21
  85. package/dist/cjs/llm/openai/streamMetadata.cjs.map +1 -1
  86. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -1
  87. package/dist/cjs/llm/openrouter/index.cjs +0 -1
  88. package/dist/cjs/llm/openrouter/index.cjs.map +1 -1
  89. package/dist/cjs/llm/openrouter/toolCache.cjs +0 -6
  90. package/dist/cjs/llm/openrouter/toolCache.cjs.map +1 -1
  91. package/dist/cjs/llm/preempt.cjs +0 -75
  92. package/dist/cjs/llm/preempt.cjs.map +1 -1
  93. package/dist/cjs/llm/providers.cjs.map +1 -1
  94. package/dist/cjs/llm/request.cjs +0 -10
  95. package/dist/cjs/llm/request.cjs.map +1 -1
  96. package/dist/cjs/llm/stream/chunkAdapters.cjs +0 -62
  97. package/dist/cjs/llm/stream/chunkAdapters.cjs.map +1 -1
  98. package/dist/cjs/llm/stream/smoother.cjs +0 -58
  99. package/dist/cjs/llm/stream/smoother.cjs.map +1 -1
  100. package/dist/cjs/llm/streamLimits.cjs +4 -293
  101. package/dist/cjs/llm/streamLimits.cjs.map +1 -1
  102. package/dist/cjs/llm/truncation.cjs +0 -36
  103. package/dist/cjs/llm/truncation.cjs.map +1 -1
  104. package/dist/cjs/llm/vertexai/index.cjs +0 -330
  105. package/dist/cjs/llm/vertexai/index.cjs.map +1 -1
  106. package/dist/cjs/messages/alternation.cjs +0 -43
  107. package/dist/cjs/messages/alternation.cjs.map +1 -1
  108. package/dist/cjs/messages/anthropicToolCache.cjs +0 -45
  109. package/dist/cjs/messages/anthropicToolCache.cjs.map +1 -1
  110. package/dist/cjs/messages/assistantPhase.cjs +0 -12
  111. package/dist/cjs/messages/assistantPhase.cjs.map +1 -1
  112. package/dist/cjs/messages/budget.cjs +0 -9
  113. package/dist/cjs/messages/budget.cjs.map +1 -1
  114. package/dist/cjs/messages/cache.cjs +0 -172
  115. package/dist/cjs/messages/cache.cjs.map +1 -1
  116. package/dist/cjs/messages/content.cjs +0 -9
  117. package/dist/cjs/messages/content.cjs.map +1 -1
  118. package/dist/cjs/messages/contextPruning.cjs +0 -15
  119. package/dist/cjs/messages/contextPruning.cjs.map +1 -1
  120. package/dist/cjs/messages/contextPruningSettings.cjs +0 -3
  121. package/dist/cjs/messages/contextPruningSettings.cjs.map +1 -1
  122. package/dist/cjs/messages/core.cjs +0 -48
  123. package/dist/cjs/messages/core.cjs.map +1 -1
  124. package/dist/cjs/messages/format.cjs +1 -345
  125. package/dist/cjs/messages/format.cjs.map +1 -1
  126. package/dist/cjs/messages/handoffCue.cjs +0 -36
  127. package/dist/cjs/messages/handoffCue.cjs.map +1 -1
  128. package/dist/cjs/messages/ids.cjs.map +1 -1
  129. package/dist/cjs/messages/injected.cjs +0 -33
  130. package/dist/cjs/messages/injected.cjs.map +1 -1
  131. package/dist/cjs/messages/langchain.cjs +0 -14
  132. package/dist/cjs/messages/langchain.cjs.map +1 -1
  133. package/dist/cjs/messages/prune.cjs +1 -184
  134. package/dist/cjs/messages/prune.cjs.map +1 -1
  135. package/dist/cjs/messages/recency.cjs +0 -32
  136. package/dist/cjs/messages/recency.cjs.map +1 -1
  137. package/dist/cjs/messages/reducer.cjs +0 -30
  138. package/dist/cjs/messages/reducer.cjs.map +1 -1
  139. package/dist/cjs/messages/tools.cjs +0 -14
  140. package/dist/cjs/messages/tools.cjs.map +1 -1
  141. package/dist/cjs/openai/index.cjs.map +1 -1
  142. package/dist/cjs/prompts/activityLabel.cjs +9 -79
  143. package/dist/cjs/prompts/activityLabel.cjs.map +1 -1
  144. package/dist/cjs/responses/index.cjs.map +1 -1
  145. package/dist/cjs/run.cjs +2 -538
  146. package/dist/cjs/run.cjs.map +1 -1
  147. package/dist/cjs/session/AgentSession.cjs +1 -17
  148. package/dist/cjs/session/AgentSession.cjs.map +1 -1
  149. package/dist/cjs/session/JsonlSessionStore.cjs.map +1 -1
  150. package/dist/cjs/session/handlers.cjs +0 -7
  151. package/dist/cjs/session/handlers.cjs.map +1 -1
  152. package/dist/cjs/session/ids.cjs.map +1 -1
  153. package/dist/cjs/session/messageSerialization.cjs +0 -4
  154. package/dist/cjs/session/messageSerialization.cjs.map +1 -1
  155. package/dist/cjs/stream.cjs +1 -93
  156. package/dist/cjs/stream.cjs.map +1 -1
  157. package/dist/cjs/summarization/index.cjs +0 -27
  158. package/dist/cjs/summarization/index.cjs.map +1 -1
  159. package/dist/cjs/summarization/node.cjs +0 -273
  160. package/dist/cjs/summarization/node.cjs.map +1 -1
  161. package/dist/cjs/tools/BashExecutor.cjs +0 -35
  162. package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
  163. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +0 -24
  164. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  165. package/dist/cjs/tools/Calculator.cjs.map +1 -1
  166. package/dist/cjs/tools/CodeExecutor.cjs +0 -13
  167. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  168. package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -1
  169. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +0 -101
  170. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  171. package/dist/cjs/tools/ReadFile.cjs.map +1 -1
  172. package/dist/cjs/tools/SkillTool.cjs +0 -5
  173. package/dist/cjs/tools/SkillTool.cjs.map +1 -1
  174. package/dist/cjs/tools/SubagentTool.cjs +0 -10
  175. package/dist/cjs/tools/SubagentTool.cjs.map +1 -1
  176. package/dist/cjs/tools/ToolNode.cjs +6 -1038
  177. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  178. package/dist/cjs/tools/ToolSearch.cjs +0 -179
  179. package/dist/cjs/tools/ToolSearch.cjs.map +1 -1
  180. package/dist/cjs/tools/cloudflare/CloudflareBridgeRuntime.cjs.map +1 -1
  181. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
  182. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs +0 -39
  183. package/dist/cjs/tools/cloudflare/CloudflareSandboxExecutionEngine.cjs.map +1 -1
  184. package/dist/cjs/tools/cloudflare/CloudflareSandboxTools.cjs.map +1 -1
  185. package/dist/cjs/tools/eagerEventExecution.cjs +0 -6
  186. package/dist/cjs/tools/eagerEventExecution.cjs.map +1 -1
  187. package/dist/cjs/tools/handlers.cjs +1 -41
  188. package/dist/cjs/tools/handlers.cjs.map +1 -1
  189. package/dist/cjs/tools/intentArg.cjs +1 -132
  190. package/dist/cjs/tools/intentArg.cjs.map +1 -1
  191. package/dist/cjs/tools/local/CompileCheckTool.cjs +0 -25
  192. package/dist/cjs/tools/local/CompileCheckTool.cjs.map +1 -1
  193. package/dist/cjs/tools/local/FileCheckpointer.cjs +0 -23
  194. package/dist/cjs/tools/local/FileCheckpointer.cjs.map +1 -1
  195. package/dist/cjs/tools/local/LocalCodingTools.cjs +0 -80
  196. package/dist/cjs/tools/local/LocalCodingTools.cjs.map +1 -1
  197. package/dist/cjs/tools/local/LocalExecutionEngine.cjs +0 -126
  198. package/dist/cjs/tools/local/LocalExecutionEngine.cjs.map +1 -1
  199. package/dist/cjs/tools/local/LocalExecutionTools.cjs.map +1 -1
  200. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +0 -12
  201. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
  202. package/dist/cjs/tools/local/attachments.cjs +0 -44
  203. package/dist/cjs/tools/local/attachments.cjs.map +1 -1
  204. package/dist/cjs/tools/local/bashAst.cjs +0 -16
  205. package/dist/cjs/tools/local/bashAst.cjs.map +1 -1
  206. package/dist/cjs/tools/local/editStrategies.cjs +0 -14
  207. package/dist/cjs/tools/local/editStrategies.cjs.map +1 -1
  208. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
  209. package/dist/cjs/tools/local/syntaxCheck.cjs +0 -31
  210. package/dist/cjs/tools/local/syntaxCheck.cjs.map +1 -1
  211. package/dist/cjs/tools/local/textEncoding.cjs +0 -11
  212. package/dist/cjs/tools/local/textEncoding.cjs.map +1 -1
  213. package/dist/cjs/tools/local/workspaceFS.cjs +0 -33
  214. package/dist/cjs/tools/local/workspaceFS.cjs.map +1 -1
  215. package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
  216. package/dist/cjs/tools/schema.cjs +0 -8
  217. package/dist/cjs/tools/schema.cjs.map +1 -1
  218. package/dist/cjs/tools/search/anthropic.cjs +0 -9
  219. package/dist/cjs/tools/search/anthropic.cjs.map +1 -1
  220. package/dist/cjs/tools/search/content.cjs.map +1 -1
  221. package/dist/cjs/tools/search/crw-scraper.cjs +0 -33
  222. package/dist/cjs/tools/search/crw-scraper.cjs.map +1 -1
  223. package/dist/cjs/tools/search/crw-search.cjs +0 -2
  224. package/dist/cjs/tools/search/crw-search.cjs.map +1 -1
  225. package/dist/cjs/tools/search/firecrawl.cjs +0 -25
  226. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  227. package/dist/cjs/tools/search/format.cjs +0 -30
  228. package/dist/cjs/tools/search/format.cjs.map +1 -1
  229. package/dist/cjs/tools/search/highlights.cjs +0 -16
  230. package/dist/cjs/tools/search/highlights.cjs.map +1 -1
  231. package/dist/cjs/tools/search/keenable-scraper.cjs +0 -8
  232. package/dist/cjs/tools/search/keenable-scraper.cjs.map +1 -1
  233. package/dist/cjs/tools/search/keenable-search.cjs +0 -7
  234. package/dist/cjs/tools/search/keenable-search.cjs.map +1 -1
  235. package/dist/cjs/tools/search/rerankers.cjs +0 -35
  236. package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
  237. package/dist/cjs/tools/search/schema.cjs +0 -1
  238. package/dist/cjs/tools/search/schema.cjs.map +1 -1
  239. package/dist/cjs/tools/search/search.cjs +1 -14
  240. package/dist/cjs/tools/search/search.cjs.map +1 -1
  241. package/dist/cjs/tools/search/serper-scraper.cjs +0 -46
  242. package/dist/cjs/tools/search/serper-scraper.cjs.map +1 -1
  243. package/dist/cjs/tools/search/tavily-scraper.cjs.map +1 -1
  244. package/dist/cjs/tools/search/tavily-search.cjs.map +1 -1
  245. package/dist/cjs/tools/search/tool.cjs +0 -25
  246. package/dist/cjs/tools/search/tool.cjs.map +1 -1
  247. package/dist/cjs/tools/search/utils.cjs +0 -8
  248. package/dist/cjs/tools/search/utils.cjs.map +1 -1
  249. package/dist/cjs/tools/skillCatalog.cjs +0 -6
  250. package/dist/cjs/tools/skillCatalog.cjs.map +1 -1
  251. package/dist/cjs/tools/streamedToolCallSeals.cjs +0 -6
  252. package/dist/cjs/tools/streamedToolCallSeals.cjs.map +1 -1
  253. package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs +0 -2
  254. package/dist/cjs/tools/subagent/SubagentExecutionRegistry.cjs.map +1 -1
  255. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +3 -213
  256. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  257. package/dist/cjs/tools/subagent/SubagentReplay.cjs.map +1 -1
  258. package/dist/cjs/tools/subagent/childGraphConfig.cjs +0 -4
  259. package/dist/cjs/tools/subagent/childGraphConfig.cjs.map +1 -1
  260. package/dist/cjs/tools/subagent/runtimeLimits.cjs.map +1 -1
  261. package/dist/cjs/tools/toolOutputReferences.cjs +1 -322
  262. package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
  263. package/dist/cjs/types/hitl.cjs +0 -5
  264. package/dist/cjs/types/hitl.cjs.map +1 -1
  265. package/dist/cjs/utils/callbacks.cjs.map +1 -1
  266. package/dist/cjs/utils/errors.cjs +14 -165
  267. package/dist/cjs/utils/errors.cjs.map +1 -1
  268. package/dist/cjs/utils/events.cjs +0 -10
  269. package/dist/cjs/utils/events.cjs.map +1 -1
  270. package/dist/cjs/utils/graph.cjs.map +1 -1
  271. package/dist/cjs/utils/handlers.cjs +0 -3
  272. package/dist/cjs/utils/handlers.cjs.map +1 -1
  273. package/dist/cjs/utils/llm.cjs +0 -1
  274. package/dist/cjs/utils/llm.cjs.map +1 -1
  275. package/dist/cjs/utils/misc.cjs +0 -16
  276. package/dist/cjs/utils/misc.cjs.map +1 -1
  277. package/dist/cjs/utils/proxy.cjs +0 -26
  278. package/dist/cjs/utils/proxy.cjs.map +1 -1
  279. package/dist/cjs/utils/run.cjs +0 -6
  280. package/dist/cjs/utils/run.cjs.map +1 -1
  281. package/dist/cjs/utils/schema.cjs +0 -5
  282. package/dist/cjs/utils/schema.cjs.map +1 -1
  283. package/dist/cjs/utils/title.cjs +0 -6
  284. package/dist/cjs/utils/title.cjs.map +1 -1
  285. package/dist/cjs/utils/tokens.cjs +0 -113
  286. package/dist/cjs/utils/tokens.cjs.map +1 -1
  287. package/dist/cjs/utils/toolContent.cjs +0 -41
  288. package/dist/cjs/utils/toolContent.cjs.map +1 -1
  289. package/dist/cjs/utils/truncation.cjs +0 -61
  290. package/dist/cjs/utils/truncation.cjs.map +1 -1
  291. package/dist/esm/agents/AgentContext.mjs +0 -356
  292. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  293. package/dist/esm/agents/projection.mjs +0 -9
  294. package/dist/esm/agents/projection.mjs.map +1 -1
  295. package/dist/esm/common/constants.mjs +0 -26
  296. package/dist/esm/common/constants.mjs.map +1 -1
  297. package/dist/esm/common/enum.mjs +0 -85
  298. package/dist/esm/common/enum.mjs.map +1 -1
  299. package/dist/esm/events.mjs +0 -14
  300. package/dist/esm/events.mjs.map +1 -1
  301. package/dist/esm/graphs/Graph.mjs +1 -909
  302. package/dist/esm/graphs/Graph.mjs.map +1 -1
  303. package/dist/esm/graphs/MultiAgentGraph.mjs +7 -272
  304. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  305. package/dist/esm/graphs/applyGraphRuntimeConfig.mjs.map +1 -1
  306. package/dist/esm/graphs/createGraph.mjs.map +1 -1
  307. package/dist/esm/hitl/askUserQuestion.mjs +0 -53
  308. package/dist/esm/hitl/askUserQuestion.mjs.map +1 -1
  309. package/dist/esm/hitl/askUserQuestions.mjs +0 -20
  310. package/dist/esm/hitl/askUserQuestions.mjs.map +1 -1
  311. package/dist/esm/hitl/askUserQuestionsInterrupt.mjs +0 -6
  312. package/dist/esm/hitl/askUserQuestionsInterrupt.mjs.map +1 -1
  313. package/dist/esm/hooks/HookRegistry.mjs +0 -127
  314. package/dist/esm/hooks/HookRegistry.mjs.map +1 -1
  315. package/dist/esm/hooks/createToolPolicyHook.mjs +0 -38
  316. package/dist/esm/hooks/createToolPolicyHook.mjs.map +1 -1
  317. package/dist/esm/hooks/createWorkspacePolicyHook.mjs +0 -77
  318. package/dist/esm/hooks/createWorkspacePolicyHook.mjs.map +1 -1
  319. package/dist/esm/hooks/executeHooks.mjs +0 -79
  320. package/dist/esm/hooks/executeHooks.mjs.map +1 -1
  321. package/dist/esm/hooks/index.mjs +0 -16
  322. package/dist/esm/hooks/index.mjs.map +1 -1
  323. package/dist/esm/hooks/matchers.mjs +0 -104
  324. package/dist/esm/hooks/matchers.mjs.map +1 -1
  325. package/dist/esm/hooks/types.mjs +0 -8
  326. package/dist/esm/hooks/types.mjs.map +1 -1
  327. package/dist/esm/instrumentation.mjs +0 -14
  328. package/dist/esm/instrumentation.mjs.map +1 -1
  329. package/dist/esm/langfuse.mjs +0 -75
  330. package/dist/esm/langfuse.mjs.map +1 -1
  331. package/dist/esm/langfuseConfig.mjs.map +1 -1
  332. package/dist/esm/langfuseRuntimeContext.mjs +0 -13
  333. package/dist/esm/langfuseRuntimeContext.mjs.map +1 -1
  334. package/dist/esm/langfuseRuntimeScope.mjs +0 -4
  335. package/dist/esm/langfuseRuntimeScope.mjs.map +1 -1
  336. package/dist/esm/langfuseSpanRegistry.mjs +0 -28
  337. package/dist/esm/langfuseSpanRegistry.mjs.map +1 -1
  338. package/dist/esm/langfuseToolOutputTracing.mjs +0 -3
  339. package/dist/esm/langfuseToolOutputTracing.mjs.map +1 -1
  340. package/dist/esm/langfuseTraceShaping.mjs +0 -74
  341. package/dist/esm/langfuseTraceShaping.mjs.map +1 -1
  342. package/dist/esm/llm/anthropic/index.mjs +0 -3
  343. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  344. package/dist/esm/llm/anthropic/types.mjs.map +1 -1
  345. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +1 -111
  346. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  347. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +0 -1
  348. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  349. package/dist/esm/llm/anthropic/utils/stream_events.mjs +0 -8
  350. package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -1
  351. package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -1
  352. package/dist/esm/llm/bedrock/cachePoints.mjs.map +1 -1
  353. package/dist/esm/llm/bedrock/index.mjs +1 -95
  354. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  355. package/dist/esm/llm/bedrock/toolCache.mjs.map +1 -1
  356. package/dist/esm/llm/bedrock/utils/message_inputs.mjs +0 -78
  357. package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
  358. package/dist/esm/llm/bedrock/utils/message_outputs.mjs +0 -24
  359. package/dist/esm/llm/bedrock/utils/message_outputs.mjs.map +1 -1
  360. package/dist/esm/llm/contextOverflowRecovery.mjs +0 -62
  361. package/dist/esm/llm/contextOverflowRecovery.mjs.map +1 -1
  362. package/dist/esm/llm/fake.mjs.map +1 -1
  363. package/dist/esm/llm/google/index.mjs +2 -21
  364. package/dist/esm/llm/google/index.mjs.map +1 -1
  365. package/dist/esm/llm/google/utils/common.mjs +0 -35
  366. package/dist/esm/llm/google/utils/common.mjs.map +1 -1
  367. package/dist/esm/llm/init.mjs +0 -9
  368. package/dist/esm/llm/init.mjs.map +1 -1
  369. package/dist/esm/llm/invoke.mjs +1 -270
  370. package/dist/esm/llm/invoke.mjs.map +1 -1
  371. package/dist/esm/llm/mistral/index.mjs.map +1 -1
  372. package/dist/esm/llm/openai/index.mjs +0 -99
  373. package/dist/esm/llm/openai/index.mjs.map +1 -1
  374. package/dist/esm/llm/openai/streamMetadata.mjs +0 -21
  375. package/dist/esm/llm/openai/streamMetadata.mjs.map +1 -1
  376. package/dist/esm/llm/openai/utils/index.mjs.map +1 -1
  377. package/dist/esm/llm/openrouter/index.mjs +0 -1
  378. package/dist/esm/llm/openrouter/index.mjs.map +1 -1
  379. package/dist/esm/llm/openrouter/toolCache.mjs +0 -6
  380. package/dist/esm/llm/openrouter/toolCache.mjs.map +1 -1
  381. package/dist/esm/llm/preempt.mjs +0 -75
  382. package/dist/esm/llm/preempt.mjs.map +1 -1
  383. package/dist/esm/llm/providers.mjs.map +1 -1
  384. package/dist/esm/llm/request.mjs +0 -10
  385. package/dist/esm/llm/request.mjs.map +1 -1
  386. package/dist/esm/llm/stream/chunkAdapters.mjs +0 -62
  387. package/dist/esm/llm/stream/chunkAdapters.mjs.map +1 -1
  388. package/dist/esm/llm/stream/smoother.mjs +0 -58
  389. package/dist/esm/llm/stream/smoother.mjs.map +1 -1
  390. package/dist/esm/llm/streamLimits.mjs +4 -293
  391. package/dist/esm/llm/streamLimits.mjs.map +1 -1
  392. package/dist/esm/llm/truncation.mjs +0 -36
  393. package/dist/esm/llm/truncation.mjs.map +1 -1
  394. package/dist/esm/llm/vertexai/index.mjs +0 -330
  395. package/dist/esm/llm/vertexai/index.mjs.map +1 -1
  396. package/dist/esm/messages/alternation.mjs +0 -43
  397. package/dist/esm/messages/alternation.mjs.map +1 -1
  398. package/dist/esm/messages/anthropicToolCache.mjs +0 -45
  399. package/dist/esm/messages/anthropicToolCache.mjs.map +1 -1
  400. package/dist/esm/messages/assistantPhase.mjs +0 -12
  401. package/dist/esm/messages/assistantPhase.mjs.map +1 -1
  402. package/dist/esm/messages/budget.mjs +0 -9
  403. package/dist/esm/messages/budget.mjs.map +1 -1
  404. package/dist/esm/messages/cache.mjs +0 -172
  405. package/dist/esm/messages/cache.mjs.map +1 -1
  406. package/dist/esm/messages/content.mjs +0 -9
  407. package/dist/esm/messages/content.mjs.map +1 -1
  408. package/dist/esm/messages/contextPruning.mjs +0 -15
  409. package/dist/esm/messages/contextPruning.mjs.map +1 -1
  410. package/dist/esm/messages/contextPruningSettings.mjs +0 -3
  411. package/dist/esm/messages/contextPruningSettings.mjs.map +1 -1
  412. package/dist/esm/messages/core.mjs +0 -48
  413. package/dist/esm/messages/core.mjs.map +1 -1
  414. package/dist/esm/messages/format.mjs +1 -345
  415. package/dist/esm/messages/format.mjs.map +1 -1
  416. package/dist/esm/messages/handoffCue.mjs +0 -36
  417. package/dist/esm/messages/handoffCue.mjs.map +1 -1
  418. package/dist/esm/messages/ids.mjs.map +1 -1
  419. package/dist/esm/messages/injected.mjs +0 -33
  420. package/dist/esm/messages/injected.mjs.map +1 -1
  421. package/dist/esm/messages/langchain.mjs +0 -14
  422. package/dist/esm/messages/langchain.mjs.map +1 -1
  423. package/dist/esm/messages/prune.mjs +1 -184
  424. package/dist/esm/messages/prune.mjs.map +1 -1
  425. package/dist/esm/messages/recency.mjs +0 -32
  426. package/dist/esm/messages/recency.mjs.map +1 -1
  427. package/dist/esm/messages/reducer.mjs +0 -30
  428. package/dist/esm/messages/reducer.mjs.map +1 -1
  429. package/dist/esm/messages/tools.mjs +0 -14
  430. package/dist/esm/messages/tools.mjs.map +1 -1
  431. package/dist/esm/openai/index.mjs.map +1 -1
  432. package/dist/esm/prompts/activityLabel.mjs +9 -79
  433. package/dist/esm/prompts/activityLabel.mjs.map +1 -1
  434. package/dist/esm/responses/index.mjs.map +1 -1
  435. package/dist/esm/run.mjs +2 -538
  436. package/dist/esm/run.mjs.map +1 -1
  437. package/dist/esm/session/AgentSession.mjs +1 -17
  438. package/dist/esm/session/AgentSession.mjs.map +1 -1
  439. package/dist/esm/session/JsonlSessionStore.mjs.map +1 -1
  440. package/dist/esm/session/handlers.mjs +0 -7
  441. package/dist/esm/session/handlers.mjs.map +1 -1
  442. package/dist/esm/session/ids.mjs.map +1 -1
  443. package/dist/esm/session/messageSerialization.mjs +0 -4
  444. package/dist/esm/session/messageSerialization.mjs.map +1 -1
  445. package/dist/esm/stream.mjs +1 -93
  446. package/dist/esm/stream.mjs.map +1 -1
  447. package/dist/esm/summarization/index.mjs +0 -27
  448. package/dist/esm/summarization/index.mjs.map +1 -1
  449. package/dist/esm/summarization/node.mjs +0 -273
  450. package/dist/esm/summarization/node.mjs.map +1 -1
  451. package/dist/esm/tools/BashExecutor.mjs +0 -35
  452. package/dist/esm/tools/BashExecutor.mjs.map +1 -1
  453. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +0 -24
  454. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  455. package/dist/esm/tools/Calculator.mjs.map +1 -1
  456. package/dist/esm/tools/CodeExecutor.mjs +0 -13
  457. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  458. package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -1
  459. package/dist/esm/tools/ProgrammaticToolCalling.mjs +0 -101
  460. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  461. package/dist/esm/tools/ReadFile.mjs.map +1 -1
  462. package/dist/esm/tools/SkillTool.mjs +0 -5
  463. package/dist/esm/tools/SkillTool.mjs.map +1 -1
  464. package/dist/esm/tools/SubagentTool.mjs +0 -10
  465. package/dist/esm/tools/SubagentTool.mjs.map +1 -1
  466. package/dist/esm/tools/ToolNode.mjs +6 -1038
  467. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  468. package/dist/esm/tools/ToolSearch.mjs +0 -179
  469. package/dist/esm/tools/ToolSearch.mjs.map +1 -1
  470. package/dist/esm/tools/cloudflare/CloudflareBridgeRuntime.mjs.map +1 -1
  471. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
  472. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs +0 -39
  473. package/dist/esm/tools/cloudflare/CloudflareSandboxExecutionEngine.mjs.map +1 -1
  474. package/dist/esm/tools/cloudflare/CloudflareSandboxTools.mjs.map +1 -1
  475. package/dist/esm/tools/eagerEventExecution.mjs +0 -6
  476. package/dist/esm/tools/eagerEventExecution.mjs.map +1 -1
  477. package/dist/esm/tools/handlers.mjs +1 -41
  478. package/dist/esm/tools/handlers.mjs.map +1 -1
  479. package/dist/esm/tools/intentArg.mjs +1 -132
  480. package/dist/esm/tools/intentArg.mjs.map +1 -1
  481. package/dist/esm/tools/local/CompileCheckTool.mjs +0 -25
  482. package/dist/esm/tools/local/CompileCheckTool.mjs.map +1 -1
  483. package/dist/esm/tools/local/FileCheckpointer.mjs +0 -23
  484. package/dist/esm/tools/local/FileCheckpointer.mjs.map +1 -1
  485. package/dist/esm/tools/local/LocalCodingTools.mjs +0 -80
  486. package/dist/esm/tools/local/LocalCodingTools.mjs.map +1 -1
  487. package/dist/esm/tools/local/LocalExecutionEngine.mjs +0 -126
  488. package/dist/esm/tools/local/LocalExecutionEngine.mjs.map +1 -1
  489. package/dist/esm/tools/local/LocalExecutionTools.mjs.map +1 -1
  490. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +0 -12
  491. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
  492. package/dist/esm/tools/local/attachments.mjs +0 -44
  493. package/dist/esm/tools/local/attachments.mjs.map +1 -1
  494. package/dist/esm/tools/local/bashAst.mjs +0 -16
  495. package/dist/esm/tools/local/bashAst.mjs.map +1 -1
  496. package/dist/esm/tools/local/editStrategies.mjs +0 -14
  497. package/dist/esm/tools/local/editStrategies.mjs.map +1 -1
  498. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
  499. package/dist/esm/tools/local/syntaxCheck.mjs +0 -31
  500. package/dist/esm/tools/local/syntaxCheck.mjs.map +1 -1
  501. package/dist/esm/tools/local/textEncoding.mjs +0 -11
  502. package/dist/esm/tools/local/textEncoding.mjs.map +1 -1
  503. package/dist/esm/tools/local/workspaceFS.mjs +0 -33
  504. package/dist/esm/tools/local/workspaceFS.mjs.map +1 -1
  505. package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
  506. package/dist/esm/tools/schema.mjs +0 -8
  507. package/dist/esm/tools/schema.mjs.map +1 -1
  508. package/dist/esm/tools/search/anthropic.mjs +0 -9
  509. package/dist/esm/tools/search/anthropic.mjs.map +1 -1
  510. package/dist/esm/tools/search/content.mjs.map +1 -1
  511. package/dist/esm/tools/search/crw-scraper.mjs +0 -33
  512. package/dist/esm/tools/search/crw-scraper.mjs.map +1 -1
  513. package/dist/esm/tools/search/crw-search.mjs +0 -2
  514. package/dist/esm/tools/search/crw-search.mjs.map +1 -1
  515. package/dist/esm/tools/search/firecrawl.mjs +0 -25
  516. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  517. package/dist/esm/tools/search/format.mjs +0 -30
  518. package/dist/esm/tools/search/format.mjs.map +1 -1
  519. package/dist/esm/tools/search/highlights.mjs +0 -16
  520. package/dist/esm/tools/search/highlights.mjs.map +1 -1
  521. package/dist/esm/tools/search/keenable-scraper.mjs +0 -8
  522. package/dist/esm/tools/search/keenable-scraper.mjs.map +1 -1
  523. package/dist/esm/tools/search/keenable-search.mjs +0 -7
  524. package/dist/esm/tools/search/keenable-search.mjs.map +1 -1
  525. package/dist/esm/tools/search/rerankers.mjs +0 -35
  526. package/dist/esm/tools/search/rerankers.mjs.map +1 -1
  527. package/dist/esm/tools/search/schema.mjs +0 -1
  528. package/dist/esm/tools/search/schema.mjs.map +1 -1
  529. package/dist/esm/tools/search/search.mjs +1 -14
  530. package/dist/esm/tools/search/search.mjs.map +1 -1
  531. package/dist/esm/tools/search/serper-scraper.mjs +0 -46
  532. package/dist/esm/tools/search/serper-scraper.mjs.map +1 -1
  533. package/dist/esm/tools/search/tavily-scraper.mjs.map +1 -1
  534. package/dist/esm/tools/search/tavily-search.mjs.map +1 -1
  535. package/dist/esm/tools/search/tool.mjs +0 -25
  536. package/dist/esm/tools/search/tool.mjs.map +1 -1
  537. package/dist/esm/tools/search/utils.mjs +0 -8
  538. package/dist/esm/tools/search/utils.mjs.map +1 -1
  539. package/dist/esm/tools/skillCatalog.mjs +0 -6
  540. package/dist/esm/tools/skillCatalog.mjs.map +1 -1
  541. package/dist/esm/tools/streamedToolCallSeals.mjs +0 -6
  542. package/dist/esm/tools/streamedToolCallSeals.mjs.map +1 -1
  543. package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs +0 -2
  544. package/dist/esm/tools/subagent/SubagentExecutionRegistry.mjs.map +1 -1
  545. package/dist/esm/tools/subagent/SubagentExecutor.mjs +3 -213
  546. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  547. package/dist/esm/tools/subagent/SubagentReplay.mjs.map +1 -1
  548. package/dist/esm/tools/subagent/childGraphConfig.mjs +0 -4
  549. package/dist/esm/tools/subagent/childGraphConfig.mjs.map +1 -1
  550. package/dist/esm/tools/subagent/runtimeLimits.mjs.map +1 -1
  551. package/dist/esm/tools/toolOutputReferences.mjs +1 -322
  552. package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
  553. package/dist/esm/types/hitl.mjs +0 -5
  554. package/dist/esm/types/hitl.mjs.map +1 -1
  555. package/dist/esm/utils/callbacks.mjs.map +1 -1
  556. package/dist/esm/utils/errors.mjs +14 -165
  557. package/dist/esm/utils/errors.mjs.map +1 -1
  558. package/dist/esm/utils/events.mjs +0 -10
  559. package/dist/esm/utils/events.mjs.map +1 -1
  560. package/dist/esm/utils/graph.mjs.map +1 -1
  561. package/dist/esm/utils/handlers.mjs +0 -3
  562. package/dist/esm/utils/handlers.mjs.map +1 -1
  563. package/dist/esm/utils/llm.mjs +0 -1
  564. package/dist/esm/utils/llm.mjs.map +1 -1
  565. package/dist/esm/utils/misc.mjs +0 -16
  566. package/dist/esm/utils/misc.mjs.map +1 -1
  567. package/dist/esm/utils/proxy.mjs +0 -26
  568. package/dist/esm/utils/proxy.mjs.map +1 -1
  569. package/dist/esm/utils/run.mjs +0 -6
  570. package/dist/esm/utils/run.mjs.map +1 -1
  571. package/dist/esm/utils/schema.mjs +0 -5
  572. package/dist/esm/utils/schema.mjs.map +1 -1
  573. package/dist/esm/utils/title.mjs +0 -6
  574. package/dist/esm/utils/title.mjs.map +1 -1
  575. package/dist/esm/utils/tokens.mjs +0 -113
  576. package/dist/esm/utils/tokens.mjs.map +1 -1
  577. package/dist/esm/utils/toolContent.mjs +0 -41
  578. package/dist/esm/utils/toolContent.mjs.map +1 -1
  579. package/dist/esm/utils/truncation.mjs +0 -61
  580. package/dist/esm/utils/truncation.mjs.map +1 -1
  581. package/package.json +35 -32
  582. package/dist/types/agents/__tests__/promptCacheLiveHelpers.d.ts +0 -52
  583. package/dist/types/test/mockTools.d.ts +0 -28
  584. package/dist/types/utils/__tests__/fixtures/contextOverflowSignatures.d.ts +0 -40
  585. package/src/__tests__/stream.eagerArgsDivergence.test.ts +0 -911
  586. package/src/__tests__/stream.eagerEventExecution.test.ts +0 -5046
  587. package/src/__tests__/stream.streamLimits.test.ts +0 -1982
  588. package/src/agents/__tests__/AgentContext.anthropic.live.test.ts +0 -448
  589. package/src/agents/__tests__/AgentContext.bedrock.live.test.ts +0 -655
  590. package/src/agents/__tests__/AgentContext.openrouter.live.test.ts +0 -128
  591. package/src/agents/__tests__/AgentContext.overflow.test.ts +0 -205
  592. package/src/agents/__tests__/AgentContext.test.ts +0 -2425
  593. package/src/agents/__tests__/projection.test.ts +0 -73
  594. package/src/agents/__tests__/promptCacheLiveHelpers.ts +0 -175
  595. package/src/aggregator.test.ts +0 -1214
  596. package/src/graphs/__tests__/Graph.breakerLifecycle.test.ts +0 -273
  597. package/src/graphs/__tests__/Graph.closeRunStep.test.ts +0 -385
  598. package/src/graphs/__tests__/Graph.contextOverflow.test.ts +0 -1766
  599. package/src/graphs/__tests__/Graph.preemptSignal.test.ts +0 -126
  600. package/src/graphs/__tests__/Graph.reasoning.test.ts +0 -1717
  601. package/src/graphs/__tests__/Graph.subagentResumeState.test.ts +0 -80
  602. package/src/graphs/__tests__/MultiAgentGraph.test.ts +0 -177
  603. package/src/graphs/__tests__/composition.smoke.test.ts +0 -509
  604. package/src/graphs/__tests__/createGraph.test.ts +0 -206
  605. package/src/hooks/__tests__/HookRegistry.test.ts +0 -334
  606. package/src/hooks/__tests__/compactHooks.test.ts +0 -250
  607. package/src/hooks/__tests__/createToolPolicyHook.test.ts +0 -268
  608. package/src/hooks/__tests__/createWorkspacePolicyHook.test.ts +0 -405
  609. package/src/hooks/__tests__/executeHooks.test.ts +0 -1294
  610. package/src/hooks/__tests__/integration.test.ts +0 -337
  611. package/src/hooks/__tests__/matchers.test.ts +0 -238
  612. package/src/hooks/__tests__/preemptBoundary.test.ts +0 -152
  613. package/src/hooks/__tests__/toolHooks.test.ts +0 -669
  614. package/src/llm/__tests__/contextOverflowRecovery.test.ts +0 -401
  615. package/src/llm/__tests__/fallbackOverflow.test.ts +0 -287
  616. package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
  617. package/src/llm/anthropic/inherited-content-utils.spec.ts +0 -249
  618. package/src/llm/anthropic/inherited-stream-events.spec.ts +0 -1259
  619. package/src/llm/anthropic/inherited-strict.spec.ts +0 -302
  620. package/src/llm/anthropic/llm.spec.ts +0 -3394
  621. package/src/llm/anthropic/utils/cross-provider-reasoning.test.ts +0 -383
  622. package/src/llm/anthropic/utils/cross-provider-server-tools.test.ts +0 -110
  623. package/src/llm/anthropic/utils/server-tool-inputs.test.ts +0 -508
  624. package/src/llm/anthropic/utils/streaming-tool-input.test.ts +0 -361
  625. package/src/llm/anthropic/utils/stripPrefillCache.test.ts +0 -111
  626. package/src/llm/anthropic/utils/tool-id-normalization.test.ts +0 -287
  627. package/src/llm/bedrock/inherited-cache.spec.ts +0 -144
  628. package/src/llm/bedrock/inherited.spec.ts +0 -724
  629. package/src/llm/bedrock/llm.spec.ts +0 -1533
  630. package/src/llm/bedrock/streamSealDispatch.test.ts +0 -331
  631. package/src/llm/bedrock/toolCache.test.ts +0 -194
  632. package/src/llm/bedrock/utils/cross-provider-reasoning.test.ts +0 -131
  633. package/src/llm/bedrock/utils/cross-provider-server-tools.test.ts +0 -122
  634. package/src/llm/bedrock/utils/message_inputs.test.ts +0 -650
  635. package/src/llm/bedrock/utils/message_outputs.test.ts +0 -85
  636. package/src/llm/bedrock/utils/toolResultCachePoint.test.ts +0 -118
  637. package/src/llm/custom-chat-models.smoke.test.ts +0 -1966
  638. package/src/llm/google/data/gettysburg10.wav +0 -0
  639. package/src/llm/google/data/hotdog.jpg +0 -0
  640. package/src/llm/google/inherited-stream-events.spec.ts +0 -350
  641. package/src/llm/google/llm.spec.ts +0 -1388
  642. package/src/llm/google/streamSmoothing.test.ts +0 -121
  643. package/src/llm/google/utils/common.test.ts +0 -196
  644. package/src/llm/invoke.alternation.test.ts +0 -87
  645. package/src/llm/invoke.handoffCue.test.ts +0 -112
  646. package/src/llm/invoke.streamLimits.test.ts +0 -142
  647. package/src/llm/invoke.test.ts +0 -1198
  648. package/src/llm/mistral/streamSmoothing.test.ts +0 -97
  649. package/src/llm/openai/cacheWriteTokens.test.ts +0 -112
  650. package/src/llm/openai/contentBlocks.test.ts +0 -381
  651. package/src/llm/openai/deepseek.test.ts +0 -747
  652. package/src/llm/openai/inherited-deepseek.spec.ts +0 -347
  653. package/src/llm/openai/inherited-xai.spec.ts +0 -416
  654. package/src/llm/openai/llm.spec.ts +0 -1774
  655. package/src/llm/openai/managedRequests.test.ts +0 -182
  656. package/src/llm/openai/sequentialToolCallSeals.test.ts +0 -199
  657. package/src/llm/openai/streamMetadata.spec.ts +0 -86
  658. package/src/llm/openai/streamMetadataDedup.spec.ts +0 -166
  659. package/src/llm/openai/utils/isReasoningModel.test.ts +0 -90
  660. package/src/llm/openai/utils/messages.test.ts +0 -488
  661. package/src/llm/openrouter/reasoning.test.ts +0 -561
  662. package/src/llm/openrouter/toolCache.test.ts +0 -134
  663. package/src/llm/preempt.test.ts +0 -323
  664. package/src/llm/stream/chunkAdapters.test.ts +0 -202
  665. package/src/llm/stream/reassembly.test.ts +0 -241
  666. package/src/llm/stream/smoother.bench.test.ts +0 -155
  667. package/src/llm/stream/smoother.test.ts +0 -519
  668. package/src/llm/streamLimits.test.ts +0 -450
  669. package/src/llm/truncation.test.ts +0 -242
  670. package/src/llm/vertexai/fixThoughtSignatures.test.ts +0 -154
  671. package/src/llm/vertexai/inherited-stream-events.spec.ts +0 -271
  672. package/src/llm/vertexai/llm.spec.ts +0 -159
  673. package/src/llm/vertexai/repairUsageMetadata.test.ts +0 -54
  674. package/src/llm/vertexai/sealStreamedToolCalls.test.ts +0 -88
  675. package/src/llm/vertexai/streamSealDispatch.test.ts +0 -148
  676. package/src/llm/vertexai/streamSmoothing.test.ts +0 -109
  677. package/src/messages/__tests__/anthropicToolCache.test.ts +0 -339
  678. package/src/messages/__tests__/observationMasking.test.ts +0 -312
  679. package/src/messages/__tests__/recency.test.ts +0 -267
  680. package/src/messages/__tests__/tools.test.ts +0 -473
  681. package/src/messages/alternation.test.ts +0 -212
  682. package/src/messages/assistantPhase.test.ts +0 -75
  683. package/src/messages/cache.tail.test.ts +0 -533
  684. package/src/messages/cache.test.ts +0 -2166
  685. package/src/messages/content.test.ts +0 -362
  686. package/src/messages/contextPruning.test.ts +0 -184
  687. package/src/messages/ensureThinkingBlock.test.ts +0 -1427
  688. package/src/messages/foldToollessToolBlocks.test.ts +0 -596
  689. package/src/messages/formatAgentMessages.reducer.test.ts +0 -162
  690. package/src/messages/formatAgentMessages.skills.test.ts +0 -513
  691. package/src/messages/formatAgentMessages.steer.test.ts +0 -598
  692. package/src/messages/formatAgentMessages.test.ts +0 -8111
  693. package/src/messages/formatAgentMessages.tools.test.ts +0 -522
  694. package/src/messages/formatMessage.test.ts +0 -693
  695. package/src/messages/handoffCue.test.ts +0 -96
  696. package/src/messages/injected.test.ts +0 -107
  697. package/src/messages/labelContentByAgent.test.ts +0 -962
  698. package/src/messages/reducer.spec.ts +0 -32
  699. package/src/messages/shiftIndexTokenCountMap.test.ts +0 -81
  700. package/src/messages/tailCacheConversion.test.ts +0 -161
  701. package/src/openai/__tests__/openai.test.ts +0 -337
  702. package/src/responses/__tests__/responses.test.ts +0 -652
  703. package/src/scripts/abort.ts +0 -157
  704. package/src/scripts/activity-labels/captured.json +0 -56
  705. package/src/scripts/activity-labels/checks.cjs +0 -205
  706. package/src/scripts/activity-labels/corpus.cjs +0 -473
  707. package/src/scripts/activity-labels/report.cjs +0 -203
  708. package/src/scripts/activity-labels/rescore.cjs +0 -102
  709. package/src/scripts/activity-labels/run.ts +0 -705
  710. package/src/scripts/activity-labels/variants.ts +0 -71
  711. package/src/scripts/ant_web_search.ts +0 -159
  712. package/src/scripts/ant_web_search_edge_case.ts +0 -163
  713. package/src/scripts/ant_web_search_error_edge_case.ts +0 -149
  714. package/src/scripts/args.ts +0 -48
  715. package/src/scripts/bedrock-cache-debug.ts +0 -250
  716. package/src/scripts/bedrock-content-aggregation-test.ts +0 -266
  717. package/src/scripts/bedrock-merge-test.ts +0 -107
  718. package/src/scripts/bedrock-parallel-tools-test.ts +0 -204
  719. package/src/scripts/bench-prompt-cache.ts +0 -479
  720. package/src/scripts/caching.ts +0 -132
  721. package/src/scripts/cli.ts +0 -172
  722. package/src/scripts/cli2.ts +0 -133
  723. package/src/scripts/cli3.ts +0 -184
  724. package/src/scripts/cli4.ts +0 -191
  725. package/src/scripts/cli5.ts +0 -191
  726. package/src/scripts/code_exec.ts +0 -214
  727. package/src/scripts/code_exec_files.ts +0 -237
  728. package/src/scripts/code_exec_multi_session.ts +0 -237
  729. package/src/scripts/code_exec_ptc.ts +0 -335
  730. package/src/scripts/code_exec_session.ts +0 -283
  731. package/src/scripts/code_exec_simple.ts +0 -148
  732. package/src/scripts/compare_pi_vs_ours.ts +0 -1259
  733. package/src/scripts/content.ts +0 -139
  734. package/src/scripts/context-overflow-probe.ts +0 -997
  735. package/src/scripts/empty_input.ts +0 -137
  736. package/src/scripts/handoff-test.ts +0 -134
  737. package/src/scripts/local_engine.ts +0 -166
  738. package/src/scripts/local_engine_checkpointer.ts +0 -205
  739. package/src/scripts/local_engine_compile.ts +0 -263
  740. package/src/scripts/local_engine_hooks.ts +0 -226
  741. package/src/scripts/local_engine_image.ts +0 -201
  742. package/src/scripts/local_engine_ptc.ts +0 -151
  743. package/src/scripts/local_engine_workspace.ts +0 -258
  744. package/src/scripts/memory.ts +0 -107
  745. package/src/scripts/multi-agent-chain.ts +0 -332
  746. package/src/scripts/multi-agent-conditional.ts +0 -222
  747. package/src/scripts/multi-agent-document-review-chain.ts +0 -198
  748. package/src/scripts/multi-agent-hybrid-flow.ts +0 -311
  749. package/src/scripts/multi-agent-parallel-start.ts +0 -265
  750. package/src/scripts/multi-agent-parallel.ts +0 -395
  751. package/src/scripts/multi-agent-sequence.ts +0 -217
  752. package/src/scripts/multi-agent-subagent.ts +0 -246
  753. package/src/scripts/multi-agent-supervisor.ts +0 -366
  754. package/src/scripts/multi-agent-test.ts +0 -187
  755. package/src/scripts/openrouter_prompt_cache_live.ts +0 -310
  756. package/src/scripts/parallel-asymmetric-tools-test.ts +0 -275
  757. package/src/scripts/parallel-full-metadata-test.ts +0 -241
  758. package/src/scripts/parallel-tools-test.ts +0 -341
  759. package/src/scripts/preempt-probe.ts +0 -330
  760. package/src/scripts/preempt-scenarios.ts +0 -388
  761. package/src/scripts/programmatic_exec.ts +0 -387
  762. package/src/scripts/programmatic_exec_agent.ts +0 -232
  763. package/src/scripts/search.ts +0 -147
  764. package/src/scripts/sequential-full-metadata-test.ts +0 -198
  765. package/src/scripts/session_live.ts +0 -548
  766. package/src/scripts/simple.ts +0 -226
  767. package/src/scripts/single-agent-metadata-test.ts +0 -196
  768. package/src/scripts/stream.ts +0 -141
  769. package/src/scripts/subagent-configurable-inheritance.ts +0 -252
  770. package/src/scripts/subagent-event-driven-debug.ts +0 -190
  771. package/src/scripts/subagent-tools-debug.ts +0 -160
  772. package/src/scripts/subagent-usage-sink.ts +0 -176
  773. package/src/scripts/summarization-recency.ts +0 -462
  774. package/src/scripts/test-custom-prompt-key.ts +0 -145
  775. package/src/scripts/test-handoff-input.ts +0 -170
  776. package/src/scripts/test-handoff-preamble.ts +0 -278
  777. package/src/scripts/test-handoff-steering.ts +0 -430
  778. package/src/scripts/test-multi-agent-list-handoff.ts +0 -418
  779. package/src/scripts/test-parallel-agent-labeling.ts +0 -327
  780. package/src/scripts/test-parallel-handoffs.ts +0 -292
  781. package/src/scripts/test-thinking-handoff-bedrock.ts +0 -154
  782. package/src/scripts/test-thinking-handoff.ts +0 -156
  783. package/src/scripts/test-thinking-to-thinking-handoff-bedrock.ts +0 -166
  784. package/src/scripts/test-tool-before-handoff-role-order.ts +0 -276
  785. package/src/scripts/test-tools-before-handoff.ts +0 -222
  786. package/src/scripts/test_code_api.ts +0 -354
  787. package/src/scripts/thinking-bedrock.ts +0 -160
  788. package/src/scripts/thinking-vertexai.ts +0 -168
  789. package/src/scripts/thinking.ts +0 -172
  790. package/src/scripts/tool_search.ts +0 -153
  791. package/src/scripts/tools.ts +0 -163
  792. package/src/session/__tests__/JsonlSessionStore.test.ts +0 -1463
  793. package/src/session/__tests__/handlers.test.ts +0 -161
  794. package/src/specs/activity-label-observability.live.test.ts +0 -262
  795. package/src/specs/activity-label-observability.test.ts +0 -167
  796. package/src/specs/activity-label-prompt.test.ts +0 -359
  797. package/src/specs/activity-label-trace-seed.test.ts +0 -47
  798. package/src/specs/activity-phase-label.test.ts +0 -306
  799. package/src/specs/agent-handoffs.live.test.ts +0 -140
  800. package/src/specs/agent-handoffs.test.ts +0 -2465
  801. package/src/specs/anthropic.simple.test.ts +0 -453
  802. package/src/specs/ask-user-question-batch.test.ts +0 -289
  803. package/src/specs/ask-user-questions.live.test.ts +0 -185
  804. package/src/specs/ask-user-questions.test.ts +0 -293
  805. package/src/specs/azure.simple.test.ts +0 -502
  806. package/src/specs/bedrock-toolless.live.test.ts +0 -123
  807. package/src/specs/bedrock-truncation.live.test.ts +0 -191
  808. package/src/specs/cache.simple.test.ts +0 -416
  809. package/src/specs/context-accuracy.live.test.ts +0 -409
  810. package/src/specs/context-overflow-recovery.live.test.ts +0 -213
  811. package/src/specs/context-usage-event.test.ts +0 -117
  812. package/src/specs/context-usage.live.test.ts +0 -297
  813. package/src/specs/custom-event-await.test.ts +0 -304
  814. package/src/specs/deepseek.simple.test.ts +0 -290
  815. package/src/specs/deterministic-trace-id.test.ts +0 -43
  816. package/src/specs/discovered-tools.test.ts +0 -217
  817. package/src/specs/durability-checkpoint.integration.test.ts +0 -243
  818. package/src/specs/graph-subagent.live.test.ts +0 -242
  819. package/src/specs/graph-subagent.test.ts +0 -322
  820. package/src/specs/handoffCue.test.ts +0 -165
  821. package/src/specs/langfuse-callbacks.test.ts +0 -1578
  822. package/src/specs/langfuse-config.test.ts +0 -247
  823. package/src/specs/langfuse-instrumentation.test.ts +0 -393
  824. package/src/specs/langfuse-metadata.test.ts +0 -245
  825. package/src/specs/langfuse-routing.integration.test.ts +0 -844
  826. package/src/specs/langfuse-runtime-context.test.ts +0 -92
  827. package/src/specs/langfuse-span-registry.test.ts +0 -87
  828. package/src/specs/langfuse-tool-output-tracing.test.ts +0 -1858
  829. package/src/specs/langfuse-trace-shaping.test.ts +0 -591
  830. package/src/specs/moonshot.simple.test.ts +0 -367
  831. package/src/specs/multi-agent-summarization.test.ts +0 -396
  832. package/src/specs/openai.simple.test.ts +0 -315
  833. package/src/specs/openrouter.simple.test.ts +0 -275
  834. package/src/specs/preemptSeal.test.ts +0 -678
  835. package/src/specs/prune.test.ts +0 -3741
  836. package/src/specs/reasoning.test.ts +0 -201
  837. package/src/specs/run-step-timestamps.test.ts +0 -414
  838. package/src/specs/spec.utils.ts +0 -15
  839. package/src/specs/subagent.test.ts +0 -864
  840. package/src/specs/summarization-unit.test.ts +0 -973
  841. package/src/specs/summarization.test.ts +0 -3823
  842. package/src/specs/summarize-prune.test.ts +0 -376
  843. package/src/specs/thinking-handoff.test.ts +0 -621
  844. package/src/specs/thinking-prune.test.ts +0 -827
  845. package/src/specs/token-accounting-e2e.test.ts +0 -1034
  846. package/src/specs/token-accounting-pipeline.test.ts +0 -1008
  847. package/src/specs/token-distribution-edge-case.test.ts +0 -315
  848. package/src/specs/token-memoization.test.ts +0 -40
  849. package/src/specs/tokens.test.ts +0 -1000
  850. package/src/specs/tool-error-resume.test.ts +0 -194
  851. package/src/specs/tool-error.test.ts +0 -198
  852. package/src/specs/vllm-reasoning-toolcalls.test.ts +0 -340
  853. package/src/stream.dispatch.test.ts +0 -63
  854. package/src/stream.test.ts +0 -144
  855. package/src/summarization/__tests__/aggregator.test.ts +0 -236
  856. package/src/summarization/__tests__/node.test.ts +0 -1996
  857. package/src/summarization/__tests__/trigger.test.ts +0 -149
  858. package/src/summarization/chunkHandler.test.ts +0 -196
  859. package/src/test/mockTools.ts +0 -386
  860. package/src/tools/Calculator.test.ts +0 -278
  861. package/src/tools/__tests__/BashExecutor.test.ts +0 -108
  862. package/src/tools/__tests__/CloudflareSandboxExecution.test.ts +0 -939
  863. package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +0 -858
  864. package/src/tools/__tests__/CodeExecutor.stateful.test.ts +0 -124
  865. package/src/tools/__tests__/LocalExecutionRoots.test.ts +0 -8
  866. package/src/tools/__tests__/LocalExecutionTools.test.ts +0 -2733
  867. package/src/tools/__tests__/ProgrammaticToolCalling.integration.test.ts +0 -318
  868. package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +0 -1557
  869. package/src/tools/__tests__/ReadFile.test.ts +0 -44
  870. package/src/tools/__tests__/SkillTool.test.ts +0 -442
  871. package/src/tools/__tests__/SubagentExecutor.test.ts +0 -3728
  872. package/src/tools/__tests__/SubagentReplay.test.ts +0 -329
  873. package/src/tools/__tests__/SubagentTool.test.ts +0 -149
  874. package/src/tools/__tests__/ToolNode.breakerSignal.test.ts +0 -595
  875. package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +0 -1191
  876. package/src/tools/__tests__/ToolNode.invalidToolCalls.test.ts +0 -757
  877. package/src/tools/__tests__/ToolNode.langfuse.test.ts +0 -57
  878. package/src/tools/__tests__/ToolNode.onResultCompletion.test.ts +0 -736
  879. package/src/tools/__tests__/ToolNode.outputReferences.test.ts +0 -1710
  880. package/src/tools/__tests__/ToolNode.runtimeState.test.ts +0 -120
  881. package/src/tools/__tests__/ToolNode.session.test.ts +0 -1352
  882. package/src/tools/__tests__/ToolNode.streamLimits.test.ts +0 -69
  883. package/src/tools/__tests__/ToolSearch.integration.test.ts +0 -161
  884. package/src/tools/__tests__/ToolSearch.test.ts +0 -1227
  885. package/src/tools/__tests__/annotateMessagesForLLM.test.ts +0 -561
  886. package/src/tools/__tests__/directToolHITLResumeScope.test.ts +0 -980
  887. package/src/tools/__tests__/directToolHooks.test.ts +0 -700
  888. package/src/tools/__tests__/eagerEventExecution.session.test.ts +0 -92
  889. package/src/tools/__tests__/handlers.test.ts +0 -997
  890. package/src/tools/__tests__/hitl.test.ts +0 -4663
  891. package/src/tools/__tests__/intentArg.test.ts +0 -357
  892. package/src/tools/__tests__/intentCoverage.test.ts +0 -139
  893. package/src/tools/__tests__/localToolNames.test.ts +0 -75
  894. package/src/tools/__tests__/skillCatalog.test.ts +0 -161
  895. package/src/tools/__tests__/subagentHooks.test.ts +0 -1651
  896. package/src/tools/__tests__/toolOutputReferences.test.ts +0 -515
  897. package/src/tools/__tests__/workspaceSeam.test.ts +0 -147
  898. package/src/tools/local/__tests__/FileCheckpointer.test.ts +0 -162
  899. package/src/tools/local/__tests__/editStrategies.test.ts +0 -134
  900. package/src/tools/search/content.test.ts +0 -173
  901. package/src/tools/search/crw.test.ts +0 -836
  902. package/src/tools/search/format.test.ts +0 -242
  903. package/src/tools/search/http-agent.test.ts +0 -133
  904. package/src/tools/search/jina-reranker.test.ts +0 -306
  905. package/src/tools/search/keenable-scraper.test.ts +0 -153
  906. package/src/tools/search/keenable.test.ts +0 -183
  907. package/src/tools/search/outcome.test.ts +0 -90
  908. package/src/tools/search/output.md +0 -2775
  909. package/src/tools/search/rag-api-reranker.test.ts +0 -891
  910. package/src/tools/search/source-processing.test.ts +0 -516
  911. package/src/tools/search/tavily.test.ts +0 -965
  912. package/src/tools/search/test.html +0 -884
  913. package/src/tools/search/test.md +0 -643
  914. package/src/tools/subagent/__tests__/SubagentExecutionRegistry.test.ts +0 -637
  915. package/src/tools/subagent/__tests__/SubagentExecutor.lazy.test.ts +0 -3054
  916. package/src/tools/subagent/__tests__/childGraphConfig.test.ts +0 -521
  917. package/src/utils/__tests__/apportion.test.ts +0 -32
  918. package/src/utils/__tests__/errors.test.ts +0 -270
  919. package/src/utils/__tests__/fixtures/contextOverflowSignatures.ts +0 -336
  920. package/src/utils/__tests__/redactSecrets.test.ts +0 -56
  921. package/src/utils/__tests__/truncation.test.ts +0 -66
  922. package/src/utils/llm.test.ts +0 -18
  923. package/src/utils/proxy.test.ts +0 -176
  924. package/src/utils/toolContent.test.ts +0 -1432
@@ -1 +1 @@
1
- {"version":3,"file":"LocalCodingTools.mjs","names":["input"],"sources":["../../../../src/tools/local/LocalCodingTools.ts"],"sourcesContent":["import { basename, dirname } from 'path';\nimport { createTwoFilesPatch } from 'diff';\nimport { tool } from '@langchain/core/tools';\nimport type { DynamicStructuredTool } from '@langchain/core/tools';\nimport type * as t from '@/types';\nimport {\n createLocalBashProgrammaticToolCallingTool,\n createLocalProgrammaticToolCallingTool,\n} from './LocalProgrammaticToolCalling';\nimport {\n getSpawn,\n getWorkspaceFS,\n resolveWorkspacePathSafe,\n spawnLocalProcess,\n truncateLocalOutput,\n} from './LocalExecutionEngine';\nimport {\n createLocalBashExecutionTool,\n createLocalCodeExecutionTool,\n} from './LocalExecutionTools';\nimport {\n createCompileCheckTool,\n createCompileCheckToolDefinition,\n} from './CompileCheckTool';\nimport { classifyAttachment, imageAttachmentContent } from './attachments';\nimport { createLocalFileCheckpointer } from './FileCheckpointer';\nimport { isWorkspaceClientTimeoutError } from './workspaceFS';\nimport { applyEdit, locateEdit } from './editStrategies';\nimport { decodeFile, encodeFile } from './textEncoding';\nimport { runPostEditSyntaxCheck } from './syntaxCheck';\nimport { withIntent } from '@/tools/intentArg';\nimport { Constants } from '@/common';\n\nconst MAX_READ_CHARS = 256000;\nconst DEFAULT_MAX_RESULTS = 200;\nconst DEFAULT_MAX_READ_BYTES = 10 * 1024 * 1024;\nconst BINARY_DETECTION_BYTES = 8000;\n\n/**\n * Tool name aliases retained for back-compat with consumers that imported\n * the per-file `Local*ToolName` constants. The canonical names live on\n * `Constants.*` (see `src/common/enum.ts`); these aliases just point at\n * them so a typo upstream gets caught at the type level.\n */\nexport const LocalWriteFileToolName = Constants.WRITE_FILE;\nexport const LocalEditFileToolName = Constants.EDIT_FILE;\nexport const LocalGrepSearchToolName = Constants.GREP_SEARCH;\nexport const LocalGlobSearchToolName = Constants.GLOB_SEARCH;\nexport const LocalListDirectoryToolName = Constants.LIST_DIRECTORY;\n\nexport const LocalReadFileToolSchema: t.JsonSchemaType = withIntent({\n type: 'object',\n properties: {\n path: {\n type: 'string',\n description:\n 'Path to a local file, relative to the configured cwd unless absolute paths are allowed.',\n },\n offset: {\n type: 'integer',\n description: 'Optional 1-indexed line offset for large files.',\n },\n limit: {\n type: 'integer',\n description: 'Optional maximum number of lines to return.',\n },\n },\n required: ['path'],\n});\n\nexport const LocalWriteFileToolSchema: t.JsonSchemaType = withIntent({\n type: 'object',\n properties: {\n path: {\n type: 'string',\n description:\n 'Path to write, relative to the configured cwd unless absolute paths are allowed.',\n },\n content: {\n type: 'string',\n description: 'Complete file contents to write.',\n },\n },\n required: ['path', 'content'],\n});\n\nexport const LocalEditFileToolSchema: t.JsonSchemaType = withIntent({\n type: 'object',\n properties: {\n path: {\n type: 'string',\n description:\n 'Path to edit, relative to the configured cwd unless absolute paths are allowed.',\n },\n old_text: {\n type: 'string',\n description: 'Exact text to replace. Must appear exactly once.',\n },\n new_text: {\n type: 'string',\n description: 'Replacement text.',\n },\n edits: {\n type: 'array',\n description:\n 'Optional batch of exact replacements. Each old_text must appear exactly once in the original file.',\n items: {\n type: 'object',\n properties: {\n old_text: { type: 'string' },\n new_text: { type: 'string' },\n },\n required: ['old_text', 'new_text'],\n },\n },\n },\n required: ['path'],\n});\n\nexport const LocalGrepSearchToolSchema: t.JsonSchemaType = withIntent({\n type: 'object',\n properties: {\n pattern: {\n type: 'string',\n description: 'Regex pattern to search for.',\n },\n path: {\n type: 'string',\n description: 'Directory or file to search. Defaults to cwd.',\n },\n glob: {\n type: 'string',\n description: 'Optional file glob passed to rg -g.',\n },\n max_results: {\n type: 'integer',\n description: 'Maximum matching lines to return.',\n },\n },\n required: ['pattern'],\n});\n\nexport const LocalGlobSearchToolSchema: t.JsonSchemaType = withIntent({\n type: 'object',\n properties: {\n pattern: {\n type: 'string',\n description: 'File glob pattern, for example \"src/**/*.ts\".',\n },\n path: {\n type: 'string',\n description: 'Directory to search. Defaults to cwd.',\n },\n max_results: {\n type: 'integer',\n description: 'Maximum file paths to return.',\n },\n },\n required: ['pattern'],\n});\n\nexport const LocalListDirectoryToolSchema: t.JsonSchemaType = withIntent({\n type: 'object',\n properties: {\n path: {\n type: 'string',\n description: 'Directory to list. Defaults to cwd.',\n },\n },\n});\n\nfunction lineWindow(\n content: string,\n offset?: number,\n limit?: number\n): { text: string; truncated: boolean } {\n const start = Math.max((offset ?? 1) - 1, 0);\n // Avoid splitting the whole file when the caller asked for a small\n // window. For a 10 MB file with `offset: 1, limit: 10`, the prior\n // `content.split('\\n')` allocated millions of strings to throw all\n // but 10 away. We walk newline indices directly: O(start + limit)\n // instead of O(file). When `limit` is omitted, fall back to the\n // simple split — it's the same amount of work either way.\n if (limit == null || limit <= 0) {\n const lines = content.split('\\n');\n const selected = lines.slice(start);\n const numbered = selected\n .map(\n (line, index) =>\n `${String(start + index + 1).padStart(6, ' ')}\\t${line}`\n )\n .join('\\n');\n return {\n text: truncateLocalOutput(numbered, MAX_READ_CHARS),\n truncated: numbered.length > MAX_READ_CHARS,\n };\n }\n // Walk to the start line by counting newlines.\n let cursor = 0;\n for (let i = 0; i < start; i++) {\n const next = content.indexOf('\\n', cursor);\n if (next === -1) {\n // File has fewer lines than `offset` — return empty window.\n return { text: '', truncated: false };\n }\n cursor = next + 1;\n }\n // Collect up to `limit` lines from `cursor`.\n const out: string[] = [];\n let pos = cursor;\n let exhausted = true;\n for (let k = 0; k < limit; k++) {\n const next = content.indexOf('\\n', pos);\n if (next === -1) {\n out.push(content.slice(pos));\n break;\n }\n out.push(content.slice(pos, next));\n pos = next + 1;\n if (k === limit - 1 && pos < content.length) {\n exhausted = false;\n }\n }\n const numbered = out\n .map(\n (text, index) => `${String(start + index + 1).padStart(6, ' ')}\\t${text}`\n )\n .join('\\n');\n return {\n text: truncateLocalOutput(numbered, MAX_READ_CHARS),\n truncated: !exhausted || numbered.length > MAX_READ_CHARS,\n };\n}\n\nconst MAX_DIFF_CHARS = 4000;\n\ntype SyntaxRun =\n | {\n mode: 'auto' | 'strict';\n outcome: import('./syntaxCheck').SyntaxCheckOutcome;\n }\n | undefined;\n\nasync function maybeRunSyntaxCheck(\n path: string,\n config: t.LocalExecutionConfig\n): Promise<SyntaxRun> {\n const mode = config.postEditSyntaxCheck ?? 'off';\n if (mode === 'off') return undefined;\n const outcome = await runPostEditSyntaxCheck(path, config);\n if (outcome == null) return undefined;\n return { mode, outcome };\n}\n\nfunction appendSyntaxCheckSummary(base: string, run: SyntaxRun): string {\n if (run == null) return base;\n if (run.outcome.ok) return base;\n const banner =\n run.mode === 'strict'\n ? `\\n\\n[syntax-check FAILED via ${run.outcome.checker}]\\n`\n : `\\n\\n[syntax-check warning via ${run.outcome.checker}]\\n`;\n return `${base}${banner}${run.outcome.output}`;\n}\n\n/**\n * Revert a write_file/edit_file mutation in `postEditSyntaxCheck:\n * 'strict'` mode after the post-write syntax check failed. Strict\n * mode advertises a safety gate, so leaving the corrupted file on\n * disk + throwing is a half-broken contract — the model \"reacts\" to\n * the error but the next call sees broken on-disk state. Codex P2\n * [49]. Best-effort: a swallowed error here means the workspace is\n * still in the bad post-write state, but we still throw the\n * original syntax-check error so the caller knows.\n *\n * - If the file existed pre-write: restore the previous bytes with\n * the original encoding.\n * - If the file is brand-new: unlink it.\n */\nasync function revertStrictWrite(\n fs: import('./workspaceFS').WorkspaceFS,\n path: string,\n existed: boolean,\n before: string,\n encoding: { text: string; hasBom: boolean; newline: '\\n' | '\\r\\n' }\n): Promise<void> {\n try {\n if (existed) {\n // encodeFile uses encoding.{hasBom,newline} to restore the\n // on-disk shape; the `text` field is overridden by the\n // explicit `before` arg we pass in.\n await fs.writeFile(\n path,\n encodeFile(before, { ...encoding, text: before }),\n 'utf8'\n );\n } else {\n await fs.unlink(path);\n }\n } catch (error) {\n // A timed-out revert leaves the rejected write on disk — the caller would\n // otherwise claim \"reverted to pre-write state\" while the bad bytes remain.\n // Surface it; for other failures stay best-effort (caller sees the original\n // syntax error).\n if (isWorkspaceClientTimeoutError(error)) {\n throw error;\n }\n }\n}\n\nfunction summariseDiff(\n filePath: string,\n before: string,\n after: string\n): string {\n if (before === after) {\n return '(no textual changes)';\n }\n const name = basename(filePath);\n const patch = createTwoFilesPatch(name, name, before, after, '', '', {\n context: 3,\n });\n if (patch.length <= MAX_DIFF_CHARS) {\n return patch;\n }\n return (\n patch.slice(0, MAX_DIFF_CHARS) +\n `\\n[... diff truncated, ${patch.length - MAX_DIFF_CHARS} more chars ...]`\n );\n}\n\nfunction normalizeEdits(input: {\n old_text?: string;\n new_text?: string;\n edits?: Array<{ old_text?: string; new_text?: string }>;\n}): Array<{ oldText: string; newText: string }> {\n const edits = Array.isArray(input.edits)\n ? input.edits.map((edit) => ({\n oldText: edit.old_text ?? '',\n newText: edit.new_text ?? '',\n }))\n : [];\n\n if (input.old_text != null || input.new_text != null) {\n edits.push({\n oldText: input.old_text ?? '',\n newText: input.new_text ?? '',\n });\n }\n\n return edits;\n}\n\nfunction toolDefinition(\n name: string,\n description: string,\n parameters: t.JsonSchemaType\n): t.LCTool {\n return {\n name,\n description,\n parameters,\n allowed_callers: ['direct', 'code_execution'],\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n toolType: 'builtin',\n };\n}\n\nasync function looksBinary(\n path: string,\n fs: import('./workspaceFS').WorkspaceFS\n): Promise<boolean> {\n let handle;\n try {\n handle = await fs.open(path, 'r');\n const sample = Buffer.alloc(BINARY_DETECTION_BYTES);\n const { bytesRead } = await handle.read(\n sample,\n 0,\n BINARY_DETECTION_BYTES,\n 0\n );\n for (let i = 0; i < bytesRead; i++) {\n if (sample[i] === 0) {\n return true;\n }\n }\n return false;\n } finally {\n await handle?.close();\n }\n}\n\nconst DEFAULT_MAX_ATTACHMENT_BYTES = 5 * 1024 * 1024;\n\nexport function createLocalReadFileTool(\n config: t.LocalExecutionConfig = {}\n): DynamicStructuredTool {\n const fs = getWorkspaceFS(config);\n return tool(\n async (rawInput) => {\n const input = rawInput as {\n path: string;\n offset?: number;\n limit?: number;\n };\n const path = await resolveWorkspacePathSafe(\n input.path,\n config,\n 'read'\n );\n const fileStat = await fs.stat(path);\n if (!fileStat.isFile()) {\n throw new Error(`Path is not a file: ${input.path}`);\n }\n const maxBytes = Math.max(\n config.maxReadBytes ?? DEFAULT_MAX_READ_BYTES,\n 1\n );\n if (fileStat.size > maxBytes) {\n const stub = `File is ${fileStat.size} bytes, exceeds the ${maxBytes}-byte read cap. Read a slice via bash (e.g. head/sed) or raise local.maxReadBytes.`;\n return [stub, { path, bytes: fileStat.size, truncated: true }];\n }\n\n if (await looksBinary(path, fs)) {\n const attachmentMode = config.attachReadAttachments ?? 'off';\n if (attachmentMode !== 'off') {\n const attachment = await classifyAttachment({\n path,\n bytes: fileStat.size,\n mode: attachmentMode,\n maxBytes: config.maxAttachmentBytes ?? DEFAULT_MAX_ATTACHMENT_BYTES,\n // Route through the configured WorkspaceFS so a custom\n // engine sees the same path semantics as `read_file`\n // itself (manual review finding F).\n fs,\n });\n if (attachment.kind === 'image') {\n return [\n imageAttachmentContent(path, attachment),\n {\n path,\n bytes: fileStat.size,\n mime: attachment.mime,\n attachment: 'image',\n },\n ];\n }\n if (attachment.kind === 'pdf') {\n return [\n [\n {\n type: 'text',\n text: `Read ${path} (application/pdf, ${fileStat.size} bytes). PDF attached as base64 data URL; vision-capable models that accept PDF will render it.`,\n },\n {\n type: 'image_url',\n image_url: { url: attachment.dataUrl },\n },\n ],\n {\n path,\n bytes: fileStat.size,\n mime: attachment.mime,\n attachment: 'pdf',\n },\n ];\n }\n if (attachment.kind === 'oversize') {\n return [\n `Refusing to embed ${attachment.mime} attachment (${attachment.bytes} bytes exceeds ${attachment.maxBytes}-byte cap).`,\n {\n path,\n bytes: fileStat.size,\n mime: attachment.mime,\n attachment: 'oversize',\n },\n ];\n }\n if (attachment.kind === 'binary') {\n return [\n `Refusing to read binary file (${fileStat.size} bytes, ${attachment.mime}): ${path}`,\n {\n path,\n bytes: fileStat.size,\n mime: attachment.mime,\n binary: true,\n },\n ];\n }\n // text-or-unknown falls through to the text-read path below.\n } else {\n return [\n `Refusing to read binary file (${fileStat.size} bytes): ${path}`,\n { path, bytes: fileStat.size, binary: true },\n ];\n }\n }\n\n const content = await fs.readFile(path, 'utf8');\n const result = lineWindow(content, input.offset, input.limit);\n return [\n result.truncated ? `${result.text}\\n[truncated]` : result.text,\n { path, bytes: fileStat.size },\n ];\n },\n {\n name: Constants.READ_FILE,\n description:\n 'Read a local text file from the configured working directory with line numbers. ' +\n 'When `attachReadAttachments` is enabled (e.g. images-only), reading an image returns an ' +\n '`image_url` content block so vision-capable models can see the file directly.',\n schema: LocalReadFileToolSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\nexport function createLocalWriteFileTool(\n config: t.LocalExecutionConfig = {},\n checkpointer?: t.LocalFileCheckpointer\n): DynamicStructuredTool {\n const fs = getWorkspaceFS(config);\n return tool(\n async (rawInput) => {\n const input = rawInput as { path: string; content: string };\n if (config.readOnly === true) {\n throw new Error('write_file is blocked in read-only local mode.');\n }\n const path = await resolveWorkspacePathSafe(\n input.path,\n config,\n 'write'\n );\n if (checkpointer != null) {\n await checkpointer.captureBeforeWrite(path);\n }\n\n let before = '';\n let encoding = { text: '', hasBom: false, newline: '\\n' as const } as\n | ReturnType<typeof decodeFile>\n | { text: string; hasBom: false; newline: '\\n' };\n let existed = false;\n try {\n const raw = await fs.readFile(path, 'utf8');\n const decoded = decodeFile(raw);\n before = decoded.text;\n encoding = decoded;\n existed = true;\n } catch (error) {\n // A stalled-RPC timeout is NOT \"file absent\" — treating it as such would\n // overwrite an existing file with fresh content. Surface it instead.\n if (isWorkspaceClientTimeoutError(error)) {\n throw error;\n }\n existed = false;\n }\n\n await fs.mkdir(dirname(path), { recursive: true });\n const finalText = encodeFile(input.content, encoding);\n await fs.writeFile(path, finalText, 'utf8');\n\n let syntax;\n try {\n syntax = await maybeRunSyntaxCheck(path, config);\n } catch (error) {\n // A validation-read timeout must still honor strict mode's revert\n // contract: restore the pre-write state before surfacing (best-effort —\n // the revert may itself time out on the same stalled container).\n if (\n isWorkspaceClientTimeoutError(error) &&\n config.postEditSyntaxCheck === 'strict'\n ) {\n await revertStrictWrite(fs, path, existed, before, encoding);\n }\n throw error;\n }\n\n const diff = existed\n ? summariseDiff(path, before, input.content)\n : `(new file, ${input.content.length} chars)`;\n const baseSummary = existed\n ? `Overwrote ${path} (${input.content.length} chars). Diff:\\n${diff}`\n : `Created ${path} (${input.content.length} chars).`;\n const summary = appendSyntaxCheckSummary(baseSummary, syntax);\n if (syntax?.outcome.ok === false && syntax.mode === 'strict') {\n // Roll back the write so strict mode is an actual gate, not\n // \"fail the call AND leave the corrupted file on disk\".\n // Codex P2 [49].\n await revertStrictWrite(fs, path, existed, before, encoding);\n throw new Error(\n `write_file syntax check failed (${syntax.outcome.checker}); reverted to pre-write state.\\n${syntax.outcome.output}`\n );\n }\n return [\n summary,\n {\n path,\n bytes: finalText.length,\n new_file: !existed,\n newline: encoding.newline === '\\r\\n' ? 'CRLF' : 'LF',\n had_bom: encoding.hasBom,\n ...(syntax != null && syntax.outcome.ok === false\n ? { syntax_error: syntax.outcome.checker }\n : {}),\n },\n ];\n },\n {\n name: LocalWriteFileToolName,\n description:\n 'Create or overwrite a local text file in the configured working directory. ' +\n 'Preserves the existing BOM and line endings when overwriting; defaults to LF without BOM for new files. ' +\n 'Returns a unified diff of the changes when overwriting.',\n schema: LocalWriteFileToolSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\nexport function createLocalEditFileTool(\n config: t.LocalExecutionConfig = {},\n checkpointer?: t.LocalFileCheckpointer\n): DynamicStructuredTool {\n const fs = getWorkspaceFS(config);\n return tool(\n async (rawInput) => {\n const input = rawInput as {\n path: string;\n old_text?: string;\n new_text?: string;\n edits?: Array<{ old_text?: string; new_text?: string }>;\n };\n if (config.readOnly === true) {\n throw new Error('edit_file is blocked in read-only local mode.');\n }\n const edits = normalizeEdits(input);\n if (edits.length === 0) {\n throw new Error('edit_file requires old_text/new_text or edits[].');\n }\n\n const path = await resolveWorkspacePathSafe(\n input.path,\n config,\n 'write'\n );\n const raw = await fs.readFile(path, 'utf8');\n const encoding = decodeFile(raw);\n const original = encoding.text;\n\n let next = original;\n const strategiesUsed: string[] = [];\n for (let i = 0; i < edits.length; i++) {\n const edit = edits[i];\n const match = locateEdit(next, edit.oldText);\n if (match == null) {\n throw new Error(\n `Edit ${i + 1}/${edits.length}: could not locate old_text in ${input.path}. ` +\n 'Tried exact, line-trimmed, whitespace-normalized, and indentation-flexible matching. ' +\n 'Re-read the file and copy the literal lines.'\n );\n }\n strategiesUsed.push(match.strategy);\n next = applyEdit(next, match, edit.newText);\n }\n\n if (checkpointer != null) {\n await checkpointer.captureBeforeWrite(path);\n }\n const finalText = encodeFile(next, encoding);\n await fs.writeFile(path, finalText, 'utf8');\n\n let syntax;\n try {\n syntax = await maybeRunSyntaxCheck(path, config);\n } catch (error) {\n // As in write_file: a validation-read timeout still triggers strict\n // mode's revert (edit_file always operates on an existing file).\n if (\n isWorkspaceClientTimeoutError(error) &&\n config.postEditSyntaxCheck === 'strict'\n ) {\n await revertStrictWrite(fs, path, true, original, encoding);\n }\n throw error;\n }\n\n const diff = summariseDiff(path, original, next);\n const fuzzy = strategiesUsed.some((s) => s !== 'exact');\n const baseSummary =\n `Applied ${edits.length} edit(s) to ${path}` +\n (fuzzy ? ` (strategies: ${strategiesUsed.join(', ')})` : '') +\n `. Diff:\\n${diff}`;\n const summary = appendSyntaxCheckSummary(baseSummary, syntax);\n if (syntax?.outcome.ok === false && syntax.mode === 'strict') {\n // Restore the pre-edit bytes so strict mode is an actual\n // gate (Codex P2 [49]). edit_file always operates on an\n // existing file, so `existed = true` here.\n await revertStrictWrite(fs, path, true, original, encoding);\n throw new Error(\n `edit_file syntax check failed (${syntax.outcome.checker}); reverted to pre-edit state.\\n${syntax.outcome.output}`\n );\n }\n return [\n summary,\n {\n path,\n edits: edits.length,\n strategies: strategiesUsed,\n newline: encoding.newline === '\\r\\n' ? 'CRLF' : 'LF',\n had_bom: encoding.hasBom,\n ...(syntax != null && syntax.outcome.ok === false\n ? { syntax_error: syntax.outcome.checker }\n : {}),\n },\n ];\n },\n {\n name: LocalEditFileToolName,\n description:\n 'Apply exact text replacements to a local file. The matcher tries exact, line-trimmed, whitespace-normalized, and indentation-flexible strategies in order so common LLM whitespace mistakes are recoverable. Each old_text must still match exactly one location. Returns a unified diff of the changes.',\n schema: LocalEditFileToolSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\n/**\n * Ripgrep availability cache, keyed on the *effective execution\n * backend* — whatever function `getSpawn(config)` returns. Without\n * the backend key, a Run that probes `rg` over Node's\n * `child_process.spawn` would poison subsequent Runs whose\n * `local.exec.spawn` routes to a remote sandbox or container that\n * doesn't have rg installed: the cached `true` would skip the probe,\n * the rg invocation would throw, and the Node fallback wouldn't be\n * reached. Per-backend caching avoids that without paying for a\n * spawn-per-search.\n */\n// Per-backend × per-env cache. Codex P1 #34 — keying by spawn\n// backend alone misses the case where two Runs share a backend but\n// vary `local.env` (especially PATH). Stale cache then claims `rg`\n// is available, the rg path runs, and the spawn fails with ENOENT\n// instead of falling back to the Node walker. The inner Map is\n// keyed by a stable JSON hash of the effective env so each unique\n// env gets its own probe.\nlet ripgrepAvailabilityByBackend = new WeakMap<\n t.LocalSpawn,\n Map<string, Promise<boolean>>\n>();\n\nfunction envCacheKey(env: NodeJS.ProcessEnv | undefined): string {\n // PATH is the only env entry that affects command lookup, but\n // hashing the whole env keeps the key correct for hosts that\n // vary anything else relevant. Stable JSON via sorted keys so\n // {A:1,B:2} and {B:2,A:1} produce the same hash.\n if (env == null) return '';\n const sorted: Record<string, string | undefined> = {};\n for (const k of Object.keys(env).sort()) {\n sorted[k] = env[k];\n }\n return JSON.stringify(sorted);\n}\n\nasync function isRipgrepAvailable(\n config: t.LocalExecutionConfig\n): Promise<boolean> {\n const backend = getSpawn(config);\n let envMap = ripgrepAvailabilityByBackend.get(backend);\n if (envMap == null) {\n envMap = new Map();\n ripgrepAvailabilityByBackend.set(backend, envMap);\n }\n const envKey = envCacheKey(config.env);\n let probePromise = envMap.get(envKey);\n if (probePromise == null) {\n probePromise = spawnLocalProcess(\n 'rg',\n ['--version'],\n { ...config, timeoutMs: 5000, sandbox: { enabled: false } },\n { internal: true }\n )\n .then((probe) => probe.exitCode === 0)\n .catch(() => false);\n envMap.set(envKey, probePromise);\n }\n return probePromise;\n}\n\n/**\n * Test-only reset hook. Clears the ripgrep-availability cache so\n * tests can swap in mocked spawn backends and reprobe deterministically.\n *\n * @internal Not part of the public SDK surface; the leading underscore\n * and `@internal` tag together signal that consumers should not call\n * this. Tests import it via the module path directly.\n */\nexport function _resetRipgrepCacheForTests(): void {\n ripgrepAvailabilityByBackend = new WeakMap();\n}\n\n// Skipped by the Node-fallback walker (used when ripgrep is\n// unavailable). Covers common build outputs, virtualenvs, and\n// caches so a `grep_search`/`glob_search` on a large monorepo or a\n// Python project with `.venv/` doesn't read every file under those\n// trees. ripgrep itself respects .gitignore so it doesn't need this\n// list. Audit follow-up from the comprehensive review (finding #3).\nconst SKIP_DIRS = new Set([\n '.git',\n '.svn',\n '.hg',\n 'node_modules',\n '.next',\n '.nuxt',\n '.cache',\n '.parcel-cache',\n '.turbo',\n 'dist',\n 'build',\n 'out',\n 'target',\n 'vendor',\n 'coverage',\n '.nyc_output',\n '__pycache__',\n '.venv',\n 'venv',\n 'env',\n '.tox',\n '.mypy_cache',\n '.pytest_cache',\n '.ruff_cache',\n]);\n\nfunction globToRegExp(pattern: string): RegExp {\n let result = '^';\n for (let i = 0; i < pattern.length; i++) {\n const c = pattern[i];\n if (c === '*') {\n if (pattern[i + 1] === '*') {\n result += '.*';\n i += 1;\n if (pattern[i + 1] === '/') {\n i += 1;\n }\n } else {\n result += '[^/]*';\n }\n } else if (c === '?') {\n result += '[^/]';\n } else if ('.+^$|(){}[]\\\\'.includes(c)) {\n result += '\\\\' + c;\n } else {\n result += c;\n }\n }\n result += '$';\n return new RegExp(result);\n}\n\nasync function* walkFiles(\n root: string,\n fs: import('./workspaceFS').WorkspaceFS\n): AsyncGenerator<string> {\n const stack: string[] = [root];\n while (stack.length > 0) {\n const dir = stack.pop() as string;\n let entries;\n try {\n entries = await fs.readdir(dir, { withFileTypes: true });\n } catch (error) {\n // A stalled-RPC timeout must surface, not be silently skipped as an\n // unreadable directory — that would corrupt search results (\"no matches\").\n if (isWorkspaceClientTimeoutError(error)) {\n throw error;\n }\n continue;\n }\n for (const entry of entries) {\n if (entry.name.startsWith('.git') || SKIP_DIRS.has(entry.name)) {\n continue;\n }\n const full = `${dir}/${entry.name}`;\n if (entry.isDirectory()) {\n stack.push(full);\n } else if (entry.isFile()) {\n yield full;\n }\n }\n }\n}\n\n/**\n * Catastrophic-backtracking guardrails for the fallback grep path.\n *\n * Without ripgrep we run the model-supplied pattern through Node's\n * `RegExp` engine, which uses a backtracking implementation. Patterns\n * with nested unbounded quantifiers (`(a+)+`, `(.*)*`, etc.) can\n * monopolise the event loop for arbitrary wall-clock time on\n * pathological input, and `setTimeout` cannot interrupt a synchronous\n * `RegExp.exec`. Manual review (finding D) flagged this as a real DoS.\n *\n * Mitigations applied here, in order of severity:\n * 1. Cap pattern length so an obviously oversize regex is rejected\n * before compile.\n * 2. Reject patterns that contain a nested unbounded quantifier of\n * the form `(...+|*)([+*]|{n,})` — the standard pathological\n * shape. Still a heuristic (not a full safety proof), but blocks\n * every common DoS construction we've seen in coding-agent logs.\n * 3. Wall-clock budget for the overall search: each file's regex\n * pass is checked against a deadline; once exceeded the search\n * bails with a partial result. Doesn't interrupt a stuck\n * `exec()` call, but stops a slow pattern from making the whole\n * Run hang once the first hung file finishes.\n *\n * Hosts that need bulletproof regex safety should install `rg` —\n * ripgrep uses RE2 internally and has no backtracking.\n */\nconst MAX_FALLBACK_PATTERN_LENGTH = 1024;\nconst FALLBACK_GREP_BUDGET_MS = 5000;\n// Per-file byte cap. Codex P2 #41 — without it, the whole-file\n// `readFile` + `split('\\n')` for a multi-GB log is an unbounded\n// allocation that the wall-clock budget (checked between files)\n// can't interrupt. Hosts that need to grep large files should\n// install ripgrep.\nconst FALLBACK_GREP_MAX_FILE_BYTES = 5 * 1024 * 1024;\n\n/**\n * Heuristic: walks `pattern` to find any `(<contents>)<quant>` where\n * `<contents>` itself has an unbounded quantifier. Catches the\n * classic `(a+)+` form AND the double-nested `((a+)+)` form (which a\n * single-pass regex misses because `[^)]*` stops at the first inner\n * close-paren). Misses sufficiently obfuscated cases — bulletproof\n * ReDoS detection requires a real parser. The 5 s wall-clock budget\n * is the hard backstop for anything this slip past.\n */\nfunction hasNestedUnboundedQuantifier(pattern: string): boolean {\n for (let i = 1; i < pattern.length - 1; i++) {\n if (pattern[i] !== ')') continue;\n if (pattern[i - 1] === '\\\\') continue;\n const next = pattern[i + 1];\n if (next !== '+' && next !== '*' && next !== '{') continue;\n // Walk back to find the matching opening paren (respecting depth\n // and `\\(` escapes).\n let depth = 1;\n let j = i - 1;\n while (j >= 0) {\n const c = pattern[j];\n const escaped = j > 0 && pattern[j - 1] === '\\\\';\n if (!escaped) {\n if (c === ')') depth++;\n else if (c === '(') {\n depth--;\n if (depth === 0) break;\n }\n }\n j--;\n }\n if (j < 0) continue;\n const inner = pattern.slice(j + 1, i);\n if (/(?<!\\\\)[+*]/.test(inner)) return true;\n }\n return false;\n}\n\nclass FallbackGrepError extends Error {\n readonly kind: 'pattern-too-long' | 'unsafe-pattern' | 'invalid-pattern';\n constructor(\n kind: 'pattern-too-long' | 'unsafe-pattern' | 'invalid-pattern',\n message: string\n ) {\n super(message);\n this.kind = kind;\n }\n}\n\nfunction compileFallbackRegex(pattern: string): RegExp {\n if (pattern.length > MAX_FALLBACK_PATTERN_LENGTH) {\n throw new FallbackGrepError(\n 'pattern-too-long',\n `Pattern exceeds ${MAX_FALLBACK_PATTERN_LENGTH}-char fallback cap (install ripgrep for unbounded patterns).`\n );\n }\n if (hasNestedUnboundedQuantifier(pattern)) {\n throw new FallbackGrepError(\n 'unsafe-pattern',\n 'Pattern contains a nested unbounded quantifier (e.g. `(a+)+` or `((a+)+)`) which can cause catastrophic backtracking in the Node fallback. Install ripgrep for RE2-safe matching.'\n );\n }\n try {\n return new RegExp(pattern);\n } catch (e) {\n throw new FallbackGrepError(\n 'invalid-pattern',\n `Invalid regex: ${(e as Error).message}`\n );\n }\n}\n\n/** Structured return so callers can count matches separately from\n * diagnostic skip-sentinels (Codex P2 [43]). */\ntype FallbackGrepResult = { matches: string[]; skipped: string[] };\n\n/** Renders fallback-grep output: real matches first, skip diagnostics appended. */\nfunction formatFallbackGrepDisplay(result: FallbackGrepResult): string {\n if (result.matches.length > 0) {\n return [...result.matches, ...result.skipped].join('\\n');\n }\n if (result.skipped.length > 0) {\n return result.skipped.join('\\n');\n }\n return 'No matches found.';\n}\n\nasync function fallbackGrep(\n root: string,\n pattern: string,\n globFilter: string | undefined,\n maxResults: number,\n fs: import('./workspaceFS').WorkspaceFS\n): Promise<FallbackGrepResult> {\n const rx = compileFallbackRegex(pattern);\n const deadline = Date.now() + FALLBACK_GREP_BUDGET_MS;\n const globRx =\n globFilter != null && globFilter !== ''\n ? globToRegExp(globFilter)\n : undefined;\n const matches: string[] = [];\n // Track skipped (oversize) files separately so they don't consume\n // the maxResults budget. Codex P2 [43]: round 14's fix pushed skip\n // sentinels into `matches`, so a directory of one oversize non-\n // matching file falsely reported `matches: 1`, and enough\n // oversize files could fill the budget before any real match was\n // scanned. Now diagnostics are appended after real matches and\n // independent of the budget.\n const skippedDiagnostics: string[] = [];\n for await (const file of walkFiles(root, fs)) {\n if (Date.now() > deadline) {\n // Wall-clock budget exceeded — return partial results rather\n // than letting a slow pattern hang the Run.\n return { matches, skipped: skippedDiagnostics };\n }\n if (globRx != null) {\n const rel = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (!globRx.test(rel)) {\n continue;\n }\n }\n // Skip files larger than the per-file cap and remember them as\n // diagnostics (NOT as matches). Codex P2 [41]: pre-fix\n // `fs.readFile` then `.split('\\n')` allocated the whole file +\n // an array of every line, which a single multi-GB log could\n // turn into an OOM even after the regex DoS guards.\n let stat;\n try {\n stat = await fs.stat(file);\n } catch (error) {\n // A stalled-RPC timeout must surface, not be skipped — skipping a file can\n // report \"no matches\" even when the (unreadable-due-to-stall) file matched.\n if (isWorkspaceClientTimeoutError(error)) {\n throw error;\n }\n continue;\n }\n if (stat.size > FALLBACK_GREP_MAX_FILE_BYTES) {\n skippedDiagnostics.push(\n `${file}:0:[skipped: file > ${FALLBACK_GREP_MAX_FILE_BYTES} bytes; install ripgrep for unbounded grep]`\n );\n continue;\n }\n let content;\n try {\n content = await fs.readFile(file, 'utf8');\n } catch (error) {\n // As above: a client-timeout means a stalled read, not an unreadable file.\n if (isWorkspaceClientTimeoutError(error)) {\n throw error;\n }\n continue;\n }\n if (content.includes('\\0')) {\n continue;\n }\n // Re-check the deadline AFTER the read — a slow disk on one\n // file can blow the budget without us noticing.\n if (Date.now() > deadline) {\n return { matches, skipped: skippedDiagnostics };\n }\n const lines = content.split('\\n');\n for (let i = 0; i < lines.length; i++) {\n if (rx.test(lines[i])) {\n matches.push(`${file}:${i + 1}:${lines[i]}`);\n if (matches.length >= maxResults) {\n return { matches, skipped: skippedDiagnostics };\n }\n }\n }\n }\n return { matches, skipped: skippedDiagnostics };\n}\n\nasync function fallbackGlob(\n root: string,\n pattern: string,\n maxResults: number,\n fs: import('./workspaceFS').WorkspaceFS\n): Promise<string[]> {\n const rx = globToRegExp(pattern);\n const out: string[] = [];\n for await (const file of walkFiles(root, fs)) {\n const rel = file.startsWith(root + '/')\n ? file.slice(root.length + 1)\n : file;\n if (rx.test(rel)) {\n out.push(file);\n if (out.length >= maxResults) {\n break;\n }\n }\n }\n return out;\n}\n\nexport function createLocalGrepSearchTool(\n config: t.LocalExecutionConfig = {}\n): DynamicStructuredTool {\n const fs = getWorkspaceFS(config);\n return tool(\n async (rawInput) => {\n const input = rawInput as {\n pattern: string;\n path?: string;\n glob?: string;\n max_results?: number;\n };\n const target = await resolveWorkspacePathSafe(\n input.path ?? '.',\n config,\n 'read'\n );\n const maxResults = Math.max(input.max_results ?? DEFAULT_MAX_RESULTS, 1);\n\n if (await isRipgrepAvailable(config)) {\n // Pass the pattern through `-e` so dash-prefixed patterns\n // like `-foo` are treated as the search regex, not as a\n // (probably-unknown) flag. `rg --help` explicitly requires\n // `-e/--regexp` (or `--`) for that case. Same trick avoids\n // any future flag-conflict if a user query happens to look\n // like an rg long option.\n const args = [\n '--line-number',\n '--column',\n '--hidden',\n '--glob',\n '!.git/**',\n ...(input.glob != null && input.glob !== ''\n ? ['--glob', input.glob]\n : []),\n '-e',\n input.pattern,\n target,\n ];\n const result = await spawnLocalProcess('rg', args, {\n ...config,\n timeoutMs: config.timeoutMs ?? 30000,\n });\n // ripgrep exit codes:\n // 0 → at least one match\n // 1 → no matches (clean — \"No matches found.\")\n // 2 → real error (bad regex, unreadable target, etc.)\n // Without this branch (Codex P2 #23 — same fix shape glob_search\n // got from P2 #13), exit-2 errors silently mapped to\n // `matches: 0`, so the agent treated tooling failures as a\n // genuine absence of matches.\n if (\n result.timedOut ||\n (result.exitCode != null && result.exitCode > 1)\n ) {\n const detail = result.stderr.trim() || `rg exited ${result.exitCode}`;\n return [\n `grep_search failed: ${detail}`,\n {\n matches: 0,\n engine: 'ripgrep',\n error: detail,\n exitCode: result.exitCode,\n },\n ];\n }\n const lines = result.stdout\n .split('\\n')\n .filter(Boolean)\n .slice(0, maxResults);\n const output =\n lines.length > 0\n ? lines.join('\\n')\n : result.stderr.trim() || 'No matches found.';\n return [output, { matches: lines.length, engine: 'ripgrep' }];\n }\n\n try {\n const { matches, skipped } = await fallbackGrep(\n target,\n input.pattern,\n input.glob,\n maxResults,\n fs\n );\n // Artifact count: ONLY real matches (Codex P2 [43] —\n // skip sentinels used to inflate the count and the budget).\n const display = formatFallbackGrepDisplay({ matches, skipped });\n return [\n display,\n {\n matches: matches.length,\n skipped: skipped.length,\n engine: 'node-fallback',\n },\n ];\n } catch (e) {\n if (e instanceof FallbackGrepError) {\n return [\n `grep_search refused the pattern: ${e.message}`,\n {\n matches: 0,\n engine: 'node-fallback',\n error: e.message,\n kind: e.kind,\n },\n ];\n }\n throw e;\n }\n },\n {\n name: LocalGrepSearchToolName,\n description:\n 'Search local files for a regex pattern (ripgrep when available, Node fallback otherwise).',\n schema: LocalGrepSearchToolSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\nexport function createLocalGlobSearchTool(\n config: t.LocalExecutionConfig = {}\n): DynamicStructuredTool {\n const fs = getWorkspaceFS(config);\n return tool(\n async (rawInput) => {\n const input = rawInput as {\n pattern: string;\n path?: string;\n max_results?: number;\n };\n const target = await resolveWorkspacePathSafe(\n input.path ?? '.',\n config,\n 'read'\n );\n const maxResults = Math.max(input.max_results ?? DEFAULT_MAX_RESULTS, 1);\n\n if (await isRipgrepAvailable(config)) {\n const result = await spawnLocalProcess(\n 'rg',\n [\n '--files',\n '--hidden',\n '--glob',\n '!.git/**',\n '--glob',\n input.pattern,\n target,\n ],\n { ...config, timeoutMs: config.timeoutMs ?? 30000 }\n );\n // rg --files exit codes:\n // 0 → at least one file matched\n // 1 → no files matched (clean — \"No files found.\")\n // 2 → real error (bad glob, unreadable target, etc.)\n // Without this branch, exit-2 errors used to silently map to\n // \"No files found.\" — the agent then treats a tooling failure\n // as a real absence of matches.\n if (\n result.timedOut ||\n (result.exitCode != null && result.exitCode > 1)\n ) {\n const detail = result.stderr.trim() || `rg exited ${result.exitCode}`;\n return [\n `glob_search failed: ${detail}`,\n {\n files: [],\n engine: 'ripgrep',\n error: detail,\n exitCode: result.exitCode,\n },\n ];\n }\n const lines = result.stdout\n .split('\\n')\n .filter(Boolean)\n .slice(0, maxResults);\n return [\n lines.length > 0 ? lines.join('\\n') : 'No files found.',\n { files: lines, engine: 'ripgrep' },\n ];\n }\n\n const files = await fallbackGlob(target, input.pattern, maxResults, fs);\n return [\n files.length > 0 ? files.join('\\n') : 'No files found.',\n { files, engine: 'node-fallback' },\n ];\n },\n {\n name: LocalGlobSearchToolName,\n description:\n 'Find local files matching a glob pattern (ripgrep when available, Node fallback otherwise).',\n schema: LocalGlobSearchToolSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\nexport function createLocalListDirectoryTool(\n config: t.LocalExecutionConfig = {}\n): DynamicStructuredTool {\n const fs = getWorkspaceFS(config);\n return tool(\n async (rawInput) => {\n const input = rawInput as { path?: string };\n const path = await resolveWorkspacePathSafe(\n input.path ?? '.',\n config,\n 'read'\n );\n const entries = await fs.readdir(path, { withFileTypes: true });\n const output = entries\n .map(\n (entry) => `${entry.isDirectory() ? 'dir ' : 'file'}\\t${entry.name}`\n )\n .join('\\n');\n return [output || 'Directory is empty.', { path, count: entries.length }];\n },\n {\n name: LocalListDirectoryToolName,\n description: 'List files and directories in a local directory.',\n schema: LocalListDirectoryToolSchema,\n responseFormat: Constants.CONTENT_AND_ARTIFACT,\n }\n );\n}\n\nexport type LocalCodingToolBundle = {\n tools: DynamicStructuredTool[];\n /**\n * Present when `config.fileCheckpointing === true` or a `checkpointer`\n * was passed in. Callers can call `rewind()` to restore captured\n * pre-write contents.\n */\n checkpointer?: t.LocalFileCheckpointer;\n};\n\nexport function createLocalCodingTools(\n config: t.LocalExecutionConfig = {},\n options: { checkpointer?: t.LocalFileCheckpointer } = {}\n): DynamicStructuredTool[] {\n const checkpointer =\n options.checkpointer ??\n (config.fileCheckpointing === true\n ? createLocalFileCheckpointer({ fs: config.exec?.fs })\n : undefined);\n return [\n createLocalReadFileTool(config),\n createLocalWriteFileTool(config, checkpointer),\n createLocalEditFileTool(config, checkpointer),\n createLocalGrepSearchTool(config),\n createLocalGlobSearchTool(config),\n createLocalListDirectoryTool(config),\n createCompileCheckTool(config),\n createLocalBashExecutionTool({ config }),\n createLocalCodeExecutionTool(config),\n createLocalProgrammaticToolCallingTool(config),\n createLocalBashProgrammaticToolCallingTool(config),\n ];\n}\n\n/**\n * Variant of `createLocalCodingTools` that returns the bundle alongside\n * the file checkpointer so callers can later call\n * `bundle.checkpointer?.rewind()`.\n */\nexport function createLocalCodingToolBundle(\n config: t.LocalExecutionConfig = {},\n options: { checkpointer?: t.LocalFileCheckpointer } = {}\n): LocalCodingToolBundle {\n const checkpointer =\n options.checkpointer ??\n (config.fileCheckpointing === true\n ? createLocalFileCheckpointer({ fs: config.exec?.fs })\n : undefined);\n return {\n tools: createLocalCodingTools(config, { checkpointer }),\n checkpointer,\n };\n}\n\nexport function createLocalCodingToolDefinitions(): t.LCTool[] {\n return [\n toolDefinition(\n Constants.READ_FILE,\n 'Read a local text file from the configured working directory with line numbers.',\n LocalReadFileToolSchema as t.JsonSchemaType\n ),\n toolDefinition(\n LocalWriteFileToolName,\n 'Create or overwrite a local text file in the configured working directory.',\n LocalWriteFileToolSchema as t.JsonSchemaType\n ),\n toolDefinition(\n LocalEditFileToolName,\n 'Apply exact text replacements to a local file.',\n LocalEditFileToolSchema as t.JsonSchemaType\n ),\n toolDefinition(\n LocalGrepSearchToolName,\n 'Search local files with ripgrep and return matching lines.',\n LocalGrepSearchToolSchema as t.JsonSchemaType\n ),\n toolDefinition(\n LocalGlobSearchToolName,\n 'Find local files matching a glob pattern.',\n LocalGlobSearchToolSchema as t.JsonSchemaType\n ),\n toolDefinition(\n LocalListDirectoryToolName,\n 'List files and directories in a local directory.',\n LocalListDirectoryToolSchema as t.JsonSchemaType\n ),\n createCompileCheckToolDefinition(),\n ];\n}\n\nexport function createLocalCodingToolRegistry(): t.LCToolRegistry {\n return new Map(\n createLocalCodingToolDefinitions().map((definition) => [\n definition.name,\n definition,\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAi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CAAC,CACH;AACF"}
1
+ {"version":3,"file":"LocalCodingTools.mjs","names":["input"],"sources":["../../../../src/tools/local/LocalCodingTools.ts"],"mappings":";;;;;;;;;;;;;;;;;AAiCA,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB,KAAK,OAAO;AAC3C,MAAM,yBAAyB;AAQ/B,MAAa,yBAAA;AACb,MAAa,wBAAA;AACb,MAAa,0BAAA;AACb,MAAa,0BAAA;AACb,MAAa,6BAAA;AAEb,MAAa,0BAA4C,WAAW;CAClE,MAAM;CACN,YAAY;EACV,MAAM;GACJ,MAAM;GACN,aACE;EACJ;EACA,QAAQ;GACN,MAAM;GACN,aAAa;EACf;EACA,OAAO;GACL,MAAM;GACN,aAAa;EACf;CACF;CACA,UAAU,CAAC,MAAM;AACnB,CAAC;AAED,MAAa,2BAA6C,WAAW;CACnE,MAAM;CACN,YAAY;EACV,MAAM;GACJ,MAAM;GACN,aACE;EACJ;EACA,SAAS;GACP,MAAM;GACN,aAAa;EACf;CACF;CACA,UAAU,CAAC,QAAQ,SAAS;AAC9B,CAAC;AAED,MAAa,0BAA4C,WAAW;CAClE,MAAM;CACN,YAAY;EACV,MAAM;GACJ,MAAM;GACN,aACE;EACJ;EACA,UAAU;GACR,MAAM;GACN,aAAa;EACf;EACA,UAAU;GACR,MAAM;GACN,aAAa;EACf;EACA,OAAO;GACL,MAAM;GACN,aACE;GACF,OAAO;IACL,MAAM;IACN,YAAY;KACV,UAAU,EAAE,MAAM,SAAS;KAC3B,UAAU,EAAE,MAAM,SAAS;IAC7B;IACA,UAAU,CAAC,YAAY,UAAU;GACnC;EACF;CACF;CACA,UAAU,CAAC,MAAM;AACnB,CAAC;AAED,MAAa,4BAA8C,WAAW;CACpE,MAAM;CACN,YAAY;EACV,SAAS;GACP,MAAM;GACN,aAAa;EACf;EACA,MAAM;GACJ,MAAM;GACN,aAAa;EACf;EACA,MAAM;GACJ,MAAM;GACN,aAAa;EACf;EACA,aAAa;G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AAe,CACrD,WAAW,MACX,UACF,CAAC,CACH;AACF"}
@@ -9,12 +9,6 @@ import { createWriteStream } from "fs";
9
9
  //#region src/tools/local/LocalExecutionEngine.ts
10
10
  const DEFAULT_TIMEOUT_MS = 6e4;
11
11
  const DEFAULT_MAX_OUTPUT_CHARS = 2e5;
12
- /**
13
- * Hard cap on total stdout+stderr bytes a child process can stream
14
- * before we kill its process tree. Independent from `maxOutputChars`
15
- * (which only affects what the *model* sees) — this is the OOM
16
- * backstop. Configurable via `local.maxSpawnedBytes`.
17
- */
18
12
  const DEFAULT_MAX_SPAWNED_BYTES = 50 * 1024 * 1024;
19
13
  const DEFAULT_LOCAL_SESSION_ID = "local";
20
14
  const DEFAULT_SHELL = process.platform === "win32" ? "bash.exe" : "bash";
@@ -27,21 +21,6 @@ const dangerousCommandPatterns = [
27
21
  new RegExp(`\\bchown\\s+-R\\s+[^;&|]+\\s+(?:--\\s+)?${DESTRUCTIVE_TARGET}(?:$|\\s|[;&|])`),
28
22
  /:\s*\(\s*\)\s*\{\s*:\s*\|\s*:\s*&\s*\}\s*;\s*:/
29
23
  ];
30
- /**
31
- * Companion patterns that look for destructive targets *inside*
32
- * matching quote pairs. These are checked against the ORIGINAL
33
- * command (not the post-quote-strip `normalized` form), because
34
- * `stripQuotedContent` blanks the contents of quoted spans —
35
- * which would otherwise let `rm -rf "/"` and friends slip past
36
- * `dangerousCommandPatterns`.
37
- *
38
- * Kept as a separate list so we don't pay false-positive cost on
39
- * benign uses like `echo "rm -rf /"` (the print case): each pattern
40
- * here REQUIRES a quote *around the destructive path argument*, not
41
- * just a quote *somewhere* in the command. `echo "rm -rf /"` has
42
- * `/` outside of any quote-pair-around-the-path (the quotes wrap
43
- * the whole `rm -rf /` text), so it doesn't match here either.
44
- */
45
24
  const quotedDestructivePatterns = [
46
25
  new RegExp(`\\brm\\s+(?:-[^\\s]*[rf][^\\s]*\\s+){1,3}(?:--\\s+)?["']${DESTRUCTIVE_TARGET}["']`),
47
26
  new RegExp(`\\bchmod\\s+-R\\s+(?:777|a\\+w)\\s+(?:--\\s+)?["']${DESTRUCTIVE_TARGET}["']`),
@@ -53,12 +32,6 @@ const nestedShellDestructivePatterns = [
53
32
  /* @__PURE__ */ new RegExp("(?:(?:ba|z|da|k)?sh|eval)\\s+(?:-l?c\\s+)?[\"'][^\"']*\\bchown\\s+-R\\s+[^;&|]+\\s+(?:--\\s+)?(?:\\/|~|\\$\\{?HOME\\}?|\\.)")
54
33
  ];
55
34
  const mutatingCommandPattern = /\b(?:rm|mv|cp|touch|mkdir|rmdir|ln|truncate|tee|sed\s+-i|perl\s+-pi|python(?:3)?\s+-c|node\s+-e|npm\s+(?:install|ci|update|publish)|pnpm\s+(?:install|update|publish)|yarn\s+(?:install|add|publish)|git\s+(?:add|commit|checkout|switch|reset|clean|rebase|merge|push|pull|stash|tag|branch)|chmod|chown)\b|(?:^|[^<])>\s*[^&]|\bcat\s+[^|;&]*>\s*/;
56
- /**
57
- * POSIX convention: `128 + signum` when a process is killed by a
58
- * signal. Maps the common signals; unknown ones default to 1 so the
59
- * caller still sees a non-zero (failed) exit. Only used when Node's
60
- * `close` event reports `exitCode === null` (true signal kill).
61
- */
62
35
  const SIGNAL_TO_EXIT_CODE = {
63
36
  SIGHUP: 129,
64
37
  SIGINT: 130,
@@ -93,15 +66,6 @@ function resolveLocalExecutionConfig(config) {
93
66
  function getLocalCwd(config) {
94
67
  return resolve(config?.workspace?.root ?? config?.cwd ?? process.cwd());
95
68
  }
96
- /**
97
- * Resolves the effective workspace boundary: a list of absolute roots
98
- * that file operations are allowed to touch. The first entry is always
99
- * the canonical root (`getLocalCwd`); subsequent entries come from
100
- * `workspace.additionalRoots` when provided.
101
- *
102
- * Returns plain absolute paths — callers symlink-resolve when they
103
- * need realpath equality (see `resolveWorkspacePathSafe`).
104
- */
105
69
  function getWorkspaceRoots(config) {
106
70
  const root = getLocalCwd(config);
107
71
  const extras = config?.workspace?.additionalRoots ?? [];
@@ -117,28 +81,12 @@ function getWorkspaceRoots(config) {
117
81
  }
118
82
  return out;
119
83
  }
120
- /**
121
- * Pluggable spawn resolver. Honours `local.exec.spawn` first, falls
122
- * back to the legacy top-level `local.spawn`, then to Node's
123
- * `child_process.spawn`. Centralised so engine swapping is one knob.
124
- */
125
84
  function getSpawn(config) {
126
85
  return config?.exec?.spawn ?? config?.spawn ?? spawn;
127
86
  }
128
- /**
129
- * Pluggable filesystem resolver. Honours `local.exec.fs`, falls back
130
- * to the Node-host implementation. A future remote engine supplies
131
- * its own implementation here and inherits every file-touching tool.
132
- */
133
87
  function getWorkspaceFS(config) {
134
88
  return config?.exec?.fs ?? nodeWorkspaceFS;
135
89
  }
136
- /**
137
- * Resolves the workspace boundary for *write* operations. Honours
138
- * `workspace.allowWriteOutside` (and the deprecated
139
- * `allowOutsideWorkspace`) by returning `null`, which the path-safety
140
- * helpers interpret as "skip the write clamp".
141
- */
142
90
  function getWriteRoots(config = {}) {
143
91
  const granular = config.workspace?.allowWriteOutside;
144
92
  if (granular === true) return null;
@@ -146,11 +94,6 @@ function getWriteRoots(config = {}) {
146
94
  if (config.allowOutsideWorkspace === true) return null;
147
95
  return getWorkspaceRoots(config);
148
96
  }
149
- /**
150
- * Resolves the workspace boundary for *read* operations. Honours
151
- * `workspace.allowReadOutside` (and the deprecated
152
- * `allowOutsideWorkspace`) by returning `null`.
153
- */
154
97
  function getReadRoots(config = {}) {
155
98
  const granular = config.workspace?.allowReadOutside;
156
99
  if (granular === true) return null;
@@ -164,7 +107,6 @@ function getLocalSessionId(config) {
164
107
  }
165
108
  const missingSandboxRuntimeMessage = ["Local sandbox is enabled, but @anthropic-ai/sandbox-runtime is not installed.", "Install it with `npm install @anthropic-ai/sandbox-runtime`, or disable local sandboxing with `local.sandbox.enabled: false`."].join(" ");
166
109
  const sandboxRuntimePackage = "@anthropic-ai/sandbox-runtime";
167
- /** Lazy-loads the ESM-only sandbox runtime only when sandboxing is enabled. */
168
110
  function loadSandboxRuntime() {
169
111
  sandboxRuntimePromise ??= import(sandboxRuntimePackage);
170
112
  return sandboxRuntimePromise;
@@ -178,11 +120,6 @@ function maybeWarnSandboxOff(config) {
178
120
  sandboxOffWarned = true;
179
121
  console.warn("[@librechat/agents] Local execution engine is running without @anthropic-ai/sandbox-runtime wrapping. The agent has full access to the host filesystem and network. Set toolExecution.local.sandbox.enabled = true to opt into process sandboxing.");
180
122
  }
181
- /**
182
- * Test-only reset hook for the sandbox-off warning latch.
183
- *
184
- * @internal Not part of the public SDK surface.
185
- */
186
123
  function _resetLocalEngineWarningsForTests() {
187
124
  sandboxOffWarned = false;
188
125
  }
@@ -306,13 +243,6 @@ async function ensureSandbox(config, cwd) {
306
243
  sandboxConfigKey = nextKey;
307
244
  return runtime.SandboxManager;
308
245
  }
309
- /**
310
- * Loopback addresses the in-process programmatic-tool bridge listens
311
- * on (`LocalProgrammaticToolCalling.ts` binds 127.0.0.1). Sandboxed
312
- * code launched by `run_tools_with_code` / `run_tools_with_bash` HTTPs
313
- * back to that address — without the entries below, the bridge is
314
- * silently blocked under sandbox.
315
- */
316
246
  const BRIDGE_LOOPBACK_HOSTS = [
317
247
  "127.0.0.1",
318
248
  "localhost",
@@ -480,35 +410,7 @@ async function executeLocalBash(command, config = {}) {
480
410
  if (!validation.valid) throw new Error(validation.errors.join("\n"));
481
411
  return spawnLocalProcess(config.shell ?? DEFAULT_SHELL, ["-lc", command], config);
482
412
  }
483
- /**
484
- * Variant of `executeLocalBash` that exposes `args` as positional
485
- * shell parameters (`$1`, `$2`, …). Mirrors what the other runtimes
486
- * do in `getRuntimeCommand`. Uses the standard `bash -c <code> --
487
- * arg0 arg1 …` form: the `--` becomes `$0`, then `args[0]` is `$1`
488
- * and so on. Same AST validation as the no-args path.
489
- *
490
- * Used by both the `execute_code`/`lang:'bash'` path AND the
491
- * `bash_tool` factory so the schema's `args` contract works
492
- * identically in both surfaces.
493
- */
494
- /**
495
- * Matches a single arg that, on its own, references a protected
496
- * location (`/`, `~`, `$HOME`, `${HOME}`, `.`, with optional trailing
497
- * slash, wildcard, or dot-glob suffix). Used to spot the
498
- * `command: 'rm -rf "$1"', args: ['/']` shape where the destructive
499
- * target is moved into a positional arg to evade the command regex.
500
- * Codex P1 [45], extended for dot-glob in Codex P1 [47] (mirrors the
501
- * `DESTRUCTIVE_TARGET` suffix matrix exactly).
502
- */
503
413
  const PROTECTED_TARGET_ARG_RE = /^(?:\/|~|\$\{?HOME\}?|\.)(?:\/?\.?\*|\/)?$/;
504
- /**
505
- * Mutating-op recognizer for the args check. Conservative: only the
506
- * three operations the destructive-command guard already covers
507
- * directly (`rm -rf …`, `chmod -R …`, `chown -R …`). Other shell
508
- * builtins might mutate state (`mv`, `cp` over an existing file,
509
- * etc.) but the destructive guard doesn't try to catch those today,
510
- * so we don't widen here either.
511
- */
512
414
  const DESTRUCTIVE_OP_IN_COMMAND_RE = /\b(?:rm\s+-[^\s]*[rf]|chmod\s+-R|chown\s+-R)\b/;
513
415
  async function executeLocalBashWithArgs(command, args, config = {}) {
514
416
  const validation = await validateBashCommand(command, config);
@@ -633,15 +535,6 @@ function getRuntimeCommand(lang, tempDir, code, args = [], shellOverride) {
633
535
  function configShell() {
634
536
  return process.platform === "win32" ? "bash.exe" : "bash";
635
537
  }
636
- /**
637
- * How long after SIGTERM we wait before escalating to SIGKILL. A
638
- * cooperative process gets a graceful chance to flush + clean up;
639
- * a process that ignores or traps SIGTERM (`trap '' TERM`) gets
640
- * killed unconditionally so timeoutMs / maxSpawnedBytes can't be
641
- * defeated by a hostile script. Codex P1 #28 — pre-fix the spawn
642
- * promise would never resolve in that case and the entire tool run
643
- * would hang past the advertised timeout.
644
- */
645
538
  const SIGKILL_ESCALATION_MS = 2e3;
646
539
  function sigterm(child) {
647
540
  if (child.pid == null) {
@@ -710,18 +603,6 @@ async function realpathOrSelf(absolutePath, realpathImpl = realpath) {
710
603
  return absolutePath;
711
604
  }
712
605
  }
713
- /**
714
- * Resolves the realpath of `absolutePath`, falling back to the nearest
715
- * existing ancestor when the target itself does not yet exist (so the
716
- * containment check still works for `write_file` to a brand-new path).
717
- *
718
- * Codex P2 #38: takes the realpath impl as a parameter so callers
719
- * can route through `WorkspaceFS.realpath` when a custom engine is
720
- * configured. Pre-fix, host `fs/promises.realpath` would fail on a
721
- * remote/in-memory FS path and silently fall back to lexical
722
- * containment, leaving the symlink-escape clamp ineffective on
723
- * non-default engines.
724
- */
725
606
  async function realpathOfPathOrAncestor(absolutePath, realpathImpl = realpath) {
726
607
  let current = absolutePath;
727
608
  let suffix = "";
@@ -736,13 +617,6 @@ async function realpathOfPathOrAncestor(absolutePath, realpathImpl = realpath) {
736
617
  current = parent;
737
618
  }
738
619
  }
739
- /**
740
- * Resolves a workspace path AND follows any symlinks before checking
741
- * containment, so a symlink inside the workspace pointing outside is
742
- * rejected even though the lexical path looks safe. Handles paths that
743
- * don't yet exist (e.g. write_file targets) by realpath-resolving the
744
- * nearest existing ancestor and re-attaching the unresolved suffix.
745
- */
746
620
  async function resolveWorkspacePathSafe(filePath, config = {}, intent = "write") {
747
621
  const lexical = resolveWorkspacePath(filePath, config, intent);
748
622
  const roots = intent === "write" ? getWriteRoots(config) : getReadRoots(config);
@@ -1 +1 @@
1
- {"version":3,"file":"LocalExecutionEngine.mjs","names":[],"sources":["../../../../src/tools/local/LocalExecutionEngine.ts"],"sourcesContent":["import { tmpdir } from 'os';\nimport { spawn } from 'child_process';\nimport { createWriteStream } from 'fs';\nimport { createHash, randomUUID } from 'crypto';\nimport { isAbsolute, relative, resolve } from 'path';\nimport { mkdir, realpath, rm, writeFile } from 'fs/promises';\nimport type { ChildProcess } from 'child_process';\nimport type { WorkspaceFS } from './workspaceFS';\nimport type * as t from '@/types';\nimport { runBashAstChecks, bashAstFindingsToErrors } from './bashAst';\nimport { nodeWorkspaceFS } from './workspaceFS';\n\nconst DEFAULT_TIMEOUT_MS = 60000;\nconst DEFAULT_MAX_OUTPUT_CHARS = 200000;\n/**\n * Hard cap on total stdout+stderr bytes a child process can stream\n * before we kill its process tree. Independent from `maxOutputChars`\n * (which only affects what the *model* sees) — this is the OOM\n * backstop. Configurable via `local.maxSpawnedBytes`.\n */\nconst DEFAULT_MAX_SPAWNED_BYTES = 50 * 1024 * 1024;\nconst DEFAULT_LOCAL_SESSION_ID = 'local';\nconst DEFAULT_SHELL = process.platform === 'win32' ? 'bash.exe' : 'bash';\n\n// `(?:--\\s+)?` before each destructive-target alternation: GNU/BSD\n// utilities accept `--` as an end-of-options marker, so `rm -rf -- /`\n// is identical in effect to `rm -rf /` but pre-fix it slipped past\n// the guard because the regex required the path to follow option\n// flags directly. Codex P1 #20.\n// `DESTRUCTIVE_TARGET` is the canonical \"protected location\" pattern:\n// matches `/`, `~`, `$HOME`, `${HOME}`, `.`, each optionally followed\n// by a trailing-slash and/or wildcard glob suffix. The suffix matrix:\n// '' — `$HOME` (round 14)\n// '/' — `$HOME/` (round 14, Codex P1 [37])\n// '*' — `$HOME*` (round 15, Codex P1 [42])\n// '/*' — `$HOME/*` (round 15, Codex P1 [42])\n// '.*' — `$HOME.*` (round 17, Codex P1 [47])\n// '/.*' — `$HOME/.*` (round 17, Codex P1 [47]) — the\n// dot-glob form deletes all dotfiles under the protected\n// root, just as destructive as `/*` but the prior matrix\n// missed it.\n// Suffix expression: `(?:\\/?\\.?\\*|\\/)?` — one of:\n// `\\/?\\.?\\*` → `*`, `.*`, `/*`, `/.*`\n// `\\/` → `/`\n// (empty) → bare base\nconst DESTRUCTIVE_TARGET = '(?:\\\\/|~|\\\\$\\\\{?HOME\\\\}?|\\\\.)(?:\\\\/?\\\\.?\\\\*|\\\\/)?';\n\nconst dangerousCommandPatterns: ReadonlyArray<RegExp> = [\n new RegExp(\n `\\\\brm\\\\s+(?:-[^\\\\s]*[rf][^\\\\s]*\\\\s+|-[^\\\\s]*[r][^\\\\s]*\\\\s+-[^\\\\s]*[f][^\\\\s]*\\\\s+)(?:--\\\\s+)?${DESTRUCTIVE_TARGET}\\\\s*(?:$|[;&|])`\n ),\n /\\b(?:mkfs|mkswap|fdisk|parted|diskutil)\\b/,\n /\\bdd\\s+[^;&|]*\\bof=\\/dev\\//,\n new RegExp(\n `\\\\bchmod\\\\s+-R\\\\s+(?:777|a\\\\+w)\\\\s+(?:--\\\\s+)?${DESTRUCTIVE_TARGET}(?:$|\\\\s|[;&|])`\n ),\n new RegExp(\n `\\\\bchown\\\\s+-R\\\\s+[^;&|]+\\\\s+(?:--\\\\s+)?${DESTRUCTIVE_TARGET}(?:$|\\\\s|[;&|])`\n ),\n /:\\s*\\(\\s*\\)\\s*\\{\\s*:\\s*\\|\\s*:\\s*&\\s*\\}\\s*;\\s*:/,\n];\n\n/**\n * Companion patterns that look for destructive targets *inside*\n * matching quote pairs. These are checked against the ORIGINAL\n * command (not the post-quote-strip `normalized` form), because\n * `stripQuotedContent` blanks the contents of quoted spans —\n * which would otherwise let `rm -rf \"/\"` and friends slip past\n * `dangerousCommandPatterns`.\n *\n * Kept as a separate list so we don't pay false-positive cost on\n * benign uses like `echo \"rm -rf /\"` (the print case): each pattern\n * here REQUIRES a quote *around the destructive path argument*, not\n * just a quote *somewhere* in the command. `echo \"rm -rf /\"` has\n * `/` outside of any quote-pair-around-the-path (the quotes wrap\n * the whole `rm -rf /` text), so it doesn't match here either.\n */\n// Quoted variant uses the same DESTRUCTIVE_TARGET (which accepts an\n// optional trailing slash) so `rm -rf \"$HOME/\"` and `rm -rf \"~/\"`\n// don't slip past. Codex P1 #37.\nconst quotedDestructivePatterns: ReadonlyArray<RegExp> = [\n new RegExp(\n `\\\\brm\\\\s+(?:-[^\\\\s]*[rf][^\\\\s]*\\\\s+){1,3}(?:--\\\\s+)?[\"']${DESTRUCTIVE_TARGET}[\"']`\n ),\n new RegExp(\n `\\\\bchmod\\\\s+-R\\\\s+(?:777|a\\\\+w)\\\\s+(?:--\\\\s+)?[\"']${DESTRUCTIVE_TARGET}[\"']`\n ),\n new RegExp(\n `\\\\bchown\\\\s+-R\\\\s+[^;&|]+\\\\s+(?:--\\\\s+)?[\"']${DESTRUCTIVE_TARGET}[\"']`\n ),\n];\n\n/**\n * Catches destructive operations smuggled inside a nested shell or\n * `eval` call, e.g. `bash -lc \"rm -rf $HOME\"` — the outer command\n * looks benign (`bash -lc \"...\"`) and the destructive `rm` lives\n * inside the quoted payload that `stripQuotedContent` blanks out.\n * Comprehensive review (manual finding C) flagged this as a real\n * bypass of the otherwise-correct quote-strip-then-match approach.\n *\n * Run against the ORIGINAL command (quotes intact) so the inside of\n * the nested-shell payload is visible. Conservative: matches only\n * the same operation set as `dangerousCommandPatterns` (rm -rf,\n * chmod -R 777, chown -R) when they appear inside a `<shell> -[l]?c\n * \"...\"` or `eval \"...\"` payload.\n */\nconst NESTED_SHELL_PREFIX = '(?:(?:ba|z|da|k)?sh|eval)\\\\s+(?:-l?c\\\\s+)?';\nconst nestedShellDestructivePatterns: ReadonlyArray<RegExp> = [\n new RegExp(\n NESTED_SHELL_PREFIX +\n '[\"\\'][^\"\\']*\\\\brm\\\\s+-[^\\\\s\"\\']*[rf][^\\\\s\"\\']*\\\\s+(?:--\\\\s+)?(?:\\\\/|~|\\\\$\\\\{?HOME\\\\}?|\\\\.)'\n ),\n new RegExp(\n NESTED_SHELL_PREFIX +\n '[\"\\'][^\"\\']*\\\\bchmod\\\\s+-R\\\\s+(?:777|a\\\\+w)\\\\s+(?:--\\\\s+)?(?:\\\\/|~|\\\\$\\\\{?HOME\\\\}?|\\\\.)'\n ),\n new RegExp(\n NESTED_SHELL_PREFIX +\n '[\"\\'][^\"\\']*\\\\bchown\\\\s+-R\\\\s+[^;&|]+\\\\s+(?:--\\\\s+)?(?:\\\\/|~|\\\\$\\\\{?HOME\\\\}?|\\\\.)'\n ),\n];\n\nconst mutatingCommandPattern =\n /\\b(?:rm|mv|cp|touch|mkdir|rmdir|ln|truncate|tee|sed\\s+-i|perl\\s+-pi|python(?:3)?\\s+-c|node\\s+-e|npm\\s+(?:install|ci|update|publish)|pnpm\\s+(?:install|update|publish)|yarn\\s+(?:install|add|publish)|git\\s+(?:add|commit|checkout|switch|reset|clean|rebase|merge|push|pull|stash|tag|branch)|chmod|chown)\\b|(?:^|[^<])>\\s*[^&]|\\bcat\\s+[^|;&]*>\\s*/;\n\ntype SpawnResult = {\n stdout: string;\n stderr: string;\n exitCode: number | null;\n timedOut: boolean;\n /**\n * True when the process was force-killed because total streamed bytes\n * exceeded `maxSpawnedBytes`. Distinct from `timedOut`. Without this\n * flag, callers (`bash_tool`, `execute_code`, etc.) would see a\n * SIGKILL'd process with `exitCode: null` and treat it as success\n * (Codex P1 — runaway commands like `yes` or noisy builds silently\n * looked successful even though their output was truncated).\n */\n overflowKilled?: boolean;\n /**\n * Signal name (e.g. `'SIGKILL'`, `'SIGSEGV'`) when the process was\n * terminated by a signal. Distinct from the overflow-kill path:\n * this captures `kill -9 $$` from inside the script, native crashes,\n * OS OOM killer, etc. Without this, signal-killed processes\n * reported `exitCode: null` and looked like clean runs (Codex P2 —\n * generalization of the overflow-kill fix). When present, the\n * exitCode field is also synthesized to `128 + signum` per the\n * POSIX convention so non-null-exit-code consumers see a failure.\n */\n signal?: string;\n /** Path to the full untruncated stdout/stderr when output exceeded `maxOutputChars`. */\n fullOutputPath?: string;\n};\n\n/**\n * POSIX convention: `128 + signum` when a process is killed by a\n * signal. Maps the common signals; unknown ones default to 1 so the\n * caller still sees a non-zero (failed) exit. Only used when Node's\n * `close` event reports `exitCode === null` (true signal kill).\n */\nconst SIGNAL_TO_EXIT_CODE: Record<string, number> = {\n SIGHUP: 129,\n SIGINT: 130,\n SIGQUIT: 131,\n SIGILL: 132,\n SIGTRAP: 133,\n SIGABRT: 134,\n SIGBUS: 135,\n SIGFPE: 136,\n SIGKILL: 137,\n SIGUSR1: 138,\n SIGSEGV: 139,\n SIGUSR2: 140,\n SIGPIPE: 141,\n SIGALRM: 142,\n SIGTERM: 143,\n};\nfunction exitCodeForSignal(signal: string | null): number {\n if (signal == null) return 1;\n return SIGNAL_TO_EXIT_CODE[signal] ?? 1;\n}\n\ntype RuntimeCommand = {\n command: string;\n args: string[];\n fileName: string;\n source?: string;\n};\n\ntype SandboxManagerType = {\n checkDependencies(): { errors: string[] };\n initialize(config: BuiltSandboxRuntimeConfig): Promise<void>;\n reset(): Promise<void>;\n wrapWithSandbox(command: string): Promise<string>;\n};\n\ntype SandboxRuntimeModule = {\n getDefaultWritePaths(): string[];\n SandboxManager: SandboxManagerType;\n};\n\nlet sandboxConfigKey: string | undefined;\nlet sandboxInitialized = false;\nlet sandboxRuntimePromise: Promise<SandboxRuntimeModule> | undefined;\n\nexport type BashValidationResult = {\n valid: boolean;\n errors: string[];\n warnings: string[];\n};\n\nfunction isToolExecutionConfig(\n config: t.ToolExecutionConfig | t.LocalExecutionConfig\n): config is t.ToolExecutionConfig {\n return 'engine' in config || 'local' in config;\n}\n\nexport function resolveLocalExecutionConfig(\n config?: t.ToolExecutionConfig | t.LocalExecutionConfig\n): t.LocalExecutionConfig {\n if (config != null && isToolExecutionConfig(config)) {\n return config.local ?? {};\n }\n return config ?? {};\n}\n\nexport function getLocalCwd(config?: t.LocalExecutionConfig): string {\n return resolve(config?.workspace?.root ?? config?.cwd ?? process.cwd());\n}\n\n/**\n * Resolves the effective workspace boundary: a list of absolute roots\n * that file operations are allowed to touch. The first entry is always\n * the canonical root (`getLocalCwd`); subsequent entries come from\n * `workspace.additionalRoots` when provided.\n *\n * Returns plain absolute paths — callers symlink-resolve when they\n * need realpath equality (see `resolveWorkspacePathSafe`).\n */\nexport function getWorkspaceRoots(config?: t.LocalExecutionConfig): string[] {\n const root = getLocalCwd(config);\n const extras = config?.workspace?.additionalRoots ?? [];\n if (extras.length === 0) return [root];\n const seen = new Set<string>([root]);\n const out: string[] = [root];\n for (const extra of extras) {\n // Relative `additionalRoots` entries are anchored to the\n // workspace root (so monorepo configs like\n // `additionalRoots: ['../shared']` resolve to a sibling of\n // `root` rather than to `process.cwd()/../shared`, which would\n // mean something completely different on a server with a\n // different cwd).\n const abs = isAbsolute(extra) ? resolve(extra) : resolve(root, extra);\n if (!seen.has(abs)) {\n seen.add(abs);\n out.push(abs);\n }\n }\n return out;\n}\n\n/**\n * Pluggable spawn resolver. Honours `local.exec.spawn` first, falls\n * back to the legacy top-level `local.spawn`, then to Node's\n * `child_process.spawn`. Centralised so engine swapping is one knob.\n */\nexport function getSpawn(config?: t.LocalExecutionConfig): t.LocalSpawn {\n return (config?.exec?.spawn ?? config?.spawn ?? spawn) as t.LocalSpawn;\n}\n\n/**\n * Pluggable filesystem resolver. Honours `local.exec.fs`, falls back\n * to the Node-host implementation. A future remote engine supplies\n * its own implementation here and inherits every file-touching tool.\n */\nexport function getWorkspaceFS(config?: t.LocalExecutionConfig): WorkspaceFS {\n return config?.exec?.fs ?? nodeWorkspaceFS;\n}\n\n/**\n * Resolves the workspace boundary for *write* operations. Honours\n * `workspace.allowWriteOutside` (and the deprecated\n * `allowOutsideWorkspace`) by returning `null`, which the path-safety\n * helpers interpret as \"skip the write clamp\".\n */\nexport function getWriteRoots(\n config: t.LocalExecutionConfig = {}\n): string[] | null {\n // Granular flag wins over the legacy one when explicitly set\n // (true OR false) — otherwise a host tightening access during\n // migration (`allowOutsideWorkspace: true, workspace.\n // allowWriteOutside: false`) would still get the loose behavior\n // because the legacy flag short-circuited the OR. Codex P1 #36.\n const granular = config.workspace?.allowWriteOutside;\n if (granular === true) return null;\n if (granular === false) return getWorkspaceRoots(config);\n if (config.allowOutsideWorkspace === true) return null;\n return getWorkspaceRoots(config);\n}\n\n/**\n * Resolves the workspace boundary for *read* operations. Honours\n * `workspace.allowReadOutside` (and the deprecated\n * `allowOutsideWorkspace`) by returning `null`.\n */\nexport function getReadRoots(\n config: t.LocalExecutionConfig = {}\n): string[] | null {\n // Same precedence as getWriteRoots: granular flag is authoritative\n // when set, legacy flag is the fallback. Codex P1 #36.\n const granular = config.workspace?.allowReadOutside;\n if (granular === true) return null;\n if (granular === false) return getWorkspaceRoots(config);\n if (config.allowOutsideWorkspace === true) return null;\n return getWorkspaceRoots(config);\n}\n\nexport function getLocalSessionId(config?: t.LocalExecutionConfig): string {\n const cwd = getLocalCwd(config);\n const digest = createHash('sha1').update(cwd).digest('hex').slice(0, 12);\n return `${DEFAULT_LOCAL_SESSION_ID}:${digest}`;\n}\n\nconst missingSandboxRuntimeMessage = [\n 'Local sandbox is enabled, but @anthropic-ai/sandbox-runtime is not installed.',\n 'Install it with `npm install @anthropic-ai/sandbox-runtime`, or disable local sandboxing with `local.sandbox.enabled: false`.',\n].join(' ');\nconst sandboxRuntimePackage = '@anthropic-ai/sandbox-runtime';\n\n/** Lazy-loads the ESM-only sandbox runtime only when sandboxing is enabled. */\nfunction loadSandboxRuntime(): Promise<SandboxRuntimeModule> {\n sandboxRuntimePromise ??= import(\n sandboxRuntimePackage\n ) as Promise<SandboxRuntimeModule>;\n return sandboxRuntimePromise;\n}\n\nfunction shouldUseLocalSandbox(config: t.LocalExecutionConfig): boolean {\n return config.sandbox?.enabled === true;\n}\n\nlet sandboxOffWarned = false;\n\nfunction maybeWarnSandboxOff(config: t.LocalExecutionConfig): void {\n if (\n sandboxOffWarned ||\n shouldUseLocalSandbox(config) ||\n config.exec?.sandboxed === true\n ) {\n return;\n }\n sandboxOffWarned = true;\n // eslint-disable-next-line no-console\n console.warn(\n '[@librechat/agents] Local execution engine is running without ' +\n '@anthropic-ai/sandbox-runtime wrapping. The agent has full access to ' +\n 'the host filesystem and network. Set toolExecution.local.sandbox.enabled ' +\n '= true to opt into process sandboxing.'\n );\n}\n\n/**\n * Test-only reset hook for the sandbox-off warning latch.\n *\n * @internal Not part of the public SDK surface.\n */\nexport function _resetLocalEngineWarningsForTests(): void {\n sandboxOffWarned = false;\n}\n\nexport function truncateLocalOutput(\n value: string,\n maxChars = DEFAULT_MAX_OUTPUT_CHARS\n): string {\n if (value.length <= maxChars) {\n return value;\n }\n const head = Math.floor(maxChars * 0.6);\n const tail = maxChars - head;\n const omitted = value.length - maxChars;\n return `${value.slice(0, head)}\\n\\n[... ${omitted} characters truncated ...]\\n\\n${value.slice(\n value.length - tail\n )}`;\n}\n\nfunction stripQuotedContent(command: string): string {\n let output = '';\n let quote: '\"' | '\\'' | '`' | undefined;\n let escaped = false;\n\n for (let i = 0; i < command.length; i++) {\n const char = command[i];\n\n if (escaped) {\n escaped = false;\n output += ' ';\n continue;\n }\n\n if (char === '\\\\') {\n escaped = true;\n output += ' ';\n continue;\n }\n\n if (quote != null) {\n if (char === quote) {\n quote = undefined;\n }\n output += ' ';\n continue;\n }\n\n if (char === '\"' || char === '\\'' || char === '`') {\n quote = char;\n output += ' ';\n continue;\n }\n\n if (char === '#') {\n while (i < command.length && command[i] !== '\\n') {\n output += ' ';\n i++;\n }\n output += '\\n';\n continue;\n }\n\n output += char;\n }\n\n return output;\n}\n\nexport async function validateBashCommand(\n command: string,\n config: t.LocalExecutionConfig = {}\n): Promise<BashValidationResult> {\n const errors: string[] = [];\n const warnings: string[] = [];\n const normalized = stripQuotedContent(command);\n\n if (command.trim() === '') {\n errors.push('Command is empty.');\n }\n\n if (command.includes('\\0')) {\n errors.push('Command contains a NUL byte.');\n }\n\n if (config.allowDangerousCommands !== true) {\n let blocked = false;\n // Strip-then-match for the bare-form patterns (avoids false\n // positives where the destructive text is buried inside a\n // string the user is just printing).\n for (const pattern of dangerousCommandPatterns) {\n if (pattern.test(normalized)) {\n errors.push('Command matches a destructive command pattern.');\n blocked = true;\n break;\n }\n }\n // Original-form pass for patterns that REQUIRE matching quote\n // pairs around a destructive path. Without this, `rm -rf \"/\"`\n // and `chmod -R 777 \"/\"` slip past the strip-then-match pass\n // because their destructive target is inside quotes.\n if (!blocked) {\n for (const pattern of quotedDestructivePatterns) {\n if (pattern.test(command)) {\n errors.push(\n 'Command matches a destructive command pattern (quoted target).'\n );\n blocked = true;\n break;\n }\n }\n }\n if (!blocked) {\n for (const pattern of nestedShellDestructivePatterns) {\n if (pattern.test(command)) {\n errors.push(\n 'Command matches a destructive command pattern (nested shell payload).'\n );\n break;\n }\n }\n }\n }\n\n const bashAstMode = config.bashAst ?? 'off';\n if (bashAstMode !== 'off' && config.allowDangerousCommands !== true) {\n const findings = runBashAstChecks(normalized, bashAstMode);\n const split = bashAstFindingsToErrors(findings);\n errors.push(...split.errors);\n warnings.push(...split.warnings);\n }\n\n if (config.readOnly === true && mutatingCommandPattern.test(normalized)) {\n errors.push(\n 'Command appears to mutate files or repository state in read-only local mode.'\n );\n }\n\n // Use the same shell the actual execution path will use. Hard-coding\n // DEFAULT_SHELL here would reject perfectly valid commands when the\n // host configures `local.shell` to a non-bash binary (or when the\n // runtime doesn't have bash installed at all but does have e.g. zsh).\n const syntaxShell = config.shell ?? DEFAULT_SHELL;\n const syntax = await spawnLocalProcess(\n syntaxShell,\n ['-n', '-c', command],\n {\n ...config,\n timeoutMs: Math.min(config.timeoutMs ?? DEFAULT_TIMEOUT_MS, 5000),\n sandbox: { enabled: false },\n },\n { internal: true }\n ).catch(\n (error: Error): SpawnResult => ({\n stdout: '',\n stderr: error.message,\n exitCode: 1,\n timedOut: false,\n })\n );\n\n if (syntax.exitCode !== 0) {\n errors.push(\n syntax.stderr.trim() === ''\n ? 'Command failed shell syntax validation.'\n : `Command failed shell syntax validation: ${syntax.stderr.trim()}`\n );\n }\n\n if (/\\bsudo\\b/.test(normalized)) {\n warnings.push('Command requests elevated privileges with sudo.');\n }\n\n return {\n valid: errors.length === 0,\n errors,\n warnings,\n };\n}\n\nasync function ensureSandbox(\n config: t.LocalExecutionConfig,\n cwd: string\n): Promise<SandboxManagerType | undefined> {\n if (!shouldUseLocalSandbox(config)) {\n return undefined;\n }\n\n const runtime = await loadSandboxRuntime().catch((error: Error) => {\n throw new Error(`${missingSandboxRuntimeMessage} Cause: ${error.message}`);\n });\n\n const runtimeConfig = buildSandboxRuntimeConfig(\n config,\n cwd,\n runtime.getDefaultWritePaths\n );\n const nextKey = JSON.stringify(runtimeConfig);\n\n if (sandboxInitialized && sandboxConfigKey === nextKey) {\n return runtime.SandboxManager;\n }\n\n const dependencyCheck = runtime.SandboxManager.checkDependencies();\n if (dependencyCheck.errors.length > 0) {\n if (config.sandbox?.failIfUnavailable === true) {\n throw new Error(\n `Local sandbox requested but unavailable: ${dependencyCheck.errors.join('; ')}`\n );\n }\n return undefined;\n }\n\n if (sandboxInitialized) {\n await runtime.SandboxManager.reset();\n }\n\n await runtime.SandboxManager.initialize(runtimeConfig);\n sandboxInitialized = true;\n sandboxConfigKey = nextKey;\n return runtime.SandboxManager;\n}\n\n/**\n * Loopback addresses the in-process programmatic-tool bridge listens\n * on (`LocalProgrammaticToolCalling.ts` binds 127.0.0.1). Sandboxed\n * code launched by `run_tools_with_code` / `run_tools_with_bash` HTTPs\n * back to that address — without the entries below, the bridge is\n * silently blocked under sandbox.\n */\nconst BRIDGE_LOOPBACK_HOSTS = ['127.0.0.1', 'localhost', '::1'] as const;\n\n/**\n * Structural shape of the sandbox-runtime config we hand to\n * `SandboxManager.initialize()`. Intentionally NOT typed as the peer\n * `SandboxRuntimeConfig` from `@anthropic-ai/sandbox-runtime`: that\n * package is an OPTIONAL peer dep, and exporting a function whose\n * return type references it would make our generated `.d.ts` import\n * a module the consumer may not have installed (Codex P1 #22 — type-\n * checking would fail with `Cannot find module\n * '@anthropic-ai/sandbox-runtime'` for any host that doesn't enable\n * local sandboxing). The shape here is a structural subset; assignable\n * to the real `SandboxRuntimeConfig` at the one runtime call site.\n *\n * @internal\n */\nexport interface BuiltSandboxRuntimeConfig {\n network: {\n allowedDomains: string[];\n deniedDomains: string[];\n allowUnixSockets?: string[];\n allowAllUnixSockets?: boolean;\n allowLocalBinding?: boolean;\n allowMachLookup?: string[];\n };\n filesystem: {\n denyRead: string[];\n allowRead?: string[];\n allowWrite: string[];\n denyWrite: string[];\n allowGitConfig?: boolean;\n };\n}\n\nexport function buildSandboxRuntimeConfig(\n config: t.LocalExecutionConfig,\n cwd: string,\n getDefaultWritePaths: () => string[]\n): BuiltSandboxRuntimeConfig {\n const sandbox = config.sandbox;\n // Seed allowedDomains with loopback so the programmatic-tool bridge\n // works under sandbox. If the host explicitly denied a loopback\n // entry via `deniedDomains`, respect that and skip seeding it.\n const userAllowed = sandbox?.network?.allowedDomains ?? [];\n const denied = new Set(sandbox?.network?.deniedDomains ?? []);\n const seededLoopback = BRIDGE_LOOPBACK_HOSTS.filter(\n (host) => !denied.has(host) && !userAllowed.includes(host)\n );\n const allowedDomains = [...seededLoopback, ...userAllowed];\n // Mirror the file-tools workspace boundary: anything in\n // `additionalRoots` counts as in-workspace, so sandboxed shell/code\n // can write there too. Without this, file_tools can resolve a\n // sibling-root path but `bash`/`execute_code` is denied write\n // access — confusing divergence flagged in Codex P2 #15.\n const workspaceWriteRoots =\n config.workspace?.additionalRoots != null\n ? getWorkspaceRoots(config)\n : [cwd];\n return {\n network: {\n allowedDomains,\n deniedDomains: sandbox?.network?.deniedDomains ?? [],\n ...(sandbox?.network?.allowUnixSockets != null && {\n allowUnixSockets: sandbox.network.allowUnixSockets,\n }),\n ...(sandbox?.network?.allowAllUnixSockets != null && {\n allowAllUnixSockets: sandbox.network.allowAllUnixSockets,\n }),\n ...(sandbox?.network?.allowLocalBinding != null && {\n allowLocalBinding: sandbox.network.allowLocalBinding,\n }),\n ...(sandbox?.network?.allowMachLookup != null && {\n allowMachLookup: sandbox.network.allowMachLookup,\n }),\n },\n filesystem: {\n denyRead: sandbox?.filesystem?.denyRead ?? [],\n allowRead: sandbox?.filesystem?.allowRead,\n allowWrite: sandbox?.filesystem?.allowWrite ?? [\n ...workspaceWriteRoots,\n ...getDefaultWritePaths(),\n ],\n denyWrite: sandbox?.filesystem?.denyWrite ?? [\n '.env',\n '.env.*',\n '.git/config',\n '.git/hooks/**',\n ],\n allowGitConfig: sandbox?.filesystem?.allowGitConfig,\n },\n };\n}\n\n/**\n * Internal options for {@link spawnLocalProcess} that we don't want\n * exposed on the public `LocalExecutionConfig` type.\n *\n * @internal\n */\nexport interface SpawnLocalProcessOptions {\n /**\n * When true, suppress the \"sandbox is off\" warning AND its latch\n * for this spawn. Use for SDK-internal probes (`bash -n` syntax\n * preflight, `rg --version`, etc.) that intentionally run with\n * the sandbox forced off — the warning is noise for those, and\n * letting the latch flip would hide the warning when a *real*\n * unsandboxed execution happens later in the same process.\n */\n internal?: boolean;\n}\n\nexport const LOCAL_SPAWN_TIMEOUT_MS = Symbol('librechat.localSpawn.timeoutMs');\n\nexport async function spawnLocalProcess(\n command: string,\n args: string[],\n config: t.LocalExecutionConfig = {},\n options?: SpawnLocalProcessOptions\n): Promise<SpawnResult> {\n const cwd = getLocalCwd(config);\n const timeoutMs = config.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const maxOutputChars = config.maxOutputChars ?? DEFAULT_MAX_OUTPUT_CHARS;\n // Streaming caps. Local tools execute arbitrary shell/code, so a noisy\n // command (`yes`, `cat /dev/urandom | base64`, a verbose build) could\n // accumulate gigabytes in memory before hitting the post-close cap.\n // We bound in-memory per-stream and spill the rest to disk; we also\n // hard-kill the child once total streamed bytes pass `maxSpawnedBytes`\n // so a process producing unbounded output gets stopped instead of\n // letting the host OOM.\n const inMemoryCapBytes = maxOutputChars * 2;\n const hardKillBytes = config.maxSpawnedBytes ?? DEFAULT_MAX_SPAWNED_BYTES;\n const sandboxManager = await ensureSandbox(config, cwd);\n // Internal probes (validateBashCommand syntax preflight,\n // isRipgrepAvailable, syntax-check probe cache priming) pass\n // `internal: true` so they don't emit a misleading \"sandbox is\n // off\" warning AND don't flip `sandboxOffWarned = true`. Without\n // this Codex P2 path: a run with `sandbox.enabled: true` would\n // see a false warning from the syntax preflight, and the latch\n // flip would suppress the warning in a *later* truly-unsandboxed\n // run — exactly the scenario operators need to see.\n if (sandboxManager == null && options?.internal !== true) {\n maybeWarnSandboxOff(config);\n }\n let spawnCommand = command;\n let spawnArgs = args;\n\n if (sandboxManager != null) {\n const rendered = [command, ...args.map(shellQuote)].join(' ');\n const sandboxed = await sandboxManager.wrapWithSandbox(rendered);\n spawnCommand = config.shell ?? DEFAULT_SHELL;\n spawnArgs = ['-lc', sandboxed];\n }\n\n const launcher = getSpawn(config);\n return new Promise<SpawnResult>((resolveResult, reject) => {\n const spawnOptions: import('child_process').SpawnOptions = {\n cwd,\n detached: process.platform !== 'win32',\n env: { ...process.env, ...(config.env ?? {}) },\n stdio: ['ignore', 'pipe', 'pipe'],\n };\n Object.defineProperty(spawnOptions, LOCAL_SPAWN_TIMEOUT_MS, {\n value: timeoutMs,\n });\n const child = launcher(spawnCommand, spawnArgs, spawnOptions);\n\n let stdout = '';\n let stderr = '';\n let totalSpawnedBytes = 0;\n let overflowKilled = false;\n let spillStream: import('fs').WriteStream | undefined;\n let spillPath: string | undefined;\n let settled = false;\n let timedOut = false;\n let timeout: NodeJS.Timeout | undefined;\n\n const ensureSpill = (): void => {\n if (spillStream != null) return;\n // Lazy-open the temp file the first time a stream's in-memory\n // buffer overflows. Seed it with everything we've buffered so\n // the file holds the FULL output (not just the post-cap tail).\n // Uses the static `createWriteStream` import — `require('fs')`\n // would throw `ReferenceError: require is not defined` in ESM\n // consumers (this package ships both `dist/cjs` and `dist/esm`).\n spillPath = resolve(tmpdir(), `lc-local-output-${randomUUID()}.txt`);\n spillStream = createWriteStream(spillPath);\n spillStream.write('===== stdout =====\\n');\n spillStream.write(stdout);\n spillStream.write('\\n===== stderr =====\\n');\n spillStream.write(stderr);\n spillStream.write('\\n===== overflow stream begins here =====\\n');\n };\n\n const handleChunk = (buf: Buffer, kind: 'stdout' | 'stderr'): void => {\n totalSpawnedBytes += buf.length;\n // hardKillBytes <= 0 means \"no cap\" per the public config contract\n // (see LocalExecutionConfig.maxSpawnedBytes). Skip the kill check\n // entirely in that case so a single byte doesn't terminate the run.\n if (\n hardKillBytes > 0 &&\n totalSpawnedBytes > hardKillBytes &&\n !overflowKilled\n ) {\n overflowKilled = true;\n killProcessTree(child);\n return;\n }\n const current = kind === 'stdout' ? stdout : stderr;\n if (current.length < inMemoryCapBytes) {\n const text = buf.toString('utf8');\n if (kind === 'stdout') stdout += text;\n else stderr += text;\n if (current.length + text.length >= inMemoryCapBytes) {\n ensureSpill();\n }\n } else {\n ensureSpill();\n spillStream!.write(`[${kind}] `);\n spillStream!.write(buf);\n }\n };\n\n const finish = (result: SpawnResult): void => {\n if (settled) {\n return;\n }\n settled = true;\n if (timeout != null) {\n clearTimeout(timeout);\n }\n const finalize = (): void => {\n const truncated = {\n stdout: truncateLocalOutput(result.stdout, maxOutputChars),\n stderr: truncateLocalOutput(result.stderr, maxOutputChars),\n };\n resolveResult({\n ...result,\n ...truncated,\n ...(spillPath != null ? { fullOutputPath: spillPath } : {}),\n });\n };\n if (spillStream == null) {\n finalize();\n return;\n }\n // Wait for the temp file to flush before reporting the path.\n // Otherwise the model sees `full_output_path: …` for a file\n // that's still being written.\n spillStream.end(() => finalize());\n };\n\n const fail = (error: Error): void => {\n if (settled) {\n return;\n }\n settled = true;\n if (timeout != null) {\n clearTimeout(timeout);\n }\n if (spillStream != null) {\n spillStream.end();\n }\n reject(error);\n };\n\n if (timeoutMs > 0) {\n timeout = setTimeout(() => {\n timedOut = true;\n killProcessTree(child);\n }, timeoutMs);\n }\n\n child.stdout.on('data', (chunk: Buffer) => {\n handleChunk(chunk, 'stdout');\n });\n\n child.stderr.on('data', (chunk: Buffer) => {\n handleChunk(chunk, 'stderr');\n });\n\n child.on('error', fail);\n\n child.on('close', (exitCode, signal) => {\n // Synthesize a non-zero exit code whenever the process exited\n // by signal — Node reports `exitCode: null` in that case and\n // the formatter only prints non-null exit codes, so signal\n // kills (overflow guard, `kill -9 $$` from inside the script,\n // native crashes, OS OOM killer, …) would otherwise look like\n // successful runs (Codex P1 + Codex P2). Overflow path keeps\n // its 137 (SIGKILL) for compatibility; other signals map per\n // POSIX `128 + signum`.\n let finalExit: number | null = exitCode;\n if (finalExit == null) {\n if (overflowKilled) {\n finalExit = 137;\n } else if (signal != null) {\n finalExit = exitCodeForSignal(signal);\n }\n }\n finish({\n stdout,\n stderr,\n exitCode: finalExit,\n timedOut,\n ...(overflowKilled ? { overflowKilled: true } : {}),\n ...(signal != null ? { signal } : {}),\n });\n });\n });\n}\n\nexport async function executeLocalBash(\n command: string,\n config: t.LocalExecutionConfig = {}\n): Promise<SpawnResult> {\n const validation = await validateBashCommand(command, config);\n if (!validation.valid) {\n throw new Error(validation.errors.join('\\n'));\n }\n const shell = config.shell ?? DEFAULT_SHELL;\n return spawnLocalProcess(shell, ['-lc', command], config);\n}\n\n/**\n * Variant of `executeLocalBash` that exposes `args` as positional\n * shell parameters (`$1`, `$2`, …). Mirrors what the other runtimes\n * do in `getRuntimeCommand`. Uses the standard `bash -c <code> --\n * arg0 arg1 …` form: the `--` becomes `$0`, then `args[0]` is `$1`\n * and so on. Same AST validation as the no-args path.\n *\n * Used by both the `execute_code`/`lang:'bash'` path AND the\n * `bash_tool` factory so the schema's `args` contract works\n * identically in both surfaces.\n */\n/**\n * Matches a single arg that, on its own, references a protected\n * location (`/`, `~`, `$HOME`, `${HOME}`, `.`, with optional trailing\n * slash, wildcard, or dot-glob suffix). Used to spot the\n * `command: 'rm -rf \"$1\"', args: ['/']` shape where the destructive\n * target is moved into a positional arg to evade the command regex.\n * Codex P1 [45], extended for dot-glob in Codex P1 [47] (mirrors the\n * `DESTRUCTIVE_TARGET` suffix matrix exactly).\n */\nconst PROTECTED_TARGET_ARG_RE = /^(?:\\/|~|\\$\\{?HOME\\}?|\\.)(?:\\/?\\.?\\*|\\/)?$/;\n\n/**\n * Mutating-op recognizer for the args check. Conservative: only the\n * three operations the destructive-command guard already covers\n * directly (`rm -rf …`, `chmod -R …`, `chown -R …`). Other shell\n * builtins might mutate state (`mv`, `cp` over an existing file,\n * etc.) but the destructive guard doesn't try to catch those today,\n * so we don't widen here either.\n */\nconst DESTRUCTIVE_OP_IN_COMMAND_RE =\n /\\b(?:rm\\s+-[^\\s]*[rf]|chmod\\s+-R|chown\\s+-R)\\b/;\n\nexport async function executeLocalBashWithArgs(\n command: string,\n args: readonly string[],\n config: t.LocalExecutionConfig = {}\n): Promise<SpawnResult> {\n const validation = await validateBashCommand(command, config);\n if (!validation.valid) {\n throw new Error(validation.errors.join('\\n'));\n }\n // Per-arg protected-target check (Codex P1 [45]). The command\n // regex can't see `$1`/`$@` substitutions at runtime — `command:\n // 'rm -rf \"$1\"', args: ['/']` would expand to `rm -rf '/'` inside\n // bash but the validator only saw `rm -rf \"$1\"` (no destructive\n // target). Block when (a) the command contains a destructive op\n // AND (b) at least one arg matches the protected-target shape.\n // Skipped when allowDangerousCommands is true (host-opted-in).\n if (\n args.length > 0 &&\n config.allowDangerousCommands !== true &&\n DESTRUCTIVE_OP_IN_COMMAND_RE.test(command)\n ) {\n const offending = args.find((a) => PROTECTED_TARGET_ARG_RE.test(a));\n if (offending !== undefined) {\n throw new Error(\n `Command matches a destructive command pattern (protected target \"${offending}\" passed via positional arg).`\n );\n }\n }\n const shell = config.shell ?? DEFAULT_SHELL;\n return spawnLocalProcess(shell, ['-lc', command, '--', ...args], config);\n}\n\nexport async function executeLocalCode(\n input: {\n lang: string;\n code: string;\n args?: string[];\n },\n config: t.LocalExecutionConfig = {}\n): Promise<SpawnResult> {\n if (input.lang === 'bash') {\n // Append `args` as positional parameters via the standard\n // `bash -c <code> -- <args...>` form so `$1`, `$2`, … inside\n // `code` resolve correctly. Honours the same args contract the\n // other runtimes (py, js, …) already support.\n if (input.args != null && input.args.length > 0) {\n return executeLocalBashWithArgs(input.code, input.args, config);\n }\n return executeLocalBash(input.code, config);\n }\n\n const tempDir = resolve(tmpdir(), `lc-local-${randomUUID()}`);\n await mkdir(tempDir, { recursive: true });\n\n try {\n const runtime = getRuntimeCommand(\n input.lang,\n tempDir,\n input.code,\n input.args,\n config.shell\n );\n if (runtime.source != null) {\n await writeFile(\n resolve(tempDir, runtime.fileName),\n runtime.source,\n 'utf8'\n );\n }\n return await spawnLocalProcess(runtime.command, runtime.args, config);\n } finally {\n await rm(tempDir, { recursive: true, force: true });\n }\n}\n\nfunction getRuntimeCommand(\n lang: string,\n tempDir: string,\n code: string,\n args: string[] = [],\n // Override for the shell used by compile-style runtimes (`rs`,\n // `c`, `cpp`, `java`, `d`, `f90`). Threads `local.shell` so a host\n // that doesn't have bash (or wants `/bin/sh` / zsh) can still\n // execute these languages — Codex P2 #29: the bare-bash hardcode\n // mirrored the same gap that Codex P1 #6 fixed for the syntax\n // preflight, but had been missed for these runtime invocations.\n shellOverride?: string\n): RuntimeCommand {\n const fileFor = (name: string): string => resolve(tempDir, name);\n const shell = shellOverride ?? configShell();\n\n switch (lang) {\n case 'py':\n return {\n command: 'python3',\n args: [fileFor('main.py'), ...args],\n fileName: 'main.py',\n source: code,\n };\n case 'js':\n return {\n command: 'node',\n args: [fileFor('main.js'), ...args],\n fileName: 'main.js',\n source: code,\n };\n case 'ts':\n return {\n command: 'npx',\n args: ['--no-install', 'tsx', fileFor('main.ts'), ...args],\n fileName: 'main.ts',\n source: code,\n };\n case 'php':\n return {\n command: 'php',\n args: [fileFor('main.php'), ...args],\n fileName: 'main.php',\n source: code,\n };\n case 'go':\n return {\n command: 'go',\n args: ['run', fileFor('main.go'), ...args],\n fileName: 'main.go',\n source: code,\n };\n case 'rs':\n return {\n command: shell,\n args: [\n '-lc',\n `rustc ${shellQuote(fileFor('main.rs'))} -o ${shellQuote(\n fileFor('main-rs')\n )} && ${shellQuote(fileFor('main-rs'))} ${args.map(shellQuote).join(' ')}`,\n ],\n fileName: 'main.rs',\n source: code,\n };\n case 'c':\n return {\n command: shell,\n args: [\n '-lc',\n `cc ${shellQuote(fileFor('main.c'))} -o ${shellQuote(\n fileFor('main-c')\n )} && ${shellQuote(fileFor('main-c'))} ${args.map(shellQuote).join(' ')}`,\n ],\n fileName: 'main.c',\n source: code,\n };\n case 'cpp':\n return {\n command: shell,\n args: [\n '-lc',\n `c++ ${shellQuote(fileFor('main.cpp'))} -o ${shellQuote(\n fileFor('main-cpp')\n )} && ${shellQuote(fileFor('main-cpp'))} ${args.map(shellQuote).join(' ')}`,\n ],\n fileName: 'main.cpp',\n source: code,\n };\n case 'java':\n return {\n command: shell,\n args: [\n '-lc',\n `javac ${shellQuote(fileFor('Main.java'))} && java -cp ${shellQuote(\n tempDir\n )} Main ${args.map(shellQuote).join(' ')}`,\n ],\n fileName: 'Main.java',\n source: code,\n };\n case 'r':\n return {\n command: 'Rscript',\n args: [fileFor('main.R'), ...args],\n fileName: 'main.R',\n source: code,\n };\n case 'd':\n return {\n command: shell,\n args: [\n '-lc',\n `dmd ${shellQuote(fileFor('main.d'))} -of=${shellQuote(\n fileFor('main-d')\n )} && ${shellQuote(fileFor('main-d'))} ${args.map(shellQuote).join(' ')}`,\n ],\n fileName: 'main.d',\n source: code,\n };\n case 'f90':\n return {\n command: shell,\n args: [\n '-lc',\n `gfortran ${shellQuote(fileFor('main.f90'))} -o ${shellQuote(\n fileFor('main-f90')\n )} && ${shellQuote(fileFor('main-f90'))} ${args.map(shellQuote).join(' ')}`,\n ],\n fileName: 'main.f90',\n source: code,\n };\n default:\n throw new Error(`Unsupported local runtime: ${lang}`);\n }\n}\n\nfunction configShell(): string {\n return process.platform === 'win32' ? 'bash.exe' : 'bash';\n}\n\n/**\n * How long after SIGTERM we wait before escalating to SIGKILL. A\n * cooperative process gets a graceful chance to flush + clean up;\n * a process that ignores or traps SIGTERM (`trap '' TERM`) gets\n * killed unconditionally so timeoutMs / maxSpawnedBytes can't be\n * defeated by a hostile script. Codex P1 #28 — pre-fix the spawn\n * promise would never resolve in that case and the entire tool run\n * would hang past the advertised timeout.\n */\nconst SIGKILL_ESCALATION_MS = 2000;\n\nfunction sigterm(child: ChildProcess): void {\n if (child.pid == null) {\n child.kill('SIGTERM');\n return;\n }\n try {\n if (process.platform === 'win32') {\n child.kill('SIGTERM');\n return;\n }\n process.kill(-child.pid, 'SIGTERM');\n } catch {\n child.kill('SIGTERM');\n }\n}\n\nfunction sigkill(child: ChildProcess): void {\n if (child.exitCode != null || child.signalCode != null) return;\n if (child.pid == null) {\n child.kill('SIGKILL');\n return;\n }\n try {\n if (process.platform === 'win32') {\n child.kill('SIGKILL');\n return;\n }\n process.kill(-child.pid, 'SIGKILL');\n } catch {\n try {\n child.kill('SIGKILL');\n } catch {\n /* already dead */\n }\n }\n}\n\nfunction killProcessTree(child: ChildProcess): void {\n sigterm(child);\n // Escalate to SIGKILL if the child is still alive after the grace\n // window. Use unref() so the timer doesn't keep the Node process\n // alive past the parent's natural exit.\n const escalation = setTimeout(() => sigkill(child), SIGKILL_ESCALATION_MS);\n escalation.unref();\n child.once('close', () => clearTimeout(escalation));\n}\n\nexport function shellQuote(value: string): string {\n if (value === '') {\n return '\\'\\'';\n }\n if (/^[A-Za-z0-9_/:=.,@%+-]+$/.test(value)) {\n return value;\n }\n return `'${value.replace(/'/g, '\\'\\\\\\'\\'')}'`;\n}\n\nexport function resolveWorkspacePath(\n filePath: string,\n config: t.LocalExecutionConfig = {},\n intent: 'read' | 'write' = 'write'\n): string {\n const cwd = getLocalCwd(config);\n const absolutePath = isAbsolute(filePath)\n ? resolve(filePath)\n : resolve(cwd, filePath);\n\n const roots =\n intent === 'write' ? getWriteRoots(config) : getReadRoots(config);\n if (roots == null) return absolutePath; // explicit allow-outside\n\n if (absolutePath === cwd || isInsideAnyRoot(absolutePath, roots)) {\n return absolutePath;\n }\n throw new Error(`Path is outside the local workspace: ${filePath}`);\n}\n\nfunction isInsideAnyRoot(absolutePath: string, roots: string[]): boolean {\n for (const root of roots) {\n if (absolutePath === root) return true;\n const rel = relative(root, absolutePath);\n if (!rel.startsWith('..') && !isAbsolute(rel)) return true;\n }\n return false;\n}\n\ntype RealpathFn = (p: string) => Promise<string>;\n\nasync function realpathOrSelf(\n absolutePath: string,\n realpathImpl: RealpathFn = realpath\n): Promise<string> {\n try {\n return await realpathImpl(absolutePath);\n } catch {\n return absolutePath;\n }\n}\n\n/**\n * Resolves the realpath of `absolutePath`, falling back to the nearest\n * existing ancestor when the target itself does not yet exist (so the\n * containment check still works for `write_file` to a brand-new path).\n *\n * Codex P2 #38: takes the realpath impl as a parameter so callers\n * can route through `WorkspaceFS.realpath` when a custom engine is\n * configured. Pre-fix, host `fs/promises.realpath` would fail on a\n * remote/in-memory FS path and silently fall back to lexical\n * containment, leaving the symlink-escape clamp ineffective on\n * non-default engines.\n */\nasync function realpathOfPathOrAncestor(\n absolutePath: string,\n realpathImpl: RealpathFn = realpath\n): Promise<string> {\n let current = absolutePath;\n let suffix = '';\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while (true) {\n try {\n const real = await realpathImpl(current);\n return suffix === '' ? real : resolve(real, suffix);\n } catch {\n const parent = resolve(current, '..');\n if (parent === current) {\n return absolutePath;\n }\n const base = current.slice(parent.length + 1);\n suffix = suffix === '' ? base : `${base}/${suffix}`;\n current = parent;\n }\n }\n}\n\n/**\n * Resolves a workspace path AND follows any symlinks before checking\n * containment, so a symlink inside the workspace pointing outside is\n * rejected even though the lexical path looks safe. Handles paths that\n * don't yet exist (e.g. write_file targets) by realpath-resolving the\n * nearest existing ancestor and re-attaching the unresolved suffix.\n */\nexport async function resolveWorkspacePathSafe(\n filePath: string,\n config: t.LocalExecutionConfig = {},\n intent: 'read' | 'write' = 'write'\n): Promise<string> {\n const lexical = resolveWorkspacePath(filePath, config, intent);\n const roots =\n intent === 'write' ? getWriteRoots(config) : getReadRoots(config);\n if (roots == null) {\n return lexical;\n }\n // Route realpath through the configured WorkspaceFS so a custom\n // engine (in-memory, remote) gets the same symlink-escape clamp\n // the host-fs path gets. Codex P2 #38: pre-fix the host realpath\n // would fail on a non-default FS path and silently fall back to\n // lexical containment, leaving the clamp ineffective.\n const fsRealpath: RealpathFn = (p) => getWorkspaceFS(config).realpath(p);\n const realRoots = await Promise.all(\n roots.map((r) => realpathOrSelf(r, fsRealpath))\n );\n const realPath = await realpathOfPathOrAncestor(lexical, fsRealpath);\n if (isInsideAnyRoot(realPath, realRoots)) {\n return lexical;\n }\n throw new Error(\n `Path is outside the local workspace (symlink escape): ${filePath}`\n );\n}\n"],"mappings":";;;;;;;;;AAYA,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;;;;;;;AAOjC,MAAM,4BAA4B,KAAK,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C,CAChD;CAEA,IAAI,gBAAgB,MADG,yBAAyB,SAAS,UAAU,GACrC,SAAS,GACrC,OAAO;CAET,MAAM,IAAI,MACR,yDAAyD,UAC3D;AACF"}
1
+ {"version":3,"file":"LocalExecutionEngine.mjs","names":[],"sources":["../../../../src/tools/local/LocalExecutionEngine.ts"],"mappings":";;;;;;;;;AAYA,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAOjC,MAAM,4BAA4B,KAAK,OAAO;AAC9C,MAAM,2BAA2B;AACjC,MAAM,gBAAgB,QAAQ,aAAa,UAAU,aAAa;AAuBlE,MAAM,qBAAqB;AAE3B,MAAM,2BAAkD;CACtD,IAAI,OACF,+FAA+F,mBAAmB,gBACpH;CACA;CACA;CACA,IAAI,OACF,iDAAiD,mBAAmB,gBACtE;CACA,IAAI,OACF,2CAA2C,mBAAmB,gBAChE;CACA;AACF;AAoBA,MAAM,4BAAmD;CACvD,IAAI,OACF,2DAA2D,mBAAmB,KAChF;CACA,IAAI,OACF,qDAAqD,mBAAmB,KAC1E;CACA,IAAI,OACF,+CAA+C,mBAAmB,KACpE;AACF;AAiBA,MAAM,iCAAwD;iBAC5D,IAAI,OACF,sIAEF;iBACA,IAAI,OACF,mIAEF;iBACA,IAAI,OACF,6HAEF;AACF;AAEA,MAAM,yBACJ;AAqCF,MAAM,sBAA8C;CAClD,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,SAAS;CACT,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;AACX;AACA,SAAS,kBAAkB,QAA+B;CACxD,IAAI,UAAU,MAAM,OAAO;CAC3B,OAAO,oBAAoB,WAAW;AACxC;AAqBA,IAAI;AACJ,IAAI,qBAAqB;AACzB,IAAI;AAQJ,SAAS,sBACP,QACiC;CACjC,OAAO,YAAY,UAAU,WAAW;AAC1C;AAEA,SAAgB,4BACd,QACwB;CACx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