{"slug": "the-local-first-safety-and-cost-layer-for-your-autonomous-agents", "title": "The local-first safety and cost layer for your autonomous agents", "summary": "Aisona Lab released Tucana Code v0.1.0, an MIT-licensed, zero-telemetry safety and budget gate that runs inside Claude Code's PreToolUse hook and wraps other CLI agents such as Codex, OpenCode and Gemini CLI. Tucana Code blocks destructive or exfiltration commands and allows safe read-only checks in under 1 ms at $0 cost and 100% offline, versus the 150–600 ms network roundtrip the project attributes to cloud AI gateways, and enforces real-time spend caps in USD plus 6 Latin American currencies (MXN, COP, ARS, BRL, CLP, PEN). The published CLI requires Node.js >=22.16.0, ships with zero runtime dependencies at 27.5 kB packed and roughly 56 ms cold start, and routes gray-zone commands to an ESCALATE prompt while logging overrides for human review in the separate tucana-lab repository.", "body_md": "**The local-first safety & cost layer for Claude Code, Codex, and OpenCode.**\n\n  Same agents. Hard spend caps. Sub-millisecond guardrails. Zero telemetry.\n\n[Quickstart](#30-second-quickstart) •\n  [Why Tucana](#why-tucana-code) •\n  [Safety Cockpit](#local-safety-cockpit-web-ui) •\n  [Architecture](#system-0--system-1-architecture) •\n  [Kill-Switch](#local-currency-kill-switch) •\n  [Closed-Loop Calibration](#closed-loop-calibration-with-tucana-lab)\n\n**Coding agents run real shell commands on your machine and burn real API dollars while you look away.**\n\nOne hallucinated `rm -rf`, one leaked `.env` piped to `curl`, or one runaway reasoning loop on pay-as-you-go tokens can wipe your morning in seconds.\n\n**Tucana Code** puts a **<1 ms, $0, 100% offline safety & budget gate** directly inside Claude Code's `PreToolUse` hook (and any CLI agent wrapper) — **without** shipping your prompts, code, or traces to anyone's cloud.\n\n| Capability | Unprotected Agent | Cloud AI Gateways | **Tucana Code (`v0.1.0`)** | \n|---|---|---|---|\n| **Safe read-only checks (`git status`, tests)** | Manual click or YOLO | +150–600 ms network roundtrip | **`<1 ms` System 0, `$0`, 100% offline** | \n| **Destructive / exfil protection** | Hope the LLM behaves | Cloud policy / SaaS lock-in | **Instant deterministic block + fail-safe** | \n| **API spend ceiling & Kill-Switch** | Surprise invoice tomorrow | USD-only / proxy account | **Real-time USD + 6 LATAM currencies** | \n| **Telemetry & cloud accounts** | Vendor telemetry | Cloud dashboard + auth | **Zero accounts · Zero network · MIT** | \n| **Learn from your overrides** | Re-prompt forever | Vendor fine-tuning | **Human review in [`tucana-lab`](https://github.com/aisona-lab/tucana-lab) → `<1 ms` rules** | \n\nRequires **Node.js `>=22.16.0`**. Zero runtime dependencies in the published CLI (` 27.5 kB` packed, ~56 ms cold start).\n\n```\nnpm install -g tucana-code\ntucana-code --help\n```\n\n*(Want to try a one-off command first? Run `npx tucana-code --help`.)*\n\n`init --dry-run` backs up `~/.claude/settings.json` with a timestamp, registers `PreToolUse` idempotently using your resolved binary path (**never** slow `npx` in the hot path), and runs in observation mode while writing real traces:\n\n```\ntucana-code init --dry-run --currency MXN\ntucana-code doctor\n```\n\nTest all three decision paths immediately:\n\n``` php\ntucana-code guard check -- git status                  # System 0 -> ALLOW (<1 ms, $0)\ntucana-code guard check -- \"rm -rf /\"                  # System 0 -> BLOCK (<1 ms, $0)\ntucana-code guard check -- \"npm run deploy:staging\"    # Gray zone -> ESCALATE (ask)\n```\n\nReady to enforce live blocking? Re-run without `--dry-run`:\n\n```\ntucana-code init --currency MXN\n```\n\nUsing **Codex**, **OpenCode**, **Gemini CLI**, or local scripts? Wrap any command in one line:\n\n```\ntucana-code guard check -- <command>\n```\n\nRun `tucana-code` locally for an **Editorial Instrument** workspace built specifically for agent governance and cost control:\n\n- **Tucana Light (Paper) & Tucana Space (Dark):** Warm paper canvas (`#F4EEE3` ) as the strict default, paired with dark space mode (`#0B101B` ) via a`Light | Space` segmented toggle.\n- **44px Top Telemetry Ribbon:** Live`System 0` mode selector (`Active` ,`Strict` ,`Dry-run` ) and an interactive**Budget Guard** popover to switch currencies (`USD` ,`MXN` ,`COP` ,`ARS` ,`BRL` ,`CLP` ,`PEN` ) and update thread/daily caps in`~/.tucana-code/budget.json` .\n- **Collapsible Editorial Rail & Session Briefing:** Numbered session index (`01` ,`02` , ...) with`Workspace & Git` ,`System 0 Gate` , and`Budget Guard` cards under the composer.\n- **Clean Offline Resilience:** Local WebSocket/network loss renders a clean Tucana reconnecting state with zero cloud dependencies.\n\nTucana splits decisions between deterministic speed and calibrated escalation so your fast path stays instant and offline:\n\n``` php\nflowchart LR\n  Agent[\"Agent Bash Call<br/>(PreToolUse / CLI)\"] --> Budget{\"Local Budget<br/>Kill-Switch?\"}\n  Budget -- \"Limit Exceeded\" --> Deny[\"DENY<br/>(0 ms, kill_switch)\"]\n  Budget -- \"Within Budget\" --> Sys0{\"System 0<br/>Deterministic + Policy\"}\n  Sys0 -- \"Known Safe / Approved\" --> Allow[\"ALLOW<br/>(&lt;1 ms, $0)\"]\n  Sys0 -- \"Known Destructive / Exfil\" --> Block[\"BLOCK<br/>(&lt;1 ms, $0)\"]\n  Sys0 -- \"Gray Zone\" --> Sys1[\"System 1 (Optional)<br/>Ollama / KEV / Jev / Offline Ask\"]\n  Deny --> Trace[\"Append-Only<br/>decision-trace.jsonl\"]\n  Allow --> Trace\n  Block --> Trace\n  Sys1 --> Trace\n  Trace --> Lab[\"Tucana Lab<br/>ECE / Brier + Active Learning\"]\n  Lab -- \"policy-calibration.json\" --> Sys0\n```\n\n- **System 0 (`<1 ms`, `$0`, offline):** Fast deterministic rules + exact-match human-approved rules loaded from`~/.tucana-code/policy-calibration.json` .\n- **System 1 (optional, never blocking):** Point`TUCANA_KEV_URL` or`OLLAMA_HOST` to your local model (`$0` ), or optionally set`JEV_API_KEY` . When offline or unconfigured, gray-zone commands gracefully`escalate` (`ask` ) — never crashing your session.\n\nEvery raw agent trace starts as scattered telemetry points in the dark (**01 Origin**). Run it through continuous evaluation and uncertainty sorting (** 02 Vortex**), assemble human-verified judgment on a structured grid (** 03 Assemblage**), and lock it into sharp, deterministic `<1 ms` instincts (** 04 The Tucana**).\n\nBuilt for real pay-as-you-go developers across the Americas and beyond. Configure limits in USD and track spend in **USD (`$`), MXN (` MX$`), COP (` COL$`), ARS (` ARS$`), BRL (` R$`), CLP (` CLP$`), or PEN (` S/`)**:\n\n```\n# Set per-thread and daily spending caps\ntucana-code budget set --currency MXN --thread-limit 0.15 --daily-limit 2.00\n\n# Check current thread & daily spend\ntucana-code budget status --currency MXN --thread-id session-1\n\n# Record token usage; triggers kill-switch once the cap is reached\ntucana-code budget record --model claude-sonnet-5-5 --input 100000 --output 20000 --thread-id session-1 --currency MXN\n\n# Once tripped, even benign commands are halted cleanly\ntucana-code guard check --thread-id session-1 --currency MXN -- git status\n# -> BLOCK (kill_switch, conf=1, 0ms): Kill-switch: thread spend MX$... reached limit MX$...\n\n# Summarize local traces or clear limits when ready\ntucana-code trace summary --currency MXN\ntucana-code budget set --thread-limit none --daily-limit none\n```\n\nEvery guardrail verdict is appended locally to `~/.tucana-code/traces/decision-trace.jsonl` (conforming to `schemas/decision-trace.schema.json`` v0.1.0`).\n\nOpen those traces in [**Tucana Lab (`aisona-lab/tucana-lab`)**](https://github.com/aisona-lab/tucana-lab) to:\n\n1. **Measure real calibration** (10-bin Reliability Diagram, Expected Calibration Error, Brier score).\n2. **Label only high-uncertainty edge cases** via keyboard-first Active Learning (`feedback.jsonl` , keeping`decision-trace.jsonl` strictly immutable).\n3. **Export `policy-calibration.json`** straight back to`~/.tucana-code/policy-calibration.json` so`tucana-code` improves`<1 ms` decisions instantly —**with zero model training required** .\n4. **Export clean SFT JSONL datasets** whenever you are ready to fine-tune your own local Qwen / Llama / Mistral classifier.\n\n- **Zero telemetry:** 100% free of PostHog, Axiom, Clerk, analytics beacons, or cloud relay dependencies. Everything lives under`~/.tucana-code/` .\n- **Fast hot path:**`tucana-code init` writes`tucana-code hook claude-pretool` (or`node <resolved-bin.mjs> hook claude-pretool` ) — never`npx` inside`PreToolUse` .\n- **MIT Open Source:** Licensed under the[MIT License](https://github.com/aisona-lab/tucana-code/blob/main/LICENSE) .\n\n```\ngit clone https://github.com/aisona-lab/tucana-code.git\ncd tucana-code\ncorepack pnpm install\ncorepack pnpm run typecheck\ncorepack pnpm --filter @tucana/guardian test\ncorepack pnpm --filter tucana-code build\n```\n\nVerify shared schema parity with `tucana-lab`:\n\n```\nnode scripts/verify-contract-parity.mjs\n```\n\n  If **Tucana Code** saved a production directory or an unexpected API bill, consider giving the repo a ⭐\n\n  and exploring [**aisona-lab/tucana-lab**](https://github.com/aisona-lab/tucana-lab) for visual calibration & Active Learning.", "url": "https://wpnews.pro/news/the-local-first-safety-and-cost-layer-for-your-autonomous-agents", "canonical_source": "https://github.com/aisona-lab/tucana-code", "published_at": "2026-12-02 10:07:30+00:00", "updated_at": "2026-12-02 10:15:42.926563+00:00", "lang": "en", "topics": ["ai-agents", "ai-safety", "ai-tools", "developer-tools"], "entities": ["Tucana Code", "Aisona Lab", "Claude Code", "Codex", "OpenCode", "Gemini CLI", "Node.js", "tucana-lab"], "also_reported_by": [], "takeaway": "Tucana Code v0.1.0 registers a <1 ms, $0, fully offline PreToolUse hook that deterministically allows safe commands like git status, blocks destructive ones like rm -rf /, and escalates gray-zone commands such as npm run deploy:staging, with spend caps set in ~/.tucana-code/budget.json.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/the-local-first-safety-and-cost-layer-for-your-autonomous-agents", "markdown": "https://wpnews.pro/news/the-local-first-safety-and-cost-layer-for-your-autonomous-agents.md", "text": "https://wpnews.pro/news/the-local-first-safety-and-cost-layer-for-your-autonomous-agents.txt", "jsonld": "https://wpnews.pro/news/the-local-first-safety-and-cost-layer-for-your-autonomous-agents.jsonld"}}