@levelcode/sdk 0.2.4 → 0.2.5

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 (324) hide show
  1. package/dist/index.cjs +493 -289
  2. package/dist/index.cjs.map +8 -7
  3. package/dist/index.mjs +564 -360
  4. package/dist/index.mjs.map +8 -7
  5. package/package.json +1 -1
  6. package/dist/agents/constants.d.ts +0 -1
  7. package/dist/agents/team/apprentice.d.ts +0 -3
  8. package/dist/agents/team/coordinator.d.ts +0 -3
  9. package/dist/agents/team/cto.d.ts +0 -3
  10. package/dist/agents/team/designer.d.ts +0 -3
  11. package/dist/agents/team/director.d.ts +0 -3
  12. package/dist/agents/team/distinguished-engineer.d.ts +0 -3
  13. package/dist/agents/team/fellow.d.ts +0 -3
  14. package/dist/agents/team/index.d.ts +0 -27
  15. package/dist/agents/team/intern.d.ts +0 -3
  16. package/dist/agents/team/junior-engineer.d.ts +0 -3
  17. package/dist/agents/team/manager.d.ts +0 -3
  18. package/dist/agents/team/mid-level-engineer.d.ts +0 -3
  19. package/dist/agents/team/principal-engineer.d.ts +0 -3
  20. package/dist/agents/team/product-lead.d.ts +0 -3
  21. package/dist/agents/team/researcher.d.ts +0 -3
  22. package/dist/agents/team/role-hierarchy.d.ts +0 -24
  23. package/dist/agents/team/scientist.d.ts +0 -3
  24. package/dist/agents/team/senior-engineer.d.ts +0 -3
  25. package/dist/agents/team/senior-staff-engineer.d.ts +0 -3
  26. package/dist/agents/team/staff-engineer.d.ts +0 -3
  27. package/dist/agents/team/sub-manager.d.ts +0 -3
  28. package/dist/agents/team/tester.d.ts +0 -3
  29. package/dist/agents/team/vp-engineering.d.ts +0 -3
  30. package/dist/agents/types/agent-definition.d.ts +0 -296
  31. package/dist/agents/types/secret-agent-definition.d.ts +0 -19
  32. package/dist/agents/types/tools.d.ts +0 -308
  33. package/dist/agents/types/util-types.d.ts +0 -134
  34. package/dist/common/src/actions.d.ts +0 -176
  35. package/dist/common/src/analytics-core.d.ts +0 -52
  36. package/dist/common/src/analytics.d.ts +0 -9
  37. package/dist/common/src/browser-actions.d.ts +0 -1200
  38. package/dist/common/src/constants/agents.d.ts +0 -47
  39. package/dist/common/src/constants/analytics-events.d.ts +0 -111
  40. package/dist/common/src/constants/byok.d.ts +0 -2
  41. package/dist/common/src/constants/claude-oauth.d.ts +0 -36
  42. package/dist/common/src/constants/index.d.ts +0 -4
  43. package/dist/common/src/constants/knowledge.d.ts +0 -21
  44. package/dist/common/src/constants/limits.d.ts +0 -14
  45. package/dist/common/src/constants/model-config.d.ts +0 -117
  46. package/dist/common/src/constants/paths.d.ts +0 -23
  47. package/dist/common/src/constants/skills.d.ts +0 -42
  48. package/dist/common/src/constants/ui.d.ts +0 -14
  49. package/dist/common/src/env-ci.d.ts +0 -22
  50. package/dist/common/src/env-process.d.ts +0 -28
  51. package/dist/common/src/env-schema.d.ts +0 -24
  52. package/dist/common/src/env.d.ts +0 -16
  53. package/dist/common/src/mcp/client.d.ts +0 -6
  54. package/dist/common/src/old-constants.d.ts +0 -10
  55. package/dist/common/src/project-file-tree.d.ts +0 -27
  56. package/dist/common/src/templates/agent-validation.d.ts +0 -48
  57. package/dist/common/src/templates/initial-agents-dir/types/agent-definition.d.ts +0 -296
  58. package/dist/common/src/templates/initial-agents-dir/types/tools.d.ts +0 -308
  59. package/dist/common/src/templates/initial-agents-dir/types/util-types.d.ts +0 -128
  60. package/dist/common/src/testing/errors.d.ts +0 -14
  61. package/dist/common/src/testing/mock-modules.d.ts +0 -11
  62. package/dist/common/src/testing/mock-types.d.ts +0 -97
  63. package/dist/common/src/testing/mocks/analytics.d.ts +0 -182
  64. package/dist/common/src/testing/mocks/child-process.d.ts +0 -29
  65. package/dist/common/src/testing/mocks/crypto.d.ts +0 -159
  66. package/dist/common/src/testing/mocks/database.d.ts +0 -197
  67. package/dist/common/src/testing/mocks/fetch.d.ts +0 -35
  68. package/dist/common/src/testing/mocks/filesystem.d.ts +0 -31
  69. package/dist/common/src/testing/mocks/index.d.ts +0 -25
  70. package/dist/common/src/testing/mocks/logger.d.ts +0 -35
  71. package/dist/common/src/testing/mocks/stream.d.ts +0 -203
  72. package/dist/common/src/testing/mocks/timers.d.ts +0 -27
  73. package/dist/common/src/testing/mocks/tree-sitter.d.ts +0 -58
  74. package/dist/common/src/testing-env-process.d.ts +0 -7
  75. package/dist/common/src/tools/constants.d.ts +0 -17
  76. package/dist/common/src/tools/list.d.ts +0 -1152
  77. package/dist/common/src/tools/params/tool/add-message.d.ts +0 -19
  78. package/dist/common/src/tools/params/tool/add-subgoal.d.ts +0 -26
  79. package/dist/common/src/tools/params/tool/ask-user.d.ts +0 -59
  80. package/dist/common/src/tools/params/tool/browser-logs.d.ts +0 -127
  81. package/dist/common/src/tools/params/tool/code-search.d.ts +0 -30
  82. package/dist/common/src/tools/params/tool/create-plan.d.ts +0 -30
  83. package/dist/common/src/tools/params/tool/end-turn.d.ts +0 -13
  84. package/dist/common/src/tools/params/tool/find-files.d.ts +0 -31
  85. package/dist/common/src/tools/params/tool/glob.d.ts +0 -26
  86. package/dist/common/src/tools/params/tool/list-directory.d.ts +0 -25
  87. package/dist/common/src/tools/params/tool/lookup-agent-info.d.ts +0 -13
  88. package/dist/common/src/tools/params/tool/propose-str-replace.d.ts +0 -40
  89. package/dist/common/src/tools/params/tool/propose-write-file.d.ts +0 -29
  90. package/dist/common/src/tools/params/tool/read-docs.d.ts +0 -19
  91. package/dist/common/src/tools/params/tool/read-files.d.ts +0 -35
  92. package/dist/common/src/tools/params/tool/read-subtree.d.ts +0 -40
  93. package/dist/common/src/tools/params/tool/run-file-change-hooks.d.ts +0 -63
  94. package/dist/common/src/tools/params/tool/run-terminal-command.d.ts +0 -88
  95. package/dist/common/src/tools/params/tool/send-message.d.ts +0 -26
  96. package/dist/common/src/tools/params/tool/set-messages.d.ts +0 -15
  97. package/dist/common/src/tools/params/tool/set-output.d.ts +0 -15
  98. package/dist/common/src/tools/params/tool/skill.d.ts +0 -28
  99. package/dist/common/src/tools/params/tool/spawn-agent-inline.d.ts +0 -17
  100. package/dist/common/src/tools/params/tool/spawn-agents.d.ts +0 -26
  101. package/dist/common/src/tools/params/tool/str-replace.d.ts +0 -43
  102. package/dist/common/src/tools/params/tool/suggest-followups.d.ts +0 -26
  103. package/dist/common/src/tools/params/tool/task-completed.d.ts +0 -13
  104. package/dist/common/src/tools/params/tool/task-create.d.ts +0 -24
  105. package/dist/common/src/tools/params/tool/task-get.d.ts +0 -15
  106. package/dist/common/src/tools/params/tool/task-list.d.ts +0 -13
  107. package/dist/common/src/tools/params/tool/task-update.d.ts +0 -29
  108. package/dist/common/src/tools/params/tool/team-create.d.ts +0 -17
  109. package/dist/common/src/tools/params/tool/team-delete.d.ts +0 -13
  110. package/dist/common/src/tools/params/tool/think-deeply.d.ts +0 -15
  111. package/dist/common/src/tools/params/tool/update-subgoal.d.ts +0 -25
  112. package/dist/common/src/tools/params/tool/web-search.d.ts +0 -25
  113. package/dist/common/src/tools/params/tool/write-file.d.ts +0 -31
  114. package/dist/common/src/tools/params/tool/write-todos.d.ts +0 -18
  115. package/dist/common/src/tools/params/utils.d.ts +0 -35
  116. package/dist/common/src/tools/utils.d.ts +0 -4
  117. package/dist/common/src/types/agent-template.d.ts +0 -156
  118. package/dist/common/src/types/contracts/agent-runtime.d.ts +0 -36
  119. package/dist/common/src/types/contracts/analytics.d.ts +0 -8
  120. package/dist/common/src/types/contracts/billing.d.ts +0 -40
  121. package/dist/common/src/types/contracts/client.d.ts +0 -45
  122. package/dist/common/src/types/contracts/database.d.ts +0 -80
  123. package/dist/common/src/types/contracts/env.d.ts +0 -150
  124. package/dist/common/src/types/contracts/llm.d.ts +0 -102
  125. package/dist/common/src/types/contracts/logger.d.ts +0 -8
  126. package/dist/common/src/types/dynamic-agent-template.d.ts +0 -227
  127. package/dist/common/src/types/filesystem.d.ts +0 -6
  128. package/dist/common/src/types/function-params.d.ts +0 -15
  129. package/dist/common/src/types/grant.d.ts +0 -2
  130. package/dist/common/src/types/json.d.ts +0 -9
  131. package/dist/common/src/types/mcp.d.ts +0 -31
  132. package/dist/common/src/types/messages/content-part.d.ts +0 -46
  133. package/dist/common/src/types/messages/data-content.d.ts +0 -3
  134. package/dist/common/src/types/messages/levelcode-message.d.ts +0 -37
  135. package/dist/common/src/types/messages/provider-metadata.d.ts +0 -3
  136. package/dist/common/src/types/print-mode.d.ts +0 -155
  137. package/dist/common/src/types/session-state.d.ts +0 -94
  138. package/dist/common/src/types/skill.d.ts +0 -31
  139. package/dist/common/src/types/source.d.ts +0 -8
  140. package/dist/common/src/types/spawn.d.ts +0 -8
  141. package/dist/common/src/types/team-config-schemas.d.ts +0 -217
  142. package/dist/common/src/types/team-config.d.ts +0 -42
  143. package/dist/common/src/types/team-hook-events.d.ts +0 -36
  144. package/dist/common/src/types/team-protocol.d.ts +0 -64
  145. package/dist/common/src/util/agent-id-parsing.d.ts +0 -22
  146. package/dist/common/src/util/agent-name-normalization.d.ts +0 -12
  147. package/dist/common/src/util/array.d.ts +0 -6
  148. package/dist/common/src/util/credentials.d.ts +0 -11
  149. package/dist/common/src/util/error.d.ts +0 -128
  150. package/dist/common/src/util/file.d.ts +0 -133
  151. package/dist/common/src/util/format-code-search.d.ts +0 -16
  152. package/dist/common/src/util/lru-cache.d.ts +0 -30
  153. package/dist/common/src/util/messages.d.ts +0 -46
  154. package/dist/common/src/util/model-utils.d.ts +0 -8
  155. package/dist/common/src/util/object.d.ts +0 -22
  156. package/dist/common/src/util/promise.d.ts +0 -16
  157. package/dist/common/src/util/random.d.ts +0 -1
  158. package/dist/common/src/util/skills.d.ts +0 -5
  159. package/dist/common/src/util/stop-sequence.d.ts +0 -14
  160. package/dist/common/src/util/string.d.ts +0 -82
  161. package/dist/common/src/util/xml.d.ts +0 -12
  162. package/dist/common/src/util/zod-schema.d.ts +0 -5
  163. package/dist/common/src/utils/dev-phases.d.ts +0 -23
  164. package/dist/common/src/utils/file-lock.d.ts +0 -13
  165. package/dist/common/src/utils/team-analytics.d.ts +0 -16
  166. package/dist/common/src/utils/team-discovery.d.ts +0 -47
  167. package/dist/common/src/utils/team-fs.d.ts +0 -20
  168. package/dist/common/src/utils/team-hook-emitter.d.ts +0 -40
  169. package/dist/common/src/utils/team-presets.d.ts +0 -35
  170. package/dist/packages/agent-runtime/src/constants.d.ts +0 -1
  171. package/dist/packages/agent-runtime/src/fast-rewrite.d.ts +0 -45
  172. package/dist/packages/agent-runtime/src/find-files/request-files-prompt.d.ts +0 -71
  173. package/dist/packages/agent-runtime/src/generate-diffs-prompt.d.ts +0 -53
  174. package/dist/packages/agent-runtime/src/get-file-reading-updates.d.ts +0 -8
  175. package/dist/packages/agent-runtime/src/inbox-poller.d.ts +0 -81
  176. package/dist/packages/agent-runtime/src/llm-api/claude.d.ts +0 -5
  177. package/dist/packages/agent-runtime/src/llm-api/context7-api.d.ts +0 -55
  178. package/dist/packages/agent-runtime/src/llm-api/gemini-with-fallbacks.d.ts +0 -40
  179. package/dist/packages/agent-runtime/src/llm-api/levelcode-web-api.d.ts +0 -49
  180. package/dist/packages/agent-runtime/src/llm-api/relace-api.d.ts +0 -16
  181. package/dist/packages/agent-runtime/src/main-prompt.d.ts +0 -29
  182. package/dist/packages/agent-runtime/src/mcp-constants.d.ts +0 -12
  183. package/dist/packages/agent-runtime/src/mcp.d.ts +0 -10
  184. package/dist/packages/agent-runtime/src/message-formatter.d.ts +0 -12
  185. package/dist/packages/agent-runtime/src/process-file-block.d.ts +0 -56
  186. package/dist/packages/agent-runtime/src/process-str-replace.d.ts +0 -21
  187. package/dist/packages/agent-runtime/src/prompt-agent-stream.d.ts +0 -28
  188. package/dist/packages/agent-runtime/src/run-agent-step.d.ts +0 -73
  189. package/dist/packages/agent-runtime/src/run-programmatic-step.d.ts +0 -40
  190. package/dist/packages/agent-runtime/src/system-prompt/prompts.d.ts +0 -19
  191. package/dist/packages/agent-runtime/src/system-prompt/search-system-prompt.d.ts +0 -14
  192. package/dist/packages/agent-runtime/src/system-prompt/team-context-prompt.d.ts +0 -9
  193. package/dist/packages/agent-runtime/src/system-prompt/team-prompt.d.ts +0 -9
  194. package/dist/packages/agent-runtime/src/system-prompt/truncate-file-tree.d.ts +0 -13
  195. package/dist/packages/agent-runtime/src/team-context.d.ts +0 -14
  196. package/dist/packages/agent-runtime/src/templates/agent-registry.d.ts +0 -35
  197. package/dist/packages/agent-runtime/src/templates/prompts.d.ts +0 -35
  198. package/dist/packages/agent-runtime/src/templates/strings.d.ts +0 -32
  199. package/dist/packages/agent-runtime/src/templates/types.d.ts +0 -13
  200. package/dist/packages/agent-runtime/src/tool-stream-parser.d.ts +0 -31
  201. package/dist/packages/agent-runtime/src/tools/handlers/handler-function-type.d.ts +0 -51
  202. package/dist/packages/agent-runtime/src/tools/handlers/list.d.ts +0 -370
  203. package/dist/packages/agent-runtime/src/tools/handlers/tool/add-message.d.ts +0 -9
  204. package/dist/packages/agent-runtime/src/tools/handlers/tool/add-subgoal.d.ts +0 -9
  205. package/dist/packages/agent-runtime/src/tools/handlers/tool/ask-user.d.ts +0 -10
  206. package/dist/packages/agent-runtime/src/tools/handlers/tool/browser-logs.d.ts +0 -8
  207. package/dist/packages/agent-runtime/src/tools/handlers/tool/code-search.d.ts +0 -8
  208. package/dist/packages/agent-runtime/src/tools/handlers/tool/create-plan.d.ts +0 -13
  209. package/dist/packages/agent-runtime/src/tools/handlers/tool/end-turn.d.ts +0 -7
  210. package/dist/packages/agent-runtime/src/tools/handlers/tool/find-files.d.ts +0 -27
  211. package/dist/packages/agent-runtime/src/tools/handlers/tool/glob.d.ts +0 -10
  212. package/dist/packages/agent-runtime/src/tools/handlers/tool/list-directory.d.ts +0 -10
  213. package/dist/packages/agent-runtime/src/tools/handlers/tool/lookup-agent-info.d.ts +0 -14
  214. package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-str-replace.d.ts +0 -15
  215. package/dist/packages/agent-runtime/src/tools/handlers/tool/propose-write-file.d.ts +0 -7
  216. package/dist/packages/agent-runtime/src/tools/handlers/tool/proposed-content-store.d.ts +0 -27
  217. package/dist/packages/agent-runtime/src/tools/handlers/tool/read-docs.d.ts +0 -21
  218. package/dist/packages/agent-runtime/src/tools/handlers/tool/read-files.d.ts +0 -13
  219. package/dist/packages/agent-runtime/src/tools/handlers/tool/read-subtree.d.ts +0 -13
  220. package/dist/packages/agent-runtime/src/tools/handlers/tool/run-file-change-hooks.d.ts +0 -10
  221. package/dist/packages/agent-runtime/src/tools/handlers/tool/run-terminal-command.d.ts +0 -10
  222. package/dist/packages/agent-runtime/src/tools/handlers/tool/send-message.d.ts +0 -15
  223. package/dist/packages/agent-runtime/src/tools/handlers/tool/set-messages.d.ts +0 -9
  224. package/dist/packages/agent-runtime/src/tools/handlers/tool/set-output.d.ts +0 -18
  225. package/dist/packages/agent-runtime/src/tools/handlers/tool/skill.d.ts +0 -11
  226. package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-inline.d.ts +0 -29
  227. package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agent-utils.d.ts +0 -130
  228. package/dist/packages/agent-runtime/src/tools/handlers/tool/spawn-agents.d.ts +0 -37
  229. package/dist/packages/agent-runtime/src/tools/handlers/tool/str-replace.d.ts +0 -16
  230. package/dist/packages/agent-runtime/src/tools/handlers/tool/suggest-followups.d.ts +0 -9
  231. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-completed.d.ts +0 -15
  232. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-create.d.ts +0 -10
  233. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-get.d.ts +0 -10
  234. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-list.d.ts +0 -10
  235. package/dist/packages/agent-runtime/src/tools/handlers/tool/task-update.d.ts +0 -15
  236. package/dist/packages/agent-runtime/src/tools/handlers/tool/team-create.d.ts +0 -15
  237. package/dist/packages/agent-runtime/src/tools/handlers/tool/team-delete.d.ts +0 -15
  238. package/dist/packages/agent-runtime/src/tools/handlers/tool/think-deeply.d.ts +0 -9
  239. package/dist/packages/agent-runtime/src/tools/handlers/tool/update-subgoal.d.ts +0 -11
  240. package/dist/packages/agent-runtime/src/tools/handlers/tool/web-search.d.ts +0 -22
  241. package/dist/packages/agent-runtime/src/tools/handlers/tool/write-file.d.ts +0 -49
  242. package/dist/packages/agent-runtime/src/tools/handlers/tool/write-todos.d.ts +0 -9
  243. package/dist/packages/agent-runtime/src/tools/prompts.d.ts +0 -31
  244. package/dist/packages/agent-runtime/src/tools/stream-parser.d.ts +0 -33
  245. package/dist/packages/agent-runtime/src/tools/tool-executor.d.ts +0 -87
  246. package/dist/packages/agent-runtime/src/util/agent-output.d.ts +0 -3
  247. package/dist/packages/agent-runtime/src/util/messages.d.ts +0 -68
  248. package/dist/packages/agent-runtime/src/util/parse-tool-calls-from-text.d.ts +0 -38
  249. package/dist/packages/agent-runtime/src/util/render-read-files-result.d.ts +0 -15
  250. package/dist/packages/agent-runtime/src/util/simplify-tool-results.d.ts +0 -7
  251. package/dist/packages/agent-runtime/src/util/stream-xml-parser.d.ts +0 -34
  252. package/dist/packages/agent-runtime/src/util/token-counter.d.ts +0 -3
  253. package/dist/packages/code-map/src/index.d.ts +0 -3
  254. package/dist/packages/code-map/src/init-node.d.ts +0 -4
  255. package/dist/packages/code-map/src/languages.d.ts +0 -36
  256. package/dist/packages/code-map/src/parse.d.ts +0 -21
  257. package/dist/packages/code-map/src/types.d.ts +0 -8
  258. package/dist/packages/code-map/src/utils.d.ts +0 -1
  259. package/dist/sdk/src/__tests__/client.test.d.ts +0 -1
  260. package/dist/sdk/src/__tests__/code-search.test.d.ts +0 -1
  261. package/dist/sdk/src/__tests__/credentials.test.d.ts +0 -1
  262. package/dist/sdk/src/__tests__/database.test.d.ts +0 -1
  263. package/dist/sdk/src/__tests__/env.test.d.ts +0 -1
  264. package/dist/sdk/src/__tests__/error-utils.test.d.ts +0 -1
  265. package/dist/sdk/src/__tests__/initial-session-state.test.d.ts +0 -1
  266. package/dist/sdk/src/__tests__/knowledge-file-selection.test.d.ts +0 -1
  267. package/dist/sdk/src/__tests__/load-agents.test.d.ts +0 -1
  268. package/dist/sdk/src/__tests__/load-mcp-config.test.d.ts +0 -1
  269. package/dist/sdk/src/__tests__/model-provider.test.d.ts +0 -1
  270. package/dist/sdk/src/__tests__/read-files.test.d.ts +0 -1
  271. package/dist/sdk/src/__tests__/run-cancellation.test.d.ts +0 -1
  272. package/dist/sdk/src/__tests__/run-file-filter.test.d.ts +0 -1
  273. package/dist/sdk/src/__tests__/run-handle-event.test.d.ts +0 -1
  274. package/dist/sdk/src/__tests__/run.integration.test.d.ts +0 -1
  275. package/dist/sdk/src/__tests__/team-api.test.d.ts +0 -1
  276. package/dist/sdk/src/__tests__/user-knowledge-files.test.d.ts +0 -1
  277. package/dist/sdk/src/__tests__/validate-agents.test.d.ts +0 -1
  278. package/dist/sdk/src/agents/load-agents.d.ts +0 -106
  279. package/dist/sdk/src/agents/load-mcp-config.d.ts +0 -69
  280. package/dist/sdk/src/client.d.ts +0 -71
  281. package/dist/sdk/src/constants.d.ts +0 -4
  282. package/dist/sdk/src/credentials.d.ts +0 -58
  283. package/dist/sdk/src/custom-tool.d.ts +0 -32
  284. package/dist/sdk/src/env.d.ts +0 -31
  285. package/dist/sdk/src/error-utils.d.ts +0 -55
  286. package/dist/sdk/src/impl/__tests__/prompt-result.test.d.ts +0 -1
  287. package/dist/sdk/src/impl/agent-runtime.d.ts +0 -8
  288. package/dist/sdk/src/impl/database.d.ts +0 -7
  289. package/dist/sdk/src/impl/llm.d.ts +0 -8
  290. package/dist/sdk/src/impl/model-provider.d.ts +0 -61
  291. package/dist/sdk/src/index.d.ts +0 -42
  292. package/dist/sdk/src/native/ripgrep.d.ts +0 -7
  293. package/dist/sdk/src/retry-config.d.ts +0 -46
  294. package/dist/sdk/src/run-state.d.ts +0 -81
  295. package/dist/sdk/src/run.d.ts +0 -79
  296. package/dist/sdk/src/skills/load-skills.d.ts +0 -42
  297. package/dist/sdk/src/team.d.ts +0 -49
  298. package/dist/sdk/src/testing/env.d.ts +0 -5
  299. package/dist/sdk/src/tools/change-file.d.ts +0 -7
  300. package/dist/sdk/src/tools/code-search.d.ts +0 -13
  301. package/dist/sdk/src/tools/glob.d.ts +0 -8
  302. package/dist/sdk/src/tools/index.d.ts +0 -16
  303. package/dist/sdk/src/tools/list-directory.d.ts +0 -7
  304. package/dist/sdk/src/tools/read-files.d.ts +0 -16
  305. package/dist/sdk/src/tools/run-file-change-hooks.d.ts +0 -4
  306. package/dist/sdk/src/tools/run-terminal-command.d.ts +0 -8
  307. package/dist/sdk/src/types/env.d.ts +0 -30
  308. package/dist/sdk/src/validate-agents.d.ts +0 -45
  309. package/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
  310. package/dist/vendor/ripgrep/arm64-linux/rg +0 -0
  311. package/dist/vendor/ripgrep/x64-darwin/rg +0 -0
  312. package/dist/vendor/ripgrep/x64-linux/rg +0 -0
  313. package/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
  314. package/dist/wasm/tree-sitter-c-sharp.wasm +0 -0
  315. package/dist/wasm/tree-sitter-cpp.wasm +0 -0
  316. package/dist/wasm/tree-sitter-go.wasm +0 -0
  317. package/dist/wasm/tree-sitter-java.wasm +0 -0
  318. package/dist/wasm/tree-sitter-javascript.wasm +0 -0
  319. package/dist/wasm/tree-sitter-python.wasm +0 -0
  320. package/dist/wasm/tree-sitter-ruby.wasm +0 -0
  321. package/dist/wasm/tree-sitter-rust.wasm +0 -0
  322. package/dist/wasm/tree-sitter-tsx.wasm +0 -0
  323. package/dist/wasm/tree-sitter-typescript.wasm +0 -0
  324. package/dist/wasm/tree-sitter.wasm +0 -0
