@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.
- package/CHANGELOG.md +86 -2
- package/dist/bundle/chunks/{anthropic-messages-KRX3GRGV.js → anthropic-messages-BWGCKOF4.js} +1 -1
- package/dist/bundle/chunks/{azure-openai-responses-YWTDZRIJ.js → azure-openai-responses-FSC6BAW3.js} +1 -1
- package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
- package/dist/bundle/chunks/chunk-36QC74V4.js +2 -0
- package/dist/bundle/chunks/{chunk-ZN2R65UF.js → chunk-3TGLJEWK.js} +1 -1
- package/dist/bundle/chunks/{chunk-LAMEVJ4W.js → chunk-4EYXVSA5.js} +9 -12
- package/dist/bundle/chunks/{chunk-AFNTYPTW.js → chunk-62VOPMLK.js} +6 -6
- package/dist/bundle/chunks/{chunk-CPKYLLPC.js → chunk-7O7QKK6A.js} +1 -1
- package/dist/bundle/chunks/{chunk-V4LJ5IY6.js → chunk-B46VJEHW.js} +1 -1
- package/dist/bundle/chunks/{chunk-N6ZHTIEL.js → chunk-BZZAKZGU.js} +1 -1
- package/dist/bundle/chunks/{chunk-M3LEVT3X.js → chunk-C2WU32PX.js} +1 -1
- package/dist/bundle/chunks/{chunk-RFUP4YGP.js → chunk-CHWNPHIS.js} +2 -2
- package/dist/bundle/chunks/{chunk-QTM7S6TH.js → chunk-EOO47QGR.js} +1 -1
- package/dist/bundle/chunks/{chunk-XPUTTZLN.js → chunk-GN3QYODH.js} +1 -1
- package/dist/bundle/chunks/{chunk-4UNN5OGR.js → chunk-NL4X6LBY.js} +1 -1
- package/dist/bundle/chunks/chunk-NZY7EIPA.js +4 -0
- package/dist/bundle/chunks/{chunk-HQBQWHLD.js → chunk-R2EGYMOO.js} +3 -3
- package/dist/bundle/chunks/chunk-TM7G7NOA.js +1239 -0
- package/dist/bundle/chunks/{chunk-BPHHHEET.js → chunk-V6KH5QG4.js} +1 -1
- package/dist/bundle/chunks/{chunk-HQJBN2MC.js → chunk-VOLAXWGI.js} +1 -1
- package/dist/bundle/chunks/{chunk-HODJBMOY.js → chunk-YZKQS34S.js} +1 -1
- package/dist/bundle/chunks/{cli-QUXYJ5RR.js → cli-MCOUW5WS.js} +11 -9
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-QPZQRBK5.js → cloudflare-workers-ai-system-one-WLAFJSP6.js} +1 -1
- package/dist/bundle/chunks/{easter-egg-3d-RD5RBYI2.js → easter-egg-3d-WMBNSJ4M.js} +1 -1
- package/dist/bundle/chunks/{execute-XTJDRV75.js → execute-4CEBORGZ.js} +1 -1
- package/dist/bundle/chunks/{google-generative-ai-J3K3YPN3.js → google-generative-ai-INGKNW72.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-VFXOTBVP.js → google-vertex-IBTX6MBF.js} +1 -1
- package/dist/bundle/chunks/image-resize-worker.js +1 -1
- package/dist/bundle/chunks/{llama-cpp-classify-4KFSGAMH.js → llama-cpp-classify-V5U3QKXI.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-C2QQGYVC.js → mistral-conversations-S4OWXIXQ.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-H2UJSVV3.js → openai-codex-responses-QAWLOQSN.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-QPD4B26I.js → openai-completions-EJNYB6IX.js} +1 -1
- package/dist/bundle/chunks/{openai-decisions-O6PHBSCB.js → openai-decisions-IXI34BYG.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-JOYMWKMB.js → openai-responses-MD3562FB.js} +1 -1
- package/dist/bundle/chunks/{openrouter-images-4WG6OOLH.js → openrouter-images-PISKSFMS.js} +1 -1
- package/dist/bundle/chunks/{pi-messages-EZXKVRR6.js → pi-messages-NORUKF4E.js} +1 -1
- package/dist/bundle/chunks/{runtime-YKR6KZPS.js → runtime-FQB7RU7U.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-X3JT6ECA.js → typesafe-system-one-CHVC2UUI.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-FBPNWDXK.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +6 -5
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +24 -5
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session-runtime.js +3 -3
- package/dist/core/agent-session-runtime.js.map +1 -1
- package/dist/core/bug-report.d.ts +4 -4
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +12 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
- package/dist/core/export-html/tool-renderer.js +3 -0
- package/dist/core/export-html/tool-renderer.js.map +1 -1
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +7 -6
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/pi-ai-extension-view.d.ts +19 -0
- package/dist/core/extensions/pi-ai-extension-view.d.ts.map +1 -0
- package/dist/core/extensions/pi-ai-extension-view.js +22 -0
- package/dist/core/extensions/pi-ai-extension-view.js.map +1 -0
- package/dist/core/extensions/types.d.ts +15 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/virtual-modules.js +8 -7
- package/dist/core/extensions/virtual-modules.js.map +1 -1
- package/dist/core/mcp-servers.d.ts +11 -4
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +15 -5
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-config.d.ts +1678 -2029
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -3
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/package-manager.d.ts +5 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +88 -25
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-ai-schemas.d.ts +163 -0
- package/dist/core/pi-ai-schemas.d.ts.map +1 -0
- package/dist/core/pi-ai-schemas.js +21 -0
- package/dist/core/pi-ai-schemas.js.map +1 -0
- package/dist/core/project-trust.js +1 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/resource-loader.d.ts +1 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +19 -20
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/session-manager.d.ts +7 -0
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +12 -10
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-schema.d.ts +3 -2
- package/dist/core/settings-schema.d.ts.map +1 -1
- package/dist/core/settings-schema.js +5 -1
- package/dist/core/settings-schema.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -14
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.js +2 -2
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/source-info.d.ts +2 -0
- package/dist/core/source-info.d.ts.map +1 -1
- package/dist/core/source-info.js +5 -0
- package/dist/core/source-info.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +5 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/bash.d.ts +2 -2
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit.d.ts +3 -3
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +2 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/find.d.ts +2 -2
- package/dist/core/tools/find.d.ts.map +1 -1
- package/dist/core/tools/find.js.map +1 -1
- package/dist/core/tools/grep.d.ts +2 -2
- package/dist/core/tools/grep.d.ts.map +1 -1
- package/dist/core/tools/grep.js.map +1 -1
- package/dist/core/tools/ls.d.ts +2 -2
- package/dist/core/tools/ls.d.ts.map +1 -1
- package/dist/core/tools/ls.js.map +1 -1
- package/dist/core/tools/read.d.ts +2 -2
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/core/tools/render-utils.d.ts.map +1 -1
- package/dist/core/tools/render-utils.js +2 -7
- package/dist/core/tools/render-utils.js.map +1 -1
- package/dist/core/tools/renderers/write.d.ts.map +1 -1
- package/dist/core/tools/renderers/write.js +19 -19
- package/dist/core/tools/renderers/write.js.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts +11 -1
- package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
- package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
- package/dist/core/tools/write.d.ts +2 -2
- package/dist/core/tools/write.d.ts.map +1 -1
- package/dist/core/tools/write.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +14 -8
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/extensions/codemode/renderer.d.ts.map +1 -1
- package/dist/extensions/codemode/renderer.js +6 -2
- package/dist/extensions/codemode/renderer.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +2 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/mcp/cli.d.ts.map +1 -1
- package/dist/extensions/mcp/cli.js +34 -8
- package/dist/extensions/mcp/cli.js.map +1 -1
- package/dist/extensions/mcp/oauth.d.ts +1 -1
- package/dist/extensions/mcp/oauth.d.ts.map +1 -1
- package/dist/extensions/mcp/oauth.js +36 -13
- package/dist/extensions/mcp/oauth.js.map +1 -1
- package/dist/extensions/tool-search/tool.d.ts +19 -8
- package/dist/extensions/tool-search/tool.d.ts.map +1 -1
- package/dist/extensions/tool-search/tool.js +87 -42
- package/dist/extensions/tool-search/tool.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -3
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/assistant-message.d.ts +1 -0
- package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/assistant-message.js +20 -6
- package/dist/modes/interactive/components/assistant-message.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +4 -17
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-entry.js +2 -1
- package/dist/modes/interactive/components/custom-entry.js.map +1 -1
- package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
- package/dist/modes/interactive/components/custom-message.js +2 -1
- package/dist/modes/interactive/components/custom-message.js.map +1 -1
- package/dist/modes/interactive/components/extension-editor.d.ts +2 -0
- package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
- package/dist/modes/interactive/components/extension-editor.js +4 -0
- package/dist/modes/interactive/components/extension-editor.js.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts +2 -1
- package/dist/modes/interactive/components/markdown-transform.d.ts.map +1 -1
- package/dist/modes/interactive/components/markdown-transform.js +2 -1
- package/dist/modes/interactive/components/markdown-transform.js.map +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts +1 -1
- package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/session-selector.js +14 -25
- package/dist/modes/interactive/components/session-selector.js.map +1 -1
- package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
- package/dist/modes/interactive/components/tool-execution.js +3 -1
- package/dist/modes/interactive/components/tool-execution.js.map +1 -1
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +2 -6
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/components/user-message.js +1 -1
- package/dist/modes/interactive/components/user-message.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts +1 -0
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +16 -4
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +6 -9
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts +10 -0
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +31 -23
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +48 -2
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/clipboard-command.d.ts.map +1 -1
- package/dist/utils/clipboard-command.js +4 -0
- package/dist/utils/clipboard-command.js.map +1 -1
- package/dist/utils/git.d.ts +1 -1
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/image-resize-core.d.ts.map +1 -1
- package/dist/utils/image-resize-core.js +5 -3
- package/dist/utils/image-resize-core.js.map +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/open-browser.js +4 -1
- package/dist/utils/open-browser.js.map +1 -1
- package/dist/utils/paths.d.ts +17 -0
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +42 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/syntax-highlight.d.ts +5 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +7 -0
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/cli.md +18 -8
- package/docs/environment-variables.md +1 -0
- package/docs/extensions.md +24 -10
- package/docs/mcp.md +6 -4
- package/docs/packages.md +2 -0
- package/docs/sessions.md +11 -3
- package/docs/settings.md +1 -0
- package/docs/slash-commands.md +2 -2
- package/docs/terminal-setup.md +3 -1
- package/docs/tmux.md +6 -0
- package/docs/windows.md +27 -0
- package/examples/extensions/README.md +2 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/debug-provider.ts +2 -2
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/tsconfig.json +180 -0
- package/package.json +10 -11
- package/schemas/models.schema.json +36 -36
- package/schemas/settings.schema.json +8 -0
- package/dist/bundle/chunks/chunk-BSS6T6KQ.js +0 -2
- package/dist/bundle/chunks/chunk-KFM2CJ7Q.js +0 -4
- package/dist/bundle/chunks/chunk-UH6VPJL7.js +0 -1237
- package/dist/bundle/chunks/virtual-modules-TW6KBQM5.js +0 -2
- package/examples/extensions/sandbox/index.ts +0 -321
- package/examples/extensions/sandbox/package-lock.json +0 -92
- 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
|
-
}
|