@useactor/core 0.1.0 → 0.2.3

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 (380) hide show
  1. package/dist/auth/google-auth.d.ts +75 -0
  2. package/dist/auth/google-auth.d.ts.map +1 -0
  3. package/dist/auth/google-auth.js +447 -0
  4. package/dist/auth/google-auth.js.map +1 -0
  5. package/dist/auth/oauth-callback-page.d.ts +4 -0
  6. package/dist/auth/oauth-callback-page.d.ts.map +1 -0
  7. package/dist/auth/oauth-callback-page.js +131 -0
  8. package/dist/auth/oauth-callback-page.js.map +1 -0
  9. package/dist/auth/openai-auth.d.ts +48 -0
  10. package/dist/auth/openai-auth.d.ts.map +1 -0
  11. package/dist/auth/openai-auth.js +350 -0
  12. package/dist/auth/openai-auth.js.map +1 -0
  13. package/dist/{artifacts.d.ts → events/artifacts.d.ts} +1 -1
  14. package/dist/events/artifacts.d.ts.map +1 -0
  15. package/dist/events/artifacts.js.map +1 -0
  16. package/dist/{events.d.ts → events/events.d.ts} +16 -2
  17. package/dist/events/events.d.ts.map +1 -0
  18. package/dist/{events.js → events/events.js} +3 -0
  19. package/dist/events/events.js.map +1 -0
  20. package/dist/{feedback.d.ts → events/feedback.d.ts} +1 -1
  21. package/dist/events/feedback.d.ts.map +1 -0
  22. package/dist/events/feedback.js.map +1 -0
  23. package/dist/{local-event-logger.d.ts → events/local-event-logger.d.ts} +1 -1
  24. package/dist/events/local-event-logger.d.ts.map +1 -0
  25. package/dist/{local-event-logger.js → events/local-event-logger.js} +11 -0
  26. package/dist/events/local-event-logger.js.map +1 -0
  27. package/dist/{local-event-schema.d.ts → events/local-event-schema.d.ts} +10 -3
  28. package/dist/events/local-event-schema.d.ts.map +1 -0
  29. package/dist/events/local-event-schema.js.map +1 -0
  30. package/dist/index.d.ts +59 -35
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +59 -35
  33. package/dist/index.js.map +1 -1
  34. package/dist/integrations/built-in-integrations.d.ts +2 -0
  35. package/dist/integrations/built-in-integrations.d.ts.map +1 -0
  36. package/dist/integrations/built-in-integrations.js +2 -0
  37. package/dist/integrations/built-in-integrations.js.map +1 -0
  38. package/dist/integrations/first-party-cli-integration.d.ts +2 -0
  39. package/dist/integrations/first-party-cli-integration.d.ts.map +1 -0
  40. package/dist/integrations/first-party-cli-integration.js +2 -0
  41. package/dist/integrations/first-party-cli-integration.js.map +1 -0
  42. package/dist/integrations/google-workspace-integration.d.ts +2 -0
  43. package/dist/integrations/google-workspace-integration.d.ts.map +1 -0
  44. package/dist/integrations/google-workspace-integration.js +2 -0
  45. package/dist/integrations/google-workspace-integration.js.map +1 -0
  46. package/dist/integrations/integrations.d.ts +2 -0
  47. package/dist/integrations/integrations.d.ts.map +1 -0
  48. package/dist/integrations/integrations.js +2 -0
  49. package/dist/integrations/integrations.js.map +1 -0
  50. package/dist/integrations/monoid-integration.d.ts +2 -0
  51. package/dist/integrations/monoid-integration.d.ts.map +1 -0
  52. package/dist/integrations/monoid-integration.js +2 -0
  53. package/dist/integrations/monoid-integration.js.map +1 -0
  54. package/dist/integrations/pilfer-integration.d.ts +2 -0
  55. package/dist/integrations/pilfer-integration.d.ts.map +1 -0
  56. package/dist/integrations/pilfer-integration.js +2 -0
  57. package/dist/integrations/pilfer-integration.js.map +1 -0
  58. package/dist/integrations/wyrdos-integration.d.ts +2 -0
  59. package/dist/integrations/wyrdos-integration.d.ts.map +1 -0
  60. package/dist/integrations/wyrdos-integration.js +2 -0
  61. package/dist/integrations/wyrdos-integration.js.map +1 -0
  62. package/dist/keybindings/shell-keybindings.d.ts +139 -0
  63. package/dist/keybindings/shell-keybindings.d.ts.map +1 -0
  64. package/dist/keybindings/shell-keybindings.js +453 -0
  65. package/dist/keybindings/shell-keybindings.js.map +1 -0
  66. package/dist/plugins/built-in-integrations.d.ts +3 -0
  67. package/dist/plugins/built-in-integrations.d.ts.map +1 -0
  68. package/dist/plugins/built-in-integrations.js +13 -0
  69. package/dist/plugins/built-in-integrations.js.map +1 -0
  70. package/dist/plugins/first-party-cli-integration.d.ts +62 -0
  71. package/dist/plugins/first-party-cli-integration.d.ts.map +1 -0
  72. package/dist/plugins/first-party-cli-integration.js +524 -0
  73. package/dist/plugins/first-party-cli-integration.js.map +1 -0
  74. package/dist/plugins/google-docs.d.ts +30 -0
  75. package/dist/plugins/google-docs.d.ts.map +1 -0
  76. package/dist/plugins/google-docs.js +487 -0
  77. package/dist/plugins/google-docs.js.map +1 -0
  78. package/dist/plugins/google-drive.d.ts +84 -0
  79. package/dist/plugins/google-drive.d.ts.map +1 -0
  80. package/dist/plugins/google-drive.js +307 -0
  81. package/dist/plugins/google-drive.js.map +1 -0
  82. package/dist/plugins/google-sheets.d.ts +122 -0
  83. package/dist/plugins/google-sheets.d.ts.map +1 -0
  84. package/dist/plugins/google-sheets.js +290 -0
  85. package/dist/plugins/google-sheets.js.map +1 -0
  86. package/dist/plugins/google-slides.d.ts +125 -0
  87. package/dist/plugins/google-slides.d.ts.map +1 -0
  88. package/dist/plugins/google-slides.js +285 -0
  89. package/dist/plugins/google-slides.js.map +1 -0
  90. package/dist/plugins/google-workspace-api.d.ts +16 -0
  91. package/dist/plugins/google-workspace-api.d.ts.map +1 -0
  92. package/dist/plugins/google-workspace-api.js +42 -0
  93. package/dist/plugins/google-workspace-api.js.map +1 -0
  94. package/dist/plugins/google-workspace-integration.d.ts +22 -0
  95. package/dist/plugins/google-workspace-integration.d.ts.map +1 -0
  96. package/dist/plugins/google-workspace-integration.js +1353 -0
  97. package/dist/plugins/google-workspace-integration.js.map +1 -0
  98. package/dist/plugins/google-workspace-oauth.d.ts +80 -0
  99. package/dist/plugins/google-workspace-oauth.d.ts.map +1 -0
  100. package/dist/plugins/google-workspace-oauth.js +187 -0
  101. package/dist/plugins/google-workspace-oauth.js.map +1 -0
  102. package/dist/plugins/monoid-integration.d.ts +11 -0
  103. package/dist/plugins/monoid-integration.d.ts.map +1 -0
  104. package/dist/plugins/monoid-integration.js +14 -0
  105. package/dist/plugins/monoid-integration.js.map +1 -0
  106. package/dist/plugins/pilfer-integration.d.ts +10 -0
  107. package/dist/plugins/pilfer-integration.d.ts.map +1 -0
  108. package/dist/plugins/pilfer-integration.js +13 -0
  109. package/dist/plugins/pilfer-integration.js.map +1 -0
  110. package/dist/plugins/plugins.d.ts +78 -0
  111. package/dist/plugins/plugins.d.ts.map +1 -0
  112. package/dist/plugins/plugins.js +81 -0
  113. package/dist/plugins/plugins.js.map +1 -0
  114. package/dist/plugins/wyrdos-integration.d.ts +11 -0
  115. package/dist/plugins/wyrdos-integration.d.ts.map +1 -0
  116. package/dist/plugins/wyrdos-integration.js +14 -0
  117. package/dist/plugins/wyrdos-integration.js.map +1 -0
  118. package/dist/{ai-sdk-provider.d.ts → providers/ai-sdk-provider.d.ts} +2 -2
  119. package/dist/providers/ai-sdk-provider.d.ts.map +1 -0
  120. package/dist/{ai-sdk-provider.js → providers/ai-sdk-provider.js} +132 -37
  121. package/dist/providers/ai-sdk-provider.js.map +1 -0
  122. package/dist/providers/api-key-providers.d.ts +25 -0
  123. package/dist/providers/api-key-providers.d.ts.map +1 -0
  124. package/dist/providers/api-key-providers.js +67 -0
  125. package/dist/providers/api-key-providers.js.map +1 -0
  126. package/dist/providers/definitions/anthropic-provider.d.ts +421 -0
  127. package/dist/providers/definitions/anthropic-provider.d.ts.map +1 -0
  128. package/dist/providers/definitions/anthropic-provider.js +204 -0
  129. package/dist/providers/definitions/anthropic-provider.js.map +1 -0
  130. package/dist/{codex-oauth-provider.d.ts → providers/definitions/codex-oauth-provider.d.ts} +2 -2
  131. package/dist/providers/definitions/codex-oauth-provider.d.ts.map +1 -0
  132. package/dist/{codex-oauth-provider.js → providers/definitions/codex-oauth-provider.js} +1 -1
  133. package/dist/providers/definitions/codex-oauth-provider.js.map +1 -0
  134. package/dist/providers/definitions/deepseek-provider.d.ts +25 -0
  135. package/dist/providers/definitions/deepseek-provider.d.ts.map +1 -0
  136. package/dist/providers/definitions/deepseek-provider.js +28 -0
  137. package/dist/providers/definitions/deepseek-provider.js.map +1 -0
  138. package/dist/providers/definitions/google-ai-oauth.d.ts +79 -0
  139. package/dist/providers/definitions/google-ai-oauth.d.ts.map +1 -0
  140. package/dist/providers/definitions/google-ai-oauth.js +177 -0
  141. package/dist/providers/definitions/google-ai-oauth.js.map +1 -0
  142. package/dist/providers/definitions/google-provider.d.ts +166 -0
  143. package/dist/providers/definitions/google-provider.d.ts.map +1 -0
  144. package/dist/providers/definitions/google-provider.js +93 -0
  145. package/dist/providers/definitions/google-provider.js.map +1 -0
  146. package/dist/providers/definitions/moonshot-provider.d.ts +28 -0
  147. package/dist/providers/definitions/moonshot-provider.d.ts.map +1 -0
  148. package/dist/providers/definitions/moonshot-provider.js +34 -0
  149. package/dist/providers/definitions/moonshot-provider.js.map +1 -0
  150. package/dist/{openai-oauth.d.ts → providers/definitions/openai-oauth.d.ts} +1 -1
  151. package/dist/providers/definitions/openai-oauth.d.ts.map +1 -0
  152. package/dist/providers/definitions/openai-oauth.js.map +1 -0
  153. package/dist/providers/definitions/openai-provider.d.ts +177 -0
  154. package/dist/providers/definitions/openai-provider.d.ts.map +1 -0
  155. package/dist/{model-catalog.js → providers/definitions/openai-provider.js} +33 -21
  156. package/dist/providers/definitions/openai-provider.js.map +1 -0
  157. package/dist/providers/definitions/perplexity-provider.d.ts +34 -0
  158. package/dist/providers/definitions/perplexity-provider.d.ts.map +1 -0
  159. package/dist/providers/definitions/perplexity-provider.js +46 -0
  160. package/dist/providers/definitions/perplexity-provider.js.map +1 -0
  161. package/dist/providers/definitions/xai-provider.d.ts +68 -0
  162. package/dist/providers/definitions/xai-provider.d.ts.map +1 -0
  163. package/dist/providers/definitions/xai-provider.js +102 -0
  164. package/dist/providers/definitions/xai-provider.js.map +1 -0
  165. package/dist/{mock-provider.d.ts → providers/mock-provider.d.ts} +1 -1
  166. package/dist/providers/mock-provider.d.ts.map +1 -0
  167. package/dist/providers/mock-provider.js.map +1 -0
  168. package/dist/{model-catalog.d.ts → providers/model-catalog.d.ts} +2 -2
  169. package/dist/providers/model-catalog.d.ts.map +1 -0
  170. package/dist/providers/model-catalog.js +31 -0
  171. package/dist/providers/model-catalog.js.map +1 -0
  172. package/dist/providers/provider-failures.d.ts +14 -0
  173. package/dist/providers/provider-failures.d.ts.map +1 -0
  174. package/dist/providers/provider-failures.js +146 -0
  175. package/dist/providers/provider-failures.js.map +1 -0
  176. package/dist/providers/provider-status.d.ts +24 -0
  177. package/dist/providers/provider-status.d.ts.map +1 -0
  178. package/dist/providers/provider-status.js +63 -0
  179. package/dist/providers/provider-status.js.map +1 -0
  180. package/dist/{providers.d.ts → providers/providers.d.ts} +1 -1
  181. package/dist/providers/providers.d.ts.map +1 -0
  182. package/dist/providers/providers.js.map +1 -0
  183. package/dist/{secrets.d.ts → providers/secrets.d.ts} +24 -0
  184. package/dist/providers/secrets.d.ts.map +1 -0
  185. package/dist/{secrets.js → providers/secrets.js} +82 -2
  186. package/dist/providers/secrets.js.map +1 -0
  187. package/dist/{app-runtime.d.ts → runtime/app-runtime.d.ts} +8 -7
  188. package/dist/runtime/app-runtime.d.ts.map +1 -0
  189. package/dist/{app-runtime.js → runtime/app-runtime.js} +58 -28
  190. package/dist/runtime/app-runtime.js.map +1 -0
  191. package/dist/runtime/in-memory-runtime.d.ts +15 -0
  192. package/dist/runtime/in-memory-runtime.d.ts.map +1 -0
  193. package/dist/{in-memory-runtime.js → runtime/in-memory-runtime.js} +135 -29
  194. package/dist/runtime/in-memory-runtime.js.map +1 -0
  195. package/dist/runtime/renderer-api.d.ts +123 -0
  196. package/dist/runtime/renderer-api.d.ts.map +1 -0
  197. package/dist/{renderer-api.js.map → runtime/renderer-api.js.map} +1 -1
  198. package/dist/{runtime-tool-execution.d.ts → runtime/runtime-tool-execution.d.ts} +8 -3
  199. package/dist/runtime/runtime-tool-execution.d.ts.map +1 -0
  200. package/dist/runtime/runtime-tool-execution.js +733 -0
  201. package/dist/runtime/runtime-tool-execution.js.map +1 -0
  202. package/dist/{runtime.d.ts → runtime/runtime.d.ts} +31 -4
  203. package/dist/runtime/runtime.d.ts.map +1 -0
  204. package/dist/{runtime.js → runtime/runtime.js} +24 -0
  205. package/dist/runtime/runtime.js.map +1 -0
  206. package/dist/{history.d.ts → sessions/history.d.ts} +3 -2
  207. package/dist/sessions/history.d.ts.map +1 -0
  208. package/dist/{history.js → sessions/history.js} +55 -1
  209. package/dist/sessions/history.js.map +1 -0
  210. package/dist/{session-actions.d.ts → sessions/session-actions.d.ts} +2 -2
  211. package/dist/sessions/session-actions.d.ts.map +1 -0
  212. package/dist/{session-actions.js → sessions/session-actions.js} +2 -2
  213. package/dist/sessions/session-actions.js.map +1 -0
  214. package/dist/{cli-defined-tools.d.ts → tools/cli-defined-tools.d.ts} +2 -2
  215. package/dist/tools/cli-defined-tools.d.ts.map +1 -0
  216. package/dist/tools/cli-defined-tools.js.map +1 -0
  217. package/dist/tools/document-tools.d.ts +92 -0
  218. package/dist/tools/document-tools.d.ts.map +1 -0
  219. package/dist/tools/document-tools.js +430 -0
  220. package/dist/tools/document-tools.js.map +1 -0
  221. package/dist/{local-tools.d.ts → tools/local-tools.d.ts} +25 -0
  222. package/dist/tools/local-tools.d.ts.map +1 -0
  223. package/dist/tools/local-tools.js +944 -0
  224. package/dist/tools/local-tools.js.map +1 -0
  225. package/dist/tools/mcp-server-config.d.ts.map +1 -0
  226. package/dist/tools/mcp-server-config.js.map +1 -0
  227. package/dist/tools/permission-grant-store.d.ts.map +1 -0
  228. package/dist/tools/permission-grant-store.js.map +1 -0
  229. package/dist/{permission-grants.d.ts → tools/permission-grants.d.ts} +1 -1
  230. package/dist/tools/permission-grants.d.ts.map +1 -0
  231. package/dist/{permission-grants.js → tools/permission-grants.js} +31 -1
  232. package/dist/tools/permission-grants.js.map +1 -0
  233. package/dist/tools/project-app-defaults-tool.d.ts +4 -0
  234. package/dist/tools/project-app-defaults-tool.d.ts.map +1 -0
  235. package/dist/tools/project-app-defaults-tool.js +135 -0
  236. package/dist/tools/project-app-defaults-tool.js.map +1 -0
  237. package/dist/{project-tool-registry.d.ts → tools/project-tool-registry.d.ts} +2 -2
  238. package/dist/tools/project-tool-registry.d.ts.map +1 -0
  239. package/dist/{project-tool-registry.js → tools/project-tool-registry.js} +47 -9
  240. package/dist/tools/project-tool-registry.js.map +1 -0
  241. package/dist/{question-requests.d.ts → tools/question-requests.d.ts} +2 -2
  242. package/dist/tools/question-requests.d.ts.map +1 -0
  243. package/dist/{question-requests.js → tools/question-requests.js} +3 -2
  244. package/dist/tools/question-requests.js.map +1 -0
  245. package/dist/tools/subagent-task-tool.d.ts +8 -0
  246. package/dist/tools/subagent-task-tool.d.ts.map +1 -0
  247. package/dist/tools/subagent-task-tool.js +38 -0
  248. package/dist/tools/subagent-task-tool.js.map +1 -0
  249. package/dist/{tool-requests.d.ts → tools/tool-requests.d.ts} +4 -3
  250. package/dist/tools/tool-requests.d.ts.map +1 -0
  251. package/dist/{tool-requests.js → tools/tool-requests.js} +15 -4
  252. package/dist/tools/tool-requests.js.map +1 -0
  253. package/dist/{tools.d.ts → tools/tools.d.ts} +7 -1
  254. package/dist/tools/tools.d.ts.map +1 -0
  255. package/dist/{tools.js → tools/tools.js} +21 -0
  256. package/dist/tools/tools.js.map +1 -0
  257. package/dist/tools/update-plan-tool.d.ts +14 -0
  258. package/dist/tools/update-plan-tool.d.ts.map +1 -0
  259. package/dist/tools/update-plan-tool.js +83 -0
  260. package/dist/tools/update-plan-tool.js.map +1 -0
  261. package/dist/{personas.d.ts → workspace/personas.d.ts} +42 -1
  262. package/dist/workspace/personas.d.ts.map +1 -0
  263. package/dist/workspace/personas.js +457 -0
  264. package/dist/workspace/personas.js.map +1 -0
  265. package/dist/{projects.d.ts → workspace/projects.d.ts} +35 -5
  266. package/dist/workspace/projects.d.ts.map +1 -0
  267. package/dist/{projects.js → workspace/projects.js} +111 -3
  268. package/dist/workspace/projects.js.map +1 -0
  269. package/dist/{prompt-context.d.ts → workspace/prompt-context.d.ts} +5 -2
  270. package/dist/workspace/prompt-context.d.ts.map +1 -0
  271. package/dist/workspace/prompt-context.js +406 -0
  272. package/dist/workspace/prompt-context.js.map +1 -0
  273. package/dist/workspace/proposed-plan.d.ts.map +1 -0
  274. package/dist/workspace/proposed-plan.js.map +1 -0
  275. package/dist/workspace/repository-instructions.d.ts +20 -0
  276. package/dist/workspace/repository-instructions.d.ts.map +1 -0
  277. package/dist/workspace/repository-instructions.js +111 -0
  278. package/dist/workspace/repository-instructions.js.map +1 -0
  279. package/dist/{skills.d.ts → workspace/skills.d.ts} +23 -2
  280. package/dist/workspace/skills.d.ts.map +1 -0
  281. package/dist/{skills.js → workspace/skills.js} +129 -5
  282. package/dist/workspace/skills.js.map +1 -0
  283. package/package.json +15 -2
  284. package/dist/ai-sdk-provider.d.ts.map +0 -1
  285. package/dist/ai-sdk-provider.js.map +0 -1
  286. package/dist/app-runtime.d.ts.map +0 -1
  287. package/dist/app-runtime.js.map +0 -1
  288. package/dist/artifacts.d.ts.map +0 -1
  289. package/dist/artifacts.js.map +0 -1
  290. package/dist/cli-defined-tools.d.ts.map +0 -1
  291. package/dist/cli-defined-tools.js.map +0 -1
  292. package/dist/codex-oauth-provider.d.ts.map +0 -1
  293. package/dist/codex-oauth-provider.js.map +0 -1
  294. package/dist/events.d.ts.map +0 -1
  295. package/dist/events.js.map +0 -1
  296. package/dist/feedback.d.ts.map +0 -1
  297. package/dist/feedback.js.map +0 -1
  298. package/dist/history.d.ts.map +0 -1
  299. package/dist/history.js.map +0 -1
  300. package/dist/in-memory-runtime.d.ts +0 -12
  301. package/dist/in-memory-runtime.d.ts.map +0 -1
  302. package/dist/in-memory-runtime.js.map +0 -1
  303. package/dist/integrations.d.ts +0 -37
  304. package/dist/integrations.d.ts.map +0 -1
  305. package/dist/integrations.js +0 -48
  306. package/dist/integrations.js.map +0 -1
  307. package/dist/local-event-logger.d.ts.map +0 -1
  308. package/dist/local-event-logger.js.map +0 -1
  309. package/dist/local-event-schema.d.ts.map +0 -1
  310. package/dist/local-event-schema.js.map +0 -1
  311. package/dist/local-tools.d.ts.map +0 -1
  312. package/dist/local-tools.js +0 -418
  313. package/dist/local-tools.js.map +0 -1
  314. package/dist/mcp-server-config.d.ts.map +0 -1
  315. package/dist/mcp-server-config.js.map +0 -1
  316. package/dist/mock-provider.d.ts.map +0 -1
  317. package/dist/mock-provider.js.map +0 -1
  318. package/dist/model-catalog.d.ts.map +0 -1
  319. package/dist/model-catalog.js.map +0 -1
  320. package/dist/monoid-integration.d.ts +0 -33
  321. package/dist/monoid-integration.d.ts.map +0 -1
  322. package/dist/monoid-integration.js +0 -184
  323. package/dist/monoid-integration.js.map +0 -1
  324. package/dist/openai-oauth.d.ts.map +0 -1
  325. package/dist/openai-oauth.js.map +0 -1
  326. package/dist/permission-grant-store.d.ts.map +0 -1
  327. package/dist/permission-grant-store.js.map +0 -1
  328. package/dist/permission-grants.d.ts.map +0 -1
  329. package/dist/permission-grants.js.map +0 -1
  330. package/dist/personas.d.ts.map +0 -1
  331. package/dist/personas.js +0 -137
  332. package/dist/personas.js.map +0 -1
  333. package/dist/project-tool-registry.d.ts.map +0 -1
  334. package/dist/project-tool-registry.js.map +0 -1
  335. package/dist/projects.d.ts.map +0 -1
  336. package/dist/projects.js.map +0 -1
  337. package/dist/prompt-context.d.ts.map +0 -1
  338. package/dist/prompt-context.js +0 -170
  339. package/dist/prompt-context.js.map +0 -1
  340. package/dist/proposed-plan.d.ts.map +0 -1
  341. package/dist/proposed-plan.js.map +0 -1
  342. package/dist/providers.d.ts.map +0 -1
  343. package/dist/providers.js.map +0 -1
  344. package/dist/question-requests.d.ts.map +0 -1
  345. package/dist/question-requests.js.map +0 -1
  346. package/dist/renderer-api.d.ts +0 -52
  347. package/dist/renderer-api.d.ts.map +0 -1
  348. package/dist/runtime-tool-execution.d.ts.map +0 -1
  349. package/dist/runtime-tool-execution.js +0 -245
  350. package/dist/runtime-tool-execution.js.map +0 -1
  351. package/dist/runtime.d.ts.map +0 -1
  352. package/dist/runtime.js.map +0 -1
  353. package/dist/secrets.d.ts.map +0 -1
  354. package/dist/secrets.js.map +0 -1
  355. package/dist/session-actions.d.ts.map +0 -1
  356. package/dist/session-actions.js.map +0 -1
  357. package/dist/skills.d.ts.map +0 -1
  358. package/dist/skills.js.map +0 -1
  359. package/dist/tool-requests.d.ts.map +0 -1
  360. package/dist/tool-requests.js.map +0 -1
  361. package/dist/tools.d.ts.map +0 -1
  362. package/dist/tools.js.map +0 -1
  363. package/dist/wyrdos-integration.d.ts +0 -32
  364. package/dist/wyrdos-integration.d.ts.map +0 -1
  365. package/dist/wyrdos-integration.js +0 -183
  366. package/dist/wyrdos-integration.js.map +0 -1
  367. /package/dist/{artifacts.js → events/artifacts.js} +0 -0
  368. /package/dist/{feedback.js → events/feedback.js} +0 -0
  369. /package/dist/{local-event-schema.js → events/local-event-schema.js} +0 -0
  370. /package/dist/{openai-oauth.js → providers/definitions/openai-oauth.js} +0 -0
  371. /package/dist/{mock-provider.js → providers/mock-provider.js} +0 -0
  372. /package/dist/{providers.js → providers/providers.js} +0 -0
  373. /package/dist/{renderer-api.js → runtime/renderer-api.js} +0 -0
  374. /package/dist/{cli-defined-tools.js → tools/cli-defined-tools.js} +0 -0
  375. /package/dist/{mcp-server-config.d.ts → tools/mcp-server-config.d.ts} +0 -0
  376. /package/dist/{mcp-server-config.js → tools/mcp-server-config.js} +0 -0
  377. /package/dist/{permission-grant-store.d.ts → tools/permission-grant-store.d.ts} +0 -0
  378. /package/dist/{permission-grant-store.js → tools/permission-grant-store.js} +0 -0
  379. /package/dist/{proposed-plan.d.ts → workspace/proposed-plan.d.ts} +0 -0
  380. /package/dist/{proposed-plan.js → workspace/proposed-plan.js} +0 -0