package/dist/index.mjs CHANGED
@@ -7271,8 +7271,8 @@ var require_uri_all = __commonJS((exports2, module) => {
7271
7271
  wsComponents.secure = undefined;
7272
7272
  }
7273
7273
  if (wsComponents.resourceName) {
7274
- var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path7 = _wsComponents$resourc2[0], query = _wsComponents$resourc2[1];
7275
- wsComponents.path = path7 && path7 !== "/" ? path7 : undefined;
7274
+ var _wsComponents$resourc = wsComponents.resourceName.split("?"), _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), path8 = _wsComponents$resourc2[0], query = _wsComponents$resourc2[1];
7275
+ wsComponents.path = path8 && path8 !== "/" ? path8 : undefined;
7276
7276
  wsComponents.query = query;
7277
7277
  wsComponents.resourceName = undefined;
7278
7278
  }
@@ -7665,12 +7665,12 @@ var require_util = __commonJS((exports2, module) => {
7665
7665
  return "'" + escapeQuotes(str) + "'";
7666
7666
  }
7667
7667
  function getPathExpr(currentPath, expr, jsonPointers, isNumber2) {
7668
- var path7 = jsonPointers ? "'/' + " + expr + (isNumber2 ? "" : ".replace(/~/g, '~0').replace(/\\//g, '~1')") : isNumber2 ? "'[' + " + expr + " + ']'" : "'[\\'' + " + expr + " + '\\']'";
7669
- return joinPaths(currentPath, path7);
7668
+ var path8 = jsonPointers ? "'/' + " + expr + (isNumber2 ? "" : ".replace(/~/g, '~0').replace(/\\//g, '~1')") : isNumber2 ? "'[' + " + expr + " + ']'" : "'[\\'' + " + expr + " + '\\']'";
7669
+ return joinPaths(currentPath, path8);
7670
7670
  }
7671
7671
  function getPath(currentPath, prop, jsonPointers) {
7672
- var path7 = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
7673
- return joinPaths(currentPath, path7);
7672
+ var path8 = jsonPointers ? toQuotedString("/" + escapeJsonPointer(prop)) : toQuotedString(getProperty(prop));
7673
+ return joinPaths(currentPath, path8);
7674
7674
  }
7675
7675
  var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
7676
7676
  var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
@@ -12636,7 +12636,7 @@ var require_windows = __commonJS((exports2, module) => {
12636
12636
  module.exports = isexe;
12637
12637
  isexe.sync = sync;
12638
12638
  var fs7 = __require("fs");
12639
- function checkPathExt(path7, options) {
12639
+ function checkPathExt(path8, options) {
12640
12640
  var pathext = options.pathExt !== undefined ? options.pathExt : process.env.PATHEXT;
12641
12641
  if (!pathext) {
12642
12642
  return true;
@@ -12647,25 +12647,25 @@ var require_windows = __commonJS((exports2, module) => {
12647
12647
  }
12648
12648
  for (var i = 0;i < pathext.length; i++) {
12649
12649
  var p = pathext[i].toLowerCase();
12650
- if (p && path7.substr(-p.length).toLowerCase() === p) {
12650
+ if (p && path8.substr(-p.length).toLowerCase() === p) {
12651
12651
  return true;
12652
12652
  }
12653
12653
  }
12654
12654
  return false;
12655
12655
  }
12656
- function checkStat(stat, path7, options) {
12656
+ function checkStat(stat, path8, options) {
12657
12657
  if (!stat.isSymbolicLink() && !stat.isFile()) {
12658
12658
  return false;
12659
12659
  }
12660
- return checkPathExt(path7, options);
12660
+ return checkPathExt(path8, options);
12661
12661
  }
12662
- function isexe(path7, options, cb) {
12663
- fs7.stat(path7, function(er, stat) {
12664
- cb(er, er ? false : checkStat(stat, path7, options));
12662
+ function isexe(path8, options, cb) {
12663
+ fs7.stat(path8, function(er, stat) {
12664
+ cb(er, er ? false : checkStat(stat, path8, options));
12665
12665
  });
12666
12666
  }
12667
- function sync(path7, options) {
12668
- return checkStat(fs7.statSync(path7), path7, options);
12667
+ function sync(path8, options) {
12668
+ return checkStat(fs7.statSync(path8), path8, options);
12669
12669
  }
12670
12670
  });
12671
12671
 
@@ -12674,13 +12674,13 @@ var require_mode = __commonJS((exports2, module) => {
12674
12674
  module.exports = isexe;
12675
12675
  isexe.sync = sync;
12676
12676
  var fs7 = __require("fs");
12677
- function isexe(path7, options, cb) {
12678
- fs7.stat(path7, function(er, stat) {
12677
+ function isexe(path8, options, cb) {
12678
+ fs7.stat(path8, function(er, stat) {
12679
12679
  cb(er, er ? false : checkStat(stat, options));
12680
12680
  });
12681
12681
  }
12682
- function sync(path7, options) {
12683
- return checkStat(fs7.statSync(path7), options);
12682
+ function sync(path8, options) {
12683
+ return checkStat(fs7.statSync(path8), options);
12684
12684
  }
12685
12685
  function checkStat(stat, options) {
12686
12686
  return stat.isFile() && checkMode(stat, options);
@@ -12711,7 +12711,7 @@ var require_isexe = __commonJS((exports2, module) => {
12711
12711
  }
12712
12712
  module.exports = isexe;
12713
12713
  isexe.sync = sync;
12714
- function isexe(path7, options, cb) {
12714
+ function isexe(path8, options, cb) {
12715
12715
  if (typeof options === "function") {
12716
12716
  cb = options;
12717
12717
  options = {};
@@ -12721,7 +12721,7 @@ var require_isexe = __commonJS((exports2, module) => {
12721
12721
  throw new TypeError("callback not provided");
12722
12722
  }
12723
12723
  return new Promise(function(resolve3, reject) {
12724
- isexe(path7, options || {}, function(er, is) {
12724
+ isexe(path8, options || {}, function(er, is) {
12725
12725
  if (er) {
12726
12726
  reject(er);
12727
12727
  } else {
@@ -12730,7 +12730,7 @@ var require_isexe = __commonJS((exports2, module) => {
12730
12730
  });
12731
12731
  });
12732
12732
  }
12733
- core(path7, options || {}, function(er, is) {
12733
+ core(path8, options || {}, function(er, is) {
12734
12734
  if (er) {
12735
12735
  if (er.code === "EACCES" || options && options.ignoreErrors) {
12736
12736
  er = null;
@@ -12740,9 +12740,9 @@ var require_isexe = __commonJS((exports2, module) => {
12740
12740
  cb(er, is);
12741
12741
  });
12742
12742
  }
12743
- function sync(path7, options) {
12743
+ function sync(path8, options) {
12744
12744
  try {
12745
- return core.sync(path7, options || {});
12745
+ return core.sync(path8, options || {});
12746
12746
  } catch (er) {
12747
12747
  if (options && options.ignoreErrors || er.code === "EACCES") {
12748
12748
  return false;
@@ -12756,7 +12756,7 @@ var require_isexe = __commonJS((exports2, module) => {
12756
12756
  // ../node_modules/which/which.js
12757
12757
  var require_which = __commonJS((exports2, module) => {
12758
12758
  var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
12759
- var path7 = __require("path");
12759
+ var path8 = __require("path");
12760
12760
  var COLON = isWindows ? ";" : ":";
12761
12761
  var isexe = require_isexe();
12762
12762
  var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
@@ -12792,7 +12792,7 @@ var require_which = __commonJS((exports2, module) => {
12792
12792
  return opt.all && found.length ? resolve3(found) : reject(getNotFoundError(cmd));
12793
12793
  const ppRaw = pathEnv[i];
12794
12794
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12795
- const pCmd = path7.join(pathPart, cmd);
12795
+ const pCmd = path8.join(pathPart, cmd);
12796
12796
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12797
12797
  resolve3(subStep(p, i, 0));
12798
12798
  });
@@ -12819,7 +12819,7 @@ var require_which = __commonJS((exports2, module) => {
12819
12819
  for (let i = 0;i < pathEnv.length; i++) {
12820
12820
  const ppRaw = pathEnv[i];
12821
12821
  const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
12822
- const pCmd = path7.join(pathPart, cmd);
12822
+ const pCmd = path8.join(pathPart, cmd);
12823
12823
  const p = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
12824
12824
  for (let j = 0;j < pathExt.length; j++) {
12825
12825
  const cur = p + pathExt[j];
@@ -12860,7 +12860,7 @@ var require_path_key = __commonJS((exports2, module) => {
12860
12860
 
12861
12861
  // ../node_modules/cross-spawn/lib/util/resolveCommand.js
12862
12862
  var require_resolveCommand = __commonJS((exports2, module) => {
12863
- var path7 = __require("path");
12863
+ var path8 = __require("path");
12864
12864
  var which = require_which();
12865
12865
  var getPathKey = require_path_key();
12866
12866
  function resolveCommandAttempt(parsed, withoutPathExt) {
@@ -12877,7 +12877,7 @@ var require_resolveCommand = __commonJS((exports2, module) => {
12877
12877
  try {
12878
12878
  resolved = which.sync(parsed.command, {
12879
12879
  path: env2[getPathKey({ env: env2 })],
12880
- pathExt: withoutPathExt ? path7.delimiter : undefined
12880
+ pathExt: withoutPathExt ? path8.delimiter : undefined
12881
12881
  });
12882
12882
  } catch (e) {} finally {
12883
12883
  if (shouldSwitchCwd) {
@@ -12885,7 +12885,7 @@ var require_resolveCommand = __commonJS((exports2, module) => {
12885
12885
  }
12886
12886
  }
12887
12887
  if (resolved) {
12888
- resolved = path7.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12888
+ resolved = path8.resolve(hasCustomCwd ? parsed.options.cwd : "", resolved);
12889
12889
  }
12890
12890
  return resolved;
12891
12891
  }
@@ -12930,8 +12930,8 @@ var require_shebang_command = __commonJS((exports2, module) => {
12930
12930
  if (!match) {
12931
12931
  return null;
12932
12932
  }
12933
- const [path7, argument] = match[0].replace(/#! ?/, "").split(" ");
12934
- const binary = path7.split("/").pop();
12933
+ const [path8, argument] = match[0].replace(/#! ?/, "").split(" ");
12934
+ const binary = path8.split("/").pop();
12935
12935
  if (binary === "env") {
12936
12936
  return argument;
12937
12937
  }
@@ -12959,7 +12959,7 @@ var require_readShebang = __commonJS((exports2, module) => {
12959
12959
 
12960
12960
  // ../node_modules/cross-spawn/lib/parse.js
12961
12961
  var require_parse = __commonJS((exports2, module) => {
12962
- var path7 = __require("path");
12962
+ var path8 = __require("path");
12963
12963
  var resolveCommand = require_resolveCommand();
12964
12964
  var escape = require_escape();
12965
12965
  var readShebang = require_readShebang();
@@ -12984,7 +12984,7 @@ var require_parse = __commonJS((exports2, module) => {
12984
12984
  const needsShell = !isExecutableRegExp.test(commandFile);
12985
12985
  if (parsed.options.forceShell || needsShell) {
12986
12986
  const needsDoubleEscapeMetaChars = isCmdShimRegExp.test(commandFile);
12987
- parsed.command = path7.normalize(parsed.command);
12987
+ parsed.command = path8.normalize(parsed.command);
12988
12988
  parsed.command = escape.command(parsed.command);
12989
12989
  parsed.args = parsed.args.map((arg) => escape.argument(arg, needsDoubleEscapeMetaChars));
12990
12990
  const shellCommand = [parsed.command].concat(parsed.args).join(" ");
@@ -13088,7 +13088,7 @@ var require_cross_spawn = __commonJS((exports2, module) => {
13088
13088
  });
13089
13089
 
13090
13090
  // src/run.ts
13091
- import path20 from "path";
13091
+ import path21 from "path";
13092
13092
 
13093
13093
  // ../common/src/env-schema.ts
13094
13094
  import z from "zod/v4";
@@ -17361,6 +17361,13 @@ function loadTeamConfig(teamName) {
17361
17361
  }
17362
17362
  return result.data;
17363
17363
  }
17364
+ async function saveTeamConfig(teamName, config) {
17365
+ const configPath = getTeamConfigPath(teamName);
17366
+ await withLock(configPath, () => {
17367
+ fs2.mkdirSync(path2.dirname(configPath), { recursive: true });
17368
+ fs2.writeFileSync(configPath, JSON.stringify(config, null, 2));
17369
+ });
17370
+ }
17364
17371
  function deleteTeam(teamName) {
17365
17372
  const teamDir = getTeamDir(teamName);
17366
17373
  if (fs2.existsSync(teamDir)) {
@@ -21571,18 +21578,165 @@ function getMinimumPhaseForTool(toolName39) {
21571
21578
  var import_lodash13 = __toESM(require_lodash(), 1);
21572
21579
 
21573
21580
  // ../packages/agent-runtime/src/team-context.ts
21581
+ import * as fs4 from "fs";
21582
+
21583
+ // ../common/src/utils/team-discovery.ts
21574
21584
  import * as fs3 from "fs";
21585
+ import * as path3 from "path";
21586
+ import * as os2 from "os";
21587
+ function getLastActiveTeamPath() {
21588
+ return path3.join(os2.homedir(), ".config", "levelcode", "teams", ".last-active-team");
21589
+ }
21590
+ function setLastActiveTeam(teamName) {
21591
+ try {
21592
+ const filePath = getLastActiveTeamPath();
21593
+ fs3.mkdirSync(path3.dirname(filePath), { recursive: true });
21594
+ fs3.writeFileSync(filePath, teamName, "utf-8");
21595
+ } catch {}
21596
+ }
21597
+ function getLastActiveTeam() {
21598
+ try {
21599
+ const filePath = getLastActiveTeamPath();
21600
+ if (!fs3.existsSync(filePath)) {
21601
+ return null;
21602
+ }
21603
+ const name = fs3.readFileSync(filePath, "utf-8").trim();
21604
+ return name || null;
21605
+ } catch {
21606
+ return null;
21607
+ }
21608
+ }
21609
+ function readTeamEntries() {
21610
+ let teamsDir;
21611
+ try {
21612
+ teamsDir = getTeamsDir();
21613
+ } catch {
21614
+ return [];
21615
+ }
21616
+ if (!fs3.existsSync(teamsDir)) {
21617
+ return [];
21618
+ }
21619
+ try {
21620
+ return fs3.readdirSync(teamsDir, { withFileTypes: true });
21621
+ } catch {
21622
+ return [];
21623
+ }
21624
+ }
21625
+ function safeLoadTeamConfig(teamName) {
21626
+ try {
21627
+ const config = loadTeamConfig(teamName);
21628
+ if (!config || !Array.isArray(config.members)) {
21629
+ return null;
21630
+ }
21631
+ return config;
21632
+ } catch {
21633
+ return null;
21634
+ }
21635
+ }
21636
+ function loadAllTeamConfigs() {
21637
+ const entries = readTeamEntries();
21638
+ const results = [];
21639
+ for (const entry of entries) {
21640
+ if (!entry.isDirectory()) {
21641
+ continue;
21642
+ }
21643
+ const config = safeLoadTeamConfig(entry.name);
21644
+ if (config) {
21645
+ results.push({ teamName: config.name, config });
21646
+ }
21647
+ }
21648
+ return results;
21649
+ }
21650
+ function findCurrentTeam(agentId) {
21651
+ const allTeams = loadAllTeamConfigs();
21652
+ for (const { teamName, config } of allTeams) {
21653
+ if (config.leadAgentId === `lead-${agentId}`) {
21654
+ return { teamName, config };
21655
+ }
21656
+ for (const member of config.members) {
21657
+ if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
21658
+ return { teamName, config };
21659
+ }
21660
+ }
21661
+ }
21662
+ if (allTeams.length === 1) {
21663
+ return allTeams[0];
21664
+ }
21665
+ const lastActive = getLastActiveTeam();
21666
+ if (lastActive) {
21667
+ const match = allTeams.find((t) => t.teamName === lastActive);
21668
+ if (match) {
21669
+ return match;
21670
+ }
21671
+ }
21672
+ return null;
21673
+ }
21674
+ function findCurrentTeamAndAgent(agentId) {
21675
+ const allTeams = loadAllTeamConfigs();
21676
+ for (const { teamName, config } of allTeams) {
21677
+ for (const member of config.members) {
21678
+ if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
21679
+ return { teamName, agentName: member.name, config };
21680
+ }
21681
+ }
21682
+ }
21683
+ let resolved = null;
21684
+ if (allTeams.length === 1) {
21685
+ resolved = allTeams[0];
21686
+ } else {
21687
+ const lastActive = getLastActiveTeam();
21688
+ if (lastActive) {
21689
+ resolved = allTeams.find((t) => t.teamName === lastActive) ?? null;
21690
+ }
21691
+ }
21692
+ if (resolved) {
21693
+ const leadMember = resolved.config.members.find((m) => m.agentId === resolved.config.leadAgentId);
21694
+ const agentName = leadMember?.name ?? "team-lead";
21695
+ return { teamName: resolved.teamName, agentName, config: resolved.config };
21696
+ }
21697
+ return null;
21698
+ }
21699
+ function findTeamByName(name) {
21700
+ try {
21701
+ validateTeamName(name);
21702
+ } catch {
21703
+ return null;
21704
+ }
21705
+ return safeLoadTeamConfig(name);
21706
+ }
21707
+ function listAllTeams() {
21708
+ const entries = readTeamEntries();
21709
+ const results = [];
21710
+ for (const entry of entries) {
21711
+ if (!entry.isDirectory()) {
21712
+ continue;
21713
+ }
21714
+ const config = safeLoadTeamConfig(entry.name);
21715
+ if (!config) {
21716
+ continue;
21717
+ }
21718
+ results.push({
21719
+ name: config.name,
21720
+ phase: config.phase,
21721
+ memberCount: config.members.length
21722
+ });
21723
+ }
21724
+ return results;
21725
+ }
21726
+
21727
+ // ../packages/agent-runtime/src/team-context.ts
21575
21728
  function findTeamContext(agentIdentifier) {
21576
21729
  const teamsDir = getTeamsDir();
21577
- if (!fs3.existsSync(teamsDir)) {
21730
+ if (!fs4.existsSync(teamsDir)) {
21578
21731
  return null;
21579
21732
  }
21580
21733
  let entries;
21581
21734
  try {
21582
- entries = fs3.readdirSync(teamsDir, { withFileTypes: true });
21735
+ entries = fs4.readdirSync(teamsDir, { withFileTypes: true });
21583
21736
  } catch {
21584
21737
  return null;
21585
21738
  }
21739
+ const allTeams = [];
21586
21740
  for (const entry of entries) {
21587
21741
  if (!entry.isDirectory()) {
21588
21742
  continue;
@@ -21591,12 +21745,30 @@ function findTeamContext(agentIdentifier) {
21591
21745
  if (!config) {
21592
21746
  continue;
21593
21747
  }
21748
+ allTeams.push({ teamName: config.name, config });
21749
+ }
21750
+ for (const { teamName, config } of allTeams) {
21594
21751
  for (const member of config.members) {
21595
21752
  if (member.agentId === agentIdentifier || member.agentId === `lead-${agentIdentifier}`) {
21596
- return { teamName: config.name, agentName: member.name, config };
21753
+ return { teamName, agentName: member.name, config };
21597
21754
  }
21598
21755
  }
21599
21756
  }
21757
+ function resolveFromTeam(team) {
21758
+ const leadMember = team.config.members.find((m) => m.agentId === team.config.leadAgentId);
21759
+ const agentName = leadMember?.name ?? "team-lead";
21760
+ return { teamName: team.teamName, agentName, config: team.config };
21761
+ }
21762
+ if (allTeams.length === 1) {
21763
+ return resolveFromTeam(allTeams[0]);
21764
+ }
21765
+ const lastActive = getLastActiveTeam();
21766
+ if (lastActive) {
21767
+ const match = allTeams.find((t) => t.teamName === lastActive);
21768
+ if (match) {
21769
+ return resolveFromTeam(match);
21770
+ }
21771
+ }
21600
21772
  return null;
21601
21773
  }
21602
21774
 
@@ -24551,8 +24723,8 @@ var import_lodash4 = __toESM(require_lodash(), 1);
24551
24723
  init_model_config();
24552
24724
 
24553
24725
  // ../common/src/util/file.ts
24554
- import * as os2 from "os";
24555
- import * as path3 from "path";
24726
+ import * as os3 from "os";
24727
+ import * as path4 from "path";
24556
24728
  import { z as z71 } from "zod/v4";
24557
24729
  var FileTreeNodeSchema = z71.object({
24558
24730
  name: z71.string(),
@@ -24630,9 +24802,9 @@ function printFileTree(nodes, depth = 0) {
24630
24802
  }
24631
24803
  return result;
24632
24804
  }
24633
- function printFileTreeWithTokens(nodes, fileTokenScores, path4 = []) {
24805
+ function printFileTreeWithTokens(nodes, fileTokenScores, path5 = []) {
24634
24806
  let result = "";
24635
- const depth = path4.length;
24807
+ const depth = path5.length;
24636
24808
  const indentToken = " ";
24637
24809
  const indentation = indentToken.repeat(depth);
24638
24810
  const indentationWithFile = indentToken.repeat(depth + 1);
@@ -24641,8 +24813,8 @@ function printFileTreeWithTokens(nodes, fileTokenScores, path4 = []) {
24641
24813
  continue;
24642
24814
  }
24643
24815
  result += `${indentation}${node.name}${node.type === "directory" ? "/" : ""}`;
24644
- path4.push(node.name);
24645
- const filePath = path4.join("/");
24816
+ path5.push(node.name);
24817
+ const filePath = path5.join("/");
24646
24818
  const tokenScores = fileTokenScores[filePath];
24647
24819
  if (node.type === "file" && tokenScores) {
24648
24820
  const tokens = Object.keys(tokenScores);
@@ -24654,16 +24826,16 @@ ${indentationWithFile}${tokens.join(" ")}`;
24654
24826
  result += `
24655
24827
  `;
24656
24828
  if (node.type === "directory" && node.children) {
24657
- result += printFileTreeWithTokens(node.children, fileTokenScores, path4);
24829
+ result += printFileTreeWithTokens(node.children, fileTokenScores, path5);
24658
24830
  }
24659
- path4.pop();
24831
+ path5.pop();
24660
24832
  }
24661
24833
  return result;
24662
24834
  }
24663
24835
  async function fileExists(params2) {
24664
- const { filePath, fs: fs4 } = params2;
24836
+ const { filePath, fs: fs5 } = params2;
24665
24837
  try {
24666
- await fs4.stat(filePath);
24838
+ await fs5.stat(filePath);
24667
24839
  return true;
24668
24840
  } catch {
24669
24841
  return false;
@@ -24674,19 +24846,19 @@ var cleanMarkdownCodeBlock = (content) => {
24674
24846
  return cleanResponse;
24675
24847
  };
24676
24848
  function isSubdir(fromPath, toPath) {
24677
- const resolvedFrom = path3.resolve(fromPath);
24678
- const resolvedTo = path3.resolve(toPath);
24849
+ const resolvedFrom = path4.resolve(fromPath);
24850
+ const resolvedTo = path4.resolve(toPath);
24679
24851
  if (process.platform === "win32") {
24680
- const fromDrive = path3.parse(resolvedFrom).root.toLowerCase();
24681
- const toDrive = path3.parse(resolvedTo).root.toLowerCase();
24852
+ const fromDrive = path4.parse(resolvedFrom).root.toLowerCase();
24853
+ const toDrive = path4.parse(resolvedTo).root.toLowerCase();
24682
24854
  if (fromDrive !== toDrive) {
24683
24855
  return false;
24684
24856
  }
24685
24857
  }
24686
- return !path3.relative(resolvedFrom, resolvedTo).startsWith("..");
24858
+ return !path4.relative(resolvedFrom, resolvedTo).startsWith("..");
24687
24859
  }
24688
24860
  function isValidProjectRoot(dir) {
24689
- return !isSubdir(dir, os2.homedir());
24861
+ return !isSubdir(dir, os3.homedir());
24690
24862
  }
24691
24863
 
24692
24864
  // ../packages/agent-runtime/src/process-file-block.ts
@@ -30013,7 +30185,7 @@ function countTokensJson(text) {
30013
30185
  // ../packages/agent-runtime/src/process-file-block.ts
30014
30186
  async function processFileBlock(params2) {
30015
30187
  const {
30016
- path: path4,
30188
+ path: path5,
30017
30189
  initialContentPromise,
30018
30190
  newContent,
30019
30191
  messages,
@@ -30028,28 +30200,28 @@ async function processFileBlock(params2) {
30028
30200
  const initialContent = await initialContentPromise;
30029
30201
  if (initialContent === null) {
30030
30202
  let cleanContent = cleanMarkdownCodeBlock(newContent);
30031
- if (hasLazyEdit(cleanContent) && !path4.endsWith(".md")) {
30032
- logger2.debug({ path: path4, newContent }, `processFileBlock: New file contained a lazy edit for ${path4}. Aborting.`);
30203
+ if (hasLazyEdit(cleanContent) && !path5.endsWith(".md")) {
30204
+ logger2.debug({ path: path5, newContent }, `processFileBlock: New file contained a lazy edit for ${path5}. Aborting.`);
30033
30205
  return promptSuccess({
30034
30206
  tool: "write_file",
30035
- path: path4,
30207
+ path: path5,
30036
30208
  error: "You created a new file with a placeholder comment like `// ... existing code ...` (or equivalent for other languages). Are you sure you have the file path right? You probably meant to modify an existing file instead of providing a path to a new file."
30037
30209
  });
30038
30210
  }
30039
- logger2.debug({ path: path4, cleanContent }, `processFileBlock: Created new file ${path4}`);
30211
+ logger2.debug({ path: path5, cleanContent }, `processFileBlock: Created new file ${path5}`);
30040
30212
  return promptSuccess({
30041
30213
  tool: "write_file",
30042
- path: path4,
30214
+ path: path5,
30043
30215
  content: cleanContent,
30044
30216
  patch: undefined,
30045
- messages: [`Created new file ${path4}`]
30217
+ messages: [`Created new file ${path5}`]
30046
30218
  });
30047
30219
  }
30048
30220
  if (newContent === initialContent) {
30049
- logger2.info({ newContent }, `processFileBlock: New was same as old, skipping ${path4}`);
30221
+ logger2.info({ newContent }, `processFileBlock: New was same as old, skipping ${path5}`);
30050
30222
  return promptSuccess({
30051
30223
  tool: "write_file",
30052
- path: path4,
30224
+ path: path5,
30053
30225
  error: "The new content was the same as the old content, skipping."
30054
30226
  });
30055
30227
  }
@@ -30070,7 +30242,7 @@ async function processFileBlock(params2) {
30070
30242
  ...params2,
30071
30243
  oldContent: normalizedInitialContent,
30072
30244
  editSnippet: normalizedEditSnippet,
30073
- filePath: path4
30245
+ filePath: path5
30074
30246
  });
30075
30247
  if (largeFileResult.aborted) {
30076
30248
  return promptAborted(largeFileResult.reason);
@@ -30079,7 +30251,7 @@ async function processFileBlock(params2) {
30079
30251
  if (!largeFileContent) {
30080
30252
  return promptSuccess({
30081
30253
  tool: "write_file",
30082
- path: path4,
30254
+ path: path5,
30083
30255
  error: "Failed to apply the write file change to this large file. You should try using the str_replace tool instead for large files."
30084
30256
  });
30085
30257
  }
@@ -30089,12 +30261,12 @@ async function processFileBlock(params2) {
30089
30261
  ...params2,
30090
30262
  initialContent: normalizedInitialContent,
30091
30263
  editSnippet: normalizedEditSnippet,
30092
- filePath: path4,
30264
+ filePath: path5,
30093
30265
  userMessage: lastUserPrompt
30094
30266
  });
30095
30267
  const shouldAddPlaceholders = await shouldAddFilePlaceholders({
30096
30268
  ...params2,
30097
- filePath: path4,
30269
+ filePath: path5,
30098
30270
  oldContent: normalizedInitialContent,
30099
30271
  rewrittenNewContent: updatedContent,
30100
30272
  messageHistory: messages
@@ -30108,12 +30280,12 @@ ${placeholderComment}`;
30108
30280
  ...params2,
30109
30281
  initialContent: normalizedInitialContent,
30110
30282
  editSnippet: updatedEditSnippet,
30111
- filePath: path4,
30283
+ filePath: path5,
30112
30284
  userMessage: lastUserPrompt
30113
30285
  });
30114
30286
  }
30115
30287
  }
30116
- let patch = createPatch(path4, normalizedInitialContent, updatedContent);
30288
+ let patch = createPatch(path5, normalizedInitialContent, updatedContent);
30117
30289
  const lines = patch.split(`
30118
30290
  `);
30119
30291
  const hunkStartIndex = lines.findIndex((line) => line.startsWith("@@"));
@@ -30123,34 +30295,34 @@ ${placeholderComment}`;
30123
30295
  } else {
30124
30296
  editMessages.push("The new content was the same as the old content, skipping.");
30125
30297
  logger2.debug({
30126
- path: path4,
30298
+ path: path5,
30127
30299
  initialContent,
30128
30300
  changes: newContent,
30129
30301
  patch,
30130
30302
  editMessages
30131
- }, `processFileBlock: No change to ${path4}`);
30303
+ }, `processFileBlock: No change to ${path5}`);
30132
30304
  return promptSuccess({
30133
30305
  tool: "write_file",
30134
- path: path4,
30306
+ path: path5,
30135
30307
  error: editMessages.join(`
30136
30308
 
30137
30309
  `)
30138
30310
  });
30139
30311
  }
30140
30312
  logger2.debug({
30141
- path: path4,
30313
+ path: path5,
30142
30314
  editSnippet: newContent,
30143
30315
  updatedContent,
30144
30316
  patch,
30145
30317
  editMessages
30146
- }, `processFileBlock: Updated file ${path4}`);
30318
+ }, `processFileBlock: Updated file ${path5}`);
30147
30319
  const patchOriginalLineEndings = patch.replaceAll(`
30148
30320
  `, lineEnding);
30149
30321
  const updatedContentOriginalLineEndings = updatedContent.replaceAll(`
30150
30322
  `, lineEnding);
30151
30323
  return promptSuccess({
30152
30324
  tool: "write_file",
30153
- path: path4,
30325
+ path: path5,
30154
30326
  content: updatedContentOriginalLineEndings,
30155
30327
  patch: patchOriginalLineEndings,
30156
30328
  messages: editMessages
@@ -30267,21 +30439,21 @@ var handleWriteFile = async (params2) => {
30267
30439
  requestOptionalFile,
30268
30440
  writeToClient
30269
30441
  } = params2;
30270
- const { path: path4, instructions, content } = toolCall.input;
30442
+ const { path: path5, instructions, content } = toolCall.input;
30271
30443
  const fileProcessingPromisesByPath = fileProcessingState2.promisesByPath;
30272
30444
  const fileProcessingPromises = fileProcessingState2.allPromises;
30273
- if (!fileProcessingPromisesByPath[path4]) {
30274
- fileProcessingPromisesByPath[path4] = [];
30445
+ if (!fileProcessingPromisesByPath[path5]) {
30446
+ fileProcessingPromisesByPath[path5] = [];
30275
30447
  }
30276
- const previousPromises = fileProcessingPromisesByPath[path4];
30448
+ const previousPromises = fileProcessingPromisesByPath[path5];
30277
30449
  const previousEdit = previousPromises[previousPromises.length - 1];
30278
- const latestContentPromise = previousEdit ? previousEdit.then((maybeResult) => maybeResult && ("content" in maybeResult) ? maybeResult.content : requestOptionalFile({ ...params2, filePath: path4 })) : requestOptionalFile({ ...params2, filePath: path4 });
30450
+ const latestContentPromise = previousEdit ? previousEdit.then((maybeResult) => maybeResult && ("content" in maybeResult) ? maybeResult.content : requestOptionalFile({ ...params2, filePath: path5 })) : requestOptionalFile({ ...params2, filePath: path5 });
30279
30451
  const fileContentWithoutStartNewline = content.startsWith(`
30280
30452
  `) ? content.slice(1) : content;
30281
- logger2.debug({ path: path4, content }, `write_file ${path4}`);
30453
+ logger2.debug({ path: path5, content }, `write_file ${path5}`);
30282
30454
  const newPromise = processFileBlock({
30283
30455
  ...params2,
30284
- path: path4,
30456
+ path: path5,
30285
30457
  instructions,
30286
30458
  initialContentPromise: latestContentPromise,
30287
30459
  newContent: fileContentWithoutStartNewline,
@@ -30303,14 +30475,14 @@ var handleWriteFile = async (params2) => {
30303
30475
  logger2.error(error, "Error processing write_file block");
30304
30476
  return {
30305
30477
  tool: "write_file",
30306
- path: path4,
30478
+ path: path5,
30307
30479
  error: `Error: Failed to process the write_file block. ${typeof error === "string" ? error : error.msg}`
30308
30480
  };
30309
30481
  }).then(async (fileProcessingResult) => ({
30310
30482
  ...fileProcessingResult,
30311
30483
  toolCallId: toolCall.toolCallId
30312
30484
  }));
30313
- fileProcessingPromisesByPath[path4].push(newPromise);
30485
+ fileProcessingPromisesByPath[path5].push(newPromise);
30314
30486
  fileProcessingPromises.push(newPromise);
30315
30487
  await previousToolCallFinished;
30316
30488
  return {
@@ -30340,12 +30512,12 @@ async function postStreamProcessing(toolCall, fileProcessingState2, writeToClien
30340
30512
  if (errors.length > 1) {
30341
30513
  throw new Error(`Internal error: Unexpected number of matching errors for ${JSON.stringify(toolCall)}, found ${errors.length}, expected 1`);
30342
30514
  }
30343
- const { path: path5, error } = errors[0];
30515
+ const { path: path6, error } = errors[0];
30344
30516
  return [
30345
30517
  {
30346
30518
  type: "json",
30347
30519
  value: {
30348
- file: path5,
30520
+ file: path6,
30349
30521
  errorMessage: error
30350
30522
  }
30351
30523
  }
@@ -30355,11 +30527,11 @@ async function postStreamProcessing(toolCall, fileProcessingState2, writeToClien
30355
30527
  if (changes.length !== 1) {
30356
30528
  throw new Error(`Internal error: Unexpected number of matching changes for ${JSON.stringify(toolCall)}, found ${changes.length}, expected 1`);
30357
30529
  }
30358
- const { patch, content, path: path4 } = changes[0];
30530
+ const { patch, content, path: path5 } = changes[0];
30359
30531
  const clientToolCall = {
30360
30532
  toolCallId: toolCall.toolCallId,
30361
30533
  toolName: toolCall.tool,
30362
- input: patch ? { type: "patch", path: path4, content: patch } : { type: "file", path: path4, content }
30534
+ input: patch ? { type: "patch", path: path5, content: patch } : { type: "file", path: path5, content }
30363
30535
  };
30364
30536
  return await requestClientToolCall(clientToolCall);
30365
30537
  }
@@ -30374,19 +30546,19 @@ var handleCreatePlan = async (params2) => {
30374
30546
  requestClientToolCall,
30375
30547
  writeToClient
30376
30548
  } = params2;
30377
- const { path: path4, plan } = toolCall.input;
30549
+ const { path: path5, plan } = toolCall.input;
30378
30550
  logger2.debug({
30379
- path: path4,
30551
+ path: path5,
30380
30552
  plan
30381
30553
  }, "Create plan");
30382
30554
  const change = {
30383
30555
  tool: "create_plan",
30384
- path: path4,
30556
+ path: path5,
30385
30557
  content: plan,
30386
30558
  messages: [],
30387
30559
  toolCallId: toolCall.toolCallId
30388
30560
  };
30389
- fileProcessingState2.promisesByPath[path4].push(Promise.resolve(change));
30561
+ fileProcessingState2.promisesByPath[path5].push(Promise.resolve(change));
30390
30562
  fileProcessingState2.allPromises.push(Promise.resolve(change));
30391
30563
  await previousToolCallFinished;
30392
30564
  return {
@@ -30403,12 +30575,12 @@ var handleEndTurn = async (params2) => {
30403
30575
 
30404
30576
  // ../packages/agent-runtime/src/find-files/request-files-prompt.ts
30405
30577
  init_old_constants();
30406
- import { dirname as dirname4, isAbsolute, normalize } from "path";
30578
+ import { dirname as dirname5, isAbsolute, normalize } from "path";
30407
30579
 
30408
30580
  // ../common/src/project-file-tree.ts
30409
30581
  var import_lodash5 = __toESM(require_lodash(), 1);
30410
30582
  init_paths();
30411
- import path4 from "path";
30583
+ import path5 from "path";
30412
30584
  import * as ignore from "ignore";
30413
30585
  function logFileTreeError(operation, filePath, error) {
30414
30586
  if (!process.env.DEBUG && !process.env.LEVELCODE_DEBUG) {
@@ -30422,7 +30594,7 @@ function logFileTreeError(operation, filePath, error) {
30422
30594
  var DEFAULT_MAX_FILES = 1e4;
30423
30595
  async function getProjectFileTree(params2) {
30424
30596
  const withDefaults = { maxFiles: DEFAULT_MAX_FILES, ...params2 };
30425
- const { projectRoot, fs: fs4 } = withDefaults;
30597
+ const { projectRoot, fs: fs5 } = withDefaults;
30426
30598
  let { maxFiles } = withDefaults;
30427
30599
  const _start = Date.now();
30428
30600
  const defaultIgnore = ignore.default();
@@ -30434,7 +30606,7 @@ async function getProjectFileTree(params2) {
30434
30606
  maxFiles = 0;
30435
30607
  }
30436
30608
  const root = {
30437
- name: path4.basename(projectRoot),
30609
+ name: path5.basename(projectRoot),
30438
30610
  type: "directory",
30439
30611
  children: [],
30440
30612
  filePath: ""
@@ -30452,20 +30624,20 @@ async function getProjectFileTree(params2) {
30452
30624
  const parsedIgnore = await parseGitignore({
30453
30625
  fullDirPath: fullPath,
30454
30626
  projectRoot,
30455
- fs: fs4
30627
+ fs: fs5
30456
30628
  });
30457
30629
  const mergedIgnore = ignore.default().add(currentIgnore).add(parsedIgnore);
30458
30630
  try {
30459
- const files = await fs4.readdir(fullPath);
30631
+ const files = await fs5.readdir(fullPath);
30460
30632
  for (const file of files) {
30461
30633
  if (totalFiles >= maxFiles)
30462
30634
  break;
30463
- const filePath = path4.join(fullPath, file);
30464
- const relativeFilePath = path4.relative(projectRoot, filePath);
30635
+ const filePath = path5.join(fullPath, file);
30636
+ const relativeFilePath = path5.relative(projectRoot, filePath);
30465
30637
  if (mergedIgnore.ignores(relativeFilePath))
30466
30638
  continue;
30467
30639
  try {
30468
- const stats = await fs4.stat(filePath);
30640
+ const stats = await fs5.stat(filePath);
30469
30641
  if (stats.isDirectory()) {
30470
30642
  const childNode = {
30471
30643
  name: file,
@@ -30527,21 +30699,21 @@ function rebaseGitignorePattern(rawPattern, relativeDirPath) {
30527
30699
  return isNegated ? `!${rebased}` : rebased;
30528
30700
  }
30529
30701
  async function parseGitignore(params2) {
30530
- const { fullDirPath, projectRoot, fs: fs4 } = params2;
30702
+ const { fullDirPath, projectRoot, fs: fs5 } = params2;
30531
30703
  const ig = ignore.default();
30532
- const relativeDirPath = path4.relative(projectRoot, fullDirPath);
30704
+ const relativeDirPath = path5.relative(projectRoot, fullDirPath);
30533
30705
  const ignoreFiles = [
30534
- path4.join(fullDirPath, ".gitignore"),
30535
- path4.join(fullDirPath, ".levelcodeignore"),
30536
- path4.join(fullDirPath, ".manicodeignore")
30706
+ path5.join(fullDirPath, ".gitignore"),
30707
+ path5.join(fullDirPath, ".levelcodeignore"),
30708
+ path5.join(fullDirPath, ".manicodeignore")
30537
30709
  ];
30538
30710
  for (const ignoreFilePath of ignoreFiles) {
30539
- const ignoreFileExists = await fileExists({ filePath: ignoreFilePath, fs: fs4 });
30711
+ const ignoreFileExists = await fileExists({ filePath: ignoreFilePath, fs: fs5 });
30540
30712
  if (!ignoreFileExists)
30541
30713
  continue;
30542
30714
  let ignoreContent;
30543
30715
  try {
30544
- ignoreContent = await fs4.readFile(ignoreFilePath, "utf8");
30716
+ ignoreContent = await fs5.readFile(ignoreFilePath, "utf8");
30545
30717
  } catch (error) {
30546
30718
  logFileTreeError("fs.readFile (ignore file)", ignoreFilePath, error);
30547
30719
  continue;
@@ -30561,9 +30733,9 @@ async function parseGitignore(params2) {
30561
30733
  function getAllFilePaths(nodes, basePath = "") {
30562
30734
  return nodes.flatMap((node) => {
30563
30735
  if (node.type === "file") {
30564
- return [path4.join(basePath, node.name)];
30736
+ return [path5.join(basePath, node.name)];
30565
30737
  }
30566
- return getAllFilePaths(node.children || [], path4.join(basePath, node.name));
30738
+ return getAllFilePaths(node.children || [], path5.join(basePath, node.name));
30567
30739
  });
30568
30740
  }
30569
30741
  function flattenTree(nodes) {
@@ -30578,18 +30750,18 @@ function getLastReadFilePaths(flattenedNodes, count) {
30578
30750
  return import_lodash5.sortBy(flattenedNodes.filter((node) => node.lastReadTime), "lastReadTime").reverse().slice(0, count).map((node) => node.filePath);
30579
30751
  }
30580
30752
  async function isFileIgnored(params2) {
30581
- const { filePath, projectRoot, fs: fs4 } = params2;
30753
+ const { filePath, projectRoot, fs: fs5 } = params2;
30582
30754
  const defaultIgnore = ignore.default();
30583
30755
  for (const pattern of DEFAULT_IGNORED_PATHS) {
30584
30756
  defaultIgnore.add(pattern);
30585
30757
  }
30586
- const relativeFilePath = path4.relative(projectRoot, path4.join(projectRoot, filePath));
30587
- const dirPath = path4.dirname(path4.join(projectRoot, filePath));
30758
+ const relativeFilePath = path5.relative(projectRoot, path5.join(projectRoot, filePath));
30759
+ const dirPath = path5.dirname(path5.join(projectRoot, filePath));
30588
30760
  const mergedIgnore = ignore.default().add(defaultIgnore);
30589
30761
  let currentDir = dirPath;
30590
30762
  while (currentDir.startsWith(projectRoot)) {
30591
- mergedIgnore.add(await parseGitignore({ fullDirPath: currentDir, projectRoot, fs: fs4 }));
30592
- currentDir = path4.dirname(currentDir);
30763
+ mergedIgnore.add(await parseGitignore({ fullDirPath: currentDir, projectRoot, fs: fs5 }));
30764
+ currentDir = path5.dirname(currentDir);
30593
30765
  }
30594
30766
  return mergedIgnore.ignores(relativeFilePath);
30595
30767
  }
@@ -30999,11 +31171,11 @@ function getExampleFileList(params2) {
30999
31171
  const selectedFiles = new Set;
31000
31172
  const selectedDirectories = new Set;
31001
31173
  for (const filePath of randomFilePaths) {
31002
- if (selectedFiles.has(filePath) || selectedDirectories.has(dirname4(filePath))) {
31174
+ if (selectedFiles.has(filePath) || selectedDirectories.has(dirname5(filePath))) {
31003
31175
  continue;
31004
31176
  }
31005
31177
  selectedFiles.add(filePath);
31006
- selectedDirectories.add(dirname4(filePath));
31178
+ selectedDirectories.add(dirname5(filePath));
31007
31179
  }
31008
31180
  return import_lodash8.uniq([...selectedFiles, ...randomFilePaths]).slice(0, count);
31009
31181
  }
@@ -31130,9 +31302,9 @@ async function getFileReadingUpdates(params2) {
31130
31302
  const { requestFiles, requestedFiles } = params2;
31131
31303
  const allFilePaths = import_lodash9.uniq(requestedFiles);
31132
31304
  const loadedFiles = await requestFiles({ filePaths: allFilePaths });
31133
- const addedFiles = allFilePaths.filter((path5) => loadedFiles[path5] != null && loadedFiles[path5] !== undefined).map((path5) => ({
31134
- path: path5,
31135
- content: loadedFiles[path5]
31305
+ const addedFiles = allFilePaths.filter((path6) => loadedFiles[path6] != null && loadedFiles[path6] !== undefined).map((path6) => ({
31306
+ path: path6,
31307
+ content: loadedFiles[path6]
31136
31308
  }));
31137
31309
  return addedFiles;
31138
31310
  }
@@ -31546,7 +31718,7 @@ ${systemInfo.platform === "win32" ? windowsNote + `
31546
31718
  Shell: ${systemInfo.shell}
31547
31719
 
31548
31720
  <user_shell_config_files>
31549
- ${Object.entries(shellConfigFiles).map(([path5, content]) => createMarkdownFileBlock(path5, content)).join(`
31721
+ ${Object.entries(shellConfigFiles).map(([path6, content]) => createMarkdownFileBlock(path6, content)).join(`
31550
31722
  `)}
31551
31723
  ${closeXml("user_shell_config_files")}
31552
31724
 
@@ -31826,12 +31998,12 @@ function normalizeLineEndings(params2) {
31826
31998
  `);
31827
31999
  }
31828
32000
  async function processStrReplace(params2) {
31829
- const { path: path5, replacements, initialContentPromise, logger: logger2 } = params2;
32001
+ const { path: path6, replacements, initialContentPromise, logger: logger2 } = params2;
31830
32002
  const initialContent = await initialContentPromise;
31831
32003
  if (initialContent === null) {
31832
32004
  return {
31833
32005
  tool: "str_replace",
31834
- path: path5,
32006
+ path: path6,
31835
32007
  error: "The file does not exist, skipping. Please use the write_file tool to create the file."
31836
32008
  };
31837
32009
  }
@@ -31871,19 +32043,19 @@ async function processStrReplace(params2) {
31871
32043
  `, lineEnding);
31872
32044
  if (initialContent === currentContent) {
31873
32045
  logger2.debug({
31874
- path: path5,
32046
+ path: path6,
31875
32047
  initialContent
31876
- }, `processStrReplace: No change to ${path5}`);
32048
+ }, `processStrReplace: No change to ${path6}`);
31877
32049
  messages.push("No change to the file");
31878
32050
  return {
31879
32051
  tool: "str_replace",
31880
- path: path5,
32052
+ path: path6,
31881
32053
  error: messages.join(`
31882
32054
 
31883
32055
  `)
31884
32056
  };
31885
32057
  }
31886
- let patch = createPatch2(path5, initialContent, currentContent);
32058
+ let patch = createPatch2(path6, initialContent, currentContent);
31887
32059
  const lines = patch.split(`
31888
32060
  `);
31889
32061
  const hunkStartIndex = lines.findIndex((line) => line.startsWith("@@"));
@@ -31893,14 +32065,14 @@ async function processStrReplace(params2) {
31893
32065
  }
31894
32066
  const finalPatch = patch;
31895
32067
  logger2.debug({
31896
- path: path5,
32068
+ path: path6,
31897
32069
  newContent: currentContent,
31898
32070
  patch: finalPatch,
31899
32071
  messages
31900
- }, `processStrReplace: Updated file ${path5}`);
32072
+ }, `processStrReplace: Updated file ${path6}`);
31901
32073
  return {
31902
32074
  tool: "str_replace",
31903
- path: path5,
32075
+ path: path6,
31904
32076
  content: currentContent,
31905
32077
  patch: finalPatch,
31906
32078
  messages
@@ -31972,17 +32144,17 @@ var handleProposeStrReplace = async (params2) => {
31972
32144
  runId,
31973
32145
  requestOptionalFile
31974
32146
  } = params2;
31975
- const { path: path5, replacements } = toolCall.input;
32147
+ const { path: path6, replacements } = toolCall.input;
31976
32148
  const getProposedOrDiskContent = async () => {
31977
- const proposedContent = getProposedContent(runId, path5);
32149
+ const proposedContent = getProposedContent(runId, path6);
31978
32150
  if (proposedContent !== undefined) {
31979
32151
  return proposedContent;
31980
32152
  }
31981
- return requestOptionalFile({ ...params2, filePath: path5 });
32153
+ return requestOptionalFile({ ...params2, filePath: path6 });
31982
32154
  };
31983
32155
  const latestContentPromise = getProposedOrDiskContent();
31984
32156
  const strReplaceResultPromise = processStrReplace({
31985
- path: path5,
32157
+ path: path6,
31986
32158
  replacements,
31987
32159
  initialContentPromise: latestContentPromise,
31988
32160
  logger: logger2
@@ -31990,11 +32162,11 @@ var handleProposeStrReplace = async (params2) => {
31990
32162
  logger2.error(error, "Error processing propose_str_replace");
31991
32163
  return {
31992
32164
  tool: "str_replace",
31993
- path: path5,
32165
+ path: path6,
31994
32166
  error: "Unknown error: Failed to process the propose_str_replace."
31995
32167
  };
31996
32168
  });
31997
- setProposedContent(runId, path5, strReplaceResultPromise.then((result) => ("content" in result) ? result.content : null));
32169
+ setProposedContent(runId, path6, strReplaceResultPromise.then((result) => ("content" in result) ? result.content : null));
31998
32170
  await previousToolCallFinished;
31999
32171
  const strReplaceResult = await strReplaceResultPromise;
32000
32172
  if ("error" in strReplaceResult) {
@@ -32003,7 +32175,7 @@ var handleProposeStrReplace = async (params2) => {
32003
32175
  {
32004
32176
  type: "json",
32005
32177
  value: {
32006
- file: path5,
32178
+ file: path6,
32007
32179
  errorMessage: strReplaceResult.error
32008
32180
  }
32009
32181
  }
@@ -32018,7 +32190,7 @@ var handleProposeStrReplace = async (params2) => {
32018
32190
  {
32019
32191
  type: "json",
32020
32192
  value: {
32021
- file: path5,
32193
+ file: path6,
32022
32194
  message,
32023
32195
  unifiedDiff: strReplaceResult.patch
32024
32196
  }
@@ -32037,21 +32209,21 @@ var handleProposeWriteFile = async (params2) => {
32037
32209
  runId,
32038
32210
  requestOptionalFile
32039
32211
  } = params2;
32040
- const { path: path5, content } = toolCall.input;
32212
+ const { path: path6, content } = toolCall.input;
32041
32213
  const getProposedOrDiskContent = async () => {
32042
- const proposedContent = getProposedContent(runId, path5);
32214
+ const proposedContent = getProposedContent(runId, path6);
32043
32215
  if (proposedContent !== undefined) {
32044
32216
  return proposedContent;
32045
32217
  }
32046
- return requestOptionalFile({ ...params2, filePath: path5 });
32218
+ return requestOptionalFile({ ...params2, filePath: path6 });
32047
32219
  };
32048
32220
  const initialContent = await getProposedOrDiskContent();
32049
32221
  const newContent = content.startsWith(`
32050
32222
  `) ? content.slice(1) : content;
32051
- setProposedContent(runId, path5, Promise.resolve(newContent));
32223
+ setProposedContent(runId, path6, Promise.resolve(newContent));
32052
32224
  await previousToolCallFinished;
32053
32225
  const oldContent = initialContent ?? "";
32054
- let patch = createPatch3(path5, oldContent, newContent);
32226
+ let patch = createPatch3(path6, oldContent, newContent);
32055
32227
  const lines = patch.split(`
32056
32228
  `);
32057
32229
  const hunkStartIndex = lines.findIndex((line) => line.startsWith("@@"));
@@ -32060,13 +32232,13 @@ var handleProposeWriteFile = async (params2) => {
32060
32232
  `);
32061
32233
  }
32062
32234
  const isNewFile = initialContent === null;
32063
- const message = isNewFile ? `Proposed new file ${path5}` : `Proposed changes to ${path5}`;
32235
+ const message = isNewFile ? `Proposed new file ${path6}` : `Proposed changes to ${path6}`;
32064
32236
  return {
32065
32237
  output: [
32066
32238
  {
32067
32239
  type: "json",
32068
32240
  value: {
32069
- file: path5,
32241
+ file: path6,
32070
32242
  message,
32071
32243
  unifiedDiff: patch
32072
32244
  }
@@ -33202,15 +33374,15 @@ var handleStrReplace = async (params2) => {
33202
33374
  requestOptionalFile,
33203
33375
  writeToClient
33204
33376
  } = params2;
33205
- const { path: path5, replacements } = toolCall.input;
33206
- if (!fileProcessingState2.promisesByPath[path5]) {
33207
- fileProcessingState2.promisesByPath[path5] = [];
33377
+ const { path: path6, replacements } = toolCall.input;
33378
+ if (!fileProcessingState2.promisesByPath[path6]) {
33379
+ fileProcessingState2.promisesByPath[path6] = [];
33208
33380
  }
33209
- const previousPromises = fileProcessingState2.promisesByPath[path5];
33381
+ const previousPromises = fileProcessingState2.promisesByPath[path6];
33210
33382
  const previousEdit = previousPromises[previousPromises.length - 1];
33211
- const latestContentPromise = previousEdit ? previousEdit.then((maybeResult) => maybeResult && ("content" in maybeResult) ? maybeResult.content : requestOptionalFile({ ...params2, filePath: path5 })) : requestOptionalFile({ ...params2, filePath: path5 });
33383
+ const latestContentPromise = previousEdit ? previousEdit.then((maybeResult) => maybeResult && ("content" in maybeResult) ? maybeResult.content : requestOptionalFile({ ...params2, filePath: path6 })) : requestOptionalFile({ ...params2, filePath: path6 });
33212
33384
  const newPromise = processStrReplace({
33213
- path: path5,
33385
+ path: path6,
33214
33386
  replacements,
33215
33387
  initialContentPromise: latestContentPromise,
33216
33388
  logger: logger2
@@ -33218,14 +33390,14 @@ var handleStrReplace = async (params2) => {
33218
33390
  logger2.error(error, "Error processing str_replace block");
33219
33391
  return {
33220
33392
  tool: "str_replace",
33221
- path: path5,
33393
+ path: path6,
33222
33394
  error: "Unknown error: Failed to process the str_replace block."
33223
33395
  };
33224
33396
  }).then((fileProcessingResult) => ({
33225
33397
  ...fileProcessingResult,
33226
33398
  toolCallId: toolCall.toolCallId
33227
33399
  }));
33228
- fileProcessingState2.promisesByPath[path5].push(newPromise);
33400
+ fileProcessingState2.promisesByPath[path6].push(newPromise);
33229
33401
  fileProcessingState2.allPromises.push(newPromise);
33230
33402
  await previousToolCallFinished;
33231
33403
  const strReplaceResult = await newPromise;
@@ -33248,7 +33420,7 @@ var handleSuggestFollowups = async (params2) => {
33248
33420
  };
33249
33421
 
33250
33422
  // ../packages/agent-runtime/src/tools/handlers/tool/task-completed.ts
33251
- import * as fs4 from "fs";
33423
+ import * as fs5 from "fs";
33252
33424
 
33253
33425
  // ../common/src/utils/team-hook-emitter.ts
33254
33426
  var listeners = new Set;
@@ -33305,10 +33477,10 @@ function emitTaskCompleted(params2) {
33305
33477
  // ../packages/agent-runtime/src/tools/handlers/tool/task-completed.ts
33306
33478
  function getActiveTeamName() {
33307
33479
  const teamsDir = getTeamsDir();
33308
- if (!fs4.existsSync(teamsDir)) {
33480
+ if (!fs5.existsSync(teamsDir)) {
33309
33481
  return null;
33310
33482
  }
33311
- const entries = fs4.readdirSync(teamsDir, { withFileTypes: true });
33483
+ const entries = fs5.readdirSync(teamsDir, { withFileTypes: true });
33312
33484
  const teamDirs = entries.filter((e) => e.isDirectory());
33313
33485
  if (teamDirs.length === 0) {
33314
33486
  return null;
@@ -33571,102 +33743,6 @@ var handleWriteTodos = async (params2) => {
33571
33743
  return { output: jsonToolResult({ message: "Todos written" }) };
33572
33744
  };
33573
33745
 
33574
- // ../common/src/utils/team-discovery.ts
33575
- import * as fs5 from "fs";
33576
- function readTeamEntries() {
33577
- let teamsDir;
33578
- try {
33579
- teamsDir = getTeamsDir();
33580
- } catch {
33581
- return [];
33582
- }
33583
- if (!fs5.existsSync(teamsDir)) {
33584
- return [];
33585
- }
33586
- try {
33587
- return fs5.readdirSync(teamsDir, { withFileTypes: true });
33588
- } catch {
33589
- return [];
33590
- }
33591
- }
33592
- function safeLoadTeamConfig(teamName) {
33593
- try {
33594
- const config = loadTeamConfig(teamName);
33595
- if (!config || !Array.isArray(config.members)) {
33596
- return null;
33597
- }
33598
- return config;
33599
- } catch {
33600
- return null;
33601
- }
33602
- }
33603
- function findCurrentTeam(agentId) {
33604
- const entries = readTeamEntries();
33605
- for (const entry of entries) {
33606
- if (!entry.isDirectory()) {
33607
- continue;
33608
- }
33609
- const config = safeLoadTeamConfig(entry.name);
33610
- if (!config) {
33611
- continue;
33612
- }
33613
- if (config.leadAgentId === `lead-${agentId}`) {
33614
- return { teamName: config.name, config };
33615
- }
33616
- for (const member of config.members) {
33617
- if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
33618
- return { teamName: config.name, config };
33619
- }
33620
- }
33621
- }
33622
- return null;
33623
- }
33624
- function findCurrentTeamAndAgent(agentId) {
33625
- const entries = readTeamEntries();
33626
- for (const entry of entries) {
33627
- if (!entry.isDirectory()) {
33628
- continue;
33629
- }
33630
- const config = safeLoadTeamConfig(entry.name);
33631
- if (!config) {
33632
- continue;
33633
- }
33634
- for (const member of config.members) {
33635
- if (member.agentId === `lead-${agentId}` || member.agentId === agentId) {
33636
- return { teamName: config.name, agentName: member.name, config };
33637
- }
33638
- }
33639
- }
33640
- return null;
33641
- }
33642
- function findTeamByName(name) {
33643
- try {
33644
- validateTeamName(name);
33645
- } catch {
33646
- return null;
33647
- }
33648
- return safeLoadTeamConfig(name);
33649
- }
33650
- function listAllTeams() {
33651
- const entries = readTeamEntries();
33652
- const results = [];
33653
- for (const entry of entries) {
33654
- if (!entry.isDirectory()) {
33655
- continue;
33656
- }
33657
- const config = safeLoadTeamConfig(entry.name);
33658
- if (!config) {
33659
- continue;
33660
- }
33661
- results.push({
33662
- name: config.name,
33663
- phase: config.phase,
33664
- memberCount: config.members.length
33665
- });
33666
- }
33667
- return results;
33668
- }
33669
-
33670
33746
  // ../packages/agent-runtime/src/tools/handlers/tool/send-message.ts
33671
33747
  function errorResult(message) {
33672
33748
  return { output: jsonToolResult({ message }) };
@@ -34050,7 +34126,7 @@ var handleTaskList = async (params2) => {
34050
34126
 
34051
34127
  // ../packages/agent-runtime/src/tools/handlers/tool/task-update.ts
34052
34128
  import * as fs6 from "fs";
34053
- import * as path5 from "path";
34129
+ import * as path6 from "path";
34054
34130
  var VALID_STATUSES = ["pending", "in_progress", "completed", "blocked", "deleted"];
34055
34131
  function errorResult4(message) {
34056
34132
  return { output: jsonToolResult({ error: message }) };
@@ -34101,7 +34177,7 @@ var handleTaskUpdate = async (params2) => {
34101
34177
  }
34102
34178
  if (status === "deleted") {
34103
34179
  try {
34104
- const taskPath = path5.join(getTasksDir(teamName), `${taskId}.json`);
34180
+ const taskPath = path6.join(getTasksDir(teamName), `${taskId}.json`);
34105
34181
  if (fs6.existsSync(taskPath)) {
34106
34182
  fs6.unlinkSync(taskPath);
34107
34183
  }
@@ -34239,6 +34315,7 @@ var handleTeamCreate = async (params2) => {
34239
34315
  const errorMessage = error instanceof Error ? error.message : String(error);
34240
34316
  return errorResult5(`Failed to create team "${team_name}": ${errorMessage}`);
34241
34317
  }
34318
+ setLastActiveTeam(team_name);
34242
34319
  trackTeamCreated({ trackEvent: trackEvent2, userId: userId ?? "", logger: logger2 }, team_name, teamConfig.members.length);
34243
34320
  let teamFilePath;
34244
34321
  let taskDirPath;
@@ -35224,8 +35301,72 @@ async function executeSegmentsArray(segments, params2) {
35224
35301
  return toolResults2;
35225
35302
  }
35226
35303
 
35304
+ // ../packages/agent-runtime/src/team-lifecycle.ts
35305
+ var registry = new Map;
35306
+ async function updateAgentStatus(teamName, agentId, status, logger2) {
35307
+ const teamMap = registry.get(teamName);
35308
+ if (teamMap) {
35309
+ const entry = teamMap.get(agentId);
35310
+ if (entry) {
35311
+ entry.status = status;
35312
+ }
35313
+ }
35314
+ const config = loadTeamConfig(teamName);
35315
+ if (!config) {
35316
+ logger2.debug({ teamName, agentId, status }, "updateAgentStatus: team config not found");
35317
+ return;
35318
+ }
35319
+ const memberIndex = config.members.findIndex((m) => m.agentId === agentId);
35320
+ if (memberIndex === -1) {
35321
+ logger2.debug({ teamName, agentId, status }, "updateAgentStatus: member not found in team config");
35322
+ return;
35323
+ }
35324
+ config.members[memberIndex].status = status;
35325
+ await saveTeamConfig(teamName, config);
35326
+ logger2.debug({ teamName, agentId, status }, `updateAgentStatus: set status to "${status}"`);
35327
+ }
35328
+ async function markAgentIdle(params2) {
35329
+ const { teamName, agentId, agentName, lastTaskId, trackEvent: trackEvent2, userId, logger: logger2 } = params2;
35330
+ await updateAgentStatus(teamName, agentId, "idle", logger2);
35331
+ const config = loadTeamConfig(teamName);
35332
+ if (config) {
35333
+ const member = config.members.find((m) => m.agentId === agentId);
35334
+ if (member) {
35335
+ member.currentTaskId = undefined;
35336
+ await saveTeamConfig(teamName, config);
35337
+ }
35338
+ }
35339
+ emitTeammateIdle({
35340
+ agentName,
35341
+ teamName,
35342
+ lastTaskId,
35343
+ trackEvent: trackEvent2,
35344
+ userId,
35345
+ logger: logger2
35346
+ });
35347
+ if (config) {
35348
+ const leadMember = config.members.find((m) => m.agentId === config.leadAgentId);
35349
+ const leadName = leadMember?.name ?? "team-lead";
35350
+ const notification = {
35351
+ type: "idle_notification",
35352
+ from: agentName,
35353
+ timestamp: new Date().toISOString(),
35354
+ summary: lastTaskId ? `Completed task ${lastTaskId}, now idle` : "Agent is idle and ready for work",
35355
+ completedTaskId: lastTaskId
35356
+ };
35357
+ await sendMessage(teamName, leadName, notification);
35358
+ logger2.debug({ teamName, agentName, leadName, lastTaskId }, "markAgentIdle: sent idle notification to team lead");
35359
+ }
35360
+ }
35361
+ async function checkIdleAfterTurn(params2) {
35362
+ const { producedOutput, ...rest } = params2;
35363
+ if (!producedOutput) {
35364
+ await markAgentIdle(rest);
35365
+ }
35366
+ }
35367
+
35227
35368
  // ../common/src/constants/knowledge.ts
35228
- import path6 from "path";
35369
+ import path7 from "path";
35229
35370
  var PRIMARY_KNOWLEDGE_FILE_NAME = "knowledge.md";
35230
35371
  var KNOWLEDGE_FILE_NAMES = [
35231
35372
  PRIMARY_KNOWLEDGE_FILE_NAME,
@@ -35234,7 +35375,7 @@ var KNOWLEDGE_FILE_NAMES = [
35234
35375
  ];
35235
35376
  var KNOWLEDGE_FILE_NAMES_LOWERCASE = KNOWLEDGE_FILE_NAMES.map((name) => name.toLowerCase());
35236
35377
  function isKnowledgeFile(filePath) {
35237
- const fileName = path6.basename(filePath).toLowerCase();
35378
+ const fileName = path7.basename(filePath).toLowerCase();
35238
35379
  if (KNOWLEDGE_FILE_NAMES_LOWERCASE.includes(fileName)) {
35239
35380
  return true;
35240
35381
  }
@@ -35326,10 +35467,10 @@ async function formatPrompt(params2) {
35326
35467
  ...Object.fromEntries(Object.entries(fileContext.knowledgeFiles).filter(([filePath]) => {
35327
35468
  const lowerPath = filePath.toLowerCase();
35328
35469
  return KNOWLEDGE_FILE_NAMES_LOWERCASE.includes(lowerPath);
35329
- }).map(([path7, content]) => [path7, content.trim()])),
35470
+ }).map(([path8, content]) => [path8, content.trim()])),
35330
35471
  ...fileContext.userKnowledgeFiles
35331
- }).map(([path7, content]) => {
35332
- return `\`\`\`${path7}
35472
+ }).map(([path8, content]) => {
35473
+ return `\`\`\`${path8}
35333
35474
  ${content.trim()}
35334
35475
  \`\`\``;
35335
35476
  }).join(`
@@ -36417,6 +36558,69 @@ async function loopAgentSteps(params2) {
36417
36558
  currentPrompt = undefined;
36418
36559
  currentParams = undefined;
36419
36560
  }
36561
+ const postLoopTeamContext = findTeamContext(userInputId2);
36562
+ if (postLoopTeamContext && !signal.aborted) {
36563
+ try {
36564
+ await checkIdleAfterTurn({
36565
+ teamName: postLoopTeamContext.teamName,
36566
+ agentId: currentAgentState.agentId,
36567
+ agentName: postLoopTeamContext.agentName,
36568
+ producedOutput: totalSteps > 0,
36569
+ trackEvent: params2.trackEvent,
36570
+ userId: userId ?? "",
36571
+ logger: logger2
36572
+ });
36573
+ } catch (idleErr) {
36574
+ logger2.debug({ error: idleErr }, "checkIdleAfterTurn failed (non-fatal)");
36575
+ }
36576
+ }
36577
+ if (postLoopTeamContext && !signal.aborted) {
36578
+ try {
36579
+ await new Promise((resolve3) => setTimeout(resolve3, 2000));
36580
+ if (!signal.aborted) {
36581
+ const wakeInbox = drainInbox({
36582
+ teamName: postLoopTeamContext.teamName,
36583
+ agentName: postLoopTeamContext.agentName,
36584
+ logger: logger2
36585
+ });
36586
+ if (wakeInbox.formattedContent) {
36587
+ logger2.debug({
36588
+ teamName: postLoopTeamContext.teamName,
36589
+ agentName: postLoopTeamContext.agentName,
36590
+ messageCount: wakeInbox.messages.length
36591
+ }, "Post-loop wake: new messages detected, running one more step");
36592
+ currentAgentState.messageHistory = [
36593
+ ...currentAgentState.messageHistory,
36594
+ userMessage(withSystemTags(wakeInbox.formattedContent))
36595
+ ];
36596
+ currentAgentState.stepsRemaining = Math.max(currentAgentState.stepsRemaining, 1);
36597
+ const wakeStep = await runAgentStep({
36598
+ ...params2,
36599
+ agentState: currentAgentState,
36600
+ agentTemplate,
36601
+ prompt: undefined,
36602
+ runId,
36603
+ spawnParams: undefined,
36604
+ system,
36605
+ tools,
36606
+ additionalToolDefinitions: async () => {
36607
+ if (!cachedAdditionalToolDefinitions) {
36608
+ cachedAdditionalToolDefinitions = await additionalToolDefinitions({
36609
+ ...params2,
36610
+ agentTemplate
36611
+ });
36612
+ }
36613
+ return cachedAdditionalToolDefinitions;
36614
+ }
36615
+ });
36616
+ totalSteps++;
36617
+ currentAgentState = wakeStep.agentState;
36618
+ }
36619
+ }
36620
+ } catch (wakeErr) {
36621
+ logger2.debug({ error: wakeErr }, "Post-loop wake check failed (non-fatal)");
36622
+ }
36623
+ }
36420
36624
  if (clearUserPromptMessagesAfterResponse) {
36421
36625
  currentAgentState.messageHistory = expireMessages(currentAgentState.messageHistory, "userPrompt");
36422
36626
  }
@@ -40240,7 +40444,7 @@ import {
40240
40444
  } from "ai";
40241
40445
 
40242
40446
  // src/impl/model-provider.ts
40243
- import path8 from "path";
40447
+ import path9 from "path";
40244
40448
  import { createAnthropic } from "@ai-sdk/anthropic";
40245
40449
 
40246
40450
  // ../node_modules/@ai-sdk/provider/dist/index.mjs
@@ -43093,7 +43297,7 @@ function createOpenRouter(options = {}) {
43093
43297
  });
43094
43298
  const createChatModel = (modelId, settings = {}) => new OpenRouterChatLanguageModel(modelId, settings, {
43095
43299
  provider: "openrouter.chat",
43096
- url: ({ path: path7 }) => `${baseURL}${path7}`,
43300
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
43097
43301
  headers: getHeaders,
43098
43302
  compatibility,
43099
43303
  fetch: options.fetch,
@@ -43101,7 +43305,7 @@ function createOpenRouter(options = {}) {
43101
43305
  });
43102
43306
  const createCompletionModel = (modelId, settings = {}) => new OpenRouterCompletionLanguageModel(modelId, settings, {
43103
43307
  provider: "openrouter.completion",
43104
- url: ({ path: path7 }) => `${baseURL}${path7}`,
43308
+ url: ({ path: path8 }) => `${baseURL}${path8}`,
43105
43309
  headers: getHeaders,
43106
43310
  compatibility,
43107
43311
  fetch: options.fetch,
@@ -43128,8 +43332,8 @@ var openrouter = createOpenRouter({
43128
43332
 
43129
43333
  // src/credentials.ts
43130
43334
  import fs7 from "fs";
43131
- import path7 from "node:path";
43132
- import os3 from "os";
43335
+ import path8 from "node:path";
43336
+ import os4 from "os";
43133
43337
 
43134
43338
  // ../common/src/util/credentials.ts
43135
43339
  import { z as z86 } from "zod/v4";
@@ -43169,18 +43373,18 @@ var userFromJson = (json) => {
43169
43373
  };
43170
43374
  var getLegacyConfigDir = (clientEnv = env) => {
43171
43375
  const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
43172
- return path7.join(os3.homedir(), ".config", `manicode${envSuffix}`);
43376
+ return path8.join(os4.homedir(), ".config", `manicode${envSuffix}`);
43173
43377
  };
43174
43378
  var getConfigDir = (clientEnv = env) => {
43175
43379
  const envSuffix = clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT && clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT !== "prod" ? `-${clientEnv.NEXT_PUBLIC_CB_ENVIRONMENT}` : "";
43176
- return path7.join(os3.homedir(), ".config", `levelcode${envSuffix}`);
43380
+ return path8.join(os4.homedir(), ".config", `levelcode${envSuffix}`);
43177
43381
  };
43178
43382
  var migrateFromLegacyConfigDir = (clientEnv = env) => {
43179
43383
  const newDir = getConfigDir(clientEnv);
43180
- const newCredsPath = path7.join(newDir, "credentials.json");
43384
+ const newCredsPath = path8.join(newDir, "credentials.json");
43181
43385
  if (fs7.existsSync(newCredsPath))
43182
43386
  return;
43183
- const legacyCredsPath = path7.join(getLegacyConfigDir(clientEnv), "credentials.json");
43387
+ const legacyCredsPath = path8.join(getLegacyConfigDir(clientEnv), "credentials.json");
43184
43388
  if (!fs7.existsSync(legacyCredsPath))
43185
43389
  return;
43186
43390
  try {
@@ -43190,7 +43394,7 @@ var migrateFromLegacyConfigDir = (clientEnv = env) => {
43190
43394
  };
43191
43395
  var getCredentialsPath = (clientEnv = env) => {
43192
43396
  migrateFromLegacyConfigDir(clientEnv);
43193
- return path7.join(getConfigDir(clientEnv), "credentials.json");
43397
+ return path8.join(getConfigDir(clientEnv), "credentials.json");
43194
43398
  };
43195
43399
  var getUserCredentials = (clientEnv = env) => {
43196
43400
  const credentialsPath = getCredentialsPath(clientEnv);
@@ -43468,7 +43672,7 @@ function createLevelCodeBackendModel(apiKey, model) {
43468
43672
  const openrouterApiKey = getByokOpenrouterApiKeyFromEnv();
43469
43673
  return new OpenAICompatibleChatLanguageModel(model, {
43470
43674
  provider: "levelcode",
43471
- url: ({ path: endpoint }) => new URL(path8.join("/api/v1", endpoint), WEBSITE_URL).toString(),
43675
+ url: ({ path: endpoint }) => new URL(path9.join("/api/v1", endpoint), WEBSITE_URL).toString(),
43472
43676
  headers: () => ({
43473
43677
  Authorization: `Bearer ${apiKey}`,
43474
43678
  "user-agent": `ai-sdk/openai-compatible/${VERSION2}/levelcode`,
@@ -43977,38 +44181,38 @@ var noopLogger = {
43977
44181
  };
43978
44182
 
43979
44183
  // src/run-state.ts
43980
- import * as os6 from "os";
43981
- import path14 from "path";
44184
+ import * as os7 from "os";
44185
+ import path15 from "path";
43982
44186
 
43983
44187
  // ../packages/code-map/src/parse.ts
43984
44188
  import * as fs10 from "fs";
43985
- import * as path11 from "path";
44189
+ import * as path12 from "path";
43986
44190
 
43987
44191
  // ../packages/code-map/src/languages.ts
43988
44192
  import * as fs9 from "fs";
43989
- import * as path10 from "path";
44193
+ import * as path11 from "path";
43990
44194
  import { Language, Parser as Parser2, Query } from "web-tree-sitter";
43991
44195
 
43992
44196
  // ../packages/code-map/src/init-node.ts
43993
44197
  import * as fs8 from "fs";
43994
- import * as path9 from "path";
44198
+ import * as path10 from "path";
43995
44199
  import { Parser } from "web-tree-sitter";
43996
44200
  async function initTreeSitterForNode() {
43997
44201
  await Parser.init({
43998
44202
  locateFile: (name14, scriptDir) => {
43999
44203
  if (name14 === "tree-sitter.wasm") {
44000
- const fallback = path9.join(scriptDir, name14);
44204
+ const fallback = path10.join(scriptDir, name14);
44001
44205
  if (fs8.existsSync(fallback)) {
44002
44206
  return fallback;
44003
44207
  }
44004
- const pkgDir = path9.dirname(__require.resolve("web-tree-sitter"));
44005
- const wasm = path9.join(pkgDir, "tree-sitter.wasm");
44208
+ const pkgDir = path10.dirname(__require.resolve("web-tree-sitter"));
44209
+ const wasm = path10.join(pkgDir, "tree-sitter.wasm");
44006
44210
  if (fs8.existsSync(wasm)) {
44007
44211
  return wasm;
44008
44212
  }
44009
44213
  throw new Error(`Internal error: web-tree-sitter/tree-sitter.wasm not found at ${wasm}. Ensure the file is included in your deployment bundle.`);
44010
44214
  }
44011
- return path9.join(scriptDir, name14);
44215
+ return path10.join(scriptDir, name14);
44012
44216
  }
44013
44217
  });
44014
44218
  }
@@ -44348,23 +44552,23 @@ function getWasmDir() {
44348
44552
  function resolveWasmPath(wasmFileName) {
44349
44553
  const customWasmDirPath = getWasmDir();
44350
44554
  if (customWasmDirPath) {
44351
- return path10.join(customWasmDirPath, wasmFileName);
44555
+ return path11.join(customWasmDirPath, wasmFileName);
44352
44556
  }
44353
44557
  const envWasmDir = process.env.LEVELCODE_WASM_DIR;
44354
44558
  if (envWasmDir) {
44355
- return path10.join(envWasmDir, wasmFileName);
44559
+ return path11.join(envWasmDir, wasmFileName);
44356
44560
  }
44357
44561
  const moduleDir = (() => {
44358
- const dirname6 = getDirnameDynamically();
44359
- if (typeof dirname6 !== "undefined") {
44360
- return dirname6;
44562
+ const dirname7 = getDirnameDynamically();
44563
+ if (typeof dirname7 !== "undefined") {
44564
+ return dirname7;
44361
44565
  }
44362
44566
  return process.cwd();
44363
44567
  })();
44364
44568
  const possiblePaths = [
44365
- path10.join(moduleDir, "..", "wasm", wasmFileName),
44366
- path10.join(moduleDir, "wasm", wasmFileName),
44367
- path10.join(process.cwd(), "dist", "wasm", wasmFileName)
44569
+ path11.join(moduleDir, "..", "wasm", wasmFileName),
44570
+ path11.join(moduleDir, "wasm", wasmFileName),
44571
+ path11.join(process.cwd(), "dist", "wasm", wasmFileName)
44368
44572
  ];
44369
44573
  for (const wasmPath of possiblePaths) {
44370
44574
  try {
@@ -44408,7 +44612,7 @@ class UnifiedLanguageLoader {
44408
44612
  }
44409
44613
  }
44410
44614
  function findLanguageConfigByExtension(filePath) {
44411
- const ext = path10.extname(filePath);
44615
+ const ext = path11.extname(filePath);
44412
44616
  return languageTable.find((c) => c.extensions.includes(ext));
44413
44617
  }
44414
44618
  async function createLanguageConfig(filePath, runtimeLoader) {
@@ -44422,7 +44626,7 @@ async function createLanguageConfig(filePath, runtimeLoader) {
44422
44626
  const lang = await runtimeLoader.loadLanguage(cfg.wasmFile);
44423
44627
  const parser = new Parser2;
44424
44628
  parser.setLanguage(lang);
44425
- const queryContent = path10.isAbsolute(cfg.queryPathOrContent) ? fs9.readFileSync(cfg.queryPathOrContent, "utf8") : cfg.queryPathOrContent;
44629
+ const queryContent = path11.isAbsolute(cfg.queryPathOrContent) ? fs9.readFileSync(cfg.queryPathOrContent, "utf8") : cfg.queryPathOrContent;
44426
44630
  cfg.language = lang;
44427
44631
  cfg.parser = parser;
44428
44632
  cfg.query = new Query(lang, queryContent);
@@ -44454,7 +44658,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
44454
44658
  const externalCalls = {};
44455
44659
  const fileCallsMap = new Map;
44456
44660
  for (const filePath of filePaths) {
44457
- const fullPath = path11.join(projectRoot, filePath);
44661
+ const fullPath = path12.join(projectRoot, filePath);
44458
44662
  const languageConfig = await getLanguageConfig(fullPath);
44459
44663
  if (languageConfig) {
44460
44664
  let parseResults;
@@ -44466,7 +44670,7 @@ async function getFileTokenScores(projectRoot, filePaths, readFile) {
44466
44670
  const { identifiers, calls, numLines } = parseResults;
44467
44671
  const tokenScoresForFile = {};
44468
44672
  tokenScores[filePath] = tokenScoresForFile;
44469
- const dirs = path11.dirname(fullPath).split(path11.sep);
44673
+ const dirs = path12.dirname(fullPath).split(path12.sep);
44470
44674
  const depth = dirs.length;
44471
44675
  const tokenBaseScore = 0.8 ** depth * Math.sqrt(numLines / (identifiers.length + 1));
44472
44676
  for (const identifier of identifiers) {
@@ -44602,8 +44806,8 @@ import z89 from "zod/v4";
44602
44806
 
44603
44807
  // src/agents/load-agents.ts
44604
44808
  import fs11 from "fs";
44605
- import os4 from "os";
44606
- import path12 from "path";
44809
+ import os5 from "os";
44810
+ import path13 from "path";
44607
44811
  import { pathToFileURL } from "url";
44608
44812
 
44609
44813
  // src/validate-agents.ts
@@ -44716,12 +44920,12 @@ var getAllAgentFiles = (dir) => {
44716
44920
  try {
44717
44921
  const entries = fs11.readdirSync(dir, { withFileTypes: true });
44718
44922
  for (const entry of entries) {
44719
- const fullPath = path12.join(dir, entry.name);
44923
+ const fullPath = path13.join(dir, entry.name);
44720
44924
  if (entry.isDirectory()) {
44721
44925
  files.push(...getAllAgentFiles(fullPath));
44722
44926
  continue;
44723
44927
  }
44724
- const extension = path12.extname(entry.name).toLowerCase();
44928
+ const extension = path13.extname(entry.name).toLowerCase();
44725
44929
  const isAgentFile = entry.isFile() && agentFileExtensions.has(extension) && !entry.name.endsWith(".d.ts") && !entry.name.endsWith(".test.ts");
44726
44930
  if (isAgentFile) {
44727
44931
  files.push(fullPath);
@@ -44731,9 +44935,9 @@ var getAllAgentFiles = (dir) => {
44731
44935
  return files;
44732
44936
  };
44733
44937
  var getDefaultAgentDirs = () => {
44734
- const cwdAgents = path12.join(process.cwd(), ".agents");
44735
- const parentAgents = path12.join(process.cwd(), "..", ".agents");
44736
- const homeAgents = path12.join(os4.homedir(), ".agents");
44938
+ const cwdAgents = path13.join(process.cwd(), ".agents");
44939
+ const parentAgents = path13.join(process.cwd(), "..", ".agents");
44940
+ const homeAgents = path13.join(os5.homedir(), ".agents");
44737
44941
  return [cwdAgents, parentAgents, homeAgents];
44738
44942
  };
44739
44943
  async function loadLocalAgents({
@@ -44823,8 +45027,8 @@ async function importAgentModule(fullPath) {
44823
45027
 
44824
45028
  // src/skills/load-skills.ts
44825
45029
  import fs12 from "fs";
44826
- import os5 from "os";
44827
- import path13 from "path";
45030
+ import os6 from "os";
45031
+ import path14 from "path";
44828
45032
 
44829
45033
  // ../common/src/constants/skills.ts
44830
45034
  var SKILLS_DIR_NAME = "skills";
@@ -44874,7 +45078,7 @@ function parseFrontmatter(content) {
44874
45078
  }
44875
45079
  }
44876
45080
  function loadSkillFromFile(skillDir, skillFilePath, verbose) {
44877
- const dirName = path13.basename(skillDir);
45081
+ const dirName = path14.basename(skillDir);
44878
45082
  let content;
44879
45083
  try {
44880
45084
  content = fs12.readFileSync(skillFilePath, "utf8");
@@ -44923,7 +45127,7 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
44923
45127
  return skills;
44924
45128
  }
44925
45129
  for (const entry of entries) {
44926
- const skillDir = path13.join(skillsDir, entry);
45130
+ const skillDir = path14.join(skillsDir, entry);
44927
45131
  try {
44928
45132
  const stat = fs12.statSync(skillDir);
44929
45133
  if (!stat.isDirectory())
@@ -44937,7 +45141,7 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
44937
45141
  }
44938
45142
  continue;
44939
45143
  }
44940
- const skillFilePath = path13.join(skillDir, SKILL_FILE_NAME);
45144
+ const skillFilePath = path14.join(skillDir, SKILL_FILE_NAME);
44941
45145
  try {
44942
45146
  fs12.statSync(skillFilePath);
44943
45147
  } catch {
@@ -44951,12 +45155,12 @@ function discoverSkillsFromDirectory(skillsDir, verbose) {
44951
45155
  return skills;
44952
45156
  }
44953
45157
  function getDefaultSkillsDirs(cwd) {
44954
- const home = os5.homedir();
45158
+ const home = os6.homedir();
44955
45159
  return [
44956
- path13.join(home, ".claude", SKILLS_DIR_NAME),
44957
- path13.join(home, ".agents", SKILLS_DIR_NAME),
44958
- path13.join(cwd, ".claude", SKILLS_DIR_NAME),
44959
- path13.join(cwd, ".agents", SKILLS_DIR_NAME)
45160
+ path14.join(home, ".claude", SKILLS_DIR_NAME),
45161
+ path14.join(home, ".agents", SKILLS_DIR_NAME),
45162
+ path14.join(cwd, ".claude", SKILLS_DIR_NAME),
45163
+ path14.join(cwd, ".agents", SKILLS_DIR_NAME)
44960
45164
  ];
44961
45165
  }
44962
45166
  async function loadSkills(options = {}) {
@@ -45079,7 +45283,7 @@ async function discoverProjectFiles(params2) {
45079
45283
  let error;
45080
45284
  const projectFilePromises = Object.fromEntries(filePaths.map((filePath) => [
45081
45285
  filePath,
45082
- fs13.readFile(path14.join(cwd, filePath), "utf8").catch((err) => {
45286
+ fs13.readFile(path15.join(cwd, filePath), "utf8").catch((err) => {
45083
45287
  error = err;
45084
45288
  return "[ERROR_READING_FILE]";
45085
45289
  })
@@ -45095,7 +45299,7 @@ async function discoverProjectFiles(params2) {
45095
45299
  }
45096
45300
  async function loadUserKnowledgeFiles(params2) {
45097
45301
  const { fs: fs13, logger: logger2 } = params2;
45098
- const homeDir = params2.homeDir ?? os6.homedir();
45302
+ const homeDir = params2.homeDir ?? os7.homedir();
45099
45303
  const userKnowledgeFiles = {};
45100
45304
  let entries;
45101
45305
  try {
@@ -45117,7 +45321,7 @@ async function loadUserKnowledgeFiles(params2) {
45117
45321
  for (const priorityName of KNOWLEDGE_FILE_NAMES_LOWERCASE) {
45118
45322
  const actualFileName = candidates.get(priorityName);
45119
45323
  if (actualFileName) {
45120
- const filePath = path14.join(homeDir, actualFileName);
45324
+ const filePath = path15.join(homeDir, actualFileName);
45121
45325
  try {
45122
45326
  const content = await fs13.readFile(filePath, "utf8");
45123
45327
  const tildeKey = `~/${actualFileName}`;
@@ -45134,7 +45338,7 @@ function selectKnowledgeFilePaths(allFilePaths) {
45134
45338
  const knowledgeCandidates = allFilePaths.filter(isKnowledgeFile);
45135
45339
  const byDirectory = new Map;
45136
45340
  for (const filePath of knowledgeCandidates) {
45137
- const dir = path14.dirname(filePath);
45341
+ const dir = path15.dirname(filePath);
45138
45342
  if (!byDirectory.has(dir)) {
45139
45343
  byDirectory.set(dir, []);
45140
45344
  }
@@ -45244,8 +45448,8 @@ async function initialSessionState(params2) {
45244
45448
  shell: "bash",
45245
45449
  nodeVersion: process.version,
45246
45450
  arch: process.arch,
45247
- homedir: os6.homedir(),
45248
- cpus: os6.cpus().length ?? 1
45451
+ homedir: os7.homedir(),
45452
+ cpus: os7.cpus().length ?? 1
45249
45453
  }
45250
45454
  });
45251
45455
  if (maxAgentSteps) {
@@ -45358,19 +45562,19 @@ function buildFileTree(filePaths) {
45358
45562
  }
45359
45563
  const rootNodes = [];
45360
45564
  const processed = new Set;
45361
- for (const [path15, node] of Object.entries(tree)) {
45362
- if (processed.has(path15))
45565
+ for (const [path16, node] of Object.entries(tree)) {
45566
+ if (processed.has(path16))
45363
45567
  continue;
45364
- const parentPath = path15.substring(0, path15.lastIndexOf("/"));
45568
+ const parentPath = path16.substring(0, path16.lastIndexOf("/"));
45365
45569
  if (parentPath && tree[parentPath]) {
45366
45570
  const parent = tree[parentPath];
45367
- if (parent.children && !parent.children.some((child) => child.filePath === path15)) {
45571
+ if (parent.children && !parent.children.some((child) => child.filePath === path16)) {
45368
45572
  parent.children.push(node);
45369
45573
  }
45370
45574
  } else {
45371
45575
  rootNodes.push(node);
45372
45576
  }
45373
- processed.add(path15);
45577
+ processed.add(path16);
45374
45578
  }
45375
45579
  function sortNodes(nodes) {
45376
45580
  nodes.sort((a, b) => {
@@ -45390,7 +45594,7 @@ function buildFileTree(filePaths) {
45390
45594
  }
45391
45595
 
45392
45596
  // src/tools/change-file.ts
45393
- import path15 from "path";
45597
+ import path16 from "path";
45394
45598
  import { applyPatch } from "diff";
45395
45599
  import z90 from "zod/v4";
45396
45600
  var FileChangeSchema2 = z90.object({
@@ -45399,12 +45603,12 @@ var FileChangeSchema2 = z90.object({
45399
45603
  content: z90.string()
45400
45604
  });
45401
45605
  function containsUpwardTraversal(dirPath) {
45402
- const normalized = path15.normalize(dirPath);
45606
+ const normalized = path16.normalize(dirPath);
45403
45607
  return normalized.includes("..");
45404
45608
  }
45405
45609
  function containsPathTraversal(filePath) {
45406
- const normalized = path15.normalize(filePath);
45407
- return path15.isAbsolute(normalized) || normalized.startsWith("..");
45610
+ const normalized = path16.normalize(filePath);
45611
+ return path16.isAbsolute(normalized) || normalized.startsWith("..");
45408
45612
  }
45409
45613
  async function changeFile(params2) {
45410
45614
  const { parameters, cwd, fs: fs13 } = params2;
@@ -45467,10 +45671,10 @@ async function applyChanges(params2) {
45467
45671
  for (const change of changes) {
45468
45672
  const { path: filePath, content, type } = change;
45469
45673
  try {
45470
- const fullPath = path15.join(projectRoot, filePath);
45674
+ const fullPath = path16.join(projectRoot, filePath);
45471
45675
  const exists = await fileExists({ filePath: fullPath, fs: fs13 });
45472
45676
  if (!exists) {
45473
- const dirPath = path15.dirname(fullPath);
45677
+ const dirPath = path16.dirname(fullPath);
45474
45678
  await fs13.mkdir(dirPath, { recursive: true });
45475
45679
  }
45476
45680
  if (type === "file") {
@@ -45500,7 +45704,7 @@ async function applyChanges(params2) {
45500
45704
  // src/tools/code-search.ts
45501
45705
  import { spawn as spawn2 } from "child_process";
45502
45706
  import * as fs13 from "fs";
45503
- import * as path16 from "path";
45707
+ import * as path17 from "path";
45504
45708
 
45505
45709
  // ../common/src/util/format-code-search.ts
45506
45710
  function formatCodeSearchOutput(stdout) {
@@ -45560,7 +45764,7 @@ function formatCodeSearchOutput(stdout) {
45560
45764
 
45561
45765
  // src/native/ripgrep.ts
45562
45766
  import { existsSync as existsSync7 } from "fs";
45563
- import { join as join6, dirname as dirname7 } from "path";
45767
+ import { join as join7, dirname as dirname8 } from "path";
45564
45768
  import { fileURLToPath } from "url";
45565
45769
  function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
45566
45770
  if (env2.LEVELCODE_RG_PATH) {
@@ -45587,24 +45791,24 @@ function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
45587
45791
  const metaUrl = importMetaUrl || import.meta.url;
45588
45792
  if (metaUrl) {
45589
45793
  const currentFile = fileURLToPath(metaUrl);
45590
- const currentDir = dirname7(currentFile);
45591
- const devPath = join6(currentDir, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
45794
+ const currentDir = dirname8(currentFile);
45795
+ const devPath = join7(currentDir, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
45592
45796
  if (existsSync7(devPath)) {
45593
45797
  vendorPath = devPath;
45594
45798
  }
45595
- const distPath = join6(currentDir, "vendor", "ripgrep", platformDir, binaryName);
45799
+ const distPath = join7(currentDir, "vendor", "ripgrep", platformDir, binaryName);
45596
45800
  if (existsSync7(distPath)) {
45597
45801
  vendorPath = distPath;
45598
45802
  }
45599
45803
  }
45600
45804
  if (!vendorPath) {
45601
- const dirname8 = new Function(`try { return __dirname; } catch (e) { return undefined; }`)();
45602
- if (typeof dirname8 !== "undefined") {
45603
- const cjsPath = join6(dirname8, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
45805
+ const dirname9 = new Function(`try { return __dirname; } catch (e) { return undefined; }`)();
45806
+ if (typeof dirname9 !== "undefined") {
45807
+ const cjsPath = join7(dirname9, "..", "..", "vendor", "ripgrep", platformDir, binaryName);
45604
45808
  if (existsSync7(cjsPath)) {
45605
45809
  vendorPath = cjsPath;
45606
45810
  }
45607
- const cjsPath2 = join6(dirname8, "vendor", "ripgrep", platformDir, binaryName);
45811
+ const cjsPath2 = join7(dirname9, "vendor", "ripgrep", platformDir, binaryName);
45608
45812
  if (existsSync7(cjsPath2)) {
45609
45813
  vendorPath = cjsPath2;
45610
45814
  }
@@ -45613,7 +45817,7 @@ function getBundledRgPath(importMetaUrl, env2 = getSdkEnv()) {
45613
45817
  if (vendorPath && existsSync7(vendorPath)) {
45614
45818
  return vendorPath;
45615
45819
  }
45616
- const distVendorPath = join6(process.cwd(), "node_modules", "@levelcode", "sdk", "dist", "vendor", "ripgrep", platformDir, binaryName);
45820
+ const distVendorPath = join7(process.cwd(), "node_modules", "@levelcode", "sdk", "dist", "vendor", "ripgrep", platformDir, binaryName);
45617
45821
  if (existsSync7(distVendorPath)) {
45618
45822
  return distVendorPath;
45619
45823
  }
@@ -45642,9 +45846,9 @@ function codeSearch({
45642
45846
  }) {
45643
45847
  return new Promise((resolve4) => {
45644
45848
  let isResolved = false;
45645
- const projectRoot = path16.resolve(projectPath);
45646
- const searchCwd = cwd ? path16.resolve(projectRoot, cwd) : projectRoot;
45647
- if (!searchCwd.startsWith(projectRoot + path16.sep) && searchCwd !== projectRoot) {
45849
+ const projectRoot = path17.resolve(projectPath);
45850
+ const searchCwd = cwd ? path17.resolve(projectRoot, cwd) : projectRoot;
45851
+ if (!searchCwd.startsWith(projectRoot + path17.sep) && searchCwd !== projectRoot) {
45648
45852
  return resolve4([
45649
45853
  {
45650
45854
  type: "json",
@@ -45657,7 +45861,7 @@ function codeSearch({
45657
45861
  const flagsArray = (flags || "").split(" ").filter(Boolean).map((token) => token.replace(/^['"]|['"]$/g, ""));
45658
45862
  const existingHiddenDirs = INCLUDED_HIDDEN_DIRS.filter((dir) => {
45659
45863
  try {
45660
- return fs13.statSync(path16.join(searchCwd, dir)).isDirectory();
45864
+ return fs13.statSync(path17.join(searchCwd, dir)).isDirectory();
45661
45865
  } catch {
45662
45866
  return false;
45663
45867
  }
@@ -45939,11 +46143,11 @@ async function glob(params2) {
45939
46143
  }
45940
46144
 
45941
46145
  // src/tools/list-directory.ts
45942
- import * as path17 from "path";
46146
+ import * as path18 from "path";
45943
46147
  async function listDirectory(params2) {
45944
46148
  const { directoryPath, projectPath, fs: fs14 } = params2;
45945
46149
  try {
45946
- const resolvedPath = path17.resolve(projectPath, directoryPath);
46150
+ const resolvedPath = path18.resolve(projectPath, directoryPath);
45947
46151
  if (!resolvedPath.startsWith(projectPath)) {
45948
46152
  return [
45949
46153
  {
@@ -45991,7 +46195,7 @@ async function listDirectory(params2) {
45991
46195
 
45992
46196
  // src/tools/read-files.ts
45993
46197
  init_old_constants();
45994
- import path18, { isAbsolute as isAbsolute3 } from "path";
46198
+ import path19, { isAbsolute as isAbsolute3 } from "path";
45995
46199
  async function getFiles(params2) {
45996
46200
  const { filePaths, cwd, fs: fs14, fileFilter } = params2;
45997
46201
  const hasCustomFilter = fileFilter !== undefined;
@@ -46001,8 +46205,8 @@ async function getFiles(params2) {
46001
46205
  if (!filePath) {
46002
46206
  continue;
46003
46207
  }
46004
- const relativePath = filePath.startsWith(cwd) ? path18.relative(cwd, filePath) : filePath;
46005
- const fullPath = path18.join(cwd, relativePath);
46208
+ const relativePath = filePath.startsWith(cwd) ? path19.relative(cwd, filePath) : filePath;
46209
+ const fullPath = path19.join(cwd, relativePath);
46006
46210
  if (isAbsolute3(relativePath) || !fullPath.startsWith(cwd)) {
46007
46211
  result[relativePath] = FILE_READ_STATUS.OUTSIDE_PROJECT;
46008
46212
  continue;
@@ -46047,8 +46251,8 @@ async function getFiles(params2) {
46047
46251
  // src/tools/run-terminal-command.ts
46048
46252
  import { spawn as spawn3 } from "child_process";
46049
46253
  import * as fs14 from "fs";
46050
- import * as os7 from "os";
46051
- import * as path19 from "path";
46254
+ import * as os8 from "os";
46255
+ import * as path20 from "path";
46052
46256
  var COMMAND_OUTPUT_LIMIT = 50000;
46053
46257
  var GIT_BASH_COMMON_PATHS = [
46054
46258
  "C:\\Program Files\\Git\\bin\\bash.exe",
@@ -46070,12 +46274,12 @@ function findWindowsBash(env2) {
46070
46274
  }
46071
46275
  }
46072
46276
  const pathEnv = env2.PATH || env2.Path || "";
46073
- const pathDirs = pathEnv.split(path19.delimiter);
46277
+ const pathDirs = pathEnv.split(path20.delimiter);
46074
46278
  const wslFallbackPaths = [];
46075
46279
  for (const dir of pathDirs) {
46076
46280
  const dirLower = dir.toLowerCase();
46077
46281
  const isWslPath = WSL_BASH_PATH_PATTERNS.some((pattern) => dirLower.includes(pattern));
46078
- const bashPath = path19.join(dir, "bash.exe");
46282
+ const bashPath = path20.join(dir, "bash.exe");
46079
46283
  if (fs14.existsSync(bashPath)) {
46080
46284
  if (isWslPath) {
46081
46285
  wslFallbackPaths.push(bashPath);
@@ -46083,7 +46287,7 @@ function findWindowsBash(env2) {
46083
46287
  return bashPath;
46084
46288
  }
46085
46289
  }
46086
- const bashPathNoExt = path19.join(dir, "bash");
46290
+ const bashPathNoExt = path20.join(dir, "bash");
46087
46291
  if (fs14.existsSync(bashPathNoExt)) {
46088
46292
  if (isWslPath) {
46089
46293
  wslFallbackPaths.push(bashPathNoExt);
@@ -46124,7 +46328,7 @@ function runTerminalCommand({
46124
46328
  throw new Error("BACKGROUND process_type not implemented");
46125
46329
  }
46126
46330
  return new Promise((resolve6, reject) => {
46127
- const isWindows = os7.platform() === "win32";
46331
+ const isWindows = os8.platform() === "win32";
46128
46332
  const processEnv2 = {
46129
46333
  ...getSystemProcessEnv(),
46130
46334
  ...env2 ?? {}
@@ -46143,7 +46347,7 @@ function runTerminalCommand({
46143
46347
  shell = "bash";
46144
46348
  shellArgs = ["-c"];
46145
46349
  }
46146
- const resolvedCwd = path19.resolve(cwd);
46350
+ const resolvedCwd = path20.resolve(cwd);
46147
46351
  const childProcess = spawn3(shell, [...shellArgs, command], {
46148
46352
  cwd: resolvedCwd,
46149
46353
  env: processEnv2,
@@ -46617,7 +46821,7 @@ async function handleToolCall({
46617
46821
  const resolvedCwd = requireCwd(cwd, "run_terminal_command");
46618
46822
  result = await runTerminalCommand({
46619
46823
  ...input,
46620
- cwd: path20.resolve(resolvedCwd, input.cwd ?? "."),
46824
+ cwd: path21.resolve(resolvedCwd, input.cwd ?? "."),
46621
46825
  env: env2
46622
46826
  });
46623
46827
  } else if (toolName39 === "code_search") {
@@ -47119,8 +47323,8 @@ var ToolHelpers = {
47119
47323
  // src/agents/load-mcp-config.ts
47120
47324
  import fs15 from "fs";
47121
47325
  import fsPromises from "fs/promises";
47122
- import os8 from "os";
47123
- import path21 from "path";
47326
+ import os9 from "os";
47327
+ import path22 from "path";
47124
47328
  import { z as z91 } from "zod/v4";
47125
47329
  var mcpFileSchema = z91.object({
47126
47330
  mcpServers: z91.record(z91.string(), mcpConfigSchema).default(() => ({}))
@@ -47154,9 +47358,9 @@ function resolveMcpConfigEnv(config) {
47154
47358
  }
47155
47359
  var MCP_CONFIG_FILE_NAME = "mcp.json";
47156
47360
  var getDefaultMcpConfigDirs = () => {
47157
- const cwdAgents = path21.join(process.cwd(), ".agents");
47158
- const parentAgents = path21.join(process.cwd(), "..", ".agents");
47159
- const homeAgents = path21.join(os8.homedir(), ".agents");
47361
+ const cwdAgents = path22.join(process.cwd(), ".agents");
47362
+ const parentAgents = path22.join(process.cwd(), "..", ".agents");
47363
+ const homeAgents = path22.join(os9.homedir(), ".agents");
47160
47364
  return [cwdAgents, parentAgents, homeAgents];
47161
47365
  };
47162
47366
  async function loadMCPConfig(options) {
@@ -47167,7 +47371,7 @@ async function loadMCPConfig(options) {
47167
47371
  };
47168
47372
  const mcpConfigDirs = getDefaultMcpConfigDirs();
47169
47373
  for (const dir of mcpConfigDirs) {
47170
- const configPath = path21.join(dir, MCP_CONFIG_FILE_NAME);
47374
+ const configPath = path22.join(dir, MCP_CONFIG_FILE_NAME);
47171
47375
  try {
47172
47376
  try {
47173
47377
  await fsPromises.access(configPath);
@@ -47214,7 +47418,7 @@ function loadMCPConfigSync(options) {
47214
47418
  };
47215
47419
  const mcpConfigDirs = getDefaultMcpConfigDirs();
47216
47420
  for (const dir of mcpConfigDirs) {
47217
- const configPath = path21.join(dir, MCP_CONFIG_FILE_NAME);
47421
+ const configPath = path22.join(dir, MCP_CONFIG_FILE_NAME);
47218
47422
  try {
47219
47423
  if (!fs15.existsSync(configPath)) {
47220
47424
  continue;
@@ -47322,5 +47526,5 @@ export {
47322
47526
  IS_DEV
47323
47527
  };
47324
47528
 
47325
- //# debugId=34FE3B00F8D969AB64756E2164756E21
47529
+ //# debugId=714311A46A611DD564756E2164756E21
47326
47530
  //# sourceMappingURL=index.mjs.map