picoclaw/pkg/agent
Huang Rui d5370c9605
fix(tools): allow /dev/null redirection and add read/write sandbox split (#967)
* fix(tools): allow /dev/null redirection and add read/write sandbox split

- Remove deny pattern that incorrectly blocked redirects to /dev/null
- Expand block device write pattern to cover nvme, mmcblk, vd, xvd,
  hd, loop, dm-, md, sr and nbd in addition to sd
- Add safe path whitelist for kernel pseudo-devices so workspace path
  check does not reject /dev/null, /dev/zero, /dev/random, /dev/urandom,
  /dev/stdin, /dev/stdout and /dev/stderr
- Add allow_read_outside_workspace config option (default true) so file
  read and list tools are unrestricted while write tools stay sandboxed

Closes https://github.com/sipeed/picoclaw/issues/964
Closes https://github.com/sipeed/picoclaw/issues/965

Signed-off-by: Huang Rui <vowstar@gmail.com>

* feat(tools): add configurable allow patterns and path whitelists

- Add custom_allow_patterns to exec config so users can exempt specific
  commands from deny pattern checks
- Add allow_read_paths and allow_write_paths regex lists to tools config
  for whitelisting specific paths outside the workspace
- Introduce whitelistFs that wraps sandboxFs and falls through to hostFs
  for paths matching whitelist patterns
- Use variadic constructor signatures to keep backward compatibility

Suggested-by: lxowalle
Signed-off-by: Huang Rui <vowstar@gmail.com>

---------

Signed-off-by: Huang Rui <vowstar@gmail.com>
2026-03-02 12:22:02 +08:00
..
context.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
context_cache_test.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
context_test.go fix: handle multi-tool-call orphan detection in sanitizeHistoryForProvider 2026-02-24 21:35:15 +08:00
instance.go fix(tools): allow /dev/null redirection and add read/write sandbox split (#967) 2026-03-02 12:22:02 +08:00
instance_test.go fix(agent): resolve fallback model aliases from model_list 2026-02-26 23:50:40 +08:00
loop.go fixed conflicts 2026-03-01 23:44:21 +01:00
loop_test.go Merge pull request #861 from p3ddd/refactor/modernize 2026-03-01 15:38:59 +08:00
memory.go refactor(modernize): apply safe modernize fixes 2026-02-27 16:35:07 +08:00
mock_provider_test.go feat(fmt): Fix formatting 2026-02-19 22:05:15 +02:00
registry.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00
registry_test.go feat(fmt): Run formatters 2026-02-18 21:48:23 +02:00