|
| 1 | +# @nebutra/code-execution |
| 2 | + |
| 3 | +Public mirror for [@nebutra/code-execution](https://www.npmjs.com/package/%40nebutra%2Fcode-execution) from [Nebutra/Nebutra-Sailor](https://github.com/Nebutra/Nebutra-Sailor/tree/main/packages/ai/code-execution). |
| 4 | + |
| 5 | +This repository is generated from the Nebutra Sailor monorepo. Package releases are cut from the monorepo and mirrored here for discovery, standalone cloning, and contribution intake. |
| 6 | + |
| 7 | +- Canonical source: `packages/ai/code-execution` in `Nebutra/Nebutra-Sailor` |
| 8 | +- Package registry: npm and GitHub Packages |
| 9 | +- Contributions: open issues or PRs here; maintainers port accepted changes back into the monorepo source package |
| 10 | + |
| 11 | +--- |
| 12 | +Action and observation execution layer backed by `@nebutra/sandbox-runtime`. |
| 13 | + |
| 14 | +This package turns shell, read, edit-by-diff, git, policy, replay, doctor, and |
| 15 | +debug actions into structured observations. It owns execution behavior, not |
| 16 | +thread state, prompts, model calls, sub-agent scheduling, or UI approval flows. |
| 17 | + |
| 18 | +## Status: WIP |
| 19 | + |
| 20 | +Experimental public package. The package metadata marks it as not production |
| 21 | +ready yet because: |
| 22 | + |
| 23 | +- notebook kernel execution is adapter-gated |
| 24 | +- remote workspace providers depend on sandbox-runtime configuration |
| 25 | +- approval UI is surfaced as observations and is not wired in this package |
| 26 | + |
| 27 | +Use it as a capability layer behind an application runtime that owns approval, |
| 28 | +tenant, and UI handoff. |
| 29 | + |
| 30 | +## Installation |
| 31 | + |
| 32 | +```bash |
| 33 | +pnpm add @nebutra/code-execution |
| 34 | +``` |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +```ts |
| 39 | +import { CodeExecutor } from "@nebutra/code-execution"; |
| 40 | + |
| 41 | +const executor = new CodeExecutor({ |
| 42 | + tenantId: "org_123", |
| 43 | + workspaceRoot: process.cwd(), |
| 44 | +}); |
| 45 | + |
| 46 | +const observation = await executor.run({ |
| 47 | + type: "read", |
| 48 | + path: "README.md", |
| 49 | +}); |
| 50 | +``` |
| 51 | + |
| 52 | +Shell actions route through `@nebutra/sandbox-runtime`: |
| 53 | + |
| 54 | +```ts |
| 55 | +const result = await executor.run({ |
| 56 | + type: "shell", |
| 57 | + cmd: "pnpm test", |
| 58 | + cwd: ".", |
| 59 | + timeoutS: 30, |
| 60 | +}); |
| 61 | +``` |
| 62 | + |
| 63 | +## Action Types |
| 64 | + |
| 65 | +| Type | Purpose | |
| 66 | +| --- | --- | |
| 67 | +| `shell` | Execute a command through the configured sandbox runtime | |
| 68 | +| `read` | Read a workspace-relative file, optionally by line range | |
| 69 | +| `edit` | Apply an edit-by-diff request to a workspace-relative file | |
| 70 | +| `git` | Execute supported git operations through the sandbox path | |
| 71 | +| `ipython` | Return an adapter-unavailable observation until a notebook sidecar is configured | |
| 72 | + |
| 73 | +## Observations |
| 74 | + |
| 75 | +The executor returns structured observations instead of raw side effects: |
| 76 | + |
| 77 | +- `shell_output` |
| 78 | +- `file_content` |
| 79 | +- `edit_applied` |
| 80 | +- `error` |
| 81 | + |
| 82 | +Approval requirements are surfaced as `error` observations with the |
| 83 | +`ApprovalRequired` kind. The caller is responsible for asking the user and |
| 84 | +retrying with `approved: true`. |
| 85 | + |
| 86 | +## Commands |
| 87 | + |
| 88 | +```bash |
| 89 | +pnpm exec:doctor |
| 90 | +pnpm exec:debug <action_id> |
| 91 | +pnpm exec:replay <action_id> |
| 92 | +pnpm exec:policy |
| 93 | +``` |
| 94 | + |
| 95 | +Executable examples live under `examples/`. |
| 96 | + |
| 97 | +## License |
| 98 | + |
| 99 | +MIT |
0 commit comments