@@ -0,0 +1,944 @@
1
+ import { execFile } from "node:child_process";
2
+ import { constants } from "node:fs";
3
+ import { access, lstat, mkdir, mkdtemp, readdir, readFile, realpath, rm, stat, writeFile, } from "node:fs/promises";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+ import { promisify } from "node:util";
7
+ import { rgPath } from "@vscode/ripgrep";
8
+ const listFilesOutputSchema = {
9
+ type: "object",
10
+ additionalProperties: false,
11
+ required: ["files", "truncated"],
12
+ properties: {
13
+ files: {
14
+ type: "array",
15
+ items: {
16
+ type: "object",
17
+ additionalProperties: false,
18
+ required: ["name", "relativePath", "kind", "size", "mtimeMs"],
19
+ properties: {
20
+ name: { type: "string" },
21
+ relativePath: { type: "string" },
22
+ kind: { type: "string", enum: ["directory", "file"] },
23
+ size: { type: "number" },
24
+ mtimeMs: { type: "number" },
25
+ },
26
+ },
27
+ },
28
+ truncated: { type: "boolean" },
29
+ },
30
+ };
31
+ const readFileOutputSchema = {
32
+ type: "object",
33
+ additionalProperties: false,
34
+ required: ["content", "relativePath", "offset", "lineCount", "truncated"],
35
+ properties: {
36
+ content: { type: "string" },
37
+ relativePath: { type: "string" },
38
+ offset: { type: "number" },
39
+ lineCount: { type: "number" },
40
+ truncated: { type: "boolean" },
41
+ nextOffset: { type: "number" },
42
+ },
43
+ };
44
+ const searchOutputSchema = {
45
+ type: "object",
46
+ additionalProperties: false,
47
+ required: ["matches", "truncated"],
48
+ properties: {
49
+ matches: {
50
+ type: "array",
51
+ items: { type: "string" },
52
+ },
53
+ truncated: { type: "boolean" },
54
+ },
55
+ };
56
+ const globOutputSchema = {
57
+ type: "object",
58
+ additionalProperties: false,
59
+ required: ["files", "truncated"],
60
+ properties: {
61
+ files: {
62
+ type: "array",
63
+ items: { type: "string" },
64
+ },
65
+ truncated: { type: "boolean" },
66
+ },
67
+ };
68
+ const writeFileOutputSchema = {
69
+ type: "object",
70
+ additionalProperties: false,
71
+ required: ["relativePath"],
72
+ properties: {
73
+ relativePath: { type: "string" },
74
+ },
75
+ };
76
+ const editFileOutputSchema = {
77
+ type: "object",
78
+ additionalProperties: false,
79
+ required: ["relativePath", "changed", "diff", "additions", "deletions", "replacements"],
80
+ properties: {
81
+ relativePath: { type: "string" },
82
+ changed: { type: "boolean" },
83
+ diff: { type: "string" },
84
+ additions: { type: "number" },
85
+ deletions: { type: "number" },
86
+ replacements: { type: "number" },
87
+ },
88
+ };
89
+ const bashOutputSchema = {
90
+ type: "object",
91
+ additionalProperties: false,
92
+ required: ["stdout", "stderr", "exitCode", "risk", "sandboxProfile", "workdir"],
93
+ properties: {
94
+ stdout: { type: "string" },
95
+ stderr: { type: "string" },
96
+ exitCode: { type: "number" },
97
+ risk: { type: "string", enum: ["normal", "destructive"] },
98
+ sandboxProfile: {
99
+ type: "string",
100
+ enum: ["read-only", "workspace-write", "network", "external-write", "destructive"],
101
+ },
102
+ workdir: { type: "string" },
103
+ },
104
+ };
105
+ export class PathGuardError extends Error {
106
+ code = "path_outside_root";
107
+ }
108
+ export async function resolveSafePath(root, requestedPath = ".") {
109
+ const rootPath = path.resolve(root.rootPath);
110
+ const absolutePath = path.resolve(rootPath, requestedPath);
111
+ if (!isWithin(rootPath, absolutePath))
112
+ throw new PathGuardError("Path escapes approved root.");
113
+ const rootRealPath = await realpath(rootPath);
114
+ const existingPath = await nearestExistingPath(absolutePath);
115
+ const existingRealPath = await realpath(existingPath);
116
+ if (!isWithin(rootRealPath, existingRealPath))
117
+ throw new PathGuardError("Path escapes approved root.");
118
+ return {
119
+ rootPath,
120
+ absolutePath,
121
+ relativePath: path.relative(rootPath, absolutePath) || ".",
122
+ };
123
+ }
124
+ export async function resolveReadablePath(root, requestedPath = ".") {
125
+ const rootPath = path.resolve(root.rootPath);
126
+ const absolutePath = path.resolve(rootPath, requestedPath);
127
+ const existingPath = await nearestExistingPath(absolutePath);
128
+ await realpath(existingPath);
129
+ return {
130
+ rootPath,
131
+ absolutePath,
132
+ relativePath: displayPath(rootPath, absolutePath),
133
+ };
134
+ }
135
+ export async function listFiles(input) {
136
+ const safePath = await resolveReadablePath(input, input.path);
137
+ const entries = await readdir(safePath.absolutePath, { withFileTypes: true });
138
+ const limit = input.limit ?? 200;
139
+ const files = await Promise.all(entries.slice(0, limit).map(async (entry) => {
140
+ const absolutePath = path.join(safePath.absolutePath, entry.name);
141
+ const info = await stat(absolutePath);
142
+ return {
143
+ name: entry.name,
144
+ relativePath: displayPath(safePath.rootPath, absolutePath),
145
+ kind: entry.isDirectory() ? "directory" : "file",
146
+ size: info.size,
147
+ mtimeMs: info.mtimeMs,
148
+ };
149
+ }));
150
+ return { files, truncated: entries.length > limit };
151
+ }
152
+ export function createListFilesTool(options = {}) {
153
+ return {
154
+ id: options.id ?? "list_files",
155
+ name: "List files",
156
+ description: "List local files and folders. Reads are allowed outside the project root when the OS allows them.",
157
+ inputSchema: {
158
+ type: "object",
159
+ additionalProperties: false,
160
+ properties: {
161
+ path: {
162
+ type: "string",
163
+ description: "Directory to list. Omit to list the project root.",
164
+ },
165
+ limit: {
166
+ type: "number",
167
+ description: "Maximum entries to return. Omit to use the default limit of 200.",
168
+ },
169
+ },
170
+ },
171
+ outputSchema: listFilesOutputSchema,
172
+ permissionPolicy: "never",
173
+ async executor(input, context) {
174
+ const rootPath = resolveToolRootPath(options, context);
175
+ const requestedPath = optionalString(input, "path");
176
+ const limit = optionalNumber(input, "limit");
177
+ const result = await listFiles({
178
+ rootPath,
179
+ ...(requestedPath !== undefined ? { path: requestedPath } : {}),
180
+ ...(limit !== undefined ? { limit } : {}),
181
+ });
182
+ return jsonToolResult(result);
183
+ },
184
+ };
185
+ }
186
+ export async function readTextFile(input) {
187
+ const maxBytes = input.maxBytes ?? 256_000;
188
+ const raw = await readRawTextFile({ ...input, maxBytes });
189
+ const offset = input.offset ?? 1;
190
+ const limit = input.limit ?? 2_000;
191
+ if (offset < 1)
192
+ throw new Error("offset must be at least 1.");
193
+ if (limit < 0)
194
+ throw new Error("limit must be at least 0.");
195
+ const lines = splitTextLines(raw.content);
196
+ const startIndex = offset - 1;
197
+ const selectedLines = lines.slice(startIndex, startIndex + limit);
198
+ const numberedContent = selectedLines
199
+ .map((line, index) => `${offset + index}: ${line}`)
200
+ .join("\n");
201
+ if (Buffer.byteLength(numberedContent, "utf8") > maxBytes) {
202
+ throw new Error("File is too large to read.");
203
+ }
204
+ const nextOffset = offset + selectedLines.length;
205
+ const truncated = nextOffset <= lines.length;
206
+ return {
207
+ content: numberedContent,
208
+ relativePath: raw.relativePath,
209
+ offset,
210
+ lineCount: selectedLines.length,
211
+ truncated,
212
+ ...(truncated ? { nextOffset } : {}),
213
+ };
214
+ }
215
+ async function readRawTextFile(input) {
216
+ const safePath = await resolveReadablePath(input, input.path);
217
+ if (input.maxBytes !== undefined) {
218
+ const info = await stat(safePath.absolutePath);
219
+ if (info.size > input.maxBytes)
220
+ throw new Error("File is too large to read.");
221
+ }
222
+ const buffer = await readFile(safePath.absolutePath);
223
+ if (buffer.includes(0))
224
+ throw new Error("Binary files are not supported.");
225
+ return {
226
+ content: buffer.toString("utf8"),
227
+ relativePath: safePath.relativePath,
228
+ };
229
+ }
230
+ export function createReadFileTool(options = {}) {
231
+ return {
232
+ id: options.id ?? "read_file",
233
+ name: "Read file",
234
+ description: "Read a local text file. Reads are allowed outside the project root when the OS allows them.",
235
+ inputSchema: {
236
+ type: "object",
237
+ additionalProperties: false,
238
+ required: ["path"],
239
+ properties: {
240
+ path: {
241
+ type: "string",
242
+ description: "Text file path to read. Relative paths resolve from the project root.",
243
+ },
244
+ offset: {
245
+ type: "number",
246
+ description: "1-indexed line number to start reading from. Omit to start at line 1.",
247
+ },
248
+ limit: {
249
+ type: "number",
250
+ description: "Maximum lines to return. Omit to use the default limit of 2000.",
251
+ },
252
+ maxBytes: {
253
+ type: "number",
254
+ description: "Maximum file bytes to read. Omit to use the default cap of 256000.",
255
+ },
256
+ },
257
+ },
258
+ outputSchema: readFileOutputSchema,
259
+ permissionPolicy: "never",
260
+ async executor(input, context) {
261
+ const rootPath = resolveToolRootPath(options, context);
262
+ const filePath = requiredString(input, "path");
263
+ const offset = optionalNumber(input, "offset");
264
+ const limit = optionalNumber(input, "limit");
265
+ const maxBytes = optionalNumber(input, "maxBytes");
266
+ const result = await readTextFile({
267
+ rootPath,
268
+ path: filePath,
269
+ ...(offset !== undefined ? { offset } : {}),
270
+ ...(limit !== undefined ? { limit } : {}),
271
+ ...(maxBytes !== undefined ? { maxBytes } : {}),
272
+ });
273
+ return jsonToolResult(result);
274
+ },
275
+ };
276
+ }
277
+ export async function writeTextFile(input) {
278
+ const safePath = await resolveSafePath(input, input.path);
279
+ await mkdir(path.dirname(safePath.absolutePath), { recursive: true });
280
+ await writeFile(safePath.absolutePath, input.content, "utf8");
281
+ return { relativePath: safePath.relativePath };
282
+ }
283
+ export function createWriteFileTool(options = {}) {
284
+ return {
285
+ id: options.id ?? "write_file",
286
+ name: "Write file",
287
+ description: "Create or overwrite a text file inside the approved project folder.",
288
+ inputSchema: {
289
+ type: "object",
290
+ additionalProperties: false,
291
+ required: ["path", "content"],
292
+ properties: {
293
+ path: {
294
+ type: "string",
295
+ description: "Destination file path inside the approved project folder.",
296
+ },
297
+ content: {
298
+ type: "string",
299
+ description: "Full UTF-8 text content to write to the destination file.",
300
+ },
301
+ },
302
+ },
303
+ outputSchema: writeFileOutputSchema,
304
+ permissionPolicy: "on-request",
305
+ async executor(input, context) {
306
+ const rootPath = resolveToolRootPath(options, context);
307
+ const filePath = requiredString(input, "path");
308
+ const content = requiredString(input, "content");
309
+ const result = await writeTextFile({ rootPath, path: filePath, content });
310
+ return jsonToolResult(result, {
311
+ artifactKind: "local_file",
312
+ artifactPath: result.relativePath,
313
+ bytes: Buffer.byteLength(content, "utf8"),
314
+ });
315
+ },
316
+ };
317
+ }
318
+ export async function editTextFile(input) {
319
+ await resolveSafePath(input, input.path);
320
+ const current = await readRawTextFile(input);
321
+ const matches = countOccurrences(current.content, input.search);
322
+ if (matches === 0)
323
+ throw new Error("Search text was not found.");
324
+ if (matches > 1 && !input.replaceAll) {
325
+ throw new Error("Search text matched multiple times. Use replaceAll to replace all matches.");
326
+ }
327
+ const next = input.replaceAll
328
+ ? current.content.split(input.search).join(input.replace)
329
+ : current.content.replace(input.search, input.replace);
330
+ await writeTextFile({ ...input, content: next });
331
+ const diff = createUnifiedDiff({
332
+ path: current.relativePath,
333
+ before: current.content,
334
+ after: next,
335
+ });
336
+ return {
337
+ relativePath: current.relativePath,
338
+ changed: current.content !== next,
339
+ diff: diff.patch,
340
+ additions: diff.additions,
341
+ deletions: diff.deletions,
342
+ replacements: input.replaceAll ? matches : 1,
343
+ };
344
+ }
345
+ export function createEditFileTool(options = {}) {
346
+ return {
347
+ id: options.id ?? "edit_file",
348
+ name: "Edit file",
349
+ description: "Replace text in a file inside the approved project folder.",
350
+ inputSchema: {
351
+ type: "object",
352
+ additionalProperties: false,
353
+ required: ["path", "search", "replace"],
354
+ properties: {
355
+ path: {
356
+ type: "string",
357
+ description: "File path inside the approved project folder to edit.",
358
+ },
359
+ search: {
360
+ type: "string",
361
+ description: "Exact text to replace. It must appear in the file.",
362
+ },
363
+ replace: {
364
+ type: "string",
365
+ description: "Replacement text to insert in place of the search text.",
366
+ },
367
+ replaceAll: {
368
+ type: "boolean",
369
+ description: "Set true to replace every occurrence when search matches multiple times.",
370
+ },
371
+ },
372
+ },
373
+ outputSchema: editFileOutputSchema,
374
+ permissionPolicy: "on-request",
375
+ async executor(input, context) {
376
+ const rootPath = resolveToolRootPath(options, context);
377
+ const replaceAll = optionalBoolean(input, "replaceAll");
378
+ const result = await editTextFile({
379
+ rootPath,
380
+ path: requiredString(input, "path"),
381
+ search: requiredString(input, "search"),
382
+ replace: requiredString(input, "replace"),
383
+ ...(replaceAll !== undefined ? { replaceAll } : {}),
384
+ });
385
+ return jsonToolResult(result, {
386
+ artifactKind: "local_file",
387
+ artifactPath: result.relativePath,
388
+ changed: result.changed,
389
+ file: result.relativePath,
390
+ diff: result.diff,
391
+ additions: result.additions,
392
+ deletions: result.deletions,
393
+ replacements: result.replacements,
394
+ });
395
+ },
396
+ };
397
+ }
398
+ export async function applyUnifiedPatch(input) {
399
+ const safeRoot = await resolveSafePath(input, ".");
400
+ const changedPaths = parseUnifiedPatchPaths(input.patch);
401
+ if (changedPaths.length === 0) {
402
+ throw new Error("Patch does not contain any file changes.");
403
+ }
404
+ await Promise.all(changedPaths.map((changedPath) => resolveSafePath(input, changedPath)));
405
+ const tempDir = await mkdtemp(path.join(os.tmpdir(), "actor-patch-"));
406
+ const patchPath = path.join(tempDir, "change.patch");
407
+ const exec = input.exec ?? execFileAsync;
408
+ try {
409
+ await writeFile(patchPath, input.patch, "utf8");
410
+ await exec("git", ["apply", "--whitespace=nowarn", patchPath], {
411
+ cwd: safeRoot.rootPath,
412
+ timeout: 10_000,
413
+ maxBuffer: 256_000,
414
+ });
415
+ }
416
+ finally {
417
+ await rm(tempDir, { recursive: true, force: true });
418
+ }
419
+ return { changedPaths };
420
+ }
421
+ export function createApplyPatchTool(options = {}) {
422
+ return {
423
+ id: options.id ?? "apply_patch",
424
+ name: "Apply patch",
425
+ description: "Apply a unified diff patch inside the approved project folder. Use for structured multi-line file edits.",
426
+ inputSchema: {
427
+ type: "object",
428
+ additionalProperties: false,
429
+ required: ["patch"],
430
+ properties: {
431
+ patch: {
432
+ type: "string",
433
+ description: "Unified diff patch to apply inside the approved project folder.",
434
+ },
435
+ },
436
+ },
437
+ permissionPolicy: "on-request",
438
+ async executor(input, context) {
439
+ const rootPath = resolveToolRootPath(options, context);
440
+ const result = await applyUnifiedPatch({
441
+ rootPath,
442
+ patch: requiredString(input, "patch"),
443
+ });
444
+ return jsonToolResult(result, {
445
+ artifactKind: "local_patch",
446
+ changedPaths: result.changedPaths,
447
+ });
448
+ },
449
+ };
450
+ }
451
+ export async function ripgrepSearch(input) {
452
+ const safePath = await resolveReadablePath(input, input.path);
453
+ const exec = input.exec ?? execFileAsync;
454
+ try {
455
+ const result = await exec(rgPath, ["--line-number", "--color", "never", input.query, safePath.relativePath], {
456
+ cwd: safePath.rootPath,
457
+ timeout: 5_000,
458
+ maxBuffer: 256_000,
459
+ });
460
+ const lines = result.stdout.split("\n").filter(Boolean);
461
+ const limit = input.limit ?? 200;
462
+ return { matches: lines.slice(0, limit), truncated: lines.length > limit };
463
+ }
464
+ catch (error) {
465
+ if (typeof error === "object" &&
466
+ error &&
467
+ "code" in error &&
468
+ error.code === 1) {
469
+ return { matches: [], truncated: false };
470
+ }
471
+ throw error;
472
+ }
473
+ }
474
+ export function createRipgrepTool(options = {}) {
475
+ return {
476
+ id: options.id ?? "ripgrep",
477
+ name: "Search files",
478
+ description: "Search local files with ripgrep. Reads are allowed outside the project root when the OS allows them.",
479
+ inputSchema: {
480
+ type: "object",
481
+ additionalProperties: false,
482
+ required: ["query"],
483
+ properties: {
484
+ query: {
485
+ type: "string",
486
+ description: "Ripgrep search pattern or literal text to find.",
487
+ },
488
+ path: {
489
+ type: "string",
490
+ description: "Directory or file to search. Omit to search the project root.",
491
+ },
492
+ limit: {
493
+ type: "number",
494
+ description: "Maximum matches to return. Omit to use the default limit of 200.",
495
+ },
496
+ },
497
+ },
498
+ outputSchema: searchOutputSchema,
499
+ permissionPolicy: "never",
500
+ async executor(input, context) {
501
+ const rootPath = resolveToolRootPath(options, context);
502
+ const requestedPath = optionalString(input, "path");
503
+ const limit = optionalNumber(input, "limit");
504
+ const result = await ripgrepSearch({
505
+ rootPath,
506
+ query: requiredString(input, "query"),
507
+ ...(requestedPath !== undefined ? { path: requestedPath } : {}),
508
+ ...(limit !== undefined ? { limit } : {}),
509
+ });
510
+ return jsonToolResult(result);
511
+ },
512
+ };
513
+ }
514
+ export async function globFiles(input) {
515
+ const safePath = await resolveReadablePath(input, input.path);
516
+ const exec = input.exec ?? execFileAsync;
517
+ try {
518
+ const result = await exec(rgPath, ["--files", "-g", input.pattern, safePath.relativePath], {
519
+ cwd: safePath.rootPath,
520
+ timeout: 5_000,
521
+ maxBuffer: 256_000,
522
+ });
523
+ const files = result.stdout.split("\n").filter(Boolean);
524
+ const limit = input.limit ?? 200;
525
+ return { files: files.slice(0, limit), truncated: files.length > limit };
526
+ }
527
+ catch (error) {
528
+ if (typeof error === "object" &&
529
+ error &&
530
+ "code" in error &&
531
+ error.code === 1) {
532
+ return { files: [], truncated: false };
533
+ }
534
+ throw error;
535
+ }
536
+ }
537
+ export function createGlobTool(options = {}) {
538
+ return {
539
+ id: options.id ?? "glob",
540
+ name: "Find files",
541
+ description: "Find local files by glob pattern. Reads are allowed outside the project root when the OS allows them.",
542
+ inputSchema: {
543
+ type: "object",
544
+ additionalProperties: false,
545
+ required: ["pattern"],
546
+ properties: {
547
+ pattern: {
548
+ type: "string",
549
+ description: "Glob pattern for file paths, for example **/*.ts.",
550
+ },
551
+ path: {
552
+ type: "string",
553
+ description: "Directory to search within. Omit to search the project root.",
554
+ },
555
+ limit: {
556
+ type: "number",
557
+ description: "Maximum file paths to return. Omit to use the default limit of 200.",
558
+ },
559
+ },
560
+ },
561
+ outputSchema: globOutputSchema,
562
+ permissionPolicy: "never",
563
+ async executor(input, context) {
564
+ const rootPath = resolveToolRootPath(options, context);
565
+ const requestedPath = optionalString(input, "path");
566
+ const limit = optionalNumber(input, "limit");
567
+ const result = await globFiles({
568
+ rootPath,
569
+ pattern: requiredString(input, "pattern"),
570
+ ...(requestedPath !== undefined ? { path: requestedPath } : {}),
571
+ ...(limit !== undefined ? { limit } : {}),
572
+ });
573
+ return jsonToolResult(result);
574
+ },
575
+ };
576
+ }
577
+ export async function runBashCommand(input) {
578
+ const safePath = await resolveSafePath(input, input.workdir);
579
+ const exec = input.exec ?? execFileAsync;
580
+ let result;
581
+ try {
582
+ const success = await exec("bash", ["-lc", input.command], {
583
+ cwd: safePath.absolutePath,
584
+ timeout: input.timeoutMs ?? 10_000,
585
+ maxBuffer: 256_000,
586
+ });
587
+ result = { stdout: success.stdout, stderr: success.stderr, exitCode: 0 };
588
+ }
589
+ catch (error) {
590
+ if (!isExecError(error))
591
+ throw error;
592
+ result = {
593
+ stdout: error.stdout ?? "",
594
+ stderr: error.stderr ?? "",
595
+ exitCode: typeof error.code === "number" ? error.code : 1,
596
+ };
597
+ }
598
+ return {
599
+ stdout: result.stdout,
600
+ stderr: result.stderr,
601
+ exitCode: result.exitCode,
602
+ risk: classifyDestructiveCommand(input.command),
603
+ sandboxProfile: classifyShellSandboxProfile(input.command),
604
+ workdir: safePath.relativePath,
605
+ };
606
+ }
607
+ export function createBashTool(options = {}) {
608
+ return {
609
+ id: "bash",
610
+ name: "Run shell command",
611
+ description: "Run a shell command inside the approved project folder.",
612
+ inputSchema: {
613
+ type: "object",
614
+ additionalProperties: false,
615
+ required: ["command"],
616
+ properties: {
617
+ command: {
618
+ type: "string",
619
+ description: "Shell command to run from the approved project folder.",
620
+ },
621
+ workdir: {
622
+ type: "string",
623
+ description: "Working directory inside the approved project folder. Omit to use the project root.",
624
+ },
625
+ description: {
626
+ type: "string",
627
+ description: "Human-readable 5 to 10 word summary for command previews.",
628
+ },
629
+ timeoutMs: {
630
+ type: "number",
631
+ description: "Maximum runtime in milliseconds. Omit to use the default timeout of 10000.",
632
+ },
633
+ },
634
+ },
635
+ outputSchema: bashOutputSchema,
636
+ permissionPolicy: "on-request",
637
+ async executor(input, context) {
638
+ const rootPath = resolveToolRootPath(options, context);
639
+ const workdir = optionalString(input, "workdir");
640
+ const description = optionalString(input, "description");
641
+ const timeoutMs = optionalNumber(input, "timeoutMs");
642
+ const result = await runBashCommand({
643
+ rootPath,
644
+ command: requiredString(input, "command"),
645
+ ...(workdir !== undefined ? { workdir } : {}),
646
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
647
+ });
648
+ return jsonToolResult(result, {
649
+ exitCode: result.exitCode,
650
+ risk: result.risk,
651
+ sandboxProfile: result.sandboxProfile,
652
+ workdir: result.workdir,
653
+ ...(description !== undefined ? { description } : {}),
654
+ });
655
+ },
656
+ };
657
+ }
658
+ export function classifyDestructiveCommand(command) {
659
+ return /\brm\s+-rf\b|\bgit\s+reset\s+--hard\b|\bchmod\s+-R\b|>\s*\/dev\/sd|:\s*>\s*\S+/.test(command)
660
+ ? "destructive"
661
+ : "normal";
662
+ }
663
+ export function classifyShellSandboxProfile(command) {
664
+ if (classifyDestructiveCommand(command) === "destructive") {
665
+ return "destructive";
666
+ }
667
+ if (/\b(?:sudo|chown|mount|umount|launchctl)\b|(?:^|\s)(?:>|>>)\s*\/|\b(?:cp|mv|mkdir|touch|tee)\b[^\n;&|]*\s\/(?:usr|etc|var|opt|System|Library)\b/u.test(command)) {
668
+ return "external-write";
669
+ }
670
+ if (/\b(?:curl|wget|ssh|scp|rsync)\b|\bgit\s+(?:clone|fetch|pull|push)\b|\b(?:npm|pnpm|yarn|bun)\s+(?:install|add|remove|update|upgrade)\b|\b(?:pip|pipx|uv)\s+install\b|\bbrew\s+(?:install|update|upgrade)\b/u.test(command)) {
671
+ return "network";
672
+ }
673
+ const prefix = splitShellWords(firstShellCommandSegment(command));
674
+ if (isReadOnlyCommandPrefix(prefix)) {
675
+ return "read-only";
676
+ }
677
+ return "workspace-write";
678
+ }
679
+ function isReadOnlyCommandPrefix(prefix) {
680
+ const [command, subcommand] = prefix;
681
+ if (!command)
682
+ return false;
683
+ if ([
684
+ "cat",
685
+ "date",
686
+ "find",
687
+ "grep",
688
+ "head",
689
+ "ls",
690
+ "pwd",
691
+ "rg",
692
+ "sed",
693
+ "tail",
694
+ "wc",
695
+ ].includes(command)) {
696
+ return true;
697
+ }
698
+ return command === "git" && typeof subcommand === "string" &&
699
+ ["diff", "log", "show", "status"].includes(subcommand);
700
+ }
701
+ function firstShellCommandSegment(command) {
702
+ let quote;
703
+ let escaped = false;
704
+ for (let index = 0; index < command.length; index += 1) {
705
+ const char = command[index];
706
+ if (escaped) {
707
+ escaped = false;
708
+ continue;
709
+ }
710
+ if (char === "\\") {
711
+ escaped = true;
712
+ continue;
713
+ }
714
+ if (quote) {
715
+ if (char === quote)
716
+ quote = undefined;
717
+ continue;
718
+ }
719
+ if (char === "'" || char === '"') {
720
+ quote = char;
721
+ continue;
722
+ }
723
+ if (char === "&" || char === "|" || char === ";") {
724
+ return command.slice(0, index).trim();
725
+ }
726
+ }
727
+ return command.trim();
728
+ }
729
+ function splitShellWords(command) {
730
+ const words = [];
731
+ let current = "";
732
+ let quote;
733
+ let escaped = false;
734
+ for (const char of command) {
735
+ if (escaped) {
736
+ current += char;
737
+ escaped = false;
738
+ continue;
739
+ }
740
+ if (char === "\\") {
741
+ escaped = true;
742
+ continue;
743
+ }
744
+ if (quote) {
745
+ if (char === quote) {
746
+ quote = undefined;
747
+ }
748
+ else {
749
+ current += char;
750
+ }
751
+ continue;
752
+ }
753
+ if (char === "'" || char === '"') {
754
+ quote = char;
755
+ continue;
756
+ }
757
+ if (/\s/u.test(char)) {
758
+ if (current) {
759
+ words.push(current);
760
+ current = "";
761
+ }
762
+ continue;
763
+ }
764
+ current += char;
765
+ }
766
+ if (current)
767
+ words.push(current);
768
+ return words;
769
+ }
770
+ const execFileAsync = promisify(execFile);
771
+ function isExecError(error) {
772
+ return Boolean(error &&
773
+ typeof error === "object" &&
774
+ ("stdout" in error || "stderr" in error || "code" in error));
775
+ }
776
+ function resolveToolRootPath(options, context) {
777
+ const rootPath = options.rootPath ?? context.project?.rootPath;
778
+ if (!rootPath)
779
+ throw new Error("A project rootPath or tool rootPath is required.");
780
+ return rootPath;
781
+ }
782
+ function jsonToolResult(value, metadata) {
783
+ return {
784
+ content: JSON.stringify(value),
785
+ ...(metadata ? { metadata } : {}),
786
+ };
787
+ }
788
+ function createUnifiedDiff(input) {
789
+ const beforeLines = splitDiffLines(input.before);
790
+ const afterLines = splitDiffLines(input.after);
791
+ const changes = diffLineChanges(beforeLines, afterLines);
792
+ const additions = changes.filter((change) => change.kind === "add").length;
793
+ const deletions = changes.filter((change) => change.kind === "remove").length;
794
+ if (additions === 0 && deletions === 0) {
795
+ return { patch: "", additions, deletions };
796
+ }
797
+ const oldCount = beforeLines.length;
798
+ const newCount = afterLines.length;
799
+ const lines = [
800
+ `diff --git a/${input.path} b/${input.path}`,
801
+ `--- a/${input.path}`,
802
+ `+++ b/${input.path}`,
803
+ `@@ -1,${oldCount} +1,${newCount} @@`,
804
+ ...changes.map((change) => `${diffMarker(change.kind)}${change.text}`),
805
+ "",
806
+ ];
807
+ return { patch: lines.join("\n"), additions, deletions };
808
+ }
809
+ function splitDiffLines(value) {
810
+ const normalized = value.replace(/\r\n/gu, "\n");
811
+ const lines = normalized.split("\n");
812
+ if (normalized.endsWith("\n")) {
813
+ lines.pop();
814
+ }
815
+ return lines;
816
+ }
817
+ function splitTextLines(value) {
818
+ if (value.length === 0)
819
+ return [];
820
+ return splitDiffLines(value);
821
+ }
822
+ function countOccurrences(value, search) {
823
+ if (search.length === 0)
824
+ return 0;
825
+ return value.split(search).length - 1;
826
+ }
827
+ function diffLineChanges(before, after) {
828
+ const lengths = Array.from({ length: before.length + 1 }, () => Array.from({ length: after.length + 1 }, () => 0));
829
+ for (let left = before.length - 1; left >= 0; left -= 1) {
830
+ for (let right = after.length - 1; right >= 0; right -= 1) {
831
+ lengths[left][right] =
832
+ before[left] === after[right]
833
+ ? lengths[left + 1][right + 1] + 1
834
+ : Math.max(lengths[left + 1][right], lengths[left][right + 1]);
835
+ }
836
+ }
837
+ const changes = [];
838
+ let left = 0;
839
+ let right = 0;
840
+ while (left < before.length && right < after.length) {
841
+ if (before[left] === after[right]) {
842
+ changes.push({ kind: "context", text: before[left] });
843
+ left += 1;
844
+ right += 1;
845
+ continue;
846
+ }
847
+ if (lengths[left + 1][right] >= lengths[left][right + 1]) {
848
+ changes.push({ kind: "remove", text: before[left] });
849
+ left += 1;
850
+ continue;
851
+ }
852
+ changes.push({ kind: "add", text: after[right] });
853
+ right += 1;
854
+ }
855
+ while (left < before.length) {
856
+ changes.push({ kind: "remove", text: before[left] });
857
+ left += 1;
858
+ }
859
+ while (right < after.length) {
860
+ changes.push({ kind: "add", text: after[right] });
861
+ right += 1;
862
+ }
863
+ return changes;
864
+ }
865
+ function diffMarker(kind) {
866
+ if (kind === "add")
867
+ return "+";
868
+ if (kind === "remove")
869
+ return "-";
870
+ return " ";
871
+ }
872
+ function inputRecord(input) {
873
+ if (!input || typeof input !== "object" || Array.isArray(input))
874
+ return {};
875
+ return input;
876
+ }
877
+ function optionalString(input, key) {
878
+ const value = inputRecord(input)[key];
879
+ return typeof value === "string" ? value : undefined;
880
+ }
881
+ function requiredString(input, key) {
882
+ const value = optionalString(input, key);
883
+ if (!value)
884
+ throw new Error(`${key} is required.`);
885
+ return value;
886
+ }
887
+ function optionalNumber(input, key) {
888
+ const value = inputRecord(input)[key];
889
+ return typeof value === "number" && Number.isFinite(value)
890
+ ? value
891
+ : undefined;
892
+ }
893
+ function optionalBoolean(input, key) {
894
+ const value = inputRecord(input)[key];
895
+ return typeof value === "boolean" ? value : undefined;
896
+ }
897
+ function parseUnifiedPatchPaths(patch) {
898
+ const paths = new Set();
899
+ for (const line of patch.split(/\r?\n/u)) {
900
+ if (!line.startsWith("--- ") && !line.startsWith("+++ "))
901
+ continue;
902
+ const filePath = normalizePatchPath(line.slice(4).trim().split(/\s+/u)[0]);
903
+ if (filePath)
904
+ paths.add(filePath);
905
+ }
906
+ return [...paths];
907
+ }
908
+ function normalizePatchPath(filePath) {
909
+ if (!filePath || filePath === "/dev/null")
910
+ return undefined;
911
+ const withoutPrefix = filePath.replace(/^[ab]\//u, "");
912
+ if (path.isAbsolute(withoutPrefix) || withoutPrefix.split(/[\\/]+/u).includes("..")) {
913
+ throw new PathGuardError("Patch path escapes approved root.");
914
+ }
915
+ return withoutPrefix;
916
+ }
917
+ async function nearestExistingPath(absolutePath) {
918
+ let current = absolutePath;
919
+ while (true) {
920
+ try {
921
+ await access(current, constants.F_OK);
922
+ const info = await lstat(current);
923
+ return info.isSymbolicLink() ? realpath(current) : current;
924
+ }
925
+ catch {
926
+ const parent = path.dirname(current);
927
+ if (parent === current)
928
+ throw new PathGuardError("No existing path found.");
929
+ current = parent;
930
+ }
931
+ }
932
+ }
933
+ function isWithin(rootPath, candidatePath) {
934
+ const relative = path.relative(rootPath, candidatePath);
935
+ return (relative === "" ||
936
+ (!relative.startsWith("..") && !path.isAbsolute(relative)));
937
+ }
938
+ function displayPath(rootPath, candidatePath) {
939
+ if (!isWithin(rootPath, candidatePath)) {
940
+ return candidatePath;
941
+ }
942
+ return path.relative(rootPath, candidatePath) || ".";
943
+ }
944
+ //# sourceMappingURL=local-tools.js.map