8000 feat(extensions): Python code tools, run in a process of their own (admins only) by adeelahmad · Pull Request #103 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(extensions): Python code tools, run in a process of their own (admins only) - #103

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-t9tw9j
Oct 3, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-t9tw9j

Conversation

@adeelahmad
Copy link
< 8000 /div> Copy Markdown
Owner

Before: an assistant tool's body could be a prompt, a web request or a canvas graph, but not code.

After: admins can write a tool in Python. Its run is {type: python, code, seconds, network}, and code defines run(**args). The assistant calls it like any other tool, and "Try it" on the extension page runs it. The new-extension editor has a "Python tool" starter.

How: app/domain/code_tools.py runs the code in its own Python process with these limits:

  • isolated mode (-I -S -B), so standard library only, started in an empty temp folder
  • an empty environment, so none of the server's keys or database address
  • rlimits on CPU (seconds, max 60), memory, file size and open files, plus a wall-clock kill
  • audit hooks that block file access outside its own folder (the Python library is read-only), starting other programs, ctypes, and sockets beyond loopback unless network: true
  • unshare -rn for a private network namespace where the machine allows it

Who can use it:

  • Only admins can save a Python tool.
  • A Python tool runs only while an admin owns its extension.
  • Manifests write the code back out as a YAML block.

Audit hooks raise the bar but are not a wall, which is why this is admins only. A container or gVisor sandbox would let non-admins write code tools; that is noted as "refine later" in DEVLOG.

Tests: the full local suite passes (backend 480 passed; the known LibreOffice conversion test fails in this environment; frontend jest 628 passed, plus tsc and lint).

🤖 Generated with Claude Code

https://claude.ai/code/session_01JroZmoXJUKvyfkvDYvmbka


Generated by Claude Code

…dmins only)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JroZmoXJUKvyfkvDYvmbka
@adeelahmad
adeelahmad merged commit 4c4e965 into main Oct 3, 2026
1 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0