SuperAPI AI Directory

SIwithin

SIwithin is a Python script for running AI agent command-line tools (CLIs) unattended, supporting Claude Code and OpenAI Codex. It uses a sandbox fence to restrict the agent to only access specified folders, and uses budget controls (dollar cap, timer, agent billing) to prevent overspending, generating a one-line ledger record after each run stating whether the run completed and how much it cost. It supports only macOS and Linux, is a single file, uses only the standard library, has no telemetry, and is licensed under Apache-2.0.

Open website

About this tool

SIwithin is an independent open-source project for running AI agent command-line tools (CLIs) unattended, imposing a fence and budget constraints on their behavior, and recording the cost and result of each run. It supports driving two CLIs, Claude Code and OpenAI Codex, but is not made, endorsed, or sponsored by Anthropic or OpenAI.

Purpose: to let an agent CLI run automatically according to a given task brief, while ensuring it can only access specified folders, cannot exceed a given dollar budget, and leaves a ledger record after each run stating whether the run was "done" or "stopped" and how much was spent.

Main capabilities:

  • Fence: uses a sandbox-exec profile on macOS and bubblewrap on Linux (socat is required for the proxy bridge). A run can only access folders specified via --dir and --read, and the user home directory is denied read and write access.
  • Budget control: each run has a dollar budget, all runs have a total cap, and each run has a timer. For the Claude adapter, a loopback proxy is used as the sole entry point for API access; the run holds a per-run dedicated token rather than the real API key, the proxy prices based on response usage, and rejects subsequent requests once the budget is exceeded.
  • Ledger: each run outputs one line containing the status (done, finished, contract, killed, stopped, refused), cost, and receipt. done means the CLI completed and the task brief's custom tests (--done and --absent) passed.
  • Key security: the Claude adapter uses proxy mode by default, and the run environment does not hold the real key; the Codex adapter uses environment variable mode, the key is in the run environment, and open network access is required.
  • Cleanup: after a run ends, processes left over from the run are killed and counted.

Usage:

  • Requires Python 3.10 or newer, standard library only.
  • Requires the target CLI to be installed and on PATH, as well as the corresponding API key.
  • Linux requires bubblewrap and socat to be installed (e.g. apt install bubblewrap socat). On Ubuntu 23.10 and later, AppAr may need to be configuredmor configuration file or adjust sysctl to allow unprivileged user namespaces.
  • Provides a demo mode that runs for about half a minute without a key, using a simulated CLI and simulated API to demonstrate fencing, proxy, and ledger features.
  • Quick start example: when using Claude Code, specify the working folder with --dir, add readable folders with --read, and specify the model with --model; when using Codex, the --model and --soft-budget flags are required, and --network open is needed.
  • Supports --dry-run to preview the fence configuration and proxy settings.

Use cases: scenarios that need to safely run AI agent CLIs in an unattended environment and strictly control their file access scope and API spending.

Limitations:

  • Only macOS and Linux are supported; Windows and other platforms will refuse to run.
  • The Linux fence has only been tested on an Ubuntu 24.04 virtual machine with a fake CLI and one real CLI run; the Codex adapter is built from documentation and has not yet been tested against the real CLI.
  • Content sent to the API in the run's own requests is not subject to the fence.
  • The code was written by AI models, with guidance and review by the maintainers; external security review was performed by another AI model, and no one outside the project has reviewed the security.
  • When using environment variable mode, keys are exposed in the runtime environment and may be leaked through text that the run reads.
  • In proxy mode, responses that exceed the budget are billed in full, and burst requests sent before the response is priced are also billed.
  • For CLIs that cannot be stopped mid-run, the tool refuses to run unless the user explicitly accepts.
  • No pricing, charges, or specific effectiveness data are provided.