@maxmo74/pi-coding-agent 1.4.0-max.3 → 1.5.0-max.0

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 (273) hide show
  1. package/CHANGELOG.md +86 -2
  2. package/dist/bundle/chunks/{anthropic-messages-KRX3GRGV.js → anthropic-messages-BWGCKOF4.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-YWTDZRIJ.js → azure-openai-responses-FSC6BAW3.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  5. package/dist/bundle/chunks/chunk-36QC74V4.js +2 -0
  6. package/dist/bundle/chunks/{chunk-ZN2R65UF.js → chunk-3TGLJEWK.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-LAMEVJ4W.js → chunk-4EYXVSA5.js} +9 -12
  8. package/dist/bundle/chunks/{chunk-AFNTYPTW.js → chunk-62VOPMLK.js} +6 -6
  9. package/dist/bundle/chunks/{chunk-CPKYLLPC.js → chunk-7O7QKK6A.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-V4LJ5IY6.js → chunk-B46VJEHW.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-N6ZHTIEL.js → chunk-BZZAKZGU.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-M3LEVT3X.js → chunk-C2WU32PX.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-RFUP4YGP.js → chunk-CHWNPHIS.js} +2 -2
  14. package/dist/bundle/chunks/{chunk-QTM7S6TH.js → chunk-EOO47QGR.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-XPUTTZLN.js → chunk-GN3QYODH.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-4UNN5OGR.js → chunk-NL4X6LBY.js} +1 -1
  17. package/dist/bundle/chunks/chunk-NZY7EIPA.js +4 -0
  18. package/dist/bundle/chunks/{chunk-HQBQWHLD.js → chunk-R2EGYMOO.js} +3 -3
  19. package/dist/bundle/chunks/chunk-TM7G7NOA.js +1239 -0
  20. package/dist/bundle/chunks/{chunk-BPHHHEET.js → chunk-V6KH5QG4.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-HQJBN2MC.js → chunk-VOLAXWGI.js} +1 -1
  22. package/dist/bundle/chunks/{chunk-HODJBMOY.js → chunk-YZKQS34S.js} +1 -1
  23. package/dist/bundle/chunks/{cli-QUXYJ5RR.js → cli-MCOUW5WS.js} +11 -9
  24. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-QPZQRBK5.js → cloudflare-workers-ai-system-one-WLAFJSP6.js} +1 -1
  25. package/dist/bundle/chunks/{easter-egg-3d-RD5RBYI2.js → easter-egg-3d-WMBNSJ4M.js} +1 -1
  26. package/dist/bundle/chunks/{execute-XTJDRV75.js → execute-4CEBORGZ.js} +1 -1
  27. package/dist/bundle/chunks/{google-generative-ai-J3K3YPN3.js → google-generative-ai-INGKNW72.js} +1 -1
  28. package/dist/bundle/chunks/{google-vertex-VFXOTBVP.js → google-vertex-IBTX6MBF.js} +1 -1
  29. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  30. package/dist/bundle/chunks/{llama-cpp-classify-4KFSGAMH.js → llama-cpp-classify-V5U3QKXI.js} +1 -1
  31. package/dist/bundle/chunks/{mistral-conversations-C2QQGYVC.js → mistral-conversations-S4OWXIXQ.js} +1 -1
  32. package/dist/bundle/chunks/{openai-codex-responses-H2UJSVV3.js → openai-codex-responses-QAWLOQSN.js} +1 -1
  33. package/dist/bundle/chunks/{openai-completions-QPD4B26I.js → openai-completions-EJNYB6IX.js} +1 -1
  34. package/dist/bundle/chunks/{openai-decisions-O6PHBSCB.js → openai-decisions-IXI34BYG.js} +1 -1
  35. package/dist/bundle/chunks/{openai-responses-JOYMWKMB.js → openai-responses-MD3562FB.js} +1 -1
  36. package/dist/bundle/chunks/{openrouter-images-4WG6OOLH.js → openrouter-images-PISKSFMS.js} +1 -1
  37. package/dist/bundle/chunks/{pi-messages-EZXKVRR6.js → pi-messages-NORUKF4E.js} +1 -1
  38. package/dist/bundle/chunks/{runtime-YKR6KZPS.js → runtime-FQB7RU7U.js} +1 -1
  39. package/dist/bundle/chunks/{typesafe-system-one-X3JT6ECA.js → typesafe-system-one-CHVC2UUI.js} +1 -1
  40. package/dist/bundle/chunks/virtual-modules-FBPNWDXK.js +2 -0
  41. package/dist/bundle/cli-runtime.js +1 -1
  42. package/dist/bundle/index.js +1 -1
  43. package/dist/bundle/rpc-entry.js +1 -1
  44. package/dist/cli/args.d.ts.map +1 -1
  45. package/dist/cli/args.js +6 -5
  46. package/dist/cli/args.js.map +1 -1
  47. package/dist/config.d.ts +10 -0
  48. package/dist/config.d.ts.map +1 -1
  49. package/dist/config.js +24 -5
  50. package/dist/config.js.map +1 -1
  51. package/dist/core/agent-session-runtime.js +3 -3
  52. package/dist/core/agent-session-runtime.js.map +1 -1
  53. package/dist/core/bug-report.d.ts +4 -4
  54. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  55. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  56. package/dist/core/compaction/branch-summarization.js +12 -3
  57. package/dist/core/compaction/branch-summarization.js.map +1 -1
  58. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  59. package/dist/core/export-html/tool-renderer.js +3 -0
  60. package/dist/core/export-html/tool-renderer.js.map +1 -1
  61. package/dist/core/extensions/index.d.ts +1 -1
  62. package/dist/core/extensions/index.d.ts.map +1 -1
  63. package/dist/core/extensions/index.js.map +1 -1
  64. package/dist/core/extensions/loader.d.ts.map +1 -1
  65. package/dist/core/extensions/loader.js +7 -6
  66. package/dist/core/extensions/loader.js.map +1 -1
  67. package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
  68. package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
  69. package/dist/core/extensions/pi-ai-extension-view.js +22 -0
  70. package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
  71. package/dist/core/extensions/types.d.ts +15 -4
  72. package/dist/core/extensions/types.d.ts.map +1 -1
  73. package/dist/core/extensions/types.js.map +1 -1
  74. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  75. package/dist/core/extensions/virtual-modules.js +8 -7
  76. package/dist/core/extensions/virtual-modules.js.map +1 -1
  77. package/dist/core/mcp-servers.d.ts +11 -4
  78. package/dist/core/mcp-servers.d.ts.map +1 -1
  79. package/dist/core/mcp-servers.js +15 -5
  80. package/dist/core/mcp-servers.js.map +1 -1
  81. package/dist/core/model-config.d.ts +1678 -2029
  82. package/dist/core/model-config.d.ts.map +1 -1
  83. package/dist/core/model-config.js +2 -3
  84. package/dist/core/model-config.js.map +1 -1
  85. package/dist/core/package-manager.d.ts +5 -0
  86. package/dist/core/package-manager.d.ts.map +1 -1
  87. package/dist/core/package-manager.js +88 -25
  88. package/dist/core/package-manager.js.map +1 -1
  89. package/dist/core/pi-ai-schemas.d.ts +163 -0
  90. package/dist/core/pi-ai-schemas.d.ts.map +1 -0
  91. package/dist/core/pi-ai-schemas.js +21 -0
  92. package/dist/core/pi-ai-schemas.js.map +1 -0
  93. package/dist/core/project-trust.js +1 -1
  94. package/dist/core/project-trust.js.map +1 -1
  95. package/dist/core/resource-loader.d.ts +1 -0
  96. package/dist/core/resource-loader.d.ts.map +1 -1
  97. package/dist/core/resource-loader.js +19 -20
  98. package/dist/core/resource-loader.js.map +1 -1
  99. package/dist/core/session-manager.d.ts +7 -0
  100. package/dist/core/session-manager.d.ts.map +1 -1
  101. package/dist/core/session-manager.js +12 -10
  102. package/dist/core/session-manager.js.map +1 -1
  103. package/dist/core/settings-schema.d.ts +3 -2
  104. package/dist/core/settings-schema.d.ts.map +1 -1
  105. package/dist/core/settings-schema.js +5 -1
  106. package/dist/core/settings-schema.js.map +1 -1
  107. package/dist/core/skills.d.ts.map +1 -1
  108. package/dist/core/skills.js +6 -14
  109. package/dist/core/skills.js.map +1 -1
  110. package/dist/core/slash-commands.js +2 -2
  111. package/dist/core/slash-commands.js.map +1 -1
  112. package/dist/core/source-info.d.ts +2 -0
  113. package/dist/core/source-info.d.ts.map +1 -1
  114. package/dist/core/source-info.js +5 -0
  115. package/dist/core/source-info.js.map +1 -1
  116. package/dist/core/system-prompt.d.ts.map +1 -1
  117. package/dist/core/system-prompt.js +5 -6
  118. package/dist/core/system-prompt.js.map +1 -1
  119. package/dist/core/tools/bash.d.ts +2 -2
  120. package/dist/core/tools/bash.d.ts.map +1 -1
  121. package/dist/core/tools/bash.js.map +1 -1
  122. package/dist/core/tools/edit.d.ts +3 -3
  123. package/dist/core/tools/edit.d.ts.map +1 -1
  124. package/dist/core/tools/edit.js +2 -4
  125. package/dist/core/tools/edit.js.map +1 -1
  126. package/dist/core/tools/find.d.ts +2 -2
  127. package/dist/core/tools/find.d.ts.map +1 -1
  128. package/dist/core/tools/find.js.map +1 -1
  129. package/dist/core/tools/grep.d.ts +2 -2
  130. package/dist/core/tools/grep.d.ts.map +1 -1
  131. package/dist/core/tools/grep.js.map +1 -1
  132. package/dist/core/tools/ls.d.ts +2 -2
  133. package/dist/core/tools/ls.d.ts.map +1 -1
  134. package/dist/core/tools/ls.js.map +1 -1
  135. package/dist/core/tools/read.d.ts +2 -2
  136. package/dist/core/tools/read.d.ts.map +1 -1
  137. package/dist/core/tools/read.js.map +1 -1
  138. package/dist/core/tools/render-utils.d.ts.map +1 -1
  139. package/dist/core/tools/render-utils.js +2 -7
  140. package/dist/core/tools/render-utils.js.map +1 -1
  141. package/dist/core/tools/renderers/write.d.ts.map +1 -1
  142. package/dist/core/tools/renderers/write.js +19 -19
  143. package/dist/core/tools/renderers/write.js.map +1 -1
  144. package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
  145. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  146. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  147. package/dist/core/tools/write.d.ts +2 -2
  148. package/dist/core/tools/write.d.ts.map +1 -1
  149. package/dist/core/tools/write.js.map +1 -1
  150. package/dist/core/trust-manager.d.ts.map +1 -1
  151. package/dist/core/trust-manager.js +14 -8
  152. package/dist/core/trust-manager.js.map +1 -1
  153. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  154. package/dist/extensions/codemode/renderer.js +6 -2
  155. package/dist/extensions/codemode/renderer.js.map +1 -1
  156. package/dist/extensions/codemode/tool.d.ts +2 -1
  157. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  158. package/dist/extensions/codemode/tool.js.map +1 -1
  159. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  160. package/dist/extensions/mcp/cli.js +34 -8
  161. package/dist/extensions/mcp/cli.js.map +1 -1
  162. package/dist/extensions/mcp/oauth.d.ts +1 -1
  163. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  164. package/dist/extensions/mcp/oauth.js +36 -13
  165. package/dist/extensions/mcp/oauth.js.map +1 -1
  166. package/dist/extensions/tool-search/tool.d.ts +19 -8
  167. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  168. package/dist/extensions/tool-search/tool.js +87 -42
  169. package/dist/extensions/tool-search/tool.js.map +1 -1
  170. package/dist/index.d.ts +1 -1
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js.map +1 -1
  173. package/dist/main.d.ts.map +1 -1
  174. package/dist/main.js +1 -3
  175. package/dist/main.js.map +1 -1
  176. package/dist/modes/interactive/components/assistant-message.d.ts +1 -0
  177. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  178. package/dist/modes/interactive/components/assistant-message.js +20 -6
  179. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  180. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  181. package/dist/modes/interactive/components/config-selector.js +4 -17
  182. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  183. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  184. package/dist/modes/interactive/components/custom-entry.js +2 -1
  185. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  186. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  187. package/dist/modes/interactive/components/custom-message.js +2 -1
  188. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  189. package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
  190. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  191. package/dist/modes/interactive/components/extension-editor.js +4 -0
  192. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  193. package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
  194. package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
  195. package/dist/modes/interactive/components/markdown-transform.js +2 -1
  196. package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
  197. package/dist/modes/interactive/components/session-selector.d.ts +1 -1
  198. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  199. package/dist/modes/interactive/components/session-selector.js +14 -25
  200. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  201. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  202. package/dist/modes/interactive/components/tool-execution.js +3 -1
  203. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  204. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  205. package/dist/modes/interactive/components/tree-selector.js +2 -6
  206. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  207. package/dist/modes/interactive/components/user-message.js +1 -1
  208. package/dist/modes/interactive/components/user-message.js.map +1 -1
  209. package/dist/modes/interactive/external-editor.d.ts +1 -0
  210. package/dist/modes/interactive/external-editor.d.ts.map +1 -1
  211. package/dist/modes/interactive/external-editor.js +16 -4
  212. package/dist/modes/interactive/external-editor.js.map +1 -1
  213. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  214. package/dist/modes/interactive/interactive-mode.js +6 -9
  215. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  216. package/dist/modes/interactive/theme/theme.d.ts +10 -0
  217. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  218. package/dist/modes/interactive/theme/theme.js +31 -23
  219. package/dist/modes/interactive/theme/theme.js.map +1 -1
  220. package/dist/package-manager-cli.d.ts.map +1 -1
  221. package/dist/package-manager-cli.js +48 -2
  222. package/dist/package-manager-cli.js.map +1 -1
  223. package/dist/utils/clipboard-command.d.ts.map +1 -1
  224. package/dist/utils/clipboard-command.js +4 -0
  225. package/dist/utils/clipboard-command.js.map +1 -1
  226. package/dist/utils/git.d.ts +1 -1
  227. package/dist/utils/git.d.ts.map +1 -1
  228. package/dist/utils/git.js.map +1 -1
  229. package/dist/utils/image-resize-core.d.ts.map +1 -1
  230. package/dist/utils/image-resize-core.js +5 -3
  231. package/dist/utils/image-resize-core.js.map +1 -1
  232. package/dist/utils/open-browser.d.ts.map +1 -1
  233. package/dist/utils/open-browser.js +4 -1
  234. package/dist/utils/open-browser.js.map +1 -1
  235. package/dist/utils/paths.d.ts +17 -0
  236. package/dist/utils/paths.d.ts.map +1 -1
  237. package/dist/utils/paths.js +42 -1
  238. package/dist/utils/paths.js.map +1 -1
  239. package/dist/utils/syntax-highlight.d.ts +5 -0
  240. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  241. package/dist/utils/syntax-highlight.js +7 -0
  242. package/dist/utils/syntax-highlight.js.map +1 -1
  243. package/docs/cli.md +18 -8
  244. package/docs/environment-variables.md +1 -0
  245. package/docs/extensions.md +24 -10
  246. package/docs/mcp.md +6 -4
  247. package/docs/packages.md +2 -0
  248. package/docs/sessions.md +11 -3
  249. package/docs/settings.md +1 -0
  250. package/docs/slash-commands.md +2 -2
  251. package/docs/terminal-setup.md +3 -1
  252. package/docs/tmux.md +6 -0
  253. package/docs/windows.md +27 -0
  254. package/examples/extensions/README.md +2 -1
  255. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  256. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  257. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  258. package/examples/extensions/debug-provider.ts +2 -2
  259. package/examples/extensions/gondolin/package-lock.json +2 -2
  260. package/examples/extensions/gondolin/package.json +1 -1
  261. package/examples/extensions/with-deps/package-lock.json +2 -2
  262. package/examples/extensions/with-deps/package.json +1 -1
  263. package/examples/tsconfig.json +180 -0
  264. package/package.json +10 -11
  265. package/schemas/models.schema.json +36 -36
  266. package/schemas/settings.schema.json +8 -0
  267. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +0 -2
  268. package/dist/bundle/chunks/chunk-KFM2CJ7Q.js +0 -4
  269. package/dist/bundle/chunks/chunk-UH6VPJL7.js +0 -1237
  270. package/dist/bundle/chunks/virtual-modules-TW6KBQM5.js +0 -2
  271. package/examples/extensions/sandbox/index.ts +0 -321
  272. package/examples/extensions/sandbox/package-lock.json +0 -92
  273. package/examples/extensions/sandbox/package.json +0 -19
@@ -1,2 +0,0 @@
1
- import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{dist_exports as dist_exports3}from"./chunk-N6ZHTIEL.js";import{all_exports,compat_exports,compile_exports,dist_exports as dist_exports2,value_exports}from"./chunk-UH6VPJL7.js";import{build_exports}from"./chunk-AFNTYPTW.js";import"./chunk-ZN2R65UF.js";import{dist_exports}from"./chunk-LAMEVJ4W.js";import"./chunk-KFM2CJ7Q.js";import"./chunk-HQBQWHLD.js";import"./chunk-HODJBMOY.js";import"./chunk-6QGV3IWD.js";import"./chunk-BSS6T6KQ.js";import"./chunk-USJZMAIR.js";import"./chunk-5AGIVGSV.js";import"./chunk-UKVNB6C4.js";import"./chunk-TMTOQ7H7.js";import"./chunk-7DDKXS2Q.js";import"./chunk-FFMDRXC4.js";import{models_exports}from"./chunk-4UNN5OGR.js";import"./chunk-LPXNMA2W.js";import"./chunk-BPHHHEET.js";import"./chunk-JXWJOIH4.js";var oauth_exports={};var VIRTUAL_MODULES={typebox:build_exports,"typebox/compile":compile_exports,"typebox/value":value_exports,"@sinclair/typebox":build_exports,"@sinclair/typebox/compile":compile_exports,"@sinclair/typebox/value":value_exports,"@earendil-works/pi-agent-core":dist_exports2,"@earendil-works/pi-tui":dist_exports,"@earendil-works/pi-ai":compat_exports,"@earendil-works/pi-ai/compat":compat_exports,"@earendil-works/pi-ai/models":models_exports,"@earendil-works/pi-ai/oauth":oauth_exports,"@earendil-works/pi-ai/providers/all":all_exports,"@earendil-works/pi-coding-agent":dist_exports3,"@mariozechner/pi-agent-core":dist_exports2,"@mariozechner/pi-tui":dist_exports,"@mariozechner/pi-ai":compat_exports,"@mariozechner/pi-ai/compat":compat_exports,"@mariozechner/pi-ai/models":models_exports,"@mariozechner/pi-ai/oauth":oauth_exports,"@mariozechner/pi-ai/providers/all":all_exports,"@mariozechner/pi-coding-agent":dist_exports3};export{VIRTUAL_MODULES};
@@ -1,321 +0,0 @@
1
- /**
2
- * Sandbox Extension - OS-level sandboxing for bash commands
3
- *
4
- * Uses @anthropic-ai/sandbox-runtime to enforce filesystem and network
5
- * restrictions on bash commands at the OS level (sandbox-exec on macOS,
6
- * bubblewrap on Linux).
7
- *
8
- * Note: this example intentionally overrides the built-in `bash` tool to show
9
- * how built-in tools can be replaced. Alternatively, you could sandbox `bash`
10
- * via `tool_call` input mutation without replacing the tool.
11
- *
12
- * Config files (merged, project takes precedence):
13
- * - ~/.pi/agent/extensions/sandbox.json (global)
14
- * - <cwd>/.pi/sandbox.json (project-local)
15
- *
16
- * Example .pi/sandbox.json:
17
- * ```json
18
- * {
19
- * "enabled": true,
20
- * "network": {
21
- * "allowedDomains": ["github.com", "*.github.com"],
22
- * "deniedDomains": []
23
- * },
24
- * "filesystem": {
25
- * "denyRead": ["~/.ssh", "~/.aws"],
26
- * "allowWrite": [".", "/tmp"],
27
- * "denyWrite": [".env"]
28
- * }
29
- * }
30
- * ```
31
- *
32
- * Usage:
33
- * - `pi -e ./sandbox` - sandbox enabled with default/config settings
34
- * - `pi -e ./sandbox --no-sandbox` - disable sandboxing
35
- * - `/sandbox` - show current sandbox configuration
36
- *
37
- * Setup:
38
- * 1. Copy sandbox/ directory to ~/.pi/agent/extensions/
39
- * 2. Run `npm install` in ~/.pi/agent/extensions/sandbox/
40
- *
41
- * Linux also requires: bubblewrap, socat, ripgrep
42
- */
43
-
44
- import { spawn } from "node:child_process";
45
- import { existsSync, readFileSync } from "node:fs";
46
- import { join } from "node:path";
47
- import { SandboxManager, type SandboxRuntimeConfig } from "@anthropic-ai/sandbox-runtime";
48
- import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
49
- import { type BashOperations, CONFIG_DIR_NAME, createBashTool, getAgentDir } from "@earendil-works/pi-coding-agent";
50
-
51
- interface SandboxConfig extends SandboxRuntimeConfig {
52
- enabled?: boolean;
53
- }
54
-
55
- const DEFAULT_CONFIG: SandboxConfig = {
56
- enabled: true,
57
- network: {
58
- allowedDomains: [
59
- "npmjs.org",
60
- "*.npmjs.org",
61
- "registry.npmjs.org",
62
- "registry.yarnpkg.com",
63
- "pypi.org",
64
- "*.pypi.org",
65
- "github.com",
66
- "*.github.com",
67
- "api.github.com",
68
- "raw.githubusercontent.com",
69
- ],
70
- deniedDomains: [],
71
- },
72
- filesystem: {
73
- denyRead: ["~/.ssh", "~/.aws", "~/.gnupg"],
74
- allowWrite: [".", "/tmp"],
75
- denyWrite: [".env", ".env.*", "*.pem", "*.key"],
76
- },
77
- };
78
-
79
- function loadConfig(cwd: string): SandboxConfig {
80
- const projectConfigPath = join(cwd, CONFIG_DIR_NAME, "sandbox.json");
81
- const globalConfigPath = join(getAgentDir(), "extensions", "sandbox.json");
82
-
83
- let globalConfig: Partial<SandboxConfig> = {};
84
- let projectConfig: Partial<SandboxConfig> = {};
85
-
86
- if (existsSync(globalConfigPath)) {
87
- try {
88
- globalConfig = JSON.parse(readFileSync(globalConfigPath, "utf-8"));
89
- } catch (e) {
90
- console.error(`Warning: Could not parse ${globalConfigPath}: ${e}`);
91
- }
92
- }
93
-
94
- if (existsSync(projectConfigPath)) {
95
- try {
96
- projectConfig = JSON.parse(readFileSync(projectConfigPath, "utf-8"));
97
- } catch (e) {
98
- console.error(`Warning: Could not parse ${projectConfigPath}: ${e}`);
99
- }
100
- }
101
-
102
- return deepMerge(deepMerge(DEFAULT_CONFIG, globalConfig), projectConfig);
103
- }
104
-
105
- function deepMerge(base: SandboxConfig, overrides: Partial<SandboxConfig>): SandboxConfig {
106
- const result: SandboxConfig = { ...base };
107
-
108
- if (overrides.enabled !== undefined) result.enabled = overrides.enabled;
109
- if (overrides.network) {
110
- result.network = { ...base.network, ...overrides.network };
111
- }
112
- if (overrides.filesystem) {
113
- result.filesystem = { ...base.filesystem, ...overrides.filesystem };
114
- }
115
-
116
- const extOverrides = overrides as {
117
- ignoreViolations?: Record<string, string[]>;
118
- enableWeakerNestedSandbox?: boolean;
119
- };
120
- const extResult = result as { ignoreViolations?: Record<string, string[]>; enableWeakerNestedSandbox?: boolean };
121
-
122
- if (extOverrides.ignoreViolations) {
123
- extResult.ignoreViolations = extOverrides.ignoreViolations;
124
- }
125
- if (extOverrides.enableWeakerNestedSandbox !== undefined) {
126
- extResult.enableWeakerNestedSandbox = extOverrides.enableWeakerNestedSandbox;
127
- }
128
-
129
- return result;
130
- }
131
-
132
- function createSandboxedBashOps(): BashOperations {
133
- return {
134
- async exec(command, cwd, { onData, signal, timeout }) {
135
- if (!existsSync(cwd)) {
136
- throw new Error(`Working directory does not exist: ${cwd}`);
137
- }
138
-
139
- const wrappedCommand = await SandboxManager.wrapWithSandbox(command);
140
-
141
- return new Promise((resolve, reject) => {
142
- const child = spawn("bash", ["-c", wrappedCommand], {
143
- cwd,
144
- detached: true,
145
- stdio: ["ignore", "pipe", "pipe"],
146
- });
147
-
148
- let timedOut = false;
149
- let timeoutHandle: NodeJS.Timeout | undefined;
150
-
151
- if (timeout !== undefined && timeout > 0) {
152
- timeoutHandle = setTimeout(() => {
153
- timedOut = true;
154
- if (child.pid) {
155
- try {
156
- process.kill(-child.pid, "SIGKILL");
157
- } catch {
158
- child.kill("SIGKILL");
159
- }
160
- }
161
- }, timeout * 1000);
162
- }
163
-
164
- child.stdout?.on("data", onData);
165
- child.stderr?.on("data", onData);
166
-
167
- child.on("error", (err) => {
168
- if (timeoutHandle) clearTimeout(timeoutHandle);
169
- reject(err);
170
- });
171
-
172
- const onAbort = () => {
173
- if (child.pid) {
174
- try {
175
- process.kill(-child.pid, "SIGKILL");
176
- } catch {
177
- child.kill("SIGKILL");
178
- }
179
- }
180
- };
181
-
182
- signal?.addEventListener("abort", onAbort, { once: true });
183
-
184
- child.on("close", (code) => {
185
- if (timeoutHandle) clearTimeout(timeoutHandle);
186
- signal?.removeEventListener("abort", onAbort);
187
-
188
- if (signal?.aborted) {
189
- reject(new Error("aborted"));
190
- } else if (timedOut) {
191
- reject(new Error(`timeout:${timeout}`));
192
- } else {
193
- resolve({ exitCode: code });
194
- }
195
- });
196
- });
197
- },
198
- };
199
- }
200
-
201
- export default function (pi: ExtensionAPI) {
202
- pi.registerFlag("no-sandbox", {
203
- description: "Disable OS-level sandboxing for bash commands",
204
- type: "boolean",
205
- default: false,
206
- });
207
-
208
- const localCwd = process.cwd();
209
- const localBash = createBashTool(localCwd);
210
-
211
- let sandboxEnabled = false;
212
- let sandboxInitialized = false;
213
-
214
- pi.registerTool({
215
- ...localBash,
216
- label: "bash (sandboxed)",
217
- async execute(id, params, signal, onUpdate, _ctx) {
218
- if (!sandboxEnabled || !sandboxInitialized) {
219
- return localBash.execute(id, params, signal, onUpdate);
220
- }
221
-
222
- const sandboxedBash = createBashTool(localCwd, {
223
- operations: createSandboxedBashOps(),
224
- });
225
- return sandboxedBash.execute(id, params, signal, onUpdate);
226
- },
227
- });
228
-
229
- pi.on("user_bash", () => {
230
- if (!sandboxEnabled || !sandboxInitialized) return;
231
- return { operations: createSandboxedBashOps() };
232
- });
233
-
234
- pi.on("session_start", async (_event, ctx) => {
235
- const noSandbox = pi.getFlag("no-sandbox") as boolean;
236
-
237
- if (noSandbox) {
238
- sandboxEnabled = false;
239
- ctx.ui.notify("Sandbox disabled via --no-sandbox", "warning");
240
- return;
241
- }
242
-
243
- const config = loadConfig(ctx.cwd);
244
-
245
- if (!config.enabled) {
246
- sandboxEnabled = false;
247
- ctx.ui.notify("Sandbox disabled via config", "info");
248
- return;
249
- }
250
-
251
- const platform = process.platform;
252
- if (platform !== "darwin" && platform !== "linux") {
253
- sandboxEnabled = false;
254
- ctx.ui.notify(`Sandbox not supported on ${platform}`, "warning");
255
- return;
256
- }
257
-
258
- try {
259
- const configExt = config as unknown as {
260
- ignoreViolations?: Record<string, string[]>;
261
- enableWeakerNestedSandbox?: boolean;
262
- };
263
-
264
- await SandboxManager.initialize({
265
- network: config.network,
266
- filesystem: config.filesystem,
267
- ignoreViolations: configExt.ignoreViolations,
268
- enableWeakerNestedSandbox: configExt.enableWeakerNestedSandbox,
269
- });
270
-
271
- sandboxEnabled = true;
272
- sandboxInitialized = true;
273
-
274
- const networkCount = config.network?.allowedDomains?.length ?? 0;
275
- const writeCount = config.filesystem?.allowWrite?.length ?? 0;
276
- ctx.ui.setStatus(
277
- "sandbox",
278
- ctx.ui.theme.fg("accent", `🔒 Sandbox: ${networkCount} domains, ${writeCount} write paths`),
279
- );
280
- ctx.ui.notify("Sandbox initialized", "info");
281
- } catch (err) {
282
- sandboxEnabled = false;
283
- ctx.ui.notify(`Sandbox initialization failed: ${err instanceof Error ? err.message : err}`, "error");
284
- }
285
- });
286
-
287
- pi.on("session_shutdown", async () => {
288
- if (sandboxInitialized) {
289
- try {
290
- await SandboxManager.reset();
291
- } catch {
292
- // Ignore cleanup errors
293
- }
294
- }
295
- });
296
-
297
- pi.registerCommand("sandbox", {
298
- description: "Show sandbox configuration",
299
- handler: async (_args, ctx) => {
300
- if (!sandboxEnabled) {
301
- ctx.ui.notify("Sandbox is disabled", "info");
302
- return;
303
- }
304
-
305
- const config = loadConfig(ctx.cwd);
306
- const lines = [
307
- "Sandbox Configuration:",
308
- "",
309
- "Network:",
310
- ` Allowed: ${config.network?.allowedDomains?.join(", ") || "(none)"}`,
311
- ` Denied: ${config.network?.deniedDomains?.join(", ") || "(none)"}`,
312
- "",
313
- "Filesystem:",
314
- ` Deny Read: ${config.filesystem?.denyRead?.join(", ") || "(none)"}`,
315
- ` Allow Write: ${config.filesystem?.allowWrite?.join(", ") || "(none)"}`,
316
- ` Deny Write: ${config.filesystem?.denyWrite?.join(", ") || "(none)"}`,
317
- ];
318
- ctx.ui.notify(lines.join("\n"), "info");
319
- },
320
- });
321
- }
@@ -1,92 +0,0 @@
1
- {
2
- "name": "pi-extension-sandbox",
3
- "version": "1.4.0",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "pi-extension-sandbox",
9
- "version": "1.4.0",
10
- "dependencies": {
11
- "@anthropic-ai/sandbox-runtime": "^0.0.26"
12
- }
13
- },
14
- "node_modules/@anthropic-ai/sandbox-runtime": {
15
- "version": "0.0.26",
16
- "resolved": "https://registry.npmjs.org/@anthropic-ai/sandbox-runtime/-/sandbox-runtime-0.0.26.tgz",
17
- "integrity": "sha512-DYV5LSsVMnzq0lbfaYMSpxZPUMAx4+hy343dRss+pVCLIfF62qOhxpYfZ5TmOk1GTDQm5f9wPprMNSStmnsV4w==",
18
- "license": "Apache-2.0",
19
- "dependencies": {
20
- "@pondwader/socks5-server": "^1.0.10",
21
- "@types/lodash-es": "^4.17.12",
22
- "commander": "^12.1.0",
23
- "lodash-es": "^4.17.21",
24
- "shell-quote": "^1.8.3",
25
- "zod": "^3.24.1"
26
- },
27
- "bin": {
28
- "srt": "dist/cli.js"
29
- },
30
- "engines": {
31
- "node": ">=18.0.0"
32
- }
33
- },
34
- "node_modules/@pondwader/socks5-server": {
35
- "version": "1.0.10",
36
- "resolved": "https://registry.npmjs.org/@pondwader/socks5-server/-/socks5-server-1.0.10.tgz",
37
- "integrity": "sha512-bQY06wzzR8D2+vVCUoBsr5QS2U6UgPUQRmErNwtsuI6vLcyRKkafjkr3KxbtGFf9aBBIV2mcvlsKD1UYaIV+sg==",
38
- "license": "MIT"
39
- },
40
- "node_modules/@types/lodash": {
41
- "version": "4.17.23",
42
- "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.23.tgz",
43
- "integrity": "sha512-RDvF6wTulMPjrNdCoYRC8gNR880JNGT8uB+REUpC2Ns4pRqQJhGz90wh7rgdXDPpCczF3VGktDuFGVnz8zP7HA==",
44
- "license": "MIT"
45
- },
46
- "node_modules/@types/lodash-es": {
47
- "version": "4.17.12",
48
- "resolved": "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.12.tgz",
49
- "integrity": "sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==",
50
- "license": "MIT",
51
- "dependencies": {
52
- "@types/lodash": "*"
53
- }
54
- },
55
- "node_modules/commander": {
56
- "version": "12.1.0",
57
- "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz",
58
- "integrity": "sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA==",
59
- "license": "MIT",
60
- "engines": {
61
- "node": ">=18"
62
- }
63
- },
64
- "node_modules/lodash-es": {
65
- "version": "4.18.1",
66
- "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.18.1.tgz",
67
- "integrity": "sha512-J8xewKD/Gk22OZbhpOVSwcs60zhd95ESDwezOFuA3/099925PdHJ7OFHNTGtajL3AlZkykD32HykiMo+BIBI8A==",
68
- "license": "MIT"
69
- },
70
- "node_modules/shell-quote": {
71
- "version": "1.8.3",
72
- "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz",
73
- "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==",
74
- "license": "MIT",
75
- "engines": {
76
- "node": ">= 0.4"
77
- },
78
- "funding": {
79
- "url": "https://github.com/sponsors/ljharb"
80
- }
81
- },
82
- "node_modules/zod": {
83
- "version": "3.25.76",
84
- "resolved": "https://registry.npmjs.org/zod/-/zod-3.25.76.tgz",
85
- "integrity": "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==",
86
- "license": "MIT",
87
- "funding": {
88
- "url": "https://github.com/sponsors/colinhacks"
89
- }
90
- }
91
- }
92
- }
@@ -1,19 +0,0 @@
1
- {
2
- "name": "pi-extension-sandbox",
3
- "private": true,
4
- "version": "1.4.0",
5
- "type": "module",
6
- "scripts": {
7
- "clean": "echo 'nothing to clean'",
8
- "build": "echo 'nothing to build'",
9
- "check": "echo 'nothing to check'"
10
- },
11
- "pi": {
12
- "extensions": [
13
- "./index.ts"
14
- ]
15
- },
16
- "dependencies": {
17
- "@anthropic-ai/sandbox-runtime": "0.0.26"
18
- }
19
- }